Interface XMatrix
- All Known Implementing Classes:
GeneralMatrix,Matrix1,Matrix2,Matrix3,Matrix4
A matrix capable of some matrix operations. The basic
Matrix interface is basically just a two dimensional
array of numbers. The XMatrix interface add inversion and multiplication capabilities.- Since:
- 2.2
- Author:
- Martin Desruisseaux (IRD), Simone Giannecchini
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(double scalar) Performs an in-place scalar addition.voidSet to the scalar addition ofscalar+matrixvoidSet to the matrix addition ofthis+matrix.voidSet to the matrix addition ofmatrix1+matrix2.doubleComputes the determinantbooleanCompares the element values.voidgetColumn(int col, double[] array) Extract col to provided array.doublegetElement(int row, int column) Returns the element at the specified index.intReturns the number of colmuns in this matrix.intReturns the number of rows in this matrix.voidgetRow(int row, double[] array) Extract row to provided arrayvoidinvert()Inverts this matrix in place.voidSet to the inverse of the provided matrix.booleanisAffine()Returnstrueif this matrix is an affine transform.booleanisIdentity(double tolerance) Returnstrueif this matrix is an identity matrix using the provided tolerance.voidmul(double scalar) Sets this matrix to the result of multiplying itself with the provided scalar.voidSets the value of this matrix to the result of multiplying the provided scalar and matrix.voidSets the value of this matrix to the result of multiplying itself with the specified matrix.voidSets the value of this matrix to the result of multiplying matrix1 and matrix2.voidSets the value of this matrix to the result of multiplying itself with the specified matrix.voidnegate()Negates the value of this matrix:this = -this.voidNegates the value of this matrix:this = -matrix.voidsetColumn(int column, double... values) Sets the value of the column using an array of values.voidSets this matrix to the identity matrix.voidsetRow(int row, double... values) Sets the value of the row using an array of values.voidsetZero()Sets all the values in this matrix to zero.voidsub(double scalar) In-place matrix subtraction:this - scalar.voidSet to the difference ofscalar - matrix2.voidIn-place matrix subtraction:this - matrix.voidSet to the difference ofmatrix1 - matrix2.voidSets the value of this matrix to its transpose.voidSet to the transpose of the provided matrix.Methods inherited from interface Matrix
clone, isIdentity, setElement
-
Method Details
-
getNumRow
int getNumRow()Returns the number of rows in this matrix. -
getNumCol
int getNumCol()Returns the number of colmuns in this matrix. -
getElement
double getElement(int row, int column) Returns the element at the specified index.- Specified by:
getElementin interfaceMatrix- Parameters:
row- The row number to be retrieved (zero indexed).column- The column number to be retrieved (zero indexed).- Returns:
- The value at the indexed element.
-
getRow
void getRow(int row, double[] array) Extract row to provided array -
setRow
void setRow(int row, double... values) Sets the value of the row using an array of values. -
getColumn
void getColumn(int col, double[] array) Extract col to provided array. -
setColumn
void setColumn(int column, double... values) Sets the value of the column using an array of values. -
setZero
void setZero()Sets all the values in this matrix to zero. -
setIdentity
void setIdentity()Sets this matrix to the identity matrix. -
isIdentity
boolean isIdentity(double tolerance) Returnstrueif this matrix is an identity matrix using the provided tolerance. This method is equivalent to computing the difference between this matrix and an identity matrix of identical size, and returningtrueif and only if all differences are smaller than or equal totolerance.- Parameters:
tolerance- The tolerance value.- Returns:
trueif this matrix is close enough to the identity matrix given the tolerance value.- Since:
- 2.4
-
equals
Compares the element values.- Parameters:
matrix- The matrix to compare.tolerance- The tolerance value.- Returns:
trueif this matrix is close enough to the given matrix given the tolerance value.- Since:
- 2.5
-
isAffine
boolean isAffine()Returnstrueif this matrix is an affine transform. A transform is affine if the matrix is square and last row contains only zeros, except in the last column which contains 1.- Returns:
trueif this matrix is affine.
-
negate
void negate()Negates the value of this matrix:this = -this. -
negate
Negates the value of this matrix:this = -matrix.- Parameters:
matrix- Matrix to negated
-
transpose
void transpose()Sets the value of this matrix to its transpose. -
transpose
Set to the transpose of the provided matrix.- Parameters:
matrix- The original matrix. Not modified.
-
invert
Inverts this matrix in place.- Throws:
SingularMatrixException- if this matrix is not invertible.
-
invert
Set to the inverse of the provided matrix.- Parameters:
matrix- The matrix that is to be inverted. Not modified.- Throws:
SingularMatrixException- if this matrix is not invertible.
-
add
void add(double scalar) Performs an in-place scalar addition.- Parameters:
scalar- The value that's added to each element.
-
add
Set to the scalar addition ofscalar+matrix- Parameters:
scalar- The value that's added to each element.matrix- The matrix that is to be added. Not modified.
-
add
Set to the matrix addition ofthis+matrix.- Parameters:
matrix- The matrix that is to be added. Not modified.
-
add
Set to the matrix addition ofmatrix1+matrix2.- Parameters:
matrix1- First matrix to be added. Not modified.matrix2- Second matrix to be added. Not modified.
-
determinate
double determinate()Computes the determinant -
multiply
Sets the value of this matrix to the result of multiplying itself with the specified matrix. In other words, performsthis=this×matrix. In the context of coordinate transformations, this is equivalent toAffineTransform.concatenate: first transforms by the supplied transform and then transform the result by the original transform.- Parameters:
matrix- The matrix to multiply to this matrix.
-
mul
void mul(double scalar) Sets this matrix to the result of multiplying itself with the provided scalar. -
mul
Sets the value of this matrix to the result of multiplying the provided scalar and matrix. -
mul
Sets the value of this matrix to the result of multiplying itself with the specified matrix. In other words, performsthis=this×matrix. In the context of coordinate transformations, this is equivalent toAffineTransform.concatenate: first transforms by the supplied transform and then transform the result by the original transform.- Parameters:
matrix- The matrix to multiply to this matrix.
-
mul
Sets the value of this matrix to the result of multiplying matrix1 and matrix2. -
sub
void sub(double scalar) In-place matrix subtraction:this - scalar. -
sub
Set to the difference ofscalar - matrix2.- Parameters:
matrix- matrix, not modified
-
sub
In-place matrix subtraction:this - matrix.- Parameters:
matrix- m by n matrix. Not modified.
-
sub
Set to the difference ofmatrix1 - matrix2.- Parameters:
matrix1- matrix, not modifiedmatrix2- matrix, not modified
-