Actual source code: ex70.c
1: /*$Id: ex70.c,v 1.13 2001/08/07 03:03:07 balay Exp $*/
3: static char help[] = "Tests Vec/MatSetValues() with negative row and column indices.\n\n";
5: #include petscmat.h
6: #include petscpc.h
10: int main(int argc,char **args)
11: {
12: Mat C;
13: int i[2],j[2],ierr;
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: