treams_rs.special¶
Special functions of multipole waves, with NumPy broadcasting.
Mirrors treams.special. Every function broadcasts its arguments as a NumPy
ufunc does. With NumPy inputs the functions accept out and where;
the coordinate transforms and vpw_* accept out only.
Advect, JAX, PyTorch and Autograd inputs select their differentiation adapter
automatically for continuous arguments. Degrees, orders and polarization labels
stay fixed. Differentiable calls do not accept out or where; use the
framework's array operations to combine or mask results.
- Bessel and Hankel functions:
jv,yv,hankel1,hankel2, the sphericalspherical_jn,spherical_yn,spherical_hankel1,spherical_hankel2, and their derivatives*_d. - Angular functions:
lpmv,pi_fun,tau_fun,sph_harmand the Wigner symbolswignersmalld,wignerdandwigner3j. - Lattice-sum integrals:
incgammaandintkambe. - Vector waves: spherical
vsw_*, cylindricalvcw_*, planevpw_*and the vector spherical harmonicsvsh_*. Anrafter the underscore (vsw_rN) selects the regular wave; without it the wave is singular (outgoing, built on the Hankel function H1). - Translation coefficients:
tl_vsw_A,tl_vsw_B,tl_vcwand their regular versionstl_vsw_rA,tl_vsw_rBandtl_vcw_r. - Coordinate transforms of points (
car2sph,sph2car, ...) and of vector components (vcar2sph,vsph2car, ...).
Results are complex128, also for real arguments. lpmv with real
arguments, wigner3j and the transforms of real points return float64.
Bessel functions, angular functions and waves raise ValueError where they have
no finite value, for example hankel1(0, 0.0). Angular functions, Wigner d
functions and spherical waves take degrees l from 0 to 128.
diff.bessel, diff.angular and their advect versions also return
gradients with respect to the argument.
Differences from treams
- Native ufuncs are exposed through dispatching callables, so they are not
instances of
numpy.ufunc. NumPy calls, ufunc attributes and methods such asouterstill delegate to the original ufunc, available as__wrapped__. Ufunc methods themselves are NumPy-only. - ValueError instead of NaN or infinity:
hankel1(0, 0.0)raises, treams returnsnan+nanj.incgammaandintkambereturn infinity at their poles, as treams does. - complex128 instead of float64 for real arguments:
jv(0, 1.0)is0.765...+0j. - Degrees l above 128 raise ValueError; treams has no limit.
hankel1,hankel2,lpmv,pi_fun,tau_fun,incgamma,intkambe,wigner3j,tl_vcwandtl_vcw_rare Python functions, not ufuncs: they have no ufunc methods such asouter.- The coordinate transforms (
car2cyl, ...,vpol2car) andvpw_M,vpw_N,vpw_Aare native functions, not ufuncs: they take nowhereand have no ufunc methods.
Example:
import numpy as np
from treams_rs import special
x = 2.0
assert np.isclose(special.jv(0, 1.0), 0.7651976865579666)
assert np.isclose(special.spherical_jn(1, x), np.sin(x) / x**2 - np.cos(x) / x)
assert np.isclose(special.lpmv(2, 2, 0.5), 3 * (1 - 0.5**2))
car2cyl¶
car2cyl(points, *args, **kwargs)
Transform Cartesian points to cylindrical coordinates.
The last axis holds the components; ufunc options are supported.
Mirrors treams.special.car2cyl.
Differences from treams: ValueError for non-finite input.
car2pol¶
car2pol(points, *args, **kwargs)
Transform Cartesian points to polar coordinates.
The last axis holds the components; ufunc options are supported.
Mirrors treams.special.car2pol.
Differences from treams: ValueError for non-finite input.
car2sph¶
car2sph(points, *args, **kwargs)
Transform Cartesian points to spherical coordinates.
The last axis holds the components; ufunc options are supported.
Mirrors treams.special.car2sph.
Differences from treams: ValueError for non-finite input.
cyl2car¶
cyl2car(points, *args, **kwargs)
Transform cylindrical points to Cartesian coordinates.
The last axis holds the components; ufunc options are supported.
Mirrors treams.special.cyl2car.
Differences from treams: ValueError for non-finite input.
cyl2sph¶
cyl2sph(points, *args, **kwargs)
Transform cylindrical points to spherical coordinates.
The last axis holds the components; ufunc options are supported.
Mirrors treams.special.cyl2sph.
Differences from treams: ValueError for non-finite input.
hankel1¶
hankel1(v: ArrayLike, z: ArrayLike, *, out: NDArray[np.complex128] | None=None, where: ArrayLike=True) -> complex | NDArray[np.complex128]
Hankel function of the first kind H1_v(z) = J_v(z) + i Y_v(z).
Mirrors treams.special.hankel1. H1 describes outgoing (singular)
cylindrical waves.
Args
v: Real order.z: Argument, real or complex, nonzero.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
complex128 array with the broadcast shape of v and z. Python
numbers give one complex number.
Differences from treams
z = 0, non-finite input and overflow raise ValueError; treams
returns NaN or infinity.
hankel1_d¶
hankel1_d(v, z, /, out=None, *, where=True)
H1_v'(z) = (H1_(v-1)(z) - H1_(v+1)(z)) / 2, the derivative of H1_v.
Mirrors treams.special.hankel1_d.
Differences from treams: ValueError for non-finite input, at z = 0 and on overflow, where treams returns NaN or infinity.
hankel2¶
hankel2(v: ArrayLike, z: ArrayLike, *, out: NDArray[np.complex128] | None=None, where: ArrayLike=True) -> complex | NDArray[np.complex128]
Hankel function of the second kind H2_v(z) = J_v(z) - i Y_v(z).
Mirrors treams.special.hankel2. H2 describes incoming cylindrical waves.
Args
v: Real order.z: Argument, real or complex, nonzero.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
complex128 array with the broadcast shape of v and z. Python
numbers give one complex number.
Differences from treams
z = 0, non-finite input and overflow raise ValueError; treams
returns NaN or infinity.
hankel2_d¶
hankel2_d(v, z, /, out=None, *, where=True)
H2_v'(z) = (H2_(v-1)(z) - H2_(v+1)(z)) / 2, the derivative of H2_v.
Mirrors treams.special.hankel2_d.
Differences from treams: ValueError for non-finite input, at z = 0 and on overflow, where treams returns NaN or infinity.
incgamma¶
incgamma(n: ArrayLike, z: ArrayLike, *, out: NDArray[np.complex128] | None=None, where: ArrayLike=True) -> complex | NDArray[np.complex128]
Upper incomplete gamma function Gamma(n, z).
Gamma(n, z) = integral_z^inf t^(n - 1) exp(-t) dt.
Mirrors treams.special.incgamma. The negative real axis is the branch
cut. For n <= 0, Gamma(n, 0) is infinite.
Args
n: Integer or half-integer degree from -128 to 128.z: Argument, real or complex.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
complex128 array with the broadcast shape of n and z. Python
numbers give one complex number.
Differences from treams
treams returns float64 for real z and NaN at z < 0 for
half-integer l and for l <= 0; this function returns the
principal-branch value (arg z = pi). Degrees outside the integers
and half-integers from -128 to 128 raise ValueError.
intkambe¶
intkambe(n: ArrayLike, z: ArrayLike, eta: ArrayLike, *, out: NDArray[np.complex128] | None=None, where: ArrayLike=True) -> complex | NDArray[np.complex128]
Kambe integral I_n(z, eta).
I_n(z, eta) = integral_eta^inf t^n exp(-z^2 t^2 / 2 + 1 / (2 t^2)) dt.
Mirrors treams.special.intkambe. The lattice sums of
treams_rs.lattice use it. Odd orders at imaginary eta = -i / w
(the arguments of the 1D spherical lattice sums) come from a series that
cancels by up to exp(|w|^2): they lose up to about 1e-4 relative at
|w| = 5, 0.1 at |w| = 6 and every digit from about |w| = 8.
Args
n: Integer order.z: Argument, real or complex.eta: Lower limit of the integral, real or complex.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
complex128 array with the broadcast shape of n, z and eta.
Python numbers give one complex number.
jv¶
jv(v, z, /, out=None, *, where=True)
J_v(z), the Bessel function of the first kind of real order v.
Mirrors treams.special.jv.
Differences from treams: complex128 results also for real z, with the principal-branch value (arg z = pi) at z < 0, where treams returns NaN for non-integer v; ValueError for non-finite input, at a pole and on overflow.
jv_d¶
jv_d(v, z, /, out=None, *, where=True)
J_v'(z) = (J_(v-1)(z) - J_(v+1)(z)) / 2, the derivative of J_v.
Mirrors treams.special.jv_d.
Differences from treams: complex128 results also for real z, with the principal-branch value (arg z = pi) at z < 0, where treams returns NaN for non-integer v; ValueError for non-finite input, at a pole and on overflow.
lpmv¶
lpmv(m: ArrayLike, n: ArrayLike, z: ArrayLike, *, out: NDArray[np.complex128] | NDArray[np.float64] | None=None, where: ArrayLike=True) -> float | complex | NDArray[np.complex128] | NDArray[np.float64]
Associated Legendre function P_v^m(z), with the Condon-Shortley phase (-1)^m.
Mirrors treams.special.lpmv. The order m comes first, as in SciPy.
For real arguments the degree may be noninteger. Orders with
|m| > v give 0.
Args
m: Integer order m.n: Degree v, from 0 to 128; integer for complexz.z: Argument. Realzoutside [-1, 1] with oddmand|m| <= vraises ValueError; pass complexzfor the continuation.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
float64 array for real arguments, complex128 array for complex z,
with the broadcast shape of m, n and z. Python numbers give
one float or complex number.
Differences from treams
At real |z| > 1 and an integer degree v >= |m| > 0, treams
returns NaN; here even m gives the value and odd m raises
ValueError. A noninteger degree v > |m| needs z in (-1, 1]
with zero imaginary part and raises ValueError elsewhere.
pi_fun¶
pi_fun(n: ArrayLike, m: ArrayLike, z: ArrayLike, *, out: NDArray[np.complex128] | None=None, where: ArrayLike=True) -> complex | NDArray[np.complex128]
Angular function pi_l^m(x) = m P_l^m(x) / sqrt(1 - x^2).
Mirrors treams.special.pi_fun. At x = +-1 it returns the limit.
Args
n: Integer degree l, from 0 to 128.m: Integer order m.z: Argument x, real or complex;x = cos(theta)on the real line.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
complex128 array with the broadcast shape of n, m and z.
Python numbers give one complex number.
Differences from treams
treams returns float64 for real x and NaN at real |x| > 1,
where this function returns the value.
pol2car¶
pol2car(points, *args, **kwargs)
Transform polar points to Cartesian coordinates.
The last axis holds the components; ufunc options are supported.
Mirrors treams.special.pol2car.
Differences from treams: ValueError for non-finite input.
sph2car¶
sph2car(points, *args, **kwargs)
Transform spherical points to Cartesian coordinates.
The last axis holds the components; ufunc options are supported.
Mirrors treams.special.sph2car.
Differences from treams: ValueError for non-finite input.
sph2cyl¶
sph2cyl(points, *args, **kwargs)
Transform spherical points to cylindrical coordinates.
The last axis holds the components; ufunc options are supported.
Mirrors treams.special.sph2cyl.
Differences from treams: ValueError for non-finite input.
sph_harm¶
sph_harm(m, l, phi, theta, /, out=None, *, where=True)
Y_lm(theta, phi) = N_lm P_l^m(cos(theta)) exp(i m phi) with N_lm = sqrt((2 l + 1) (l - m)! / (4 pi (l + m)!)); the order of the arguments follows SciPy.
Mirrors treams.special.sph_harm.
Differences from treams: 0 for |m| > l, where treams returns NaN at real theta; degrees up to 128; ValueError for non-finite angles.
spherical_hankel1¶
spherical_hankel1(n, z, /, out=None, *, where=True)
h1_n(z) = j_n(z) + i y_n(z), the spherical Hankel function of the first kind.
Mirrors treams.special.spherical_hankel1.
Differences from treams: ValueError at z = 0, where treams raises ZeroDivisionError; also for non-finite input, on overflow and for n = 0 at |z| below about 1e-162.
spherical_hankel1_d¶
spherical_hankel1_d(n, z, /, out=None, *, where=True)
h1_n'(z) = (n h1_(n-1)(z) - (n + 1) h1_(n+1)(z)) / (2 n + 1), the derivative of h1_n.
Mirrors treams.special.spherical_hankel1_d.
Differences from treams: ValueError at z = 0, where treams raises ZeroDivisionError; also for non-finite input and on overflow.
spherical_hankel2¶
spherical_hankel2(n, z, /, out=None, *, where=True)
h2_n(z) = j_n(z) - i y_n(z), the spherical Hankel function of the second kind.
Mirrors treams.special.spherical_hankel2.
Differences from treams: ValueError at z = 0, where treams raises ZeroDivisionError; also for non-finite input, on overflow and for n = 0 at |z| below about 1e-162.
spherical_hankel2_d¶
spherical_hankel2_d(n, z, /, out=None, *, where=True)
h2_n'(z) = (n h2_(n-1)(z) - (n + 1) h2_(n+1)(z)) / (2 n + 1), the derivative of h2_n.
Mirrors treams.special.spherical_hankel2_d.
Differences from treams: ValueError at z = 0, where treams raises ZeroDivisionError; also for non-finite input and on overflow.
spherical_jn¶
spherical_jn(n: ArrayLike, z: ArrayLike, derivative: bool=False, *, out: NDArray[np.complex128] | None=None, where: ArrayLike=True) -> NDArray[np.complex128]
Spherical Bessel function j_n(z) = sqrt(pi / (2 z)) J_{n + 1/2}(z).
Mirrors treams.special.spherical_jn.
Args
n: Order n, usually an integer n >= 0; a noninteger n evaluates the formula above.z: Argument, real or complex.derivative: If True, return the derivative dj_n/dz instead.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
complex128 array with the broadcast shape of n and z.
Differences from treams
treams returns float64 for real z and truncates a noninteger n;
here a noninteger n evaluates the formula above. Non-finite input
and overflow raise ValueError.
spherical_jn_d¶
spherical_jn_d(n, z, /, out=None, *, where=True)
j_n'(z) = (n j_(n-1)(z) - (n + 1) j_(n+1)(z)) / (2 n + 1), the derivative of j_n.
Mirrors treams.special.spherical_jn_d.
Differences from treams: complex128 results also for real z; ValueError for non-finite input and on overflow.
spherical_yn¶
spherical_yn(n: ArrayLike, z: ArrayLike, derivative: bool=False, *, out: NDArray[np.complex128] | None=None, where: ArrayLike=True) -> NDArray[np.complex128]
Spherical Bessel function y_n(z) = sqrt(pi / (2 z)) Y_{n + 1/2}(z).
Mirrors treams.special.spherical_yn.
Args
n: Order n, usually an integer n >= 0; a noninteger n evaluates the formula above.z: Argument, real or complex, nonzero.derivative: If True, return the derivative dy_n/dz instead.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
complex128 array with the broadcast shape of n and z.
Differences from treams
treams returns float64 for real z, -inf at z = 0 and
truncates a noninteger n; here z = 0 raises ValueError and a
noninteger n evaluates the formula above. Non-finite input,
overflow and n = 0 at |z| below about 1e-162 raise
ValueError.
spherical_yn_d¶
spherical_yn_d(n, z, /, out=None, *, where=True)
y_n'(z) = (n y_(n-1)(z) - (n + 1) y_(n+1)(z)) / (2 n + 1), the derivative of y_n.
Mirrors treams.special.spherical_yn_d.
Differences from treams: complex128 results also for real z; ValueError for non-finite input, at z = 0 and on overflow.
tau_fun¶
tau_fun(n: ArrayLike, m: ArrayLike, z: ArrayLike, *, out: NDArray[np.complex128] | None=None, where: ArrayLike=True) -> complex | NDArray[np.complex128]
Angular function tau_l^m(x) = d P_l^m(cos theta) / d theta at x = cos theta.
Mirrors treams.special.tau_fun. At x = +-1 it returns the limit.
Args
n: Integer degree l, from 0 to 128.m: Integer order m.z: Argument x, real or complex.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
complex128 array with the broadcast shape of n, m and z.
Python numbers give one complex number.
Differences from treams
treams returns float64 for real x and NaN at real |x| > 1
unless l = |m| <= 1; this function returns the value. For
|m| > l it returns 0, where treams returns, for example,
tau_fun(0, -1, x) = 0.5.
tl_vcw¶
tl_vcw(kz: ArrayLike, mu: ArrayLike, qz: ArrayLike, m: ArrayLike, krr: ArrayLike, phi: ArrayLike, z: ArrayLike, *args: object, **kwargs: object) -> complex | NDArray[np.complex128]
Singular cylindrical translation coefficient of one mode pair.
H1_{m - mu}(krr) exp(i ((m - mu) phi + kz z)) if kz == qz, else 0.
Mirrors treams.special.tl_vcw. It expands a singular wave about the
source origin in regular waves about the destination origin;
cw.translate adds the polarization.
Args
kz: Axial wavenumber of the destination mode.mu: Integer order of the destination mode.qz: Axial wavenumber of the source mode.m: Integer order of the source mode.krr: Radial distance of the displacement times the radial wavenumber, real or complex, nonzero.phi: Azimuthal angle of the displacement.z: Axial distance of the displacement, not scaled by a wavenumber.*args: Further ufunc arguments, such asout.**kwargs: Further ufunc keywords, such aswhere.
Returns
complex128 array with the broadcast shape of the arguments. Python numbers give one complex number.
Differences from treams
krr = 0 raises ValueError; treams returns nan+nanj.
tl_vcw_r¶
tl_vcw_r(kz: ArrayLike, mu: ArrayLike, qz: ArrayLike, m: ArrayLike, krr: ArrayLike, phi: ArrayLike, z: ArrayLike, *args: object, **kwargs: object) -> complex | NDArray[np.complex128]
Regular cylindrical translation coefficient of one mode pair.
J_{m - mu}(krr) exp(i ((m - mu) phi + kz z)) if kz == qz, else 0.
Mirrors treams.special.tl_vcw_r. It expands a wave about the source
origin in waves of the same kind about the destination origin. At
krr = 0 it returns the limit.
Args
kz: Axial wavenumber of the destination mode.mu: Integer order of the destination mode.qz: Axial wavenumber of the source mode.m: Integer order of the source mode.krr: Radial distance of the displacement times the radial wavenumber, real or complex.phi: Azimuthal angle of the displacement.z: Axial distance of the displacement, not scaled by a wavenumber.*args: Further ufunc arguments, such asout.**kwargs: Further ufunc keywords, such aswhere.
Returns
complex128 array with the broadcast shape of the arguments. Python numbers give one complex number.
tl_vsw_A¶
tl_vsw_A(lambda_, mu, l, m, x, theta, phi, /, out=None, *, where=True)
The translation coefficient A from the parity wave (l, m) to (lambda_, mu) of equal parity, from singular to regular vector spherical waves, across the displacement (x, theta, phi) with x = k r.
Mirrors treams.special.tl_vsw_A.
Differences from treams: degrees up to 128; ValueError at x = 0, where treams raises ZeroDivisionError, and for non-finite input.
tl_vsw_B¶
tl_vsw_B(lambda_, mu, l, m, x, theta, phi, /, out=None, *, where=True)
The translation coefficient B from the parity wave (l, m) to (lambda_, mu) of opposite parity, from singular to regular vector spherical waves, across the displacement (x, theta, phi) with x = k r.
Mirrors treams.special.tl_vsw_B.
Differences from treams: degrees up to 128; ValueError at x = 0, where treams raises ZeroDivisionError, and for non-finite input.
tl_vsw_rA¶
tl_vsw_rA(lambda_, mu, l, m, x, theta, phi, /, out=None, *, where=True)
The translation coefficient A from the parity wave (l, m) to (lambda_, mu) of equal parity, between vector spherical waves of one kind, across the displacement (x, theta, phi) with x = k r.
Mirrors treams.special.tl_vsw_rA.
Differences from treams: degrees up to 128; ValueError for non-finite input.
tl_vsw_rB¶
tl_vsw_rB(lambda_, mu, l, m, x, theta, phi, /, out=None, *, where=True)
The translation coefficient B from the parity wave (l, m) to (lambda_, mu) of opposite parity, between vector spherical waves of one kind, across the displacement (x, theta, phi) with x = k r.
Mirrors treams.special.tl_vsw_rB.
Differences from treams: degrees up to 128; ValueError for non-finite input.
vcar2cyl¶
vcar2cyl(vector, points, *args, **kwargs)
Transform vector components from the Cartesian to the cylindrical basis.
Positions are given in the input coordinate system; the last axis holds the components and ufunc options are supported.
Mirrors treams.special.vcar2cyl.
Differences from treams: ValueError for non-finite input.
vcar2pol¶
vcar2pol(vector, points, *args, **kwargs)
Transform vector components from the Cartesian to the polar basis.
Positions are given in the input coordinate system; the last axis holds the components and ufunc options are supported.
Mirrors treams.special.vcar2pol.
Differences from treams: ValueError for non-finite input.
vcar2sph¶
vcar2sph(vector, points, *args, **kwargs)
Transform vector components from the Cartesian to the spherical basis.
Positions are given in the input coordinate system; the last axis holds the components and ufunc options are supported.
Mirrors treams.special.vcar2sph.
Differences from treams: ValueError for non-finite input.
vcw_A¶
vcw_A(kz, m, xrho, phi, z, k, pol, /, out=None)
A_kzm = (N_kzm +- M_kzm) / sqrt(2), the singular vector cylindrical wave of helicity pol (1 positive, 0 negative), in cylindrical components (rho, phi, z).
Mirrors treams.special.vcw_A.
Differences from treams: orders |m| up to 128; ValueError at xrho = 0 and k = 0, where treams raises ZeroDivisionError, and for non-finite input.
vcw_M¶
vcw_M(kz, m, xrho, phi, z, /, out=None)
M_kzm(xrho, phi, z), the singular vector cylindrical wave M built on H_m(xrho) exp(i (kz z + m phi)) with xrho = k_rho rho, in cylindrical components (rho, phi, z).
Mirrors treams.special.vcw_M.
Differences from treams: orders |m| up to 128; ValueError at xrho = 0, where treams raises ZeroDivisionError, and for non-finite input.
vcw_N¶
vcw_N(kz, m, xrho, phi, z, k, /, out=None)
N_kzm(xrho, phi, z), the curl of M_kzm divided by k: the singular vector cylindrical wave N, in cylindrical components (rho, phi, z).
Mirrors treams.special.vcw_N.
Differences from treams: orders |m| up to 128; ValueError at xrho = 0 and k = 0, where treams raises ZeroDivisionError, and for non-finite input.
vcw_rA¶
vcw_rA(kz, m, xrho, phi, z, k, pol, /, out=None)
A_kzm = (N_kzm +- M_kzm) / sqrt(2), the regular vector cylindrical wave of helicity pol (1 positive, 0 negative), in cylindrical components (rho, phi, z).
Mirrors treams.special.vcw_rA.
Differences from treams: orders |m| up to 128; ValueError at k = 0, where treams raises ZeroDivisionError, and for non-finite input.
vcw_rM¶
vcw_rM(kz, m, xrho, phi, z, /, out=None)
M_kzm(xrho, phi, z), the regular vector cylindrical wave M built on J_m(xrho) exp(i (kz z + m phi)) with xrho = k_rho rho, in cylindrical components (rho, phi, z).
Mirrors treams.special.vcw_rM.
Differences from treams: orders |m| up to 128; ValueError for non-finite input.
vcw_rN¶
vcw_rN(kz, m, xrho, phi, z, k, /, out=None)
N_kzm(xrho, phi, z), the curl of M_kzm divided by k: the regular vector cylindrical wave N, in cylindrical components (rho, phi, z).
Mirrors treams.special.vcw_rN.
Differences from treams: orders |m| up to 128; ValueError at k = 0, where treams raises ZeroDivisionError, and for non-finite input.
vcyl2car¶
vcyl2car(vector, points, *args, **kwargs)
Transform vector components from the cylindrical to the Cartesian basis.
Positions are given in the input coordinate system; the last axis holds the components and ufunc options are supported.
Mirrors treams.special.vcyl2car.
Differences from treams: ValueError for non-finite input.
vcyl2sph¶
vcyl2sph(vector, points, *args, **kwargs)
Transform vector components from the cylindrical to the spherical basis.
Positions are given in the input coordinate system; the last axis holds the components and ufunc options are supported.
Mirrors treams.special.vcyl2sph.
Differences from treams: ValueError for non-finite input.
vpol2car¶
vpol2car(vector, points, *args, **kwargs)
Transform vector components from the polar to the Cartesian basis.
Positions are given in the input coordinate system; the last axis holds the components and ufunc options are supported.
Mirrors treams.special.vpol2car.
Differences from treams: ValueError for non-finite input.
vpw_A¶
vpw_A(kx, ky, kz, x, y, z, pol, *args, **kwargs)
A_k(r) = (N_k(r) +- M_k(r)) / sqrt(2), the vector plane wave of helicity pol (1 positive, 0 negative).
The last axis holds x, y and z. Python scalars take a direct native path that also accepts complex positions with zero imaginary part. Arrays and ufunc options use the ufunc of the same name, which requires real positions.
Mirrors treams.special.vpw_A.
Differences from treams: ValueError for kx**2 + ky**2 + kz**2 = 0 and for
non-finite input.
vpw_M¶
vpw_M(kx, ky, kz, x, y, z, *args, **kwargs)
M_k(r) = -i phi_hat(k) exp(i k.r), the vector plane wave M.
The last axis holds x, y and z. Python scalars take a direct native path that also accepts complex positions with zero imaginary part. Arrays and ufunc options use the ufunc of the same name, which requires real positions.
Mirrors treams.special.vpw_M.
Differences from treams: ValueError for kx**2 + ky**2 + kz**2 = 0 and for
non-finite input.
vpw_N¶
vpw_N(kx, ky, kz, x, y, z, *args, **kwargs)
N_k(r) = -theta_hat(k) exp(i k.r), the vector plane wave N.
The last axis holds x, y and z. Python scalars take a direct native path that also accepts complex positions with zero imaginary part. Arrays and ufunc options use the ufunc of the same name, which requires real positions.
Mirrors treams.special.vpw_N.
Differences from treams: ValueError for kx**2 + ky**2 + kz**2 = 0 and for
non-finite input.
vsh_X¶
vsh_X(l, m, theta, phi, /, out=None)
X_lm(theta, phi), the vector spherical harmonic tangent to the sphere of the M waves, in spherical components (r, theta, phi).
Mirrors treams.special.vsh_X.
Differences from treams: degrees up to 128; ValueError for non-finite input.
vsh_Y¶
vsh_Y(l, m, theta, phi, /, out=None)
Y_lm(theta, phi) = r_hat x X_lm(theta, phi), in spherical components (r, theta, phi).
Mirrors treams.special.vsh_Y.
Differences from treams: degrees up to 128; ValueError for non-finite input.
vsh_Z¶
vsh_Z(l, m, theta, phi, /, out=None)
Z_lm(theta, phi) = i Y_lm(theta, phi) r_hat, in spherical components (r, theta, phi).
Mirrors treams.special.vsh_Z.
Differences from treams: degrees up to 128; ValueError for non-finite input.
vsph2car¶
vsph2car(vector, points, *args, **kwargs)
Transform vector components from the spherical to the Cartesian basis.
Positions are given in the input coordinate system; the last axis holds the components and ufunc options are supported.
Mirrors treams.special.vsph2car.
Differences from treams: ValueError for non-finite input.
vsph2cyl¶
vsph2cyl(vector, points, *args, **kwargs)
Transform vector components from the spherical to the cylindrical basis.
Positions are given in the input coordinate system; the last axis holds the components and ufunc options are supported.
Mirrors treams.special.vsph2cyl.
Differences from treams: ValueError for non-finite input.
vsw_A¶
vsw_A(l, m, x, theta, phi, p, /, out=None)
A_lm(x, theta, phi) = (N_lm +- M_lm) / sqrt(2), the singular vector spherical wave of helicity p (1 positive, 0 negative), in spherical components (r, theta, phi).
Mirrors treams.special.vsw_A.
Differences from treams: degrees up to 128; ValueError at x = 0, where treams raises ZeroDivisionError, and for non-finite input.
vsw_M¶
vsw_M(l, m, x, theta, phi, /, out=None)
M_lm(x, theta, phi) = h_l(x) X_lm(theta, phi), the singular vector spherical wave M at x = k r, in spherical components (r, theta, phi).
Mirrors treams.special.vsw_M.
Differences from treams: degrees up to 128; ValueError at x = 0, where treams raises ZeroDivisionError, and for non-finite input.
vsw_N¶
vsw_N(l, m, x, theta, phi, /, out=None)
N_lm(x, theta, phi), the curl of M_lm with respect to x = k r: the singular vector spherical wave N, in spherical components (r, theta, phi).
Mirrors treams.special.vsw_N.
Differences from treams: degrees up to 128; ValueError at x = 0, where treams raises ZeroDivisionError, and for non-finite input.
vsw_rA¶
vsw_rA(l, m, x, theta, phi, p, /, out=None)
A_lm(x, theta, phi) = (N_lm +- M_lm) / sqrt(2), the regular vector spherical wave of helicity p (1 positive, 0 negative), in spherical components (r, theta, phi).
Mirrors treams.special.vsw_rA.
Differences from treams: degrees up to 128; ValueError for non-finite input.
vsw_rM¶
vsw_rM(l, m, x, theta, phi, /, out=None)
M_lm(x, theta, phi) = j_l(x) X_lm(theta, phi), the regular vector spherical wave M at x = k r, in spherical components (r, theta, phi).
Mirrors treams.special.vsw_rM.
Differences from treams: degrees up to 128; ValueError for non-finite input.
vsw_rN¶
vsw_rN(l, m, x, theta, phi, /, out=None)
N_lm(x, theta, phi), the curl of M_lm with respect to x = k r: the regular vector spherical wave N, in spherical components (r, theta, phi).
Mirrors treams.special.vsw_rN.
Differences from treams: degrees up to 128; ValueError for non-finite input.
wigner3j¶
wigner3j(j1: ArrayLike, j2: ArrayLike, j3: ArrayLike, m1: ArrayLike, m2: ArrayLike, m3: ArrayLike, *, out: NDArray[np.float64] | None=None, where: ArrayLike=True) -> float | NDArray[np.float64]
Wigner 3j symbol (j1 j2 j3; m1 m2 m3).
Mirrors treams.special.wigner3j. Labels that break the selection rules
(m1 + m2 + m3 = 0, the triangle rule, |mi| <= ji) give 0.
Args
j1: Integer degree.j2: Integer degree.j3: Integer degree.m1: Integer order.m2: Integer order.m3: Integer order.out: Array for the result, as for a NumPy ufunc.where: Mask of the elements to compute, as for a NumPy ufunc.
Returns
float64 array with the broadcast shape of the six labels. Python integers give one float.
Differences from treams
Labels must be integers from -260 to 260; others raise ValueError.
wignerd¶
wignerd(l, m, k, phi, theta, psi, /, out=None, *, where=True)
D^l_mk(phi, theta, psi) = exp(-i m phi) d^l_mk(theta) exp(-i k psi), the Wigner D function.
Mirrors treams.special.wignerd.
Differences from treams: complex phi and psi keep their imaginary parts, which treams drops; degrees up to 128; ValueError for non-finite angles.
wignersmalld¶
wignersmalld(l, m, k, theta, /, out=None, *, where=True)
d^l_mk(theta), the Wigner small-d function.
Mirrors treams.special.wignersmalld.
Differences from treams: complex128 results also for real theta; degrees up to 128; ValueError for non-finite theta.
yv¶
yv(v, z, /, out=None, *, where=True)
Y_v(z), the Bessel function of the second kind of real order v.
Mirrors treams.special.yv.
Differences from treams: complex128 results also for real z, with the principal-branch value (arg z = pi) at z < 0, where treams returns NaN; ValueError for non-finite input, at z = 0 and on overflow.
yv_d¶
yv_d(v, z, /, out=None, *, where=True)
Y_v'(z) = (Y_(v-1)(z) - Y_(v+1)(z)) / 2, the derivative of Y_v.
Mirrors treams.special.yv_d.
Differences from treams: complex128 results also for real z, with the principal-branch value (arg z = pi) at z < 0, where treams returns NaN; ValueError for non-finite input, at z = 0 and on overflow.