pymiediff.special.sph_jn_torch

Contents

pymiediff.special.sph_jn_torch#

pymiediff.special.sph_jn_torch(n: Tensor | int, z: Tensor, n_add: str | int = 'auto', max_n_add: int = 50, small_z: float = 1e-08, precision='double', **kwargs)#

Vectorized spherical Bessel of the first kind via continued-fraction ratios.

Returns all orders. Small z are evaluated with Taylor series for more stability and efficiency. Vectorized over all z (we flatten then reshape back). Caution: May be unstable for extremely large |Im z|. You may try to increase n_add.

Parameters:
  • n (torch.Tensor or int) – integer order(s)

  • z (torch.Tensor) – complex (or real) arguments to evalute

  • n_add (str or int) – ‘auto’ or integer extra depth for the continued fraction (seed truncation). ‘auto’ picks a safe default based on max|z|. defaults to “auto”

  • max_n_add (int) – upper bound for automatic extra depth (protects against huge loops). defaults to 50.

  • small_z (float) – threshold to treat z as small and use Taylor-series for those entries. Defaults to 1e-8.

  • precision (str) – “single” our “double”. defaults to “double”.

  • kwargs – other kwargs are ignored

Returns:

tensor of same shape of input z + (n_max+1,) dimension, where last dim indexes order n=0..n_max.

Return type:

torch.Tensor