static char help[] = "Tests converting a matrix to another format with MatConvert().\n\n"; #include int main(int argc,char **args) { Mat C,A; PetscInt i,j,m = 5,n = 4,Ii,J; PetscMPIInt rank,size; PetscScalar v; char mtype[256]; PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); /* This example does not work correctly for np > 2 */ PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); PetscCheck(size <= 2,PETSC_COMM_WORLD,PETSC_ERR_WRONG_MPI_SIZE,"Use np <= 2"); /* Create the matrix for the five point stencil, YET AGAIN */ PetscCall(MatCreate(PETSC_COMM_WORLD,&C)); PetscCall(MatSetSizes(C,PETSC_DECIDE,PETSC_DECIDE,m*n,m*n)); PetscCall(MatSetFromOptions(C)); PetscCall(MatSetUp(C)); for (i=0; i0) {J = Ii - n; PetscCall(MatSetValues(C,1,&Ii,1,&J,&v,INSERT_VALUES));} if (i0) {J = Ii - 1; PetscCall(MatSetValues(C,1,&Ii,1,&J,&v,INSERT_VALUES));} if (j