On Thu, Jun 18, 2020 at 4:22 PM Rakesh Halder <rhal...@umich.edu> wrote:
> Hi all, > > I'm writing an algorithm using PETSc that requires part of an (N x k) > matrix, where k << N. Specifically, my algorithm loops from j = 1 to k, and > uses j columns of the matrix of a time. I've been creating a new matrix for > each iteration, and use MatGetColumnVector to get the values for each > column vector, scatter them into a new vector, and then use MatSetValue to > populate my matrix. MatGetColumnVector is very slow, and I was thinking of > using MatCreateSubMatrix. However, I'm not entirely sure how to get the > correct IS that would allow me to create a submatrix using the first j > columns of the matrix at a time. I'm running in parallel, and the matrix is > an MPIAIJ matrix. I've looked at examples of MatCreateSubMatrix as well as > examples including the use of IS, but I'm still not very sure how to use > them. > Use a ISStride of [0, N) for an MxN matrix for the column IS and you will get everything in the row, which is what you want. Thanks, Matt > Thanks, > > Rakesh > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>