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