org.ojalgo.matrix.jama
Class JamaMatrix

java.lang.Object
  extended by org.ojalgo.matrix.jama.JamaMatrix
All Implemented Interfaces:
Serializable, Access2D<Double>, Basic2D, BasicMatrix, MatrixStore<Double>, PhysicalStore<Double>

public final class JamaMatrix
extends Object
implements BasicMatrix, PhysicalStore<Double>, Serializable

This class adapts JAMA's Matrix to ojAlgo's BasicMatrix and PhysicalStore interfaces.

Author:
apete
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.ojalgo.matrix.BasicMatrix
BasicMatrix.Factory
 
Nested classes/interfaces inherited from interface org.ojalgo.matrix.store.PhysicalStore
PhysicalStore.Factory<N extends Number>
 
Nested classes/interfaces inherited from interface org.ojalgo.matrix.store.MatrixStore
MatrixStore.Builder<N extends Number>
 
Field Summary
static JamaFactory FACTORY
           
 
Constructor Summary
JamaMatrix(BasicMatrix aMtrx)
           
JamaMatrix(MatrixStore<Double> aStore)
           
 
Method Summary
 JamaMatrix add(BasicMatrix aMtrx)
          Adds the elements of aMtrx to the elements of this matrix.
 JamaMatrix add(Number aNmbr)
          Adds aNmbr to the elements of this.
 Double aggregateAll(ChainableAggregator aVisitor)
           
 Double aggregateAll(CollectableAggregator aVisitor)
           
 List<Double> asList()
           
 MatrixStore.Builder<Double> builder()
           
 void caxpy(Double aSclrA, int aColX, int aColY, int aFirstRow)
           column a * x plus y
 JamaMatrix conjugate()
          For real matrices conjugate() and transpose() are identical.
 PhysicalStore<Double> copy()
          Each call must produce a new instance.
 JamaMatrix divide(Number aNmbr)
          Divides the elements of this with aNmbr.
 JamaMatrix divideElements(BasicMatrix aMtrx)
          Divides the elements of this with the elements of aMtrx.
 double doubleValue(int aRow, int aCol)
          Extracts one element of this matrix as a double.
 JamaMatrix enforce(NumberContext aContext)
           
 boolean equals(BasicMatrix aMtrx, NumberContext aCntxt)
           
 boolean equals(MatrixStore<Double> aStore, NumberContext aCntxt)
           
 boolean equals(Object anObject)
           
 void exchangeColumns(int aColA, int aColB)
           
 void exchangeRows(int aRowA, int aRowB)
           
 void fillAll(Double aNmbr)
           
 void fillByMultiplying(MatrixStore<Double> aLeftArg, MatrixStore<Double> aRightArg)
           
 void fillColumn(int aRow, int aCol, Double aNmbr)
           
 void fillDiagonal(int aRow, int aCol, Double aNmbr)
           
 void fillMatching(Access2D<Double> aSource2D)
           
 void fillMatching(Double aLeftArg, BinaryFunction<Double> aFunc, MatrixStore<Double> aRightArg)
           Will replace the elements of [this] with the results of element wise invocation of the input binary funtion:
 void fillMatching(MatrixStore<Double> aLeftArg, BinaryFunction<Double> aFunc, Double aRightArg)
           Will replace the elements of [this] with the results of element wise invocation of the input binary funtion:
 void fillMatching(MatrixStore<Double> aLeftArg, BinaryFunction<Double> aFunc, MatrixStore<Double> aRightArg)
           Will replace the elements of [this] with the results of element wise invocation of the input binary funtion:
 void fillRow(int aRow, int aCol, Double aNmbr)
           
 void flushCache()
          BasicMatrix instances are intended to be immutable.
 Householder<Double> generateHouseholderColumn(int newI, int newIj)
           
 Householder<Double> generateHouseholderRow(int newIj, int newI)
           
 Double get(int aRow, int aCol)
           
 int getColDim()
          The size of this structure in the column-direction/dimension
 JamaMatrix getColumns(int[] someCols)
           
 Scalar<Double> getCondition()
           
 PrimitiveScalar getDeterminant()
           
 List<ComplexNumber> getEigenvalues()
           
 PhysicalStore.Factory<Double> getFactory()
           
 PrimitiveScalar getFrobeniusNorm()
          The Frobenius norm is the square root of the sum of the squares of each element, or the square root of the sum of the square of the singular values.
 int getIndexOfLargestInColumn(int aRow, int aCol)
           
 int getIndexOfLargestInRow(int aRow, int aCol)
           
 Scalar<?> getInfinityNorm()
           
 PrimitiveScalar getKyFanNorm(int k)
           
 int getMinDim()
           
 Scalar<?> getOneNorm()
           
 PrimitiveScalar getOperatorNorm()
          2-norm, max singular value
 int getRank()
          The rank of a matrix is the (maximum) number of linearly independent rows or columns it contains.
 int getRowDim()
          The size of this structure in the row-direction/dimension
 JamaMatrix getRows(int[] someRows)
           
 List<Double> getSingularValues()
           
 PrimitiveScalar getTrace()
          The sum of the diagonal elements.
 PrimitiveScalar getTraceNorm()
           
 PrimitiveScalar getVectorNorm(int aDegree)
          Treats [this] as if it is one dimensional (a vector) and calculates the vector norm.
 int hashCode()
           
 JamaMatrix invert()
           About inverting matrices:
 boolean isAbsolute(int aRow, int aCol)
           
 boolean isEmpty()
          Matrices are either square, tall, fat or empty.
 boolean isFat()
          Matrices are either square, tall, fat or empty.
 boolean isFullRank()
           
 boolean isHermitian()
           
 boolean isReal(int aRow, int aCol)
           
 boolean isScalar()
           
 boolean isSquare()
          Matrices are either square, tall, fat or empty.
 boolean isSymmetric()
           
 boolean isTall()
          Matrices are either square, tall, fat or empty.
 boolean isVector()
           
 boolean isZero(int aRow, int aCol)
           
 void maxpy(Double aSclrA, MatrixStore<Double> aMtrxX)
           matrix a * x plus y
 JamaMatrix mergeColumns(BasicMatrix aMtrx)
          [aMtrx] is appended to the bottom of [this].
 JamaMatrix mergeRows(BasicMatrix aMtrx)
          [aMtrx] is appended to the right side of [this].
 void modifyAll(UnaryFunction<Double> aFunc)
           
 void modifyColumn(int aRow, int aCol, UnaryFunction<Double> aFunc)
           
 void modifyDiagonal(int aRow, int aCol, UnaryFunction<Double> aFunc)
           
 void modifyRow(int aRow, int aCol, UnaryFunction<Double> aFunc)
           
 JamaMatrix multiply(Number aNmbr)
          Multiplies the elements of this matrix with aNmbr.
 JamaMatrix multiplyElements(BasicMatrix aMtrx)
          Multiplies the elements of this matrix with the elements of aMtrx.
 JamaMatrix multiplyLeft(BasicMatrix aMtrx)
          Matrix multiplication: [aMtrx][this]
The column dimension of the left matrix must equal the row dimension of the right matrix.
 JamaMatrix multiplyLeft(MatrixStore<Double> aStore)
           
 JamaMatrix multiplyRight(BasicMatrix aMtrx)
          Matrix multiplication: [this][aMtrx]
The column dimension of the left matrix must equal the row dimension of the right matrix.
 JamaMatrix multiplyRight(MatrixStore<Double> aStore)
           
 PrimitiveScalar multiplyVectors(BasicMatrix aVctr)
          Assumes that both [this] and [aVctr] have row or column dimension, doesn't matter which, equal to 1.
 JamaMatrix negate()
           
 void raxpy(Double aSclrA, int aRowX, int aRowY, int aFirstCol)
           row a * x plus y
 JamaMatrix round(NumberContext aCntxt)
           
 void set(int aRow, int aCol, double aNmbr)
           
 void set(int aRow, int aCol, Double aNmbr)
           
 JamaMatrix set(int aRow, int aCol, Number aNmbr)
          Do not use this method to populate large dense matrices! Only use it to change a few (a small number) of elements.
 int size()
           
 JamaMatrix solve(BasicMatrix aRHS)
           This method solves a system of linear equations: [this][X]=[aRHS].
 void substituteBackwards(Access2D<Double> aBody, boolean someAssumeOne, boolean someTransposed)
           
 void substituteForwards(Access2D<Double> aBody, boolean someAssumeOne, boolean someTransposed)
           
 JamaMatrix subtract(BasicMatrix aMtrx)
          Subtracts the elements of aMtrx from the elements of this matrix.
 JamaMatrix subtract(Number aNmbr)
          Subtracts aNmbr from the elements of this matrix.
 BigDecimal toBigDecimal(int aRow, int aCol)
          Extracts one element of this matrix as a BigDecimal.
 PhysicalStore<BigDecimal> toBigStore()
          Must be a copy that is safe to modify.
 ComplexNumber toComplexNumber(int aRow, int aCol)
          Extracts one element of this matrix as a ComplexNumber.
 PhysicalStore<ComplexNumber> toComplexStore()
          Must be a copy that is safe to modify.
 List<BasicMatrix> toListOfColumns()
           
 List<Double> toListOfElements()
          It is also possible to call BasicMatrix.toBigStore(), BasicMatrix.toComplexStore() or BasicMatrix.toPrimitiveStore() and then PhysicalStore.asList().
 List<BasicMatrix> toListOfRows()
           
 JamaMatrix toPrimitiveStore()
          Must be a copy that is safe to modify.
 PrimitiveScalar toScalar(int aRow, int aCol)
          Extracts one element of this matrix as a Scalar.
 String toString()
           
 String toString(int aRow, int aCol)
           
 void transformLeft(Householder<Double> aTransf, int aFirstCol)
           
 void transformLeft(Rotation<Double> aTransf)
           As in MatrixStore.multiplyLeft(MatrixStore) where the left/parameter matrix is a plane rotation.
 void transformRight(Householder<Double> aTransf, int aFirstRow)
           
 void transformRight(Rotation<Double> aTransf)
           As in MatrixStore.multiplyRight(MatrixStore) where the right/parameter matrix is a plane rotation.
 JamaMatrix transpose()
          Transposes this matrix.
 void update(int[] someRows, int[] someColumns, JamaMatrix aMtrx)
           
 void update(int[] someRows, int aFirstCol, int aColCount, JamaMatrix aMtrx)
           
 void update(int aFirstRow, int aRowCount, int[] someColumns, JamaMatrix aMtrx)
           
 void update(int aFirstRow, int aRowCount, int aFirstCol, int aColCount, JamaMatrix aMtrx)
           
 void update(int aRow, int aCol, Number aNmbr)
           
 void visitAll(AggregatorFunction<Double> aVisitor)
           
 void visitColumn(int aRow, int aCol, AggregatorFunction<Double> aVisitor)
           
 void visitDiagonal(int aRow, int aCol, AggregatorFunction<Double> aVisitor)
           
 void visitRow(int aRow, int aCol, AggregatorFunction<Double> aVisitor)
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FACTORY

public static final JamaFactory FACTORY
Constructor Detail

JamaMatrix

public JamaMatrix(BasicMatrix aMtrx)

JamaMatrix

public JamaMatrix(MatrixStore<Double> aStore)
Method Detail

add

public JamaMatrix add(BasicMatrix aMtrx)
Description copied from interface: BasicMatrix
Adds the elements of aMtrx to the elements of this matrix. The matrices must have equal dimensions.

Specified by:
add in interface BasicMatrix
Parameters:
aMtrx - What to add.
Returns:
A new matrix whos elements are the sum of this' and aMtrx'.

add

public JamaMatrix add(Number aNmbr)
Description copied from interface: BasicMatrix
Adds aNmbr to the elements of this.

Specified by:
add in interface BasicMatrix
Parameters:
aNmbr - What to add
Returns:
A new matrix whos elements are the sum of this' elements and aNmbr.

aggregateAll

public Double aggregateAll(ChainableAggregator aVisitor)
Specified by:
aggregateAll in interface MatrixStore<Double>

aggregateAll

public Double aggregateAll(CollectableAggregator aVisitor)
Specified by:
aggregateAll in interface MatrixStore<Double>

asList

public List<Double> asList()
Specified by:
asList in interface PhysicalStore<Double>
Returns:
The elements of the physical store as a fixed size (1 dimensional) list. The elements may be accessed either row or colomn major.

builder

public final MatrixStore.Builder<Double> builder()
Specified by:
builder in interface MatrixStore<Double>

caxpy

public void caxpy(Double aSclrA,
                  int aColX,
                  int aColY,
                  int aFirstRow)
Description copied from interface: PhysicalStore

column a * x plus y

[this(*,aColY)] = aSclrA [this(*,aColX)] + [this(*,aColY)]

Specified by:
caxpy in interface PhysicalStore<Double>

conjugate

public JamaMatrix conjugate()
Description copied from interface: BasicMatrix
For real matrices conjugate() and transpose() are identical. For complex matrices they're not.

Specified by:
conjugate in interface BasicMatrix
Specified by:
conjugate in interface MatrixStore<Double>
Returns:
The conjugate transpose of this.
See Also:
BasicMatrix.transpose()

copy

public PhysicalStore<Double> copy()
Description copied from interface: MatrixStore
Each call must produce a new instance.

Specified by:
copy in interface MatrixStore<Double>
Returns:
A new PhysicalStore copy.

divide

public JamaMatrix divide(Number aNmbr)
Description copied from interface: BasicMatrix
Divides the elements of this with aNmbr.

Specified by:
divide in interface BasicMatrix
Parameters:
aNmbr - The denominator.
Returns:
A new matrix whos elements are the elements of this divided with aNmbr.

divideElements

public JamaMatrix divideElements(BasicMatrix aMtrx)
Description copied from interface: BasicMatrix
Divides the elements of this with the elements of aMtrx. The matrices must have equal dimensions.

Specified by:
divideElements in interface BasicMatrix
Parameters:
aMtrx - The denominator elements.
Returns:
A new matrix whos elements are the elements of this divided with the elements of aMtrx.

doubleValue

public double doubleValue(int aRow,
                          int aCol)
Extracts one element of this matrix as a double.

Parameters:
aRow - A row index.
aCol - A column index.
Returns:
One matrix element

enforce

public JamaMatrix enforce(NumberContext aContext)
Specified by:
enforce in interface BasicMatrix

equals

public final boolean equals(BasicMatrix aMtrx,
                            NumberContext aCntxt)
Specified by:
equals in interface BasicMatrix
Returns:
true if the frobenius norm of the difference between [this] and [aStore] is zero within the limits of aCntxt.

equals

public boolean equals(MatrixStore<Double> aStore,
                      NumberContext aCntxt)
Specified by:
equals in interface MatrixStore<Double>

equals

public final boolean equals(Object anObject)
Overrides:
equals in class Object

exchangeColumns

public void exchangeColumns(int aColA,
                            int aColB)
Specified by:
exchangeColumns in interface PhysicalStore<Double>

exchangeRows

public void exchangeRows(int aRowA,
                         int aRowB)
Specified by:
exchangeRows in interface PhysicalStore<Double>

fillAll

public void fillAll(Double aNmbr)
Specified by:
fillAll in interface PhysicalStore<Double>

fillByMultiplying

public void fillByMultiplying(MatrixStore<Double> aLeftArg,
                              MatrixStore<Double> aRightArg)
Specified by:
fillByMultiplying in interface PhysicalStore<Double>

fillColumn

public void fillColumn(int aRow,
                       int aCol,
                       Double aNmbr)
Specified by:
fillColumn in interface PhysicalStore<Double>

fillDiagonal

public void fillDiagonal(int aRow,
                         int aCol,
                         Double aNmbr)
Specified by:
fillDiagonal in interface PhysicalStore<Double>

fillMatching

public void fillMatching(Access2D<Double> aSource2D)
Specified by:
fillMatching in interface PhysicalStore<Double>

fillMatching

public void fillMatching(Double aLeftArg,
                         BinaryFunction<Double> aFunc,
                         MatrixStore<Double> aRightArg)
Description copied from interface: PhysicalStore

Will replace the elements of [this] with the results of element wise invocation of the input binary funtion:

this(i,j) = aFunc.invoke(aLeftArg,aRightArg(i,j))

Specified by:
fillMatching in interface PhysicalStore<Double>

fillMatching

public void fillMatching(MatrixStore<Double> aLeftArg,
                         BinaryFunction<Double> aFunc,
                         Double aRightArg)
Description copied from interface: PhysicalStore

Will replace the elements of [this] with the results of element wise invocation of the input binary funtion:

this(i,j) = aFunc.invoke(aLeftArg(i,j),aRightArg))

Specified by:
fillMatching in interface PhysicalStore<Double>

fillMatching

public void fillMatching(MatrixStore<Double> aLeftArg,
                         BinaryFunction<Double> aFunc,
                         MatrixStore<Double> aRightArg)
Description copied from interface: PhysicalStore

Will replace the elements of [this] with the results of element wise invocation of the input binary funtion:

this(i,j) = aFunc.invoke(aLeftArg(i,j),aRightArg(i,j))

Specified by:
fillMatching in interface PhysicalStore<Double>

fillRow

public void fillRow(int aRow,
                    int aCol,
                    Double aNmbr)
Specified by:
fillRow in interface PhysicalStore<Double>

flushCache

public void flushCache()
Description copied from interface: BasicMatrix
BasicMatrix instances are intended to be immutable. If they are it possible to cache (partial) calculation results. Calling this method should flush any cached calculation results.

Specified by:
flushCache in interface BasicMatrix

generateHouseholderColumn

public Householder<Double> generateHouseholderColumn(int newI,
                                                     int newIj)
Specified by:
generateHouseholderColumn in interface PhysicalStore<Double>

generateHouseholderRow

public Householder<Double> generateHouseholderRow(int newIj,
                                                  int newI)
Specified by:
generateHouseholderRow in interface PhysicalStore<Double>

get

public Double get(int aRow,
                  int aCol)

getColDim

public int getColDim()
The size of this structure in the column-direction/dimension

Returns:
The number of columns

getColumns

public JamaMatrix getColumns(int[] someCols)
Specified by:
getColumns in interface BasicMatrix
Parameters:
someCols - An ordered array of column indeces.
Returns:
A matrix with a subset of, reordered, columns.

getCondition

public Scalar<Double> getCondition()
Specified by:
getCondition in interface BasicMatrix

getDeterminant

public PrimitiveScalar getDeterminant()
Specified by:
getDeterminant in interface BasicMatrix
Returns:
The matrix' determinant.

getEigenvalues

public List<ComplexNumber> getEigenvalues()
Specified by:
getEigenvalues in interface BasicMatrix

getFactory

public PhysicalStore.Factory<Double> getFactory()
Specified by:
getFactory in interface MatrixStore<Double>

getFrobeniusNorm

public PrimitiveScalar getFrobeniusNorm()
Description copied from interface: BasicMatrix
The Frobenius norm is the square root of the sum of the squares of each element, or the square root of the sum of the square of the singular values.

Specified by:
getFrobeniusNorm in interface BasicMatrix
Returns:
The matrix' Frobenius norm
See Also:
BasicMatrix.getFrobeniusNorm(), BasicMatrix.getInfinityNorm(), BasicMatrix.getKyFanNorm(int), BasicMatrix.getOneNorm(), BasicMatrix.getOperatorNorm(), BasicMatrix.getTraceNorm(), BasicMatrix.getVectorNorm(int)

getIndexOfLargestInColumn

public int getIndexOfLargestInColumn(int aRow,
                                     int aCol)
Specified by:
getIndexOfLargestInColumn in interface PhysicalStore<Double>

getIndexOfLargestInRow

public int getIndexOfLargestInRow(int aRow,
                                  int aCol)
Specified by:
getIndexOfLargestInRow in interface PhysicalStore<Double>

getInfinityNorm

public Scalar<?> getInfinityNorm()
Specified by:
getInfinityNorm in interface BasicMatrix
Returns:
Max row sum
See Also:
BasicMatrix.getFrobeniusNorm(), BasicMatrix.getInfinityNorm(), BasicMatrix.getKyFanNorm(int), BasicMatrix.getOneNorm(), BasicMatrix.getOperatorNorm(), BasicMatrix.getTraceNorm(), BasicMatrix.getVectorNorm(int)

getKyFanNorm

public PrimitiveScalar getKyFanNorm(int k)
Specified by:
getKyFanNorm in interface BasicMatrix
See Also:
BasicMatrix.getFrobeniusNorm(), BasicMatrix.getInfinityNorm(), BasicMatrix.getKyFanNorm(int), BasicMatrix.getOneNorm(), BasicMatrix.getOperatorNorm(), BasicMatrix.getTraceNorm(), BasicMatrix.getVectorNorm(int)

getMinDim

public int getMinDim()
Specified by:
getMinDim in interface MatrixStore<Double>

getOneNorm

public Scalar<?> getOneNorm()
Specified by:
getOneNorm in interface BasicMatrix
Returns:
Max col sum
See Also:
BasicMatrix.getFrobeniusNorm(), BasicMatrix.getInfinityNorm(), BasicMatrix.getKyFanNorm(int), BasicMatrix.getOneNorm(), BasicMatrix.getOperatorNorm(), BasicMatrix.getTraceNorm(), BasicMatrix.getVectorNorm(int)

getOperatorNorm

public PrimitiveScalar getOperatorNorm()
Description copied from interface: BasicMatrix
2-norm, max singular value

Specified by:
getOperatorNorm in interface BasicMatrix
See Also:
BasicMatrix.getFrobeniusNorm(), BasicMatrix.getInfinityNorm(), BasicMatrix.getKyFanNorm(int), BasicMatrix.getOneNorm(), BasicMatrix.getOperatorNorm(), BasicMatrix.getTraceNorm(), BasicMatrix.getVectorNorm(int)

getRank

public int getRank()
Description copied from interface: BasicMatrix
The rank of a matrix is the (maximum) number of linearly independent rows or columns it contains. It is also equal to the number of nonzero singular values of the matrix.

Specified by:
getRank in interface BasicMatrix
Returns:
The matrix' rank.

getRowDim

public int getRowDim()
The size of this structure in the row-direction/dimension

Returns:
The number of rows

getRows

public JamaMatrix getRows(int[] someRows)
Specified by:
getRows in interface BasicMatrix
Parameters:
someRows - An ordered array of row indeces.
Returns:
A matrix with a subset of, reordered, rows.

getSingularValues

public List<Double> getSingularValues()
Specified by:
getSingularValues in interface BasicMatrix

getTrace

public PrimitiveScalar getTrace()
Description copied from interface: BasicMatrix
The sum of the diagonal elements.

Specified by:
getTrace in interface BasicMatrix
Returns:
The matrix' trace.

getTraceNorm

public PrimitiveScalar getTraceNorm()
Specified by:
getTraceNorm in interface BasicMatrix
See Also:
BasicMatrix.getFrobeniusNorm(), BasicMatrix.getInfinityNorm(), BasicMatrix.getKyFanNorm(int), BasicMatrix.getOneNorm(), BasicMatrix.getOperatorNorm(), BasicMatrix.getTraceNorm(), BasicMatrix.getVectorNorm(int)

getVectorNorm

public PrimitiveScalar getVectorNorm(int aDegree)
Description copied from interface: BasicMatrix
Treats [this] as if it is one dimensional (a vector) and calculates the vector norm. The interface only requires that implementations can handle arguments 0, 1, 2 and Integer.MAX_VALUE.

Specified by:
getVectorNorm in interface BasicMatrix
See Also:
BasicMatrix.getFrobeniusNorm(), BasicMatrix.getInfinityNorm(), BasicMatrix.getKyFanNorm(int), BasicMatrix.getOneNorm(), BasicMatrix.getOperatorNorm(), BasicMatrix.getTraceNorm(), BasicMatrix.getVectorNorm(int)

hashCode

public final int hashCode()
Overrides:
hashCode in class Object

invert

public JamaMatrix invert()
Description copied from interface: BasicMatrix

About inverting matrices:

Specified by:
invert in interface BasicMatrix
Returns:
The "best possible" inverse....

isAbsolute

public boolean isAbsolute(int aRow,
                          int aCol)
Specified by:
isAbsolute in interface MatrixStore<Double>
See Also:
Scalar.isAbsolute()

isEmpty

public boolean isEmpty()
Description copied from interface: BasicMatrix
Matrices are either square, tall, fat or empty. m <= 0 or n <= 0

Specified by:
isEmpty in interface BasicMatrix
Returns:
true if matrix is empty

isFat

public boolean isFat()
Description copied from interface: BasicMatrix
Matrices are either square, tall, fat or empty. 1 <= m < n

Specified by:
isFat in interface BasicMatrix
Returns:
true if matrix is fat

isFullRank

public boolean isFullRank()
Specified by:
isFullRank in interface BasicMatrix
Returns:
true if BasicMatrix.getRank() == min(getRowDim(),getColDim())

isHermitian

public boolean isHermitian()
Specified by:
isHermitian in interface BasicMatrix

isReal

public boolean isReal(int aRow,
                      int aCol)
Specified by:
isReal in interface MatrixStore<Double>
See Also:
Scalar.isReal()

isScalar

public boolean isScalar()
Specified by:
isScalar in interface BasicMatrix
Returns:
true if this is a 1x1 matrix

isSquare

public boolean isSquare()
Description copied from interface: BasicMatrix
Matrices are either square, tall, fat or empty. m = n <> 0

Specified by:
isSquare in interface BasicMatrix
Returns:
true if matrix is square

isSymmetric

public boolean isSymmetric()
Specified by:
isSymmetric in interface BasicMatrix

isTall

public boolean isTall()
Description copied from interface: BasicMatrix
Matrices are either square, tall, fat or empty. m > n >= 1

Specified by:
isTall in interface BasicMatrix
Returns:
true if matrix is tall

isVector

public boolean isVector()
Specified by:
isVector in interface BasicMatrix
Returns:
true if the row or column dimensions are equal to 1.

isZero

public boolean isZero(int aRow,
                      int aCol)
Specified by:
isZero in interface MatrixStore<Double>
See Also:
Scalar.isZero()

maxpy

public void maxpy(Double aSclrA,
                  MatrixStore<Double> aMtrxX)
Description copied from interface: PhysicalStore

matrix a * x plus y

[this] = aSclrA [aMtrxX] + [this]

Specified by:
maxpy in interface PhysicalStore<Double>

mergeColumns

public JamaMatrix mergeColumns(BasicMatrix aMtrx)
Description copied from interface: BasicMatrix
[aMtrx] is appended to the bottom of [this]. The two matrices must have the same number of columns.

Specified by:
mergeColumns in interface BasicMatrix
Parameters:
aMtrx - The matrix to merge.
Returns:
A new matrix with more rows.

mergeRows

public JamaMatrix mergeRows(BasicMatrix aMtrx)
Description copied from interface: BasicMatrix
[aMtrx] is appended to the right side of [this]. The two matrices must have the same number of rows.

Specified by:
mergeRows in interface BasicMatrix
Parameters:
aMtrx - The matrix to merge.
Returns:
A new matrix with more columns.

modifyAll

public void modifyAll(UnaryFunction<Double> aFunc)
Specified by:
modifyAll in interface PhysicalStore<Double>

modifyColumn

public void modifyColumn(int aRow,
                         int aCol,
                         UnaryFunction<Double> aFunc)
Specified by:
modifyColumn in interface PhysicalStore<Double>

modifyDiagonal

public void modifyDiagonal(int aRow,
                           int aCol,
                           UnaryFunction<Double> aFunc)
Specified by:
modifyDiagonal in interface PhysicalStore<Double>

modifyRow

public void modifyRow(int aRow,
                      int aCol,
                      UnaryFunction<Double> aFunc)
Specified by:
modifyRow in interface PhysicalStore<Double>

multiply

public JamaMatrix multiply(Number aNmbr)
Description copied from interface: BasicMatrix
Multiplies the elements of this matrix with aNmbr.

Specified by:
multiply in interface BasicMatrix
Parameters:
aNmbr - What to multiply with.
Returns:
A new matrix whos elements are the elements of this multiplied with aNmbr.

multiplyElements

public JamaMatrix multiplyElements(BasicMatrix aMtrx)
Description copied from interface: BasicMatrix
Multiplies the elements of this matrix with the elements of aMtrx. The matrices must have equal dimensions.

Specified by:
multiplyElements in interface BasicMatrix
Parameters:
aMtrx - The elements to multiply by.
Returns:
A new matrix whos elements are the elements of this multiplied with the elements of aMtrx.

multiplyLeft

public JamaMatrix multiplyLeft(BasicMatrix aMtrx)
Description copied from interface: BasicMatrix
Matrix multiplication: [aMtrx][this]
The column dimension of the left matrix must equal the row dimension of the right matrix.

Specified by:
multiplyLeft in interface BasicMatrix
Parameters:
aMtrx - The left matrix.
Returns:
The product.
See Also:
BasicMatrix.multiplyRight(BasicMatrix)

multiplyLeft

public JamaMatrix multiplyLeft(MatrixStore<Double> aStore)
Specified by:
multiplyLeft in interface MatrixStore<Double>

multiplyRight

public JamaMatrix multiplyRight(BasicMatrix aMtrx)
Description copied from interface: BasicMatrix
Matrix multiplication: [this][aMtrx]
The column dimension of the left matrix must equal the row dimension of the right matrix.

Specified by:
multiplyRight in interface BasicMatrix
Parameters:
aMtrx - The right matrix.
Returns:
The product.
See Also:
BasicMatrix.multiplyLeft(BasicMatrix)

multiplyRight

public JamaMatrix multiplyRight(MatrixStore<Double> aStore)
Specified by:
multiplyRight in interface MatrixStore<Double>

multiplyVectors

public PrimitiveScalar multiplyVectors(BasicMatrix aVctr)
Description copied from interface: BasicMatrix
Assumes that both [this] and [aVctr] have row or column dimension, doesn't matter which, equal to 1. The two vectors must have the same number of elements.

Specified by:
multiplyVectors in interface BasicMatrix

negate

public JamaMatrix negate()
Specified by:
negate in interface BasicMatrix
Returns:
A new matrix with negated elements.

raxpy

public void raxpy(Double aSclrA,
                  int aRowX,
                  int aRowY,
                  int aFirstCol)
Description copied from interface: PhysicalStore

row a * x plus y

[this(aRowY,*)] = aSclrA [this(aRowX,*)] + [this(aRowY,*)]

Specified by:
raxpy in interface PhysicalStore<Double>

round

public JamaMatrix round(NumberContext aCntxt)
Specified by:
round in interface BasicMatrix

set

public void set(int aRow,
                int aCol,
                double aNmbr)
Specified by:
set in interface PhysicalStore<Double>

set

public void set(int aRow,
                int aCol,
                Double aNmbr)
Specified by:
set in interface PhysicalStore<Double>

set

public JamaMatrix set(int aRow,
                      int aCol,
                      Number aNmbr)
Description copied from interface: BasicMatrix
Do not use this method to populate large dense matrices! Only use it to change a few (a small number) of elements.

Specified by:
set in interface BasicMatrix

size

public int size()
Returns:
The total number of elements contained in this structure

solve

public JamaMatrix solve(BasicMatrix aRHS)
Description copied from interface: BasicMatrix

This method solves a system of linear equations: [this][X]=[aRHS]. A combination of columns in [this] should produce a column in [aRHS]. It is ok for [aRHS] to have more than 1 column.

Remember that: [X][this]=[aRHS] is equivalent to [this]T[X]T=[aRHS]T

Specified by:
solve in interface BasicMatrix
Parameters:
aRHS - The right hand side of the equation.
Returns:
The solution, [X].

substituteBackwards

public void substituteBackwards(Access2D<Double> aBody,
                                boolean someAssumeOne,
                                boolean someTransposed)

substituteForwards

public void substituteForwards(Access2D<Double> aBody,
                               boolean someAssumeOne,
                               boolean someTransposed)

subtract

public JamaMatrix subtract(BasicMatrix aMtrx)
Description copied from interface: BasicMatrix
Subtracts the elements of aMtrx from the elements of this matrix. The matrices must have equal dimensions.

Specified by:
subtract in interface BasicMatrix
Parameters:
aMtrx - What to subtract.
Returns:
A new matrix whos elements are the difference of this' and aMtrx'.

subtract

public JamaMatrix subtract(Number aNmbr)
Description copied from interface: BasicMatrix
Subtracts aNmbr from the elements of this matrix.

Specified by:
subtract in interface BasicMatrix
Parameters:
aNmbr - What to subtract.
Returns:
A new matrix whos elements are the differences between this' elements and aNmbr.

toBigDecimal

public BigDecimal toBigDecimal(int aRow,
                               int aCol)
Description copied from interface: BasicMatrix
Extracts one element of this matrix as a BigDecimal.

Specified by:
toBigDecimal in interface BasicMatrix
Parameters:
aRow - A row index.
aCol - A column index.
Returns:
One matrix element

toBigStore

public PhysicalStore<BigDecimal> toBigStore()
Description copied from interface: BasicMatrix
Must be a copy that is safe to modify.

Specified by:
toBigStore in interface BasicMatrix
See Also:
BasicMatrix.toComplexStore(), BasicMatrix.toPrimitiveStore()

toComplexNumber

public ComplexNumber toComplexNumber(int aRow,
                                     int aCol)
Description copied from interface: BasicMatrix
Extracts one element of this matrix as a ComplexNumber.

Specified by:
toComplexNumber in interface BasicMatrix
Parameters:
aRow - A row index.
aCol - A column index.
Returns:
One matrix element

toComplexStore

public PhysicalStore<ComplexNumber> toComplexStore()
Description copied from interface: BasicMatrix
Must be a copy that is safe to modify.

Specified by:
toComplexStore in interface BasicMatrix
See Also:
BasicMatrix.toBigStore(), BasicMatrix.toPrimitiveStore()

toListOfColumns

public List<BasicMatrix> toListOfColumns()
Specified by:
toListOfColumns in interface BasicMatrix

toListOfElements

public List<Double> toListOfElements()
Description copied from interface: BasicMatrix
It is also possible to call BasicMatrix.toBigStore(), BasicMatrix.toComplexStore() or BasicMatrix.toPrimitiveStore() and then PhysicalStore.asList().

Specified by:
toListOfElements in interface BasicMatrix

toListOfRows

public List<BasicMatrix> toListOfRows()
Specified by:
toListOfRows in interface BasicMatrix

toPrimitiveStore

public JamaMatrix toPrimitiveStore()
Description copied from interface: BasicMatrix
Must be a copy that is safe to modify.

Specified by:
toPrimitiveStore in interface BasicMatrix
See Also:
BasicMatrix.toBigStore(), BasicMatrix.toComplexStore()

toScalar

public PrimitiveScalar toScalar(int aRow,
                                int aCol)
Description copied from interface: Basic2D
Extracts one element of this matrix as a Scalar.

Specified by:
toScalar in interface Basic2D
Specified by:
toScalar in interface MatrixStore<Double>
Parameters:
aRow - A row index.
aCol - A column index.
Returns:
One matrix element

toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(int aRow,
                       int aCol)
Specified by:
toString in interface BasicMatrix

transformLeft

public void transformLeft(Householder<Double> aTransf,
                          int aFirstCol)
Specified by:
transformLeft in interface PhysicalStore<Double>

transformLeft

public void transformLeft(Rotation<Double> aTransf)
Description copied from interface: PhysicalStore

As in MatrixStore.multiplyLeft(MatrixStore) where the left/parameter matrix is a plane rotation.

Multiplying by a plane rotation from the left means that [this] gets two of its rows updated to new combinations of those two (current) rows.

There are two ways to transpose/invert a rotation. Either you negate the angle or you interchange the two indeces that define the rotation plane.

Specified by:
transformLeft in interface PhysicalStore<Double>
See Also:
PhysicalStore.transformRight(Rotation)

transformRight

public void transformRight(Householder<Double> aTransf,
                           int aFirstRow)
Specified by:
transformRight in interface PhysicalStore<Double>

transformRight

public void transformRight(Rotation<Double> aTransf)
Description copied from interface: PhysicalStore

As in MatrixStore.multiplyRight(MatrixStore) where the right/parameter matrix is a plane rotation.

Multiplying by a plane rotation from the right means that [this] gets two of its columns updated to new combinations of those two (current) columns.

There result is undefined if the two input indeces are the same (in which case the rotation plane is undefined).

Specified by:
transformRight in interface PhysicalStore<Double>
See Also:
PhysicalStore.transformLeft(Rotation)

transpose

public JamaMatrix transpose()
Description copied from interface: BasicMatrix
Transposes this matrix. For complex matrices conjugate() and transpose() are NOT EQUAL.

Specified by:
transpose in interface BasicMatrix
Specified by:
transpose in interface MatrixStore<Double>
Returns:
A matrix that is the transpose of this matrix.
See Also:
BasicMatrix.conjugate()

update

public final void update(int aFirstRow,
                         int aRowCount,
                         int aFirstCol,
                         int aColCount,
                         JamaMatrix aMtrx)

update

public final void update(int aFirstRow,
                         int aRowCount,
                         int[] someColumns,
                         JamaMatrix aMtrx)

update

public final void update(int aRow,
                         int aCol,
                         Number aNmbr)

update

public final void update(int[] someRows,
                         int aFirstCol,
                         int aColCount,
                         JamaMatrix aMtrx)

update

public final void update(int[] someRows,
                         int[] someColumns,
                         JamaMatrix aMtrx)

visitAll

public void visitAll(AggregatorFunction<Double> aVisitor)
Specified by:
visitAll in interface MatrixStore<Double>

visitColumn

public void visitColumn(int aRow,
                        int aCol,
                        AggregatorFunction<Double> aVisitor)
Specified by:
visitColumn in interface MatrixStore<Double>

visitDiagonal

public void visitDiagonal(int aRow,
                          int aCol,
                          AggregatorFunction<Double> aVisitor)
Specified by:
visitDiagonal in interface MatrixStore<Double>

visitRow

public void visitRow(int aRow,
                     int aCol,
                     AggregatorFunction<Double> aVisitor)
Specified by:
visitRow in interface MatrixStore<Double>