Package de.tilman_neumann.jml.base
Class BigIntPoly
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<BigInteger>
-
- de.tilman_neumann.jml.base.BigIntPoly
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<BigInteger>
,Collection<BigInteger>
,List<BigInteger>
,RandomAccess
public class BigIntPoly extends ArrayList<BigInteger>
A simple integer polynomial implementation, once inspired by http://www.strw.leidenuniv.nl/~mathar/progs/FI/oeis_8java.html (now dead link, sorry)- Author:
- Tilman Neumann
- 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BigInteger
at(int n)
Retrieve a polynomial coefficient.int
degree()
BigIntPoly
multiply(BigIntPoly val)
Multiply by another polynomial.BigInteger
set(int n, 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
-
-
-
-
Method Detail
-
set
public BigInteger set(int n, BigInteger value)
Set a polynomial coefficient.- Specified by:
set
in interfaceList<BigInteger>
- Overrides:
set
in classArrayList<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
public BigIntPoly multiply(BigIntPoly val)
Multiply by another polynomial.- Parameters:
val
- the other polynomial- Returns:
- the product of this with the other polynomial
-
at
public 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.
-
-