Package cc.redberry.rings
Class FactorDecomposition<E>
java.lang.Object
cc.redberry.rings.FactorDecomposition<E>
- All Implemented Interfaces:
Stringifiable<E>
,Serializable
,Iterable<E>
- Direct Known Subclasses:
PolynomialFactorDecomposition
public class FactorDecomposition<E> extends Object implements Iterable<E>, Stringifiable<E>, Serializable
Factor decomposition of element. Unit coefficient of decomposition is stored in
unit
, factors returned by
get(int)
are non-units. This class is mutable.
Iterable specification provides iterator over
non-unit factors only; to iterate over all factors including the constant factor use iterableWithUnit()
- Since:
- 2.2
- Author:
- Stanislav Poslavsky
- See Also:
- Serialized Form
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description FactorDecomposition<E>
addAll(FactorDecomposition<E> other)
add all factors from otherFactorDecomposition<E>
addFactor(E factor, int exponent)
add another factorFactorDecomposition<E>
addUnit(E unit)
add another unit factorFactorDecomposition<E>
addUnit(E unit, int exponent)
add another unit factorFactorDecomposition<E>
apply(Function<E,E> mapper)
FactorDecomposition<E>
applyConstantFactor()
Raise all factors to its corresponding exponentsFactorDecomposition<E>
applyExponents()
Raise all factors to its corresponding exponentsFactorDecomposition<E>
canonical()
Sort factors.FactorDecomposition<E>
clone()
FactorDecomposition<E>
dropExponents()
Set all exponents to oneFactorDecomposition<E>
dropFactor(int i)
Remove specified factorFactorDecomposition<E>
dropUnit()
Drops constant factor from this (new instance returned)static <E> FactorDecomposition<E>
empty(Ring<E> ring)
Empty factorizationboolean
equals(Object o)
E
get(int i)
Returns i-th factorint
getExponent(int i)
Exponent of i-th factorint
hashCode()
boolean
isTrivial()
Whether this is a trivial factorization (contains only one factor)boolean
isUnit(E element)
Iterable<E>
iterableWithUnit()
Iterator over all factors including a unit oneIterator<E>
iterator()
<R> FactorDecomposition<R>
mapTo(Ring<R> othRing, Function<E,R> mapper)
E
multiply()
Multiply factorsE
multiplyIgnoreExponents()
Multiply with no account for exponentsstatic <E> FactorDecomposition<E>
of(Ring<E> ring, E... factors)
Factor decomposition with specified factors and exponentsstatic <E> FactorDecomposition<E>
of(Ring<E> ring, E unit, List<E> factors, gnu.trove.list.array.TIntArrayList exponents)
Factor decomposition with specified factors and exponentsstatic <E> FactorDecomposition<E>
of(Ring<E> ring, Collection<E> factors)
Factor decomposition with specified factors and exponentsvoid
raiseExponents(long val)
Multiply each exponent by a given factorFactorDecomposition<E>
setUnit(E unit)
Sets the unit factorint
size()
Number of non-constant factorsE
squareFreePart()
Square-free partStream<E>
stream()
Stream of all factorsStream<E>
streamWithoutUnit()
Stream of all factors exceptunit
int
sumExponents()
Sum all exponentsE[]
toArrayWithoutUnit()
Array of factors without constant factorE[]
toArrayWithUnit()
Array of factors without constant factorString
toString()
String
toString(IStringifier<E> stringifier)
convert this to string with the use of stringifierstatic <E> FactorDecomposition<E>
unit(Ring<E> ring, E unit)
Unit factorizationMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
ring
The ring -
unit
unit coefficient -
factors
factors -
exponents
public final gnu.trove.list.array.TIntArrayList exponentsexponents
-
-
Constructor Details
-
FactorDecomposition
-
-
Method Details
-
iterator
-
iterableWithUnit
Iterator over all factors including a unit one- Returns:
- iterator over all factors including a unit one
-
isUnit
-
get
Returns i-th factor -
getExponent
public int getExponent(int i)Exponent of i-th factor -
size
public int size()Number of non-constant factors -
isTrivial
public boolean isTrivial()Whether this is a trivial factorization (contains only one factor) -
sumExponents
public int sumExponents()Sum all exponents -
raiseExponents
public void raiseExponents(long val)Multiply each exponent by a given factor -
setUnit
Sets the unit factor -
addUnit
add another unit factor -
addUnit
add another unit factor -
addFactor
add another factor -
addAll
add all factors from other -
applyExponents
Raise all factors to its corresponding exponents -
applyConstantFactor
Raise all factors to its corresponding exponents -
dropExponents
Set all exponents to one -
dropUnit
Drops constant factor from this (new instance returned) -
dropFactor
Remove specified factor -
stream
Stream of all factors -
streamWithoutUnit
Stream of all factors exceptunit
-
toArrayWithoutUnit
Array of factors without constant factor -
toArrayWithUnit
Array of factors without constant factor -
multiply
Multiply factors -
multiplyIgnoreExponents
Multiply with no account for exponents -
squareFreePart
Square-free part -
canonical
Sort factors. -
mapTo
-
apply
-
toString
Description copied from interface:Stringifiable
convert this to string with the use of stringifier- Specified by:
toString
in interfaceStringifiable<E>
-
toString
-
equals
-
hashCode
public int hashCode() -
clone
-
unit
Unit factorization -
empty
Empty factorization -
of
public static <E> FactorDecomposition<E> of(Ring<E> ring, E unit, List<E> factors, gnu.trove.list.array.TIntArrayList exponents)Factor decomposition with specified factors and exponents- Parameters:
ring
- the ringunit
- the unit coefficientfactors
- the factorsexponents
- the exponents
-
of
Factor decomposition with specified factors and exponents- Parameters:
ring
- the ringfactors
- factors
-
of
Factor decomposition with specified factors and exponents- Parameters:
ring
- the ringfactors
- factors
-