On Mon, May 24, 2021 at 9:19 PM Matthew Knepley <[email protected]> wrote:
> On Mon, May 24, 2021 at 9:08 PM Salazar De Troya, Miguel via petsc-users < > [email protected]> wrote: > >> Hello, >> >> >> >> I am simply interested in obtaining a vector with x_i = \sum_j | A_{i, j} >> | for each row āiā in the matrix A. I found MatGetColumnNorms(), but no row >> version. I am wondering if it is more efficient to calculate the transpose >> A^T and then MatGetColumnNorms() or maybe iterate through each row with >> MatGetRow() and calculate \sum_j | A_{i, j} | by hand by myself. >> > > Vec ones, sums; > > MatCreateVecs(A, &ones, &sums); > VecSet(ones, 1.0); > MatMult(A, ones, sums); > VecDestroy(&ones); > VecDestroy(&sums); > This does the row sum, not the absolute value. If you want the absolute value, you can just call MatGetRow() and sum the values. Thanks, Matt > Thanks, > > Matt > > >> >> >> Thanks >> >> Miguel >> >> >> >> Miguel A. Salazar de Troya >> >> Postdoctoral Researcher, Lawrence Livermore National Laboratory >> >> B141 >> >> Rm: 1085-5 >> >> Ph: 1(925) 422-6411 >> > > > -- > 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/> > -- 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/>
