00001
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef spOKAY
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include "spConfig.h"
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
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
00113
00114
00115 #define spREAL double
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 #define spDEFAULT_PARTITION 0
00157 #define spDIRECT_PARTITION 1
00163 #define spINDIRECT_PARTITION 2
00169 #define spAUTO_PARTITION 3
00181
00182
00183
00184
00185
00186
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
00252
00253
00254
00255
00257 typedef spGenericPtr spMatrix;
00258
00260 typedef spREAL spElement;
00261
00263 typedef int spError;
00264
00265
00266
00267
00268
00269
00282
00283 struct spTemplate
00284 { spElement *Element1;
00285 spElement *Element2;
00286 spElement *Element3Negated;
00287 spElement *Element4Negated;
00288 };
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
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
00348
00349 #if spCOMPLEX
00350 spcEXTERN void spDeterminant( spMatrix, int*, spREAL*, spREAL* );
00351 #else
00352 spcEXTERN void spDeterminant( spMatrix, int*, spREAL* );
00353 #endif
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
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
00374 #endif