Python scipy.special.jnp_zeros() Examples
The following are 7
code examples of scipy.special.jnp_zeros().
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: sphere_models.py From dmipy with MIT License | 6 votes |
def __init__( self, diameter=None, diffusion_constant=CONSTANTS['water_in_axons_diffusion_constant'], number_of_roots=20, number_of_functions=50, ): self.diameter = diameter self.Dintra = diffusion_constant self.alpha = np.empty((number_of_roots, number_of_functions)) self.alpha[0, 0] = 0 if number_of_roots > 1: self.alpha[1:, 0] = special.jnp_zeros(0, number_of_roots - 1) for m in range(1, number_of_functions): self.alpha[:, m] = special.jnp_zeros(m, number_of_roots)
Example #2
Source File: cylinder_models.py From dmipy with MIT License | 6 votes |
def __init__( self, mu=None, lambda_par=None, diameter=None, diffusion_perpendicular=CONSTANTS['water_in_axons_diffusion_constant'], number_of_roots=20, number_of_functions=50, ): self.mu = mu self.lambda_par = lambda_par self.diffusion_perpendicular = diffusion_perpendicular self.diameter = diameter self.alpha = np.empty((number_of_roots, number_of_functions)) self.alpha[0, 0] = 0 if number_of_roots > 1: self.alpha[1:, 0] = special.jnp_zeros(0, number_of_roots - 1) for m in range(1, number_of_functions): self.alpha[:, m] = special.jnp_zeros(m, number_of_roots)
Example #3
Source File: VanGelderenCylindricalRestrictedSignal.py From MDT with GNU Lesser General Public License v3.0 | 6 votes |
def _ncrs_python(self, Delta, delta, d, R, G): if R == 0 or R < np.finfo(float).eps: return 0 GAMMA = 267.5987E6 alpha_roots = jnp_zeros(1, 16) / R sum = 0 for i in range(alpha_roots.shape[0]): alpha = alpha_roots[i] num = (2 * d * alpha**2 * delta - 2 + 2 * np.exp(-d * alpha**2 * delta) + 2 * np.exp(-d * alpha**2 * Delta) - np.exp(-d * alpha**2 * (Delta - delta)) - np.exp(-d * alpha**2 * (Delta + delta))) dem = d**2 * alpha**6 * (R**2 * alpha**2 - 1) sum += (num / dem) return -2 * GAMMA**2 * G**2 * sum
Example #4
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 #5
Source File: disk_harmonic.py From hcipy with MIT License | 5 votes |
def disk_harmonic_energy(n, m, bc='dirichlet'): '''Get the energy of a disk harmonic function. This allows for functions to sort a disk harmonic mode basis on energy. Parameters ---------- n : int Radial order m : int Azimuthal order bc : string The boundary conditions to use. This can be either 'dirichlet', or 'neumann' for a Dirichlet or Neumann boundary condition respectively. Returns ------- scalar The energy corresponding to the mode. Raises ------ ValueError If the boundary condition is not recognized. ''' m = abs(m) if bc == 'dirichlet': lambda_mn = jn_zeros(m, n)[-1] elif bc == 'neumann': lambda_mn = jnp_zeros(m, n)[-1] else: raise ValueError('Boundary condition not recognized.') return lambda_mn**2
Example #6
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 #7
Source File: disk_harmonic.py From hcipy with MIT License | 4 votes |
def disk_harmonic(n, m, D=1, bc='dirichlet', grid=None): '''Create a disk harmonic. Parameters ---------- n : int Radial order m : int Azimuthal order D : scalar The diameter of the pupil. bc : string The boundary conditions to use. This can be either 'dirichlet', or 'neumann' for a Dirichlet or Neumann boundary condition respectively. grid : Grid The grid on which to evaluate the function. Returns ------- Field The disk harmonic function evaluated on `grid`. Raises ------ ValueError If the boundary condition is not recognized. ''' polar_grid = grid.as_('polar') r = 2 * polar_grid.r / D theta = polar_grid.theta m_negative = m < 0 m = abs(m) if bc == 'dirichlet': lambda_mn = jn_zeros(m, n)[-1] norm = 1 elif bc == 'neumann': lambda_mn = jnp_zeros(m, n)[-1] norm = 1 else: raise ValueError('Boundary condition not recognized.') if m_negative: z = norm * jv(m, lambda_mn * r) * np.sin(m * theta) else: z = norm * jv(m, lambda_mn * r) * np.cos(m * theta) # Do manual normalization for now... mask = circular_aperture(D)(grid) > 0.5 norm = np.sqrt(np.sum(z[mask]**2)) return Field(z * mask / norm, grid)