MatrixFunctions Namespace Reference

A collection of matrix functions. More...


Classes

class  MatrixObject
 The MatrixObject is a trait object for use with the Resource template. More...
class  MatrixResource
 This is a Resource class that creates and destroys two-dimensional matrices. More...

Functions

template<typename T>
T ** createMatrix (const int &numRows, const int &numCols, const T *pInitialData)
template<typename T>
bool deleteMatrix (T **&pMatrix)
bool computeSingularValueDecomposition (const double **pMatrix, double *pSingularValues, double **pColumnMatrix, double **pOrthogonalMatrix, const int &numRows, const int &numCols)
bool solveLinearEquation (double *pResult, const double **pLhs, const double *pRhs, const int &numRows, const int &numColsLhs)
bool getEigenvalues (const double **pSymmetricMatrix, double *pEigenvalues, double **pEigenvectors, const int &numRows)
bool invertSquareMatrix1D (double *pDestination, const double *pSource, const int &numRows)
bool invertSquareMatrix2D (double **pDestination, const double **pSource, const int &numRows)
bool invertRasterElement (RasterElement *pDestination, const RasterElement *pSource)
template<typename T>
bool areMatricesEqual (const T **pLhsMatrix, const T **pRhsMatrix, const int &numRows, const int &numCols, const double &tolerance=1e-6)
template<typename T>
bool isMatrixSymmetric (const T **pMatrix, const int &numRows, const double &tolerance=1e-3)


Detailed Description

A collection of matrix functions.

Function Documentation

template<typename T>
bool MatrixFunctions::areMatricesEqual ( const T **  pLhsMatrix,
const T **  pRhsMatrix,
const int &  numRows,
const int &  numCols,
const double &  tolerance = 1e-6 
)

Compares two matrices for equality.

Parameters:
pLhsMatrix A pointer to the location of the left-hand side matrix to be compared. This location must be allocated and freed by the caller of this function. This parameter cannot be NULL.
pRhsMatrix A pointer to the location of the right-hand side matrix to be compared. This location must be allocated and freed by the caller of this function. This parameter cannot be NULL.
numRows The number of rows in pLhsMatrix and pRhsMatrix. This parameter cannot be less than or equal to 0.
numCols The number of columns in pLhsMatrix and pRhsMatrix. This parameter cannot be less than or equal to 0.
tolerance The maximum allowable difference between any single element of pLhsMatrix and pRhsMatrix. This parameter cannot be less than 0.
Returns:
True if the operation succeeded, false otherwise.

Definition at line 449 of file MatrixFunctions.h.

bool MatrixFunctions::computeSingularValueDecomposition ( const double **  pMatrix,
double *  pSingularValues,
double **  pColumnMatrix,
double **  pOrthogonalMatrix,
const int &  numRows,
const int &  numCols 
)

Calculates the singular value decomposition (SVD) for the given matrix.

Parameters:
pMatrix A pointer to the location of the matrix to use for computation. This location must be allocated and freed by the caller of this function. This parameter cannot be NULL.
pSingularValues A pointer to the location to store the singular values. This location must be allocated and freed by the caller of this function. If this parameter is NULL, singular values will not be returned.
pColumnMatrix A pointer to the location to store the numRows x numCols column matrix of the decomposition. This location must be allocated and freed by the caller of this function. If this parameter is NULL, the column matrix will not be returned.
pOrthogonalMatrix A pointer to the location to store the numCols x numCols orthogonal matrix of the decomposition. This location must be allocated and freed by the caller of this function. If this parameter is NULL, the orthogonal matrix will not be returned.
numRows The number of rows in pMatrix. This parameter cannot be less than numCols.
numCols The number of columns in pMatrix. This parameter cannot be less than or equal to 0.
Returns:
True if the operation succeeded, false otherwise.
See also:
isMatrixSymmetric()

template<typename T>
T ** MatrixFunctions::createMatrix ( const int &  numRows,
const int &  numCols,
const T *  pInitialData 
)

Allocate memory for a two-dimensional matrix.

Parameters:
numRows The number of rows to allocate. This parameter cannot be less than or equal to 0.
numCols The number of columns to allocate. This parameter cannot be less than or equal to 0.
pInitialData The initial values to copy into the matrix. There should be numRows * numCols elements available in this buffer. If this parameter is NULL, the returned matrix will be set to 0 before returning.
Returns:
A pointer to the matrix if the operation succeeded, NULL otherwise.
See also:
deleteMatrix()

Definition at line 201 of file MatrixFunctions.h.

template<typename T>
bool MatrixFunctions::deleteMatrix ( T **&  pMatrix  ) 

Free memory for a two-dimensional matrix.

Parameters:
pMatrix The value returned by createMatrix(). On successful return, this will be set to NULL.
Returns:
True if the operation succeeded, false otherwise.
See also:
createMatrix()

Definition at line 250 of file MatrixFunctions.h.

bool MatrixFunctions::getEigenvalues ( const double **  pSymmetricMatrix,
double *  pEigenvalues,
double **  pEigenvectors,
const int &  numRows 
)

Calculates eigenvalues and eigenvectors for the given symmetric matrix.

Parameters:
pSymmetricMatrix A pointer to the location of the symmetric matrix to use for computation. This location must be allocated and freed by the caller of this function. This parameter cannot be NULL.
pEigenvalues A pointer to the location to store the sorted eigenvalues. This location must be allocated and freed by the caller of this function. If this parameter is NULL, eigenvalues will not be returned.
pEigenvectors A pointer to the location to store the sorted eigenvectors. This location must be allocated and freed by the caller of this function. If this parameter is NULL, eigenvectors will not be returned.
numRows The number of rows in pSymmetricMatrix. Since only square matrices have eigenvalues, this value also represents the number of columns. This parameter cannot be less than or equal to 0.
Returns:
True if the operation succeeded, false otherwise.
See also:
isMatrixSymmetric()

bool MatrixFunctions::invertRasterElement ( RasterElement pDestination,
const RasterElement pSource 
)

Inverts a RasterElement representing a square matrix.

Parameters:
pDestination A pointer to the RasterElement to store the inverted matrix. This parameter must be the same size (rows, columns, and bands) and EncodingType as pSource. This parameter can be the same as pSource. This parameter cannot be NULL.
pSource A pointer to the RasterElement containing the data to be inverted. The number of rows must not be greater than numeric_limits<int>::max(). This parameter must contain the same number of rows and columns. This parameter must contain single band data. This parameter must have an EncodingType of FLT8BYTES. This parameter can be the same as pDestination. This parameter cannot be NULL.
Returns:
True if the operation succeeded, false otherwise.

bool MatrixFunctions::invertSquareMatrix1D ( double *  pDestination,
const double *  pSource,
const int &  numRows 
)

Inverts a square matrix.

Parameters:
pDestination A pointer to the location to store the inverted matrix. This location must be allocated and freed by the caller of this function. This parameter can be the same as pSource. This parameter cannot be NULL.
pSource A pointer to the location of the matrix to be inverted. This location must be allocated and freed by the caller of this function. This parameter can be the same as pDestination. This parameter cannot be NULL.
numRows The number of rows in pDestination and pSource. Since only square matrices are invertible, this value also represents the number of columns. This parameter cannot be less than or equal to 0.
Returns:
True if the operation succeeded, false otherwise.

bool MatrixFunctions::invertSquareMatrix2D ( double **  pDestination,
const double **  pSource,
const int &  numRows 
)

This method is similar to invertSquareMatrix1D, except pSource and pDestination refer to two-dimensional pointers, such as those returned by createMatrix().

Inverts a square matrix.

Parameters:
pDestination A pointer to the location to store the inverted matrix. This location must be allocated and freed by the caller of this function. This parameter can be the same as pSource. This parameter cannot be NULL.
pSource A pointer to the location of the matrix to be inverted. This location must be allocated and freed by the caller of this function. This parameter can be the same as pDestination. This parameter cannot be NULL.
numRows The number of rows in pDestination and pSource. Since only square matrices are invertible, this value also represents the number of columns. This parameter cannot be less than or equal to 0.
Returns:
True if the operation succeeded, false otherwise.

See also:
createMatrix()

template<typename T>
bool MatrixFunctions::isMatrixSymmetric ( const T **  pMatrix,
const int &  numRows,
const double &  tolerance = 1e-3 
)

Determines whether a given matrix is symmetric.

Parameters:
pMatrix A pointer to the location of the matrix to be checked. This location must be allocated and freed by the caller of this function. This parameter cannot be NULL.
numRows The number of rows in pMatrix. Since only square matrices can be symmetric, this value also represents the number of columns. This parameter cannot be less than or equal to 0.
tolerance The maximum allowable difference between pMatrix[row][col] and pMatrix[col][row]. This parameter cannot be less than 0.
Returns:
True if the operation succeeded, false otherwise.

Definition at line 506 of file MatrixFunctions.h.

bool MatrixFunctions::solveLinearEquation ( double *  pResult,
const double **  pLhs,
const double *  pRhs,
const int &  numRows,
const int &  numColsLhs 
)

Solves a linear equation of the form Ax = b, where A is represented by pLhs, b is represented by pRhs, and x is represented by pResult.

Parameters:
pResult A pointer to the location of the vector to use for results. This vector is assumed to be 1 column wide and contain numRows entries. This location must be allocated and freed by the caller of this function. This parameter cannot be NULL.
pLhs A pointer to the location of the matrix to use for solving the equation. This location must be allocated and freed by the caller of this function. This parameter cannot be NULL.
pRhs A pointer to the location of the vector to use for solving the equation. This vector is assumed to be 1 column wide and contain numRows entries. This location must be allocated and freed by the caller of this function. This parameter cannot be NULL.
numRows The number of rows in pLhs, pRhs and pResult. This parameter cannot be less than numColsLhs.
numColsLhs The number of columns in pLhs. This parameter cannot be less than or equal to 0.
Returns:
True if the operation succeeded, false otherwise.


Software Development Kit - Opticks 4.8.0 Build 15482