public abstract class AbstractRealMatrix extends RealLinearOperator implements RealMatrix
All the methods implemented here use getEntry(int, int)
to access matrix elements.
Derived class can provide faster implementations.
This class is up-to-date with commons-math 3.6.1.
Modifier | Constructor and Description |
---|---|
protected |
AbstractRealMatrix()
Creates a matrix with no data.
|
protected |
AbstractRealMatrix(double[][] data)
Creates a new matrix using the supplied data array.
|
protected |
AbstractRealMatrix(int rowDimension,
int columnDimension)
Creates a new matrix with the supplied row and column dimensions.
|
Modifier and Type | Method and Description |
---|---|
RealMatrix |
add(RealMatrix m)
Returns the result of adding the matrix
m to this matrix. |
void |
addToEntry(int row,
int column,
double increment)
Adds (in place) a given value to the specified entry of this matrix.
|
protected static void |
checkDestinationArray(int nbRows,
int nbColumns,
double[][] destination,
int startRowDest,
int startColumnDest)
Ensures the destination array is not
null , and large enough to store the data of a
submatrix. |
protected void |
checkSquare()
Checks if this is a square matrix and throws an exception if that's not the case.
|
RealMatrix |
concatenateDiagonally(RealMatrix m)
Diagonally concatenates this matrix and another matrix
m , placing it in the lower
right part of the concatenated matrix. |
RealMatrix |
concatenateDiagonally(RealMatrix m,
boolean lowerRightConcatenation)
Diagonally concatenates this matrix and another matrix
m , placing it in the lower
right or upper left part of the concatenated matrix. |
RealMatrix |
concatenateDiagonally(RealMatrix m,
boolean rightConcatenation,
boolean lowerConcatenation)
Diagonally or anti-diagonally concatenates this matrix and another matrix
m . |
RealMatrix |
concatenateHorizontally(RealMatrix m)
Horizontally concatenates this matrix and another matrix
m , placing it in the right
part of the concatenated matrix. |
RealMatrix |
concatenateHorizontally(RealMatrix m,
boolean rightConcatenation)
Horizontally concatenates this matrix and another matrix
m , , placing it in the left
or right part of the concatenated matrix. |
RealMatrix |
concatenateVertically(RealMatrix m)
Vertically concatenates this matrix and another matrix
m , placing it in the lower
part of the concatenated matrix. |
RealMatrix |
concatenateVertically(RealMatrix m,
boolean lowerConcatenation)
Vertically concatenates this matrix and another matrix
m , placing it in the lower or
upper part of the concatenated matrix. |
abstract RealMatrix |
copy()
Returns a deep copy of this matrix.
|
void |
copySubMatrix(int[] selectedRows,
int[] selectedColumns,
double[][] destination)
Copies a submatrix into a given 2D array.
|
void |
copySubMatrix(int[] selectedRows,
int[] selectedColumns,
double[][] destination,
int startRowDest,
int startColumnDest)
Copies a submatrix into a given 2D array.
|
void |
copySubMatrix(int startRow,
int endRow,
int startColumn,
int endColumn,
double[][] destination)
Copies a submatrix into a given 2D array.
|
void |
copySubMatrix(int startRow,
int endRow,
int startColumn,
int endColumn,
double[][] destination,
int startRowDest,
int startColumnDest)
Copies a submatrix into a given 2D array.
|
abstract RealMatrix |
createMatrix(int rowDimension,
int columnDimension)
Creates a new matrix of the same type as this matrix.
|
boolean |
equals(Object object)
Returns
true if the provided object is a RealMatrix instance with the
same dimensions as this matrix, whose entries are strictly equal to the entries of this
matrix (no absolute or relative tolerance is taken into account when comparing the entries). |
boolean |
equals(RealMatrix m,
double relativeThreshold,
double absoluteThreshold)
Is this matrix numerically equivalent to another matrix?
|
double[] |
getColumn(int column)
Gets the entries of a given column.
|
abstract int |
getColumnDimension()
Returns the dimension of the domain of this operator.
|
RealMatrix |
getColumnMatrix(int column)
Gets the entries of a given column as a column matrix.
|
RealVector |
getColumnVector(int column)
Gets the entries of a given column as a vector.
|
double[][] |
getData()
Returns a 2D array containing the entries of the matrix.
|
double[][] |
getData(boolean forceCopy)
Returns a 2D array containing the entries of the matrix.
|
Function<RealMatrix,Decomposition> |
getDefaultDecomposition()
Gets the decomposition builder the
getInverse() method uses
by default when computing the inverse of the matrix. |
double[] |
getDiagonal()
Gets the diagonal vector from this matrix.
|
abstract double |
getEntry(int row,
int column)
Gets the entry at the specified row and column.
|
double |
getFrobeniusNorm()
Returns the Frobenius norm of
the matrix.
|
RealMatrix |
getInverse()
Gets the inverse (or pseudo-inverse) of this matrix using the default decomposition.
|
RealMatrix |
getInverse(Function<RealMatrix,Decomposition> decompositionBuilder)
Gets the inverse (or pseudo-inverse) of this matrix using the given decomposition algorithm.
|
double |
getMax()
Returns the maximum value of the matrix.
|
double |
getMin()
Returns the minimum value of the matrix.
|
double |
getNorm()
Returns the maximum
absolute row sum norm of the matrix.
|
double[] |
getRow(int row)
Gets the entries of a given row.
|
abstract int |
getRowDimension()
Returns the dimension of the codomain of this operator.
|
RealMatrix |
getRowMatrix(int row)
Gets the entries of a given row as a row matrix.
|
RealVector |
getRowVector(int row)
Gets the entries of a given row as a vector.
|
RealMatrix |
getSubMatrix(int[] selectedRows,
int[] selectedColumns)
Gets a submatrix.
|
RealMatrix |
getSubMatrix(int startRow,
int endRow,
int startColumn,
int endColumn)
Gets a submatrix.
|
double |
getTrace()
Returns the trace of the matrix
(the sum of the elements on the main diagonal).
|
int |
hashCode()
Computes a hash code for the matrix.
|
boolean |
isAntisymmetric(double relativeTolerance,
double absoluteTolerance)
Is this a antisymmetric matrix?
|
boolean |
isDiagonal(double absoluteTolerance)
Is this a diagonal matrix?
|
boolean |
isInvertible(double relativeTolerance)
Is this an invertible matrix?
|
boolean |
isOrthogonal(double normalityThreshold,
double orthogonalityThreshold)
Is this an orthogonal matrix?
|
boolean |
isSquare()
Is this a square matrix?
|
boolean |
isSymmetric()
Is this a symmetric matrix?
|
boolean |
isSymmetric(double relativeTolerance)
Is this a symmetric matrix?
|
boolean |
isSymmetric(double relativeTolerance,
double absoluteTolerance)
Is this a symmetric matrix?
|
RealMatrix |
multiply(DiagonalMatrix m,
double d)
Returns the result of postmultiplying this matrix by the diagonal matrix
m , then by
the scalar d . |
RealMatrix |
multiply(RealMatrix m)
Returns the result of postmultiplying this matrix by the matrix
m . |
RealMatrix |
multiply(RealMatrix m,
boolean toTranspose)
Returns the result of postmultiplying this matrix by the matrix
m or its transpose
m T. |
RealMatrix |
multiply(RealMatrix m,
boolean toTranspose,
double d)
Returns the result of postmultiplying this matrix by the matrix
m or its transpose
m T, then by the scalar d . |
void |
multiplyEntry(int row,
int column,
double factor)
Multiplies (in place) the specified entry of
this matrix by a given value. |
double[] |
operate(double[] v)
Returns the result of postmultiplying this matrix by the vector
v . |
RealVector |
operate(RealVector v)
Returns the result of multiplying
this by the vector x . |
RealMatrix |
power(int p)
Returns the the result of multiplying this matrix with itself
p times. |
double[] |
preMultiply(double[] v)
Returns the result of premultiplying this matrix by the vector
v . |
RealMatrix |
preMultiply(RealMatrix m)
Returns the result of premultiplying this matrix by the matrix
m . |
RealVector |
preMultiply(RealVector v)
Returns the result of premultiplying this matrix by the vector
v . |
RealMatrix |
scalarAdd(double d)
Returns the result of adding a scalar
d to the entries of this matrix. |
RealMatrix |
scalarMultiply(double d)
Returns the result of multiplying the entries of this matrix by the scalar
d . |
void |
setColumn(int column,
double[] array)
Replaces the entries of a given column with the entries of the specified data array.
|
void |
setColumnMatrix(int column,
RealMatrix matrix)
Replaces the entries of a given column with the entries of the specified column matrix.
|
void |
setColumnVector(int column,
RealVector vector)
Replaces the entries of a given column with the entries of the specified vector.
|
void |
setDefaultDecomposition(Function<RealMatrix,Decomposition> defaultDecompositionBuilder)
Sets the decomposition builder the
getInverse() method should
use by default when computing the inverse of the matrix. |
abstract void |
setEntry(int row,
int column,
double value)
Sets the entry at the specified row and column to a new value.
|
void |
setRow(int row,
double[] array)
Replaces the entries of a given row with the entries of the specified data array.
|
void |
setRowMatrix(int row,
RealMatrix matrix)
Replaces the entries of a given row with the entries of the specified row matrix.
|
void |
setRowVector(int row,
RealVector vector)
Replaces the entries of a given row with the entries of the specified vector.
|
void |
setSubMatrix(double[][] subMatrix,
int row,
int column)
Replaces part of the matrix with a given submatrix, starting at the specified row and column.
|
RealMatrix |
subtract(RealMatrix m)
Returns the result of subtracting the matrix
m from this matrix. |
String |
toString()
Get a string representation for this matrix.
|
String |
toString(RealMatrixFormat realMatrixFormat)
Gets a string representation of this matrix using the specified format.
|
RealMatrix |
transpose()
Returns the transpose of this matrix.
|
RealMatrix |
transpose(boolean forceCopy)
Returns the transpose of this matrix.
|
double |
walkInColumnOrder(RealMatrixChangingVisitor visitor)
Visits (and possibly change) all matrix entries in column order.
|
double |
walkInColumnOrder(RealMatrixChangingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visits (and possibly change) some matrix entries in column order.
|
double |
walkInColumnOrder(RealMatrixPreservingVisitor visitor)
Visits (but don't change) all matrix entries in column order.
|
double |
walkInColumnOrder(RealMatrixPreservingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visits (but don't change) some matrix entries in column order.
|
double |
walkInOptimizedOrder(RealMatrixChangingVisitor visitor)
Visits (and possibly change) all matrix entries using the fastest possible order.
|
double |
walkInOptimizedOrder(RealMatrixChangingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visits (and possibly change) some matrix entries using the fastest possible order.
|
double |
walkInOptimizedOrder(RealMatrixPreservingVisitor visitor)
Visits (but don't change) all matrix entries using the fastest possible order.
|
double |
walkInOptimizedOrder(RealMatrixPreservingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visits (but don't change) some matrix entries using the fastest possible order.
|
double |
walkInRowOrder(RealMatrixChangingVisitor visitor)
Visits (and possibly change) all matrix entries in row order.
|
double |
walkInRowOrder(RealMatrixChangingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visits (and possibly change) some matrix entries in row order.
|
double |
walkInRowOrder(RealMatrixPreservingVisitor visitor)
Visits (but don't change) all matrix entries in row order.
|
double |
walkInRowOrder(RealMatrixPreservingVisitor visitor,
int startRow,
int endRow,
int startColumn,
int endColumn)
Visits (but don't change) some matrix entries in row order.
|
isTransposable, operateTranspose
protected AbstractRealMatrix()
protected AbstractRealMatrix(int rowDimension, int columnDimension)
rowDimension
- the number of rows in the matrixcolumnDimension
- the number of columns in the matrixNotStrictlyPositiveException
- if the row/column dimensions are not strictly positiveprotected AbstractRealMatrix(double[][] data)
data
- the data array containing the entries of the matrixNullArgumentException
- if the data array is null
NoDataException
- if the data array is emptyDimensionMismatchException
- if the rows of the data array do not have a constant number of columnsprotected void checkSquare()
NonSquareMatrixException
- if this is not a square matrixpublic RealMatrix add(RealMatrix m)
m
to this matrix.add
in interface RealMatrix
m
- the matrix to be addedthis
+m
public RealMatrix subtract(RealMatrix m)
m
from this matrix.subtract
in interface RealMatrix
m
- the matrix to be subtractedthis
-m
public RealMatrix scalarAdd(double d)
d
to the entries of this matrix.scalarAdd
in interface RealMatrix
d
- the scalar value to be added to the entries of this matrixthis
+d
public RealMatrix scalarMultiply(double d)
d
.scalarMultiply
in interface RealMatrix
d
- the scalar value by which to multiply the entries of this matrix bythis
×d
public RealMatrix multiply(RealMatrix m)
m
.multiply
in interface RealMatrix
m
- the matrix by which to postmultiply this matrix bythis
×m
public RealMatrix multiply(RealMatrix m, boolean toTranspose)
m
or its transpose
m
T.multiply
in interface RealMatrix
m
- the matrix by which to postmultiply this matrix bytoTranspose
- whether to compute the product this
×m
(toTranspose=false
), or the product this
×m
T (toTranspose=true
)this
×m
or this
×m
Tpublic RealMatrix multiply(RealMatrix m, boolean toTranspose, double d)
m
or its transpose
m
T, then by the scalar d
.multiply
in interface RealMatrix
m
- the matrix by which to multiply this matrix bytoTranspose
- whether to compute the product this
×m
×d
(
toTranspose=false
), or the product this
×m
T×d
(toTranspose=true
)d
- the scalar by which to multiply the resulting matrix bythis
×m
×d
or
this
×m
T×d
public RealMatrix multiply(DiagonalMatrix m, double d)
m
, then by
the scalar d
.m
- the diagonal matrix by which to multiply this matrix byd
- the scalar by which to multiply the resulting matrix bythis
×m
×d
or
this
×m
T×d
DimensionMismatchException
- if the matrices are not multiplication compatiblepublic RealMatrix preMultiply(RealMatrix m)
m
.preMultiply
in interface RealMatrix
m
- the matrix M by which to premultiply this matrix bym
×this
public double[] operate(double[] v)
v
.operate
in interface RealMatrix
v
- the vector by which to multiply this matrix bythis
×v
public RealVector operate(RealVector v)
this
by the vector x
.operate
in interface RealMatrix
operate
in class RealLinearOperator
v
- the vector to operate onthis
instance with x
public double[] preMultiply(double[] v)
v
.preMultiply
in interface RealMatrix
v
- the row vector by which to premultiply this matrix byv
×this
public RealVector preMultiply(RealVector v)
v
.preMultiply
in interface RealMatrix
v
- the vector by which to premultiply this matrix byv
×this
public RealMatrix power(int p)
p
times.
The exponent p
must be positive or equal to zero.
This operation is only supported for square matrices.
Depending on the underlying storage, numerical instabilities might occur for high powers.
power
in interface RealMatrix
p
- the exponent p
to which this matrix is to be raisedp
public double[][] getData()
getData
in interface RealMatrix
public double[][] getData(boolean forceCopy)
If forceCopy
is true
, the returned array is guaranteed to be free of
references to any internal data array (thus, can be safely modified). Otherwise, the returned
array may contain references to internal data arrays (for optimization purposes). Note that
setting forceCopy
to false
does not guarantee the returned array references
an internal data array. For instance, implementations that do not store the entries of the
matrix in a 2D array have to rebuild a new array each time this method is called, regardless
of this parameter.
getData
in interface RealMatrix
forceCopy
- if true
, the entries of the matrix are systematically stored in a new array;
otherwise the returned array may reference internal data arrayspublic double[] getDiagonal()
Note: The matrix needs to be square.
getDiagonal
in interface RealMatrix
public double getNorm()
getNorm
in interface RealMatrix
public double getFrobeniusNorm()
getFrobeniusNorm
in interface RealMatrix
public double getTrace()
The trace of the matrix is only defined for square matrices.
getTrace
in interface RealMatrix
public double getMax()
getMax
in interface RealMatrix
public double getMin()
getMin
in interface RealMatrix
public RealMatrix getSubMatrix(int startRow, int endRow, int startColumn, int endColumn)
Rows and columns are indicated counting from 0 to n-1.
getSubMatrix
in interface RealMatrix
startRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column index (inclusive)public RealMatrix getSubMatrix(int[] selectedRows, int[] selectedColumns)
Rows and columns are indicated counting from 0 to n-1.
getSubMatrix
in interface RealMatrix
selectedRows
- the selected row indicesselectedColumns
- the selected column indicespublic void copySubMatrix(int startRow, int endRow, int startColumn, int endColumn, double[][] destination)
Rows and columns are indicated counting from 0 to n-1. The submatrix data is copied in the upper-left part of the destination array. Elements which are not overwritten by the submatrix data are left unchanged (for example, if the destination array is larger than the size of the extracted submatrix).
copySubMatrix
in interface RealMatrix
startRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column index (inclusive)destination
- the 2D array where the submatrix data should be copiedpublic void copySubMatrix(int startRow, int endRow, int startColumn, int endColumn, double[][] destination, int startRowDest, int startColumnDest)
Rows and columns are indicated counting from 0 to n-1. The submatrix data is copied in the upper-left part of the destination array, starting at the specified row/column indices. Elements which are not overwritten by the submatrix data are left unchanged (for example, if the destination array is larger than the size of the extracted submatrix).
copySubMatrix
in interface RealMatrix
startRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column index (inclusive)destination
- the 2D array where the submatrix data should be copiedstartRowDest
- the initial row index of the destination arraystartColumnDest
- the initial column index of the destination arraypublic void copySubMatrix(int[] selectedRows, int[] selectedColumns, double[][] destination)
Rows and columns are indicated counting from 0 to n-1. The submatrix data is copied in the upper-left part of the destination array. Elements which are not overwritten by the submatrix data are left unchanged (for example, if the destination array is larger than the size of the extracted submatrix).
copySubMatrix
in interface RealMatrix
selectedRows
- the selected row indicesselectedColumns
- the selected column indicesdestination
- the 2D array where the submatrix data should be copiedpublic void copySubMatrix(int[] selectedRows, int[] selectedColumns, double[][] destination, int startRowDest, int startColumnDest)
Rows and columns are indicated counting from 0 to n-1. The submatrix data is copied in the upper-left part of the destination array, starting at the specified row/column indices. Elements which are not overwritten by the submatrix data are left unchanged (for example, if the destination array is larger than the size of the extracted submatrix).
copySubMatrix
in interface RealMatrix
selectedRows
- the selected row indicesselectedColumns
- the selected column indicesdestination
- the 2D array where the submatrix data should be copiedstartRowDest
- the initial row index of the destination arraystartColumnDest
- the initial column index of the destination arrayprotected static void checkDestinationArray(int nbRows, int nbColumns, double[][] destination, int startRowDest, int startColumnDest)
null
, and large enough to store the data of a
submatrix.nbRows
- the number of rows of the extracted submatrixnbColumns
- the number of columns of the extracted submatrixdestination
- the 2D array where the submatrix data is to be copiedstartRowDest
- the initial row index in the destination arraystartColumnDest
- the initial column index in the destination arrayNullArgumentException
- if the destination array is null
, or if any of the rows which will store the
submatrix data is null
OutOfRangeException
- if the initial or final index is not a valid index for the destination arrayMatrixDimensionMismatchException
- if the destination array is not large enough to store the submatrix datapublic void setSubMatrix(double[][] subMatrix, int row, int column)
Rows and columns are indicated counting from 0 to n-1.
Usage example:
// Initial matrix matrix = [a00, a10, a20] [a10, a11, a21] [a20, a21, a22] // Submatrix subMatrix = [b00, b01] [b10, b11] // Replace part of the initial matrix matrix.setSubMatrix(subMatrix, 1, 1) =>[a00, a10, a20] [a10, b00, b01] [a20, b10, b11]
setSubMatrix
in interface RealMatrix
subMatrix
- the array containing the submatrix replacement datarow
- the row coordinate of the top, left element to be replacedcolumn
- the column coordinate of the top, left element to be replacedpublic RealMatrix getRowMatrix(int row)
Row indices start at 0.
getRowMatrix
in interface RealMatrix
row
- the index of the row to be fetchedpublic void setRowMatrix(int row, RealMatrix matrix)
Row indices start at 0.
The provided matrix must have one row and the same number of columns as this matrix.
setRowMatrix
in interface RealMatrix
row
- the index of the row to be replacedmatrix
- the row matrix to be copiedpublic RealMatrix getColumnMatrix(int column)
Column indices start at 0.
getColumnMatrix
in interface RealMatrix
column
- the index of the column to be fetchedpublic void setColumnMatrix(int column, RealMatrix matrix)
Column indices start at 0.
The provided matrix must have one column and the same number of rows as this matrix.
setColumnMatrix
in interface RealMatrix
column
- the index of the column to be replacedmatrix
- the column matrix to be copiedpublic RealVector getRowVector(int row)
Row indices start at 0.
getRowVector
in interface RealMatrix
row
- the index of the row to be fetchedpublic void setRowVector(int row, RealVector vector)
Row indices start at 0.
The size of the provided vector must match the column dimension of this matrix.
setRowVector
in interface RealMatrix
row
- the index of the row to be replacedvector
- the row vector to be copiedpublic RealVector getColumnVector(int column)
Column indices start at 0.
getColumnVector
in interface RealMatrix
column
- the index of the column to be fetchedpublic void setColumnVector(int column, RealVector vector)
Column indices start at 0.
The size of the provided vector must match the row dimension of this matrix.
setColumnVector
in interface RealMatrix
column
- the index of the column to be replacedvector
- the column vector to be copiedpublic double[] getRow(int row)
Row indices start at 0.
getRow
in interface RealMatrix
row
- the index of the row to be fetchedpublic void setRow(int row, double[] array)
Row indices start at 0.
The size of the provided data array must match the column dimension of this matrix.
setRow
in interface RealMatrix
row
- the index of the row to be replacedarray
- the row data array to be copiedpublic double[] getColumn(int column)
Column indices start at 0.
getColumn
in interface RealMatrix
column
- the index of the column to be fetchedpublic void setColumn(int column, double[] array)
Column indices start at 0.
The size of the provided data array must match the row dimension of this matrix.
setColumn
in interface RealMatrix
column
- the index of the column to be replacedarray
- the column data array to be copiedpublic void addToEntry(int row, int column, double increment)
Row and column indices start at 0.
addToEntry
in interface RealMatrix
row
- the row index of the entry to be modifiedcolumn
- the column index of the entry to be modifiedincrement
- the value to add to the matrix entrypublic void multiplyEntry(int row, int column, double factor)
this
matrix by a given value.
Row and column indices start at 0.
multiplyEntry
in interface RealMatrix
row
- the row index of the entry to be modifiedcolumn
- the column index of the entry to be modifiedfactor
- the multiplication factor for the matrix entrypublic RealMatrix transpose()
transpose
in interface RealMatrix
public RealMatrix transpose(boolean forceCopy)
If forceCopy
is true
, the returned matrix is guaranteed to be a new instance,
which can be modified without any risk of impacting the current instance. Otherwise, this
method may simply return the current instance when the matrix is its own transpose (symmetric
matrix).
transpose
in interface RealMatrix
forceCopy
- if true
, the transpose of the matrix is systematically stored in a new matrix;
otherwise the method may return the current instance when the matrix is its own
transposepublic RealMatrix concatenateHorizontally(RealMatrix m)
m
, placing it in the right
part of the concatenated matrix.concatenateHorizontally
in interface RealMatrix
m
- the matrix to be concatenated with this matrixpublic RealMatrix concatenateHorizontally(RealMatrix m, boolean rightConcatenation)
m
, , placing it in the left
or right part of the concatenated matrix.
The way the two matrices are concatenated depends on the provided argument:
The matrix m
is placed in the right part of the concatenated matrix if
rightConcatenation
is set to true
, and in its left part if it is set to
false
.
Usage examples:
this.concatenateHorizontally(m, true) => [this, m] this.concatenateHorizontally(m, false) => [m, this]
concatenateHorizontally
in interface RealMatrix
m
- the matrix to be concatenated with this matrixrightConcatenation
- whether the matrix m
is to be placed in the right (true
) or left (
false
) part of the concatenated matrixpublic RealMatrix concatenateVertically(RealMatrix m)
m
, placing it in the lower
part of the concatenated matrix.concatenateVertically
in interface RealMatrix
m
- the matrix to be concatenated with this matrixpublic RealMatrix concatenateVertically(RealMatrix m, boolean lowerConcatenation)
m
, placing it in the lower or
upper part of the concatenated matrix.
The way the two matrices are concatenated depends on the provided argument:
The matrix m
is placed in the lower part of the concatenated matrix if
lowerConcatenation
is set to true
, and in its upper part if it is set to
false
.
Usage examples:
this.concatenateVertically(m, true) => [this] [ m] this.concatenateVertically(m, false) => [ m] [this]
concatenateVertically
in interface RealMatrix
m
- the matrix to be concatenated with this matrixlowerConcatenation
- whether the matrix m
is to be placed in the lower (true
) or upper (
false
) part of the concatenated matrixpublic RealMatrix concatenateDiagonally(RealMatrix m)
m
, placing it in the lower
right part of the concatenated matrix.concatenateDiagonally
in interface RealMatrix
m
- the matrix to be concatenated with this matrixpublic RealMatrix concatenateDiagonally(RealMatrix m, boolean lowerRightConcatenation)
m
, placing it in the lower
right or upper left part of the concatenated matrix.
The way the two matrices are concatenated depends on the provided argument:
The matrix m
is placed in the lower right part of the concatenated matrix if
lowerRightConcatenation
is set to true
, and in its upper left part if it is
set to false
.
Usage examples:
this.concatenateDiagonally(m, true) => [this, 0] [ 0, m] this.concatenateDiagonally(m, false) => [m, 0] [0, this]
concatenateDiagonally
in interface RealMatrix
m
- the matrix to be concatenated with this matrixlowerRightConcatenation
- whether the matrix m
is to be placed in the lower right (true
) or
upper left (false
) part of the concatenated matrixpublic RealMatrix concatenateDiagonally(RealMatrix m, boolean rightConcatenation, boolean lowerConcatenation)
m
.
The way the two matrices are concatenated depends on the provided arguments:
The matrix m
is placed in the right part of the concatenated matrix if
rightConcatenation
is set to true
, and in its left part if it is set to
false
. Similarly, the matrix m
is placed in the lower part of the
concatenated matrix if lowerConcatenation
is set to true
, and in its upper
part if it is set to false
. This matrix is then placed in the opposite part of the
concatenated matrix (as an example, if the provided matrix is placed in the upper left part,
this matrix will be placed in the lower right part, the remaining parts being filled with
zeros).
Usage examples:
// Diagonal concatenation this.concatenateDiagonally(m, true, true) => [this, 0] [ 0, m] this.concatenateDiagonally(m, false, false) => [m, 0] [0, this] // Anti-diagonal concatenation this.concatenateDiagonally(m, false, true) => [0, this] [m, 0] this.concatenateDiagonally(m, true, false) => [ 0, m] [this, 0]
concatenateDiagonally
in interface RealMatrix
m
- the matrix to be concatenated with this matrixrightConcatenation
- whether the matrix m
is to be placed in the right (true
) or left (
false
) part of the concatenated matrixlowerConcatenation
- whether the matrix m
is to be placed in the lower (true
) or upper (
false
) part of the concatenated matrixpublic void setDefaultDecomposition(Function<RealMatrix,Decomposition> defaultDecompositionBuilder)
getInverse()
method should
use by default when computing the inverse of the matrix.setDefaultDecomposition
in interface RealMatrix
defaultDecompositionBuilder
- the default decomposition builderpublic Function<RealMatrix,Decomposition> getDefaultDecomposition()
getInverse()
method uses
by default when computing the inverse of the matrix.
Unless overridden by calling setDefaultDecomposition(Function)
, the default
decomposition is a LU decomposition
with a singularity threshold of .
getDefaultDecomposition
in interface RealMatrix
public RealMatrix getInverse()
The default decomposition builder can be changed using the
setDefaultDecomposition
method.
getInverse
in interface RealMatrix
RealMatrix.getDefaultDecomposition()
,
RealMatrix.setDefaultDecomposition(Function)
public RealMatrix getInverse(Function<RealMatrix,Decomposition> decompositionBuilder)
The decomposition builder is a function capable of generating new instances of the decomposition algorithm to be used for the computation of the inverse matrix (like the QRDecomposition or the EigenDecomposition, for instance).
getInverse
in interface RealMatrix
decompositionBuilder
- the decomposition builder to usepublic boolean isSquare()
public boolean isOrthogonal(double normalityThreshold, double orthogonalityThreshold)
This method indicates if this matrix is orthogonal, taking into account the specified
tolerances.
To do so, the method checks if the columns of the matrix form an orthonormal set (that is,
the column vectors are orthogonal to each other and their norm is numerically equal to 1).
This method systematically returns false
for non-square matrices.
isOrthogonal
in interface RealMatrix
normalityThreshold
- the relative tolerance to take into account when checking the normality of the the
column vectorsorthogonalityThreshold
- the absolute tolerance to take into account when checking the mutual orthogonality of
the the column vectorstrue
if this is an orthogonal matrix, false
otherwisepublic boolean isDiagonal(double absoluteTolerance)
This method indicates if the matrix is diagonal, taking into account the specified tolerance.
To do so, the method checks if the off-diagonal elements are numerically equal to zero.
This method systematically returns false
for non-square matrices.
isDiagonal
in interface RealMatrix
absoluteTolerance
- the absolute threshold above which the absolute value of an off-diagonal element is
considered to be strictly positivetrue
if this is a diagonal matrix, false
otherwisepublic boolean isInvertible(double relativeTolerance)
This method indicates if the matrix is invertible, taking into account the specified
tolerance.
To do so, the method checks the linear independence between the column vectors of the matrix.
Two columns are considered to be linearly dependent if their dot product is numerically equal
to the product of their norm.
This method systematically returns false
for non-square matrices.
isInvertible
in interface RealMatrix
relativeTolerance
- the relative tolerance to take into account when checking the independence of the
column vectorstrue
if this is an invertible matrix, false
otherwisepublic boolean isSymmetric()
This method indicates if the matrix is symmetric.
To do so, the method checks that symmetric off-diagonal elements are numerically equal. Two
elements are considered to have different values if their absolute and relative differences
are both above the default tolerances.
This method systematically returns false
for non-square matrices.
The absolute and relative tolerances both default to Precision.DOUBLE_COMPARISON_EPSILON.
isSymmetric
in interface RealMatrix
true
if this is a symmetric matrix, false
otherwisepublic boolean isSymmetric(double relativeTolerance)
This method indicates if the matrix is symmetric.
To do so, the method checks that symmetric off-diagonal elements are numerically equal. Two
elements are considered to have different values if their relative difference is above the
specified tolerance.
This method systematically returns false
for non-square matrices.
isSymmetric
in interface RealMatrix
relativeTolerance
- the relative tolerance to take into account when comparing off-diagonal elementstrue
if this is a symmetric matrix, false
otherwisepublic boolean isSymmetric(double relativeTolerance, double absoluteTolerance)
This method indicates if the matrix is symmetric.
To do so, the method checks that symmetric off-diagonal elements are numerically equal. Two
elements are considered to have different values if their absolute and relative differences
are both above the specified tolerances.
This method systematically returns false
for non-square matrices.
isSymmetric
in interface RealMatrix
relativeTolerance
- the relative tolerance to take into account when comparing off-diagonal elementsabsoluteTolerance
- the absolute tolerance to take into account when comparing off-diagonal elementstrue
if this is a symmetric matrix, false
otherwisepublic boolean isAntisymmetric(double relativeTolerance, double absoluteTolerance)
This method indicates if the matrix is antisymmetric.
To do so, the method checks that symmetric off-diagonal elements have numerically equal
values but opposite signs, and that diagonal elements are numerically equal to zero. Two
off-diagonal elements are considered to have different values if their absolute and relative
differences are both above the specified tolerances. Diagonal elements are considered to be
different from zero if their absolute value is greater than the specified absolute tolerance.
This method systematically returns false
for non-square matrices.
isAntisymmetric
in interface RealMatrix
relativeTolerance
- the relative tolerance to take into account when comparing off-diagonal elementsabsoluteTolerance
- the absolute tolerance to take into account when comparing off-diagonal elements, and
when checking if diagonal elements are
equal to zerotrue
if this is an antisymmetric matrix, false
otherwisepublic double walkInRowOrder(RealMatrixChangingVisitor visitor)
Row order starts at upper left element, 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
visitor
- the visitor used to process all matrix entriesRealMatrixChangingVisitor.end()
at the end of the walkRealMatrix.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)
Row order starts at upper left element, 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
visitor
- the visitor used to process all matrix entriesRealMatrixPreservingVisitor.end()
at the end of the
walkRealMatrix.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)
Row order starts at upper left element, 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
visitor
- the visitor used to process all matrix entriesstartRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column indexRealMatrixChangingVisitor.end()
at the end of the walkRealMatrix.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)
Row order starts at upper left element, 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
visitor
- the visitor used to process all matrix entriesstartRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column indexRealMatrixPreservingVisitor.end()
at the end of the
walkRealMatrix.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)
Column order starts at upper left element, 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
visitor
- the visitor used to process all matrix entriesRealMatrixChangingVisitor.end()
at the end of the walkRealMatrix.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)
Column order starts at upper left element, 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
visitor
- the visitor used to process all matrix entriesRealMatrixPreservingVisitor.end()
at the end of the
walkRealMatrix.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)
Column order starts at upper left element, 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
visitor
- the visitor used to process all matrix entriesstartRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column indexRealMatrixChangingVisitor.end()
at the end of the walkRealMatrix.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)
Column order starts at upper left element, 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
visitor
- the visitor used to process all matrix entriesstartRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column indexRealMatrixPreservingVisitor.end()
at the end of the
walkRealMatrix.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)
public double walkInOptimizedOrder(RealMatrixChangingVisitor visitor)
The fastest walking order depends on the exact matrix class. It may be different from traditional row or column orders.
walkInOptimizedOrder
in interface RealMatrix
visitor
- the visitor used to process all matrix entriesRealMatrixChangingVisitor.end()
at the end of the walkRealMatrix.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.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInOptimizedOrder(RealMatrixPreservingVisitor visitor)
The fastest walking order depends on the exact matrix class. It may be different from traditional row or column orders.
walkInOptimizedOrder
in interface RealMatrix
visitor
- the visitor used to process all matrix entriesRealMatrixPreservingVisitor.end()
at the end of the
walkRealMatrix.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.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInOptimizedOrder(RealMatrixChangingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn)
The fastest walking order depends on the exact matrix class. It may be different from traditional row or column orders.
walkInOptimizedOrder
in interface RealMatrix
visitor
- the visitor used to process all matrix entriesstartRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column index (inclusive)RealMatrixChangingVisitor.end()
at the end of the walkRealMatrix.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.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor, int, int, int, int)
public double walkInOptimizedOrder(RealMatrixPreservingVisitor visitor, int startRow, int endRow, int startColumn, int endColumn)
The fastest walking order depends on the exact matrix class. It may be different from traditional row or column orders.
walkInOptimizedOrder
in interface RealMatrix
visitor
- the visitor used to process all matrix entriesstartRow
- the initial row indexendRow
- the final row index (inclusive)startColumn
- the initial column indexendColumn
- the final column index (inclusive)RealMatrixPreservingVisitor.end()
at the end of the
walkRealMatrix.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.walkInColumnOrder(RealMatrixPreservingVisitor, int, int, int, int)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixPreservingVisitor)
,
RealMatrix.walkInOptimizedOrder(RealMatrixChangingVisitor, int, int, int, int)
public String toString()
Default format is MatrixUtils.VISUAL_FORMAT
.
public String toString(RealMatrixFormat realMatrixFormat)
Several predefined matrix formats are available in MatrixUtils.
toString
in interface RealMatrix
realMatrixFormat
- the matrix format to be usedMatrixUtils.JAVA_FORMAT
,
MatrixUtils.OCTAVE_FORMAT
,
MatrixUtils.VISUAL_FORMAT
,
MatrixUtils.SUMMARY_FORMAT
public boolean equals(Object object)
true
if the provided object is a RealMatrix instance with the
same dimensions as this matrix, whose entries are strictly equal to the entries of this
matrix (no absolute or relative tolerance is taken into account when comparing the entries).public boolean equals(RealMatrix m, double relativeThreshold, double absoluteThreshold)
This method indicates if this matrix is equal to another matrix.
To do so, the method checks that the two matrices have the same row/column dimensions, and
that all entries are numerically equal. Two elements are considered to have different values
if their absolute and relative differences are both above the specified tolerances.
equals
in interface RealMatrix
m
- the matrix to be tested for equalityrelativeThreshold
- the relative tolerance to take into account when comparing the entries of the matricesabsoluteThreshold
- the absolute tolerance to take into account when comparing the entries of the matricestrue
if the tested matrix is numerically equivalent to this matrix,
false
otherwisepublic int hashCode()
public abstract int getRowDimension()
getRowDimension
in interface AnyMatrix
getRowDimension
in class RealLinearOperator
public abstract int getColumnDimension()
getColumnDimension
in interface AnyMatrix
getColumnDimension
in class RealLinearOperator
public abstract double getEntry(int row, int column)
Row and column indices start at 0.
getEntry
in interface RealMatrix
row
- the row index of entry to be fetchedcolumn
- the column index of entry to be fetchedpublic abstract void setEntry(int row, int column, double value)
Row and column indices start at 0.
setEntry
in interface RealMatrix
row
- the row index of entry to be setcolumn
- the column index of entry to be setvalue
- the new value of the entrypublic abstract RealMatrix createMatrix(int rowDimension, int columnDimension)
The returned matrix is filled with zeros. Its size is determined by the specified row and column dimensions, which must both be strictly positive. Additional constraints on the dimensions may apply depending on the implementation (for example, symmetric matrices must be square, which implies that the row and column dimensions must be equal).
createMatrix
in interface RealMatrix
rowDimension
- the number of rows in the new matrixcolumnDimension
- the number of columns in the new matrixpublic abstract RealMatrix copy()
copy
in interface RealMatrix
Copyright © 2023 CNES. All rights reserved.