static char help[] = "Reads a PETSc matrix and vector from a file; expands the matrix with the vector\n\n"; /*T Concepts: Mat^ordering a matrix - loading a binary matrix and vector; Concepts: Mat^loading a binary matrix and vector; Concepts: Vectors^loading a binary vector; Concepts: PetscLog^preloading executable Processors: 1 T*/ /* Include "petscmat.h" so that we can use matrices. automatically includes: petscsys.h - base PETSc routines petscvec.h - vectors petscmat.h - matrices petscis.h - index sets petscviewer.h - viewers */ #include /* Adds a new column and row to the vector (the last) containing the vector */ PetscErrorCode PadMatrix(Mat A,Vec v,PetscScalar c,Mat *B) { PetscErrorCode ierr; PetscInt n,i,*cnt,*indices,nc; const PetscInt *aj; const PetscScalar *vv,*aa; PetscFunctionBegin; ierr = MatGetSize(A,&n,NULL);CHKERRQ(ierr); ierr = VecGetArrayRead(v,&vv);CHKERRQ(ierr); ierr = PetscMalloc1(n,&indices);CHKERRQ(ierr); for (i=0; i