def test_pcfd(self): def pcfd(v, x): return sc.pbdv(v, x)[0] assert_mpmath_equal( pcfd, _exception_to_nan(lambda v, x: mpmath.pcfd(v, x, **HYPERKW)), [Arg(), Arg()])
def pcfd( nu, z, ): """ Computes the parabolic cylinder function. The parameters nu and z may be complex. Further, one of them may be a numpy array. This always uses mpmath for the time being as the c implementation is unreliable. """ uselib = lib is not None and not use_mpmath #if not uselib and mp is None: # mp = __import__("mpmath") if (np.ndim(nu) + np.ndim(z) > 1): raise TypeError("at most one parameter may be a numpy array") if False: # if lib is not None and not use_mpmath: p = PrmsAndInfo(c_int(max_iter), c_double(tol), c_int(0), c_double(0)) if (np.ndim(nu) == 1): out = np.zeros(len(nu), dtype=np.complex128) lib.pcfd_nu_arr(nu.astype(np.complex128), cmpl(z), out, len(out), byref(p)) return out elif (np.ndim(z) == 1): out = np.zeros(len(z), dtype=np.complex128) lib.pcfd_z_arr(cmpl(nu), z.astype(np.complex128), out, len(out), byref(p)) return out else: c = lib.pcfd2(cmpl(nu), cmpl(z), byref(p)) return c.re + 1j * c.im else: if (np.ndim(nu) == 1): return np.array([np.complex128(mp.pcfd(nunu, z)) for nunu in nu]) elif (np.ndim(z) == 1): return np.array([np.complex128(mp.pcfd(nu, zz)) for zz in z]) else: return np.complex128(mp.pcfd(nu, z))
def test_pcfd(self): def pcfd(v, x): return sc.pbdv(v, x)[0] assert_mpmath_equal(pcfd, _exception_to_nan(lambda v, x: mpmath.pcfd(v, x, **HYPERKW)), [Arg(), Arg()])