[petsc-users] Problem in MatSetValues

Eda Oktay eda.oktay at metu.edu.tr
Mon Mar 11 07:26:46 CDT 2019


Hello,

I have a following part of a code which tries to change the nonzero values
of matrix L with -1. However in MatSetValues line, something happens and
some of the values in matrix turns into 1.99665e-314 instead of -1. Type of
arr is defined as PetscScalar and arr is produced correctly. What can be
the problem, is there a mistake about types?

Thanks,

Eda


for(rw = mm; rw<nn; ++rw){

            ierr = MatGetRow(L,rw,&ncols,&cols,&vals);CHKERRQ(ierr);

            s = sizeof(vals);

            ierr = PetscMalloc1(s,&arr);CHKERRQ(ierr);

            for(j=0;j<s;++j){

                arr[j]=-1.0;
            }
            ierr =
MatSetValues(NSymmA,1,&rw,ncols,cols,arr,INSERT_VALUES);CHKERRQ(ierr);
            ierr = MatRestoreRow(L,rw,&ncols,&cols,&vals);CHKERRQ(ierr);
        }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190311/3b53659f/attachment.html>


More information about the petsc-users mailing list