Thank you so much! Eda
Zhang, Hong <hongzh...@anl.gov>, 2 Tem 2020 Per, 07:29 tarihinde şunu yazdı: > > Dense matrix is stored in column-major order, so you might want to use > MatGetColumnVector() to access columns of the matrix instead of the rows. For > instance, you can get the n-th column out of the matrix and place it into a > vector that shares the same parallel layout as the matrix with the following: > > MatDenseGetColumn(J,n,&xarr); > VecPlaceArray(vec,xarr); > ... > VecResetArray(vec); > MatDenseRestoreColumn(J,&xarr); > > Hong (Mr.) > > On Jun 10, 2020, at 8:08 AM, Eda Oktay <eda.ok...@metu.edu.tr> wrote: > > Dear Matt, > > Matthew Knepley <knep...@gmail.com>, 10 Haz 2020 Çar, 16:03 tarihinde > şunu yazdı: > > > On Wed, Jun 10, 2020 at 8:56 AM Eda Oktay <eda.ok...@metu.edu.tr> wrote: > > > Hi all, > > I am trying to get all the rows of a parallel matrix as individual > vectors. For instance, if I have 72*4 matrix, I want to get 72 > different vectors having size 4. > > As far as I understood, MatGetRow is only for local rows, so > MatGetOwnershipRange is used, however, when I tried this one, I > couldn't get the whole and desired row vectors. > > In MatGetRow explanation, it is written that I should use > MatCreateSubMatrices first, then use MatGetRow. But I couldn't > understand to which extent I should create submatrices. I just need to > have all 72 rows as 72 different vectors each having 4 elements. > > > > 1) For sparse matrices, the storage is always divided by row, so that values > can only be retrieved for local rows with MatGetRow() > > 2) Is this matrix sparse? It sounds like it is dense. > > > Matrix is dense. > > > 3) Are you asking to get all matrix values on all processes? If so, I think > the easiest thing to do is first wrap a Vec around the > values, then use VecScatterToAll(), then wrap each one in a MatDense again. > > > Yes, I want all row vectors on all processes. In a dense matrix, > should I still wrap a Vec around the values? I know I should use > scatter but I couldn't even wrap a Vec around them. > > Thanks so much! > > Eda > > > Thanks, > > Matt > > > Thanks! > > Eda > > > > > -- > 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/ > >