ch.javasoft.smx.impl
Class DefaultBigIntegerMatrix

java.lang.Object
  extended by ch.javasoft.smx.impl.DefaultBigIntegerMatrix
All Implemented Interfaces:
BigIntegerMatrix, MatrixBase<BigInteger>, ReadableBigIntegerMatrix<BigInteger>, ReadableBigIntegerRationalMatrix<BigInteger>, ReadableDoubleMatrix<BigInteger>, ReadableMatrix<BigInteger>, WritableBigIntegerMatrix<BigInteger>, WritableIntMatrix<BigInteger>, WritableLongMatrix<BigInteger>, WritableMatrix<BigInteger>, Cloneable

public class DefaultBigIntegerMatrix
extends Object
implements BigIntegerMatrix

The DefaultBigIntegerMatrix is the default implementation of BigIntegerMatrix. It contains a 1-dimensional array with all the matrix values.


Constructor Summary
DefaultBigIntegerMatrix(BigInteger[][] values, boolean rowsInDim1)
          Initializes the matrix from a 2-dim BigInteger array.
DefaultBigIntegerMatrix(BigInteger[] values, int rowCount, int columnCount)
           
DefaultBigIntegerMatrix(int rowCount, int colCount)
           
DefaultBigIntegerMatrix(ReadableBigIntegerMatrix mx)
           
 
Method Summary
 void add(int row, int col, BigInteger value)
           
 void add(int row, int col, int value)
           
 void add(int row, int col, long value)
           
 void addRowToOtherRow(int srcRow, BigInteger srcFactor, int dstRow, BigInteger dstFactor)
           
 void addRowToOtherRow(int srcRow, int srcFactor, int dstRow, int dstFactor)
           
 void addRowToOtherRow(int srcRow, long srcFactor, int dstRow, long dstFactor)
           
 DefaultBigIntegerMatrix clone()
           
static DefaultBigIntegerMatrix diag(BigInteger[] values)
           
static DefaultBigIntegerMatrix diag(BigInteger value, int len)
           
 boolean equals(Object obj)
           
 BigFraction getBigFractionValueAt(int row, int col)
           
 BigInteger[] getBigIntegerColumn(int col)
           
static BigInteger[] getBigIntegerColumn(ReadableBigIntegerMatrix mx, int col)
           
 BigInteger[][] getBigIntegerColumns()
           
static BigInteger[][] getBigIntegerColumns(ReadableBigIntegerMatrix mx)
           
 BigInteger getBigIntegerDenominatorAt(int row, int col)
           
 BigInteger getBigIntegerNumeratorAt(int row, int col)
           
 BigInteger[] getBigIntegerRow(int row)
           
static BigInteger[] getBigIntegerRow(ReadableBigIntegerMatrix mx, int row)
           
 BigInteger[][] getBigIntegerRows()
           
static BigInteger[][] getBigIntegerRows(ReadableBigIntegerMatrix mx)
           
 BigInteger getBigIntegerValueAt(int row, int col)
           
 int getColumnCount()
           
 double[] getDoubleColumn(int col)
           
 double[][] getDoubleColumns()
           
 double[] getDoubleRow(int row)
           
 double[][] getDoubleRows()
           
 double getDoubleValueAt(int row, int col)
           
 MatrixOperations<BigInteger> getMatrixOperations()
           
 BigIntegerOperations getNumberOperations()
           
 BigInteger[][] getNumberRows()
           
 BigInteger getNumberValueAt(int row, int col)
           
 int getRowCount()
           
 int getSignumAt(int row, int col)
           
 int hashCode()
           
static DefaultBigIntegerMatrix identity(int len)
           
 void multiply(int row, int col, BigInteger factor)
           
 void multiply(int row, int col, int factor)
           
 void multiply(int row, int col, long factor)
           
 void multiplyRow(int row, BigInteger factor)
           
 void multiplyRow(int row, int factor)
           
 void multiplyRow(int row, long factor)
           
 void negate(int row, int col)
           
 DefaultBigIntegerMatrix newInstance(BigInteger[][] data, boolean rowsInDim1)
           
 DefaultBigIntegerMatrix newInstance(int rows, int cols)
           
 void setValueAt(int row, int col, BigInteger value)
           
 void setValueAt(int row, int col, int value)
           
 void setValueAt(int row, int col, Integer value)
           
 void setValueAt(int row, int col, long value)
           
 void setValueAt(int row, int col, Long value)
           
 BigIntegerMatrix subBigIntegerMatrix(int rowStart, int rowEnd, int colStart, int colEnd)
           
 BigIntegerRationalMatrix subBigIntegerRationalMatrix(int rowStart, int rowEnd, int colStart, int colEnd)
           
 DoubleMatrix subDoubleMatrix(int rowStart, int rowEnd, int colStart, int colEnd)
           
 void swapColumns(int colA, int colB)
           
 void swapRows(int rowA, int rowB)
           
 void toArray(BigInteger[] array)
           
 void toArray(double[] array)
           
 void toArray(long[] array)
           
static void toArray(ReadableLongMatrix mx, long[] array)
           
 BigInteger[] toBigIntegerArray()
           
 BigIntegerMatrix toBigIntegerMatrix(boolean enforceNewInstance)
           
 BigIntegerRationalMatrix toBigIntegerRationalMatrix(boolean enforceNewInstance)
           
 double[] toDoubleArray()
           
 DoubleMatrix toDoubleMatrix(boolean enforceNewInstance)
           
 long[] toLongArray()
           
 String toMultilineString()
           
static String toMultilineString(ReadableBigIntegerMatrix mx)
           
 BigIntegerMatrix toReadableMatrix(boolean enforceNewInstance)
           
 String toString()
           
static String toString(ReadableBigIntegerMatrix mx)
           
protected static String toString(ReadableBigIntegerMatrix mx, String prefix, String postfix, String rowPrefix, String rowPostfix, String rowSeparator, String colPrefix, String colPostfix, String colSeparator)
           
 BigIntegerMatrix toWritableMatrix(boolean enforceNewInstance)
           
 DefaultBigIntegerMatrix transpose()
           
 void writeTo(OutputStream out)
           
static void writeTo(OutputStream out, ReadableBigIntegerMatrix mx)
           
protected static void writeTo(PrintWriter writer, ReadableBigIntegerMatrix mx, String prefix, String postfix, String rowPrefix, String rowPostfix, String rowSeparator, String colPrefix, String colPostfix, String colSeparator)
           
 void writeTo(Writer writer)
           
static void writeTo(Writer writer, ReadableBigIntegerMatrix mx)
           
 void writeToMultiline(OutputStream out)
           
static void writeToMultiline(OutputStream out, ReadableBigIntegerMatrix mx)
           
 void writeToMultiline(Writer writer)
           
static void writeToMultiline(Writer writer, ReadableBigIntegerMatrix mx)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultBigIntegerMatrix

public DefaultBigIntegerMatrix(int rowCount,
                               int colCount)

DefaultBigIntegerMatrix

public DefaultBigIntegerMatrix(BigInteger[] values,
                               int rowCount,
                               int columnCount)

DefaultBigIntegerMatrix

public DefaultBigIntegerMatrix(BigInteger[][] values,
                               boolean rowsInDim1)
Initializes the matrix from a 2-dim BigInteger array. The resulting rows relate to the first dimension if rowsInDim1 is true, or to the second dimension otherwise. If the second dimension has different lengths, the maximum value is taken, missing values are initialized with 0.

Parameters:
values - The 2-dim BigInteger array with the source values
rowsInDim1 - If true, the 1st dimension will become rows in the resulting DefaultDoubleMatrix, the columns relate to the 2nd dimension. If false, it is vice versa.

DefaultBigIntegerMatrix

public DefaultBigIntegerMatrix(ReadableBigIntegerMatrix mx)
Method Detail

diag

public static DefaultBigIntegerMatrix diag(BigInteger[] values)

diag

public static DefaultBigIntegerMatrix diag(BigInteger value,
                                           int len)

identity

public static DefaultBigIntegerMatrix identity(int len)

getNumberOperations

public BigIntegerOperations getNumberOperations()
Specified by:
getNumberOperations in interface MatrixBase<BigInteger>

getMatrixOperations

public MatrixOperations<BigInteger> getMatrixOperations()
Specified by:
getMatrixOperations in interface MatrixBase<BigInteger>

getSignumAt

public int getSignumAt(int row,
                       int col)
Specified by:
getSignumAt in interface ReadableMatrix<BigInteger>

getBigIntegerNumeratorAt

public BigInteger getBigIntegerNumeratorAt(int row,
                                           int col)
Specified by:
getBigIntegerNumeratorAt in interface ReadableBigIntegerRationalMatrix<BigInteger>

getBigIntegerDenominatorAt

public BigInteger getBigIntegerDenominatorAt(int row,
                                             int col)
Specified by:
getBigIntegerDenominatorAt in interface ReadableBigIntegerRationalMatrix<BigInteger>

getDoubleValueAt

public double getDoubleValueAt(int row,
                               int col)
Specified by:
getDoubleValueAt in interface ReadableDoubleMatrix<BigInteger>

getBigFractionValueAt

public BigFraction getBigFractionValueAt(int row,
                                         int col)
Specified by:
getBigFractionValueAt in interface ReadableBigIntegerRationalMatrix<BigInteger>

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface MatrixBase<BigInteger>

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface MatrixBase<BigInteger>

setValueAt

public void setValueAt(int row,
                       int col,
                       BigInteger value)
Specified by:
setValueAt in interface WritableBigIntegerMatrix<BigInteger>
Specified by:
setValueAt in interface WritableMatrix<BigInteger>

setValueAt

public void setValueAt(int row,
                       int col,
                       int value)
Specified by:
setValueAt in interface WritableIntMatrix<BigInteger>

setValueAt

public void setValueAt(int row,
                       int col,
                       long value)
Specified by:
setValueAt in interface WritableLongMatrix<BigInteger>

setValueAt

public void setValueAt(int row,
                       int col,
                       Integer value)

setValueAt

public void setValueAt(int row,
                       int col,
                       Long value)

swapRows

public void swapRows(int rowA,
                     int rowB)
Specified by:
swapRows in interface WritableMatrix<BigInteger>

swapColumns

public void swapColumns(int colA,
                        int colB)
Specified by:
swapColumns in interface WritableMatrix<BigInteger>

getNumberValueAt

public BigInteger getNumberValueAt(int row,
                                   int col)
Specified by:
getNumberValueAt in interface ReadableMatrix<BigInteger>

toArray

public void toArray(long[] array)

toArray

public static void toArray(ReadableLongMatrix mx,
                           long[] array)

toDoubleArray

public double[] toDoubleArray()
Specified by:
toDoubleArray in interface ReadableDoubleMatrix<BigInteger>

toLongArray

public long[] toLongArray()

toArray

public void toArray(double[] array)
Specified by:
toArray in interface ReadableDoubleMatrix<BigInteger>

getDoubleColumn

public double[] getDoubleColumn(int col)
Specified by:
getDoubleColumn in interface ReadableDoubleMatrix<BigInteger>

getDoubleColumns

public double[][] getDoubleColumns()
Specified by:
getDoubleColumns in interface ReadableDoubleMatrix<BigInteger>

getDoubleRow

public double[] getDoubleRow(int row)
Specified by:
getDoubleRow in interface ReadableDoubleMatrix<BigInteger>

getDoubleRows

public double[][] getDoubleRows()
Specified by:
getDoubleRows in interface ReadableDoubleMatrix<BigInteger>

getBigIntegerColumn

public BigInteger[] getBigIntegerColumn(int col)
Specified by:
getBigIntegerColumn in interface ReadableBigIntegerMatrix<BigInteger>

getBigIntegerColumn

public static BigInteger[] getBigIntegerColumn(ReadableBigIntegerMatrix mx,
                                               int col)

getBigIntegerRow

public BigInteger[] getBigIntegerRow(int row)
Specified by:
getBigIntegerRow in interface ReadableBigIntegerMatrix<BigInteger>

getBigIntegerRow

public static BigInteger[] getBigIntegerRow(ReadableBigIntegerMatrix mx,
                                            int row)

getBigIntegerColumns

public BigInteger[][] getBigIntegerColumns()
Specified by:
getBigIntegerColumns in interface ReadableBigIntegerMatrix<BigInteger>

getBigIntegerRows

public BigInteger[][] getBigIntegerRows()
Specified by:
getBigIntegerRows in interface ReadableBigIntegerMatrix<BigInteger>

getBigIntegerRows

public static BigInteger[][] getBigIntegerRows(ReadableBigIntegerMatrix mx)

getBigIntegerColumns

public static BigInteger[][] getBigIntegerColumns(ReadableBigIntegerMatrix mx)

getNumberRows

public BigInteger[][] getNumberRows()
Specified by:
getNumberRows in interface ReadableMatrix<BigInteger>

toString

public String toString()
Specified by:
toString in interface MatrixBase<BigInteger>
Overrides:
toString in class Object

writeTo

public void writeTo(Writer writer)
Specified by:
writeTo in interface MatrixBase<BigInteger>

writeTo

public void writeTo(OutputStream out)
Specified by:
writeTo in interface MatrixBase<BigInteger>

toString

public static String toString(ReadableBigIntegerMatrix mx)

writeTo

public static void writeTo(Writer writer,
                           ReadableBigIntegerMatrix mx)

writeTo

public static void writeTo(OutputStream out,
                           ReadableBigIntegerMatrix mx)

toMultilineString

public String toMultilineString()
Specified by:
toMultilineString in interface MatrixBase<BigInteger>

writeToMultiline

public void writeToMultiline(Writer writer)
Specified by:
writeToMultiline in interface MatrixBase<BigInteger>

writeToMultiline

public void writeToMultiline(OutputStream out)
Specified by:
writeToMultiline in interface MatrixBase<BigInteger>

toMultilineString

public static String toMultilineString(ReadableBigIntegerMatrix mx)

writeToMultiline

public static void writeToMultiline(Writer writer,
                                    ReadableBigIntegerMatrix mx)

writeToMultiline

public static void writeToMultiline(OutputStream out,
                                    ReadableBigIntegerMatrix mx)

toString

protected static String toString(ReadableBigIntegerMatrix mx,
                                 String prefix,
                                 String postfix,
                                 String rowPrefix,
                                 String rowPostfix,
                                 String rowSeparator,
                                 String colPrefix,
                                 String colPostfix,
                                 String colSeparator)

writeTo

protected static void writeTo(PrintWriter writer,
                              ReadableBigIntegerMatrix mx,
                              String prefix,
                              String postfix,
                              String rowPrefix,
                              String rowPostfix,
                              String rowSeparator,
                              String colPrefix,
                              String colPostfix,
                              String colSeparator)

clone

public DefaultBigIntegerMatrix clone()
Specified by:
clone in interface BigIntegerMatrix
Specified by:
clone in interface MatrixBase<BigInteger>
Specified by:
clone in interface ReadableMatrix<BigInteger>
Specified by:
clone in interface WritableMatrix<BigInteger>
Overrides:
clone in class Object

newInstance

public DefaultBigIntegerMatrix newInstance(int rows,
                                           int cols)
Specified by:
newInstance in interface BigIntegerMatrix
Specified by:
newInstance in interface MatrixBase<BigInteger>
Specified by:
newInstance in interface ReadableMatrix<BigInteger>
Specified by:
newInstance in interface WritableMatrix<BigInteger>

newInstance

public DefaultBigIntegerMatrix newInstance(BigInteger[][] data,
                                           boolean rowsInDim1)
Specified by:
newInstance in interface BigIntegerMatrix
Specified by:
newInstance in interface MatrixBase<BigInteger>
Specified by:
newInstance in interface ReadableMatrix<BigInteger>
Specified by:
newInstance in interface WritableMatrix<BigInteger>

toBigIntegerMatrix

public BigIntegerMatrix toBigIntegerMatrix(boolean enforceNewInstance)
Specified by:
toBigIntegerMatrix in interface ReadableBigIntegerMatrix<BigInteger>

toWritableMatrix

public BigIntegerMatrix toWritableMatrix(boolean enforceNewInstance)
Specified by:
toWritableMatrix in interface ReadableMatrix<BigInteger>

toReadableMatrix

public BigIntegerMatrix toReadableMatrix(boolean enforceNewInstance)
Specified by:
toReadableMatrix in interface WritableMatrix<BigInteger>

toBigIntegerRationalMatrix

public BigIntegerRationalMatrix toBigIntegerRationalMatrix(boolean enforceNewInstance)
Specified by:
toBigIntegerRationalMatrix in interface ReadableBigIntegerRationalMatrix<BigInteger>

toDoubleMatrix

public DoubleMatrix toDoubleMatrix(boolean enforceNewInstance)
Specified by:
toDoubleMatrix in interface ReadableDoubleMatrix<BigInteger>

addRowToOtherRow

public void addRowToOtherRow(int srcRow,
                             long srcFactor,
                             int dstRow,
                             long dstFactor)
Specified by:
addRowToOtherRow in interface WritableLongMatrix<BigInteger>

addRowToOtherRow

public void addRowToOtherRow(int srcRow,
                             int srcFactor,
                             int dstRow,
                             int dstFactor)
Specified by:
addRowToOtherRow in interface WritableIntMatrix<BigInteger>

addRowToOtherRow

public void addRowToOtherRow(int srcRow,
                             BigInteger srcFactor,
                             int dstRow,
                             BigInteger dstFactor)
Specified by:
addRowToOtherRow in interface WritableBigIntegerMatrix<BigInteger>

add

public void add(int row,
                int col,
                BigInteger value)
Specified by:
add in interface WritableBigIntegerMatrix<BigInteger>

add

public void add(int row,
                int col,
                int value)
Specified by:
add in interface WritableIntMatrix<BigInteger>

add

public void add(int row,
                int col,
                long value)
Specified by:
add in interface WritableLongMatrix<BigInteger>

multiply

public void multiply(int row,
                     int col,
                     int factor)
Specified by:
multiply in interface WritableIntMatrix<BigInteger>

multiply

public void multiply(int row,
                     int col,
                     long factor)
Specified by:
multiply in interface WritableLongMatrix<BigInteger>

multiply

public void multiply(int row,
                     int col,
                     BigInteger factor)
Specified by:
multiply in interface WritableBigIntegerMatrix<BigInteger>

multiplyRow

public void multiplyRow(int row,
                        int factor)
Specified by:
multiplyRow in interface WritableIntMatrix<BigInteger>

multiplyRow

public void multiplyRow(int row,
                        long factor)
Specified by:
multiplyRow in interface WritableLongMatrix<BigInteger>

multiplyRow

public void multiplyRow(int row,
                        BigInteger factor)
Specified by:
multiplyRow in interface WritableBigIntegerMatrix<BigInteger>

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

subBigIntegerMatrix

public BigIntegerMatrix subBigIntegerMatrix(int rowStart,
                                            int rowEnd,
                                            int colStart,
                                            int colEnd)
Specified by:
subBigIntegerMatrix in interface ReadableBigIntegerMatrix<BigInteger>

subBigIntegerRationalMatrix

public BigIntegerRationalMatrix subBigIntegerRationalMatrix(int rowStart,
                                                            int rowEnd,
                                                            int colStart,
                                                            int colEnd)
Specified by:
subBigIntegerRationalMatrix in interface ReadableBigIntegerRationalMatrix<BigInteger>

subDoubleMatrix

public DoubleMatrix subDoubleMatrix(int rowStart,
                                    int rowEnd,
                                    int colStart,
                                    int colEnd)
Specified by:
subDoubleMatrix in interface ReadableDoubleMatrix<BigInteger>

transpose

public DefaultBigIntegerMatrix transpose()
Specified by:
transpose in interface BigIntegerMatrix
Specified by:
transpose in interface MatrixBase<BigInteger>
Specified by:
transpose in interface ReadableMatrix<BigInteger>
Specified by:
transpose in interface WritableMatrix<BigInteger>

toArray

public void toArray(BigInteger[] array)
Specified by:
toArray in interface ReadableBigIntegerMatrix<BigInteger>

toBigIntegerArray

public BigInteger[] toBigIntegerArray()
Specified by:
toBigIntegerArray in interface ReadableBigIntegerMatrix<BigInteger>

getBigIntegerValueAt

public BigInteger getBigIntegerValueAt(int row,
                                       int col)
Specified by:
getBigIntegerValueAt in interface ReadableBigIntegerMatrix<BigInteger>

negate

public void negate(int row,
                   int col)
Specified by:
negate in interface WritableMatrix<BigInteger>