Main Page   Compound List   File List   File Members  

spMatrix.h

Go to the documentation of this file.
00001 /*  EXPORTS for sparse matrix routines. */
00021 /*
00022  *  Revision and copyright information.
00023  *
00024  *  Copyright (c) 1985-2003 by Kenneth S. Kundert
00025  *
00026  *  $Date: 2003/06/29 04:19:52 $
00027  *  $Revision: 1.2 $
00028  */
00029 
00030 
00031 
00032 
00033 #ifndef  spOKAY
00034 
00035 /*
00036  *  IMPORTS
00037  *
00038  *  >>> Import descriptions:
00039  *  spConfig.h
00040  *      Macros that customize the sparse matrix routines.
00041  */
00042 
00043 #include "spConfig.h"
00044 
00045 
00046 
00047 
00048 
00049 
00050 /*
00051  *  ERROR KEYWORDS
00052  *
00053  *  The actual numbers used in the error codes are not sacred, they can be
00054  *  changed under the condition that the codes for the nonfatal errors are
00055  *  less than the code for spFATAL and similarly the codes for the fatal
00056  *  errors are greater than that for spFATAL.
00057  */
00058 
00059 /* Begin error macros. */
00060 #define  spOKAY         0  
00064 #define  spSMALL_PIVOT  1  
00070 #define  spZERO_DIAG    2  
00078 #define  spSINGULAR     3  
00082 #define  spMANGLED      4  
00087 #define  spNO_MEMORY    5  
00091 #define  spPANIC        6  
00100 #define  spFATAL        2  
00111 /*
00112  *  KEYWORD DEFINITIONS
00113  */
00114 
00115 #define  spREAL double  
00128 /*
00129  *  PARTITION TYPES
00130  *
00131  *  When factoring a previously ordered matrix using spFactor(), Sparse
00132  *  operates on a row-at-a-time basis.  For speed, on each step, the row
00133  *  being updated is copied into a full vector and the operations are
00134  *  performed on that vector.  This can be done one of two ways, either
00135  *  using direct addressing or indirect addressing.  Direct addressing
00136  *  is fastest when the matrix is relatively dense and indirect addressing
00137  *  is quite sparse.  The user can select which partitioning mode is used.
00138  *  The following keywords are passed to spPartition() and indicate that
00139  *  Sparse should use only direct addressing, only indirect addressing, or
00140  *  that it should choose the best mode on a row-by-row basis.  The time
00141  *  required to choose a partition is of the same order of the cost to factor
00142  *  the matrix.
00143  *
00144  *  If you plan to factor a large number of matrices with the same structure,
00145  *  it is best to let Sparse choose the partition.  Otherwise, you should
00146  *  choose the partition based on the predicted density of the matrix.
00147  */
00148 
00149 /* Begin partition keywords. */
00150 
00151 #define spDEFAULT_PARTITION     0 
00157 #define spDIRECT_PARTITION      1 
00163 #define spINDIRECT_PARTITION    2 
00169 #define spAUTO_PARTITION        3 
00181 
00182 /*
00183  *  MACRO FUNCTION DEFINITIONS
00184  */
00185 
00186 /* Begin Macros. */
00190 #define  spADD_REAL_ELEMENT(element,real)       *(element) += real
00191 
00196 #define  spADD_IMAG_ELEMENT(element,imag)       *(element+1) += imag
00197 
00202 #define  spADD_COMPLEX_ELEMENT(element,real,imag)       \
00203 {   *(element) += real;                                 \
00204     *(element+1) += imag;                               \
00205 }
00206 
00211 #define  spADD_REAL_QUAD(template,real)         \
00212 {   *((template).Element1) += real;             \
00213     *((template).Element2) += real;             \
00214     *((template).Element3Negated) -= real;      \
00215     *((template).Element4Negated) -= real;      \
00216 }
00217 
00222 #define  spADD_IMAG_QUAD(template,imag)         \
00223 {   *((template).Element1+1) += imag;           \
00224     *((template).Element2+1) += imag;           \
00225     *((template).Element3Negated+1) -= imag;    \
00226     *((template).Element4Negated+1) -= imag;    \
00227 }
00228 
00233 #define  spADD_COMPLEX_QUAD(template,real,imag) \
00234 {   *((template).Element1) += real;             \
00235     *((template).Element2) += real;             \
00236     *((template).Element3Negated) -= real;      \
00237     *((template).Element4Negated) -= real;      \
00238     *((template).Element1+1) += imag;           \
00239     *((template).Element2+1) += imag;           \
00240     *((template).Element3Negated+1) -= imag;    \
00241     *((template).Element4Negated+1) -= imag;    \
00242 }
00243 
00244 
00245 
00246 
00247 
00248 
00249 
00250 /*
00251  *   TYPE DEFINITION FOR EXTERNAL MATRIX ELEMENT REFERENCES
00252  *
00253  *   External type definitions for Sparse data objects.
00254  */
00255 
00257 typedef spGenericPtr spMatrix;
00258 
00260 typedef spREAL spElement;
00261 
00263 typedef int spError;
00264 
00265 
00266 
00267 
00268 
00269 /* TYPE DEFINITION FOR COMPONENT TEMPLATE */
00282 /* Begin `spTemplate'. */
00283 struct  spTemplate
00284 {   spElement   *Element1;
00285     spElement   *Element2;
00286     spElement   *Element3Negated;
00287     spElement   *Element4Negated;
00288 };
00289 
00290 
00291 
00292 
00293 
00294 /*
00295  *   FUNCTION TYPE DEFINITIONS
00296  *
00297  *   The type of every user accessible function is declared here.
00298  */
00299 
00300 /* Begin function declarations. */
00301 
00302 spcEXTERN  void       spClear( spMatrix );
00303 spcEXTERN  spREAL     spCondition( spMatrix, spREAL, int* );
00304 spcEXTERN  spMatrix   spCreate( int, int, spError* );
00305 spcEXTERN  void       spDeleteRowAndCol( spMatrix, int, int );
00306 spcEXTERN  void       spDestroy( spMatrix );
00307 spcEXTERN  int        spElementCount( spMatrix );
00308 spcEXTERN  spError    spErrorState( spMatrix );
00309 #ifdef EOF
00310     spcEXTERN void    spErrorMessage( spMatrix, FILE*, char* );
00311 #else
00312 #   define spErrorMessage(a,b,c) spcFUNC_NEEDS_FILE(_spErrorMessage,stdio)
00313 #endif
00314 
00315 
00316 spcEXTERN  spError    spFactor( spMatrix );
00317 spcEXTERN  int        spFileMatrix( spMatrix, char*, char*, int, int, int );
00318 spcEXTERN  int        spFileStats( spMatrix, char*, char* );
00319 spcEXTERN  int        spFillinCount( spMatrix );
00320 spcEXTERN  spElement *spFindElement( spMatrix, int, int );
00321 spcEXTERN  spError    spGetAdmittance( spMatrix, int, int,
00322                                 struct spTemplate* );
00323 spcEXTERN  spElement *spGetElement( spMatrix, int, int );
00324 spcEXTERN  spGenericPtr spGetInitInfo( spElement* );
00325 spcEXTERN  spError    spGetOnes( spMatrix, int, int, int,
00326                                 struct spTemplate* );
00327 spcEXTERN  spError    spGetQuad( spMatrix, int, int, int, int,
00328                                 struct spTemplate* );
00329 spcEXTERN  int        spGetSize( spMatrix, int );
00330 spcEXTERN  int        spInitialize( spMatrix, int (*pInit)(spElement *, spGenericPtr, int, int) );
00331 spcEXTERN  void       spInstallInitInfo( spElement*, spGenericPtr );
00332 spcEXTERN  spREAL     spLargestElement( spMatrix );
00333 spcEXTERN  void       spMNA_Preorder( spMatrix );
00334 spcEXTERN  spREAL     spNorm( spMatrix );
00335 spcEXTERN  spError    spOrderAndFactor( spMatrix, spREAL[], spREAL,
00336                                 spREAL, int );
00337 spcEXTERN  void       spPartition( spMatrix, int );
00338 spcEXTERN  void       spPrint( spMatrix, int, int, int );
00339 spcEXTERN  spREAL     spPseudoCondition( spMatrix );
00340 spcEXTERN  spREAL     spRoundoff( spMatrix, spREAL );
00341 spcEXTERN  void       spScale( spMatrix, spREAL[], spREAL[] );
00342 spcEXTERN  void       spSetComplex( spMatrix );
00343 spcEXTERN  void       spSetReal( spMatrix );
00344 spcEXTERN  void       spStripFills( spMatrix );
00345 spcEXTERN  void       spWhereSingular( spMatrix, int*, int* );
00346 
00347 /* Functions with argument lists that are dependent on options. */
00348 
00349 #if spCOMPLEX
00350 spcEXTERN  void       spDeterminant( spMatrix, int*, spREAL*, spREAL* );
00351 #else /* NOT spCOMPLEX */
00352 spcEXTERN  void       spDeterminant( spMatrix, int*, spREAL* );
00353 #endif /* NOT spCOMPLEX */
00354 #if spCOMPLEX && spSEPARATED_COMPLEX_VECTORS
00355 spcEXTERN  int        spFileVector( spMatrix, char* ,
00356                                 spREAL[], spREAL[]);
00357 spcEXTERN  void       spMultiply( spMatrix, spREAL[], spREAL[],
00358                                 spREAL[], spREAL[] );
00359 spcEXTERN  void       spMultTransposed( spMatrix, spREAL[], spREAL[],
00360                                 spREAL[], spREAL[] );
00361 spcEXTERN  void       spSolve( spMatrix, spREAL[], spREAL[], spREAL[],
00362                                 spREAL[] );
00363 spcEXTERN  void       spSolveTransposed( spMatrix, spREAL[], spREAL[],
00364                                 spREAL[], spREAL[] );
00365 #else /* NOT  (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */
00366 spcEXTERN  int        spFileVector( spMatrix, char* , spREAL[] );
00367 spcEXTERN  void       spMultiply( spMatrix, spREAL[], spREAL[] );
00368 spcEXTERN  void       spMultTransposed( spMatrix,
00369                                 spREAL[], spREAL[] );
00370 spcEXTERN  void       spSolve( spMatrix, spREAL[], spREAL[] );
00371 spcEXTERN  void       spSolveTransposed( spMatrix,
00372                                 spREAL[], spREAL[] );
00373 #endif /* NOT  (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */
00374 #endif  /* spOKAY */

Generated on Mon Jun 30 12:01:27 2003 for Sparse by doxygen1.2.17