Array2DRowFieldMatrix
with a BigReal
parameter@Deprecated public class BigMatrixImpl extends java.lang.Object implements BigMatrix, java.io.Serializable
BigMatrix
using a BigDecimal[][] array to store entries
and
LU decompostion to support linear system
solution and inverse.
The LU decompostion is performed as needed, to support the following operations:
Usage notes:
getDataRef()
, then the stored
LU decomposition will not be discarded. In this case, you need to
explicitly invoke LUDecompose()
to recompute the decomposition
before using any of the methods above.BigMatrix
interface, matrix element indexing
is 0-based -- e.g., getEntry(0, 0)
returns the element in the first row, first column of the matrix.Constructor and Description |
---|
BigMatrixImpl()
Deprecated.
Creates a matrix with no data
|
BigMatrixImpl(java.math.BigDecimal[] v)
Deprecated.
Create a new (column) BigMatrix using
v as the
data for the unique column of the v.length x 1 matrix
created. |
BigMatrixImpl(java.math.BigDecimal[][] d)
Deprecated.
Create a new BigMatrix using
d as the underlying
data array. |
BigMatrixImpl(java.math.BigDecimal[][] d,
boolean copyArray)
Deprecated.
Create a new BigMatrix using the input array as the underlying
data array.
|
BigMatrixImpl(double[][] d)
Deprecated.
Create a new BigMatrix using
d as the underlying
data array. |
BigMatrixImpl(int rowDimension,
int columnDimension)
Deprecated.
Create a new BigMatrix with the supplied row and column dimensions.
|
BigMatrixImpl(java.lang.String[][] d)
Deprecated.
Create a new BigMatrix using the values represented by the strings in
d as the underlying data array. |
Modifier and Type | Method and Description |
---|---|
BigMatrix |
add(BigMatrix m)
Deprecated.
Compute the sum of this and
m . |
BigMatrixImpl |
add(BigMatrixImpl m)
Deprecated.
Compute the sum of this and
m . |
BigMatrix |
copy()
Deprecated.
Create a new BigMatrix which is a copy of this.
|
boolean |
equals(java.lang.Object object)
Deprecated.
Returns true iff
object is a
BigMatrixImpl instance with the same dimensions as this
and all corresponding matrix entries are equal. |
java.math.BigDecimal[] |
getColumn(int col)
Deprecated.
Returns the entries in column number
col as an array. |
double[] |
getColumnAsDoubleArray(int col)
Deprecated.
Returns the entries in column number
col as an array
of double values. |
int |
getColumnDimension()
Deprecated.
Returns the number of columns in the matrix.
|
BigMatrix |
getColumnMatrix(int column)
Deprecated.
Returns the entries in column number
column
as a column matrix. |
java.math.BigDecimal[][] |
getData()
Deprecated.
Returns matrix entries as a two-dimensional array.
|
double[][] |
getDataAsDoubleArray()
Deprecated.
Returns matrix entries as a two-dimensional array.
|
java.math.BigDecimal[][] |
getDataRef()
Deprecated.
Returns a reference to the underlying data array.
|
java.math.BigDecimal |
getDeterminant()
Deprecated.
Returns the determinant of this matrix.
|
java.math.BigDecimal |
getEntry(int row,
int column)
Deprecated.
Returns the entry in the specified row and column.
|
double |
getEntryAsDouble(int row,
int column)
Deprecated.
Returns the entry in the specified row and column as a double.
|
java.math.BigDecimal |
getNorm()
Deprecated.
Returns the
maximum absolute row sum norm of the matrix.
|
int |
getRoundingMode()
Deprecated.
Gets the rounding mode for division operations
The default is
BigDecimal.ROUND_HALF_UP |
java.math.BigDecimal[] |
getRow(int row)
Deprecated.
Returns the entries in row number
row as an array. |
double[] |
getRowAsDoubleArray(int row)
Deprecated.
Returns the entries in row number
row as an array
of double values. |
int |
getRowDimension()
Deprecated.
Returns the number of rows in the matrix.
|
BigMatrix |
getRowMatrix(int row)
Deprecated.
Returns the entries in row number
row
as a row matrix. |
int |
getScale()
Deprecated.
Sets the scale for division operations.
|
BigMatrix |
getSubMatrix(int[] selectedRows,
int[] selectedColumns)
Deprecated.
Gets a submatrix.
|
BigMatrix |
getSubMatrix(int startRow,
int endRow,
int startColumn,
int endColumn)
Deprecated.
Gets a submatrix.
|
java.math.BigDecimal |
getTrace()
Deprecated.
Returns the
trace of the matrix (the sum of the elements on the main diagonal).
|
int |
hashCode()
Deprecated.
Computes a hashcode for the matrix.
|
BigMatrix |
inverse()
Deprecated.
Returns the inverse matrix if this matrix is invertible.
|
boolean |
isSingular()
Deprecated.
Is this a singular matrix?
|
boolean |
isSquare()
Deprecated.
Is this a square matrix?
|
void |
luDecompose()
Deprecated.
Computes a new
LU decompostion for this matrix, storing the result for use by other methods.
|
BigMatrix |
multiply(BigMatrix m)
Deprecated.
Returns the result of postmultiplying this by
m . |
BigMatrixImpl |
multiply(BigMatrixImpl m)
Deprecated.
Returns the result of postmultiplying this by
m . |
java.math.BigDecimal[] |
operate(java.math.BigDecimal[] v)
Deprecated.
Returns the result of multiplying this by the vector
v . |
java.math.BigDecimal[] |
operate(double[] v)
Deprecated.
Returns the result of multiplying this by the vector
v . |
java.math.BigDecimal[] |
preMultiply(java.math.BigDecimal[] v)
Deprecated.
Returns the (row) vector result of premultiplying this by the vector
v . |
BigMatrix |
preMultiply(BigMatrix m)
Deprecated.
Returns the result premultiplying this by
m . |
BigMatrix |
scalarAdd(java.math.BigDecimal d)
Deprecated.
Returns the result of adding d to each entry of this.
|
BigMatrix |
scalarMultiply(java.math.BigDecimal d)
Deprecated.
Returns the result of multiplying each entry of this by
d |
void |
setRoundingMode(int roundingMode)
Deprecated.
Sets the rounding mode for decimal divisions.
|
void |
setScale(int scale)
Deprecated.
Sets the scale for division operations.
|
void |
setSubMatrix(java.math.BigDecimal[][] subMatrix,
int row,
int column)
Deprecated.
Replace the submatrix starting at
row, column using data in
the input subMatrix array. |
java.math.BigDecimal[] |
solve(java.math.BigDecimal[] b)
Deprecated.
Returns a matrix of (column) solution vectors for linear systems with
coefficient matrix = this and constant vectors = columns of
b . |
BigMatrix |
solve(BigMatrix b)
Deprecated.
Returns a matrix of (column) solution vectors for linear systems with
coefficient matrix = this and constant vectors = columns of
b . |
java.math.BigDecimal[] |
solve(double[] b)
Deprecated.
Returns a matrix of (column) solution vectors for linear systems with
coefficient matrix = this and constant vectors = columns of
b . |
BigMatrix |
subtract(BigMatrix m)
Deprecated.
Compute this minus
m . |
BigMatrixImpl |
subtract(BigMatrixImpl m)
Deprecated.
Compute this minus
m . |
java.lang.String |
toString()
Deprecated.
Get a string representation for this matrix.
|
BigMatrix |
transpose()
Deprecated.
Returns the transpose matrix.
|
public BigMatrixImpl()
public BigMatrixImpl(int rowDimension, int columnDimension)
rowDimension
- the number of rows in the new matrixcolumnDimension
- the number of columns in the new matrixjava.lang.IllegalArgumentException
- if row or column dimension is not
positivepublic BigMatrixImpl(java.math.BigDecimal[][] d)
d
as the underlying
data array.
The input array is copied, not referenced. This constructor has
the same effect as calling BigMatrixImpl(BigDecimal[][], boolean)
with the second argument set to true
.
d
- data for new matrixjava.lang.IllegalArgumentException
- if d
is not rectangular
(not all rows have the same length) or emptyjava.lang.NullPointerException
- if d
is nullpublic BigMatrixImpl(java.math.BigDecimal[][] d, boolean copyArray)
If an array is built specially in order to be embedded in a
BigMatrix and not used directly, the copyArray
may be
set to false
d
- data for new matrixcopyArray
- if true, the input array will be copied, otherwise
it will be referencedjava.lang.IllegalArgumentException
- if d
is not rectangular
(not all rows have the same length) or emptyjava.lang.NullPointerException
- if d
is nullBigMatrixImpl(BigDecimal[][])
public BigMatrixImpl(double[][] d)
d
as the underlying
data array.
Since the underlying array will hold BigDecimal
instances, it will be created.
d
- data for new matrixjava.lang.IllegalArgumentException
- if d
is not rectangular
(not all rows have the same length) or emptyjava.lang.NullPointerException
- if d
is nullpublic BigMatrixImpl(java.lang.String[][] d)
d
as the underlying data array.d
- data for new matrixjava.lang.IllegalArgumentException
- if d
is not rectangular
(not all rows have the same length) or emptyjava.lang.NullPointerException
- if d
is nullpublic BigMatrixImpl(java.math.BigDecimal[] v)
v
as the
data for the unique column of the v.length x 1
matrix
created.
The input array is copied, not referenced.
v
- column vector holding data for new matrixpublic BigMatrix copy()
public BigMatrix add(BigMatrix m) throws java.lang.IllegalArgumentException
m
.public BigMatrixImpl add(BigMatrixImpl m) throws java.lang.IllegalArgumentException
m
.m
- matrix to be addedjava.lang.IllegalArgumentException
- if m is not the same size as thispublic BigMatrix subtract(BigMatrix m) throws java.lang.IllegalArgumentException
m
.public BigMatrixImpl subtract(BigMatrixImpl m) throws java.lang.IllegalArgumentException
m
.m
- matrix to be subtractedjava.lang.IllegalArgumentException
- if m is not the same size as thispublic BigMatrix scalarAdd(java.math.BigDecimal d)
public BigMatrix scalarMultiply(java.math.BigDecimal d)
d
scalarMultiply
in interface BigMatrix
d
- value to multiply all entries bypublic BigMatrix multiply(BigMatrix m) throws java.lang.IllegalArgumentException
m
.public BigMatrixImpl multiply(BigMatrixImpl m) throws java.lang.IllegalArgumentException
m
.m
- matrix to postmultiply byjava.lang.IllegalArgumentException
- if columnDimension(this) != rowDimension(m)public BigMatrix preMultiply(BigMatrix m) throws java.lang.IllegalArgumentException
m
.preMultiply
in interface BigMatrix
m
- matrix to premultiply byjava.lang.IllegalArgumentException
- if rowDimension(this) != columnDimension(m)public java.math.BigDecimal[][] getData()
Makes a fresh copy of the underlying data.
public double[][] getDataAsDoubleArray()
Makes a fresh copy of the underlying data converted to
double
values.
getDataAsDoubleArray
in interface BigMatrix
public java.math.BigDecimal[][] getDataRef()
Does not make a fresh copy of the underlying data.
public int getRoundingMode()
BigDecimal.ROUND_HALF_UP
getRoundingMode
in interface BigMatrix
BigDecimal
public void setRoundingMode(int roundingMode)
roundingMode
- rounding mode for decimal divisionsBigDecimal
public int getScale()
BigDecimal
public void setScale(int scale)
scale
- scale for division operationsBigDecimal
public java.math.BigDecimal getNorm()
public BigMatrix getSubMatrix(int startRow, int endRow, int startColumn, int endColumn) throws MatrixIndexException
getSubMatrix
in interface BigMatrix
startRow
- Initial row indexendRow
- Final row indexstartColumn
- Initial column indexendColumn
- Final column indexMatrixIndexException
- if row or column selections are not validpublic BigMatrix getSubMatrix(int[] selectedRows, int[] selectedColumns) throws MatrixIndexException
getSubMatrix
in interface BigMatrix
selectedRows
- Array of row indices must be non-emptyselectedColumns
- Array of column indices must be non-emptyMatrixIndexException
- if supplied row or column index arrays
are not validpublic void setSubMatrix(java.math.BigDecimal[][] subMatrix, int row, int column) throws MatrixIndexException
row, column
using data in
the input subMatrix
array. Indexes are 0-based.
Example:
Starting with
1 2 3 4 5 6 7 8 9 0 1 2and
subMatrix = {{3, 4} {5,6}}
, invoking
setSubMatrix(subMatrix,1,1))
will result in 1 2 3 4 5 3 4 8 9 5 6 2
subMatrix
- array containing the submatrix replacement datarow
- row coordinate of the top, left element to be replacedcolumn
- column coordinate of the top, left element to be replacedMatrixIndexException
- if subMatrix does not fit into this
matrix from element in (row, column)java.lang.IllegalArgumentException
- if subMatrix
is not rectangular
(not all rows have the same length) or emptyjava.lang.NullPointerException
- if subMatrix
is nullpublic BigMatrix getRowMatrix(int row) throws MatrixIndexException
row
as a row matrix. Row indices start at 0.getRowMatrix
in interface BigMatrix
row
- the row to be fetchedMatrixIndexException
- if the specified row index is invalidpublic BigMatrix getColumnMatrix(int column) throws MatrixIndexException
column
as a column matrix. Column indices start at 0.getColumnMatrix
in interface BigMatrix
column
- the column to be fetchedMatrixIndexException
- if the specified column index is invalidpublic java.math.BigDecimal[] getRow(int row) throws MatrixIndexException
row
as an array.
Row indices start at 0. A MatrixIndexException
is thrown
unless 0 <= row < rowDimension.
getRow
in interface BigMatrix
row
- the row to be fetchedMatrixIndexException
- if the specified row index is not validpublic double[] getRowAsDoubleArray(int row) throws MatrixIndexException
row
as an array
of double values.
Row indices start at 0. A MatrixIndexException
is thrown
unless 0 <= row < rowDimension.
getRowAsDoubleArray
in interface BigMatrix
row
- the row to be fetchedMatrixIndexException
- if the specified row index is not validpublic java.math.BigDecimal[] getColumn(int col) throws MatrixIndexException
col
as an array.
Column indices start at 0. A MatrixIndexException
is thrown
unless 0 <= column < columnDimension.
getColumn
in interface BigMatrix
col
- the column to be fetchedMatrixIndexException
- if the specified column index is not validpublic double[] getColumnAsDoubleArray(int col) throws MatrixIndexException
col
as an array
of double values.
Column indices start at 0. A MatrixIndexException
is thrown
unless 0 <= column < columnDimension.
getColumnAsDoubleArray
in interface BigMatrix
col
- the column to be fetchedMatrixIndexException
- if the specified column index is not validpublic java.math.BigDecimal getEntry(int row, int column) throws MatrixIndexException
Row and column indices start at 0 and must satisfy
0 <= row < rowDimension
0 <= column < columnDimension
MatrixIndexException
is thrown.getEntry
in interface BigMatrix
row
- row location of entry to be fetchedcolumn
- column location of entry to be fetchedMatrixIndexException
- if the row or column index is not validpublic double getEntryAsDouble(int row, int column) throws MatrixIndexException
Row and column indices start at 0 and must satisfy
0 <= row < rowDimension
0 <= column < columnDimension
MatrixIndexException
is thrown.getEntryAsDouble
in interface BigMatrix
row
- row location of entry to be fetchedcolumn
- column location of entry to be fetchedMatrixIndexException
- if the row
or column index is not validpublic BigMatrix transpose()
public BigMatrix inverse() throws InvalidMatrixException
inverse
in interface BigMatrix
InvalidMatrixException
- if this is not invertiblepublic java.math.BigDecimal getDeterminant() throws InvalidMatrixException
getDeterminant
in interface BigMatrix
InvalidMatrixException
- if matrix is not squarepublic boolean isSquare()
public boolean isSingular()
public int getRowDimension()
getRowDimension
in interface AnyMatrix
public int getColumnDimension()
getColumnDimension
in interface AnyMatrix
public java.math.BigDecimal getTrace() throws java.lang.IllegalArgumentException
public java.math.BigDecimal[] operate(java.math.BigDecimal[] v) throws java.lang.IllegalArgumentException
v
.public java.math.BigDecimal[] operate(double[] v) throws java.lang.IllegalArgumentException
v
.v
- the vector to operate onjava.lang.IllegalArgumentException
- if columnDimension != v.size()public java.math.BigDecimal[] preMultiply(java.math.BigDecimal[] v) throws java.lang.IllegalArgumentException
v
.preMultiply
in interface BigMatrix
v
- the row vector to premultiply byjava.lang.IllegalArgumentException
- if rowDimension != v.size()public java.math.BigDecimal[] solve(java.math.BigDecimal[] b) throws java.lang.IllegalArgumentException, InvalidMatrixException
b
.solve
in interface BigMatrix
b
- array of constants forming RHS of linear systems to
to solvejava.lang.IllegalArgumentException
- if this.rowDimension != row dimensionInvalidMatrixException
- if this matrix is not square or is singularpublic java.math.BigDecimal[] solve(double[] b) throws java.lang.IllegalArgumentException, InvalidMatrixException
b
.b
- array of constants forming RHS of linear systems to
to solvejava.lang.IllegalArgumentException
- if this.rowDimension != row dimensionInvalidMatrixException
- if this matrix is not square or is singularpublic BigMatrix solve(BigMatrix b) throws java.lang.IllegalArgumentException, InvalidMatrixException
b
.solve
in interface BigMatrix
b
- matrix of constant vectors forming RHS of linear systems to
to solvejava.lang.IllegalArgumentException
- if this.rowDimension != row dimensionInvalidMatrixException
- if this matrix is not square or is singularpublic void luDecompose() throws InvalidMatrixException
Implementation Note:
Uses
Crout's algortithm, with partial pivoting.
Usage Note:
This method should rarely be invoked directly. Its only use is
to force recomputation of the LU decomposition when changes have been
made to the underlying data using direct array references. Changes
made using setXxx methods will trigger recomputation when needed
automatically.
InvalidMatrixException
- if the matrix is non-square or singular.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object object)
object
is a
BigMatrixImpl
instance with the same dimensions as this
and all corresponding matrix entries are equal. BigDecimal.equals
is used to compare corresponding entries.equals
in class java.lang.Object
object
- the object to test equality against.public int hashCode()
hashCode
in class java.lang.Object
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"