public class Array2DRowRealMatrix extends AbstractRealMatrix implements java.io.Serializable
The LU decomposition 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.RealMatrix
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 |
---|
Array2DRowRealMatrix()
Creates a matrix with no data
|
Array2DRowRealMatrix(double[] v)
Create a new (column) RealMatrix using
v as the
data for the unique column of the v.length x 1 matrix
created. |
Array2DRowRealMatrix(double[][] d)
Create a new RealMatrix using the input array as the underlying
data array.
|
Array2DRowRealMatrix(double[][] d,
boolean copyArray)
Create a new RealMatrix using the input array as the underlying
data array.
|
Array2DRowRealMatrix(int rowDimension,
int columnDimension)
Create a new RealMatrix with the supplied row and column dimensions.
|
Modifier and Type | Method and Description |
---|---|
Array2DRowRealMatrix |
add(Array2DRowRealMatrix m)
Compute the sum of this and
m . |
RealMatrix |
add(RealMatrix m)
Compute the sum of this and m.
|
void |
addToEntry(int row,
int column,
double increment)
Change an entry in the specified row and column.
|
RealMatrix |
copy()
Returns a (deep) copy of this.
|
RealMatrix |
createMatrix(int rowDimension,
int columnDimension)
Create a new RealMatrix of the same type as the instance with the supplied
row and column dimensions.
|
int |
getColumnDimension()
Returns the number of columns in the matrix.
|
double[][] |
getData()
Returns matrix entries as a two-dimensional array.
|
double[][] |
getDataRef()
Returns a reference to the underlying data array.
|
double |
getEntry(int row,
int column)
Returns the entry in the specified row and column.
|
int |
getRowDimension()
Returns the number of rows in the matrix.
|
Array2DRowRealMatrix |
multiply(Array2DRowRealMatrix m)
Returns the result of postmultiplying this by
m . |
RealMatrix |
multiply(RealMatrix m)
Returns the result of postmultiplying this by m.
|
void |
multiplyEntry(int row,
int column,
double factor)
Change an entry in the specified row and column.
|
double[] |
operate(double[] v)
Returns the result of multiplying this by the vector
v . |
double[] |
preMultiply(double[] v)
Returns the (row) vector result of premultiplying this by the vector
v . |
void |
setEntry(int row,
int column,
double value)
Set the entry in the specified row and column.
|
void |
setSubMatrix(double[][] subMatrix,
int row,
int column)
Replace the submatrix starting at
row, column using data in
the input subMatrix array. |
Array2DRowRealMatrix |
subtract(Array2DRowRealMatrix m)
Compute this minus
m . |
RealMatrix |
subtract(RealMatrix m)
Compute this minus m.
|
double |
walkInColumnOrder(RealMatrixChangingVisitor visitor)
Visit (and possibly change) all matrix entries in column order.
|
double |
walkInColumnOrder(RealMatrixChangingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visit (and possibly change) some matrix entries in column order.
|
double |
walkInColumnOrder(RealMatrixPreservingVisitor visitor)
Visit (but don't change) all matrix entries in column order.
|
double |
walkInColumnOrder(RealMatrixPreservingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visit (but don't change) some matrix entries in column order.
|
double |
walkInRowOrder(RealMatrixChangingVisitor visitor)
Visit (and possibly change) all matrix entries in row order.
|
double |
walkInRowOrder(RealMatrixChangingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visit (and possibly change) some matrix entries in row order.
|
double |
walkInRowOrder(RealMatrixPreservingVisitor visitor)
Visit (but don't change) all matrix entries in row order.
|
double |
walkInRowOrder(RealMatrixPreservingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visit (but don't change) some matrix entries in row order.
|
copySubMatrix, copySubMatrix, equals, getColumn, getColumnMatrix, getColumnVector, getDeterminant, getFrobeniusNorm, getNorm, getRow, getRowMatrix, getRowVector, getSubMatrix, getSubMatrix, getTrace, hashCode, inverse, isSingular, isSquare, luDecompose, operate, preMultiply, preMultiply, scalarAdd, scalarMultiply, setColumn, setColumnMatrix, setColumnVector, setRow, setRowMatrix, setRowVector, solve, solve, toString, transpose, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInOptimizedOrder
public Array2DRowRealMatrix()
public Array2DRowRealMatrix(int rowDimension, int columnDimension) throws java.lang.IllegalArgumentException
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 Array2DRowRealMatrix(double[][] d) throws java.lang.IllegalArgumentException, java.lang.NullPointerException
The input array is copied, not referenced. This constructor has
the same effect as calling Array2DRowRealMatrix(double[][], 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 nullArray2DRowRealMatrix(double[][], boolean)
public Array2DRowRealMatrix(double[][] d, boolean copyArray) throws java.lang.IllegalArgumentException, java.lang.NullPointerException
If an array is built specially in order to be embedded in a
RealMatrix 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 nullArray2DRowRealMatrix(double[][])
public Array2DRowRealMatrix(double[] 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 RealMatrix createMatrix(int rowDimension, int columnDimension) throws java.lang.IllegalArgumentException
createMatrix
in interface RealMatrix
createMatrix
in class AbstractRealMatrix
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 RealMatrix copy()
copy
in interface RealMatrix
copy
in class AbstractRealMatrix
public RealMatrix add(RealMatrix m) throws java.lang.IllegalArgumentException
add
in interface RealMatrix
add
in class AbstractRealMatrix
m
- matrix to be addedjava.lang.IllegalArgumentException
- if m is not the same size as thispublic Array2DRowRealMatrix add(Array2DRowRealMatrix m) throws java.lang.IllegalArgumentException
m
.m
- matrix to be addedjava.lang.IllegalArgumentException
- if m is not the same size as thispublic RealMatrix subtract(RealMatrix m) throws java.lang.IllegalArgumentException
subtract
in interface RealMatrix
subtract
in class AbstractRealMatrix
m
- matrix to be subtractedjava.lang.IllegalArgumentException
- if m is not the same size as thispublic Array2DRowRealMatrix subtract(Array2DRowRealMatrix m) throws java.lang.IllegalArgumentException
m
.m
- matrix to be subtractedjava.lang.IllegalArgumentException
- if m is not the same size as thispublic RealMatrix multiply(RealMatrix m) throws java.lang.IllegalArgumentException
multiply
in interface RealMatrix
multiply
in class AbstractRealMatrix
m
- matrix to postmultiply byjava.lang.IllegalArgumentException
- if columnDimension(this) != rowDimension(m)public Array2DRowRealMatrix multiply(Array2DRowRealMatrix m) throws java.lang.IllegalArgumentException
m
.m
- matrix to postmultiply byjava.lang.IllegalArgumentException
- if columnDimension(this) != rowDimension(m)public double[][] getData()
getData
in interface RealMatrix
getData
in class AbstractRealMatrix
public double[][] getDataRef()
Does not make a fresh copy of the underlying data.
public void setSubMatrix(double[][] 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
setSubMatrix
in interface RealMatrix
setSubMatrix
in class AbstractRealMatrix
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)public double 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 RealMatrix
getEntry
in class AbstractRealMatrix
row
- row location of entry to be fetchedcolumn
- column location of entry to be fetchedMatrixIndexException
- if the row or column index is not validpublic void setEntry(int row, int column, double value) throws MatrixIndexException
Row and column indices start at 0 and must satisfy
0 <= row < rowDimension
0 <= column < columnDimension
MatrixIndexException
is thrown.setEntry
in interface RealMatrix
setEntry
in class AbstractRealMatrix
row
- row location of entry to be setcolumn
- column location of entry to be setvalue
- matrix entry to be set in row,columnMatrixIndexException
- if the row or column index is not validpublic void addToEntry(int row, int column, double increment) throws MatrixIndexException
Row and column indices start at 0 and must satisfy
0 <= row < rowDimension
0 <= column < columnDimension
MatrixIndexException
is thrown.addToEntry
in interface RealMatrix
addToEntry
in class AbstractRealMatrix
row
- row location of entry to be setcolumn
- column location of entry to be setincrement
- value to add to the current matrix entry in row,columnMatrixIndexException
- if the row or column index is not validpublic void multiplyEntry(int row, int column, double factor) throws MatrixIndexException
Row and column indices start at 0 and must satisfy
0 <= row < rowDimension
0 <= column < columnDimension
MatrixIndexException
is thrown.multiplyEntry
in interface RealMatrix
multiplyEntry
in class AbstractRealMatrix
row
- row location of entry to be setcolumn
- column location of entry to be setfactor
- multiplication factor for the current matrix entry in row,columnMatrixIndexException
- if the row or column index is not validpublic int getRowDimension()
getRowDimension
in interface AnyMatrix
getRowDimension
in class AbstractRealMatrix
public int getColumnDimension()
getColumnDimension
in interface AnyMatrix
getColumnDimension
in class AbstractRealMatrix
public double[] operate(double[] v) throws java.lang.IllegalArgumentException
v
.operate
in interface RealMatrix
operate
in class AbstractRealMatrix
v
- the vector to operate onjava.lang.IllegalArgumentException
- if columnDimension != v.size()public double[] preMultiply(double[] v) throws java.lang.IllegalArgumentException
v
.preMultiply
in interface RealMatrix
preMultiply
in class AbstractRealMatrix
v
- the row vector to premultiply byjava.lang.IllegalArgumentException
- if rowDimension != v.size()public double walkInRowOrder(RealMatrixChangingVisitor visitor) throws MatrixVisitorException
Row order starts at upper left and iterating through all elements of a row from left to right before going to the leftmost element of the next row.
walkInRowOrder
in interface RealMatrix
walkInRowOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesRealMatrixChangingVisitor.end()
at the end
of the walkMatrixVisitorException
- if the visitor cannot process an entryRealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInRowOrder(RealMatrixPreservingVisitor visitor) throws MatrixVisitorException
Row order starts at upper left and iterating through all elements of a row from left to right before going to the leftmost element of the next row.
walkInRowOrder
in interface RealMatrix
walkInRowOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesRealMatrixPreservingVisitor.end()
at the end
of the walkMatrixVisitorException
- if the visitor cannot process an entryRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInRowOrder(RealMatrixChangingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn) throws MatrixIndexException, MatrixVisitorException
Row order starts at upper left and iterating through all elements of a row from left to right before going to the leftmost element of the next row.
walkInRowOrder
in interface RealMatrix
walkInRowOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesstartRow
- Initial row indexendRow
- Final row index (inclusive)startColumn
- Initial column indexendColumn
- Final column indexRealMatrixChangingVisitor.end()
at the end
of the walkMatrixIndexException
- if the indices are not validMatrixVisitorException
- if the visitor cannot process an entryRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInRowOrder(RealMatrixPreservingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn) throws MatrixIndexException, MatrixVisitorException
Row order starts at upper left and iterating through all elements of a row from left to right before going to the leftmost element of the next row.
walkInRowOrder
in interface RealMatrix
walkInRowOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesstartRow
- Initial row indexendRow
- Final row index (inclusive)startColumn
- Initial column indexendColumn
- Final column indexRealMatrixPreservingVisitor.end()
at the end
of the walkMatrixIndexException
- if the indices are not validMatrixVisitorException
- if the visitor cannot process an entryRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInColumnOrder(RealMatrixChangingVisitor visitor) throws MatrixVisitorException
Column order starts at upper left and iterating through all elements of a column from top to bottom before going to the topmost element of the next column.
walkInColumnOrder
in interface RealMatrix
walkInColumnOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesRealMatrixChangingVisitor.end()
at the end
of the walkMatrixVisitorException
- if the visitor cannot process an entryRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInColumnOrder(RealMatrixPreservingVisitor visitor) throws MatrixVisitorException
Column order starts at upper left and iterating through all elements of a column from top to bottom before going to the topmost element of the next column.
walkInColumnOrder
in interface RealMatrix
walkInColumnOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesRealMatrixPreservingVisitor.end()
at the end
of the walkMatrixVisitorException
- if the visitor cannot process an entryRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInColumnOrder(RealMatrixChangingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn) throws MatrixIndexException, MatrixVisitorException
Column order starts at upper left and iterating through all elements of a column from top to bottom before going to the topmost element of the next column.
walkInColumnOrder
in interface RealMatrix
walkInColumnOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesstartRow
- Initial row indexendRow
- Final row index (inclusive)startColumn
- Initial column indexendColumn
- Final column indexRealMatrixChangingVisitor.end()
at the end
of the walkMatrixIndexException
- if the indices are not validMatrixVisitorException
- if the visitor cannot process an entryRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInColumnOrder(RealMatrixPreservingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn) throws MatrixIndexException, MatrixVisitorException
Column order starts at upper left and iterating through all elements of a column from top to bottom before going to the topmost element of the next column.
walkInColumnOrder
in interface RealMatrix
walkInColumnOrder
in class AbstractRealMatrix
visitor
- visitor used to process all matrix entriesstartRow
- Initial row indexendRow
- Final row index (inclusive)startColumn
- Initial column indexendColumn
- Final column indexRealMatrixPreservingVisitor.end()
at the end
of the walkMatrixIndexException
- if the indices are not validMatrixVisitorException
- if the visitor cannot process an entryRealMatrix.walkInRowOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInRowOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInRowOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInColumnOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
Copyright © 2010 - 2020 Adobe. All Rights Reserved