csc_utils.c

Contains functions to manage CSC

Summary
csc_utils.cContains functions to manage CSC
cmp_colrowUsed for qsort to sort arrays of INT following their first element.
csc_symgraphModify the CSC to a symetric graph one.
csc_symgraph_intModify the CSC to a symetric graph one.
csc_noDiagSupress diagonal term.
csc_check_doublesCheck if the csc contains doubles and if correct if asked
csc_checksymCheck if the CSC graph is symetric.
CSC_colPermPerforms column permutation on a CSC
CSC_colScaleMoved from kass, only used in MC64
CSC_rowScaleMoved from kass, only used in MC64
CSC_sort
CSC_Fnum2CnumConvert CSC numbering from fortran numbering to C numbering.
CSC_Cnum2FnumConvert CSC numbering from C numbering to Fortran numbering.
CSC_buildZerosAndNonZerosGraphsSeparate a graph in two graphs, following wether the diagonal term of a column is null or not.
CSC_isolateIsolate a list of unknowns at the end of the CSC.
csc_saveSave a csc on disk.
csc_loadLoad a csc from disk.

cmp_colrow

int cmp_colrow(const void *p1,
const void *p2)

Used for qsort to sort arrays of INT following their first element.

Returns the difference between the first element of p1 and the first element of p2

Parameters

p1the first array to compare
p2the second array to compare

csc_symgraph

int csc_symgraph(INT n,
INT *ia,
INT *ja,
FLOAT *a,
INT *newn,
INT **newia,
INT **newja,
FLOAT **newa)

Modify the CSC to a symetric graph one.  Don’t use it on a lower symetric CSC it would give you all the CSC upper + lower.

External function.

Parameters

nNumber of columns/vertices
iaStarting index of each column in ja and a
jaRow index of each element
aValue of each element,can be NULL
newnNew number of column
newiaStarting index of each column in ja and a
newjaRow index of each element
newaValue of each element,can be NULL

csc_symgraph_int

int csc_symgraph_int (INT n,
INT *ia,
INT *ja,
FLOAT *a,
INT *newn,
INT **newia,
INT **newja,
FLOAT **newa,
int malloc_flag)

Modify the CSC to a symetric graph one.  Don’t use it on a lower symetric CSC it would give you all the CSC upper + lower.

Parameters

nNumber of columns/vertices
iaStarting index of each column in ja and a
jaRow index of each element
aValue of each element,can be NULL
newnNew number of column
newiaStarting index of each column in ja and a
newjaRow index of each element
newaValue of each element,can be NULL
malloc_flagflag to indicate if function call is intern to pastix or extern.

csc_noDiag

void csc_noDiag(INT baseval,
INT n,
INT *ia,
INT *ja,
FLOAT *a)

Supress diagonal term.  After this call, ja can be reallocated to ia[n] -1.

Parameters

nsize of the matrix.
iaIndex in ja and a of the first element of each column
jarow of each element
avalue of each element, can be set to NULL

Returns

ia and ja tabulars modified.

csc_check_doubles

int csc_check_doubles(INT n,
INT *colptr,
INT **rows,
FLOAT **values,
int dof,
int flag,
int flagalloc)

Check if the csc contains doubles and if correct if asked

Assumes that the CSC is sorted.

Assumes that the CSC is Fortran numeroted (base 1)

Parameters

nSize of the matrix.
colptrIndex in rows and values of the first element of each column
rowsrow of each element
valuesvalue of each element (Can be NULL)
dofNumber of degrees of freedom
flagIndicate if user wants correction (API_BOOLEAN)
flagallocindicate if allocation on CSC uses internal malloc.

Returns

API_YESIf the matrix contained no double or was successfully corrected.
API_NOOtherwise.

csc_checksym

int csc_checksym(INT n,
INT *colptr,
INT **rows,
FLOAT **values,
int correct,
int alloc,
int dof)

Check if the CSC graph is symetric.

For all local column C,

For all row R in the column C,

We look in column R if we have the row number C.

If we can correct we had missing non zeros.

Assumes that the CSC is Fortran numbered (1 based).

Assumes that the matrix is sorted.

Parameters

nNumber of local columns
colptrStarting index of each columns in ja
rowsRow of each element.
valuesValue of each element.
correctFlag indicating if we can correct the symmetry.
allocindicate if allocation on CSC uses internal malloc.
dofNumber of degrees of freedom.

CSC_colPerm

void CSC_colPerm(INT n,
INT *ia,
INT *ja,
FLOAT *a,
INT *cperm)

Performs column permutation on a CSC

Parameters

nSize of the matrix.
iaIndex of first element of each column in ia and a
jaRows of non zeros of the matrix.
aValues of non zeros of the matrix.
cpermPermutation to perform

CSC_colScale

void CSC_colScale(INT n,
INT *ia,
INT *ja,
FLOAT *a,
FLOAT *dcol)

Moved from kass, only used in MC64

CSC_rowScale

void CSC_rowScale(INT n,
INT *ia,
INT *ja,
FLOAT *a,
FLOAT *drow)

Moved from kass, only used in MC64

CSC_sort

void CSC_sort(INT n,
INT *ia,
INT *ja,
FLOAT *a)

CSC_Fnum2Cnum

void CSC_Fnum2Cnum(INT *ja,
INT *ia,
INT n)

Convert CSC numbering from fortran numbering to C numbering.

Parameters

jaRows of each element.
iaFirst index of each column in ja
nNumber of columns

CSC_Cnum2Fnum

void CSC_Cnum2Fnum(INT *ja,
INT *ia,
INT n)

Convert CSC numbering from C numbering to Fortran numbering.

Parameters

jaRows of each element.
iaFirst index of each column in ja
nNumber of columns

CSC_buildZerosAndNonZerosGraphs

int CSC_buildZerosAndNonZerosGraphs(INT n,
INT *colptr,
INT *rows,
FLOAT *values,
INT *n_nz,
INT **colptr_nz,
INT **rows_nz,
INT *n_z,
INT **colptr_z,
INT **rows_z,
INT *perm,
INT *revperm,
double criteria)

Separate a graph in two graphs, following wether the diagonal term of a column is null or not.

Parameters

n, colptr, rows, valuesThe initial CSC
n_nz, colptr_nz, rows_nzThe graph of the non-null diagonal part.
n_z, colptr_z, rows_zThe graph of the null diagonal part.
permPermutation to go from the first graph to the one composed of the two graph concatenated.
revpermReverse permutation tabular.
criteriaValue beside which a number is said null.

CSC_isolate

int CSC_isolate(INT n,
INT *colptr,
INT *rows,
INT n_isolate,
INT *isolate_list,
INT *perm,
INT *revperm)

Isolate a list of unknowns at the end of the CSC.

Parameters

nNumber of columns.
colptrIndex of first element of each column in ia.
rowsRows of each non zeros.
n_isolateNumber of unknow to isolate.
isolate_listList of unknown to isolate.
permpermutation tabular.
revpermreverse permutation tabular.

csc_save

int csc_save(INT n,
INT *colptr,
INT *rows,
FLOAT *values,
int dof,
FILE *outfile)

Save a csc on disk.

Parameters

nnumber of columns
colptrFirst cscd starting index of each column in ja and a
rowsRow of each element in first CSCD
valuesvalue of each cscd in first CSCD (can be NULL)
dofNumber of degrees of freedom
outfileOutput stream.

Return

NO_ERR

csc_load

int csc_load(INT *n,
INT **colptr,
INT **rows,
FLOAT **values,
int *dof,
FILE *infile)

Load a csc from disk.

Fill n, colptr, rows, values and dof from infile.

Parameters

nnumber of columns
colptrFirst cscd starting index of each column in ja and a
rowsRow of each element in first CSCD
valuesvalue of each cscd in first CSCD (can be NULL)
dofNumber of degrees of freedom
outfileOutput stream.

Return

NO_ERR

int cmp_colrow(const void *p1,
const void *p2)
Used for qsort to sort arrays of INT following their first element.
int csc_symgraph(INT n,
INT *ia,
INT *ja,
FLOAT *a,
INT *newn,
INT **newia,
INT **newja,
FLOAT **newa)
Modify the CSC to a symetric graph one.
int csc_symgraph_int (INT n,
INT *ia,
INT *ja,
FLOAT *a,
INT *newn,
INT **newia,
INT **newja,
FLOAT **newa,
int malloc_flag)
Modify the CSC to a symetric graph one.
void csc_noDiag(INT baseval,
INT n,
INT *ia,
INT *ja,
FLOAT *a)
Supress diagonal term.
int csc_check_doubles(INT n,
INT *colptr,
INT **rows,
FLOAT **values,
int dof,
int flag,
int flagalloc)
Check if the csc contains doubles and if correct if asked
int csc_checksym(INT n,
INT *colptr,
INT **rows,
FLOAT **values,
int correct,
int alloc,
int dof)
Check if the CSC graph is symetric.
void CSC_colPerm(INT n,
INT *ia,
INT *ja,
FLOAT *a,
INT *cperm)
Performs column permutation on a CSC
void CSC_colScale(INT n,
INT *ia,
INT *ja,
FLOAT *a,
FLOAT *dcol)
Moved from kass, only used in MC64
void CSC_rowScale(INT n,
INT *ia,
INT *ja,
FLOAT *a,
FLOAT *drow)
Moved from kass, only used in MC64
void CSC_sort(INT n,
INT *ia,
INT *ja,
FLOAT *a)
void CSC_Fnum2Cnum(INT *ja,
INT *ia,
INT n)
Convert CSC numbering from fortran numbering to C numbering.
void CSC_Cnum2Fnum(INT *ja,
INT *ia,
INT n)
Convert CSC numbering from C numbering to Fortran numbering.
int CSC_buildZerosAndNonZerosGraphs(INT n,
INT *colptr,
INT *rows,
FLOAT *values,
INT *n_nz,
INT **colptr_nz,
INT **rows_nz,
INT *n_z,
INT **colptr_z,
INT **rows_z,
INT *perm,
INT *revperm,
double criteria)
Separate a graph in two graphs, following wether the diagonal term of a column is null or not.
int CSC_isolate(INT n,
INT *colptr,
INT *rows,
INT n_isolate,
INT *isolate_list,
INT *perm,
INT *revperm)
Isolate a list of unknowns at the end of the CSC.
int csc_save(INT n,
INT *colptr,
INT *rows,
FLOAT *values,
int dof,
FILE *outfile)
Save a csc on disk.
int csc_load(INT *n,
INT **colptr,
INT **rows,
FLOAT **values,
int *dof,
FILE *infile)
Load a csc from disk.
enum API_BOOLEAN
Boolean modes (All boolean except IPARM_SYM)
Close