Python scipy.special.jvp() Examples
The following are 12
code examples of scipy.special.jvp().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
scipy.special
, or try the search function
.
Example #1
Source File: test_basic.py From Computable with MIT License | 6 votes |
def test_h2vp(self): h2 = special.h2vp(1,.1) h2real = (special.jvp(1,.1) - special.yvp(1,.1)*1j) assert_almost_equal(h2,h2real,8)
Example #2
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_h1vp(self): h1 = special.h1vp(1,.1) h1real = (special.jvp(1,.1) + special.yvp(1,.1)*1j) assert_almost_equal(h1,h1real,8)
Example #3
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_jnp_zeros(self): jnp = special.jnp_zeros(1,5) assert_array_almost_equal(jnp, array([1.84118, 5.33144, 8.53632, 11.70600, 14.86359]),4) jnp = special.jnp_zeros(443,5) assert_tol_equal(special.jvp(443, jnp), 0, atol=1e-15)
Example #4
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_jvp(self): jvprim = special.jvp(2,2) jv0 = (special.jv(1,2)-special.jv(3,2))/2 assert_almost_equal(jvprim,jv0,10)
Example #5
Source File: test_basic.py From Computable with MIT License | 5 votes |
def test_lmbda(self): lam = special.lmbda(1,.1) lamr = (array([special.jn(0,.1), 2*special.jn(1,.1)/.1]), array([special.jvp(0,.1), -2*special.jv(1,.1)/.01 + 2*special.jvp(1,.1)/.1])) assert_array_almost_equal(lam,lamr,8)
Example #6
Source File: cylinder_models.py From dmipy with MIT License | 5 votes |
def perpendicular_attenuation(self, q, tau, diameter): "Implements the finite time Callaghan model for cylinders" radius = diameter / 2. alpha = self.alpha q_argument = 2 * np.pi * q * radius q_argument_2 = q_argument ** 2 res = np.zeros_like(q) J = special.j1(q_argument) ** 2 for k in range(0, self.alpha.shape[0]): alpha2 = alpha[k, 0] ** 2 update = ( 4 * np.exp(-alpha2 * self.diffusion_perpendicular * tau / radius ** 2) * q_argument_2 / (q_argument_2 - alpha2) ** 2 * J ) res += update for m in range(1, self.alpha.shape[1]): J = special.jvp(m, q_argument, 1) q_argument_J = (q_argument * J) ** 2 for k in range(self.alpha.shape[0]): alpha2 = self.alpha[k, m] ** 2 update = ( 8 * np.exp(-alpha2 * self.diffusion_perpendicular * tau / radius ** 2) * alpha2 / (alpha2 - m ** 2) * q_argument_J / (q_argument_2 - alpha2) ** 2 ) res += update return res
Example #7
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_h1vp(self): h1 = special.h1vp(1,.1) h1real = (special.jvp(1,.1) + special.yvp(1,.1)*1j) assert_almost_equal(h1,h1real,8)
Example #8
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_h2vp(self): h2 = special.h2vp(1,.1) h2real = (special.jvp(1,.1) - special.yvp(1,.1)*1j) assert_almost_equal(h2,h2real,8)
Example #9
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_jnp_zeros(self): jnp = special.jnp_zeros(1,5) assert_array_almost_equal(jnp, array([1.84118, 5.33144, 8.53632, 11.70600, 14.86359]),4) jnp = special.jnp_zeros(443,5) assert_allclose(special.jvp(443, jnp), 0, atol=1e-15)
Example #10
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_jvp(self): jvprim = special.jvp(2,2) jv0 = (special.jv(1,2)-special.jv(3,2))/2 assert_almost_equal(jvprim,jv0,10)
Example #11
Source File: test_basic.py From GraphicDesignPatternByPython with MIT License | 5 votes |
def test_lmbda(self): lam = special.lmbda(1,.1) lamr = (array([special.jn(0,.1), 2*special.jn(1,.1)/.1]), array([special.jvp(0,.1), -2*special.jv(1,.1)/.01 + 2*special.jvp(1,.1)/.1])) assert_array_almost_equal(lam,lamr,8)
Example #12
Source File: radial.py From sfa-numpy with MIT License | 4 votes |
def circ_radial_weights(N, kr, setup): r"""Radial weighing functions. Computes the radial weighting functions for diferent array types For instance for an rigid array .. math:: b_n(kr) = J_n(kr) - \frac{J_n^\prime(kr)}{H_n^{(2)\prime}(kr)}H_n^{(2)}(kr) Parameters ---------- N : int Maximum order. kr : (M,) array_like Wavenumber * radius. setup : {'open', 'card', 'rigid'} Array configuration (open, cardioids, rigid). Returns ------- bn : (M, 2*N+1) numpy.ndarray Radial weights for all orders up to N and the given wavenumbers. """ kr = util.asarray_1d(kr) n = np.arange(N+1) Bns = np.zeros((len(kr), N+1), dtype=complex) for i, x in enumerate(kr): Jn = special.jv(n, x) if setup == 'open': bn = Jn elif setup == 'card': bn = Jn - 1j * special.jvp(n, x, n=1) elif setup == 'rigid': if x == 0: # Hn(x)/Hn'(x) -> 0 for x -> 0 bn = Jn else: Jnd = special.jvp(n, x, n=1) Hn = special.hankel2(n, x) Hnd = special.h2vp(n, x) bn = Jn - Jnd/Hnd*Hn else: raise ValueError('setup must be either: open, card or rigid') Bns[i, :] = bn Bns = np.concatenate((Bns, (Bns*(-1)**np.arange(N+1))[:, :0:-1]), axis=-1) return np.squeeze(Bns)