#include "BSprivate.h"

/*@ BSset_diag - Set the diagonal of A to a constant

    Input Parameters:
.   A - a sparse matrix
.   my_alpha - the constant
.   procinfo - the usual processor stuff

    Output Parameters:
.   A - a sparse matrix with the diagonal set to my_alpha

    Returns:
    void

    Notes:  In the nonsymmetric case we set the diagonal +/-my_alpha
    depending on the sign of the diagonal.

 @*/
/* Set the diagonal of the matrix to my_alpha */
void BSset_diag(BSpar_mat *A, FLOAT my_alpha, BSprocinfo *procinfo)
{
	int	i;
	FLOAT	*matrix;
	int	cl_ind, size;
	BScl_2_inode *cliques;

	cliques = A->clique2inode;
	for (cl_ind=0;cl_ind<cliques->num_cols;cl_ind++) {
		if (cliques->proc[cl_ind] == procinfo->my_id) {
			matrix = cliques->d_mats[cl_ind].matrix;
			size = cliques->d_mats[cl_ind].size;
			if(A->icc_storage) {
				for (i=0;i<size;i++) {
					matrix[(i*size)+i] = my_alpha;
				}
			} else {
				for (i=0;i<size;i++) {
					if (matrix[(i*size)+i] < 0.0)
						matrix[(i*size)+i] = -my_alpha;
					else
						matrix[(i*size)+i] = my_alpha;
				}
			}
		}
	}
}


syntax highlighted by Code2HTML, v. 0.9.1