/usr/include/ITK-4.5/sparse/spMatrix.h is in libinsighttoolkit4-dev 4.5.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 | /* EXPORTS for sparse matrix routines. */
/*!
* \file
*
* This file contains definitions that are useful to the calling
* program. In particular, this file contains error keyword
* definitions, some macro functions that are used to quickly enter
* data into the matrix and the type definition of a data structure
* that acts as a template for entering admittances into the matrix.
* Also included is the type definitions for the various functions
* available to the user.
*
* Objects that begin with the \a spc prefix are considered private
* and should not be used.
*
* \author
* Kenneth S. Kundert <kundert@users.sourceforge.net>
*/
/*
* Revision and copyright information.
*
* Copyright (c) 1985-2003 by Kenneth S. Kundert
*
*/
#ifndef spOKAY
/*
* IMPORTS
*
* >>> Import descriptions:
* spConfig.h
* Macros that customize the sparse matrix routines.
*/
#include "spConfig.h"
/*
* ERROR KEYWORDS
*
* The actual numbers used in the error codes are not sacred, they can be
* changed under the condition that the codes for the nonfatal errors are
* less than the code for spFATAL and similarly the codes for the fatal
* errors are greater than that for spFATAL.
*/
/* Begin error macros. */
#define spOKAY 0 /*!<
* Error code that indicates that no error has
* occurred.
*/
#define spSMALL_PIVOT 1 /*!<
* Non-fatal error code that indicates that, when
* reordering the matrix, no element was found that
* satisfies the absolute threshold criteria. The
* largest element in the matrix was chosen as pivot.
*/
#define spZERO_DIAG 2 /*!<
* Fatal error code that indicates that, a zero was
* encountered on the diagonal the matrix. This does
* not necessarily imply that the matrix is singular.
* When this error occurs, the matrix should be
* reconstructed and factored using
* spOrderAndFactor().
*/
#define spSINGULAR 3 /*!<
* Fatal error code that indicates that, matrix is
* singular, so no unique solution exists.
*/
#define spMANGLED 4 /*!<
* Fatal error code that indicates that, matrix has
* been mangled, results of requested operation are
* garbage.
*/
#define spNO_MEMORY 5 /*!<
* Fatal error code that indicates that not enough
* memory is available.
*/
#define spPANIC 6 /*!<
* Fatal error code that indicates that the routines
* are not prepared to handle the matrix that has
* been requested. This may occur when the matrix
* is specified to be real and the routines are not
* compiled for real matrices, or when the matrix is
* specified to be complex and the routines are not
* compiled to handle complex matrices.
*/
#define spFATAL 2 /*!<
* Error code that is not an error flag, but rather
* the dividing line between fatal errors and
* warnings.
*/
/*
* KEYWORD DEFINITIONS
*/
#define spREAL double /*!<
* Defines the precision of the arithmetic used by
* \a Sparse will use. Double precision is suggested
* as being most appropriate for circuit simulation
* and for C. However, it is possible to change spREAL
* to a float for single precision arithmetic. Note
* that in C, single precision arithmetic is often
* slower than double precision. Sparse
* internally refers to spREALs as RealNumbers.
*/
/*
* PARTITION TYPES
*
* When factoring a previously ordered matrix using spFactor(), Sparse
* operates on a row-at-a-time basis. For speed, on each step, the row
* being updated is copied into a full vector and the operations are
* performed on that vector. This can be done one of two ways, either
* using direct addressing or indirect addressing. Direct addressing
* is fastest when the matrix is relatively dense and indirect addressing
* is quite sparse. The user can select which partitioning mode is used.
* The following keywords are passed to spPartition() and indicate that
* Sparse should use only direct addressing, only indirect addressing, or
* that it should choose the best mode on a row-by-row basis. The time
* required to choose a partition is of the same order of the cost to factor
* the matrix.
*
* If you plan to factor a large number of matrices with the same structure,
* it is best to let Sparse choose the partition. Otherwise, you should
* choose the partition based on the predicted density of the matrix.
*/
/* Begin partition keywords. */
#define spDEFAULT_PARTITION 0 /*!<
* Partition code for spPartition().
* Indicates that the default partitioning
* mode should be used.
* \see spPartition()
*/
#define spDIRECT_PARTITION 1 /*!<
* Partition code for spPartition().
* Indicates that all rows should be placed
* in the direct addressing partition.
* \see spPartition()
*/
#define spINDIRECT_PARTITION 2 /*!<
* Partition code for spPartition().
* Indicates that all rows should be placed
* in the indirect addressing partition.
* \see spPartition()
*/
#define spAUTO_PARTITION 3 /*!<
* Partition code for spPartition().
* Indicates that \a Sparse should chose
* the best partition for each row based
* on some simple rules. This is generally
* preferred.
* \see spPartition()
*/
/*
* MACRO FUNCTION DEFINITIONS
*/
/* Begin Macros. */
/*!
* Macro function that adds data to a real element in the matrix by a pointer.
*/
#define spADD_REAL_ELEMENT(element,real) *(element) += real
/*!
* Macro function that adds data to a imaginary element in the matrix by
* a pointer.
*/
#define spADD_IMAG_ELEMENT(element,imag) *(element+1) += imag
/*!
* Macro function that adds data to a complex element in the matrix by
* a pointer.
*/
#define spADD_COMPLEX_ELEMENT(element,real,imag) \
{ *(element) += real; \
*(element+1) += imag; \
}
/*!
* Macro function that adds data to each of the four real matrix elements
* specified by the given template.
*/
#define spADD_REAL_QUAD(template,real) \
{ *((template).Element1) += real; \
*((template).Element2) += real; \
*((template).Element3Negated) -= real; \
*((template).Element4Negated) -= real; \
}
/*!
* Macro function that adds data to each of the four imaginary matrix
* elements specified by the given template.
*/
#define spADD_IMAG_QUAD(template,imag) \
{ *((template).Element1+1) += imag; \
*((template).Element2+1) += imag; \
*((template).Element3Negated+1) -= imag; \
*((template).Element4Negated+1) -= imag; \
}
/*!
* Macro function that adds data to each of the four complex matrix
* elements specified by the given template.
*/
#define spADD_COMPLEX_QUAD(template,real,imag) \
{ *((template).Element1) += real; \
*((template).Element2) += real; \
*((template).Element3Negated) -= real; \
*((template).Element4Negated) -= real; \
*((template).Element1+1) += imag; \
*((template).Element2+1) += imag; \
*((template).Element3Negated+1) -= imag; \
*((template).Element4Negated+1) -= imag; \
}
/*
* TYPE DEFINITION FOR EXTERNAL MATRIX ELEMENT REFERENCES
*
* External type definitions for Sparse data objects.
*/
/*! Declares the type of the a pointer to a matrix. */
typedef spGenericPtr spMatrix;
/*! Declares the type of the a pointer to a matrix element. */
typedef spREAL spElement;
/*! Declares the type of the Sparse error codes. */
typedef int spError;
/* TYPE DEFINITION FOR COMPONENT TEMPLATE */
/*!
* This data structure is used to hold pointers to four related elements in
* matrix. It is used in conjunction with the routines spGetAdmittance(),
* spGetQuad(), and spGetOnes(). These routines stuff the structure which
* is later used by the \a spADD_QUAD macro functions above. It is also
* possible for the user to collect four pointers returned by spGetElement()
* and stuff them into the template. The \a spADD_QUAD routines stuff data
* into the matrix in locations specified by \a Element1 and \a Element2
* without changing the data. The data is negated before being placed in
* \a Element3 and \a Element4.
*/
/* Begin `spTemplate'. */
struct spTemplate
{ spElement *Element1;
spElement *Element2;
spElement *Element3Negated;
spElement *Element4Negated;
};
/*
* FUNCTION TYPE DEFINITIONS
*
* The type of every user accessible function is declared here.
*/
/* Begin function declarations. */
spcEXTERN void spClear( spMatrix );
spcEXTERN spREAL spCondition( spMatrix, spREAL, int* );
spcEXTERN spMatrix spCreate( int, int, spError* );
spcEXTERN void spDeleteRowAndCol( spMatrix, int, int );
spcEXTERN void spDestroy( spMatrix );
spcEXTERN int spElementCount( spMatrix );
spcEXTERN spError spErrorState( spMatrix );
#if 0 // Remove Borland error
#ifdef EOF
spcEXTERN void spErrorMessage( spMatrix, FILE*, char* );
#else
# define spErrorMessage(a,b,c) spcFUNC_NEEDS_FILE(_spErrorMessage,stdio)
#endif
#endif // Remove Borland error
spcEXTERN spError spFactor( spMatrix );
/* Remove file IO due to archaic fopen method which gives warnings in windoz
spcEXTERN int spFileMatrix( spMatrix, char*, char*, int, int, int );
spcEXTERN int spFileStats( spMatrix, char*, char* );
*/
spcEXTERN int spFillinCount( spMatrix );
spcEXTERN spElement *spFindElement( spMatrix, int, int );
spcEXTERN spError spGetAdmittance( spMatrix, int, int,
struct spTemplate* );
spcEXTERN spElement *spGetElement( spMatrix, int, int );
spcEXTERN spGenericPtr spGetInitInfo( spElement* );
spcEXTERN spError spGetOnes( spMatrix, int, int, int,
struct spTemplate* );
spcEXTERN spError spGetQuad( spMatrix, int, int, int, int,
struct spTemplate* );
spcEXTERN int spGetSize( spMatrix, int );
spcEXTERN int spInitialize( spMatrix, int (*pInit)(spElement *, spGenericPtr, int, int) );
spcEXTERN void spInstallInitInfo( spElement*, spGenericPtr );
spcEXTERN spREAL spLargestElement( spMatrix );
spcEXTERN void spMNA_Preorder( spMatrix );
spcEXTERN spREAL spNorm( spMatrix );
spcEXTERN spError spOrderAndFactor( spMatrix, spREAL[], spREAL,
spREAL, int );
spcEXTERN void spPartition( spMatrix, int );
spcEXTERN void spPrint( spMatrix, int, int, int );
spcEXTERN void spRowColOrder( spMatrix, int*, int*);
spcEXTERN spREAL spPseudoCondition( spMatrix );
spcEXTERN spREAL spRoundoff( spMatrix, spREAL );
spcEXTERN void spScale( spMatrix, spREAL[], spREAL[] );
spcEXTERN void spSetComplex( spMatrix );
spcEXTERN void spSetReal( spMatrix );
spcEXTERN void spStripFills( spMatrix );
spcEXTERN void spWhereSingular( spMatrix, int*, int* );
/* Functions with argument lists that are dependent on options. */
#if spCOMPLEX
spcEXTERN void spDeterminant( spMatrix, int*, spREAL*, spREAL* );
#else /* NOT spCOMPLEX */
spcEXTERN void spDeterminant( spMatrix, int*, spREAL* );
#endif /* NOT spCOMPLEX */
#if spCOMPLEX && spSEPARATED_COMPLEX_VECTORS
/* Get rid of arcaic file IO
spcEXTERN int spFileVector( spMatrix, char* ,
spREAL[], spREAL[]);
*/
spcEXTERN void spMultiply( spMatrix, spREAL[], spREAL[],
spREAL[], spREAL[] );
spcEXTERN void spMultTransposed( spMatrix, spREAL[], spREAL[],
spREAL[], spREAL[] );
spcEXTERN void spSolve( spMatrix, spREAL[], spREAL[], spREAL[],
spREAL[] );
spcEXTERN void spSolveTransposed( spMatrix, spREAL[], spREAL[],
spREAL[], spREAL[] );
#else /* NOT (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */
/* Get rid of arcaic file IO
spcEXTERN int spFileVector( spMatrix, char* , spREAL[] );
*/
spcEXTERN void spMultiply( spMatrix, spREAL[], spREAL[] );
spcEXTERN void spMultTransposed( spMatrix,
spREAL[], spREAL[] );
spcEXTERN void spSolve( spMatrix, spREAL[], spREAL[] );
spcEXTERN void spSolveTransposed( spMatrix,
spREAL[], spREAL[] );
#endif /* NOT (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */
#endif /* spOKAY */
|