static char help[] = "Test MatCreate() with MAT_STRUCTURE_ONLY .\n\n"; #include int main(int argc,char **argv) { Mat mat; PetscInt m = 7,n,i,j,rstart,rend; PetscMPIInt size; PetscScalar v; PetscBool struct_only=PETSC_TRUE; PetscCall(PetscInitialize(&argc,&argv,(char*)0,help)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); PetscCheck(size == 1,PETSC_COMM_WORLD,PETSC_ERR_WRONG_MPI_SIZE,"This is a uniprocessor example only!"); PetscCall(PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD,PETSC_VIEWER_ASCII_COMMON)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-m",&m,NULL)); PetscCall(PetscOptionsGetBool(NULL,NULL,"-struct_only",&struct_only,NULL)); n = m; /* ------- Assemble matrix, test MatValid() --------- */ PetscCall(MatCreate(PETSC_COMM_WORLD,&mat)); PetscCall(MatSetSizes(mat,PETSC_DECIDE,PETSC_DECIDE,m,n)); PetscCall(MatSetFromOptions(mat)); if (struct_only) { PetscCall(MatSetOption(mat,MAT_STRUCTURE_ONLY,PETSC_TRUE)); } PetscCall(MatSetUp(mat)); PetscCall(MatGetOwnershipRange(mat,&rstart,&rend)); for (i=rstart; i