static char help[] = "Reads a PETSc matrix and vector from a file; expands the matrix with the vector\n\n"; /* 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) { PetscInt n,i,*cnt,*indices,nc; const PetscInt *aj; const PetscScalar *vv,*aa; PetscFunctionBegin; PetscCall(MatGetSize(A,&n,NULL)); PetscCall(VecGetArrayRead(v,&vv)); PetscCall(PetscMalloc1(n,&indices)); for (i=0; i