58 for(j=0; j<spm->
n; j++, colptr++, loc2glob++) {
59 jg = spm->
replicated ? j : *loc2glob - baseval;
62 for(k=colptr[0]; k<colptr[1]; k++, rowptr++) {
63 ig = *rowptr - baseval;
74 degrees[jg] += (dofi - 1);
113 for(k=0; k<spm->
nnz; k++, rowptr++, colptr++)
115 ig = *rowptr - baseval;
116 jg = *colptr - baseval;
128 degrees[jg] += (dofi - 1);
175#if defined(SPM_WITH_MPI)
178 MPI_SUM, spm->
comm );
219 spm->
nnz = oldspm.
nnz + (spm->
n - diagval);
240 for(j=0; j<spm->
n; j++, newcol++, loc2glob++) {
244 memcpy( newrow, oldrow, nbelt *
sizeof(
spm_int_t) );
248 jg = spm->
replicated ? j + baseval : *loc2glob;
249 for(k=0; k<nbelt; k++, oldrow++) {
272 assert( d == spm->
n );
306 spm->
nnz = oldspm.
nnz + (spm->
n - diagval);
316 for(k=0; k<spm->
n; k++, newrow++, newcol++, loc2glob++)
323 assert( loc2glob == NULL );
324 for(k=0; k<spm->
n; k++, newrow++, newcol++)
326 *newrow = k + baseval;
327 *newcol = k + baseval;
332 for(k=0; k<spm->
nnz; k++, oldrow++, oldcol++)
334 if ( *oldrow == *oldcol ) {
368 assert( diagval < spm->n );
426 spm_attr_fallthrough;
429 for(j=0; j<spm->
n; j++, colptr++, loc2glob++)
431 jg = spm->
replicated ? j : *loc2glob - baseval;
432 jge = (dof > 0) ? jg * dof : dofs[jg] - baseval;
433 dofj = (dof > 0) ? dof : dofs[jg+1] - dofs[jg];
434 for(k=colptr[0]; k<colptr[1]; k++, rowptr++)
436 ig = *rowptr - baseval;
437 ige = (dof > 0) ? ig * dof : dofs[ig] - baseval;
438 dofi = (dof > 0) ? dof : dofs[ig+1] - dofs[ig];
440 for ( jj=0; jj<dofj; jj++ )
442 for ( ii=0; ii<dofi; ii++, values++ )
445 if ( (jge+jj) == (ige+ii) ) {
446 *values = alpha * degrees[jg];
457 for(k=0; k<spm->
nnz; k++, rowptr++, colptr++)
459 ig = *rowptr - baseval;
460 jg = *colptr - baseval;
461 ige = (dof > 0) ? ig * dof : dofs[ig] - baseval;
462 jge = (dof > 0) ? jg * dof : dofs[jg] - baseval;
463 dofi = (dof > 0) ? dof : dofs[ig+1] - dofs[ig];
464 dofj = (dof > 0) ? dof : dofs[jg+1] - dofs[jg];
466 for ( jj=0; jj<dofj; jj++ )
468 for ( ii=0; ii<dofi; ii++, values++ )
471 if ( (jge+jj) == (ige+ii) ) {
472 *values = alpha * degrees[jg];
481 assert( (values - (
double*)(spm->
values)) == spm->
nnzexp );
517 spm_print_error(
"spmGenFakeValues: Cannot generate fake values for non SpmPattern matrices\n" );
521 if ( spm->
values != NULL ) {
522 spm_print_error(
"spmGenFakeValues: values field should be NULL on entry\n" );
530 char *str = spm_getenv(
"SPM_FAKE_ALPHA" );
534 value = strtod( str, NULL );
535 if ( (value != HUGE_VAL) && (value != 0.) &&
536 !isnan(value) && !isinf(value) )
543 str = spm_getenv(
"SPM_FAKE_BETA" );
545 value = strtod( str, NULL );
546 if ( (value != HUGE_VAL) && (value != 0.) &&
547 !isnan(value) && !isinf(value) )
558#if defined(SPM_WITH_MPI)
560 MPI_Allreduce( &diagval, &gdiagval, 1,
SPM_MPI_INT,
561 MPI_SUM, spm->
comm );
569 if ( gdiagval != spm->
gN ) {
571 if ( spm->
n != diagval ) {
#define SPM_MPI_INT
The MPI type associated to spm_int_t.
void spmUpdateComputedFields(spmatrix_t *spm)
Update all the computed fields based on the static values stored.
int spm_int_t
The main integer datatype used in spm arrays.
void spmGenFakeValues(spmatrix_t *spm)
Generate the fake values array such that .
The sparse matrix data structure.
static spm_int_t spm_compute_degrees_ijv(const spmatrix_t *spm, spm_int_t *degrees)
Compute the degree of each vertex of an IJV matrix.
static spm_int_t spm_compute_degrees_csx(const spmatrix_t *spm, spm_int_t *degrees)
Compute the local degree of each vertex of an SPM in CSR/CSC format.
static void spm_add_diag_ijv(spmatrix_t *spm, spm_int_t diagval)
Insert diagonal elements to the graph of an IJV matrix to have a full Laplacian generated.
static void spm_add_diag(spmatrix_t *spm, spm_int_t diagval)
Insert diagonal elements to the graph of a matrix to have a full Laplacian generated.
static void spm_add_diag_csx(spmatrix_t *spm, spm_int_t diagval)
Insert diagonal elements to the graph of a CSC/CSR matrix to have a full Laplacian generated.
static void spm_generate_fake_values(spmatrix_t *spm, const spm_int_t *degrees, double alpha, double beta)
Generate the fake values array such that .
static spm_int_t spm_compute_degrees(const spmatrix_t *spm, spm_int_t *degrees)
Compute the degree of each vertex.