[petsc-dev] VecGetArrayRead vs. VecGetArrayPrivate

Barry Smith bsmith at mcs.anl.gov
Tue Nov 23 08:21:49 CST 2010


On Nov 23, 2010, at 8:15 AM, Jed Brown wrote:

> On Tue, Nov 23, 2010 at 15:10, Barry Smith <bsmith at mcs.anl.gov> wrote:
> You misunderstand. VecNorm()
                                        ^^^^^^^^^^^^^^^^  VecScale()

> would still be calling the update cache business,. the only difference is it would get the cached values before the (*v->scale)(...) call and set them back into the Vec after the (*v->scale)(...)
> 
> VecNorm just reads the cache, you must mean that VecScale pulls out the cached values as

   Yes, sorry, mistyped the name of that function.

> 
>     /*
>      * Update cached data
>      */
>     for (i=0; i<4; i++) {
>       ierr = PetscObjectComposedDataGetReal((PetscObject)x,NormIds[i],norms[i],flgs[i]);CHKERRQ(ierr);
>     }
> 
>     ierr = (*x->ops->scale)(x,alpha);CHKERRQ(ierr); /* state is increased here */
> 
>     for (i=0; i<4; i++) {
>       if (flgs[i]) {
>         ierr = PetscObjectComposedDataSetReal((PetscObject)x,NormIds[i],PetscAbsScalar(alpha)*norms[i]);CHKERRQ(ierr);
>       }
>     }
> 




More information about the petsc-dev mailing list