org.geotoolkit.referencing.operation.matrix
Class MatrixFactory

Object
  extended by Static
      extended by MatrixFactory

public final class MatrixFactory
extends Static

Static utility methods for creating matrix. This factory selects one of the Matrix1, Matrix2, Matrix3, Matrix4 or GeneralMatrix implementation according the desired matrix size. Note that if the matrix size is know at compile time, it may be more efficient to invoke directly the constructor of the appropriate class instead.

Since:
2.2
Version:
3.16
Author:
Martin Desruisseaux (IRD, Geomatys)
Module:
referencing/geotk-referencing (download)    View source code for this class

Method Summary
static XMatrix create(int size)
          Creates a square identity matrix of size size × size.
static XMatrix create(int numRow, int numCol)
          Creates a matrix of size numRow × numCol.
static XMatrix create(int numRow, int numCol, double[] elements)
          Creates a matrix of size numRow × numCol initialized to the given elements.
static XMatrix create(Matrix matrix)
          Creates a new matrix which is a copy of the specified matrix.
static Matrix getMatrix(MathTransform transform)
          If the given transform is linear, returns its coefficients as a matrix.
static GeneralMatrix toGeneralMatrix(Matrix matrix)
          Converts the specified matrix to GeneralMatrix.
static XMatrix toOptimalMatrix(Matrix matrix)
          Converts the specified matrix to the most suitable Geotk implementation.
static XMatrix toXMatrix(Matrix matrix)
          Converts the specified matrix to a Geotk implementation.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static XMatrix create(int size)
Creates a square identity matrix of size size × size.

Parameters:
size - For an affine transform, this is the number of source and target dimensions + 1.
Returns:
An identity matrix of the given size.

create

public static XMatrix create(int numRow,
                             int numCol)
Creates a matrix of size numRow × numCol. Elements on the diagonal (j == i) are set to 1.

Parameters:
numRow - For an affine transform, this is the number of target dimensions + 1.
numCol - For an affine transform, this is the number of source dimensions + 1.
Returns:
An identity matrix of the given size.

create

public static XMatrix create(int numRow,
                             int numCol,
                             double[] elements)
Creates a matrix of size numRow × numCol initialized to the given elements. The elements array size must be equals to numRow*numCol. Column indices vary fastest, as expected by the GeneralMatrix.GeneralMatrix(int,int,double[]) constructor.

Parameters:
numRow - Number of rows.
numCol - Number of columns.
elements - Elements of the matrix. Column indices vary fastest.
Returns:
A matrix initialized to the given elements.
Since:
3.00

create

public static XMatrix create(Matrix matrix)
Creates a new matrix which is a copy of the specified matrix.

Parameters:
matrix - The matrix to copy.
Returns:
A copy of the given matrix.

getMatrix

public static Matrix getMatrix(MathTransform transform)
If the given transform is linear, returns its coefficients as a matrix. More specifically:

Parameters:
transform - The transform, or null.
Returns:
The matrix of the given transform, or null if none.
Since:
3.16 (derived from 3.15)

toXMatrix

public static XMatrix toXMatrix(Matrix matrix)
Converts the specified matrix to a Geotk implementation. If matrix is already an instance of XMatrix, then it is returned unchanged. Otherwise all elements are copied in a new XMatrix object.

Parameters:
matrix - The matrix to convert, or null.
Returns:
The given matrix, or a copy of it as a XMatrix object, or null if the given matrix was null.
Since:
3.16 (derived from 3.00)

toOptimalMatrix

public static XMatrix toOptimalMatrix(Matrix matrix)
Converts the specified matrix to the most suitable Geotk implementation. This method process as below:

Using those specialized implementations brings a little bit of performance and, more important, precision in the floating point results of matrix operations.

Parameters:
matrix - The matrix to convert, or null.
Returns:
The given matrix, or a copy of it as a XMatrix object.
Since:
3.16 (derived from 3.00)

toGeneralMatrix

public static GeneralMatrix toGeneralMatrix(Matrix matrix)
Converts the specified matrix to GeneralMatrix. If matrix is already an instance of GeneralMatrix, then it is returned unchanged. Otherwise all elements are copied in a new GeneralMatrix object.

Consider using toXMatrix(Matrix) instead than this method if a XMatrix instance is sufficient. Use this method only if a GeneralMatrix is really necessary.

Parameters:
matrix - The matrix to convert, or null.
Returns:
The given matrix, or a copy of it as a GeneralMatrix object.
Since:
3.16 (derived from 3.00)


Copyright © 2009-2011 Geotoolkit.org. All Rights Reserved.