1*7fb60732SBarry Smith 2*7fb60732SBarry Smith static char help[] = "Tests MatTranspose() with MAT_REUSE_MATRIX and different nonzero pattern\n\n"; 3*7fb60732SBarry Smith 4*7fb60732SBarry Smith #include <petscmat.h> 5*7fb60732SBarry Smith 6*7fb60732SBarry Smith int main(int argc,char **argv) 7*7fb60732SBarry Smith { 8*7fb60732SBarry Smith Mat A,B; 9*7fb60732SBarry Smith PetscMPIInt size; 10*7fb60732SBarry Smith 11*7fb60732SBarry Smith PetscCall(PetscInitialize(&argc,&argv,(char*) 0,help)); 12*7fb60732SBarry Smith PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); 13*7fb60732SBarry Smith PetscCheck(size == 1,PETSC_COMM_WORLD,PETSC_ERR_WRONG_MPI_SIZE,"This is a uniprocessor example only!"); 14*7fb60732SBarry Smith PetscCall(MatCreateSeqAIJ(PETSC_COMM_SELF,2,2,2,NULL,&A)); 15*7fb60732SBarry Smith PetscCall(MatSetValue(A,0,0,1.0,INSERT_VALUES)); 16*7fb60732SBarry Smith PetscCall(MatSetValue(A,0,1,2.0,INSERT_VALUES)); 17*7fb60732SBarry Smith PetscCall(MatSetValue(A,1,1,4.0,INSERT_VALUES)); 18*7fb60732SBarry Smith PetscCall(MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY)); 19*7fb60732SBarry Smith PetscCall(MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY)); 20*7fb60732SBarry Smith PetscCall(MatView(A,PETSC_VIEWER_STDOUT_SELF)); 21*7fb60732SBarry Smith PetscCall(MatTranspose(A,MAT_INITIAL_MATRIX,&B)); 22*7fb60732SBarry Smith PetscCall(MatView(B,PETSC_VIEWER_STDOUT_SELF)); 23*7fb60732SBarry Smith PetscCall(MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE)); 24*7fb60732SBarry Smith PetscCall(MatSetValue(A,1,0,3.0,INSERT_VALUES)); 25*7fb60732SBarry Smith PetscCall(MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY)); 26*7fb60732SBarry Smith PetscCall(MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY)); 27*7fb60732SBarry Smith PetscCall(MatView(A,PETSC_VIEWER_STDOUT_SELF)); 28*7fb60732SBarry Smith PetscCall(MatTranspose(A,MAT_REUSE_MATRIX,&B)); 29*7fb60732SBarry Smith PetscCall(MatView(B,PETSC_VIEWER_STDOUT_SELF)); 30*7fb60732SBarry Smith PetscCall(MatDestroy(&A)); 31*7fb60732SBarry Smith PetscCall(MatDestroy(&B)); 32*7fb60732SBarry Smith PetscCall(PetscFinalize()); 33*7fb60732SBarry Smith return 0; 34*7fb60732SBarry Smith } 35*7fb60732SBarry Smith 36*7fb60732SBarry Smith /*TEST 37*7fb60732SBarry Smith 38*7fb60732SBarry Smith test: 39*7fb60732SBarry Smith 40*7fb60732SBarry Smith TEST*/ 41