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.BigInteger
at(int n)
Retrieve a polynomial coefficient.int
degree()
BigIntPoly
multiply(BigIntPoly val)
Multiply by another polynomial.java.math.BigInteger
set(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, trimToSize
Methods inherited from class java.util.AbstractCollection
containsAll, toString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, stream, toArray
Methods 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:
set
in interfacejava.util.List<java.math.BigInteger>
- Overrides:
set
in 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.
-