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