use spError as function

This commit is contained in:
dwarning 2023-06-17 10:14:01 +02:00
parent 74e77e909b
commit 3638656ce6
4 changed files with 29 additions and 25 deletions

View File

@ -271,7 +271,7 @@ typedef spGenericPtr spMatrix;
typedef spREAL spElement; typedef spREAL spElement;
/*! Declares the type of the Sparse error codes. */ /*! Declares the type of the Sparse error codes. */
typedef int spError; //typedef int spError;
@ -313,12 +313,12 @@ typedef struct MatrixFrame *MatrixPtr;
spcEXTERN void spClear( MatrixPtr ); spcEXTERN void spClear( MatrixPtr );
spcEXTERN spREAL spCondition( MatrixPtr, spREAL, int* ); spcEXTERN spREAL spCondition( MatrixPtr, spREAL, int* );
spcEXTERN MatrixPtr spCreate( int, int, spError* ); spcEXTERN MatrixPtr spCreate( int, int, int* );
spcEXTERN void spDeleteRowAndCol( MatrixPtr, int, int ); spcEXTERN void spDeleteRowAndCol( MatrixPtr, int, int );
spcEXTERN void spDestroy( MatrixPtr ); spcEXTERN void spDestroy( MatrixPtr );
spcEXTERN int spElementCount( MatrixPtr ); spcEXTERN int spElementCount( MatrixPtr );
spcEXTERN int spOriginalCount( MatrixPtr ); spcEXTERN int spOriginalCount( MatrixPtr );
spcEXTERN spError spErrorState( MatrixPtr ); spcEXTERN int spError( MatrixPtr );
#ifdef EOF #ifdef EOF
spcEXTERN void spErrorMessage( MatrixPtr, FILE*, char* ); spcEXTERN void spErrorMessage( MatrixPtr, FILE*, char* );
#else #else
@ -326,18 +326,18 @@ spcEXTERN spError spErrorState( MatrixPtr );
#endif #endif
spcEXTERN spError spFactor( MatrixPtr ); spcEXTERN int spFactor( MatrixPtr );
spcEXTERN int spFileMatrix( MatrixPtr, char*, char*, int, int, int ); spcEXTERN int spFileMatrix( MatrixPtr, char*, char*, int, int, int );
spcEXTERN int spFileStats( MatrixPtr, char*, char* ); spcEXTERN int spFileStats( MatrixPtr, char*, char* );
spcEXTERN int spFillinCount( MatrixPtr ); spcEXTERN int spFillinCount( MatrixPtr );
spcEXTERN spElement *spFindElement( MatrixPtr, int, int ); spcEXTERN spElement *spFindElement( MatrixPtr, int, int );
spcEXTERN spError spGetAdmittance( MatrixPtr, int, int, spcEXTERN int spGetAdmittance( MatrixPtr, int, int,
struct spTemplate* ); struct spTemplate* );
spcEXTERN spElement *spGetElement( MatrixPtr, int, int ); spcEXTERN spElement *spGetElement( MatrixPtr, int, int );
spcEXTERN spGenericPtr spGetInitInfo( spElement* ); spcEXTERN spGenericPtr spGetInitInfo( spElement* );
spcEXTERN spError spGetOnes( MatrixPtr, int, int, int, spcEXTERN int spGetOnes( MatrixPtr, int, int, int,
struct spTemplate* ); struct spTemplate* );
spcEXTERN spError spGetQuad( MatrixPtr, int, int, int, int, spcEXTERN int spGetQuad( MatrixPtr, int, int, int, int,
struct spTemplate* ); struct spTemplate* );
spcEXTERN int spGetSize( MatrixPtr, int ); spcEXTERN int spGetSize( MatrixPtr, int );
spcEXTERN int spInitialize( MatrixPtr, int (*pInit)(spElement *, spGenericPtr, int, int) ); spcEXTERN int spInitialize( MatrixPtr, int (*pInit)(spElement *, spGenericPtr, int, int) );
@ -345,7 +345,7 @@ spcEXTERN void spInstallInitInfo( spElement*, spGenericPtr );
spcEXTERN spREAL spLargestElement( MatrixPtr ); spcEXTERN spREAL spLargestElement( MatrixPtr );
spcEXTERN void spMNA_Preorder( MatrixPtr ); spcEXTERN void spMNA_Preorder( MatrixPtr );
spcEXTERN spREAL spNorm( MatrixPtr ); spcEXTERN spREAL spNorm( MatrixPtr );
spcEXTERN spError spOrderAndFactor( MatrixPtr, spREAL[], spREAL, spcEXTERN int spOrderAndFactor( MatrixPtr, spREAL[], spREAL,
spREAL, int ); spREAL, int );
spcEXTERN void spPartition( MatrixPtr, int ); spcEXTERN void spPartition( MatrixPtr, int );
spcEXTERN void spPrint( MatrixPtr, int, int, int ); spcEXTERN void spPrint( MatrixPtr, int, int, int );

View File

@ -18,7 +18,7 @@
/* >>> User accessible functions contained in this file: /* >>> User accessible functions contained in this file:
* spCreate * spCreate
* spDestroy * spDestroy
* spErrorState * spError
* spWhereSingular * spWhereSingular
* spGetSize * spGetSize
* spSetReal * spSetReal
@ -92,7 +92,7 @@ char spcMatrixMustNotBeFactored[] = "Matrix must not be factored";
//static spError ReserveElements( MatrixPtr, int ); //static spError ReserveElements( MatrixPtr, int );
static void InitializeElementBlocks( MatrixPtr, int, int ); static void InitializeElementBlocks( MatrixPtr, int, int );
static void RecordAllocation( MatrixPtr, void* ); static void RecordAllocation( MatrixPtr, void * );
static void AllocateBlockOfAllocationList( MatrixPtr ); static void AllocateBlockOfAllocationList( MatrixPtr );
@ -115,7 +115,7 @@ static void AllocateBlockOfAllocationList( MatrixPtr );
* Further note that if a matrix will be both real and complex, it must * Further note that if a matrix will be both real and complex, it must
* be specified here as being complex. * be specified here as being complex.
* \param pError * \param pError
* Returns error flag, needed because function \a spErrorState() will * Returns error flag, needed because function \a spError() will
* not work correctly if \a spCreate() returns \a NULL. Possible errors * not work correctly if \a spCreate() returns \a NULL. Possible errors
* include \a spNO_MEMORY and \a spPANIC. * include \a spNO_MEMORY and \a spPANIC.
*/ */
@ -130,7 +130,7 @@ MatrixPtr
spCreate( spCreate(
int Size, int Size,
int Complex, int Complex,
spError *pError int *pError
) )
{ {
unsigned SizePlusOne; unsigned SizePlusOne;
@ -596,7 +596,7 @@ AllocationListPtr ListPtr;
} }
/* Record allocation of space for allocation list on allocation list. */ /* Record allocation of space for allocation list on allocation list. */
Matrix->TopOfAllocationList->AllocatedPtr = ListPtr; Matrix->TopOfAllocationList->AllocatedPtr = (void *)ListPtr;
Matrix->RecordsRemaining = ELEMENTS_PER_ALLOCATION; Matrix->RecordsRemaining = ELEMENTS_PER_ALLOCATION;
return; return;
@ -654,7 +654,11 @@ AllocationListPtr ListPtr, NextListPtr;
ListPtr = Matrix->TopOfAllocationList; ListPtr = Matrix->TopOfAllocationList;
while (ListPtr != NULL) while (ListPtr != NULL)
{ NextListPtr = ListPtr->NextRecord; { NextListPtr = ListPtr->NextRecord;
SP_FREE( ListPtr->AllocatedPtr ); if ((void *) ListPtr == ListPtr->AllocatedPtr) {
SP_FREE( ListPtr );
} else {
SP_FREE( ListPtr->AllocatedPtr );
}
ListPtr = NextListPtr; ListPtr = NextListPtr;
} }
return; return;
@ -676,10 +680,10 @@ AllocationListPtr ListPtr, NextListPtr;
* 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 int
spErrorState( MatrixPtr Matrix ) spError( MatrixPtr Matrix )
{ {
/* Begin `spErrorState'. */ /* Begin `spError'. */
if (Matrix != NULL) if (Matrix != NULL)
{ ASSERT_IS_SPARSE( Matrix ); { ASSERT_IS_SPARSE( Matrix );

View File

@ -196,7 +196,7 @@ static void WriteStatus( MatrixPtr, int );
* *
*/ */
spError int
spOrderAndFactor( spOrderAndFactor(
MatrixPtr Matrix, MatrixPtr Matrix,
spREAL RHS[], spREAL RHS[],
@ -338,7 +338,7 @@ Done:
* \see spOrderAndFactor() * \see spOrderAndFactor()
*/ */
spError int
spFactor( MatrixPtr Matrix ) spFactor( MatrixPtr Matrix )
{ {
#if REAL #if REAL

View File

@ -122,7 +122,7 @@ int Row, int Col,
double Value) double Value)
{ {
*spGetElement( Matrix, Row, Col ) = Value; *spGetElement( Matrix, Row, Col ) = Value;
return spErrorState( Matrix ); return spError( Matrix );
} }
/* /*
@ -311,7 +311,7 @@ SMPpreOrder(
SMPmatrix *Matrix) SMPmatrix *Matrix)
{ {
spMNA_Preorder( Matrix ); spMNA_Preorder( Matrix );
return spErrorState( Matrix ); return spError( Matrix );
} }
/* /*
@ -368,7 +368,7 @@ int *pExponent)
#else #else
spDeterminant( Matrix, pExponent, &(pMantissa->real) ); spDeterminant( Matrix, pExponent, &(pMantissa->real) );
#endif #endif
return spErrorState( Matrix ); return spError( Matrix );
} }
/* /*
@ -454,7 +454,7 @@ SMPcDProd(SMPmatrix *Matrix, SPcomplex *pMantissa, int *pExponent)
printf("Determinant 10->2: (%20g,%20g)^%d\n", pMantissa->real, printf("Determinant 10->2: (%20g,%20g)^%d\n", pMantissa->real,
pMantissa->imag, *pExponent); pMantissa->imag, *pExponent);
#endif #endif
return spErrorState( Matrix ); return spError( Matrix );
} }
@ -542,7 +542,7 @@ SMPcZeroCol(SMPmatrix *Matrix, int Col)
#endif #endif
} }
return spErrorState( Matrix ); return spError( Matrix );
} }
/* /*
@ -575,7 +575,7 @@ SMPcAddCol(SMPmatrix *Matrix, int Accum_Col, int Addend_Col)
Addend = Addend->NextInCol; Addend = Addend->NextInCol;
} }
return spErrorState( Matrix ); return spError( Matrix );
} }
/* /*