1 #include "BSprivate.h"
2 
3 /*@ BSset_diagv - Set the diagonal equal to a vector
4 
5     Input Parameters:
6 .   A - a sparse matrix
7 .   diag - the vector
8 .   procinfo - the usual processor stuff
9 
10     Output Parameters:
11 .   A - a sparse matrix with the diagonal set to diag
12 
13     Returns:
14     void
15 
16  @*/
BSset_diagv(BSpar_mat * A,FLOAT * diag,BSprocinfo * procinfo)17 void BSset_diagv(BSpar_mat *A, FLOAT *diag, BSprocinfo *procinfo)
18 {
19 	int	i;
20 	FLOAT	*matrix;
21 	int	cl_ind, size;
22 	BScl_2_inode *cliques;
23 	int	count;
24 
25 	cliques = A->clique2inode;
26 	count = 0;
27 	for (cl_ind=0;cl_ind<cliques->num_cols;cl_ind++) {
28 		if (cliques->proc[cl_ind] == procinfo->my_id) {
29 			matrix = cliques->d_mats[cl_ind].matrix;
30 			size = cliques->d_mats[cl_ind].size;
31 			for (i=0;i<size;i++) {
32 				matrix[(i*size)+i] = diag[count];
33 				count++;
34 			}
35 		}
36 	}
37 }
38