Package de.tilman_neumann.jml.base
Class BigIntTriangle
java.lang.Object
de.tilman_neumann.jml.base.BigIntTriangle
- Direct Known Subclasses:
EgyptianFractionsTriangle
public class BigIntTriangle
extends java.lang.Object
A triangle of integers.
-
Constructor Summary
Constructors Constructor Description BigIntTriangle()Create a triangle without data.BigIntTriangle(int n, java.math.BigInteger init)Creates an initialized number triangle with n rows. -
Method Summary
Modifier and Type Method Description voidaddRow(java.util.ArrayList<java.math.BigInteger> row)java.math.BigIntegerget(int n, int k)Returns the entry T[n,k], with T[1,1] being the very first element.java.util.ArrayList<java.math.BigInteger>getRow(int n)return n.th row, where the first row has index 1.java.math.BigIntegergetRowSum(int n)Returns the sum over all entries of the n.th row, where the first row has index 1.java.util.ArrayList<java.math.BigInteger>getRowSums()voidset(int n, int k, java.math.BigInteger value)Sets the value T[n,k].java.util.ArrayList<java.math.BigInteger>toList()java.lang.StringtoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Constructor Details
-
BigIntTriangle
public BigIntTriangle()Create a triangle without data. Rows may be added with the addRow() method. -
BigIntTriangle
public BigIntTriangle(int n, java.math.BigInteger init)Creates an initialized number triangle with n rows.- Parameters:
n-init- The value with which the triangle entries are initialized.
-
-
Method Details
-
get
public java.math.BigInteger get(int n, int k)Returns the entry T[n,k], with T[1,1] being the very first element.- Parameters:
n-k-- Returns:
- T[n,k]
-
set
public void set(int n, int k, java.math.BigInteger value)Sets the value T[n,k].- Parameters:
n-k-value-
-
addRow
public void addRow(java.util.ArrayList<java.math.BigInteger> row) -
getRow
public java.util.ArrayList<java.math.BigInteger> getRow(int n)return n.th row, where the first row has index 1.- Parameters:
n-- Returns:
- n.th row
-
getRowSum
public java.math.BigInteger getRowSum(int n)Returns the sum over all entries of the n.th row, where the first row has index 1.- Parameters:
n-- Returns:
- the sum over all entries of the n.th row
-
getRowSums
public java.util.ArrayList<java.math.BigInteger> getRowSums()- Returns:
- List of row sums of this triangle.
-
toList
public java.util.ArrayList<java.math.BigInteger> toList()- Returns:
- This triangle converted into a list read by rows. Better suited for OEIS lookups.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-