<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Yes, that would be exactly what I need, I have not thought about
that possibility, thanks!</p>
<p>Concerning slicing: Assumed my matrix A and vector v are defined
by</p>
<p>A = |a b|<br>
|c d|<br>
v = |w x y z|</p>
<p>After v is larger than the row size of A, I only can take some
elements for multiplication and therefore I have to use only a
slice of vector v:</p>
<p>A*v[1:2] = |xa yb|<br>
|xc yd|</p>
<p>or</p>
<p>A*v[0:1] = |wa xb|<br>
|wc xd|</p>
<p>How could I do that?</p>
<p>Thanks,</p>
<p>Roland<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">Am 08.12.2020 um 19:26 schrieb Matthew
Knepley:<br>
</div>
<blockquote type="cite"
cite="mid:CAMYG4G=bQtqDqTsj3+RtOMgmSURqbcJ=Any5TFmraMR6GwHcvA@mail.gmail.com">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div dir="ltr">On Tue, Dec 8, 2020 at 1:13 PM Roland Richter
<<a href="mailto:roland.richter@ntnu.no"
moz-do-not-send="true">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"
moz-do-not-send="true">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" moz-do-not-send="true">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</body>
</html>