[petsc-users] Getting access to matrix rows without and setting values simultaneously

Alexander Grayver agrayver at gfz-potsdam.de
Thu Jun 16 05:59:24 CDT 2011


Sorry for weird subject. The problem is very simple actually. I have big 
distributed dense matrix and I want to change the element of this matrix 
without copying whole matrix.
If I do it this way:

   call MatGetOwnershipRange(A,istart,iend,ierr);CHKERRQ(ierr)
   do i=istart,iend-1
     ! get one row from A
     rowidx(1) = i
     call MatGetRow(A,i,nvals,cols,vals,ierr);CHKERRQ(ierr);

     ! transform all elements in the row
     do j=1,nvals
        transformedvals(j) = func(vals(j))

     ! store transformed elements
     call MatRestoreRow(A,i,nvals,cols,vals,ierr);CHKERRQ(ierr);

It tells me that I can't use MatGetRow/MatRestoreRow and MatSetValues at 
the same time. So, what would be the better way of doing this?
Maybe MatGetArrayF90? I would like to try it but don't find the 
description of output element arrays.


More information about the petsc-users mailing list