50 static char copyright[] =
51 "Sparse1.3: Copyright (c) 1985,86,87,88,89,90 by Kenneth S. Kundert";
53 "@(#)$Header: spAllocate.c,v 1.3 88/06/24 05:00:11 kundert Exp $";
70 #define spINSIDE_SPARSE 138 register unsigned SizePlusOne;
148 if ((Size < 0)
OR (Size == 0
AND NOT EXPANDABLE))
168 AllocatedSize =
MAX( Size, MINIMUM_ALLOCATED_SIZE );
169 SizePlusOne = (unsigned)(AllocatedSize + 1);
182 Matrix->
Error = *pError;
255 for (I = 1; I <= AllocatedSize; I++)
270 for (I = 1; I <= AllocatedSize; I++)
280 SPACE_FOR_FILL_INS*AllocatedSize );
284 return (
char *)Matrix;
336 if (Matrix->ElementsRemaining == 0)
340 Matrix->ElementsRemaining = ELEMENTS_PER_ALLOCATION;
341 Matrix->NextAvailElement =
pElement;
345 Matrix->ElementsRemaining--;
346 return Matrix->NextAvailElement++;
389 NumberOfFillinsExpected )
392 int InitialNumberOfElements, NumberOfFillinsExpected;
402 Matrix->ElementsRemaining = InitialNumberOfElements;
403 Matrix->NextAvailElement =
pElement;
409 Matrix->FillinsRemaining = NumberOfFillinsExpected;
416 Matrix->LastFillinListNode = Matrix->FirstFillinListNode;
418 Matrix->FirstFillinListNode->pFillinList =
pElement;
419 Matrix->FirstFillinListNode->NumberOfFillinsInList =NumberOfFillinsExpected;
420 Matrix->FirstFillinListNode->Next =
NULL;
463 #if NOT STRIP OR LINT 464 if (Matrix->FillinsRemaining == 0)
469 if (Matrix->FillinsRemaining == 0)
470 { pListNode = Matrix->LastFillinListNode;
474 { Matrix->LastFillinListNode = pListNode = pListNode->
Next;
484 Matrix->FillinsRemaining = ELEMENTS_PER_ALLOCATION;
485 Matrix->NextAvailFillin = pFillins;
491 Matrix->LastFillinListNode = pListNode = pListNode->
Next;
501 Matrix->FillinsRemaining--;
502 return Matrix->NextAvailFillin++;
541 if (AllocatedPtr ==
NULL)
547 if (Matrix->RecordsRemaining == 0)
550 {
FREE(AllocatedPtr);
556 (++Matrix->TopOfAllocationList)->AllocatedPtr = AllocatedPtr;
557 Matrix->RecordsRemaining--;
606 ListPtr->
NextRecord = Matrix->TopOfAllocationList;
607 Matrix->TopOfAllocationList = ListPtr;
608 ListPtr += ELEMENTS_PER_ALLOCATION;
609 for (I = ELEMENTS_PER_ALLOCATION; I > 0; I--)
615 Matrix->TopOfAllocationList->
AllocatedPtr = (
char *)ListPtr;
616 Matrix->RecordsRemaining = ELEMENTS_PER_ALLOCATION;
651 register
char *eMatrix;
678 while (ListPtr !=
NULL)
688 ListPtr = NextListPtr;
765 else *pRow = *pCol = 0;
static void InitializeElementBlocks()
#define ALLOC(type, number)
void spDestroy(char *eMatrix)
ArrayOfElementPtrs FirstInRow
void spSetReal(char *eMatrix)
int NumberOfFillinsInList
void spSetComplex(char *eMatrix)
int spElementCount(char *eMatrix)
int spGetSize(char *eMatrix, BOOLEAN External)
int spError(char *eMatrix)
#define IS_SPARSE(matrix)
int spFillinCount(char *eMatrix)
BOOLEAN PreviousMatrixWasComplex
BOOLEAN NumberOfInterchangesIsOdd
ElementPtr spcGetFillin(MatrixPtr Matrix)
struct MatrixElement * NextInCol
ASSERT(IS_VALID(Matrix) AND IS_FACTORED(Matrix))
#define CALLOC(ptr, type, number)
register ElementPtr pElement
ElementPtr spcGetElement(MatrixPtr Matrix)
struct AllocationRecord * NextRecord
struct MatrixElement TrashCan
BOOLEAN InternalVectorsAllocated
static void RecordAllocation()
struct MatrixElement * NextInRow
struct MatrixFrame * MatrixPtr
struct FillinListNodeStruct * Next
void spWhereSingular(char *eMatrix, int *pRow, int *pCol)
static void AllocateBlockOfAllocationList()
char * spCreate(int Size, BOOLEAN Complex, int *pError)
ArrayOfElementPtrs FirstInCol
AllocationListPtr TopOfAllocationList