public class ArrayRowSymmetricPositiveMatrix extends ArrayRowSymmetricMatrix implements SymmetricPositiveMatrix
This implementation stores the elements of the lower triangular part of a symmetric matrix. These
elements are stored in a 1D array, row after row. For example, for a 3 by 3 matrix we have:
(1) = s1,1;
(2) = s2,1; (3) = s2,2;
(4) = s3,1; (5) = s3,2; (6) = s3,3;
The elements actually stored depends on the type of symmetry specified at construction:
LOWER or
UPPER
implies the symmetry is enforced by keeping only the lower or upper triangular part of the
matrix, while
MEAN
enforces the symmetry by computing the mean of the lower and upper elements. The symmetry of the
provided matrix is not checked by default, meaning that the symmetry is enforced regardless of
the inputs. However, such a check can be triggered by setting the default absolute or relative
symmetry threshold to a non-null value, or by specifying any of these thresholds at construction.
Note that the default values for these symmetry thresholds are shared with
ArrayRowSymmetricMatrix.
In contrast, the positivity of the symmetrized matrix is always checked by default. This check
can be disabled by setting the absolute and relative positivity thresholds to null,
either by changing the default values or by overriding them at construction. A symmetric matrix
is considered to be positive semi-definite if all its pivots are strictly positive, or if the
pivot and the associated row/column are equal to zero. Possible numerical errors are taken into
account by adding a small value (which depends on the specified tolerances) to the diagonal
elements of the matrix. The relative tolerance is relative to the maximum row sum norm of the
matrix.
Important:
Since it might induce a loss of positivity or definiteness, modifying any element of the matrix
is forbidden.
ArrayRowSymmetricMatrix,
Serialized FormArrayRowSymmetricMatrix.SymmetryType| Modifier | Constructor and Description |
|---|---|
|
ArrayRowSymmetricPositiveMatrix(ArrayRowSymmetricMatrix.SymmetryType symmetryType,
double[][] dataIn)
Builds a new
ArrayRowSymmetricPositiveMatrix from the provided data, using the
default symmetry and positivity thresholds. |
|
ArrayRowSymmetricPositiveMatrix(ArrayRowSymmetricMatrix.SymmetryType symmetryType,
double[][] dataIn,
Double absoluteSymmetryThreshold,
Double relativeSymmetryThreshold,
Double absolutePositivityThreshold,
Double relativePositivityThreshold)
Builds a new
ArrayRowSymmetricPositiveMatrix from the provided data, using the
specified symmetry and positivity thresholds. |
|
ArrayRowSymmetricPositiveMatrix(ArrayRowSymmetricMatrix.SymmetryType symmetryType,
RealMatrix matrix)
Builds a new
ArrayRowSymmetricPositiveMatrix from the provided matrix, using the
default symmetry and positivity thresholds. |
|
ArrayRowSymmetricPositiveMatrix(ArrayRowSymmetricMatrix.SymmetryType symmetryType,
RealMatrix matrix,
Double absoluteSymmetryThreshold,
Double relativeSymmetryThreshold,
Double absolutePositivityThreshold,
Double relativePositivityThreshold)
Builds a new
ArrayRowSymmetricPositiveMatrix from the provided matrix, using the
specified symmetry and positivity thresholds. |
protected |
ArrayRowSymmetricPositiveMatrix(double[] dataIn,
boolean copyArray)
Builds a new
ArrayRowSymmetricPositiveMatrix by specifying the lower triangular part
of the matrix directly. |
|
ArrayRowSymmetricPositiveMatrix(int n)
Builds a new
ArrayRowSymmetricPositiveMatrix of dimension n (filled with zero). |
| Modifier and Type | Method and Description |
|---|---|
ArrayRowSymmetricMatrix |
add(SymmetricMatrix m)
Returns the result of adding the symmetric matrix
m to this matrix. |
ArrayRowSymmetricPositiveMatrix |
add(SymmetricPositiveMatrix m)
Returns the result of adding the symmetric positive semi-definite 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 |
checkPositiveSemiDefinite(SymmetricMatrix symmetricMatrix,
double tolerance)
Ensures a symmetric matrix is positive semi-definite and throws an exception if that's not
the case.
|
ArrayRowSymmetricPositiveMatrix |
copy()
Returns a deep copy of this matrix.
|
static ArrayRowSymmetricPositiveMatrix |
createIdentityMatrix(int dim)
Creates an identity matrix of the specified dimension.
|
ArrayRowSymmetricPositiveMatrix |
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). |
static Double |
getDefaultAbsolutePositivityThreshold()
Gets the default absolute positivity threshold, above which a value is considered to be
strictly positive.
|
static Double |
getDefaultRelativePositivityThreshold()
Gets the default relative positivity threshold, above which a value is considered to be
numerically significant when compared to another value.
|
protected static double |
getEffectiveTolerance(Double absoluteTolerance,
Double relativeTolerance,
double maxValue)
Gets the effective tolerance from a given absolute and relative tolerance.
|
ArrayRowSymmetricPositiveMatrix |
getInverse()
Gets the inverse (or pseudo-inverse) of this matrix using the default decomposition.
|
ArrayRowSymmetricPositiveMatrix |
getInverse(Function<RealMatrix,Decomposition> decompositionBuilder)
Gets the inverse (or pseudo-inverse) of this matrix using the given decomposition algorithm.
|
ArrayRowSymmetricPositiveMatrix |
getSubMatrix(int[] index)
Extracts the submatrix corresponding to the specified indices.
|
RealMatrix |
getSubMatrix(int[] selectedRows,
int[] selectedColumns)
Gets a submatrix.
|
ArrayRowSymmetricPositiveMatrix |
getSubMatrix(int startIndex,
int endIndex)
Extracts the submatrix corresponding to the specified indices.
|
RealMatrix |
getSubMatrix(int startRow,
int endRow,
int startColumn,
int endColumn)
Gets a submatrix.
|
int |
hashCode()
Computes a hash code for the matrix.
|
boolean |
isPositiveSemiDefinite(double absoluteTolerance)
Determines if this matrix is positive semi-definite or not.
|
static boolean |
isPositiveSemiDefinite(SymmetricMatrix symmetricMatrix,
double absoluteTolerance)
Determines if a symmetric matrix is positive semi-definite or not.
|
void |
multiplyEntry(int row,
int column,
double factor)
Multiplies (in place) the specified entry of
this matrix by a given value. |
ArrayRowSymmetricPositiveMatrix |
positiveScalarAdd(double d)
Returns the result of adding a positive scalar
d to the entries of this matrix. |
ArrayRowSymmetricPositiveMatrix |
positiveScalarMultiply(double d)
Returns the result of multiplying the entries of this matrix by a positive scalar
d. |
ArrayRowSymmetricPositiveMatrix |
power(int p)
Returns the the result of multiplying this matrix with itself
p times. |
ArrayRowSymmetricPositiveMatrix |
quadraticMultiplication(RealMatrix m)
Returns the result of the quadratic multiplication M×
this×MT,
where M is the provided matrix. |
ArrayRowSymmetricPositiveMatrix |
quadraticMultiplication(RealMatrix m,
boolean isTranspose)
Returns the result of the quadratic multiplication M×
this×MT,
where M or MT is the provided matrix. |
ArrayRowSymmetricMatrix |
scalarAdd(double d)
Returns the result of adding a scalar
d to the entries of this matrix. |
ArrayRowSymmetricMatrix |
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.
|
static void |
setDefaultAbsolutePositivityThreshold(Double threshold)
Sets the default absolute positivity threshold, above which a value is considered to be
positive.
|
static void |
setDefaultRelativePositivityThreshold(Double threshold)
Sets the default relative positivity threshold, above which a value is considered to be
numerically significant when compared to another value.
|
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.
|
ArrayRowSymmetricPositiveMatrix |
transpose()
Returns the transpose of this matrix.
|
ArrayRowSymmetricPositiveMatrix |
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 |
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 |
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.
|
add, add, checkAbsoluteThreshold, checkDataArray, checkMatrix, checkRelativeThreshold, concatenateDiagonally, concatenateHorizontally, concatenateVertically, getColumnDimension, getColumnMatrix, getDataRef, getDefaultAbsoluteSymmetryThreshold, getDefaultRelativeSymmetryThreshold, getEntry, getRowDimension, getRowMatrix, isSquare, isSymmetric, isSymmetric, isSymmetric, multiply, multiply, setDefaultAbsoluteSymmetryThreshold, setDefaultRelativeSymmetryThreshold, subtract, subtract, subtractcheckDestinationArray, checkSquare, concatenateDiagonally, concatenateDiagonally, concatenateHorizontally, concatenateVertically, copySubMatrix, copySubMatrix, copySubMatrix, copySubMatrix, equals, getAbs, getColumn, getColumnVector, getData, getData, getDefaultDecomposition, getDiagonal, getFrobeniusNorm, getMax, getMin, getNorm, getRow, getRowVector, getTrace, isAntisymmetric, isDiagonal, isInvertible, isOrthogonal, multiply, multiply, operate, operate, preMultiply, preMultiply, preMultiply, setDefaultDecomposition, toString, toString, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrderisTransposable, operateTransposeclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetDiagonal, subtractadd, concatenateDiagonally, concatenateDiagonally, concatenateDiagonally, concatenateHorizontally, concatenateHorizontally, concatenateVertically, concatenateVertically, copySubMatrix, copySubMatrix, copySubMatrix, copySubMatrix, equals, getAbs, getColumn, getColumnMatrix, getColumnVector, getData, getData, getDefaultDecomposition, getEntry, getFrobeniusNorm, getMax, getMax, getMin, getMin, getNorm, getRow, getRowMatrix, getRowVector, getTrace, isAntisymmetric, isDiagonal, isInvertible, isOrthogonal, isSymmetric, isSymmetric, isSymmetric, multiply, multiply, multiply, operate, operate, preMultiply, preMultiply, preMultiply, setDefaultDecomposition, subtract, toString, walkInColumnOrder, walkInColumnOrder, walkInOptimizedOrder, walkInOptimizedOrder, walkInRowOrder, walkInRowOrdergetColumnDimension, getRowDimension, isSquarepublic ArrayRowSymmetricPositiveMatrix(int n)
ArrayRowSymmetricPositiveMatrix of dimension n (filled with zero).n - the dimension of the matrixpublic ArrayRowSymmetricPositiveMatrix(ArrayRowSymmetricMatrix.SymmetryType symmetryType, double[][] dataIn)
ArrayRowSymmetricPositiveMatrix from the provided data, using the
default symmetry and positivity thresholds.symmetryType - the type of symmetry enforced at constructiondataIn - the data of the matrix (must be a NxN array)ArrayRowSymmetricMatrix.getDefaultRelativeSymmetryThreshold(),
getDefaultAbsolutePositivityThreshold()public ArrayRowSymmetricPositiveMatrix(ArrayRowSymmetricMatrix.SymmetryType symmetryType, double[][] dataIn, Double absoluteSymmetryThreshold, Double relativeSymmetryThreshold, Double absolutePositivityThreshold, Double relativePositivityThreshold)
ArrayRowSymmetricPositiveMatrix from the provided data, using the
specified symmetry and positivity thresholds.
The provided thresholds must either be null, or set to a positive value. Setting both
the absolute and relative thresholds to null completely disables the associated
symmetry or positivity check. Any null threshold is considered to be equal to zero if
the associated check is not disabled.
symmetryType - the type of symmetry enforced at constructiondataIn - the data of the matrix (must be a NxN array)absoluteSymmetryThreshold - the absolute symmetry threshold, above which off-diagonal elements are considered
differentrelativeSymmetryThreshold - the relative symmetry threshold, above which off-diagonal elements are considered
differentabsolutePositivityThreshold - the absolute positivity threshold, above which a value is considered to be strictly
positiverelativePositivityThreshold - the relative positivity threshold, above which a value is considered to be numerically
significant when compared to anothervaluepublic ArrayRowSymmetricPositiveMatrix(ArrayRowSymmetricMatrix.SymmetryType symmetryType, RealMatrix matrix)
ArrayRowSymmetricPositiveMatrix from the provided matrix, using the
default symmetry and positivity thresholds.symmetryType - the type of symmetry enforced at constructionmatrix - the matrix (must NxN)ArrayRowSymmetricMatrix.getDefaultRelativeSymmetryThreshold(),
getDefaultAbsolutePositivityThreshold()public ArrayRowSymmetricPositiveMatrix(ArrayRowSymmetricMatrix.SymmetryType symmetryType, RealMatrix matrix, Double absoluteSymmetryThreshold, Double relativeSymmetryThreshold, Double absolutePositivityThreshold, Double relativePositivityThreshold)
ArrayRowSymmetricPositiveMatrix from the provided matrix, using the
specified symmetry and positivity thresholds.
The provided thresholds must either be null, or set to a positive value. Setting both
the absolute and relative thresholds to null completely disables the associated
symmetry or positivity check. Any null threshold is considered to be equal to zero if
the associated check is not disabled.
symmetryType - the type of symmetry enforced at constructionmatrix - the matrix (must NxN)absoluteSymmetryThreshold - the absolute symmetry threshold, above which off-diagonal elements are considered
differentrelativeSymmetryThreshold - the relative symmetry threshold, above which off-diagonal elements are considered
differentabsolutePositivityThreshold - the absolute positivity threshold, above which a value is considered to be strictly
positiverelativePositivityThreshold - the relative positivity threshold, above which a value is considered to be numerically
significant when compared to another valueNonPositiveDefiniteMatrixException - if the matrix is not positive semi-definiteprotected ArrayRowSymmetricPositiveMatrix(double[] dataIn,
boolean copyArray)
ArrayRowSymmetricPositiveMatrix by specifying the lower triangular part
of the matrix directly.
No check is made on the positivity or definiteness of the matrix. This constructor should only be used when the matrix defined by the provided data is positive semi-definite by construction.
dataIn - the array storing the lower triangular part of the matrixcopyArray - if true, the provided array will be copied, otherwise it will be passed by
referencepublic void setEntry(int row,
int column,
double value)
Row and column indices start at 0.
This method automatically modify the symmetric element to ensure the symmetry of the matrix is preserved.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
setEntry in interface RealMatrixsetEntry in class ArrayRowSymmetricMatrixrow - the row index of entry to be setcolumn - the column index of entry to be setvalue - the new value of the entryMathUnsupportedOperationException - systematically (this operation is forbidden)public void addToEntry(int row,
int column,
double increment)
Row and column indices start at 0.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
addToEntry in interface RealMatrixaddToEntry in class ArrayRowSymmetricMatrixrow - 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 entryMathUnsupportedOperationException - systematically, since this operation is not supportedpublic void multiplyEntry(int row,
int column,
double factor)
this matrix by a given value.
Row and column indices start at 0.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
multiplyEntry in interface RealMatrixmultiplyEntry in class ArrayRowSymmetricMatrixrow - the row index of the entry to be modifiedcolumn - the column index of the entry to be modifiedfactor - the multiplication factor for the matrix entryMathUnsupportedOperationException - systematically, since this operation is not supportedpublic RealMatrix getSubMatrix(int startRow, int endRow, int startColumn, int endColumn)
Rows and columns are indicated counting from 0 to n-1.
The returned matrix is an ArrayRowSymmetricMatrix if the selected indices are the same for the rows and the columns, and an Array2DRowRealMatrix or a BlockRealMatrix otherwise.
The returned matrix is an ArrayRowSymmetricPositiveMatrix if the selected indices are the same for the rows and the columns, and an Array2DRowRealMatrix or a BlockRealMatrix otherwise.
getSubMatrix in interface RealMatrixgetSubMatrix in class ArrayRowSymmetricMatrixstartRow - 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.
The returned matrix is an ArrayRowSymmetricMatrix if the selected indices are the same for the rows and the columns (same indices, same order), and an Array2DRowRealMatrix or a BlockRealMatrix otherwise.
The returned matrix is an ArrayRowSymmetricPositiveMatrix if the selected indices are the same for the rows and the columns (same indices, same order), and an Array2DRowRealMatrix or a BlockRealMatrix otherwise.
getSubMatrix in interface RealMatrixgetSubMatrix in class ArrayRowSymmetricMatrixselectedRows - the selected row indicesselectedColumns - the selected column indicespublic ArrayRowSymmetricPositiveMatrix getSubMatrix(int startIndex, int endIndex)
This method uses the same start/end indices to select the rows and columns to be extracted. These indices must be valid indices with respect to the dimensions of the matrix (valid indices range from 0 to n-1, with n the row/column dimension of the matrix). Calling this method is equivalent to calling RealMatrix.getSubMatrix(int, int, int, int) using the same start/end indices for the rows and columns. The extracted submatrix is guaranteed to be symmetric. It will also remain positive semi-definite if the initial matrix originally is.
Usage examples:
// Initial matrix
matrix = [a00, a10, a20]
[a10, a11, a21]
[a20, a21, a22]
// Submatrix extraction
matrix.getSubMatrix(1, 2) => [a11, a21]
[a21, a22]
getSubMatrix in interface SymmetricMatrixgetSubMatrix in interface SymmetricPositiveMatrixgetSubMatrix in class ArrayRowSymmetricMatrixstartIndex - the initial row/column indexendIndex - the final row/column index (inclusive)public ArrayRowSymmetricPositiveMatrix getSubMatrix(int[] index)
This method uses a single index array to select the rows and columns to be extracted. All indices must be valid indices with respect to the dimensions of the matrix (valid indices range from 0 to n-1, with n the row/column dimension of the matrix). The provided index array is allowed to contain duplicates. Calling this method is equivalent to calling RealMatrix.getSubMatrix(int[], int[]) using the provided index array for the selected rows and columns. This method can be used to extract any submatrix and perform a symmetric reordering of its rows/columns. The extracted submatrix is guaranteed to be symmetric. It will also remain positive semi-definite if the initial matrix originally is.
Usage examples:
// Initial matrix
matrix = [a00, a10, a20]
[a10, a11, a21]
[a20, a21, a22]
// Submatrix extraction
matrix.getSubMatrix([1, 2]) => [a11, a21]
[a21, a22]
// Rows/Columns permutation
matrix.getSubMatrix([1, 2, 0]) => [a11, a21, a10]
[a21, a22, a20]
[a10, a20, a00]
// Submatrix extraction (with duplicated indices)
matrix.getSubMatrix([1, 2, 0, 1, 0])
=> [a11, a21, a10, a11, a10]
[a21, a22, a20, a21, a20]
[a10, a20, a00, a10, a00]
[a11, a21, a10, a11, a10]
[a10, a20, a00, a10, a00]
getSubMatrix in interface SymmetricMatrixgetSubMatrix in interface SymmetricPositiveMatrixgetSubMatrix in class ArrayRowSymmetricMatrixindex - the selected indicespublic void setSubMatrix(double[][] subMatrix,
int row,
int column)
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
setSubMatrix in interface RealMatrixsetSubMatrix in class ArrayRowSymmetricMatrixsubMatrix - the array containing the replacement data of the targeted submatrixrow - the row coordinate of the top, left element to be replacedcolumn - the column coordinate of the top, left element to be replacedMathUnsupportedOperationException - systematically, since this operation is not supportedpublic 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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
setRow in interface RealMatrixsetRow in class AbstractRealMatrixrow - the index of the row to be replacedarray - the row data array to be copiedMathUnsupportedOperationException - systematically, since this operation is not supportedpublic 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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
setRowVector in interface RealMatrixsetRowVector in class AbstractRealMatrixrow - the index of the row to be replacedvector - the row vector to be copiedMathUnsupportedOperationException - systematically, since this operation is not supportedpublic 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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
setRowMatrix in interface RealMatrixsetRowMatrix in class AbstractRealMatrixrow - the index of the row to be replacedmatrix - the row matrix to be copiedMathUnsupportedOperationException - systematically, since this operation is not supportedpublic 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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
setColumn in interface RealMatrixsetColumn in class AbstractRealMatrixcolumn - the index of the column to be replacedarray - the column data array to be copiedMathUnsupportedOperationException - systematically, since this operation is not supportedpublic 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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
setColumnVector in interface RealMatrixsetColumnVector in class AbstractRealMatrixcolumn - the index of the column to be replacedvector - the column vector to be copiedMathUnsupportedOperationException - systematically, since this operation is not supportedpublic 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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
setColumnMatrix in interface RealMatrixsetColumnMatrix in class AbstractRealMatrixcolumn - the index of the column to be replacedmatrix - the column matrix to be copiedMathUnsupportedOperationException - systematically, since this operation is not supportedpublic ArrayRowSymmetricMatrix scalarAdd(double d)
d to the entries of this matrix.scalarAdd in interface RealMatrixscalarAdd in interface SymmetricMatrixscalarAdd in class ArrayRowSymmetricMatrixd - the scalar value to be added to the entries of this matrixthis+dpublic ArrayRowSymmetricPositiveMatrix positiveScalarAdd(double d)
d to the entries of this matrix.positiveScalarAdd in interface SymmetricPositiveMatrixd - the positive scalar value to be added to the entries of this matrixthis+
dpublic ArrayRowSymmetricMatrix scalarMultiply(double d)
d.scalarMultiply in interface RealMatrixscalarMultiply in interface SymmetricMatrixscalarMultiply in class ArrayRowSymmetricMatrixd - the scalar value by which to multiply the entries of this matrix bythis×dpublic ArrayRowSymmetricPositiveMatrix positiveScalarMultiply(double d)
d.positiveScalarMultiply in interface SymmetricPositiveMatrixd - the positive scalar value by which to multiply the entries of this matrix byd
×thispublic ArrayRowSymmetricMatrix add(SymmetricMatrix m)
m to this matrix.
The returned matrix is, in order of priority:
add in interface SymmetricMatrixadd in class ArrayRowSymmetricMatrixm - the matrix to be addedthis+mpublic ArrayRowSymmetricPositiveMatrix add(SymmetricPositiveMatrix m)
m to this
matrix.add in interface SymmetricPositiveMatrixm - the symmetric positive semi-definite matrix to be addedthis+
mpublic ArrayRowSymmetricPositiveMatrix quadraticMultiplication(RealMatrix m)
this×MT,
where M is the provided matrix.quadraticMultiplication in interface SymmetricMatrixquadraticMultiplication in interface SymmetricPositiveMatrixquadraticMultiplication in class ArrayRowSymmetricMatrixm - the matrix Mthis
×MTpublic ArrayRowSymmetricPositiveMatrix quadraticMultiplication(RealMatrix m, boolean isTranspose)
this×MT,
where M or MT is the provided matrix.quadraticMultiplication in interface SymmetricMatrixquadraticMultiplication in interface SymmetricPositiveMatrixquadraticMultiplication in class ArrayRowSymmetricMatrixm - the matrix M or the matrix MTisTranspose - if true, assumes the provided matrix is MT, otherwise assumes it is
Mthis
×MTpublic ArrayRowSymmetricPositiveMatrix 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 RealMatrixpower in interface SymmetricMatrixpower in interface SymmetricPositiveMatrixpower in class ArrayRowSymmetricMatrixp - the exponent p to which this matrix is to be raisedppublic ArrayRowSymmetricPositiveMatrix 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 RealMatrixcreateMatrix in interface SymmetricMatrixcreateMatrix in interface SymmetricPositiveMatrixcreateMatrix in class ArrayRowSymmetricMatrixrowDimension - the number of rows in the new matrixcolumnDimension - the number of columns in the new matrixpublic static ArrayRowSymmetricPositiveMatrix createIdentityMatrix(int dim)
dim - the dimension of the identity matrixpublic ArrayRowSymmetricPositiveMatrix copy()
copy in interface RealMatrixcopy in interface SymmetricMatrixcopy in interface SymmetricPositiveMatrixcopy in class ArrayRowSymmetricMatrixpublic ArrayRowSymmetricPositiveMatrix transpose()
transpose in interface RealMatrixtranspose in interface SymmetricMatrixtranspose in interface SymmetricPositiveMatrixtranspose in class ArrayRowSymmetricMatrixpublic ArrayRowSymmetricPositiveMatrix 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 RealMatrixtranspose in interface SymmetricMatrixtranspose in interface SymmetricPositiveMatrixtranspose in class ArrayRowSymmetricMatrixforceCopy - 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 ArrayRowSymmetricPositiveMatrix getInverse()
The default decomposition builder can be changed using the
setDefaultDecomposition method.
getInverse in interface RealMatrixgetInverse in interface SymmetricMatrixgetInverse in interface SymmetricPositiveMatrixgetInverse in class ArrayRowSymmetricMatrixRealMatrix.getDefaultDecomposition(),
RealMatrix.setDefaultDecomposition(Function)public ArrayRowSymmetricPositiveMatrix 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 RealMatrixgetInverse in interface SymmetricMatrixgetInverse in interface SymmetricPositiveMatrixgetInverse in class ArrayRowSymmetricMatrixdecompositionBuilder - the decomposition builder to usepublic boolean isPositiveSemiDefinite(double absoluteTolerance)
A symmetric matrix is considered to be positive semi-definite if its pivots are either strictly positive, or if the whole row is equal to zero after reduction (pivot included). In order to take into account possible numerical errors, the specified tolerance is added to the diagonal elements of the initial matrix.
absoluteTolerance - the absolute tolerance to take into accounttrue if this matrix is positive semi-definite, false otherwisepublic static boolean isPositiveSemiDefinite(SymmetricMatrix symmetricMatrix, double absoluteTolerance)
A symmetric matrix is considered to be positive semi-definite if its pivots are either strictly positive, or if the whole row is equal to zero after reduction (pivot included). In order to take into account possible numerical errors, the specified tolerance is added to the diagonal elements of the initial matrix.
symmetricMatrix - the symmetric matrix to be checkedabsoluteTolerance - the absolute tolerance to take into accounttrue if the provided matrix is positive semi-definite, false
otherwisepublic 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).equals in class ArrayRowSymmetricMatrixobject - the object to be tested for equalitytrue if the provided object is equal to this matrixpublic int hashCode()
hashCode in class ArrayRowSymmetricMatrixpublic 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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
walkInRowOrder in interface RealMatrixwalkInRowOrder in class AbstractRealMatrixvisitor - the visitor used to process all matrix entriesRealMatrixChangingVisitor.end() at the end of the walkMathUnsupportedOperationException - systematically (this operation is forbidden)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),
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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
walkInRowOrder in interface RealMatrixwalkInRowOrder in class AbstractRealMatrixvisitor - 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 walkMathUnsupportedOperationException - systematically (this operation is forbidden)RealMatrix.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 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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
walkInColumnOrder in interface RealMatrixwalkInColumnOrder in class AbstractRealMatrixvisitor - the visitor used to process all matrix entriesRealMatrixChangingVisitor.end() at the end of the walkMathUnsupportedOperationException - systematically (this operation is forbidden)RealMatrix.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(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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
walkInColumnOrder in interface RealMatrixwalkInColumnOrder in class AbstractRealMatrixvisitor - 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 walkMathUnsupportedOperationException - systematically (this operation is forbidden)RealMatrix.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 walkInOptimizedOrder(RealMatrixChangingVisitor visitor)
The fastest walking order depends on the exact matrix class. It may be different from traditional row or column orders.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
walkInOptimizedOrder in interface RealMatrixwalkInOptimizedOrder in class AbstractRealMatrixvisitor - the visitor used to process all matrix entriesRealMatrixChangingVisitor.end() at the end of the walkMathUnsupportedOperationException - systematically (this operation is forbidden)RealMatrix.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(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.
Important:
This method systematically throws a MathUnsupportedOperationException since this
operation is not safe when dealing with symmetric positive definite matrices (the properties
of the matrix are not guaranteed to be preserved).
walkInOptimizedOrder in interface RealMatrixwalkInOptimizedOrder in class AbstractRealMatrixvisitor - 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 walkMathUnsupportedOperationException - systematically (this operation is forbidden)RealMatrix.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 static Double getDefaultAbsolutePositivityThreshold()
null)public static void setDefaultAbsolutePositivityThreshold(Double threshold)
threshold - the new default absolute positivity threshold (≥0 or null)IllegalArgumentException - if the provided threshold is NaN or is strictly negativepublic static Double getDefaultRelativePositivityThreshold()
null)public static void setDefaultRelativePositivityThreshold(Double threshold)
threshold - the new default relative positivity threshold (≥0 or null)IllegalArgumentException - if the provided threshold is NaN or is strictly negativeprotected static void checkPositiveSemiDefinite(SymmetricMatrix symmetricMatrix, double tolerance)
A symmetric matrix is considered to be positive semi-definite if its pivots are either strictly positive, or if the whole row is equal to zero after reduction (pivot included). In order to take into account possible numerical errors, the specified tolerance is added to the diagonal elements of the initial matrix.
symmetricMatrix - the symmetric matrix to be checkedtolerance - the absolute tolerance to take into accountNonPositiveDefiniteMatrixException - if the provided matrix is not positive semi-definiteprotected static double getEffectiveTolerance(Double absoluteTolerance, Double relativeTolerance, double maxValue)
The effective tolerance is the largest value between the specified absolute tolerance and the
relative tolerance multiplied by the provided element value. The provided tolerances default
to zero when they are null.
absoluteTolerance - the absolute tolerancerelativeTolerance - the relative tolerancemaxValue - the value to which the relative tolerance is to be appliedCopyright © 2025 CNES. All rights reserved.