<div dir="ltr"><div dir="ltr">On Tue, Dec 8, 2020 at 1:13 PM Roland Richter <<a href="mailto:roland.richter@ntnu.no">roland.richter@ntnu.no</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hei,<br>
<br>
I would like to multiply a row-vector to each row in a dense matrix,<br>
either full or sliced (i.e. if the row-vector is larger than the row<br>
length of the matrix). Armadillo offers a each_row()-function, where I<br>
can iterate over all rows in a matrix and multiply the vector to them<br>
(similar to the operation VecPointwiseMult()). Is there a similar<br>
operation in PETSc? Ideally with the option of only multiplying a<br>
part/slice of the row vector to each row, if the corresponding row of<br>
the target matrix is shorter than the initial row vector.<br></blockquote><div><br></div><div>It helps to write in linear algebra notation so that we can be sure we are talking</div><div>about the same thing. Say we have the matrix A and vector v</div><div><br></div><div>  A = / a b \  v = <m, n></div><div>        \ c d /</div><div><br></div><div>and you want</div><div><br></div><div>  A * m = / ma nb \ = / a b \ / m 0 \ = A . diag(v)</div><div>               \ mc nd /    \ c d /  \ 0  n /</div><div><br></div><div>which you can get using <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatDiagonalScale.html">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatDiagonalScale.html</a></div><div><br></div><div>is that what you want? I do not have a clear picture of what you want slicing for.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Thanks,<br>
<br>
Roland<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>