Actual source code: ex70.c

  2: static char help[] = "Tests Vec/MatSetValues() with negative row and column indices.\n\n";

 4:  #include petscmat.h
 5:  #include petscpc.h

  9: int main(int argc,char **args)
 10: {
 11:   Mat            C;
 12:   PetscInt       i[2],j[2];
 14:   PetscScalar    v[] = {1.0,2.0,3.0,4.0};
 15:   Vec            x;

 17:   PetscInitialize(&argc,&args,(char *)0,help);

 19:   MatCreate(PETSC_COMM_WORLD,PETSC_DECIDE,PETSC_DECIDE,3,3,&C);
 20:   MatSetFromOptions(C);
 21:   VecCreateSeq(PETSC_COMM_WORLD,3,&x);
 22: 
 23:   i[0] = 1; i[1] = -1; j[0] = 1; j[1] = 2;
 24:   MatSetValues(C,2,i,2,j,v,INSERT_VALUES);
 25:   MatSetValues(C,2,j,2,i,v,INSERT_VALUES);
 26:   VecSetValues(x,2,i,v,INSERT_VALUES);
 27: 
 28:   MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
 29:   MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);

 31:   MatView(C,PETSC_VIEWER_STDOUT_WORLD);
 32:   VecView(x,PETSC_VIEWER_STDOUT_WORLD);

 34:   VecDestroy(x);
 35:   MatDestroy(C);

 37:   PetscFinalize();
 38:   return 0;
 39: }

 41: