unify MatrixPtr
This commit is contained in:
parent
61ecbbaecf
commit
db7b9ecae4
|
|
@ -57,53 +57,64 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Begin error macros. */
|
/* Begin error macros. */
|
||||||
#define spOKAY 0 /*!<
|
//#define spOKAY 0 /*!<
|
||||||
* Error code that indicates that no error has
|
// * Error code that indicates that no error has
|
||||||
* occurred.
|
// * occurred.
|
||||||
*/
|
// */
|
||||||
#define spSMALL_PIVOT 1 /*!<
|
//#define spSMALL_PIVOT 1 /*!<
|
||||||
* Non-fatal error code that indicates that, when
|
// * Non-fatal error code that indicates that, when
|
||||||
* reordering the matrix, no element was found that
|
// * reordering the matrix, no element was found that
|
||||||
* satisfies the absolute threshold criteria. The
|
// * satisfies the absolute threshold criteria. The
|
||||||
* largest element in the matrix was chosen as pivot.
|
// * largest element in the matrix was chosen as pivot.
|
||||||
*/
|
// */
|
||||||
#define spZERO_DIAG 2 /*!<
|
//#define spZERO_DIAG 2 /*!<
|
||||||
* Fatal error code that indicates that, a zero was
|
// * Fatal error code that indicates that, a zero was
|
||||||
* encountered on the diagonal the matrix. This does
|
// * encountered on the diagonal the matrix. This does
|
||||||
* not necessarily imply that the matrix is singular.
|
// * not necessarily imply that the matrix is singular.
|
||||||
* When this error occurs, the matrix should be
|
// * When this error occurs, the matrix should be
|
||||||
* reconstructed and factored using
|
// * reconstructed and factored using
|
||||||
* spOrderAndFactor().
|
// * spOrderAndFactor().
|
||||||
*/
|
// */
|
||||||
#define spSINGULAR 3 /*!<
|
//#define spSINGULAR 3 /*!<
|
||||||
* Fatal error code that indicates that, matrix is
|
// * Fatal error code that indicates that, matrix is
|
||||||
* singular, so no unique solution exists.
|
// * singular, so no unique solution exists.
|
||||||
*/
|
// */
|
||||||
#define spMANGLED 4 /*!<
|
//#define spMANGLED 4 /*!<
|
||||||
* Fatal error code that indicates that, matrix has
|
// * Fatal error code that indicates that, matrix has
|
||||||
* been mangled, results of requested operation are
|
// * been mangled, results of requested operation are
|
||||||
* garbage.
|
// * garbage.
|
||||||
*/
|
// */
|
||||||
#define spNO_MEMORY 5 /*!<
|
//#define spNO_MEMORY 5 /*!<
|
||||||
* Fatal error code that indicates that not enough
|
// * Fatal error code that indicates that not enough
|
||||||
* memory is available.
|
// * memory is available.
|
||||||
*/
|
// */
|
||||||
#define spPANIC 6 /*!<
|
//#define spPANIC 6 /*!<
|
||||||
* Fatal error code that indicates that the routines
|
// * Fatal error code that indicates that the routines
|
||||||
* are not prepared to handle the matrix that has
|
// * are not prepared to handle the matrix that has
|
||||||
* been requested. This may occur when the matrix
|
// * been requested. This may occur when the matrix
|
||||||
* is specified to be real and the routines are not
|
// * is specified to be real and the routines are not
|
||||||
* compiled for real matrices, or when the matrix is
|
// * compiled for real matrices, or when the matrix is
|
||||||
* specified to be complex and the routines are not
|
// * specified to be complex and the routines are not
|
||||||
* compiled to handle complex matrices.
|
// * compiled to handle complex matrices.
|
||||||
*/
|
// */
|
||||||
#define spFATAL 2 /*!<
|
//#define spFATAL 2 /*!<
|
||||||
* Error code that is not an error flag, but rather
|
// * Error code that is not an error flag, but rather
|
||||||
* the dividing line between fatal errors and
|
// * the dividing line between fatal errors and
|
||||||
* warnings.
|
// * warnings.
|
||||||
*/
|
// */
|
||||||
|
|
||||||
|
#include "ngspice/sperror.h" /* Spice error definitions. */
|
||||||
|
|
||||||
|
/* Begin error macros. */
|
||||||
|
#define spOKAY OK
|
||||||
|
#define spSMALL_PIVOT OK
|
||||||
|
#define spZERO_DIAG E_SINGULAR
|
||||||
|
#define spSINGULAR E_SINGULAR
|
||||||
|
#define spNO_MEMORY E_NOMEM
|
||||||
|
#define spPANIC E_BADMATRIX
|
||||||
|
#define spMANGLED E_BADMATRIX
|
||||||
|
|
||||||
|
#define spFATAL E_BADMATRIX
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -289,6 +300,7 @@ struct spTemplate
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct MatrixFrame *MatrixPtr;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -299,78 +311,78 @@ struct spTemplate
|
||||||
|
|
||||||
/* Begin function declarations. */
|
/* Begin function declarations. */
|
||||||
|
|
||||||
spcEXTERN void spClear( spMatrix );
|
spcEXTERN void spClear( MatrixPtr );
|
||||||
spcEXTERN spREAL spCondition( spMatrix, spREAL, int* );
|
spcEXTERN spREAL spCondition( MatrixPtr, spREAL, int* );
|
||||||
spcEXTERN spMatrix spCreate( int, int, spError* );
|
spcEXTERN MatrixPtr spCreate( int, int, spError* );
|
||||||
spcEXTERN void spDeleteRowAndCol( spMatrix, int, int );
|
spcEXTERN void spDeleteRowAndCol( MatrixPtr, int, int );
|
||||||
spcEXTERN void spDestroy( spMatrix );
|
spcEXTERN void spDestroy( MatrixPtr );
|
||||||
spcEXTERN int spElementCount( spMatrix );
|
spcEXTERN int spElementCount( MatrixPtr );
|
||||||
spcEXTERN int spOriginalCount( spMatrix );
|
spcEXTERN int spOriginalCount( MatrixPtr );
|
||||||
spcEXTERN spError spErrorState( spMatrix );
|
spcEXTERN spError spErrorState( MatrixPtr );
|
||||||
#ifdef EOF
|
#ifdef EOF
|
||||||
spcEXTERN void spErrorMessage( spMatrix, FILE*, char* );
|
spcEXTERN void spErrorMessage( MatrixPtr, FILE*, char* );
|
||||||
#else
|
#else
|
||||||
# define spErrorMessage(a,b,c) spcFUNC_NEEDS_FILE(_spErrorMessage,stdio)
|
# define spErrorMessage(a,b,c) spcFUNC_NEEDS_FILE(_spErrorMessage,stdio)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
spcEXTERN spError spFactor( spMatrix );
|
spcEXTERN spError spFactor( MatrixPtr );
|
||||||
spcEXTERN int spFileMatrix( spMatrix, char*, char*, int, int, int );
|
spcEXTERN int spFileMatrix( MatrixPtr, char*, char*, int, int, int );
|
||||||
spcEXTERN int spFileStats( spMatrix, char*, char* );
|
spcEXTERN int spFileStats( MatrixPtr, char*, char* );
|
||||||
spcEXTERN int spFillinCount( spMatrix );
|
spcEXTERN int spFillinCount( MatrixPtr );
|
||||||
spcEXTERN spElement *spFindElement( spMatrix, int, int );
|
spcEXTERN spElement *spFindElement( MatrixPtr, int, int );
|
||||||
spcEXTERN spError spGetAdmittance( spMatrix, int, int,
|
spcEXTERN spError spGetAdmittance( MatrixPtr, int, int,
|
||||||
struct spTemplate* );
|
struct spTemplate* );
|
||||||
spcEXTERN spElement *spGetElement( spMatrix, int, int );
|
spcEXTERN spElement *spGetElement( MatrixPtr, int, int );
|
||||||
spcEXTERN spGenericPtr spGetInitInfo( spElement* );
|
spcEXTERN spGenericPtr spGetInitInfo( spElement* );
|
||||||
spcEXTERN spError spGetOnes( spMatrix, int, int, int,
|
spcEXTERN spError spGetOnes( MatrixPtr, int, int, int,
|
||||||
struct spTemplate* );
|
struct spTemplate* );
|
||||||
spcEXTERN spError spGetQuad( spMatrix, int, int, int, int,
|
spcEXTERN spError spGetQuad( MatrixPtr, int, int, int, int,
|
||||||
struct spTemplate* );
|
struct spTemplate* );
|
||||||
spcEXTERN int spGetSize( spMatrix, int );
|
spcEXTERN int spGetSize( MatrixPtr, int );
|
||||||
spcEXTERN int spInitialize( spMatrix, int (*pInit)(spElement *, spGenericPtr, int, int) );
|
spcEXTERN int spInitialize( MatrixPtr, int (*pInit)(spElement *, spGenericPtr, int, int) );
|
||||||
spcEXTERN void spInstallInitInfo( spElement*, spGenericPtr );
|
spcEXTERN void spInstallInitInfo( spElement*, spGenericPtr );
|
||||||
spcEXTERN spREAL spLargestElement( spMatrix );
|
spcEXTERN spREAL spLargestElement( MatrixPtr );
|
||||||
spcEXTERN void spMNA_Preorder( spMatrix );
|
spcEXTERN void spMNA_Preorder( MatrixPtr );
|
||||||
spcEXTERN spREAL spNorm( spMatrix );
|
spcEXTERN spREAL spNorm( MatrixPtr );
|
||||||
spcEXTERN spError spOrderAndFactor( spMatrix, spREAL[], spREAL,
|
spcEXTERN spError spOrderAndFactor( MatrixPtr, spREAL[], spREAL,
|
||||||
spREAL, int );
|
spREAL, int );
|
||||||
spcEXTERN void spPartition( spMatrix, int );
|
spcEXTERN void spPartition( MatrixPtr, int );
|
||||||
spcEXTERN void spPrint( spMatrix, int, int, int );
|
spcEXTERN void spPrint( MatrixPtr, int, int, int );
|
||||||
spcEXTERN spREAL spPseudoCondition( spMatrix );
|
spcEXTERN spREAL spPseudoCondition( MatrixPtr );
|
||||||
spcEXTERN spREAL spRoundoff( spMatrix, spREAL );
|
spcEXTERN spREAL spRoundoff( MatrixPtr, spREAL );
|
||||||
spcEXTERN void spScale( spMatrix, spREAL[], spREAL[] );
|
spcEXTERN void spScale( MatrixPtr, spREAL[], spREAL[] );
|
||||||
spcEXTERN void spSetComplex( spMatrix );
|
spcEXTERN void spSetComplex( MatrixPtr );
|
||||||
spcEXTERN void spSetReal( spMatrix );
|
spcEXTERN void spSetReal( MatrixPtr );
|
||||||
spcEXTERN void spStripFills( spMatrix );
|
spcEXTERN void spStripFills( MatrixPtr );
|
||||||
spcEXTERN void spWhereSingular( spMatrix, int*, int* );
|
spcEXTERN void spWhereSingular( MatrixPtr, int*, int* );
|
||||||
spcEXTERN void spConstMult( spMatrix, double );
|
spcEXTERN void spConstMult( MatrixPtr, double );
|
||||||
|
|
||||||
/* Functions with argument lists that are dependent on options. */
|
/* Functions with argument lists that are dependent on options. */
|
||||||
|
|
||||||
#if spCOMPLEX
|
#if spCOMPLEX
|
||||||
spcEXTERN void spDeterminant( spMatrix, int*, spREAL*, spREAL* );
|
spcEXTERN void spDeterminant( MatrixPtr, int*, spREAL*, spREAL* );
|
||||||
#else /* NOT spCOMPLEX */
|
#else /* NOT spCOMPLEX */
|
||||||
spcEXTERN void spDeterminant( spMatrix, int*, spREAL* );
|
spcEXTERN void spDeterminant( MatrixPtr, int*, spREAL* );
|
||||||
#endif /* NOT spCOMPLEX */
|
#endif /* NOT spCOMPLEX */
|
||||||
#if spCOMPLEX && spSEPARATED_COMPLEX_VECTORS
|
#if spCOMPLEX && spSEPARATED_COMPLEX_VECTORS
|
||||||
spcEXTERN int spFileVector( spMatrix, char* ,
|
spcEXTERN int spFileVector( MatrixPtr, char* ,
|
||||||
spREAL[], spREAL[]);
|
spREAL[], spREAL[]);
|
||||||
spcEXTERN void spMultiply( spMatrix, spREAL[], spREAL[],
|
spcEXTERN void spMultiply( MatrixPtr, spREAL[], spREAL[],
|
||||||
spREAL[], spREAL[] );
|
spREAL[], spREAL[] );
|
||||||
spcEXTERN void spMultTransposed( spMatrix, spREAL[], spREAL[],
|
spcEXTERN void spMultTransposed( MatrixPtr, spREAL[], spREAL[],
|
||||||
spREAL[], spREAL[] );
|
spREAL[], spREAL[] );
|
||||||
spcEXTERN void spSolve( spMatrix, spREAL[], spREAL[], spREAL[],
|
spcEXTERN void spSolve( MatrixPtr, spREAL[], spREAL[], spREAL[],
|
||||||
spREAL[] );
|
spREAL[] );
|
||||||
spcEXTERN void spSolveTransposed( spMatrix, spREAL[], spREAL[],
|
spcEXTERN void spSolveTransposed( MatrixPtr, spREAL[], spREAL[],
|
||||||
spREAL[], spREAL[] );
|
spREAL[], spREAL[] );
|
||||||
#else /* NOT (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */
|
#else /* NOT (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */
|
||||||
spcEXTERN int spFileVector( spMatrix, char* , spREAL[] );
|
spcEXTERN int spFileVector( MatrixPtr, char* , spREAL[] );
|
||||||
spcEXTERN void spMultiply( spMatrix, spREAL[], spREAL[] );
|
spcEXTERN void spMultiply( MatrixPtr, spREAL[], spREAL[] );
|
||||||
spcEXTERN void spMultTransposed( spMatrix,
|
spcEXTERN void spMultTransposed( MatrixPtr,
|
||||||
spREAL[], spREAL[] );
|
spREAL[], spREAL[] );
|
||||||
spcEXTERN void spSolve( spMatrix, spREAL[], spREAL[] );
|
spcEXTERN void spSolve( MatrixPtr, spREAL[], spREAL[] );
|
||||||
spcEXTERN void spSolveTransposed( spMatrix,
|
spcEXTERN void spSolveTransposed( MatrixPtr,
|
||||||
spREAL[], spREAL[] );
|
spREAL[], spREAL[] );
|
||||||
#endif /* NOT (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */
|
#endif /* NOT (spCOMPLEX && spSEPARATED_COMPLEX_VECTORS) */
|
||||||
#endif /* spOKAY */
|
#endif /* spOKAY */
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ static void AllocateBlockOfAllocationList( MatrixPtr );
|
||||||
* A pointer to the matrix frame being created.
|
* A pointer to the matrix frame being created.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spMatrix
|
MatrixPtr
|
||||||
spCreate(
|
spCreate(
|
||||||
int Size,
|
int Size,
|
||||||
int Complex,
|
int Complex,
|
||||||
|
|
@ -263,14 +263,14 @@ int AllocatedSize;
|
||||||
if (Matrix->Error == spNO_MEMORY)
|
if (Matrix->Error == spNO_MEMORY)
|
||||||
goto MemoryError;
|
goto MemoryError;
|
||||||
|
|
||||||
return (char *)Matrix;
|
return Matrix;
|
||||||
|
|
||||||
MemoryError:
|
MemoryError:
|
||||||
|
|
||||||
/* Deallocate matrix and return no pointer to matrix if there is not enough
|
/* Deallocate matrix and return no pointer to matrix if there is not enough
|
||||||
memory. */
|
memory. */
|
||||||
*pError = spNO_MEMORY;
|
*pError = spNO_MEMORY;
|
||||||
spDestroy( (char *)Matrix);
|
spDestroy( Matrix );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -605,7 +605,7 @@ register AllocationListPtr ListPtr;
|
||||||
/*!
|
/*!
|
||||||
* Destroys a matrix and frees all memory associated with it.
|
* Destroys a matrix and frees all memory associated with it.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix frame which is to be destroyed.
|
* Pointer to the matrix frame which is to be destroyed.
|
||||||
*/
|
*/
|
||||||
/* >>> Local variables:
|
/* >>> Local variables:
|
||||||
|
|
@ -620,9 +620,8 @@ register AllocationListPtr ListPtr;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
spDestroy( spMatrix eMatrix )
|
spDestroy( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register AllocationListPtr ListPtr, NextListPtr;
|
register AllocationListPtr ListPtr, NextListPtr;
|
||||||
|
|
||||||
/* Begin `spDestroy'. */
|
/* Begin `spDestroy'. */
|
||||||
|
|
@ -666,18 +665,18 @@ register AllocationListPtr ListPtr, NextListPtr;
|
||||||
* \return
|
* \return
|
||||||
* The error status of the given matrix.
|
* The error status of the given matrix.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* The pointer to the matrix for which the error status is desired.
|
* The pointer to the matrix for which the error status is desired.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spError
|
spError
|
||||||
spErrorState( spMatrix eMatrix )
|
spErrorState( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
/* Begin `spErrorState'. */
|
/* Begin `spErrorState'. */
|
||||||
|
|
||||||
if (eMatrix != NULL)
|
if (Matrix != NULL)
|
||||||
{ ASSERT_IS_SPARSE( (MatrixPtr)eMatrix );
|
{ ASSERT_IS_SPARSE( (MatrixPtr)Matrix );
|
||||||
return ((MatrixPtr)eMatrix)->Error;
|
return ((MatrixPtr)Matrix)->Error;
|
||||||
}
|
}
|
||||||
else return spNO_MEMORY; /* This error may actually be spPANIC,
|
else return spNO_MEMORY; /* This error may actually be spPANIC,
|
||||||
* no way to tell. */
|
* no way to tell. */
|
||||||
|
|
@ -698,7 +697,7 @@ spErrorState( spMatrix eMatrix )
|
||||||
* allowed on the last factorization). Pivoting is performed only in
|
* allowed on the last factorization). Pivoting is performed only in
|
||||||
* spOrderAndFactor().
|
* spOrderAndFactor().
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* The matrix for which the error status is desired.
|
* The matrix for which the error status is desired.
|
||||||
* \param pRow
|
* \param pRow
|
||||||
* The row number.
|
* The row number.
|
||||||
|
|
@ -708,13 +707,11 @@ spErrorState( spMatrix eMatrix )
|
||||||
|
|
||||||
void
|
void
|
||||||
spWhereSingular(
|
spWhereSingular(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int *pRow,
|
int *pRow,
|
||||||
int *pCol
|
int *pCol
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
|
|
||||||
/* Begin `spWhereSingular'. */
|
/* Begin `spWhereSingular'. */
|
||||||
ASSERT_IS_SPARSE( Matrix );
|
ASSERT_IS_SPARSE( Matrix );
|
||||||
|
|
||||||
|
|
@ -735,7 +732,7 @@ MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
||||||
* Returns the size of the matrix. Either the internal or external size of
|
* Returns the size of the matrix. Either the internal or external size of
|
||||||
* the matrix is returned.
|
* the matrix is returned.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param External
|
* \param External
|
||||||
* If \a External is set true, the external size , i.e., the value of the
|
* If \a External is set true, the external size , i.e., the value of the
|
||||||
|
|
@ -746,12 +743,10 @@ MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
||||||
|
|
||||||
int
|
int
|
||||||
spGetSize(
|
spGetSize(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int External
|
int External
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
|
|
||||||
/* Begin `spGetSize'. */
|
/* Begin `spGetSize'. */
|
||||||
ASSERT_IS_SPARSE( Matrix );
|
ASSERT_IS_SPARSE( Matrix );
|
||||||
|
|
||||||
|
|
@ -775,18 +770,18 @@ MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
||||||
/*!
|
/*!
|
||||||
* Forces matrix to be real.
|
* Forces matrix to be real.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
spSetReal( spMatrix eMatrix )
|
spSetReal( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
/* Begin `spSetReal'. */
|
/* Begin `spSetReal'. */
|
||||||
|
|
||||||
ASSERT_IS_SPARSE( (MatrixPtr)eMatrix );
|
ASSERT_IS_SPARSE( (MatrixPtr)Matrix );
|
||||||
vASSERT( REAL, "Sparse not compiled to handle real matrices" );
|
vASSERT( REAL, "Sparse not compiled to handle real matrices" );
|
||||||
((MatrixPtr)eMatrix)->Complex = NO;
|
((MatrixPtr)Matrix)->Complex = NO;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -794,18 +789,18 @@ spSetReal( spMatrix eMatrix )
|
||||||
/*!
|
/*!
|
||||||
* Forces matrix to be complex.
|
* Forces matrix to be complex.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
spSetComplex( spMatrix eMatrix )
|
spSetComplex( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
/* Begin `spSetComplex'. */
|
/* Begin `spSetComplex'. */
|
||||||
|
|
||||||
ASSERT_IS_SPARSE( (MatrixPtr)eMatrix );
|
ASSERT_IS_SPARSE( (MatrixPtr)Matrix );
|
||||||
vASSERT( spCOMPLEX, "Sparse not compiled to handle complex matrices" );
|
vASSERT( spCOMPLEX, "Sparse not compiled to handle complex matrices" );
|
||||||
((MatrixPtr)eMatrix)->Complex = YES;
|
((MatrixPtr)Matrix)->Complex = YES;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -820,44 +815,44 @@ spSetComplex( spMatrix eMatrix )
|
||||||
/*!
|
/*!
|
||||||
* This function returns the number of fill-ins that currently exists in a matrix.
|
* This function returns the number of fill-ins that currently exists in a matrix.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
spFillinCount( spMatrix eMatrix )
|
spFillinCount( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
/* Begin `spFillinCount'. */
|
/* Begin `spFillinCount'. */
|
||||||
|
|
||||||
ASSERT_IS_SPARSE( (MatrixPtr)eMatrix );
|
ASSERT_IS_SPARSE( (MatrixPtr)Matrix );
|
||||||
return ((MatrixPtr)eMatrix)->Fillins;
|
return ((MatrixPtr)Matrix)->Fillins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* This function returns the total number of elements (including fill-ins) that currently exists in a matrix.
|
* This function returns the total number of elements (including fill-ins) that currently exists in a matrix.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* FIXME: Seems no different size entries available anymore */
|
/* FIXME: Seems no different size entries available anymore */
|
||||||
|
|
||||||
int
|
int
|
||||||
spElementCount( spMatrix eMatrix )
|
spElementCount( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
/* Begin `spElementCount'. */
|
/* Begin `spElementCount'. */
|
||||||
|
|
||||||
ASSERT_IS_SPARSE( (MatrixPtr)eMatrix );
|
ASSERT_IS_SPARSE( (MatrixPtr)Matrix );
|
||||||
return ((MatrixPtr)eMatrix)->Elements;
|
return ((MatrixPtr)Matrix)->Elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
spOriginalCount( spMatrix eMatrix )
|
spOriginalCount( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
/* Begin `spOriginalCount'. */
|
/* Begin `spOriginalCount'. */
|
||||||
|
|
||||||
ASSERT_IS_SPARSE( (MatrixPtr)eMatrix );
|
ASSERT_IS_SPARSE( (MatrixPtr)Matrix );
|
||||||
return ((MatrixPtr)eMatrix)->Elements;
|
return ((MatrixPtr)Matrix)->Elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ static void EnlargeMatrix( MatrixPtr, int );
|
||||||
/*!
|
/*!
|
||||||
* Sets every element of the matrix to zero and clears the error flag.
|
* Sets every element of the matrix to zero and clears the error flag.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix that is to be cleared.
|
* Pointer to matrix that is to be cleared.
|
||||||
*/
|
*/
|
||||||
/* >>> Local variables:
|
/* >>> Local variables:
|
||||||
|
|
@ -94,9 +94,8 @@ static void EnlargeMatrix( MatrixPtr, int );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
spClear( spMatrix eMatrix )
|
spClear( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register int I;
|
register int I;
|
||||||
|
|
||||||
|
|
@ -156,7 +155,7 @@ register int I;
|
||||||
* \return
|
* \return
|
||||||
* A pointer to the desired element, or \a NULL if it does not exist.
|
* A pointer to the desired element, or \a NULL if it does not exist.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param Row
|
* \param Row
|
||||||
* Row index for element.
|
* Row index for element.
|
||||||
|
|
@ -172,12 +171,11 @@ register int I;
|
||||||
|
|
||||||
spElement *
|
spElement *
|
||||||
spFindElement(
|
spFindElement(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int Row,
|
int Row,
|
||||||
int Col
|
int Col
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
int StartAt;
|
int StartAt;
|
||||||
long int Min = LARGEST_LONG_INTEGER;
|
long int Min = LARGEST_LONG_INTEGER;
|
||||||
|
|
@ -256,7 +254,7 @@ long int Min = LARGEST_LONG_INTEGER;
|
||||||
* Returns a pointer to the element. This pointer is then used to directly
|
* Returns a pointer to the element. This pointer is then used to directly
|
||||||
* access the element during successive builds.
|
* access the element during successive builds.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix that the element is to be added to.
|
* Pointer to the matrix that the element is to be added to.
|
||||||
* \param Row
|
* \param Row
|
||||||
* Row index for element. Must be in the range of [0..Size] unless
|
* Row index for element. Must be in the range of [0..Size] unless
|
||||||
|
|
@ -280,12 +278,11 @@ long int Min = LARGEST_LONG_INTEGER;
|
||||||
|
|
||||||
spElement *
|
spElement *
|
||||||
spGetElement(
|
spGetElement(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int Row,
|
int Row,
|
||||||
int Col
|
int Col
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
ElementPtr pElement;
|
ElementPtr pElement;
|
||||||
|
|
||||||
/* Begin `spGetElement'. */
|
/* Begin `spGetElement'. */
|
||||||
|
|
@ -1152,7 +1149,7 @@ register int I, OldAllocatedSize = Matrix->AllocatedExtSize;
|
||||||
*
|
*
|
||||||
* \return
|
* \return
|
||||||
* Returns the return value of the \a pInit() function.
|
* Returns the return value of the \a pInit() function.
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param pInit
|
* \param pInit
|
||||||
* Pointer to a function that initializes an element.
|
* Pointer to a function that initializes an element.
|
||||||
|
|
@ -1162,7 +1159,7 @@ register int I, OldAllocatedSize = Matrix->AllocatedExtSize;
|
||||||
|
|
||||||
int
|
int
|
||||||
spInitialize(
|
spInitialize(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int (*pInit)(
|
int (*pInit)(
|
||||||
spElement *pElement,
|
spElement *pElement,
|
||||||
spGenericPtr pInitInfo,
|
spGenericPtr pInitInfo,
|
||||||
|
|
@ -1171,7 +1168,6 @@ spInitialize(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
int J, Error, Col;
|
int J, Error, Col;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ static void WriteStatus( MatrixPtr, int );
|
||||||
* \a spSINGULAR and \a spSMALL_PIVOT.
|
* \a spSINGULAR and \a spSMALL_PIVOT.
|
||||||
* Error is cleared upon entering this function.
|
* Error is cleared upon entering this function.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix.
|
* Pointer to the matrix.
|
||||||
* \param RHS
|
* \param RHS
|
||||||
* Representative right-hand side vector that is used to determine
|
* Representative right-hand side vector that is used to determine
|
||||||
|
|
@ -187,14 +187,13 @@ static void WriteStatus( MatrixPtr, int );
|
||||||
|
|
||||||
spError
|
spError
|
||||||
spOrderAndFactor(
|
spOrderAndFactor(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
spREAL RHS[],
|
spREAL RHS[],
|
||||||
spREAL RelThreshold,
|
spREAL RelThreshold,
|
||||||
spREAL AbsThreshold,
|
spREAL AbsThreshold,
|
||||||
int DiagPivoting
|
int DiagPivoting
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
ElementPtr pPivot;
|
ElementPtr pPivot;
|
||||||
int Step, Size;
|
int Step, Size;
|
||||||
ElementPtr SearchForPivot();
|
ElementPtr SearchForPivot();
|
||||||
|
|
@ -318,15 +317,14 @@ Done:
|
||||||
* \a spNO_MEMORY, \a spSINGULAR, \a spZERO_DIAG and \a spSMALL_PIVOT.
|
* \a spNO_MEMORY, \a spSINGULAR, \a spZERO_DIAG and \a spSMALL_PIVOT.
|
||||||
* Error is cleared upon entering this function.
|
* Error is cleared upon entering this function.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \see spOrderAndFactor()
|
* \see spOrderAndFactor()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spError
|
spError
|
||||||
spFactor( spMatrix eMatrix )
|
spFactor( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register ElementPtr pColumn;
|
register ElementPtr pColumn;
|
||||||
register int Step, Size;
|
register int Step, Size;
|
||||||
|
|
@ -338,10 +336,10 @@ RealNumber Mult;
|
||||||
ASSERT_IS_NOT_FACTORED( Matrix );
|
ASSERT_IS_NOT_FACTORED( Matrix );
|
||||||
|
|
||||||
if (Matrix->NeedsOrdering)
|
if (Matrix->NeedsOrdering)
|
||||||
{ return spOrderAndFactor( eMatrix, (RealVector)NULL,
|
{ return spOrderAndFactor( Matrix, (RealVector)NULL,
|
||||||
0.0, 0.0, DIAG_PIVOTING_AS_DEFAULT );
|
0.0, 0.0, DIAG_PIVOTING_AS_DEFAULT );
|
||||||
}
|
}
|
||||||
if (NOT Matrix->Partitioned) spPartition( eMatrix, spDEFAULT_PARTITION );
|
if (NOT Matrix->Partitioned) spPartition( Matrix, spDEFAULT_PARTITION );
|
||||||
#if spCOMPLEX
|
#if spCOMPLEX
|
||||||
if (Matrix->Complex) return FactorComplexMatrix( Matrix );
|
if (Matrix->Complex) return FactorComplexMatrix( Matrix );
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -444,7 +442,7 @@ RealNumber Mult;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
FactorComplexMatrix( MatrixPtr Matrix )
|
FactorComplexMatrix( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register ElementPtr pColumn;
|
register ElementPtr pColumn;
|
||||||
|
|
@ -570,7 +568,7 @@ ComplexNumber Mult, Pivot;
|
||||||
* best to let Sparse choose the partition. Otherwise, you should
|
* best to let Sparse choose the partition. Otherwise, you should
|
||||||
* choose the partition based on the predicted density of the matrix.
|
* choose the partition based on the predicted density of the matrix.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param Mode
|
* \param Mode
|
||||||
* Mode must be one of three special codes: \a spDIRECT_PARTITION,
|
* Mode must be one of three special codes: \a spDIRECT_PARTITION,
|
||||||
|
|
@ -579,11 +577,10 @@ ComplexNumber Mult, Pivot;
|
||||||
|
|
||||||
void
|
void
|
||||||
spPartition(
|
spPartition(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int Mode
|
int Mode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement, pColumn;
|
register ElementPtr pElement, pColumn;
|
||||||
register int Step, Size;
|
register int Step, Size;
|
||||||
register int *Nc, *No;
|
register int *Nc, *No;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
* statistics are also output. The matrix is output in a format that is
|
* statistics are also output. The matrix is output in a format that is
|
||||||
* readable by people.
|
* readable by people.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param PrintReordered
|
* \param PrintReordered
|
||||||
* Indicates whether the matrix should be printed out in its original
|
* Indicates whether the matrix should be printed out in its original
|
||||||
|
|
@ -129,13 +129,12 @@
|
||||||
|
|
||||||
void
|
void
|
||||||
spPrint(
|
spPrint(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int PrintReordered,
|
int PrintReordered,
|
||||||
int Data,
|
int Data,
|
||||||
int Header
|
int Header
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int J = 0;
|
register int J = 0;
|
||||||
int I, Row, Col, Size, Top, StartCol = 1, StopCol, Columns, ElementCount = 0;
|
int I, Row, Col, Size, Top, StartCol = 1, StopCol, Columns, ElementCount = 0;
|
||||||
double Magnitude, SmallestDiag, SmallestElement;
|
double Magnitude, SmallestDiag, SmallestElement;
|
||||||
|
|
@ -365,7 +364,7 @@ int *PrintOrdToIntRowMap, *PrintOrdToIntColMap;
|
||||||
* The calling function can query \a errno (the system global error variable)
|
* The calling function can query \a errno (the system global error variable)
|
||||||
* as to the reason why this routine failed.
|
* as to the reason why this routine failed.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param File
|
* \param File
|
||||||
* Name of file into which matrix is to be written.
|
* Name of file into which matrix is to be written.
|
||||||
|
|
@ -397,7 +396,7 @@ int *PrintOrdToIntRowMap, *PrintOrdToIntColMap;
|
||||||
|
|
||||||
int
|
int
|
||||||
spFileMatrix(
|
spFileMatrix(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
char *File,
|
char *File,
|
||||||
char *Label,
|
char *Label,
|
||||||
int Reordered,
|
int Reordered,
|
||||||
|
|
@ -405,7 +404,6 @@ spFileMatrix(
|
||||||
int Header
|
int Header
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int I, Size;
|
register int I, Size;
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
int Row, Col, Err;
|
int Row, Col, Err;
|
||||||
|
|
@ -528,7 +526,7 @@ FILE *pMatrixFile;
|
||||||
* The calling function can query \a errno (the system global error variable)
|
* The calling function can query \a errno (the system global error variable)
|
||||||
* as to the reason why this routine failed.
|
* as to the reason why this routine failed.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param File
|
* \param File
|
||||||
* Name of file into which matrix is to be written.
|
* Name of file into which matrix is to be written.
|
||||||
|
|
@ -551,7 +549,7 @@ FILE *pMatrixFile;
|
||||||
|
|
||||||
int
|
int
|
||||||
spFileVector(
|
spFileVector(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
char *File,
|
char *File,
|
||||||
spREAL RHS[]
|
spREAL RHS[]
|
||||||
#if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
#if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
||||||
|
|
@ -559,7 +557,6 @@ spFileVector(
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int I, Size, Err;
|
register int I, Size, Err;
|
||||||
FILE *pMatrixFile;
|
FILE *pMatrixFile;
|
||||||
|
|
||||||
|
|
@ -649,7 +646,7 @@ FILE *pMatrixFile;
|
||||||
* The calling function can query \a errno (the system global error variable)
|
* The calling function can query \a errno (the system global error variable)
|
||||||
* as to the reason why this routine failed.
|
* as to the reason why this routine failed.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param File
|
* \param File
|
||||||
* Name of file into which matrix is to be written.
|
* Name of file into which matrix is to be written.
|
||||||
|
|
@ -675,12 +672,11 @@ FILE *pMatrixFile;
|
||||||
|
|
||||||
int
|
int
|
||||||
spFileStats(
|
spFileStats(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
char *File,
|
char *File,
|
||||||
char *Label
|
char *Label
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int Size, I;
|
register int Size, I;
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
int NumberOfElements;
|
int NumberOfElements;
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,7 @@
|
||||||
|
|
||||||
typedef spREAL *RealVector;
|
typedef spREAL *RealVector;
|
||||||
|
|
||||||
static void LoadGmin(char *Matrix, double Gmin);
|
static void LoadGmin(MatrixPtr Matrix, double Gmin);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SMPaddElt()
|
* SMPaddElt()
|
||||||
|
|
@ -109,8 +109,8 @@ SMPmatrix *Matrix,
|
||||||
int Row, int Col,
|
int Row, int Col,
|
||||||
double Value)
|
double Value)
|
||||||
{
|
{
|
||||||
*spGetElement( (char *)Matrix, Row, Col ) = Value;
|
*spGetElement( Matrix, Row, Col ) = Value;
|
||||||
return spErrorState( (char *)Matrix );
|
return spErrorState( Matrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -121,7 +121,7 @@ SMPmakeElt(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
int Row, int Col)
|
int Row, int Col)
|
||||||
{
|
{
|
||||||
return spGetElement( (char *)Matrix, Row, Col );
|
return spGetElement( Matrix, Row, Col );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -131,7 +131,7 @@ void
|
||||||
SMPcClear(
|
SMPcClear(
|
||||||
SMPmatrix *Matrix)
|
SMPmatrix *Matrix)
|
||||||
{
|
{
|
||||||
spClear( (char *)Matrix );
|
spClear( Matrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -141,7 +141,7 @@ void
|
||||||
SMPclear(
|
SMPclear(
|
||||||
SMPmatrix *Matrix)
|
SMPmatrix *Matrix)
|
||||||
{
|
{
|
||||||
spClear( (char *)Matrix );
|
spClear( Matrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -153,8 +153,8 @@ SMPcLUfac(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
double PivTol)
|
double PivTol)
|
||||||
{
|
{
|
||||||
spSetComplex( (char *)Matrix );
|
spSetComplex( Matrix );
|
||||||
return spFactor( (char *)Matrix );
|
return spFactor( Matrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -166,9 +166,9 @@ SMPluFac(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
double PivTol, double Gmin)
|
double PivTol, double Gmin)
|
||||||
{
|
{
|
||||||
spSetReal( (char *)Matrix );
|
spSetReal( Matrix );
|
||||||
LoadGmin( (char *)Matrix, Gmin );
|
LoadGmin( Matrix, Gmin );
|
||||||
return spFactor( (char *)Matrix );
|
return spFactor( Matrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -181,8 +181,8 @@ double PivTol, double PivRel,
|
||||||
int *NumSwaps)
|
int *NumSwaps)
|
||||||
{
|
{
|
||||||
*NumSwaps = 0;
|
*NumSwaps = 0;
|
||||||
spSetComplex( (char *)Matrix );
|
spSetComplex( Matrix );
|
||||||
return spOrderAndFactor( (char *)Matrix, (spREAL*)NULL,
|
return spOrderAndFactor( Matrix, (spREAL*)NULL,
|
||||||
(spREAL)PivRel, (spREAL)PivTol, YES );
|
(spREAL)PivRel, (spREAL)PivTol, YES );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -194,9 +194,9 @@ SMPreorder(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
double PivTol, double PivRel, double Gmin)
|
double PivTol, double PivRel, double Gmin)
|
||||||
{
|
{
|
||||||
spSetComplex( (char *)Matrix );
|
spSetComplex( Matrix );
|
||||||
LoadGmin( (char *)Matrix, Gmin );
|
LoadGmin( Matrix, Gmin );
|
||||||
return spOrderAndFactor( (char *)Matrix, (spREAL*)NULL,
|
return spOrderAndFactor( Matrix, (spREAL*)NULL,
|
||||||
(spREAL)PivRel, (spREAL)PivTol, YES );
|
(spREAL)PivRel, (spREAL)PivTol, YES );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,7 +208,7 @@ SMPcaSolve(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
double RHS[], double iRHS[], double Spare[], double iSpare[])
|
double RHS[], double iRHS[], double Spare[], double iSpare[])
|
||||||
{
|
{
|
||||||
spSolveTransposed( (char *)Matrix, RHS, RHS, iRHS, iRHS );
|
spSolveTransposed( Matrix, RHS, RHS, iRHS, iRHS );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -219,7 +219,7 @@ SMPcSolve(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
double RHS[], double iRHS[], double Spare[], double iSpare[])
|
double RHS[], double iRHS[], double Spare[], double iSpare[])
|
||||||
{
|
{
|
||||||
spSolve( (char *)Matrix, RHS, RHS, iRHS, iRHS );
|
spSolve( Matrix, RHS, RHS, iRHS, iRHS );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -230,7 +230,7 @@ SMPsolve(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
double RHS[], double Spare[])
|
double RHS[], double Spare[])
|
||||||
{
|
{
|
||||||
spSolve( (char *)Matrix, RHS, RHS, (spREAL*)NULL, (spREAL*)NULL );
|
spSolve( Matrix, RHS, RHS, (spREAL*)NULL, (spREAL*)NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -240,7 +240,7 @@ int
|
||||||
SMPmatSize(
|
SMPmatSize(
|
||||||
SMPmatrix *Matrix)
|
SMPmatrix *Matrix)
|
||||||
{
|
{
|
||||||
return spGetSize( (char *)Matrix, 1 );
|
return spGetSize( Matrix, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -263,7 +263,7 @@ void
|
||||||
SMPdestroy(
|
SMPdestroy(
|
||||||
SMPmatrix *Matrix)
|
SMPmatrix *Matrix)
|
||||||
{
|
{
|
||||||
spDestroy( (char *)Matrix );
|
spDestroy( Matrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -273,8 +273,8 @@ int
|
||||||
SMPpreOrder(
|
SMPpreOrder(
|
||||||
SMPmatrix *Matrix)
|
SMPmatrix *Matrix)
|
||||||
{
|
{
|
||||||
spMNA_Preorder( (char *)Matrix );
|
spMNA_Preorder( Matrix );
|
||||||
return spErrorState( (char *)Matrix );
|
return spErrorState( Matrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -295,7 +295,7 @@ SMPprint(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
char *File)
|
char *File)
|
||||||
{
|
{
|
||||||
spPrint( (char *)Matrix, 0, 1, 1 );
|
spPrint( Matrix, 0, 1, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -306,7 +306,7 @@ SMPgetError(
|
||||||
SMPmatrix *Matrix,
|
SMPmatrix *Matrix,
|
||||||
int *Row, int *Col)
|
int *Row, int *Col)
|
||||||
{
|
{
|
||||||
spWhereSingular( (char *)Matrix, Row, Col );
|
spWhereSingular( Matrix, Row, Col );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -318,9 +318,9 @@ SMPmatrix *Matrix,
|
||||||
SPcomplex *pMantissa,
|
SPcomplex *pMantissa,
|
||||||
int *pExponent)
|
int *pExponent)
|
||||||
{
|
{
|
||||||
spDeterminant( (char *)Matrix, pExponent, &(pMantissa->real),
|
spDeterminant( Matrix, pExponent, &(pMantissa->real),
|
||||||
&(pMantissa->imag) );
|
&(pMantissa->imag) );
|
||||||
return spErrorState( (char *)Matrix );
|
return spErrorState( Matrix );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -419,10 +419,9 @@ SMPcDProd(SMPmatrix *Matrix, SPcomplex *pMantissa, int *pExponent)
|
||||||
#include "spDefs.h"
|
#include "spDefs.h"
|
||||||
static void
|
static void
|
||||||
LoadGmin(
|
LoadGmin(
|
||||||
char *eMatrix,
|
MatrixPtr Matrix,
|
||||||
register double Gmin)
|
register double Gmin)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int I;
|
register int I;
|
||||||
register ArrayOfElementPtrs Diag;
|
register ArrayOfElementPtrs Diag;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ static void SolveComplexTransposedMatrix( MatrixPtr,
|
||||||
* in different way than is traditionally used in order to exploit the
|
* in different way than is traditionally used in order to exploit the
|
||||||
* sparsity of the right-hand side. See the reference in spRevision.
|
* sparsity of the right-hand side. See the reference in spRevision.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param RHS
|
* \param RHS
|
||||||
* \a RHS is the input data array, the right hand side. This data is
|
* \a RHS is the input data array, the right hand side. This data is
|
||||||
|
|
@ -137,7 +137,7 @@ static void SolveComplexTransposedMatrix( MatrixPtr,
|
||||||
|
|
||||||
void
|
void
|
||||||
spSolve(
|
spSolve(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
spREAL RHS[],
|
spREAL RHS[],
|
||||||
spREAL Solution[]
|
spREAL Solution[]
|
||||||
# if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
# if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
||||||
|
|
@ -146,7 +146,6 @@ spSolve(
|
||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register RealVector Intermediate;
|
register RealVector Intermediate;
|
||||||
register RealNumber Temp;
|
register RealNumber Temp;
|
||||||
|
|
@ -405,7 +404,7 @@ ComplexNumber Temp;
|
||||||
* matrix and that the diagonal of the untransposed upper
|
* matrix and that the diagonal of the untransposed upper
|
||||||
* triangular matrix consists of ones.
|
* triangular matrix consists of ones.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to matrix.
|
* Pointer to matrix.
|
||||||
* \param RHS
|
* \param RHS
|
||||||
* \a RHS is the input data array, the right hand side. This data is
|
* \a RHS is the input data array, the right hand side. This data is
|
||||||
|
|
@ -451,7 +450,7 @@ ComplexNumber Temp;
|
||||||
|
|
||||||
void
|
void
|
||||||
spSolveTransposed(
|
spSolveTransposed(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
spREAL RHS[],
|
spREAL RHS[],
|
||||||
spREAL Solution[]
|
spREAL Solution[]
|
||||||
# if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
# if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
||||||
|
|
@ -460,7 +459,6 @@ spSolveTransposed(
|
||||||
# endif
|
# endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register RealVector Intermediate;
|
register RealVector Intermediate;
|
||||||
register int I, *pExtOrder, Size;
|
register int I, *pExtOrder, Size;
|
||||||
|
|
|
||||||
|
|
@ -170,7 +170,7 @@ static RealNumber ComplexCondition( MatrixPtr, RealNumber, int* );
|
||||||
* The algorithm used in this function was developed by Ken Kundert and
|
* The algorithm used in this function was developed by Ken Kundert and
|
||||||
* Tom Quarles.
|
* Tom Quarles.
|
||||||
*
|
*
|
||||||
* \param * eMatrix
|
* \param * Matrix
|
||||||
* Pointer to the matrix to be preordered.
|
* Pointer to the matrix to be preordered.
|
||||||
*/
|
*/
|
||||||
/* >>> Local variables;
|
/* >>> Local variables;
|
||||||
|
|
@ -193,9 +193,8 @@ static RealNumber ComplexCondition( MatrixPtr, RealNumber, int* );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
spMNA_Preorder( spMatrix eMatrix )
|
spMNA_Preorder( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int J, Size;
|
register int J, Size;
|
||||||
ElementPtr pTwin1, pTwin2;
|
ElementPtr pTwin1, pTwin2;
|
||||||
int Twins, StartAt = 1;
|
int Twins, StartAt = 1;
|
||||||
|
|
@ -362,7 +361,7 @@ int Col1 = pTwin1->Col, Col2 = pTwin2->Col;
|
||||||
* the RHS and Solution vectors descaled. Lastly, this function
|
* the RHS and Solution vectors descaled. Lastly, this function
|
||||||
* should not be executed before the function spMNA_Preorder().
|
* should not be executed before the function spMNA_Preorder().
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix to be scaled.
|
* Pointer to the matrix to be scaled.
|
||||||
* \param SolutionScaleFactors
|
* \param SolutionScaleFactors
|
||||||
* The array of Solution scale factors. These factors scale the columns.
|
* The array of Solution scale factors. These factors scale the columns.
|
||||||
|
|
@ -385,12 +384,11 @@ int Col1 = pTwin1->Col, Col2 = pTwin2->Col;
|
||||||
|
|
||||||
void
|
void
|
||||||
spScale(
|
spScale(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
spREAL RHS_ScaleFactors[],
|
spREAL RHS_ScaleFactors[],
|
||||||
spREAL SolutionScaleFactors[]
|
spREAL SolutionScaleFactors[]
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register int I, lSize, *pExtOrder;
|
register int I, lSize, *pExtOrder;
|
||||||
RealNumber ScaleFactor;
|
RealNumber ScaleFactor;
|
||||||
|
|
@ -579,7 +577,7 @@ RealNumber ScaleFactor;
|
||||||
* as a test to see if solutions are correct. It should not be used
|
* as a test to see if solutions are correct. It should not be used
|
||||||
* before spMNA_Preorder().
|
* before spMNA_Preorder().
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix.
|
* Pointer to the matrix.
|
||||||
* \param RHS
|
* \param RHS
|
||||||
* RHS is the right hand side. This is what is being solved for.
|
* RHS is the right hand side. This is what is being solved for.
|
||||||
|
|
@ -597,7 +595,7 @@ RealNumber ScaleFactor;
|
||||||
|
|
||||||
void
|
void
|
||||||
spMultiply(
|
spMultiply(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
spREAL RHS[],
|
spREAL RHS[],
|
||||||
spREAL Solution[]
|
spREAL Solution[]
|
||||||
#if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
#if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
||||||
|
|
@ -610,7 +608,6 @@ register ElementPtr pElement;
|
||||||
register RealVector Vector;
|
register RealVector Vector;
|
||||||
register RealNumber Sum;
|
register RealNumber Sum;
|
||||||
register int I, *pExtOrder;
|
register int I, *pExtOrder;
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
extern void ComplexMatrixMultiply();
|
extern void ComplexMatrixMultiply();
|
||||||
|
|
||||||
/* Begin `spMultiply'. */
|
/* Begin `spMultiply'. */
|
||||||
|
|
@ -770,7 +767,7 @@ register int I, *pExtOrder;
|
||||||
* as a test to see if solutions are correct. It should not be used
|
* as a test to see if solutions are correct. It should not be used
|
||||||
* before spMNA_Preorder().
|
* before spMNA_Preorder().
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix.
|
* Pointer to the matrix.
|
||||||
* \param RHS
|
* \param RHS
|
||||||
* RHS is the right hand side. This is what is being solved for.
|
* RHS is the right hand side. This is what is being solved for.
|
||||||
|
|
@ -788,7 +785,7 @@ register int I, *pExtOrder;
|
||||||
|
|
||||||
void
|
void
|
||||||
spMultTransposed(
|
spMultTransposed(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
spREAL RHS[],
|
spREAL RHS[],
|
||||||
spREAL Solution[]
|
spREAL Solution[]
|
||||||
#if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
#if spCOMPLEX AND spSEPARATED_COMPLEX_VECTORS
|
||||||
|
|
@ -801,7 +798,6 @@ register ElementPtr pElement;
|
||||||
register RealVector Vector;
|
register RealVector Vector;
|
||||||
register RealNumber Sum;
|
register RealNumber Sum;
|
||||||
register int I, *pExtOrder;
|
register int I, *pExtOrder;
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
extern void ComplexTransposedMatrixMultiply();
|
extern void ComplexTransposedMatrixMultiply();
|
||||||
|
|
||||||
/* Begin `spMultTransposed'. */
|
/* Begin `spMultTransposed'. */
|
||||||
|
|
@ -973,7 +969,7 @@ register int I, *pExtOrder;
|
||||||
* point number. For this reason the determinant is scaled to a
|
* point number. For this reason the determinant is scaled to a
|
||||||
* reasonable value and the logarithm of the scale factor is returned.
|
* reasonable value and the logarithm of the scale factor is returned.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* A pointer to the matrix for which the determinant is desired.
|
* A pointer to the matrix for which the determinant is desired.
|
||||||
* \param pExponent
|
* \param pExponent
|
||||||
* The logarithm base 10 of the scale factor for the determinant. To find
|
* The logarithm base 10 of the scale factor for the determinant. To find
|
||||||
|
|
@ -998,7 +994,7 @@ register int I, *pExtOrder;
|
||||||
|
|
||||||
void
|
void
|
||||||
spDeterminant(
|
spDeterminant(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int *pExponent,
|
int *pExponent,
|
||||||
spREAL *pDeterminant
|
spREAL *pDeterminant
|
||||||
#if spCOMPLEX
|
#if spCOMPLEX
|
||||||
|
|
@ -1006,7 +1002,6 @@ spDeterminant(
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
register MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int I, Size;
|
register int I, Size;
|
||||||
RealNumber Norm, nr, ni;
|
RealNumber Norm, nr, ni;
|
||||||
ComplexNumber Pivot, cDeterminant;
|
ComplexNumber Pivot, cDeterminant;
|
||||||
|
|
@ -1133,7 +1128,7 @@ ComplexNumber Pivot, cDeterminant;
|
||||||
/*!
|
/*!
|
||||||
* Strips the matrix of all fill-ins.
|
* Strips the matrix of all fill-ins.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix to be stripped.
|
* Pointer to the matrix to be stripped.
|
||||||
*/
|
*/
|
||||||
/* >>> Local variables:
|
/* >>> Local variables:
|
||||||
|
|
@ -1151,9 +1146,8 @@ ComplexNumber Pivot, cDeterminant;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
spStripFills( spMatrix eMatrix )
|
spStripFills( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
struct FillinListNodeStruct *pListNode;
|
struct FillinListNodeStruct *pListNode;
|
||||||
|
|
||||||
/* Begin `spStripFills'. */
|
/* Begin `spStripFills'. */
|
||||||
|
|
@ -1225,7 +1219,7 @@ struct FillinListNodeStruct *pListNode;
|
||||||
* Sparse will abort if an attempt is made to delete a row or column that
|
* Sparse will abort if an attempt is made to delete a row or column that
|
||||||
* doesn't exist.
|
* doesn't exist.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix in which the row and column are to be deleted.
|
* Pointer to the matrix in which the row and column are to be deleted.
|
||||||
* \param Row
|
* \param Row
|
||||||
* Row to be deleted.
|
* Row to be deleted.
|
||||||
|
|
@ -1252,12 +1246,11 @@ struct FillinListNodeStruct *pListNode;
|
||||||
|
|
||||||
void
|
void
|
||||||
spDeleteRowAndCol(
|
spDeleteRowAndCol(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
int Row,
|
int Row,
|
||||||
int Col
|
int Col
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement, *ppElement, pLastElement;
|
register ElementPtr pElement, *ppElement, pLastElement;
|
||||||
int Size, ExtRow, ExtCol;
|
int Size, ExtRow, ExtCol;
|
||||||
|
|
||||||
|
|
@ -1358,14 +1351,13 @@ int Size, ExtRow, ExtCol;
|
||||||
* The magnitude of the ratio of the largest to smallest pivot used during
|
* The magnitude of the ratio of the largest to smallest pivot used during
|
||||||
* previous factorization. If the matrix was singular, zero is returned.
|
* previous factorization. If the matrix was singular, zero is returned.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix.
|
* Pointer to the matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spREAL
|
spREAL
|
||||||
spPseudoCondition( spMatrix eMatrix )
|
spPseudoCondition( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int I;
|
register int I;
|
||||||
register ArrayOfElementPtrs Diag;
|
register ArrayOfElementPtrs Diag;
|
||||||
RealNumber MaxPivot, MinPivot, Mag;
|
RealNumber MaxPivot, MinPivot, Mag;
|
||||||
|
|
@ -1437,7 +1429,7 @@ spPseudoCondition( spMatrix eMatrix )
|
||||||
* The reciprocal of the condition number. If the matrix was singular,
|
* The reciprocal of the condition number. If the matrix was singular,
|
||||||
* zero is returned.
|
* zero is returned.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix.
|
* Pointer to the matrix.
|
||||||
* \param NormOfMatrix
|
* \param NormOfMatrix
|
||||||
* The L-infinity norm of the unfactored matrix as computed by
|
* The L-infinity norm of the unfactored matrix as computed by
|
||||||
|
|
@ -1449,12 +1441,11 @@ spPseudoCondition( spMatrix eMatrix )
|
||||||
|
|
||||||
spREAL
|
spREAL
|
||||||
spCondition(
|
spCondition(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
spREAL NormOfMatrix,
|
spREAL NormOfMatrix,
|
||||||
int *pError
|
int *pError
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register RealVector T, Tm;
|
register RealVector T, Tm;
|
||||||
register int I, K, Row;
|
register int I, K, Row;
|
||||||
|
|
@ -1844,14 +1835,13 @@ ComplexNumber Wp, Wm;
|
||||||
* \return
|
* \return
|
||||||
* The largest absolute row sum of matrix.
|
* The largest absolute row sum of matrix.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix.
|
* Pointer to the matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spREAL
|
spREAL
|
||||||
spNorm( spMatrix eMatrix )
|
spNorm( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register int I;
|
register int I;
|
||||||
RealNumber Max = 0.0, AbsRowSum;
|
RealNumber Max = 0.0, AbsRowSum;
|
||||||
|
|
@ -1959,14 +1949,13 @@ RealNumber Max = 0.0, AbsRowSum;
|
||||||
* the matrix. If the matrix is factored, a bound on the magnitude of the
|
* the matrix. If the matrix is factored, a bound on the magnitude of the
|
||||||
* largest element in any of the reduced submatrices is returned.
|
* largest element in any of the reduced submatrices is returned.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix.
|
* Pointer to the matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
spREAL
|
spREAL
|
||||||
spLargestElement( spMatrix eMatrix )
|
spLargestElement( MatrixPtr Matrix )
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register int I;
|
register int I;
|
||||||
RealNumber Mag, AbsColSum, Max = 0.0, MaxRow = 0.0, MaxCol = 0.0;
|
RealNumber Mag, AbsColSum, Max = 0.0, MaxRow = 0.0, MaxCol = 0.0;
|
||||||
RealNumber Pivot;
|
RealNumber Pivot;
|
||||||
|
|
@ -2073,7 +2062,7 @@ register ElementPtr pElement, pDiag;
|
||||||
* Returns a bound on the magnitude of the largest element in
|
* Returns a bound on the magnitude of the largest element in
|
||||||
* \f$ E = A - LU \f$.
|
* \f$ E = A - LU \f$.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Pointer to the matrix.
|
* Pointer to the matrix.
|
||||||
* \param Rho
|
* \param Rho
|
||||||
* The bound on the magnitude of the largest element in any of the
|
* The bound on the magnitude of the largest element in any of the
|
||||||
|
|
@ -2084,11 +2073,10 @@ register ElementPtr pElement, pDiag;
|
||||||
|
|
||||||
spREAL
|
spREAL
|
||||||
spRoundoff(
|
spRoundoff(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
spREAL Rho
|
spREAL Rho
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
register ElementPtr pElement;
|
register ElementPtr pElement;
|
||||||
register int Count, I, MaxCount = 0;
|
register int Count, I, MaxCount = 0;
|
||||||
RealNumber Reid, Gear;
|
RealNumber Reid, Gear;
|
||||||
|
|
@ -2099,7 +2087,7 @@ RealNumber Reid, Gear;
|
||||||
ASSERT_IS_FACTORED( Matrix );
|
ASSERT_IS_FACTORED( Matrix );
|
||||||
|
|
||||||
/* Compute Barlow's bound if it is not given. */
|
/* Compute Barlow's bound if it is not given. */
|
||||||
if (Rho < 0.0) Rho = spLargestElement( eMatrix );
|
if (Rho < 0.0) Rho = spLargestElement( Matrix );
|
||||||
|
|
||||||
/* Find the maximum number of off-diagonals in L if not previously computed. */
|
/* Find the maximum number of off-diagonals in L if not previously computed. */
|
||||||
if (Matrix->MaxRowCountInLowerTri < 0)
|
if (Matrix->MaxRowCountInLowerTri < 0)
|
||||||
|
|
@ -2139,7 +2127,7 @@ RealNumber Reid, Gear;
|
||||||
* of sparse. No message is produced if there is no error.
|
* of sparse. No message is produced if there is no error.
|
||||||
* The error state is cleared.
|
* The error state is cleared.
|
||||||
*
|
*
|
||||||
* \param eMatrix
|
* \param Matrix
|
||||||
* Matrix for which the error message is to be printed.
|
* Matrix for which the error message is to be printed.
|
||||||
* \param Stream
|
* \param Stream
|
||||||
* Stream to which the error message is to be printed.
|
* Stream to which the error message is to be printed.
|
||||||
|
|
@ -2150,7 +2138,7 @@ RealNumber Reid, Gear;
|
||||||
|
|
||||||
void
|
void
|
||||||
spErrorMessage(
|
spErrorMessage(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
FILE *Stream,
|
FILE *Stream,
|
||||||
char *Originator
|
char *Originator
|
||||||
)
|
)
|
||||||
|
|
@ -2158,11 +2146,11 @@ spErrorMessage(
|
||||||
int Row, Col, Error;
|
int Row, Col, Error;
|
||||||
|
|
||||||
/* Begin `spErrorMessage'. */
|
/* Begin `spErrorMessage'. */
|
||||||
if (eMatrix == NULL)
|
if (Matrix == NULL)
|
||||||
Error = spNO_MEMORY;
|
Error = spNO_MEMORY;
|
||||||
else
|
else
|
||||||
{ ASSERT_IS_SPARSE( (MatrixPtr)eMatrix );
|
{ ASSERT_IS_SPARSE( (MatrixPtr)Matrix );
|
||||||
Error = ((MatrixPtr)eMatrix)->Error;
|
Error = ((MatrixPtr)Matrix)->Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error == spOKAY) return;
|
if (Error == spOKAY) return;
|
||||||
|
|
@ -2184,12 +2172,12 @@ int Row, Col, Error;
|
||||||
else if (Error == spMANGLED)
|
else if (Error == spMANGLED)
|
||||||
fprintf( Stream, "matrix is mangled.\n");
|
fprintf( Stream, "matrix is mangled.\n");
|
||||||
else if (Error == spSINGULAR)
|
else if (Error == spSINGULAR)
|
||||||
{ spWhereSingular( eMatrix, &Row, &Col );
|
{ spWhereSingular( Matrix, &Row, &Col );
|
||||||
fprintf( Stream, "singular matrix detected at row %d and column %d.\n",
|
fprintf( Stream, "singular matrix detected at row %d and column %d.\n",
|
||||||
Row, Col);
|
Row, Col);
|
||||||
}
|
}
|
||||||
else if (Error == spZERO_DIAG)
|
else if (Error == spZERO_DIAG)
|
||||||
{ spWhereSingular( eMatrix, &Row, &Col );
|
{ spWhereSingular( Matrix, &Row, &Col );
|
||||||
fprintf( Stream, "zero diagonal detected at row %d and column %d.\n",
|
fprintf( Stream, "zero diagonal detected at row %d and column %d.\n",
|
||||||
Row, Col);
|
Row, Col);
|
||||||
}
|
}
|
||||||
|
|
@ -2199,7 +2187,7 @@ int Row, Col, Error;
|
||||||
}
|
}
|
||||||
else ABORT();
|
else ABORT();
|
||||||
|
|
||||||
((MatrixPtr)eMatrix)->Error = spOKAY;
|
((MatrixPtr)Matrix)->Error = spOKAY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif /* DOCUMENTATION */
|
#endif /* DOCUMENTATION */
|
||||||
|
|
|
||||||
|
|
@ -30,13 +30,12 @@
|
||||||
|
|
||||||
void
|
void
|
||||||
spConstMult(
|
spConstMult(
|
||||||
spMatrix eMatrix,
|
MatrixPtr Matrix,
|
||||||
double constant
|
double constant
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ElementPtr pElement;
|
ElementPtr pElement;
|
||||||
int I;
|
int I;
|
||||||
MatrixPtr Matrix = (MatrixPtr)eMatrix;
|
|
||||||
int size = Matrix->Size;
|
int size = Matrix->Size;
|
||||||
|
|
||||||
ASSERT_IS_SPARSE( Matrix );
|
ASSERT_IS_SPARSE( Matrix );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue