Skip to content

Conversation

cval26
Copy link
Contributor

@cval26 cval26 commented Aug 4, 2020

ENH: add Chebyshev (cosine) transforms implemented via FFTs

This PR adds the two 1D Chebyshev transform functions chebyfft and ichebyfft into the numpy.fft module, utilizing the real FFTs rfft and irfft, respectively. As far as I understand, pockefft does not support cosine transforms natively; for this reason, an even extension of the input vector is constructed, whose real FFT corresponds to a cosine transform.

The motivation behind these two additions is the ability to quickly perform direct and inverse Chebyshev transforms with numpy, without the need to write scripts that do the necessary (although minor) modifications. Chebyshev transforms are used often e.g. in the spectral integration of PDE problems; thus, I believe having them implemented in numpy would be useful to many people in the community.

I will also post a message to the mailing list to probe interest and gather feedback from more people that are potentially interested in such a feature. In addition, proper tests should be included to make sure the functions work properly, something that I haven't done yet.

@seberg @peterbell10 @leofang @grlee77

@rossbar
Copy link
Contributor

rossbar commented Aug 4, 2020

scipy.fft includes the DCT and DST already and if new functions were going to be considered to be added to NumPy, consistency with scipy.fft would be a prime consideration. Also, I think it's generally best to float a feature proposal along these lines to the mailing list!

@rgommers
Copy link
Member

rgommers commented Aug 4, 2020

Agreed, this is definitely out of scope for numpy.fft, but can be considered for scipy.fft. A bit more rationale on applications, and adding one or more references in the docstring to papers on Chebyshev FFT so we can see this is used would be useful as well.

@rgommers
Copy link
Member

rgommers commented Aug 4, 2020

Chebyshev transforms are used often e.g. in the spectral integration of PDE problems

this is useful, for SciPy a criterion is that there need to be applications in multiple domains, so if you could add to this (actually, maybe better include on the scipy-dev mailing list and close this PR), that would be helpful.

@cval26
Copy link
Contributor Author

cval26 commented Aug 5, 2020

Thank you for the feedback and quick replies! I wasn't aware that scipy.fft already included DCT and DST functions, my mistake! It looks like Chebyshev FFTs would be more suitable there then, or perhaps even redundant if the DCT type I'm interested in is already implemented.

A bit more rationale on applications, and adding one or more references in the docstring to papers on Chebyshev FFT so we can see this is used would be useful as well.

thanks, I'll make sure to justify the use of such a feature with more detail! I'm closing this PR so that it's not considered ongoing work.

@cval26 cval26 closed this Aug 5, 2020
@cval26 cval26 deleted the chebyshev-fft branch November 21, 2020 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants