Hi Daniel,

I think what you want to do is 1d real valued convolution? Have you
looked at PDL::Image2D / PDL::ImageND and the ocnv*  functions?

Reshape your q and t with secnod dim 1 and try conv2d.

Of course you can do rfft1 / irfft1 directly. Instead of using cmul try
a simple *.

Slicing is the same for compex numbers as for real ones. You should get
the latest CPAN/github release since complex numbers handling improved
significantly.

I hope this helps. If you want more specific answers it would help to
give an example of input and desired output.


On 06.06.21 22:45, Daniel Wolfinger wrote:
Hi all,

let me anticipate that I am a Perl novice.
I am currently trying to port a python code, detailed here:
https://github.com/tylerwmarrs/mass-ts/blob/master/mass_ts/_mass_ts.py
<https://github.com/tylerwmarrs/mass-ts/blob/master/mass_ts/_mass_ts.py>,
in particular the function mass().
I am using for this purpose the PDL::FFTW3 module. However, I am
facing a lot of problems.
First of all, look at this part of the python code:

X = np.fft.fft(x)
Y = np.fft.fft(y)
Y.resize(X.shape)
Z = X * Y
z = np.fft.ifft(Z)

In perl, I am doing the following:

my $target = PDL->new([@target]);
my $t = rfft1($target);

my $query = PDL->new([@query]);
my $q= rfft1($query);

my $p = Cmul($t, $q);
my $p2 = ifft1($p);

However, the result that I get is very different from the one I get in
python. Notably, if instead of ifft1 I use irfft1(), the result I
get in perl is identical to the "real" part that I get in python. Why
is ifft1 returning a different result?

Next problem I am encountering is, how can I slice part of a "complex"
piddle? I could not find any function for that.

Any help would be highly appreciated!

Best,
Daniel


_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general
_______________________________________________
pdl-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to