ch.javasoft.smx.impl
Class DefaultIntRationalMatrix

java.lang.Object
  extended by ch.javasoft.smx.impl.DefaultIntRationalMatrix
All Implemented Interfaces:
IntRationalMatrix, MatrixBase, RationalMatrix, ReadableBigIntegerRationalMatrix, ReadableDoubleMatrix, ReadableIntRationalMatrix, ReadableLongRationalMatrix, ReadableMatrix, WritableIntMatrix, WritableIntRationalMatrix, WritableMatrix, Cloneable

public class DefaultIntRationalMatrix
extends Object
implements IntRationalMatrix

The DefaultIntRationalMatrix is the default implementation of IntRationalMatrix. It contains 2 int-arrays which contain the enumerator and denominator values for the matrix fractional integers.


Constructor Summary
DefaultIntRationalMatrix(int[] numerators, int[] denominators, int rowCount, int columnCount)
           
DefaultIntRationalMatrix(int rowCount, int columnCount)
           
DefaultIntRationalMatrix(ReadableIntRationalMatrix mx)
           
 
Method Summary
 void add(int row, int col, int value)
           
 void add(int row, int col, int numerator, int denominator)
           
 void addRowToOtherRow(int srcRow, int srcFactor, int dstRow, int dstFactor)
           
 void addRowToOtherRow(int srcRow, int srcNumerator, int srcDenominator, int dstRow, int dstNumerator, int dstDenominator)
           
 DefaultIntRationalMatrix clone()
           
static DefaultIntRationalMatrix diag(int[] numerators, int[] denominators)
           
static DefaultIntRationalMatrix diag(int numerator, int denominator, int len)
           
 boolean equals(Object obj)
           
 BigFraction getBigFractionValueAt(int row, int col)
           
 BigInteger getBigIntegerDenominatorAt(int row, int col)
           
 BigInteger getBigIntegerNumeratorAt(int row, int col)
           
 int getColumnCount()
           
 double[] getDoubleColumn(int col)
           
 double[][] getDoubleColumns()
           
 double[] getDoubleRow(int row)
           
 double[][] getDoubleRows()
           
 double getDoubleValueAt(int row, int col)
           
 int getIntDenominatorAt(int row, int col)
           
 int getIntNumeratorAt(int row, int col)
           
 long getLongDenominatorAt(int row, int col)
           
 long getLongNumeratorAt(int row, int col)
           
 MatrixOperations getMatrixOperations()
           
 NumberOperations getNumberOperations()
           
 Number[][] getNumberRows()
           
 Number getNumberValueAt(int row, int col)
           
 int getRowCount()
           
 int getSignumAt(int row, int col)
           
 int hashCode()
           
static DefaultIntRationalMatrix identity(int len)
           
 void multiply(int row, int col, int factor)
           
 void multiply(int row, int col, int numerator, int denominator)
           
 void multiplyRow(int row, int factor)
           
 void multiplyRow(int row, int numerator, int denominator)
           
 void negate(int row, int col)
           
 DefaultIntRationalMatrix newInstance(int rows, int cols)
           
 DefaultIntRationalMatrix newInstance(Number[][] data, boolean rowsInDim1)
           
 boolean reduce()
          Reduce the whole matrix, that is, divide numerators/denominators by their greatest common divisor
 boolean reduceRow(int row)
          Reduce the specified row, that is, divide numerators/denominators by their greatest common divisor
 boolean reduceValueAt(int row, int col)
          Reduce the specified value, that is, divide numerator/denominator by their greatest common divisor
 void setValueAt(int row, int col, int value)
           
 void setValueAt(int row, int col, int numerator, int denominator)
           
 void setValueAt(int row, int col, Number value)
           
 BigIntegerRationalMatrix subBigIntegerRationalMatrix(int rowStart, int rowEnd, int colStart, int colEnd)
           
 DoubleMatrix subDoubleMatrix(int rowStart, int rowEnd, int colStart, int colEnd)
           
 IntRationalMatrix subIntRationalMatrix(int rowStart, int rowEnd, int colStart, int colEnd)
           
 LongRationalMatrix subLongRationalMatrix(int rowStart, int rowEnd, int colStart, int colEnd)
           
 void swapColumns(int colA, int colB)
           
 void swapRows(int rowA, int rowB)
           
 void toArray(double[] array)
           
 BigIntegerRationalMatrix toBigIntegerRationalMatrix(boolean enforceNewInstance)
           
 double[] toDoubleArray()
           
 DoubleMatrix toDoubleMatrix(boolean enforceNewInstance)
           
 IntRationalMatrix toIntRationalMatrix(boolean enforceNewInstance)
           
 LongRationalMatrix toLongRationalMatrix(boolean enforceNewInstance)
           
 String toMultilineString()
           
static String toMultilineString(ReadableIntRationalMatrix mx)
           
 IntRationalMatrix toReadableMatrix(boolean enforceNewInstance)
           
 String toString()
           
static String toString(ReadableIntRationalMatrix mx)
           
protected static String toString(ReadableIntRationalMatrix mx, String prefix, String postfix, String rowPrefix, String rowPostfix, String rowSeparator, String colPrefix, String colPostfix, String colSeparator)
           
 IntRationalMatrix toWritableMatrix(boolean enforceNewInstance)
           
 DefaultIntRationalMatrix transpose()
           
 void writeTo(OutputStream out)
           
static void writeTo(OutputStream out, ReadableIntRationalMatrix mx)
           
protected static void writeTo(PrintWriter writer, ReadableIntRationalMatrix 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, ReadableIntRationalMatrix mx)
           
 void writeToMultiline(OutputStream out)
           
static void writeToMultiline(OutputStream out, ReadableIntRationalMatrix mx)
           
 void writeToMultiline(Writer writer)
           
static void writeToMultiline(Writer writer, ReadableIntRationalMatrix mx)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultIntRationalMatrix

public DefaultIntRationalMatrix(int rowCount,
                                int columnCount)

DefaultIntRationalMatrix

public DefaultIntRationalMatrix(int[] numerators,
                                int[] denominators,
                                int rowCount,
                                int columnCount)

DefaultIntRationalMatrix

public DefaultIntRationalMatrix(ReadableIntRationalMatrix mx)
Method Detail

diag

public static DefaultIntRationalMatrix diag(int[] numerators,
                                            int[] denominators)

diag

public static DefaultIntRationalMatrix diag(int numerator,
                                            int denominator,
                                            int len)

identity

public static DefaultIntRationalMatrix identity(int len)

getNumberOperations

public NumberOperations getNumberOperations()
Specified by:
getNumberOperations in interface MatrixBase

getMatrixOperations

public MatrixOperations getMatrixOperations()
Specified by:
getMatrixOperations in interface MatrixBase

getIntNumeratorAt

public int getIntNumeratorAt(int row,
                             int col)
Specified by:
getIntNumeratorAt in interface ReadableIntRationalMatrix

getIntDenominatorAt

public int getIntDenominatorAt(int row,
                               int col)
Specified by:
getIntDenominatorAt in interface ReadableIntRationalMatrix

getSignumAt

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

getLongNumeratorAt

public long getLongNumeratorAt(int row,
                               int col)
Specified by:
getLongNumeratorAt in interface ReadableLongRationalMatrix

getLongDenominatorAt

public long getLongDenominatorAt(int row,
                                 int col)
Specified by:
getLongDenominatorAt in interface ReadableLongRationalMatrix

getBigIntegerNumeratorAt

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

getBigIntegerDenominatorAt

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

getDoubleValueAt

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

getBigFractionValueAt

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

getRowCount

public int getRowCount()
Specified by:
getRowCount in interface MatrixBase

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface MatrixBase

setValueAt

public void setValueAt(int row,
                       int col,
                       int numerator,
                       int denominator)
Specified by:
setValueAt in interface WritableIntRationalMatrix

setValueAt

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

swapRows

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

swapColumns

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

getNumberValueAt

public Number getNumberValueAt(int row,
                               int col)
Specified by:
getNumberValueAt in interface ReadableMatrix

setValueAt

public void setValueAt(int row,
                       int col,
                       Number value)
Specified by:
setValueAt in interface WritableMatrix

toString

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

writeTo

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

writeTo

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

toString

public static String toString(ReadableIntRationalMatrix mx)

writeTo

public static void writeTo(Writer writer,
                           ReadableIntRationalMatrix mx)

writeTo

public static void writeTo(OutputStream out,
                           ReadableIntRationalMatrix mx)

toMultilineString

public String toMultilineString()
Specified by:
toMultilineString in interface MatrixBase

writeToMultiline

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

writeToMultiline

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

toMultilineString

public static String toMultilineString(ReadableIntRationalMatrix mx)

writeToMultiline

public static void writeToMultiline(Writer writer,
                                    ReadableIntRationalMatrix mx)

writeToMultiline

public static void writeToMultiline(OutputStream out,
                                    ReadableIntRationalMatrix mx)

toString

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

writeTo

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

clone

public DefaultIntRationalMatrix clone()
Specified by:
clone in interface IntRationalMatrix
Specified by:
clone in interface MatrixBase
Specified by:
clone in interface ReadableMatrix
Specified by:
clone in interface WritableMatrix
Overrides:
clone in class Object

newInstance

public DefaultIntRationalMatrix newInstance(int rows,
                                            int cols)
Specified by:
newInstance in interface IntRationalMatrix
Specified by:
newInstance in interface MatrixBase
Specified by:
newInstance in interface ReadableMatrix
Specified by:
newInstance in interface WritableMatrix

newInstance

public DefaultIntRationalMatrix newInstance(Number[][] data,
                                            boolean rowsInDim1)
Specified by:
newInstance in interface IntRationalMatrix
Specified by:
newInstance in interface MatrixBase
Specified by:
newInstance in interface ReadableMatrix
Specified by:
newInstance in interface WritableMatrix

toIntRationalMatrix

public IntRationalMatrix toIntRationalMatrix(boolean enforceNewInstance)
Specified by:
toIntRationalMatrix in interface ReadableIntRationalMatrix

toWritableMatrix

public IntRationalMatrix toWritableMatrix(boolean enforceNewInstance)
Specified by:
toWritableMatrix in interface ReadableMatrix

toReadableMatrix

public IntRationalMatrix toReadableMatrix(boolean enforceNewInstance)
Specified by:
toReadableMatrix in interface WritableMatrix

toDoubleMatrix

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

toLongRationalMatrix

public LongRationalMatrix toLongRationalMatrix(boolean enforceNewInstance)
Specified by:
toLongRationalMatrix in interface ReadableLongRationalMatrix

toBigIntegerRationalMatrix

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

toDoubleArray

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

toArray

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

getDoubleColumn

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

getDoubleColumns

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

getDoubleRow

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

getDoubleRows

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

getNumberRows

public Number[][] getNumberRows()
Specified by:
getNumberRows in interface ReadableMatrix

addRowToOtherRow

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

addRowToOtherRow

public void addRowToOtherRow(int srcRow,
                             int srcNumerator,
                             int srcDenominator,
                             int dstRow,
                             int dstNumerator,
                             int dstDenominator)
Specified by:
addRowToOtherRow in interface WritableIntRationalMatrix

add

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

add

public void add(int row,
                int col,
                int numerator,
                int denominator)
Specified by:
add in interface WritableIntRationalMatrix

multiply

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

multiply

public void multiply(int row,
                     int col,
                     int numerator,
                     int denominator)
Specified by:
multiply in interface WritableIntRationalMatrix

multiplyRow

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

multiplyRow

public void multiplyRow(int row,
                        int numerator,
                        int denominator)
Specified by:
multiplyRow in interface WritableIntRationalMatrix

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

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

subIntRationalMatrix

public IntRationalMatrix subIntRationalMatrix(int rowStart,
                                              int rowEnd,
                                              int colStart,
                                              int colEnd)
Specified by:
subIntRationalMatrix in interface ReadableIntRationalMatrix

subLongRationalMatrix

public LongRationalMatrix subLongRationalMatrix(int rowStart,
                                                int rowEnd,
                                                int colStart,
                                                int colEnd)
Specified by:
subLongRationalMatrix in interface ReadableLongRationalMatrix

subBigIntegerRationalMatrix

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

subDoubleMatrix

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

reduce

public boolean reduce()
Description copied from interface: RationalMatrix
Reduce the whole matrix, that is, divide numerators/denominators by their greatest common divisor

Specified by:
reduce in interface RationalMatrix
Returns:
true if any value has been changed in the matrix

reduceRow

public boolean reduceRow(int row)
Description copied from interface: RationalMatrix
Reduce the specified row, that is, divide numerators/denominators by their greatest common divisor

Specified by:
reduceRow in interface RationalMatrix
Returns:
true if any value has been changed in the given row

reduceValueAt

public boolean reduceValueAt(int row,
                             int col)
Description copied from interface: RationalMatrix
Reduce the specified value, that is, divide numerator/denominator by their greatest common divisor

Specified by:
reduceValueAt in interface RationalMatrix
Returns:
true if the value has been changed

transpose

public DefaultIntRationalMatrix transpose()
Specified by:
transpose in interface IntRationalMatrix
Specified by:
transpose in interface MatrixBase
Specified by:
transpose in interface ReadableMatrix
Specified by:
transpose in interface WritableMatrix

negate

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