/*=============================================================================

    This file is part of FLINT.

    FLINT is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    FLINT is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with FLINT; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

=============================================================================*/
/******************************************************************************

    Copyright (C) 2011 Fredrik Johansson

******************************************************************************/

*******************************************************************************

    Factoring integers 

    An integer may be represented in factored form using the 
    \code{fmpz_factor_t} data structure. This consists of two \code{fmpz} 
    vectors representing bases and exponents, respectively. Canonically, 
    the bases will be prime numbers sorted in ascending order and the 
    exponents will be positive.

    A separate \code{int} field holds the sign, which may be $-1$, $0$ or $1$.

*******************************************************************************

void fmpz_factor_init(fmpz_factor_t factor)

    Initialises an \code{fmpz_factor_t} structure.

void fmpz_factor_clear(fmpz_factor_t factor)

    Clears an \code{fmpz_factor_t} structure.

void fmpz_factor(fmpz_factor_t factor, const fmpz_t n)

    Factors $n$ into prime numbers. If $n$ is zero or negative, the
    sign field of the \code{factor} object will be set accordingly.

    This currently only uses trial division, falling back to \code{n_factor()}
    as soon as the number shrinks to a single limb.

void fmpz_factor_expand_iterative(fmpz_t n, const fmpz_factor_t factor)

    Evaluates an integer in factored form back to an \code{fmpz_t}.

    This currently exponentiates the bases separately and multiplies
    them together one by one, although much more efficient algorithms
    exist. 

