1 #include "BSprivate.h" 2 3 /*+ BSins_diag - insert diagonals back into matrix 4 5 Input Parameters: 6 . A - the sparse matrix 7 8 Output Parameters: 9 . A - the sparse matrix with diagonals 10 11 Returns: 12 void 13 14 Notes: 15 This routine only works if BSrem_diag has previously removed the diagonal. 16 It relies on the array being preallocated and the diagonal value 17 being hidden at the end of the array 18 19 +*/ BSins_diag(BSspmat * A)20void BSins_diag(BSspmat *A) 21 { 22 int i, j; 23 BSsprow *row; 24 int ival; 25 26 for (i=0;i<A->num_rows;i++) { 27 row = A->rows[i]; 28 row->diag_ind = -row->diag_ind; 29 row->length++; 30 ival = row->col[row->length-1]; 31 for (j=row->length-1;j>row->diag_ind;j--) { 32 row->col[j] = row->col[j-1]; 33 } 34 row->col[row->diag_ind] = ival; 35 } 36 } 37