Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

psSparse.h

Go to the documentation of this file.
00001 /** @file  psSparse.h
00002  *
00003  * functions to manipulate sparse matrices equations
00004  *
00005  */
00006 
00007 #ifndef PS_SPARSE_H
00008 #define PS_SPARSE_H
00009 
00010 // constraints to limit the range of the matrix equation solution
00011 typedef struct
00012 {
00013     double paramDelta;
00014     double paramMin;
00015     double paramMax;
00016 }
00017 psSparseConstraint;
00018 
00019 // A sparse matrix equation: A x = Bf
00020 typedef struct
00021 {
00022     psVector *Aij;                      // Aij contains the populated elements of the matrix
00023     psVector *Bfj;                      // Bfj contains the elements of the vector Bf
00024     psVector *Qii;                      // Qii contains the diagonal elements of Aij
00025     psVector *Si;                       // Si contains the i-index values of Aij
00026     psVector *Sj;                       // Sj contains the j-index values of Aij
00027     int Nelem;                         // Number of elements
00028     int Nrows;                         // Number of rows
00029 }
00030 psSparse;
00031 
00032 // allocate a sparse matrix structure
00033 psSparse *psSparseAlloc(int Nrows, int Nelem);
00034 
00035 // add a new matrix element
00036 // user should only add elements above the diagonal
00037 bool psSparseMatrixElement(psSparse *sparse, // Matrix to which to add
00038                            int i, int j, // Matrix indices at which to add
00039                            float value  // Value to add
00040                           );
00041 
00042 // define a new sparse matrix equation vector element
00043 void psSparseVectorElement(psSparse *sparse, // Matrix to which to add
00044                            int i,      // Index to add
00045                            float value  // Value to add
00046                           );
00047 
00048 // perform the operation matrix * vector on a sparse matrix and a vector
00049 psVector *psSparseMatrixTimesVector(psVector *output, // Output vector, or NULL
00050                                     const psSparse *matrix, // Sparse matrix
00051                                     const psVector *vector // Corresponding vector
00052                                    );
00053 
00054 // re-sort a sparse matrix to have all elements in index order rather than insertion order
00055 // call this before solving, but after populating matrix and vector
00056 bool psSparseResort(psSparse *sparse    // Matrix to re-sort
00057                    );
00058 
00059 // solve the equation A x = Bf for the value of x
00060 // a good starting guess is the vector Bf
00061 psVector *psSparseSolve(psVector *output,// The output vector, or NULL
00062                         psSparseConstraint constraint, // Constraint to limit the range of the solution
00063                         const psSparse *sparse, // Sparse matrix
00064                         int Niter       // Number of iterations
00065                        );
00066 
00067 #endif /* PS_SPARSE_H */

Generated on Mon Jul 3 14:13:44 2006 for Pan-STARRS Foundation Library by  doxygen 1.4.4