HP MLIB User's Guide Vol. 2 7th Ed.

Chapter 11 Introduction to Distributed SuperLU 759
Sample programs
}
/* Create compressed column matrix for GA. */
/*
* Create SuperMatrix GA:
* GAstore points to the storage of a Harwell-Boeing sparse matrix
* format for GA.
* GA.Stype MUST be SLU_NC, GA.Dtype MUST be SLU_D for pdgssvx and
* MUST be SLU_Z for pzgssvx, and GA.Mtype MUST be SLU_GE.
*/
GA.Stype = SLU_NC;
GA.Dtype = SLU_D;
GA.Mtype = SLU_GE;
GA.nrow = m;
GA.ncol = n;
if (!(GA.Store = (void *) malloc( sizeof(NCformat) ))){
printf(“malloc fails for GA.Store”);
exit (-1);
}
GAstore = (NCformat *) GA.Store;
GAstore->nnz = nnz;
GAstore->nzval = nzval;
GAstore->rowind = rowind;
GAstore->colptr = colptr;
/* Set up the right-hand side. */
if (!(b_global=(double *) malloc(m*nrhs*sizeof(double)))) {
printf(“malloc fails for rowptr[]\n”);
exit (-1);
}
b_global[0]=3.8; b_global[1]=4.7; b_global[2]=13.0; b_global[3]=8.6;
b_global[4]=15.8;
/*Change GA to a local A with NR_loc format */
if (!(rowptr=(int_t*) malloc((m_loc+1)*sizeof(int_t)))) {
printf(“malloc fails for rowptr[]\n”);
exit (-1);
}
if (!(marker = (int_t *) malloc((n) * sizeof(int_t)))) {
printf(“malloc fails for marker[]\n”);
exit (-1);
}
for (i = 0; i < n; ++i) marker[i] = 0;
/* Get counts of each row of GA */
for (i = 0; i < n; ++i)
for (j = colptr[i]; j < colptr[i+1]; ++j) ++marker[rowind[j]];