psMatrix.h

Go to the documentation of this file.
00001 /* @file  psMatrix.h
00002  *
00003  * @brief Provides functions for linear algebra operations on psImages and psVectors.
00004  *
00005  * Functions are provided to:
00006  *     Transpose a psImage
00007  *     Compute LUD
00008  *     Solve LUD
00009  *     Matrix inversion
00010  *     Calculate determinant
00011  *     Matrix multiplication
00012  *     Calculate Eigenvectors
00013  *     Convert matrix to vector
00014  *     Convert vector to matrix
00015  *
00016  * These functions treat psImages as if they were matrices, therefore there is no psMatrix. These functions
00017  * operate only with the psF64 data type.
00018  *
00019  * @author Ross Harman, MHPCC
00020  *
00021  * @version $Revision: 1.26 $ $Name:  $
00022  * @date $Date: 2007/01/23 22:47:23 $
00023  * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
00024  */
00025 
00026 #ifndef PSMATRIX_H
00027 #define PSMATRIX_H
00028 
00029 /// @addtogroup MathOps Mathematical Operations
00030 /// @{
00031 
00032 /** LU Decomposition of psImage matrix.
00033  *
00034  *  Performs a LU decomposition on a psImage matrix and returns the LU matrix. If the user specifies NULL for
00035  *  the outImage or outPerm arguments, then they will be automatically created. The input image must
00036  *  be square. This function operates only with the psF64 data type. Input and output arguments should not be
00037  *  the same. GSL indexes the top row as the zero row, not the bottom.
00038  *
00039  *  @return  psImage* : Pointer to LU decomposed psImage.
00040  */
00041 psImage* psMatrixLUD(
00042     psImage* out,                      ///< Image to return, or NULL.
00043     psVector** perm,                   ///< Output permutation vector used by psMatrixLUSolve.
00044     const psImage* in                  ///< Image to decompose.
00045 );
00046 
00047 /** LU Solution of psImage matrix.
00048  *
00049  *  Solves for and returns the psVector, {x} in the equation [A]{x} = {b}. If the user specifies NULL as the
00050  *  outVector argument, then it will automatically be created. The input image must be square. This function
00051  *  operates only with the psF64 data type. Input and output arguments should not be the same. GSL indexes
00052  *  the top row as the zero row, not the bottom.
00053  *
00054  *  @return  psVector* : Pointer to psVector solution of matrix equation.
00055  */
00056 psVector* psMatrixLUSolve(
00057     psVector* out,                     ///< Vector to return, or NULL.
00058     const psImage* LU,                 ///< LU-decomposed matrix.
00059     const psVector* RHS,               ///< Vector right-hand-side of equation.
00060     const psVector* perm               ///< Permutation vector resulting from psMatrixLUD function.
00061 );
00062 
00063 /** Gauss-Jordan numerical solver.
00064  *
00065  *  @return bool:   True if successful.
00066  */
00067 bool psMatrixGJSolve(
00068     psImage *A,                   ///< Matrix to be solved
00069     psVector *b                   ///< Vector of values
00070 );
00071 
00072 /** Gauss-Jordan numerical solver for F32 input data
00073  *
00074  *  @return bool:   True if successful.
00075  */
00076 bool psMatrixGJSolveF32(
00077     psImage *A,                   ///< Matrix to be solved
00078     psVector *b                   ///< Vector of values
00079 );
00080 
00081 /** Invert psImage matrix.
00082  *
00083  *  Inverts a psImage matrix and returns the determinant as an option through the argument list. If the user
00084  *  specifies NULL as the outImage argument, then it will automatically be created. The input image must be
00085  *  square. This function operates only with the psF64 data type. Input and output arguments should not be
00086  *  the same. GSL indexes the top row as the zero row, not the bottom.
00087  *
00088  *  @return  psImage* : Pointer to inverted psImage.
00089  */
00090 psImage* psMatrixInvert(
00091     psImage* out,                      ///< Image to return, or NULL for in-place substitution.
00092     const psImage* in,                 ///< Image to be inverted
00093     float *determinant                 ///< Determinant to return, or NULL
00094 );
00095 
00096 /** Calculate psImage matrix determinant.
00097  *
00098  *  Calculates the determinant of a psImage matrix and returns the single precision floating point result. The
00099  *  input image must be square. This function operates only with the psF64 data type. GSL indexes the top row
00100  *  as the zero row, not the bottom.
00101  *
00102  *  @return  float: Determinant from psImage.
00103  */
00104 float psMatrixDeterminant(
00105     const psImage* in                  ///< Image used to calculate determinant.
00106 );
00107 
00108 /** Performs psImage matrix multiplication.
00109  *
00110  *  Performs a classical matrix multiplication involving row and column operations. Input images must be square
00111  *  and the same size. If the user specifies NULL as the outImage argument, then it will automatically be
00112  *  created. This function operates only with the psF64 data type. GSL indexes the top row as the
00113  *  zero row, not the bottom.
00114  *
00115  *  @return  psImage* : Pointer to resulting psImage.
00116  */
00117 psImage* psMatrixMultiply(
00118     psImage* out,                      ///< Matrix to return, or NULL.
00119     const psImage* in1,                ///< First input image.
00120     const psImage* in2                 ///< Second input image.
00121 );
00122 
00123 /** Transpose matrix.
00124  *
00125  *  Performs psImage matrix transpose by substituting existing rows for columns. The input image must be
00126  *  square. If the user specifies NULL as the outImage argument, then it will automaticallty be created.
00127  *  This function operates only with the psF64 data type. GSL indexes the top row as the zero
00128  *  row, not the bottom.
00129  *
00130  *  @return  psImage* : Pointer to transposed psImage.
00131  */
00132 psImage* psMatrixTranspose(
00133     psImage* out,                      ///< Image to return, or NULL
00134     const psImage* in                  ///< Image to transpose
00135 );
00136 
00137 /** Calculate matrix eigenvectors.
00138  *
00139  *  Calculates the eigenvectors for a matrix. The input image must be symmetric and square. If the user
00140  *  specifies NULL as the outImage argument, then it will automatically be created. This function operates
00141  *  only with the psF64 data type. GSL indexes the top row as the zero row, not the bottom.
00142  *
00143  *  @return  psImage* : Pointer to matrix of Eigenvectors.
00144  */
00145 psImage* psMatrixEigenvectors(
00146     psImage* out,                      ///< Eigenvectors to return, or NULL.
00147     const psImage* in                  ///< Input image.
00148 );
00149 
00150 /** Convert matrix to vector.
00151  *
00152  *  Converts a 1-d psImage matrix into a vector. If the user specifies NULL as the outVector argument, then it
00153  *  will automatically be created based on the input image (PS_DIMEN_VECTOR for an input image with 1 col or
00154  *  PS_DIMENT_TRANSV for an input image with 1 row). Either the number of rows or the number of colums of the
00155  *  input matrix must be 1. This function operates only  with the psF64 data type.
00156  *
00157  *  @return  psVector* : Pointer to psVector.
00158  */
00159 psVector* psMatrixToVector(
00160     psVector* outVector,               ///< Vector to return, or NULL.
00161     const psImage* inImage             ///< Image to convert.
00162 );
00163 
00164 /** Convert vector to matrix.
00165  *
00166  *  Converts a vector into a psImage matrix. If the dimensionality of the vector is PS_DIMEN_VECTOR, then the
00167  *  resulting psImage is a 1d column. If the dimensionality of the vector is PS_DIMEN_TRANSV, then the
00168  *  resulting psImage is a 1d row. If the user specifies NULL as the outImage argument,  then it will
00169  *  automatically be created. This function operates only with the psF64 data type.
00170  *
00171  *  @return  psVector* : Pointer to psIamge.
00172  */
00173 psImage* psVectorToMatrix(
00174     psImage* outImage,                 ///< Matrix to return, or NULL.
00175     const psVector* inVector           ///< Vector to convert.
00176 );
00177 
00178 /// Single value decomposition, provided by Andy Becker
00179 psImage *psMatrixSVDSolve(psImage* evec, psVector* eval, const psImage* in);
00180 
00181 /// @}
00182 #endif // #ifndef PSMATRIX_H

Generated on Fri Feb 2 22:24:35 2007 for pslib by  doxygen 1.5.1