Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type-detection is wrong for complex Pars, and converted [o] Pars in flowing transforms don't work #511

Open
mohawk2 opened this issue Dec 19, 2024 · 0 comments

Comments

@mohawk2
Copy link
Member

mohawk2 commented Dec 19, 2024

This is discussed in https://pdl.perl.org/advent/blog/2024/12/20/pdl-internals/

Type detection

The type-detection broke PDL::FFTW3's real -> native complex FFT. The latest has a workaround that avoids using type_coerce. As noted in the article above, the type-detection should correctly detect including for complex Pars, though that should be fixed last after the other issue.

The type-detection should prioritise outputs over inputs, since the final results after any potential type-converting will be dictated by them anyway (putting aside questions of operating at higher precision to get more accurate results).

Type-detection could be simplified in the one-type case by detecting there's only one type, and just picking that.

Type conversion

When an output must be converted, because its type isn't an available option for that xform, then pdl_converttypei_new would be called with the ndarray params the non-usual way round, with the input null's datatype being set to the xform's, and the output being the original supplied input. In the case where it already has a trans_parent, this would instead cause an error.

xform inputs from Perl values being made into ndarrays too soon, and thus having a type assigned that requires converting

The XS code part of xforms could be enhanced to analyse the supplied Perl parameters, and use the xform spec to determine the required type for each. It could then make ndarrays out of the Perl values with the required type, avoiding the need for conversion.

A further benefit from that would be in generating versions of readdata (backward dataflow wouldn't make sense) that only processed Perl SVs, which would avoid overhead in the Perl-value-only scenario (and allow removing the PMCode for log10).

Other thoughts

  • For generated redodims/readdata/writebackdata functions, they should merge the indx and either long or longlong case, since they are functionally identical and it's a bit less code to generate.
  • non-[o] OtherPars should be copied into stack vars at the start of r/w functions, and be forced as rvalues.
mohawk2 added a commit to mohawk2/perl-PDL-IO-Touchstone that referenced this issue Dec 20, 2024
mohawk2 added a commit to PDLPorters/perl5-PGPLOT that referenced this issue Dec 20, 2024
mohawk2 added a commit to mohawk2/PDL-HMM that referenced this issue Dec 20, 2024
mohawk2 added a commit to jlapeyre/PDL-Fit-Levmar that referenced this issue Dec 20, 2024
mohawk2 added a commit to EntropyOrg/p5-Data-Frame that referenced this issue Dec 20, 2024
mohawk2 added a commit to mohawk2/perl5-Test2-Tools-PDL that referenced this issue Dec 20, 2024
mohawk2 added a commit to mohawk2/Photonic that referenced this issue Dec 20, 2024
mohawk2 added a commit to mohawk2/Photonic that referenced this issue Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant