Factorisation
Nemo provides a unified interface to handle factorisations using the Fact
objects. These can only be constructed using the factor function for the respective ring elements. This is best illustrated by an example.
julia> fac = factor(ZZ(-6000361807272228723606))
-1 * 2 * 229^3 * 43669^3 * 3
julia> unit(fac)
-1
julia> -6000361807272228723606 == unit(fac) * prod([ p^e for (p, e) in fac])
true
julia> for (p, e) in fac; println("$p $e"); end
2 1
229 3
43669 3
3 1
julia> 229 in fac
true
julia> fac[229]
3
Basic functionality
Objects of type Fac
are iterable, that is, if a
is an object of type Fac
, then for (p, e) in a
will iterate through all pairs (p, e)
, where p
is a factor and e
the corresponding exponent.
Base.in
— Methodin(a, b::Fac)
Test whether $a$ is a factor of $b$.
Base.getindex
— Methodgetindex(a::Fac, b) -> Int
If $b$ is a factor of $a$, the corresponding exponent is returned. Otherwise an error is thrown.
Base.length
— Methodlength(a::Fac) -> Int
Return the number of factors of $a$, not including the unit.
AbstractAlgebra.unit
— Methodunit(a::Fac{T}) -> T
Return the unit of the factorization.