rename ALLOC, REALLOC, CALLOC, FREE, in the "src/maths/sparse" domain
This commit is contained in:
parent
46aeab65a8
commit
3cc50320e3
10
ChangeLog
10
ChangeLog
|
|
@ -1,3 +1,13 @@
|
||||||
|
2010-10-24 Robert Larice
|
||||||
|
* src/maths/sparse/spalloc.c ,
|
||||||
|
* src/maths/sparse/spbuild.c ,
|
||||||
|
* src/maths/sparse/spdefs.h ,
|
||||||
|
* src/maths/sparse/spfactor.c ,
|
||||||
|
* src/maths/sparse/spoutput.c ,
|
||||||
|
* src/maths/sparse/sputils.c :
|
||||||
|
rename ALLOC, REALLOC, CALLOC, FREE, in the "src/maths/sparse" domain
|
||||||
|
-> SP_MALLOC, SP_REALLOC, SP_CALLOC, SP_FREE
|
||||||
|
|
||||||
2010-10-24 Robert Larice
|
2010-10-24 Robert Larice
|
||||||
* src/include/complex.h :
|
* src/include/complex.h :
|
||||||
ngcomplex_t instead of complex, #2/2
|
ngcomplex_t instead of complex, #2/2
|
||||||
|
|
|
||||||
|
|
@ -149,7 +149,7 @@ spCreate(int Size, int Complex, int *pError)
|
||||||
AllocatedSize = MAX( Size, MINIMUM_ALLOCATED_SIZE );
|
AllocatedSize = MAX( Size, MINIMUM_ALLOCATED_SIZE );
|
||||||
SizePlusOne = (unsigned)(AllocatedSize + 1);
|
SizePlusOne = (unsigned)(AllocatedSize + 1);
|
||||||
|
|
||||||
if ((Matrix = ALLOC(struct MatrixFrame, 1)) == NULL) {
|
if ((Matrix = SP_MALLOC(struct MatrixFrame, 1)) == NULL) {
|
||||||
*pError = spNO_MEMORY;
|
*pError = spNO_MEMORY;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
@ -209,26 +209,26 @@ spCreate(int Size, int Complex, int *pError)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Allocate space in memory for Diag pointer vector. */
|
/* Allocate space in memory for Diag pointer vector. */
|
||||||
CALLOC( Matrix->Diag, ElementPtr, SizePlusOne);
|
SP_CALLOC( Matrix->Diag, ElementPtr, SizePlusOne);
|
||||||
if (Matrix->Diag == NULL)
|
if (Matrix->Diag == NULL)
|
||||||
goto MemoryError;
|
goto MemoryError;
|
||||||
|
|
||||||
/* Allocate space in memory for FirstInCol pointer vector. */
|
/* Allocate space in memory for FirstInCol pointer vector. */
|
||||||
CALLOC( Matrix->FirstInCol, ElementPtr, SizePlusOne);
|
SP_CALLOC( Matrix->FirstInCol, ElementPtr, SizePlusOne);
|
||||||
if (Matrix->FirstInCol == NULL)
|
if (Matrix->FirstInCol == NULL)
|
||||||
goto MemoryError;
|
goto MemoryError;
|
||||||
|
|
||||||
/* Allocate space in memory for FirstInRow pointer vector. */
|
/* Allocate space in memory for FirstInRow pointer vector. */
|
||||||
CALLOC( Matrix->FirstInRow, ElementPtr, SizePlusOne);
|
SP_CALLOC( Matrix->FirstInRow, ElementPtr, SizePlusOne);
|
||||||
if (Matrix->FirstInRow == NULL)
|
if (Matrix->FirstInRow == NULL)
|
||||||
goto MemoryError;
|
goto MemoryError;
|
||||||
|
|
||||||
/* Allocate space in memory for IntToExtColMap vector. */
|
/* Allocate space in memory for IntToExtColMap vector. */
|
||||||
if (( Matrix->IntToExtColMap = ALLOC(int, SizePlusOne)) == NULL)
|
if (( Matrix->IntToExtColMap = SP_MALLOC(int, SizePlusOne)) == NULL)
|
||||||
goto MemoryError;
|
goto MemoryError;
|
||||||
|
|
||||||
/* Allocate space in memory for IntToExtRowMap vector. */
|
/* Allocate space in memory for IntToExtRowMap vector. */
|
||||||
if (( Matrix->IntToExtRowMap = ALLOC(int, SizePlusOne)) == NULL)
|
if (( Matrix->IntToExtRowMap = SP_MALLOC(int, SizePlusOne)) == NULL)
|
||||||
goto MemoryError;
|
goto MemoryError;
|
||||||
|
|
||||||
/* Initialize MapIntToExt vectors. */
|
/* Initialize MapIntToExt vectors. */
|
||||||
|
|
@ -240,11 +240,11 @@ spCreate(int Size, int Complex, int *pError)
|
||||||
|
|
||||||
#if TRANSLATE
|
#if TRANSLATE
|
||||||
/* Allocate space in memory for ExtToIntColMap vector. */
|
/* Allocate space in memory for ExtToIntColMap vector. */
|
||||||
if (( Matrix->ExtToIntColMap = ALLOC(int, SizePlusOne)) == NULL)
|
if (( Matrix->ExtToIntColMap = SP_MALLOC(int, SizePlusOne)) == NULL)
|
||||||
goto MemoryError;
|
goto MemoryError;
|
||||||
|
|
||||||
/* Allocate space in memory for ExtToIntRowMap vector. */
|
/* Allocate space in memory for ExtToIntRowMap vector. */
|
||||||
if (( Matrix->ExtToIntRowMap = ALLOC(int, SizePlusOne)) == NULL)
|
if (( Matrix->ExtToIntRowMap = SP_MALLOC(int, SizePlusOne)) == NULL)
|
||||||
goto MemoryError;
|
goto MemoryError;
|
||||||
|
|
||||||
/* Initialize MapExtToInt vectors. */
|
/* Initialize MapExtToInt vectors. */
|
||||||
|
|
@ -314,7 +314,7 @@ spcGetElement(MatrixPtr Matrix)
|
||||||
#if !COMBINE || STRIP || LINT
|
#if !COMBINE || STRIP || LINT
|
||||||
/* Allocate block of MatrixElements if necessary. */
|
/* Allocate block of MatrixElements if necessary. */
|
||||||
if (Matrix->ElementsRemaining == 0) {
|
if (Matrix->ElementsRemaining == 0) {
|
||||||
pElements = ALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION);
|
pElements = SP_MALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION);
|
||||||
RecordAllocation( Matrix, (void *)pElements );
|
RecordAllocation( Matrix, (void *)pElements );
|
||||||
if (Matrix->Error == spNO_MEMORY) return NULL;
|
if (Matrix->Error == spNO_MEMORY) return NULL;
|
||||||
Matrix->ElementsRemaining = ELEMENTS_PER_ALLOCATION;
|
Matrix->ElementsRemaining = ELEMENTS_PER_ALLOCATION;
|
||||||
|
|
@ -334,14 +334,14 @@ spcGetElement(MatrixPtr Matrix)
|
||||||
Matrix->NextAvailElement = pListNode->pElementList;
|
Matrix->NextAvailElement = pListNode->pElementList;
|
||||||
} else {
|
} else {
|
||||||
/* Allocate block of elements. */
|
/* Allocate block of elements. */
|
||||||
pElements = ALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION);
|
pElements = SP_MALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION);
|
||||||
RecordAllocation( Matrix, (void *)pElements );
|
RecordAllocation( Matrix, (void *)pElements );
|
||||||
if (Matrix->Error == spNO_MEMORY) return NULL;
|
if (Matrix->Error == spNO_MEMORY) return NULL;
|
||||||
Matrix->ElementsRemaining = ELEMENTS_PER_ALLOCATION;
|
Matrix->ElementsRemaining = ELEMENTS_PER_ALLOCATION;
|
||||||
Matrix->NextAvailElement = pElements;
|
Matrix->NextAvailElement = pElements;
|
||||||
|
|
||||||
/* Allocate an element list structure. */
|
/* Allocate an element list structure. */
|
||||||
pListNode->Next = ALLOC(struct ElementListNodeStruct,1);
|
pListNode->Next = SP_MALLOC(struct ElementListNodeStruct,1);
|
||||||
RecordAllocation( Matrix, (void *)pListNode->Next );
|
RecordAllocation( Matrix, (void *)pListNode->Next );
|
||||||
if (Matrix->Error == spNO_MEMORY)
|
if (Matrix->Error == spNO_MEMORY)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -405,14 +405,14 @@ InitializeElementBlocks(MatrixPtr Matrix, int InitialNumberOfElements,
|
||||||
/* Begin `InitializeElementBlocks'. */
|
/* Begin `InitializeElementBlocks'. */
|
||||||
|
|
||||||
/* Allocate block of MatrixElements for elements. */
|
/* Allocate block of MatrixElements for elements. */
|
||||||
pElement = ALLOC(struct MatrixElement, InitialNumberOfElements);
|
pElement = SP_MALLOC(struct MatrixElement, InitialNumberOfElements);
|
||||||
RecordAllocation( Matrix, (void *)pElement );
|
RecordAllocation( Matrix, (void *)pElement );
|
||||||
if (Matrix->Error == spNO_MEMORY) return;
|
if (Matrix->Error == spNO_MEMORY) return;
|
||||||
Matrix->ElementsRemaining = InitialNumberOfElements;
|
Matrix->ElementsRemaining = InitialNumberOfElements;
|
||||||
Matrix->NextAvailElement = pElement;
|
Matrix->NextAvailElement = pElement;
|
||||||
|
|
||||||
/* Allocate an element list structure. */
|
/* Allocate an element list structure. */
|
||||||
Matrix->FirstElementListNode = ALLOC(struct ElementListNodeStruct,1);
|
Matrix->FirstElementListNode = SP_MALLOC(struct ElementListNodeStruct,1);
|
||||||
RecordAllocation( Matrix, (void *)Matrix->FirstElementListNode );
|
RecordAllocation( Matrix, (void *)Matrix->FirstElementListNode );
|
||||||
if (Matrix->Error == spNO_MEMORY) return;
|
if (Matrix->Error == spNO_MEMORY) return;
|
||||||
Matrix->LastElementListNode = Matrix->FirstElementListNode;
|
Matrix->LastElementListNode = Matrix->FirstElementListNode;
|
||||||
|
|
@ -423,14 +423,14 @@ InitializeElementBlocks(MatrixPtr Matrix, int InitialNumberOfElements,
|
||||||
Matrix->FirstElementListNode->Next = NULL;
|
Matrix->FirstElementListNode->Next = NULL;
|
||||||
|
|
||||||
/* Allocate block of MatrixElements for fill-ins. */
|
/* Allocate block of MatrixElements for fill-ins. */
|
||||||
pElement = ALLOC(struct MatrixElement, NumberOfFillinsExpected);
|
pElement = SP_MALLOC(struct MatrixElement, NumberOfFillinsExpected);
|
||||||
RecordAllocation( Matrix, (void *)pElement );
|
RecordAllocation( Matrix, (void *)pElement );
|
||||||
if (Matrix->Error == spNO_MEMORY) return;
|
if (Matrix->Error == spNO_MEMORY) return;
|
||||||
Matrix->FillinsRemaining = NumberOfFillinsExpected;
|
Matrix->FillinsRemaining = NumberOfFillinsExpected;
|
||||||
Matrix->NextAvailFillin = pElement;
|
Matrix->NextAvailFillin = pElement;
|
||||||
|
|
||||||
/* Allocate a fill-in list structure. */
|
/* Allocate a fill-in list structure. */
|
||||||
Matrix->FirstFillinListNode = ALLOC(struct FillinListNodeStruct,1);
|
Matrix->FirstFillinListNode = SP_MALLOC(struct FillinListNodeStruct,1);
|
||||||
RecordAllocation( Matrix, (void *)Matrix->FirstFillinListNode );
|
RecordAllocation( Matrix, (void *)Matrix->FirstFillinListNode );
|
||||||
if (Matrix->Error == spNO_MEMORY) return;
|
if (Matrix->Error == spNO_MEMORY) return;
|
||||||
Matrix->LastFillinListNode = Matrix->FirstFillinListNode;
|
Matrix->LastFillinListNode = Matrix->FirstFillinListNode;
|
||||||
|
|
@ -490,14 +490,14 @@ spcGetFillin(MatrixPtr Matrix)
|
||||||
Matrix->NextAvailFillin = pListNode->pFillinList;
|
Matrix->NextAvailFillin = pListNode->pFillinList;
|
||||||
} else {
|
} else {
|
||||||
/* Allocate block of fill-ins. */
|
/* Allocate block of fill-ins. */
|
||||||
pFillins = ALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION);
|
pFillins = SP_MALLOC(struct MatrixElement, ELEMENTS_PER_ALLOCATION);
|
||||||
RecordAllocation( Matrix, (void *)pFillins );
|
RecordAllocation( Matrix, (void *)pFillins );
|
||||||
if (Matrix->Error == spNO_MEMORY) return NULL;
|
if (Matrix->Error == spNO_MEMORY) return NULL;
|
||||||
Matrix->FillinsRemaining = ELEMENTS_PER_ALLOCATION;
|
Matrix->FillinsRemaining = ELEMENTS_PER_ALLOCATION;
|
||||||
Matrix->NextAvailFillin = pFillins;
|
Matrix->NextAvailFillin = pFillins;
|
||||||
|
|
||||||
/* Allocate a fill-in list structure. */
|
/* Allocate a fill-in list structure. */
|
||||||
pListNode->Next = ALLOC(struct FillinListNodeStruct,1);
|
pListNode->Next = SP_MALLOC(struct FillinListNodeStruct,1);
|
||||||
RecordAllocation( Matrix, (void *)pListNode->Next );
|
RecordAllocation( Matrix, (void *)pListNode->Next );
|
||||||
if (Matrix->Error == spNO_MEMORY) return NULL;
|
if (Matrix->Error == spNO_MEMORY) return NULL;
|
||||||
Matrix->LastFillinListNode = pListNode = pListNode->Next;
|
Matrix->LastFillinListNode = pListNode = pListNode->Next;
|
||||||
|
|
@ -553,7 +553,7 @@ RecordAllocation(MatrixPtr Matrix, void *AllocatedPtr )
|
||||||
if (Matrix->RecordsRemaining == 0) {
|
if (Matrix->RecordsRemaining == 0) {
|
||||||
AllocateBlockOfAllocationList( Matrix );
|
AllocateBlockOfAllocationList( Matrix );
|
||||||
if (Matrix->Error == spNO_MEMORY) {
|
if (Matrix->Error == spNO_MEMORY) {
|
||||||
FREE(AllocatedPtr);
|
SP_FREE(AllocatedPtr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -597,7 +597,7 @@ AllocateBlockOfAllocationList(MatrixPtr Matrix)
|
||||||
|
|
||||||
/* Begin `AllocateBlockOfAllocationList'. */
|
/* Begin `AllocateBlockOfAllocationList'. */
|
||||||
/* Allocate block of records for allocation list. */
|
/* 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) {
|
if (ListPtr == NULL) {
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
return;
|
return;
|
||||||
|
|
@ -660,19 +660,19 @@ spDestroy(MatrixPtr eMatrix)
|
||||||
assert( IS_SPARSE( Matrix ) );
|
assert( IS_SPARSE( Matrix ) );
|
||||||
|
|
||||||
/* Deallocate the vectors that are located in the matrix frame. */
|
/* Deallocate the vectors that are located in the matrix frame. */
|
||||||
FREE( Matrix->IntToExtColMap );
|
SP_FREE( Matrix->IntToExtColMap );
|
||||||
FREE( Matrix->IntToExtRowMap );
|
SP_FREE( Matrix->IntToExtRowMap );
|
||||||
FREE( Matrix->ExtToIntColMap );
|
SP_FREE( Matrix->ExtToIntColMap );
|
||||||
FREE( Matrix->ExtToIntRowMap );
|
SP_FREE( Matrix->ExtToIntRowMap );
|
||||||
FREE( Matrix->Diag );
|
SP_FREE( Matrix->Diag );
|
||||||
FREE( Matrix->FirstInRow );
|
SP_FREE( Matrix->FirstInRow );
|
||||||
FREE( Matrix->FirstInCol );
|
SP_FREE( Matrix->FirstInCol );
|
||||||
FREE( Matrix->MarkowitzRow );
|
SP_FREE( Matrix->MarkowitzRow );
|
||||||
FREE( Matrix->MarkowitzCol );
|
SP_FREE( Matrix->MarkowitzCol );
|
||||||
FREE( Matrix->MarkowitzProd );
|
SP_FREE( Matrix->MarkowitzProd );
|
||||||
FREE( Matrix->DoCmplxDirect );
|
SP_FREE( Matrix->DoCmplxDirect );
|
||||||
FREE( Matrix->DoRealDirect );
|
SP_FREE( Matrix->DoRealDirect );
|
||||||
FREE( Matrix->Intermediate );
|
SP_FREE( Matrix->Intermediate );
|
||||||
|
|
||||||
/* Sequentially step through the list of allocated pointers
|
/* Sequentially step through the list of allocated pointers
|
||||||
* freeing pointers along the way. */
|
* freeing pointers along the way. */
|
||||||
|
|
@ -680,9 +680,9 @@ spDestroy(MatrixPtr eMatrix)
|
||||||
while (ListPtr != NULL) {
|
while (ListPtr != NULL) {
|
||||||
NextListPtr = ListPtr->NextRecord;
|
NextListPtr = ListPtr->NextRecord;
|
||||||
if ((void *) ListPtr == ListPtr->AllocatedPtr) {
|
if ((void *) ListPtr == ListPtr->AllocatedPtr) {
|
||||||
FREE( ListPtr );
|
SP_FREE( ListPtr );
|
||||||
} else {
|
} else {
|
||||||
FREE( ListPtr->AllocatedPtr );
|
SP_FREE( ListPtr->AllocatedPtr );
|
||||||
}
|
}
|
||||||
ListPtr = NextListPtr;
|
ListPtr = NextListPtr;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -972,27 +972,27 @@ EnlargeMatrix(MatrixPtr Matrix, int NewSize)
|
||||||
NewSize = MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
|
NewSize = MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
|
||||||
Matrix->AllocatedSize = NewSize;
|
Matrix->AllocatedSize = NewSize;
|
||||||
|
|
||||||
if (( REALLOC(Matrix->IntToExtColMap, int, NewSize+1)) == NULL)
|
if (( SP_REALLOC(Matrix->IntToExtColMap, int, NewSize+1)) == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (( REALLOC(Matrix->IntToExtRowMap, int, NewSize+1)) == NULL)
|
if (( SP_REALLOC(Matrix->IntToExtRowMap, int, NewSize+1)) == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (( REALLOC(Matrix->Diag, ElementPtr, NewSize+1)) == NULL)
|
if (( SP_REALLOC(Matrix->Diag, ElementPtr, NewSize+1)) == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (( REALLOC(Matrix->FirstInCol, ElementPtr, NewSize+1)) == NULL)
|
if (( SP_REALLOC(Matrix->FirstInCol, ElementPtr, NewSize+1)) == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (( REALLOC(Matrix->FirstInRow, ElementPtr, NewSize+1)) == NULL)
|
if (( SP_REALLOC(Matrix->FirstInRow, ElementPtr, NewSize+1)) == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
return;
|
return;
|
||||||
|
|
@ -1000,12 +1000,12 @@ EnlargeMatrix(MatrixPtr Matrix, int NewSize)
|
||||||
|
|
||||||
/* Destroy the Markowitz and Intermediate vectors, they will be
|
/* Destroy the Markowitz and Intermediate vectors, they will be
|
||||||
* recreated in spOrderAndFactor(). */
|
* recreated in spOrderAndFactor(). */
|
||||||
FREE( Matrix->MarkowitzRow );
|
SP_FREE( Matrix->MarkowitzRow );
|
||||||
FREE( Matrix->MarkowitzCol );
|
SP_FREE( Matrix->MarkowitzCol );
|
||||||
FREE( Matrix->MarkowitzProd );
|
SP_FREE( Matrix->MarkowitzProd );
|
||||||
FREE( Matrix->DoRealDirect );
|
SP_FREE( Matrix->DoRealDirect );
|
||||||
FREE( Matrix->DoCmplxDirect );
|
SP_FREE( Matrix->DoCmplxDirect );
|
||||||
FREE( Matrix->Intermediate );
|
SP_FREE( Matrix->Intermediate );
|
||||||
Matrix->InternalVectorsAllocated = NO;
|
Matrix->InternalVectorsAllocated = NO;
|
||||||
|
|
||||||
/* Initialize the new portion of the vectors. */
|
/* Initialize the new portion of the vectors. */
|
||||||
|
|
@ -1062,12 +1062,12 @@ ExpandTranslationArrays(MatrixPtr Matrix, int NewSize)
|
||||||
NewSize = MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
|
NewSize = MAX( NewSize, EXPANSION_FACTOR * OldAllocatedSize );
|
||||||
Matrix->AllocatedExtSize = NewSize;
|
Matrix->AllocatedExtSize = NewSize;
|
||||||
|
|
||||||
if (( REALLOC(Matrix->ExtToIntRowMap, int, NewSize+1)) == NULL)
|
if (( SP_REALLOC(Matrix->ExtToIntRowMap, int, NewSize+1)) == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (( REALLOC(Matrix->ExtToIntColMap, int, NewSize+1)) == NULL)
|
if (( SP_REALLOC(Matrix->ExtToIntColMap, int, NewSize+1)) == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -369,20 +369,20 @@ extern void * tmalloc(size_t);
|
||||||
extern void txfree(void *);
|
extern void txfree(void *);
|
||||||
extern void * trealloc(void *, size_t);
|
extern void * trealloc(void *, size_t);
|
||||||
|
|
||||||
#define ALLOC(type,number) ((type *)tmalloc((size_t)(sizeof(type)*(number))))
|
#define SP_MALLOC(type,number) ((type *)tmalloc((size_t)(sizeof(type)*(number))))
|
||||||
#define REALLOC(ptr,type,number) \
|
#define SP_REALLOC(ptr,type,number) \
|
||||||
ptr = (type *)trealloc((char *)ptr,(unsigned)(sizeof(type)*(number)))
|
ptr = (type *)trealloc((char *)ptr,(unsigned)(sizeof(type)*(number)))
|
||||||
#define FREE(ptr) { if ((ptr) != NULL) txfree((char *)(ptr)); (ptr) = NULL; }
|
#define SP_FREE(ptr) { if ((ptr) != NULL) txfree((char *)(ptr)); (ptr) = NULL; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* A new calloc */
|
/* A new calloc */
|
||||||
#ifndef HAVE_LIBGC
|
#ifndef HAVE_LIBGC
|
||||||
#define CALLOC(ptr,type,number) \
|
#define SP_CALLOC(ptr,type,number) \
|
||||||
{ ptr = (type *) calloc(number, sizeof(type)); \
|
{ ptr = (type *) calloc(number, sizeof(type)); \
|
||||||
}
|
}
|
||||||
#else /* HAVE_LIBCG */
|
#else /* HAVE_LIBCG */
|
||||||
#define CALLOC(ptr,type,number) \
|
#define SP_CALLOC(ptr,type,number) \
|
||||||
{ ptr = (type *) tmalloc(((size_t)number) * sizeof(type)); \
|
{ ptr = (type *) tmalloc(((size_t)number) * sizeof(type)); \
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -744,33 +744,33 @@ spcCreateInternalVectors( MatrixPtr Matrix )
|
||||||
|
|
||||||
if (Matrix->MarkowitzRow == NULL)
|
if (Matrix->MarkowitzRow == NULL)
|
||||||
{
|
{
|
||||||
if (( Matrix->MarkowitzRow = ALLOC(int, Size+1)) == NULL)
|
if (( Matrix->MarkowitzRow = SP_MALLOC(int, Size+1)) == NULL)
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
}
|
}
|
||||||
if (Matrix->MarkowitzCol == NULL)
|
if (Matrix->MarkowitzCol == NULL)
|
||||||
{
|
{
|
||||||
if (( Matrix->MarkowitzCol = ALLOC(int, Size+1)) == NULL)
|
if (( Matrix->MarkowitzCol = SP_MALLOC(int, Size+1)) == NULL)
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
}
|
}
|
||||||
if (Matrix->MarkowitzProd == NULL)
|
if (Matrix->MarkowitzProd == NULL)
|
||||||
{
|
{
|
||||||
if (( Matrix->MarkowitzProd = ALLOC(long, Size+2)) == NULL)
|
if (( Matrix->MarkowitzProd = SP_MALLOC(long, Size+2)) == NULL)
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create DoDirect vectors for use in spFactor(). */
|
/* Create DoDirect vectors for use in spFactor(). */
|
||||||
if (Matrix->DoRealDirect == NULL) {
|
if (Matrix->DoRealDirect == NULL) {
|
||||||
if (( Matrix->DoRealDirect = ALLOC(int, Size+1)) == NULL)
|
if (( Matrix->DoRealDirect = SP_MALLOC(int, Size+1)) == NULL)
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
}
|
}
|
||||||
if (Matrix->DoCmplxDirect == NULL) {
|
if (Matrix->DoCmplxDirect == NULL) {
|
||||||
if (( Matrix->DoCmplxDirect = ALLOC(int, Size+1)) == NULL)
|
if (( Matrix->DoCmplxDirect = SP_MALLOC(int, Size+1)) == NULL)
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create Intermediate vectors for use in MatrixSolve. */
|
/* Create Intermediate vectors for use in MatrixSolve. */
|
||||||
if (Matrix->Intermediate == NULL) {
|
if (Matrix->Intermediate == NULL) {
|
||||||
if ((Matrix->Intermediate = ALLOC(RealNumber,2*(Size+1))) == NULL)
|
if ((Matrix->Intermediate = SP_MALLOC(RealNumber,2*(Size+1))) == NULL)
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,11 +148,11 @@ spPrint(MatrixPtr eMatrix, int PrintReordered, int Data, int Header)
|
||||||
/* Begin `spPrint'. */
|
/* Begin `spPrint'. */
|
||||||
assert( IS_SPARSE( Matrix ) );
|
assert( IS_SPARSE( Matrix ) );
|
||||||
Size = Matrix->Size;
|
Size = Matrix->Size;
|
||||||
CALLOC(pImagElements, ElementPtr, Printer_Width / 10 + 1);
|
SP_CALLOC(pImagElements, ElementPtr, Printer_Width / 10 + 1);
|
||||||
if ( pImagElements == NULL)
|
if ( pImagElements == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
FREE(pImagElements);
|
SP_FREE(pImagElements);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -163,19 +163,19 @@ spPrint(MatrixPtr eMatrix, int PrintReordered, int Data, int Header)
|
||||||
#else
|
#else
|
||||||
Top = Matrix->AllocatedSize;
|
Top = Matrix->AllocatedSize;
|
||||||
#endif
|
#endif
|
||||||
CALLOC( PrintOrdToIntRowMap, int, Top + 1 );
|
SP_CALLOC( PrintOrdToIntRowMap, int, Top + 1 );
|
||||||
if ( PrintOrdToIntRowMap == NULL)
|
if ( PrintOrdToIntRowMap == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
FREE(pImagElements);
|
SP_FREE(pImagElements);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CALLOC( PrintOrdToIntColMap, int, Top + 1 );
|
SP_CALLOC( PrintOrdToIntColMap, int, Top + 1 );
|
||||||
if (PrintOrdToIntColMap == NULL)
|
if (PrintOrdToIntColMap == NULL)
|
||||||
{
|
{
|
||||||
Matrix->Error = spNO_MEMORY;
|
Matrix->Error = spNO_MEMORY;
|
||||||
FREE(pImagElements);
|
SP_FREE(pImagElements);
|
||||||
FREE(PrintOrdToIntRowMap);
|
SP_FREE(PrintOrdToIntRowMap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (I = 1; I <= Size; I++)
|
for (I = 1; I <= Size; I++)
|
||||||
|
|
@ -377,8 +377,8 @@ spPrint(MatrixPtr eMatrix, int PrintReordered, int Data, int Header)
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
(void)fflush(stdout);
|
(void)fflush(stdout);
|
||||||
|
|
||||||
FREE(PrintOrdToIntColMap);
|
SP_FREE(PrintOrdToIntColMap);
|
||||||
FREE(PrintOrdToIntRowMap);
|
SP_FREE(PrintOrdToIntRowMap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1634,7 +1634,7 @@ int *pError;
|
||||||
|
|
||||||
Size = Matrix->Size;
|
Size = Matrix->Size;
|
||||||
T = (ComplexVector)Matrix->Intermediate;
|
T = (ComplexVector)Matrix->Intermediate;
|
||||||
Tm = ALLOC( ComplexNumber, Size+1 );
|
Tm = SP_MALLOC( ComplexNumber, Size+1 );
|
||||||
if (Tm == NULL)
|
if (Tm == NULL)
|
||||||
{
|
{
|
||||||
*pError = spNO_MEMORY;
|
*pError = spNO_MEMORY;
|
||||||
|
|
@ -1800,7 +1800,7 @@ int *pError;
|
||||||
/* Compute 1-norm of T, which now contains z. */
|
/* Compute 1-norm of T, which now contains z. */
|
||||||
for (ASz = 0.0, I = Size; I > 0; I--) ASz += CMPLX_1_NORM(T[I]);
|
for (ASz = 0.0, I = Size; I > 0; I--) ASz += CMPLX_1_NORM(T[I]);
|
||||||
|
|
||||||
FREE( Tm );
|
SP_FREE( Tm );
|
||||||
|
|
||||||
Linpack = ASy / ASz;
|
Linpack = ASy / ASz;
|
||||||
OLeary = E / MaxY;
|
OLeary = E / MaxY;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue