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