Implement spMatrix_CSC_dump()
This commit is contained in:
parent
d2562ba82f
commit
0afda7f89c
|
|
@ -305,9 +305,9 @@ typedef struct sBindElement {
|
||||||
} BindElement ;
|
} BindElement ;
|
||||||
|
|
||||||
extern int WriteCol_original (MatrixPtr, int, spREAL *, spREAL *, int *, BindElement *, spREAL **) ;
|
extern int WriteCol_original (MatrixPtr, int, spREAL *, spREAL *, int *, BindElement *, spREAL **) ;
|
||||||
extern int WriteCol_original_dump (MatrixPtr, int, spREAL *, int *) ;
|
extern int WriteCol_original_dump (MatrixPtr, int, spREAL *, int *, unsigned int) ;
|
||||||
extern void spMatrix_CSC (MatrixPtr, int *, int *, double *, double *, int, BindElement *, double **) ;
|
extern void spMatrix_CSC (MatrixPtr, int *, int *, double *, double *, int, BindElement *, double **) ;
|
||||||
extern void spMatrix_CSC_dump (MatrixPtr, char *) ;
|
extern void spMatrix_CSC_dump (MatrixPtr, unsigned int, char *) ;
|
||||||
extern void spRHS_CSC_dump (spREAL *, char *, MatrixPtr) ;
|
extern void spRHS_CSC_dump (spREAL *, char *, MatrixPtr) ;
|
||||||
#endif
|
#endif
|
||||||
/* ------------------------------------------------------ */
|
/* ------------------------------------------------------ */
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,9 @@ SMPmatrix_CSC (SMPmatrix *Matrix)
|
||||||
{
|
{
|
||||||
spMatrix_CSC (Matrix->SPmatrix, Matrix->CKTkluAp, Matrix->CKTkluAi, Matrix->CKTkluAx,
|
spMatrix_CSC (Matrix->SPmatrix, Matrix->CKTkluAp, Matrix->CKTkluAi, Matrix->CKTkluAx,
|
||||||
Matrix->CKTkluAx_Complex, Matrix->CKTkluN, Matrix->CKTbindStruct, Matrix->CKTdiag_CSC) ;
|
Matrix->CKTkluAx_Complex, Matrix->CKTkluN, Matrix->CKTbindStruct, Matrix->CKTdiag_CSC) ;
|
||||||
|
|
||||||
|
// spMatrix_CSC_dump (Matrix->SPmatrix, 1, NULL) ;
|
||||||
|
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,15 +44,22 @@ WriteCol_original (MatrixPtr Matrix, int Col, spREAL *CSC_Element, spREAL *CSC_E
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
WriteCol_original_dump (MatrixPtr Matrix, int Col, spREAL *CSC_Element, int *CSC_Row)
|
WriteCol_original_dump (MatrixPtr Matrix, int Col, spREAL *CSC_Element, int *CSC_Row, unsigned int complex)
|
||||||
{
|
{
|
||||||
int i ;
|
int i ;
|
||||||
ElementPtr current ;
|
ElementPtr current ;
|
||||||
i = 0 ;
|
i = 0 ;
|
||||||
current = Matrix->FirstInCol [Col] ;
|
current = Matrix->FirstInCol [Col] ;
|
||||||
|
|
||||||
while (current != NULL) {
|
while (current != NULL)
|
||||||
|
{
|
||||||
|
if (complex)
|
||||||
|
{
|
||||||
|
CSC_Element [2 * i] = current->Real ;
|
||||||
|
CSC_Element [2 * i + 1] = current->Imag ;
|
||||||
|
} else {
|
||||||
CSC_Element [i] = current->Real ;
|
CSC_Element [i] = current->Real ;
|
||||||
|
}
|
||||||
CSC_Row [i] = (current->Row) - 1 ;
|
CSC_Row [i] = (current->Row) - 1 ;
|
||||||
i++ ;
|
i++ ;
|
||||||
current = current->NextInCol ;
|
current = current->NextInCol ;
|
||||||
|
|
@ -77,7 +84,7 @@ spMatrix_CSC (MatrixPtr Matrix, int *Ap, int *Ai, double *Ax, double *Ax_Complex
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spMatrix_CSC_dump (MatrixPtr Matrix, char *CSC_output)
|
spMatrix_CSC_dump (MatrixPtr Matrix, unsigned int complex, char *CSC_output)
|
||||||
{
|
{
|
||||||
FILE *output ;
|
FILE *output ;
|
||||||
int offset, i, j, *Ap, *Ai, n, nz ;
|
int offset, i, j, *Ap, *Ai, n, nz ;
|
||||||
|
|
@ -87,15 +94,22 @@ spMatrix_CSC_dump (MatrixPtr Matrix, char *CSC_output)
|
||||||
nz = Matrix->Elements ;
|
nz = Matrix->Elements ;
|
||||||
Ap = (int *) SP_MALLOC (int, n + 1) ;
|
Ap = (int *) SP_MALLOC (int, n + 1) ;
|
||||||
Ai = (int *) SP_MALLOC (int, nz) ;
|
Ai = (int *) SP_MALLOC (int, nz) ;
|
||||||
|
if (complex)
|
||||||
|
{
|
||||||
|
Ax = (double *) SP_MALLOC (double, 2 * nz) ;
|
||||||
|
} else {
|
||||||
Ax = (double *) SP_MALLOC (double, nz) ;
|
Ax = (double *) SP_MALLOC (double, nz) ;
|
||||||
|
|
||||||
offset = 0 ;
|
|
||||||
Ap[0] = offset ;
|
|
||||||
for (i = 1 ; i <= n ; i++) {
|
|
||||||
offset += WriteCol_original_dump (Matrix, i, (spREAL *)(Ax + offset), (int *)(Ai + offset)) ;
|
|
||||||
Ap[i] = offset ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offset = 0 ;
|
||||||
|
Ap [0] = offset ;
|
||||||
|
for (i = 1 ; i <= n ; i++) {
|
||||||
|
offset += WriteCol_original_dump (Matrix, i, (spREAL *)(Ax + offset), (int *)(Ai + offset), complex) ;
|
||||||
|
Ap [i] = offset ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!complex && CSC_output != NULL)
|
||||||
|
{
|
||||||
output = fopen (CSC_output, "w") ;
|
output = fopen (CSC_output, "w") ;
|
||||||
fprintf (output, "%%%%MatrixMarket matrix coordinate real general\n") ;
|
fprintf (output, "%%%%MatrixMarket matrix coordinate real general\n") ;
|
||||||
fprintf (output, "%%-------------------------------------------------------------------------------\n") ;
|
fprintf (output, "%%-------------------------------------------------------------------------------\n") ;
|
||||||
|
|
@ -111,6 +125,21 @@ spMatrix_CSC_dump (MatrixPtr Matrix, char *CSC_output)
|
||||||
for (i = 1 ; i <= n ; i++)
|
for (i = 1 ; i <= n ; i++)
|
||||||
fprintf (output, "%d\n", Matrix->IntToExtColMap [i]) ;
|
fprintf (output, "%d\n", Matrix->IntToExtColMap [i]) ;
|
||||||
fclose (output) ;
|
fclose (output) ;
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "CSC Matrix converted from SPARSE 1.3 matrix\n") ;
|
||||||
|
for (i = 0 ; i < n ; i++)
|
||||||
|
{
|
||||||
|
for (j = Ap [i] ; j < Ap [i + 1] ; j++)
|
||||||
|
{
|
||||||
|
if (complex)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "Row: %d\tCol: %d\tValue: %-.9g j%-.9g\n", Ai [j] + 1, i + 1, Ax [2 * j], Ax [2 * j + 1]) ;
|
||||||
|
} else {
|
||||||
|
fprintf (stderr, "Row: %d\tCol: %d\tValue: %-.9g\n", Ai [j] + 1, i + 1, Ax [j]) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SP_FREE (Ap) ;
|
SP_FREE (Ap) ;
|
||||||
SP_FREE (Ai) ;
|
SP_FREE (Ai) ;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue