[petsc-users] ADDing a row to another one

Sr. Yo ventejuy at yahoo.es
Thu Dec 31 07:05:37 CST 2009


Hi all,
I'm trying to ADD(sum) a row into another on sparce matrix. I was looking for a function on PETSC documentation but no luck, so now a get the entire row to a PetscScalar and them ADD it to another row. It works but is slow, not elegant and no good for a sparce matrix. So, is there a smart way to do this?.

Thanks.

PD: the actual code is similar to ...

// N_N --> number of columns of the matrix
// fileHomo --> ifstream to a text file
// *valor --> PetscScalar pointer;
for(int i=0; i<N_N; i++) ptrFila[i]=i;
for(int i=0; i<N_H; i++){
        fileHomo >> n1 >> n2;
        // getting the entire row "n2" to valor
        ierr=MatGetValues(Pm_global,1,&n2,N_N,ptrFila,valor);CHKERRQ(ierr);
        // adding valor to "n1" row
        ierr=MatSetValues(Pm_global,1,&n1,N_N,ptrFila,valor,ADD_VALUES);CHKERRQ(ierr);
        MatAssemblyBegin(Pm_global,MAT_FINAL_ASSEMBLY);
        MatAssemblyEnd(Pm_global,MAT_FINAL_ASSEMBLY);
}




      


More information about the petsc-users mailing list