1 #include "BSprivate.h" 2 3 /*@ BSset_diag - Set the diagonal of A to a constant 4 5 Input Parameters: 6 . A - a sparse matrix 7 . my_alpha - the constant 8 . procinfo - the usual processor stuff 9 10 Output Parameters: 11 . A - a sparse matrix with the diagonal set to my_alpha 12 13 Returns: 14 void 15 16 Notes: In the nonsymmetric case we set the diagonal +/-my_alpha 17 depending on the sign of the diagonal. 18 19 @*/ 20 /* Set the diagonal of the matrix to my_alpha */ BSset_diag(BSpar_mat * A,FLOAT my_alpha,BSprocinfo * procinfo)21void BSset_diag(BSpar_mat *A, FLOAT my_alpha, BSprocinfo *procinfo) 22 { 23 int i; 24 FLOAT *matrix; 25 int cl_ind, size; 26 BScl_2_inode *cliques; 27 28 cliques = A->clique2inode; 29 for (cl_ind=0;cl_ind<cliques->num_cols;cl_ind++) { 30 if (cliques->proc[cl_ind] == procinfo->my_id) { 31 matrix = cliques->d_mats[cl_ind].matrix; 32 size = cliques->d_mats[cl_ind].size; 33 if(A->icc_storage) { 34 for (i=0;i<size;i++) { 35 matrix[(i*size)+i] = my_alpha; 36 } 37 } else { 38 for (i=0;i<size;i++) { 39 if (matrix[(i*size)+i] < 0.0) 40 matrix[(i*size)+i] = -my_alpha; 41 else 42 matrix[(i*size)+i] = my_alpha; 43 } 44 } 45 } 46 } 47 } 48