Actual source code: ex100.c
2: static char help[] = "Tests various routines in MatMAIJ format.\n";
4: #include <petscmat.h>
5: #define IMAX 15
6: int main(int argc,char **args)
7: {
8: Mat A,B,MA;
9: PetscViewer fd;
10: char file[PETSC_MAX_PATH_LEN];
11: PetscInt m,n,M,N,dof=1;
12: PetscMPIInt rank,size;
13: PetscBool flg;
15: PetscInitialize(&argc,&args,(char*)0,help);
16: MPI_Comm_rank(PETSC_COMM_WORLD,&rank);
17: MPI_Comm_size(PETSC_COMM_WORLD,&size);
19: /* Load aij matrix A */
20: PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),&flg);
22: PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd);
23: MatCreate(PETSC_COMM_WORLD,&A);
24: MatLoad(A,fd);
25: PetscViewerDestroy(&fd);
27: /* Get dof, then create maij matrix MA */
28: PetscOptionsGetInt(NULL,NULL,"-dof",&dof,NULL);
29: MatCreateMAIJ(A,dof,&MA);
30: MatGetLocalSize(MA,&m,&n);
31: MatGetSize(MA,&M,&N);
33: if (size == 1) {
34: MatConvert(MA,MATSEQAIJ,MAT_INITIAL_MATRIX,&B);
35: } else {
36: MatConvert(MA,MATMPIAIJ,MAT_INITIAL_MATRIX,&B);
37: }
39: /* Test MatMult() */
40: MatMultEqual(MA,B,10,&flg);
42: /* Test MatMultAdd() */
43: MatMultAddEqual(MA,B,10,&flg);
46: /* Test MatMultTranspose() */
47: MatMultTransposeEqual(MA,B,10,&flg);
50: /* Test MatMultTransposeAdd() */
51: MatMultTransposeAddEqual(MA,B,10,&flg);
54: MatDestroy(&MA);
55: MatDestroy(&A);
56: MatDestroy(&B);
57: PetscFinalize();
58: return 0;
59: }
61: /*TEST
63: build:
64: requires: !complex
66: test:
67: nsize: {{1 3}}
68: requires: datafilespath !complex double !defined(PETSC_USE_64BIT_INDICES)
69: args: -f ${DATAFILESPATH}/matrices/arco1 -dof {{1 2 3 4 5 6 8 9 16}} -viewer_binary_skip_info
71: TEST*/