Date: 2013-07-02T14:40:14+00:00

Actual source code: ex35.c
petsc-3.4.2 2013-07-02

      2: static char help[] = "Test VecGetArray4d()\n";

      4: #include <petscvec.h>

      8: int main(int argc,char **argv)
      9: {
     11:   PetscInt       cnt,i,j,k,l,m = 2,n = 3,p = 4,q = 5;
     12:   Vec            x;
     13:   PetscScalar    ****xx;

     15:   PetscInitialize(&argc,&argv,(char*)0,help);
     16:   VecCreateSeq(PETSC_COMM_WORLD,m*n*p*q,&x);
     17:   VecGetArray4d(x,m,n,p,q,0,0,0,0,&xx);
     18:   cnt  = 0;
     19:   for (i=0; i<m; i++)
     20:     for (j=0; j<n; j++)
     21:       for (k=0; k<p; k++)
     22:         for (l=0; l<q; l++)
     23:           xx[i][j][k][l] = cnt++;

     25:   VecRestoreArray4d(x,m,n,p,q,0,0,0,0,&xx);
     26:   VecView(x,PETSC_VIEWER_STDOUT_WORLD);
     27:   VecDestroy(&x);
     28:   PetscFinalize();
     29:   return 0;
     30: }