Hello Luis,
the results look fine when the expected types in the two failing tests
are adjusted. Don't know if it would break any "real" code, maybe
"is_pdl" is just too strict here.
t/ufunc.t:
is_pdl $empty->magnover, sbyte('BAD'), "bad flag gets set on empty magnover";
is_pdl +(sequence(4)+i())->magnover, double(4.242640), 'magnover
correct for complex';
Best regards,
-jo
On Wed 23 Jul 2025 04:52:24 AM CEST, Luis Mochan <moc...@icf.unam.mx> wrote:
Hello,
In some of my programs I used the code such as
$abs=$cvec->abs2->sumover->sqrt;
to get the magnitude of a vector $cvec. I just replaced it to the cleaner
$abs=$cvec->magnover;
But then my program failed when I made the comparison
if($abs > 0){...}
with the message
Can't compare complex numbers at lib/PDL/PP.pm line 1445.
It is true that we shouldn't compare complex numbers, except for
equality, but, shouldn't the magnitude of a complex vector be a real
number instead of a complex number (with zero imaginary part)?
I tried to fix it by replacing the qualifier 'float+' in the pp_def of
magnover in Ufunc.pd by the qualifier 'real', but then the tests fail
as bytes are not converted to floats.
Best regards,
Luis
_______________________________________________
pdl-devel mailing list
pdl-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pdl-devel