|
|
|
@ -149,7 +149,7 @@ spCreate(int Size, int Complex, int *pError) |
|
|
|
AllocatedSize = MAX( Size, MINIMUM_ALLOCATED_SIZE ); |
|
|
|
SizePlusOne = (unsigned)(AllocatedSize + 1); |
|
|
|
|
|
|
|
if ((Matrix = ALLOC(struct MatrixFrame, 1)) == NULL) { |
|
|
|
if ((Matrix = SP_MALLOC(struct MatrixFrame, 1)) == NULL) { |
|
|
|
*pError = spNO_MEMORY; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
@ -209,26 +209,26 @@ spCreate(int Size, int Complex, int *pError) |
|
|
|
#endif |
|
|
|
|
|
|
|
/* Allocate space in memory for Diag pointer vector. */ |
|
|
|
CALLOC( Matrix->Diag, ElementPtr, SizePlusOne); |
|
|
|
SP_CALLOC( Matrix->Diag, ElementPtr, SizePlusOne); |
|
|
|
if (Matrix->Diag == NULL) |
|
|
|
goto MemoryError; |
|
|
|
|
|
|
|
/* Allocate space in memory for FirstInCol pointer vector. */ |
|
|
|
CALLOC( Matrix->FirstInCol, ElementPtr, SizePlusOne); |
|
|
|
SP_CALLOC( Matrix->FirstInCol, ElementPtr, SizePlusOne); |
|
|
|
if (Matrix->FirstInCol == NULL) |
|
|
|
goto MemoryError; |
|
|
|
|
|
|
|
/* Allocate space in memory for FirstInRow pointer vector. */ |
|
|
|
CALLOC( Matrix->FirstInRow, ElementPtr, SizePlusOne); |
|
|
|
SP_CALLOC( Matrix->FirstInRow, ElementPtr, SizePlusOne); |
|
|
|
if (Matrix->FirstInRow == NULL) |
|
|
|
goto MemoryError; |
|
|
|
|
|
|
|
/* Allocate space in memory for IntToExtColMap vector. */ |
|
|
|
if (( Matrix->IntToExtColMap = ALLOC(int, SizePlusOne)) == NULL) |
|
|
|
if (( Matrix->IntToExtColMap = SP_MALLOC(int, SizePlusOne)) == NULL) |
|
|
|
goto MemoryError; |
|
|
|
|
|
|
|
/* Allocate space in memory for IntToExtRowMap vector. */ |
|
|
|
if (( Matrix->IntToExtRowMap = ALLOC(int, SizePlusOne)) == NULL) |
|
|
|
if (( Matrix->IntToExtRowMap = SP_MALLOC(int, SizePlusOne)) == NULL) |
|
|
|
goto MemoryError; |
|
|
|
|
|
|
|
/* Initialize MapIntToExt vectors. */ |
|
|
|
@ -240,11 +240,11 @@ spCreate(int Size, int Complex, int *pError) |
|
|
|
|
|
|
|
#if TRANSLATE |
|
|
|
/* Allocate space in memory for ExtToIntColMap vector. */ |
|
|
|
if (( Matrix->ExtToIntColMap = ALLOC(int, SizePlusOne)) == NULL) |
|
|
|
if (( Matrix->ExtToIntColMap = SP_MALLOC(int, SizePlusOne)) == NULL) |
|
|
|
goto MemoryError; |
|
|
|
|
|
|
|
/* Allocate space in memory for ExtToIntRowMap vector. */ |
|
|
|
if (( Matrix->ExtToIntRowMap = ALLOC(int, SizePlusOne)) == NULL) |
|
|
|
if (( Matrix->ExtToIntRowMap = SP_MALLOC(int, SizePlusOne)) == NULL) |
|
|
|
goto MemoryError; |
|
|
|
|
|
|
|
/* Initialize MapExtToInt vectors. */ |
|
|
|
@ -314,7 +314,7 @@ spcGetElement(MatrixPtr Matrix) |
|
|
|
#if !COMBINE || STRIP || LINT |
|
|
|
/* Allocate block of MatrixElements if necessary. */ |
|
|
|
if (Matrix->ElementsRemaining == 0) { |
|
|
|
pElements = ALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION); |
|
|
|
pElements = SP_MALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION); |
|
|
|
RecordAllocation( Matrix, (void *)pElements ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) return NULL; |
|
|
|
Matrix->ElementsRemaining = ELEMENTS_PER_ALLOCATION; |
|
|
|
@ -334,14 +334,14 @@ spcGetElement(MatrixPtr Matrix) |
|
|
|
Matrix->NextAvailElement = pListNode->pElementList; |
|
|
|
} else { |
|
|
|
/* Allocate block of elements. */ |
|
|
|
pElements = ALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION); |
|
|
|
pElements = SP_MALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION); |
|
|
|
RecordAllocation( Matrix, (void *)pElements ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) return NULL; |
|
|
|
Matrix->ElementsRemaining = ELEMENTS_PER_ALLOCATION; |
|
|
|
Matrix->NextAvailElement = pElements; |
|
|
|
|
|
|
|
/* Allocate an element list structure. */ |
|
|
|
pListNode->Next = ALLOC(struct ElementListNodeStruct,1); |
|
|
|
pListNode->Next = SP_MALLOC(struct ElementListNodeStruct,1); |
|
|
|
RecordAllocation( Matrix, (void *)pListNode->Next ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) |
|
|
|
return NULL; |
|
|
|
@ -405,14 +405,14 @@ InitializeElementBlocks(MatrixPtr Matrix, int InitialNumberOfElements, |
|
|
|
/* Begin `InitializeElementBlocks'. */ |
|
|
|
|
|
|
|
/* Allocate block of MatrixElements for elements. */ |
|
|
|
pElement = ALLOC(struct MatrixElement, InitialNumberOfElements); |
|
|
|
pElement = SP_MALLOC(struct MatrixElement, InitialNumberOfElements); |
|
|
|
RecordAllocation( Matrix, (void *)pElement ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) return; |
|
|
|
Matrix->ElementsRemaining = InitialNumberOfElements; |
|
|
|
Matrix->NextAvailElement = pElement; |
|
|
|
|
|
|
|
/* Allocate an element list structure. */ |
|
|
|
Matrix->FirstElementListNode = ALLOC(struct ElementListNodeStruct,1); |
|
|
|
Matrix->FirstElementListNode = SP_MALLOC(struct ElementListNodeStruct,1); |
|
|
|
RecordAllocation( Matrix, (void *)Matrix->FirstElementListNode ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) return; |
|
|
|
Matrix->LastElementListNode = Matrix->FirstElementListNode; |
|
|
|
@ -423,14 +423,14 @@ InitializeElementBlocks(MatrixPtr Matrix, int InitialNumberOfElements, |
|
|
|
Matrix->FirstElementListNode->Next = NULL; |
|
|
|
|
|
|
|
/* Allocate block of MatrixElements for fill-ins. */ |
|
|
|
pElement = ALLOC(struct MatrixElement, NumberOfFillinsExpected); |
|
|
|
pElement = SP_MALLOC(struct MatrixElement, NumberOfFillinsExpected); |
|
|
|
RecordAllocation( Matrix, (void *)pElement ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) return; |
|
|
|
Matrix->FillinsRemaining = NumberOfFillinsExpected; |
|
|
|
Matrix->NextAvailFillin = pElement; |
|
|
|
|
|
|
|
/* Allocate a fill-in list structure. */ |
|
|
|
Matrix->FirstFillinListNode = ALLOC(struct FillinListNodeStruct,1); |
|
|
|
Matrix->FirstFillinListNode = SP_MALLOC(struct FillinListNodeStruct,1); |
|
|
|
RecordAllocation( Matrix, (void *)Matrix->FirstFillinListNode ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) return; |
|
|
|
Matrix->LastFillinListNode = Matrix->FirstFillinListNode; |
|
|
|
@ -490,14 +490,14 @@ spcGetFillin(MatrixPtr Matrix) |
|
|
|
Matrix->NextAvailFillin = pListNode->pFillinList; |
|
|
|
} else { |
|
|
|
/* Allocate block of fill-ins. */ |
|
|
|
pFillins = ALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION); |
|
|
|
pFillins = SP_MALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION); |
|
|
|
RecordAllocation( Matrix, (void *)pFillins ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) return NULL; |
|
|
|
Matrix->FillinsRemaining = ELEMENTS_PER_ALLOCATION; |
|
|
|
Matrix->NextAvailFillin = pFillins; |
|
|
|
|
|
|
|
/* Allocate a fill-in list structure. */ |
|
|
|
pListNode->Next = ALLOC(struct FillinListNodeStruct,1); |
|
|
|
pListNode->Next = SP_MALLOC(struct FillinListNodeStruct,1); |
|
|
|
RecordAllocation( Matrix, (void *)pListNode->Next ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) return NULL; |
|
|
|
Matrix->LastFillinListNode = pListNode = pListNode->Next; |
|
|
|
@ -553,7 +553,7 @@ RecordAllocation(MatrixPtr Matrix, void *AllocatedPtr ) |
|
|
|
if (Matrix->RecordsRemaining == 0) { |
|
|
|
AllocateBlockOfAllocationList( Matrix ); |
|
|
|
if (Matrix->Error == spNO_MEMORY) { |
|
|
|
FREE(AllocatedPtr); |
|
|
|
SP_FREE(AllocatedPtr); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -597,7 +597,7 @@ AllocateBlockOfAllocationList(MatrixPtr Matrix) |
|
|
|
|
|
|
|
/* Begin `AllocateBlockOfAllocationList'. */ |
|
|
|
/* Allocate block of records for allocation list. */ |
|
|
|
ListPtr = ALLOC(struct AllocationRecord, (ELEMENTS_PER_ALLOCATION+1)); |
|
|
|
ListPtr = SP_MALLOC(struct AllocationRecord, (ELEMENTS_PER_ALLOCATION+1)); |
|
|
|
if (ListPtr == NULL) { |
|
|
|
Matrix->Error = spNO_MEMORY; |
|
|
|
return; |
|
|
|
@ -660,19 +660,19 @@ spDestroy(MatrixPtr eMatrix) |
|
|
|
assert( IS_SPARSE( Matrix ) ); |
|
|
|
|
|
|
|
/* Deallocate the vectors that are located in the matrix frame. */ |
|
|
|
FREE( Matrix->IntToExtColMap ); |
|
|
|
FREE( Matrix->IntToExtRowMap ); |
|
|
|
FREE( Matrix->ExtToIntColMap ); |
|
|
|
FREE( Matrix->ExtToIntRowMap ); |
|
|
|
FREE( Matrix->Diag ); |
|
|
|
FREE( Matrix->FirstInRow ); |
|
|
|
FREE( Matrix->FirstInCol ); |
|
|
|
FREE( Matrix->MarkowitzRow ); |
|
|
|
FREE( Matrix->MarkowitzCol ); |
|
|
|
FREE( Matrix->MarkowitzProd ); |
|
|
|
FREE( Matrix->DoCmplxDirect ); |
|
|
|
FREE( Matrix->DoRealDirect ); |
|
|
|
FREE( Matrix->Intermediate ); |
|
|
|
SP_FREE( Matrix->IntToExtColMap ); |
|
|
|
SP_FREE( Matrix->IntToExtRowMap ); |
|
|
|
SP_FREE( Matrix->ExtToIntColMap ); |
|
|
|
SP_FREE( Matrix->ExtToIntRowMap ); |
|
|
|
SP_FREE( Matrix->Diag ); |
|
|
|
SP_FREE( Matrix->FirstInRow ); |
|
|
|
SP_FREE( Matrix->FirstInCol ); |
|
|
|
SP_FREE( Matrix->MarkowitzRow ); |
|
|
|
SP_FREE( Matrix->MarkowitzCol ); |
|
|
|
SP_FREE( Matrix->MarkowitzProd ); |
|
|
|
SP_FREE( Matrix->DoCmplxDirect ); |
|
|
|
SP_FREE( Matrix->DoRealDirect ); |
|
|
|
SP_FREE( Matrix->Intermediate ); |
|
|
|
|
|
|
|
/* Sequentially step through the list of allocated pointers |
|
|
|
* freeing pointers along the way. */ |
|
|
|
@ -680,9 +680,9 @@ spDestroy(MatrixPtr eMatrix) |
|
|
|
while (ListPtr != NULL) { |
|
|
|
NextListPtr = ListPtr->NextRecord; |
|
|
|
if ((void *) ListPtr == ListPtr->AllocatedPtr) { |
|
|
|
FREE( ListPtr ); |
|
|
|
SP_FREE( ListPtr ); |
|
|
|
} else { |
|
|
|
FREE( ListPtr->AllocatedPtr ); |
|
|
|
SP_FREE( ListPtr->AllocatedPtr ); |
|
|
|
} |
|
|
|
ListPtr = NextListPtr; |
|
|
|
} |
|
|
|
|