[petsc-users] Transform of algorithm containing zgemv/FFT/Slicing into PETSc-functions

Roland Richter roland.richter at ntnu.no
Mon Dec 14 17:18:08 CST 2020


Dear all,

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):

Assumed I have matrices A and B, defined as

A =  |aa ab ac ad|
        |ae af ag ah|
        |ai aj ak al|

B =  |ba bb bc|
        |be bf bg|
        |bi bj bk|

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).

Moreover, I have vectors x and y, with x defined as

x = |xa xb xc xd|

and y defined as

y = |ya yb yc|

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.

Now, the transformation can be described as

  * Set all values in A to zero
  * Copy B into A with an offset of a0:
      o A(a0 = 1) = |0 ba bb bc|
                            |0 be bf bg|
                            |0 bi bj bk|
  * Multiply every row in A elementwise with y, including offset,
    resulting in
      o A(a0 = 1) = |0 ba*ya bb*yb bc*yc|
                            |0 be*ya bf*yb bg*yc|
                            |0 bi*ya bj*yb bk*yc|
  * Apply a 1d-FFT over each row of A, resulting in A'
  * Multiply every row in A' elementwise with x, resulting in
      o A'(a0 = 1) = |aa'*xa (ba*ya)'*xb (bb*yb)'*xc (bc*yc)'*xd|
                            |ae'*xa (be*ya)'*xb (bf*yb)'*xc (bg*yc)'*xd|
                            |ai'*xa (bi*ya)'*xb (bj*yb)'*xc (bk*yc)'*xd|

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.

Thanks!

Roland

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20201215/a3d63ccc/attachment.html>


More information about the petsc-users mailing list