You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds support for complex values to the digamma function. This is made possible by the recent translation of SciPy's complex valued digamma implementation to CUDA compatible C++, scipy/scipy#19834. This PR also makes an improvement to the real valued digamma implementation which was made in SciPy but had not been ported to CuPy (scipy/scipy#8129).
I've copied over the entirety of the SciPy special C++ library as it exists now, despite it not all being used for digamma, but if you'd like, I can go through and try to add only the minimum number of headers that are actually needed. I just thought it would be easier to maintain if SciPy and CuPy vendor the same version of this set of files.
polevl_definition in _digamma.py is no longer used for the digamma function but I've left it in place because it is imported in other files.
Thanks @asi1024, it was oversight on my part not to set no_complex=False. I've found there is a failing test due to differences in how division by complex infinity is handled in the C++ standard library on my system vs in thrust::complex.
For large z, (including infinite z) the code uses an asymptotic expansion log(z) - 0.5/z (plus additional terms if needed). If the input is inf + x*1i, for finite x, then in the C++ standard library on my system, -0.5/z evaluates to 0i, but for thrust complex numbers it evaluates to nan + nan*1i. I've found the C++ standard library does not specify the behavior of division by complex infinities; the behavior is implementation dependent. The fix will be to make sure that the results do not depend on the outcome of any divisions by complex infinity. I'll update the code to check for infinities and handle them separately.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds support for complex values to the
digammafunction. This is made possible by the recent translation of SciPy's complex valueddigammaimplementation to CUDA compatible C++, scipy/scipy#19834. This PR also makes an improvement to the real valueddigammaimplementation which was made in SciPy but had not been ported to CuPy (scipy/scipy#8129).I've copied over the entirety of the SciPy special C++ library as it exists now, despite it not all being used for
digamma, but if you'd like, I can go through and try to add only the minimum number of headers that are actually needed. I just thought it would be easier to maintain if SciPy and CuPy vendor the same version of this set of files.polevl_definitionin_digamma.pyis no longer used for thedigammafunction but I've left it in place because it is imported in other files.