Class Matrix1
java.lang.Object
org.apache.sis.referencing.operation.matrix.MatrixSIS
org.apache.sis.referencing.operation.matrix.Matrix1
- All Implemented Interfaces:
Serializable
,Cloneable
,LenientComparable
,org.opengis.referencing.operation.Matrix
A matrix of fixed 1×1 size,
typically resulting from
MathTransform1D
derivative computation.
The matrix member is:
┌ ┐ │ m00 │ └ ┘
- Since:
- 0.4
- Version:
- 1.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptiondouble
The only element in this matrix.private static final long
Serial number for inter-operability with different versions.static final int
The matrix size, which is 1. -
Constructor Summary
ConstructorsConstructorDescriptionMatrix1()
Creates a new identity matrix.Matrix1
(boolean ignore) Creates a new matrix filled with only zero values.Matrix1
(double m00) Creates a new matrix initialized to the specified value.Matrix1
(double[] elements) Creates a new matrix initialized to the specified values.Matrix1
(org.opengis.referencing.operation.Matrix matrix) Creates a new matrix initialized to the same value than the specified one. -
Method Summary
Modifier and TypeMethodDescriptionstatic Matrix1
castOrCopy
(org.opengis.referencing.operation.Matrix matrix) Casts or copies the given matrix to aMatrix1
implementation.clone()
Returns a clone of this matrix.boolean
Returnstrue
if the specified object is of typeMatrix1
and all of the data members are equal to the corresponding data members in this matrix.final double
getElement
(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.(package private) final void
getElements
(double[] elements) Copies the matrix elements in the given flat array.final int
Returns the number of columns in this matrix, which is always 1 in this implementation.final int
Returns the number of rows in this matrix, which is always 1 in this implementation.int
hashCode()
Returns a hash code value based on the data values in this object.final boolean
isAffine()
Returnstrue
if this matrix represents an affine transform.final boolean
Returnstrue
if this matrix is an identity matrix.Normalizes all columns in-place.final void
setElement
(int row, int column, double value) Modifies the value at the specified row and column of this matrix.final void
setElements
(double[] elements) Sets all matrix elements from a flat, row-major (column indices vary fastest) array.void
For a 1×1 matrix, this method does nothing.Methods inherited from class org.apache.sis.referencing.operation.matrix.MatrixSIS
convertAfter, convertBefore, ensureLengthMatch, ensureNumRowMatch, ensureSizeMatch, equals, equals, get, getElements, getInteger, getNumber, indexOutOfBounds, inverse, isAffine, isExtendedPrecision, multiply, multiply, removeColumns, removeRows, set, setElements, setMatrix, setNumber, solve, toString, translate
-
Field Details
-
serialVersionUID
private static final long serialVersionUIDSerial number for inter-operability with different versions.- See Also:
-
SIZE
public static final int SIZEThe matrix size, which is 1.- See Also:
-
m00
public double m00The only element in this matrix.
-
-
Constructor Details
-
Matrix1
public Matrix1()Creates a new identity matrix. -
Matrix1
Matrix1(boolean ignore) Creates a new matrix filled with only zero values.- Parameters:
ignore
- shall always befalse
in current version.
-
Matrix1
public Matrix1(double m00) Creates a new matrix initialized to the specified value.- Parameters:
m00
- The element in this matrix.
-
Matrix1
Creates 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:
-
Matrix1
Matrix1(org.opengis.referencing.operation.Matrix matrix) Creates a new matrix initialized to the same value than the specified one. The specified matrix size must be 1×1. This is not verified by this constructor, since it shall be verified byMatrices
.- Parameters:
matrix
- the matrix to copy.
-
-
Method Details
-
castOrCopy
public static Matrix1 castOrCopy(org.opengis.referencing.operation.Matrix matrix) throws MismatchedMatrixSizeException Casts or copies the given matrix to aMatrix1
implementation. If the givenmatrix
is already an instance ofMatrix1
, then it is returned unchanged. Otherwise this method verifies the matrix size, then copies the element in a newMatrix1
object.- Parameters:
matrix
- the matrix to cast or copy, ornull
.- Returns:
- the matrix argument if it can be safely casted (including
null
argument), or a copy of the given matrix otherwise. - Throws:
MismatchedMatrixSizeException
- if the size of the given matrix is not 1×1.
-
getNumRow
public final int getNumRow()Returns the number of rows in this matrix, which is always 1 in this implementation.- Returns:
- always 1.
-
getNumCol
public final int getNumCol()Returns the number of columns in this matrix, which is always 1 in this implementation.- Returns:
- always 1.
-
getElement
public 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 them00
field can be read directly for efficiency.- Specified by:
getElement
in interfaceorg.opengis.referencing.operation.Matrix
- Specified by:
getElement
in classMatrixSIS
- Parameters:
row
- the row index, which can only be 0.column
- the column index, which can only be 0.- Returns:
- the current value.
-
setElement
public 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 them00
field 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.
-
getElements
public final double[] getElements()Returns all matrix elements in a flat, row-major (column indices vary fastest) array. The array length is 1.- Overrides:
getElements
in classMatrixSIS
- Returns:
- a copy of all current matrix elements in a row-major array.
-
getElements
final void getElements(double[] elements) Copies the matrix elements in the given flat array. The array length shall be at least 1, may also be 2.- Overrides:
getElements
in classMatrixSIS
- Parameters:
elements
- the destination array. May be longer than necessary (this happen when the caller needs to appendDoubleDouble.error
values after the elements).
-
setElements
public 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:
setElements
in classMatrixSIS
- Parameters:
elements
- The new matrix elements in a row-major array.- See Also:
-
isAffine
public final boolean isAffine()Returnstrue
if 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. -
isIdentity
public final boolean isIdentity()Returnstrue
if this matrix is an identity matrix. This method is equivalent to the following code, except that it is potentially more efficient:- Specified by:
isIdentity
in interfaceorg.opengis.referencing.operation.Matrix
- Specified by:
isIdentity
in classMatrixSIS
- Returns:
true
if this matrix is an identity matrix.- See Also:
-
transpose
public void transpose()For a 1×1 matrix, this method does nothing. -
normalizeColumns
Normalizes all columns in-place. For a 1×1 matrix with non-NaN value, this method sets them00
value to +1, -1 or 0 with the same sign than the original value.- Overrides:
normalizeColumns
in classMatrixSIS
- Returns:
- the magnitude of the column, which is the absolute value of
m00
.
-
clone
Returns a clone of this matrix. -
equals
Returnstrue
if the specified object is of typeMatrix1
and all of the data members are equal to the corresponding data members in this matrix.- Specified by:
equals
in interfaceLenientComparable
- Overrides:
equals
in classMatrixSIS
- Parameters:
object
- the object to compare with this matrix for equality.- Returns:
true
if the given object is equal to this matrix.- See Also:
-
hashCode
public int hashCode()Returns a hash code value based on the data values in this object.
-