Class Matrix1
- All Implemented Interfaces:
- Serializable,- Cloneable,- LenientComparable,- Matrix
A matrix of fixed 1×1 size,
 typically resulting from 
MathTransform1D derivative computation.
 The matrix member is:
 ┌ ┐ │ m00 │ └ ┘
- Since:
- 0.4
- See Also:
Defined in the sis-referencing module
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic Matrix1castOrCopy(Matrix matrix) Casts or copies the given matrix to aMatrix1implementation.clone()Returns a clone of this matrix.booleanReturnstrueif the specified object is of typeMatrix1and all of the data members are equal to the corresponding data members in this matrix.final doublegetElement(int row, int column) Retrieves the value at the specified row and column of this matrix.final double[]Returns all matrix elements in a flat, row-major (column indices vary fastest) array.final intReturns the number of columns in this matrix, which is always 1 in this implementation.final intReturns the number of rows in this matrix, which is always 1 in this implementation.intReturns a hash code value based on the data values in this object.final booleanReturnstrueif this matrix represents an affine transform.final booleanReturnstrueif this matrix is an identity matrix.Normalizes all columns in-place.final voidsetElement(int row, int column, double value) Modifies the value at the specified row and column of this matrix.final voidsetElements(double[] elements) Sets all matrix elements from a flat, row-major (column indices vary fastest) array.voidFor a 1×1 matrix, this method does nothing.Methods inherited from class MatrixSISconvertAfter, convertBefore, equals, equals, getInteger, getNumber, inverse, multiply, multiply, removeColumns, removeRows, setMatrix, setNumber, solve, toString, translate
- 
Field Details- 
SIZEpublic static final int SIZEThe matrix size, which is 1.- See Also:
 
- 
m00public double m00The only element in this matrix.
 
- 
- 
Constructor Details- 
Matrix1public Matrix1()Creates a new identity matrix.
- 
Matrix1public Matrix1(double m00) Creates a new matrix initialized to the specified value.- Parameters:
- m00- The element in this matrix.
 
- 
Matrix1Creates a new matrix initialized to the specified values. The length of the given array must be 1.- Parameters:
- elements- elements of the matrix.
- Throws:
- IllegalArgumentException- if the given array does not have the expected length.
- See Also:
 
 
- 
- 
Method Details- 
castOrCopyCasts or copies the given matrix to aMatrix1implementation. If the givenmatrixis already an instance ofMatrix1, then it is returned unchanged. Otherwise this method verifies the matrix size, then copies the element in a newMatrix1object.- Parameters:
- matrix- the matrix to cast or copy, or- null.
- Returns:
- the matrix argument if it can be safely casted (including nullargument), or a copy of the given matrix otherwise.
- Throws:
- MismatchedMatrixSizeException- if the size of the given matrix is not 1×1.
 
- 
getNumRowpublic final int getNumRow()Returns the number of rows in this matrix, which is always 1 in this implementation.- Returns:
- always 1.
 
- 
getNumColpublic final int getNumCol()Returns the number of columns in this matrix, which is always 1 in this implementation.- Returns:
- always 1.
 
- 
getElementpublic final double getElement(int row, int column) Retrieves the value at the specified row and column of this matrix. This method can be invoked when the matrix size or type is unknown. If the matrix is known to be an instance ofMatrix1, then them00field can be read directly for efficiency.- Specified by:
- getElementin interface- Matrix
- Specified by:
- getElementin class- MatrixSIS
- Parameters:
- row- the row index, which can only be 0.
- column- the column index, which can only be 0.
- Returns:
- the current value.
 
- 
setElementpublic final void setElement(int row, int column, double value) Modifies the value at the specified row and column of this matrix. This method can be invoked when the matrix size or type is unknown. If the matrix is known to be an instance ofMatrix1, then them00field can be set directly for efficiency.- Parameters:
- row- the row index, which can only be 0.
- column- the column index, which can only be 0.
- value- the new value to set.
 
- 
getElementspublic final double[] getElements()Returns all matrix elements in a flat, row-major (column indices vary fastest) array. The array length is 1.- Overrides:
- getElementsin class- MatrixSIS
- Returns:
- a copy of all current matrix elements in a row-major array.
 
- 
setElementspublic final void setElements(double[] elements) Sets all matrix elements from a flat, row-major (column indices vary fastest) array. The array length shall be 1.- Specified by:
- setElementsin class- MatrixSIS
- Parameters:
- elements- The new matrix elements in a row-major array.
- See Also:
 
- 
isAffinepublic final boolean isAffine()Returnstrueif this matrix represents an affine transform. A transform is affine if the matrix is square and its last row contains only zeros, except in the last column which contains 1.- Overrides:
- isAffinein class- MatrixSIS
- Returns:
- trueif this matrix represents an affine transform.
- See Also:
 
- 
isIdentitypublic final boolean isIdentity()Returnstrueif this matrix is an identity matrix. This method is equivalent to the following code, except that it is potentially more efficient:return Matrices.isIdentity(this, 0.0); - Specified by:
- isIdentityin interface- Matrix
- Specified by:
- isIdentityin class- MatrixSIS
- Returns:
- trueif this matrix is an identity matrix.
- See Also:
 
- 
transposepublic void transpose()For a 1×1 matrix, this method does nothing.- Specified by:
- transposein class- MatrixSIS
 
- 
normalizeColumnsNormalizes all columns in-place. For a 1×1 matrix with non-NaN value, this method sets them00value to +1, -1 or 0 with the same sign than the original value.- Overrides:
- normalizeColumnsin class- MatrixSIS
- Returns:
- the magnitude of the column, which is the absolute value of m00.
 
- 
cloneReturns a clone of this matrix.- Specified by:
- clonein interface- Matrix
- Overrides:
- clonein class- MatrixSIS
- Returns:
- a new matrix of the same class and with the same values than this matrix.
- See Also:
 
- 
equalsReturnstrueif the specified object is of typeMatrix1and all of the data members are equal to the corresponding data members in this matrix.- Specified by:
- equalsin interface- LenientComparable
- Overrides:
- equalsin class- MatrixSIS
- Parameters:
- object- the object to compare with this matrix for equality.
- Returns:
- trueif the given object is equal to this matrix.
- See Also:
 
- 
hashCodepublic int hashCode()Returns a hash code value based on the data values in this object.- Overrides:
- hashCodein class- MatrixSIS
- Returns:
- a hash code value for this matrix.
 
 
-