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.nn";
5: #include petscmat.h
6: #include petscpc.h
8: int main(int argc,char **args)
9: {
10: Mat C;
11: int i[2],j[2],ierr;
12: PetscScalar v[] = {1.0,2.0,3.0,4.0};
13: Vec x;
15: PetscInitialize(&argc,&args,(char *)0,help);
17: MatCreate(PETSC_COMM_WORLD,PETSC_DECIDE,PETSC_DECIDE,3,3,&C);
18: MatSetFromOptions(C);
19: VecCreateSeq(PETSC_COMM_WORLD,3,&x);
20:
21: i[0] = 1; i[1] = -1; j[0] = 1; j[1] = 2;
22: MatSetValues(C,2,i,2,j,v,INSERT_VALUES);
23: MatSetValues(C,2,j,2,i,v,INSERT_VALUES);
24: VecSetValues(x,2,i,v,INSERT_VALUES);
25:
26: MatAssemblyBegin(C,MAT_FINAL_ASSEMBLY);
27: MatAssemblyEnd(C,MAT_FINAL_ASSEMBLY);
29: MatView(C,PETSC_VIEWER_STDOUT_WORLD);
30: VecView(x,PETSC_VIEWER_STDOUT_WORLD);
32: VecDestroy(x);
33: MatDestroy(C);
35: PetscFinalize();
36: return 0;
37: }
39: