<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Dear all,</p>
<p>I am currently working on the transformation of an algorithm
implemented using armadillo into PETSc. It is a forward/backward
transformation, and boils down to the following steps (for the
forward transformation):</p>
<p>Assumed I have matrices A and B, defined as <br>
</p>
<p>A = |aa ab ac ad|<br>
|ae af ag ah|<br>
|ai aj ak al|</p>
<p>B = |ba bb bc|<br>
|be bf bg|<br>
|bi bj bk|</p>
<p>with the number of rows in A and B always equal, but number of
columns in B always less or equal than half the number of columns
in A (Example here is only for demonstration, I am aware of that 3
is not smaller or equal than 2).</p>
<p>Moreover, I have vectors x and y, with x defined as</p>
<p>x = |xa xb xc xd|</p>
<p>and y defined as <br>
</p>
<p>y = |ya yb yc|</p>
<p>The number of elements in x corresponds to the number of columns
in A, and the number of elements y accordingly correspond to the
number of columns in B.</p>
<p>Now, the transformation can be described as</p>
<ul>
<li>Set all values in A to zero</li>
<li>Copy B into A with an offset of a0:</li>
<ul>
<li>A(a0 = 1) = |0 ba bb bc|<br>
|0 be bf bg|<br>
|0 bi bj bk|</li>
</ul>
<li>Multiply every row in A elementwise with y, including offset,
resulting in</li>
<ul>
<li>A(a0 = 1) = |0 ba*ya bb*yb bc*yc|<br>
|0 be*ya bf*yb bg*yc|<br>
|0 bi*ya bj*yb bk*yc|</li>
</ul>
<li>Apply a 1d-FFT over each row of A, resulting in A'<br>
</li>
<li>Multiply every row in A' elementwise with x, resulting in <br>
</li>
<ul>
<li>A'(a0 = 1) = |aa'*xa (ba*ya)'*xb (bb*yb)'*xc (bc*yc)'*xd|<br>
|ae'*xa (be*ya)'*xb (bf*yb)'*xc
(bg*yc)'*xd|<br>
|ai'*xa (bi*ya)'*xb (bj*yb)'*xc
(bk*yc)'*xd|</li>
</ul>
</ul>
<p>Based on earlier questions, I already know how to apply a vector
to each row of a matrix (by using .diag()) and how to apply an FFT
over each row of a distributed matrix by using FFTW. Still, I am
not aware of a method for copying B into A with an offset, and
therefore I would have to iterate over each row for the copy
process, which might slow down the process. Therefore, is there a
way I could make this process more efficient using the built-in
functions in PETSc? Unfortunately, I am not that familiar with all
the functions yet.</p>
<p>Thanks!</p>
<p>Roland<br>
</p>
</body>
</html>