Package de.tilman_neumann.jml.base
Class BigIntPoly
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
java.util.ArrayList<java.math.BigInteger>
de.tilman_neumann.jml.base.BigIntPoly
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<java.math.BigInteger>,java.util.Collection<java.math.BigInteger>,java.util.List<java.math.BigInteger>,java.util.RandomAccess
public class BigIntPoly
extends java.util.ArrayList<java.math.BigInteger>
A simple integer polynomial implementation, once inspired by http://www.strw.leidenuniv.nl/~mathar/progs/FI/oeis_8java.html
(now dead link, sorry)
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Constructor Summary
Constructors Constructor Description BigIntPoly(int n)Constructor for an empty polynomial with initial capacity n. -
Method Summary
Modifier and Type Method Description java.math.BigIntegerat(int n)Retrieve a polynomial coefficient.intdegree()BigIntPolymultiply(BigIntPoly val)Multiply by another polynomial.java.math.BigIntegerset(int n, java.math.BigInteger value)Set a polynomial coefficient.Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, size, sort, spliterator, subList, toArray, toArray, trimToSizeMethods inherited from class java.util.AbstractCollection
containsAll, toStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArrayMethods inherited from interface java.util.List
containsAll
-
Constructor Details
-
BigIntPoly
public BigIntPoly(int n)Constructor for an empty polynomial with initial capacity n.- Parameters:
n-
-
-
Method Details
-
set
public java.math.BigInteger set(int n, java.math.BigInteger value)Set a polynomial coefficient.- Specified by:
setin interfacejava.util.List<java.math.BigInteger>- Overrides:
setin classjava.util.ArrayList<java.math.BigInteger>- Parameters:
n- the zero-based index of the coefficient. n=0 for the constant term. If the polynomial has not yet the degree to need this coefficient, the intermediate coefficients are implicitly set to zero.value- the new value of the coefficient.
-
multiply
Multiply by another polynomial.- Parameters:
val- the other polynomial- Returns:
- the product of this with the other polynomial
-
at
public java.math.BigInteger at(int n)Retrieve a polynomial coefficient.- Parameters:
n- the zero-based index of the coefficient. n=0 for the constant term.- Returns:
- the polynomial coefficient in front of x^n.
-
degree
public int degree()- Returns:
- the polynomial degree.
-