Object
Matrix1
All Implemented Interfaces:
Serializable, Cloneable, Matrix, Cloneable, XMatrix

public class Matrix1 extends Object implements XMatrix, Serializable
A matrix of fixed 1×1 size. This trivial matrix is returned as a result of MathTransform1D derivative computation.
Since:
2.2
Author:
Martin Desruisseaux (IRD)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    double
    The only element in this matrix.
    static final int
    The matrix size, which is 1.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new identity matrix.
    Matrix1(double m00)
    Creates a new matrix initialized to the specified value.
    Matrix1(Matrix matrix)
    Creates a new matrix initialized to the same value than the specified one.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(double scalar)
    Performs an in-place scalar addition.
    void
    add(double scalar, XMatrix matrix)
    Set to the scalar addition of scalar+matrix
    void
    add(XMatrix matrix)
    Set to the matrix addition of this+matrix.
    void
    add(XMatrix matrix1, XMatrix matrix2)
    Set to the matrix addition of matrix1+matrix2.
    Returns a clone of this matrix.
    double
    Computes the determinant
    boolean
    equals(Object object)
    Returns true if the specified object is of type Matrix1 and all of the data members are equal to the corresponding data members in this matrix.
    boolean
    equals(Matrix matrix, double tolerance)
    Compares the element values.
    void
    getColumn(int column, double[] array)
    Extract col to provided array.
    final double
    getElement(int row, int col)
    Returns the element at the specified index.
    final int
    Returns the number of colmuns 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.
    void
    getRow(int row, double[] array)
    Extract row to provided array
    int
    Returns a hash code value based on the data values in this object.
    final void
    Inverts this matrix in place.
    void
    invert(Matrix matrix)
    Set to the inverse of the provided matrix.
    final boolean
    Returns true if this matrix is an affine transform.
    final boolean
    Returns true if this matrix is an identity matrix.
    final boolean
    isIdentity(double tolerance)
    Returns true if this matrix is an identity matrix using the provided tolerance.
    void
    mul(double scalar)
    Sets this matrix to the result of multiplying itself with the provided scalar.
    void
    mul(double scalar, Matrix matrix)
    Sets the value of this matrix to the result of multiplying the provided scalar and matrix.
    void
    mul(Matrix matrix)
    Sets the value of this matrix to the result of multiplying itself with the specified matrix.
    void
    mul(Matrix matrix1, Matrix matrix2)
    Sets the value of this matrix to the result of multiplying matrix1 and matrix2.
    final void
    multiply(Matrix matrix)
    Sets the value of this matrix to the result of multiplying itself with the specified matrix.
    final void
    Negates the value of this matrix: this = -this.
    void
    negate(Matrix matrix)
    Negates the value of this matrix: this = -matrix.
    void
    setColumn(int column, double... values)
    Sets the value of the column using an array of values.
    final void
    setElement(int row, int col, double value)
    Modifies the value at the specified row and column of this matrix.
    final void
    Sets this matrix to the identity matrix.
    void
    setRow(int row, double... values)
    Sets the value of the row using an array of values.
    final void
    Sets all the values in this matrix to zero.
    void
    sub(double scalar)
    In-place matrix subtraction: this - scalar.
    void
    sub(double scalar, Matrix matrix)
    Set to the difference of scalar - matrix2.
    void
    sub(Matrix matrix)
    In-place matrix subtraction: this - matrix.
    void
    sub(Matrix matrix1, Matrix matrix2)
    Set to the difference of matrix1 - matrix2.
    Returns a string representation of this matrix.
    final void
    Sets the value of this matrix to its transpose.
    void
    transpose(Matrix matrix)
    Set to the transpose of the provided matrix.

    Methods inherited from class Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • m00

      public double m00
      The only element in this matrix.
    • SIZE

      public static final int SIZE
      The matrix size, which is 1.
      See Also:
  • Constructor Details

    • Matrix1

      public Matrix1()
      Creates a new identity matrix.
    • Matrix1

      public Matrix1(double m00)
      Creates a new matrix initialized to the specified value.
    • Matrix1

      public Matrix1(Matrix matrix)
      Creates a new matrix initialized to the same value than the specified one. The specified matrix size must be 1×1.
  • Method Details

    • getNumRow

      public final int getNumRow()
      Returns the number of rows in this matrix, which is always 1 in this implementation.
      Specified by:
      getNumRow in interface Matrix
      Specified by:
      getNumRow in interface XMatrix
      Returns:
      The number of rows in this matrix.
    • getNumCol

      public final int getNumCol()
      Returns the number of colmuns in this matrix, which is always 1 in this implementation.
      Specified by:
      getNumCol in interface Matrix
      Specified by:
      getNumCol in interface XMatrix
      Returns:
      The number of columns in this matrix.
    • getElement

      public final double getElement(int row, int col)
      Returns the element at the specified index.
      Specified by:
      getElement in interface Matrix
      Specified by:
      getElement in interface XMatrix
      Parameters:
      row - The row number to be retrieved (zero indexed).
      col - The column number to be retrieved (zero indexed).
      Returns:
      The value at the indexed element.
    • setElement

      public final void setElement(int row, int col, double value)
      Modifies the value at the specified row and column of this matrix.
      Specified by:
      setElement in interface Matrix
      Parameters:
      row - The row number to be retrieved (zero indexed).
      col - The column number to be retrieved (zero indexed).
      value - The new matrix element value.
    • setZero

      public final void setZero()
      Sets all the values in this matrix to zero.
      Specified by:
      setZero in interface XMatrix
    • setIdentity

      public final void setIdentity()
      Sets this matrix to the identity matrix.
      Specified by:
      setIdentity in interface XMatrix
    • isIdentity

      public final boolean isIdentity()
      Returns true if this matrix is an identity matrix.
      Specified by:
      isIdentity in interface Matrix
      Returns:
      true if this matrix is an identity matrix.
    • isIdentity

      public final boolean isIdentity(double tolerance)
      Returns true if 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 returning true if and only if all differences are smaller than or equal to tolerance.
      Specified by:
      isIdentity in interface XMatrix
      Parameters:
      tolerance - The tolerance value.
      Returns:
      true if this matrix is close enough to the identity matrix given the tolerance value.
    • isAffine

      public final boolean isAffine()
      Returns true if 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.
      Specified by:
      isAffine in interface XMatrix
      Returns:
      true if this matrix is affine.
    • negate

      public final void negate()
      Negates the value of this matrix: this = -this.
      Specified by:
      negate in interface XMatrix
    • negate

      public void negate(Matrix matrix)
      Description copied from interface: XMatrix
      Negates the value of this matrix: this = -matrix.
      Specified by:
      negate in interface XMatrix
      Parameters:
      matrix - Matrix to negated
    • transpose

      public final void transpose()
      Sets the value of this matrix to its transpose.
      Specified by:
      transpose in interface XMatrix
    • transpose

      public void transpose(Matrix matrix)
      Description copied from interface: XMatrix
      Set to the transpose of the provided matrix.
      Specified by:
      transpose in interface XMatrix
      Parameters:
      matrix - The original matrix. Not modified.
    • invert

      public final void invert()
      Inverts this matrix in place.
      Specified by:
      invert in interface XMatrix
    • invert

      public void invert(Matrix matrix) throws SingularMatrixException
      Description copied from interface: XMatrix
      Set to the inverse of the provided matrix.
      Specified by:
      invert in interface XMatrix
      Parameters:
      matrix - The matrix that is to be inverted. Not modified.
      Throws:
      SingularMatrixException - if this matrix is not invertible.
    • multiply

      public final void multiply(Matrix matrix)
      Sets the value of this matrix to the result of multiplying itself with the specified matrix. In other words, performs this = this × matrix. In the context of coordinate transformations, this is equivalent to AffineTransform.concatenate: first transforms by the supplied transform and then transform the result by the original transform.
      Specified by:
      multiply in interface XMatrix
      Parameters:
      matrix - The matrix to multiply to this matrix.
    • equals

      public boolean equals(Matrix matrix, double tolerance)
      Compares the element values.
      Specified by:
      equals in interface XMatrix
      Parameters:
      matrix - The matrix to compare.
      tolerance - The tolerance value.
      Returns:
      true if this matrix is close enough to the given matrix given the tolerance value.
    • equals

      public boolean equals(Object object)
      Returns true if the specified object is of type Matrix1 and all of the data members are equal to the corresponding data members in this matrix.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Returns a hash code value based on the data values in this object.
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Returns a string representation of this matrix. The returned string is implementation dependent. It is usually provided for debugging purposes only.
      Overrides:
      toString in class Object
    • clone

      public Matrix1 clone()
      Returns a clone of this matrix.
      Specified by:
      clone in interface Cloneable
      Specified by:
      clone in interface Matrix
      Overrides:
      clone in class Object
      Returns:
      A clone of this matrix.
      See Also:
    • getRow

      public void getRow(int row, double[] array)
      Description copied from interface: XMatrix
      Extract row to provided array
      Specified by:
      getRow in interface XMatrix
    • setRow

      public void setRow(int row, double... values)
      Description copied from interface: XMatrix
      Sets the value of the row using an array of values.
      Specified by:
      setRow in interface XMatrix
    • getColumn

      public void getColumn(int column, double[] array)
      Description copied from interface: XMatrix
      Extract col to provided array.
      Specified by:
      getColumn in interface XMatrix
    • setColumn

      public void setColumn(int column, double... values)
      Description copied from interface: XMatrix
      Sets the value of the column using an array of values.
      Specified by:
      setColumn in interface XMatrix
    • add

      public void add(double scalar)
      Description copied from interface: XMatrix
      Performs an in-place scalar addition.
      Specified by:
      add in interface XMatrix
      Parameters:
      scalar - The value that's added to each element.
    • add

      public void add(double scalar, XMatrix matrix)
      Description copied from interface: XMatrix
      Set to the scalar addition of scalar+matrix
      Specified by:
      add in interface XMatrix
      Parameters:
      scalar - The value that's added to each element.
      matrix - The matrix that is to be added. Not modified.
    • add

      public void add(XMatrix matrix)
      Description copied from interface: XMatrix
      Set to the matrix addition of this+matrix.
      Specified by:
      add in interface XMatrix
      Parameters:
      matrix - The matrix that is to be added. Not modified.
    • add

      public void add(XMatrix matrix1, XMatrix matrix2)
      Description copied from interface: XMatrix
      Set to the matrix addition of matrix1+matrix2.
      Specified by:
      add in interface XMatrix
      Parameters:
      matrix1 - First matrix to be added. Not modified.
      matrix2 - Second matrix to be added. Not modified.
    • determinate

      public double determinate()
      Description copied from interface: XMatrix
      Computes the determinant
      Specified by:
      determinate in interface XMatrix
    • mul

      public void mul(double scalar)
      Description copied from interface: XMatrix
      Sets this matrix to the result of multiplying itself with the provided scalar.
      Specified by:
      mul in interface XMatrix
    • mul

      public void mul(double scalar, Matrix matrix)
      Description copied from interface: XMatrix
      Sets the value of this matrix to the result of multiplying the provided scalar and matrix.
      Specified by:
      mul in interface XMatrix
    • mul

      public void mul(Matrix matrix)
      Description copied from interface: XMatrix
      Sets the value of this matrix to the result of multiplying itself with the specified matrix. In other words, performs this = this × matrix. In the context of coordinate transformations, this is equivalent to AffineTransform.concatenate: first transforms by the supplied transform and then transform the result by the original transform.
      Specified by:
      mul in interface XMatrix
      Parameters:
      matrix - The matrix to multiply to this matrix.
    • mul

      public void mul(Matrix matrix1, Matrix matrix2)
      Description copied from interface: XMatrix
      Sets the value of this matrix to the result of multiplying matrix1 and matrix2.
      Specified by:
      mul in interface XMatrix
    • sub

      public void sub(double scalar)
      Description copied from interface: XMatrix
      In-place matrix subtraction: this - scalar.
      Specified by:
      sub in interface XMatrix
    • sub

      public void sub(Matrix matrix)
      Description copied from interface: XMatrix
      In-place matrix subtraction: this - matrix.
      Specified by:
      sub in interface XMatrix
      Parameters:
      matrix - m by n matrix. Not modified.
    • sub

      public void sub(double scalar, Matrix matrix)
      Description copied from interface: XMatrix
      Set to the difference of scalar - matrix2.
      Specified by:
      sub in interface XMatrix
      matrix - matrix, not modified
    • sub

      public void sub(Matrix matrix1, Matrix matrix2)
      Description copied from interface: XMatrix
      Set to the difference of matrix1 - matrix2.
      Specified by:
      sub in interface XMatrix
      Parameters:
      matrix1 - matrix, not modified
      matrix2 - matrix, not modified