Sorry that you had to add extra bits! Could you PR what you have, and add the 
test code as a comment on the PR? (I’m happy to bend it into the .t)

Best regards,
Ed

From: Luis Mochan<mailto:moc...@icf.unam.mx>
Sent: 15 August 2022 20:23
To: Ed .<mailto:ej...@hotmail.com>
Cc: perldl<mailto:pdl-general@lists.sourceforge.net>; 
perldl<mailto:pdl-de...@lists.sourceforge.net>
Subject: Re: [Pdl-general] conv2d

Thaks Ed,
I modified conv2d as you suggested. The result became a CDouble, but
the imaginary part disappeared. I could fix it by also changing the
init_vars line (around l. 270), removing the variable tmp, which was
declared as a double, and declaring it just before the start of the
broadcastloop using
    $GENERIC() tmp;
However, as I'm not familiar with init_vars, init_map, etc., I'm not
sure what I did is correct. I checked with a few examples that it works for
complex array with real mask, real array with complex mask, and complex
array with complex mask.
Regards,
Luis



On Mon, Aug 15, 2022 at 05:31:01PM +0000, Ed . wrote:
> Hi Luis,
>
> For backward compatibility, operations default to supporting all real types, 
> which is why you’re getting LDouble (the highest-numbered real type, but 
> still below the complex ones). To make the various Image* operations work on 
> native complex values, they just need telling to do so.
>
> Could you try patching Libtmp/Image2D/image2d.pd with this at the top 
> (cribbed from Basic/Ops/ops.pd) before the pp_addpm:
>
> my $A = [ppdefs_all];
>
> Then add “GenericTypes => $A” to at least the pp_def of conv2d, around line 
> 266?
>
> Please let us know if that works (you’d need to do a “make install”, or else 
> a “make basic” then “perl -Mblib yourlocalscript.pl”). If it does, feel like 
> PR-ing an update for all the Image* modules in Libtmp? :-)
>
> Best regards,
> Ed
>
> From: Luis Mochan<mailto:moc...@icf.unam.mx>
> Sent: 15 August 2022 17:39
> To: perldl<mailto:pdl-general@lists.sourceforge.net>; 
> perldl<mailto:pdl-de...@lists.sourceforge.net>
> Subject: [Pdl-general] conv2d
>
> Hello,
> I tried to use conv2d from PDL::Image2D to make a simple average, as in
>     $z->conv2d(ones(3,3))/9;
> to take the arithmetic average a pixel with its neareast
> neighbors. However, what I want to average is a component of an
> electric field which is complex valued. It turns out that conv2d
> doesn't work on complex quantities and the result I obtained was of
> the LDouble type. Having looked further yet.
> Regards,
> Luis
>
> --
>
>                                                                   o
> W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
> Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
> Av. Universidad s/n CP 62210         |                           (*)/\/  \
> Cuernavaca, Morelos, México          | moc...@fis.unam.mx   /\_/\__/
> GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB
>
>
> _______________________________________________
> pdl-general mailing list
> pdl-general@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pdl-general
>

--

                                                                  o
W. Luis Mochán,                      | tel:(52)(777)329-1734     /<(*)
Instituto de Ciencias Físicas, UNAM  | fax:(52)(777)317-5388     `>/   /\
Av. Universidad s/n CP 62210         |                           (*)/\/  \
Cuernavaca, Morelos, México          | moc...@fis.unam.mx   /\_/\__/
GPG: 791EB9EB, C949 3F81 6D9B 1191 9A16  C2DF 5F0A C52B 791E B9EB

_______________________________________________
pdl-general mailing list
pdl-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-general

Reply via email to