org.geotools.referencing.operation.matrix
Class Matrix1

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

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:
Serialized Form
Module:

Field Summary
 double m00
          The only element in this matrix.
static int SIZE
          The matrix size, which is 1.
 
Constructor Summary
Matrix1()
          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
 Matrix1 clone()
          Returns a clone of this matrix.
 boolean equals(Matrix matrix, double tolerance)
          Compares the element values regardless the object class.
 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.
 double getElement(int row, int col)
          Returns the element at the specified index.
 int getNumCol()
          Returns the number of colmuns in this matrix, which is always 1 in this implementation.
 int getNumRow()
          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.
 void invert()
          Inverts this matrix in place.
 boolean isAffine()
          Returns true if this matrix is an affine transform.
 boolean isIdentity()
          Returns true if this matrix is an identity matrix.
 boolean isIdentity(double tolerance)
          Returns true if this matrix is an identity matrix using the provided tolerance.
 void multiply(Matrix matrix)
          Sets the value of this matrix to the result of multiplying itself with the specified matrix.
 void negate()
          Negates the value of this matrix: this = -this.
 void setElement(int row, int col, double value)
          Set the element at the specified index.
 void setIdentity()
          Sets this matrix to the identity matrix.
 void setZero()
          Sets all the values in this matrix to zero.
 String toString()
          Returns a string representation of this matrix.
 void transpose()
          Sets the value of this matrix to its transpose.
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

m00

public double m00
The only element in this matrix.


SIZE

public static final int SIZE
The matrix size, which is 1.

See Also:
Constant Field Values
Constructor Detail

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 Detail

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 XMatrix
Specified by:
getNumRow in interface 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 XMatrix
Specified by:
getNumCol in interface Matrix

getElement

public final double getElement(int row,
                               int col)
Returns the element at the specified index.

Specified by:
getElement in interface XMatrix
Specified by:
getElement in interface Matrix

setElement

public final void setElement(int row,
                             int col,
                             double value)
Set the element at the specified index.

Specified by:
setElement in interface XMatrix
Specified by:
setElement in interface Matrix

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 XMatrix
Specified by:
isIdentity in interface 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

transpose

public final void transpose()
Sets the value of this matrix to its transpose.

Specified by:
transpose in interface XMatrix

invert

public final void invert()
Inverts this matrix in place.

Specified by:
invert in interface XMatrix

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 regardless the object class. This is similar to a call to GMatrix.epsilonEquals(matrix, tolerance). The method name is intentionally different in order to avoid ambiguities at compile-time.

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 Matrix
Overrides:
clone in class Object


Copyright © 1996-2009 Geotools. All Rights Reserved.