-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
ENH: Migrate xsf header files from scipy repo to xsf repo #2
Closed
Conversation
This file contains 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
…#19515) * Add private _get_include for scipy::special scalar functions * Fix include path * Remove unnecessary abspath * Get safe path to include error.h * Give proper layout for extra_special * Change namespace scipy::special to extra_special * Remove top level using statements from lambertw.h * Put lambertw helper functions in detail namespace * Remove extraneous whitespace * Change working name extra_special -> special * Update path to file in comment
…601) * Changes to special C++ code to make lambertw work on CUDA * Undid formatting, saving that for a follow-up PR * Attempt to avoid redefinition of M_E * removed complex.h as a standalone file --------- Co-authored-by: izaid <[email protected]>
* Added .clang-format for special C++ files and formatted them * Added newlines --------- Co-authored-by: izaid <[email protected]>
* STY: special: use indent width of 4 in clang-format was previously 2 * MAINT: git blame ignores for special c++ formatting
* Rewrite csinpi in C++ * Rewrite ccospi in C++ * Add header comment for _trig.h * Rewrite loggamma in C++ * Translate zlog1 function from complexstuff.pxd into C++ * Remove _loggamma.pxd * Remove _evalpoly.pxd * Do some cleaning up * Move more files to special C++ lib * Add loggamma, sinpi and cospi to special C++ lib - along with Cephes dependencies - Sinpi and Cospi to avoid conflict with Cuda runtime library * Check in missing file * Fix includes * Fix function names * Add conj to std from thrust * Fix bug, using fabs instead of abs * Respond to review feedback * Change Sinpi/Cospi back to sinpi/cospi
* Translate digamma function to C++ * Fix typo (reversed inequality) and remove extraneous whitespace * Flatten nested namespace for digamma under detail * Use sf_error conditionally * Add missing pragma once * Move constants out of toplevel namespace * Make digamma tol an inline constexpr * Move digamma to new library * Make digamma work on cuda * Fix inequality * Make style change for more concise return statement * Use std::numeric_limits for machine epsilon * Change Sinpi/Cospi back to sinpi/cospi
* Add headers noting these are translations * Add missing include config.h in lambertw.h - this stil worked because error.h includes config.h, but it's better to be explicit. * Clang format code
Co-authored-by: izaid <[email protected]>
* Adapted specfun_wrappers to use new specfun in special * Replaced calls to sf_error with special::set_error in specfun_wrappers * Accidentally removed _specfun.pyx from build, have put it back * Remove ABS macro used in specfun_wrappers * Hopeful fix for Windows failure * Moved specfun wrappers into special namespace * maybe fixes for aliasing * maybe fix for windows * minor changes --------- Co-authored-by: izaid <[email protected]>
Co-authored-by: Irwin Zaid <[email protected]>
…some clean-up (#20352) * Made comprehensive function types for casting * Translated fresnel * Added obl_ang1_doc * Added terminating new lines * Updated clang-format * Turned rest of specfun into ufuncs * Removed unneeded cast functions * . * . * . * . * . * . * Cleaned up airy * . * Took more functions out of specfun.h * . * . * Remove unused variable * . --------- Co-authored-by: izaid <[email protected]>
* Converting amos to std::complex * Define M_PI if not available (for windows) * Bump test tolerance --------- Co-authored-by: izaid <[email protected]> Co-authored-by: Albert Steppi <[email protected]>
* Translated amos wrappers * Added include config.h * . --------- Co-authored-by: izaid <[email protected]>
* Made ufuncs for amos * Added docs * Added Hankel docs * Added a link with cephes for now * Added clean-up of code, removed C99 variables * Removed dummy returns and removed PyModule_AddObjectRef for Python < 3.10 * Covered points 2, 3, 4, 5 * Removed DO_SFERR and added iv * Added cephes link --------- Co-authored-by: izaid <[email protected]>
* Get wright_bessel working in CuPy with CUDA * Change Sinpi/Cospi back to sinpi/cospi * Change rgamma ufunc to use cephes C++ translation * EMPTY: [skip actions] [skip cirrus] * Update header comment * Remove accidental change to original cephes lanczos.h * Remove extra blank line * Fix wright_bessel * Use sinpi in cephes/gamma.h and make lgam not template function - lgam uses minimax polynomial calculations which are specific to the precision used * Purge specfun's gamma function
* Added float32 overloads for amos functions * Add test for matching 32bit and 64bit sigs for each ufunc --------- Co-authored-by: izaid <[email protected]> Co-authored-by: Albert Steppi <[email protected]>
Co-authored-by: izaid <[email protected]>
…0089) * Add new functions to config.h * Add series and continued fraction evaluators * Add gammasgn to special::cephes * Add cephes poch * Translate hyp2f1 into C++ * Handle z = 1, polynomial case * Update comments * Get things working on CUDA * squash remove unused continued fraction generator * Check for Kummer's theorem before c - a, or c - b negative int * Update comments for series evaluators * Add hyp2f1 precompute script to meson.build * Add new hyp2f1 test cases for region 3 (1 - z transform) * Add test case from gh-1034 * Handle special case a - b integer, c - a positive integer. * Add helpful comment on limit series c - a integer * Use clang format * Bump test tolerances * Bump more tolerances * Remove _hyp2f1.pxd * Use new C++ hyp2f1 in orthogonal_eval.pxd * Try again to get C wrapper for hyp2f1 working * Change to conventional template parameter T * Simplify returning NaN for real or complex types * Explain choice of maxiter and remove outdated comment * Update cython_special.pyx for new hyp2f1
…func (#20438) Co-authored-by: izaid <[email protected]>
…ppers (#20463) Co-authored-by: izaid <[email protected]>
…20483) * Translated scaled_exp1 * Refactoring cyl bessel * Refactoring of hankel, airy * Refactored amos error functions * Refactored rotations and reflections * Converted all ufuncs to references instead of pointers * Renamed exp1 and expi wrappers * Updated ber and friends wrapper names * renamed itstruve wrappers * Refactoring of legendre * . * Made sure Python.h gets included first * . --------- Co-authored-by: izaid <[email protected]>
* Add continued fraction evaluator * Add stub for iv_ratio * Basic implementation of iv_ratio. * Polish the continued fraction evaluator. * Refactor continued fraction convergent difference into a generator. * Refactor into Kahan series evaluator. * Clean up and add continued_fraction_series() function. * Refactor to use generator protocol. * Cosmetic changes to make code style more consistent. * Handle invalid arguments to _iv_ratio. * Clean up unused code. * Rearrange formula to simplify code and improve accuracy. * Unify definition of inv_ratio(v,x) := iv(v,x)/iv(v-1,x). * Add comp argument to return one's complement of iv_ratio. Adjust c.f. leading term. * Scale multiplier by 2 to avoid subnormal multiplier. * Remove the comp argument of iv_ratio. A separate function to compute the complement of iv_ratio is preferred and may be added in the future. * Move iv_ratio.h into special/ directory. * Add float overload of iv_ratio(). * Return quiet NaN as error handling is delegated to set_error(). * Pass arguments to kahan_step() by reference. * Return signed zero if x is signed zero. * Add unit tests for iv_ratio. * Ignore spurious mypy error in unit test file. --------- Co-authored-by: Albert Steppi <[email protected]>
…20805) * BUG: special: Restore missing line of code in the function cchg(). The line appears to have gone missing in the translation from Fortran to C++. Added new tests, which revealed that hyp1f1 can still be very inaccurate. Closes gh-20797. * MAINT: Change a couple commented out test cases to xfail cases. Co-authored-by: Albert Steppi <[email protected]> * BUG/TST: Fix a test reference value. The 'j' suffix was missing in a complex value. --------- Co-authored-by: Albert Steppi <[email protected]>
* DEV: Rename gamma to gamma_complex for complex type * DEV: Use gamma_complex * DEV: Use template for std::complex * DEV: Shift gamma to gamma.h
* replaced mdspan implementation with kokkos version * Put mdspan in third_party subdirectory * Added license to LICENSES_bundled.txt --------- Co-authored-by: izaid <[email protected]>
* BUG: Fix indices in sphj * Fix sphj argument order * Fix translation error from original Fortran * TST: Add test for pro_rad1 * Bump test tolerance for linux 32bit
* Fix several cuda issues * Remove direct stdlib include outside config.h * More config updates * Add xslow tests that special functions work in CuPy * Fix overzealous autoformat * Remove cruft and add missing SPECFUN_HOST_DEVICE * Update C++ version in elementwise kernel * Avoid use of helper types not supported in cupy * Add std::pair to config.h correctly * Add iv_ratio to special_sources in meson.build * Add test iv_ratio works in cupy * Add mypy ignore * Revert accidental commenting of a line * Put # type: ignore in the right place * Add missing SPECFUN_HOST_DEVICE specifiers
… on CUDA (#21163) * Add cuda tests for ellipkinc and ellipeinc * Add missing headers to cephes sources in meson * Fixes to make ellipeinc and ellipkinc on cuda
* . * . * . * changing number of recurrence terms * . * . * . * . * . * . * . * . * . * . * . * renamed multiufunc to MultiUFunc * enabled lambdas for special functions * more lambda stuff * templated clpmn_all * Covered all norm and unnorm cases * recurrence updates * . * . * Py_BuildValue updates * added normalised legendre polynomials * added norm to clpmn tests * cleaning up tests * renaming of legendre functions * renamed some type to typ * . * more clean-up * . * . * . * refactored out specific assoc_legendre tests * fix for litner * more lint fixes * switched assoc_legendre_p n and m arg order * . * renaming clpmn to multi_assoc_legendre_p * . * permuted n and m dimensions in legendre * fixes for lint * . * . * renamed legendre test functions * reorganising some tests * . * . * . * testing experimental grad_tuple * more grad_tuple testing * moved all of legendre_p over * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * . * grad refactoring * refactoring assoc_legendre for grad * . * . * . * . * refactoring grad<...> * refactoring grad still * refactoring for refs * more refactoring * removed refs as tuple functions * . * . * . * . * . * . * turning grad into a std::tuple where possible * renamed grad to tuple_wrapper * renamed grad.h to tuple_wrapper.h * . * converted refs to apply_tie * worked out tuple_assigner * cleaned up tuple_assigner * . * . * bit more refactoring * . * added grad_tuple_t * . * removed diag bool flag * . * . * various refactoring and renaming * removed unnecessary includes from sph_harm * added sph_legendre and updated sph_harm * Turned tuple helper functions into their own namespace * . * slight dot refactoring * added sph_harm_y_next * Fully added sph_legendre_p * fix for linter * working towards sph_harm derivatives * added derivatives for sph_harm_y * made sph_harm_y_all a multiufunc * fix for linter * . * rebased * Make multiufunc attributes public + adjust names * Use slots in MultiUFunc * Add signature for resolve_ufunc and make not takes ufuncs * Adjust name/docs of resolution methods * Add input validation to multiufunc. * Use distinct names for ufuncs within multiufunc * Begin documenting MultiUFunc * Only allow resolvers set by decorator - There should be one-- and preferably only one --obvious way to do it. * preliminary work to set docstrings * Get instance level docstring working * Make separate docstring and class docstring work * Remove hack in of class docstring for MultiUFunc * Add new multifuncs to docs * Clean up all merge conflicts - for real this time * Add input validation for diff_n * Update docs for MultiUFuncs * Docstring for assoc_legendre_p * Get rid of the __slots__ in MultiUFunc * Separate _multiufuncs out of _basic * Use _nonneg_int_or_fail to validate diff_n * Update Legendre docs * Update docstring short descriptions for consistency * Pointless thrashing * Made docs a settable attribute from the constructor * removed unused import of operator * made names the same again * added missing r * added _multiufuncs to mypy * forces_complex_output -> force_complex_output * switched as_ prefix to register_ * reworked some docs, working on sph_harm hess * fix for linter * Some doc updates * added map_dims to sort out sph_harm_all derivatives * deleted steps_offset, made ranks_scans * synced non-gufuncs * . * trying axes keyword of gufunc * migrated multiufunc fully to use axes keyword * cleaned up all test * made resolve_ufunc return a key * flattened collections of ufuncs * . * made typ a default argument for multiufunc * removed assoc_legendre_p_all * deleted assoc_legendre_p * removed force_complex for multi_assoc_... * . * Revert "deleted assoc_legendre_p" This reverts commit 560b075b014d4a48733c7811340d3291d0ce413e. * Revert "removed assoc_legendre_p_all" This reverts commit 2063e469dbc939ffd0ad71bc4220bba368e9d303. * Revert "made typ a default argument for multiufunc" This reverts commit a50ce036d78ceaf4cb0c63b1442d057ebc56d94a. * readded force_complex_output flag * switched order of z and type for multi_assoc_legendre_p and multi_assoc_legendre_p_all * made lpmn use multi_assoc_legendre_p_all * added real overloads * removed force_complex_output from multi_assoc_legendre_p_all * added float overloads for multi_assoc_legendre_p * added cast to complex in clpmn * removed force_complex_output from multi_assoc_legendre_p * moved several tests to multi_* * removed assoc_legendre_p from Python * removed assoc_legendre_p_* and assoc_legendre_p_all_* * added typ keyword to multi_legendre_p_all * added typ keyword to multi_legendre_p * added default values to typ * removed assoc_legendre C++ code * made MultiUFunc method setters consistently called override, renamed multi_ to assoc_ * . * . * renamed all C++ instances of multi_ * synced testing names * switched order of type and z in global namespace * swapped more z and type in C++ * . * added a default kwargs function to MultiUFunc * multiufunc refactoring * fix for linter * . * . * several fixes and docs * added deprecation notices to docs * updated sph_harm_y and sph_harm_y_all docs * fixes for linter * . * clean-up * made resolve_ufunc private * renamed typ to branch_cut * simplified the "all" functions documentation * fix for linter * renamed type -> branch_cut in some of the C++ * renamed rest of C++ code from type -> branch_cut * various Python refactoring * Revert "various Python refactoring" This reverts commit c50cfd194cadbeaec4ab875a8c68bdcc020c22f3. * reverted * updated default testing arguments * removed unnecessary keyword use * renamed typ_sign to branch_cut_sign * updated exception * . * . * Suppress ABI change warning from special/recur.h - ../scipy/special/special/recur.h:89:6: note: the ABI of passing structure with ‘complex float’ member has changed in GCC 4.4 * Add multiufuncs to special's __all__ * Make all multiufunc scaffolding private * switched meaning of theta and phi in new spherical harmonics * updated new sph_harm docs and made angle change consistent for sph_legendre_p * removed underscores from override methods * removed underscores from override methods * Only add -Wno-psabi when compiler is gcc * Add missing newline * Remove extraneous whitespace * Formatting changes for pep8 * More pep8 formatting updates * Replace ssize_t (not standard) with ptrdiff_t * fix for zero-size arrays * removed signbit call * updated branch_cut docs * Fix sphinx RST issue * Mark test as slow - Can take over 1 second to run * Add noqa to ignore linter since this is desired --------- Co-authored-by: izaid <[email protected]> Co-authored-by: Albert Steppi <[email protected]>
* Fixes #21228 * The `cstddef` include had a typo, preventing the tests failing in the above ticket from running properly. [skip cirrus] [skip circle]
* namespace special -> namespace xsf * Renamed folder special/special -> special/xsf * deleted xsf/cephes/sindg.c, which was leftover from cephes translation * renamed SPECFUN_ASSERT -> XSF_ASSERT and SPECFUN_HOST_DEVICE -> XSF_HOST_DEVICE * Renamed special_wrappers.{c,h} -> xsf_wrappers.{c,h} * Renamed special.h -> xsf_special.h --------- Co-authored-by: izaid <[email protected]>
* ENH: special: Improve precision of special.logit
* Removed some more functions from functions.json * Removed struve and modstruve * several other functions * translated some of the gamma functions * removed fresnel * removed several ellip entries * removed riemann_zeta * updated wrappers * more wrapper work * . * more wrapper refactoring * . --------- Co-authored-by: izaid <[email protected]>
* refactoring ufunc.h in special * refactored out relevant parts of gufunc.cpp * moved ufunc.h to xsf/numpy.h * Add "xsf/numpy.h" to list of Python-including headers --------- Co-authored-by: izaid <[email protected]> Co-authored-by: Albert Steppi <[email protected]>
* Add scipy.special._ufuncs._iv_ratio_c function. * iv_ratio: propagate x or v if it is nan, in that order. * iv_ratio: add detailed doc. * Add unit tests for iv_ratio_c. * Relax rtol for iv_ratio_c unit tests. * Rearrange continued fraction series formula to reduce roundoff error. * iv_ratio: reduce tolerance to improve accuracy. * iv_ratio: update doc with improved accuracy. * Relax domain of v to greater than or equal to 0.5. * Sketch code to compute iv_ratio_c using double-double arithmetic. * Clean up iv_ratio_c implementation. * Update doc with enlarged domain. * Editorial changes. * Update tests with enlarged domain.
* Traslate complex valued sine integrals to C++ * Consolidate sici/shichi into single header sici.h * Make exponential integrals work on CUDA * Make some updates needed to get things working in cupy * Add sici/shichi cupy tests * Add comment that expint implementations came from specfun * Fix cast to incorrect type * Add required explicit cast to std::complex<float> * Update to make work after special->xsf rename * Remove failing iv_ratio tests for test_xsf_cuda
…inal CEPHES code (#20695) * Update ndtr.h - fixing error See the original version from cephes * Update ndtr.h - flagging loss of precision Flagging loss of precision : 1 - 1e-30 != 1 * Update ndtr.h indentation indentation change * Update ndtr.h indentation indentation * Update test_ndtr.py assert if warning raised when loss of precision Should raise warning when loss of precision for normal cdf (in which case the survival function should be used) * Update scipy/special/tests/test_ndtr.py preferred style preferred style Co-authored-by: Lucas Colley <[email protected]> * Update scipy/special/tests/test_ndtr.py Unnecessary import Co-authored-by: Lucas Colley <[email protected]> * Update test_ndtr.py Comment on why warning Comment on why it should raise a warning * Update test_ndtr.py import pytest Import pytest * Update test_ndtr.py adding context for error handling adding context for error handling * Apply suggestions from code review [skip ci] --------- Co-authored-by: Lucas Colley <[email protected]> Co-authored-by: Matt Haberland <[email protected]>
…GPU while making substantial improvements (#21454) * Add scalar root bracketing and root finding tools to xsf * Add gdtrib to xsf as proof of concept for adding cdflib * Settle gdtrib edge case handling
…1483) * first pass at dual * Working towards assoc_legendre * converting assoc_legendre_p * Updated branch cut definition to work with new derivatives * . * refactored sph_legendre * . * removal of more old tuple code * . * Made sph_harm work with dual * removed custom std::exp * . * made sph_harm use dual<dual<complex>> rather then complex<dual<dual>> * fix for linter * simplifying multidim duals * . * reworking multidims * made dual variadic * . * more refactoring * Removed unboxing multiplication * . * make_dual -> dual_var * refactoring * removed last definitions in std namespace * implemented remaining comparisons, some clean-up * removed binom and factorial functions from dual * slight clean-up of complex in sph_harm_y * removed some std::complex from dual.h * Removed extra trig calls * removed tuple usage from legendre_p * . * converted assoc_legendre_p and sph_legendre_p and their all versions * deleted all of tuples.h * . * . * fixed sph_harm_y p test * removed unneeded resolve_out_shapes and some typedef clean-up * fixed up remaining typedefs * added wrap_autodiff for legendre_p * added trailing newline to _multiufuncs and add wrap_autodiff for sph_legendre_p * fix for linter * removed assoc_legendre_p wrapper * wrapped sph_harm_y * fixing _all function autodiff wrappers * removed unneeded assoc_legendre_p wrapper * removed sph_harm_y wrapper * fix for sph_harm-y * added xsf::numpy::applies for transforms * updated ufuncs as well * added a long long int adapter * . * . * . * . * . * . * . * . * . * . * . * . * more clean-up * . * removed long long ints * . * . --------- Co-authored-by: izaid <[email protected]>
Putting this on hold. I talked to @izaid, and there's still a few things that should be done on the SciPy side before we can split things off.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 migrates header files (and
.clang-format
) fromscipy/scipy/special/xsf
toxsf/include/xsf
while preserving git history.I used
git-filter-repo
as described here, #1 (comment), but in order to preserve history across the rename fromscipy/scipy/special/special
toscipy/scipy/special/xsf
here https://github.com/scipy/scipy/pull/21297/files,git-filter-branch
for all ofscipy/scipy/special
scipy/scipy/special/special
orscipy/scipy/special/xsf
.The interactive rebase was done by setting
GIT_SEQUENCE_EDITOR
to the script in the details section below. Carrying out the rebase involved a tedious process of manually fixing merge conflicts, typically just usinggit rm
to remove files which were added or updated inscipy/scipy/special
but which are not part of the scalar kernel header library. However, sometimes there were merge conflicts because git seems to get confused when you try to rebase through an intermediate merge of main. I made a mistake resolving one of them inxsf/amos.h
and needed to fix it in an additional commit here.I've used
git diff --no-index ~/scipy/scipy/special/xsf ~/include/xsf
from within thexsf
repo to confirm that no unwanted changes have creeped in.