xref: /petsc/src/mat/tests/ex179.c (revision 732aec7a18f2199fb53bb9a2f3aef439a834ce31)
17fb60732SBarry Smith static char help[] = "Tests MatTranspose() with MAT_REUSE_MATRIX and different nonzero pattern\n\n";
27fb60732SBarry Smith 
37fb60732SBarry Smith #include <petscmat.h>
47fb60732SBarry Smith 
main(int argc,char ** argv)5d71ae5a4SJacob Faibussowitsch int main(int argc, char **argv)
6d71ae5a4SJacob Faibussowitsch {
77fb60732SBarry Smith   Mat         A, B;
87fb60732SBarry Smith   PetscMPIInt size;
97fb60732SBarry Smith 
10*c8025a54SPierre Jolivet   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
117fb60732SBarry Smith   PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
127fb60732SBarry Smith   PetscCheck(size == 1, PETSC_COMM_WORLD, PETSC_ERR_WRONG_MPI_SIZE, "This is a uniprocessor example only!");
137fb60732SBarry Smith   PetscCall(MatCreateSeqAIJ(PETSC_COMM_SELF, 2, 2, 2, NULL, &A));
147fb60732SBarry Smith   PetscCall(MatSetValue(A, 0, 0, 1.0, INSERT_VALUES));
157fb60732SBarry Smith   PetscCall(MatSetValue(A, 0, 1, 2.0, INSERT_VALUES));
167fb60732SBarry Smith   PetscCall(MatSetValue(A, 1, 1, 4.0, INSERT_VALUES));
177fb60732SBarry Smith   PetscCall(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY));
187fb60732SBarry Smith   PetscCall(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY));
197fb60732SBarry Smith   PetscCall(MatView(A, PETSC_VIEWER_STDOUT_SELF));
207fb60732SBarry Smith   PetscCall(MatTranspose(A, MAT_INITIAL_MATRIX, &B));
217fb60732SBarry Smith   PetscCall(MatView(B, PETSC_VIEWER_STDOUT_SELF));
227fb60732SBarry Smith   PetscCall(MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE));
237fb60732SBarry Smith   PetscCall(MatSetValue(A, 1, 0, 3.0, INSERT_VALUES));
247fb60732SBarry Smith   PetscCall(MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY));
257fb60732SBarry Smith   PetscCall(MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY));
267fb60732SBarry Smith   PetscCall(MatView(A, PETSC_VIEWER_STDOUT_SELF));
277fb60732SBarry Smith   PetscCall(MatTranspose(A, MAT_REUSE_MATRIX, &B));
287fb60732SBarry Smith   PetscCall(MatView(B, PETSC_VIEWER_STDOUT_SELF));
297fb60732SBarry Smith   PetscCall(MatDestroy(&A));
307fb60732SBarry Smith   PetscCall(MatDestroy(&B));
317fb60732SBarry Smith   PetscCall(PetscFinalize());
327fb60732SBarry Smith   return 0;
337fb60732SBarry Smith }
347fb60732SBarry Smith 
357fb60732SBarry Smith /*TEST
367fb60732SBarry Smith 
377fb60732SBarry Smith    test:
387fb60732SBarry Smith 
397fb60732SBarry Smith TEST*/
40