Hi team,

https://github.com/scipy/scipy/pull/20320 by Irwin Zaid updates the
legendre functions of the first and second kind, lpn
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.lpn.html>
and lqn
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.lqn.html>
respectively, and the associated legendre functions of the first and second
kind, lpmn
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.lpmn.html>
/clpmn
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.clpmn.html#scipy.special.clpmn>
and lqmn
<https://docs.scipy.org/doc/scipy/reference/generated/scipy.special.lqmn.html>
respectively, to take array arguments for the parameter z. Currently lxn(n,
z) returns a tuple of arrays, each of shape (n+1, ), evaluating a legendre
function at the point z for degrees 0 through n. lxmn(m, n, z) returns a
tuple of arrays, each of shape (m+1, n+1) evaluating an associated legendre
function at the point z for orders from 0 to m and degrees from 0 to n.
#20320 updates these functions to allow z to be an ndarray, such that the
output shape of lxn(n, z) will be (n+1, ) + z.shape and the output shape of
lxmn(m, n, z) will be (m+1, n+1) + z.shape.

I think this is a highly valuable change, allowing efficient evaluation of
these functions over multiple points.

To accomplish this, Irwin worked directly with the NumPy C API to create
generalized universal functions (gufuncs
<https://numpy.org/doc/stable/reference/c-api/generalized-ufuncs.html>)
that allow the inner loops of these functions to be run in native code. His
approach extends a C++ metaprogramming approach he implemented to
streamline working with the NumPy C API to create ufuncs in
https://github.com/scipy/scipy/pull/20260.

Our hope is to make the use of gufuncs more widespread in special, and to
make them available in CuPy's special as well, along the lines of what was
discussed in https://github.com/scipy/scipy/issues/19404.

Feel free to share your thoughts either here or in #20320.

Cheers,
Albert

ps. The count of lines changed in #20320 looks imposing, but it's just
because kokkos/mdspan <https://github.com/kokkos/mdspan>, the reference
implementation of the C++23 addition mdspan,
<https://en.cppreference.com/w/cpp/container/mdspan> has been pasted into
the under development special function C++ library Irwin and I are working
on.
_______________________________________________
SciPy-Dev mailing list -- scipy-dev@python.org
To unsubscribe send an email to scipy-dev-le...@python.org
https://mail.python.org/mailman3/lists/scipy-dev.python.org/
Member address: arch...@mail-archive.com

Reply via email to