本文整理匯總了Python中numpy.cdouble方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.cdouble方法的具體用法?Python numpy.cdouble怎麽用?Python numpy.cdouble使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy
的用法示例。
在下文中一共展示了numpy.cdouble方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: do
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def do(self, a, b, tags):
d = linalg.det(a)
(s, ld) = linalg.slogdet(a)
if asarray(a).dtype.type in (single, double):
ad = asarray(a).astype(double)
else:
ad = asarray(a).astype(cdouble)
ev = linalg.eigvals(ad)
assert_almost_equal(d, multiply.reduce(ev, axis=-1))
assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))
s = np.atleast_1d(s)
ld = np.atleast_1d(ld)
m = (s != 0)
assert_almost_equal(np.abs(s[m]), 1)
assert_equal(ld[~m], -inf)
示例2: do
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def do(self, a, b):
d = linalg.det(a)
(s, ld) = linalg.slogdet(a)
if asarray(a).dtype.type in (single, double):
ad = asarray(a).astype(double)
else:
ad = asarray(a).astype(cdouble)
ev = linalg.eigvals(ad)
assert_almost_equal(d, multiply.reduce(ev, axis=-1))
assert_almost_equal(s * np.exp(ld), multiply.reduce(ev, axis=-1))
s = np.atleast_1d(s)
ld = np.atleast_1d(ld)
m = (s != 0)
assert_almost_equal(np.abs(s[m]), 1)
assert_equal(ld[~m], -inf)
示例3: test_complex_inf_nan
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_inf_nan():
"""Check inf/nan formatting of complex types."""
TESTS = {
complex(np.inf, 0): "(inf+0j)",
complex(0, np.inf): "inf*j",
complex(-np.inf, 0): "(-inf+0j)",
complex(0, -np.inf): "-inf*j",
complex(np.inf, 1): "(inf+1j)",
complex(1, np.inf): "(1+inf*j)",
complex(-np.inf, 1): "(-inf+1j)",
complex(1, -np.inf): "(1-inf*j)",
complex(np.nan, 0): "(nan+0j)",
complex(0, np.nan): "nan*j",
complex(-np.nan, 0): "(nan+0j)",
complex(0, -np.nan): "nan*j",
complex(np.nan, 1): "(nan+1j)",
complex(1, np.nan): "(1+nan*j)",
complex(-np.nan, 1): "(nan+1j)",
complex(1, -np.nan): "(1+nan*j)",
}
for tp in [np.complex64, np.cdouble, np.clongdouble]:
for c, s in TESTS.items():
yield _check_complex_inf_nan, c, s, tp
示例4: test_complex_inf_nan
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_inf_nan():
"""Check inf/nan formatting of complex types."""
TESTS = {
complex(np.inf, 0): "(inf+0j)",
complex(0, np.inf): "infj",
complex(-np.inf, 0): "(-inf+0j)",
complex(0, -np.inf): "-infj",
complex(np.inf, 1): "(inf+1j)",
complex(1, np.inf): "(1+infj)",
complex(-np.inf, 1): "(-inf+1j)",
complex(1, -np.inf): "(1-infj)",
complex(np.nan, 0): "(nan+0j)",
complex(0, np.nan): "nanj",
complex(-np.nan, 0): "(nan+0j)",
complex(0, -np.nan): "nanj",
complex(np.nan, 1): "(nan+1j)",
complex(1, np.nan): "(1+nanj)",
complex(-np.nan, 1): "(nan+1j)",
complex(1, -np.nan): "(1+nanj)",
}
for tp in [np.complex64, np.cdouble, np.clongdouble]:
for c, s in TESTS.items():
yield _check_complex_inf_nan, c, s, tp
示例5: test_array
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_array(self):
a = np.array([], float)
self.check_roundtrips(a)
a = np.array([[1, 2], [3, 4]], float)
self.check_roundtrips(a)
a = np.array([[1, 2], [3, 4]], int)
self.check_roundtrips(a)
a = np.array([[1 + 5j, 2 + 6j], [3 + 7j, 4 + 8j]], dtype=np.csingle)
self.check_roundtrips(a)
a = np.array([[1 + 5j, 2 + 6j], [3 + 7j, 4 + 8j]], dtype=np.cdouble)
self.check_roundtrips(a)
示例6: test_basic
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_basic(self):
ai32 = np.array([[1, 2], [3, 4]], dtype=np.int32)
af16 = np.array([[1, 2], [3, 4]], dtype=np.float16)
af32 = np.array([[1, 2], [3, 4]], dtype=np.float32)
af64 = np.array([[1, 2], [3, 4]], dtype=np.float64)
acs = np.array([[1+5j, 2+6j], [3+7j, 4+8j]], dtype=np.csingle)
acd = np.array([[1+5j, 2+6j], [3+7j, 4+8j]], dtype=np.cdouble)
assert_(common_type(ai32) == np.float64)
assert_(common_type(af16) == np.float16)
assert_(common_type(af32) == np.float32)
assert_(common_type(af64) == np.float64)
assert_(common_type(acs) == np.csingle)
assert_(common_type(acd) == np.cdouble)
示例7: get_real_dtype
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def get_real_dtype(dtype):
return {single: single, double: double,
csingle: single, cdouble: double}[dtype]
示例8: get_complex_dtype
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def get_complex_dtype(dtype):
return {single: csingle, double: cdouble,
csingle: csingle, cdouble: cdouble}[dtype]
示例9: test_precisions_consistent
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_precisions_consistent(self):
z = 1 + 1j
for f in self.funcs:
fcf = f(np.csingle(z))
fcd = f(np.cdouble(z))
fcl = f(np.clongdouble(z))
assert_almost_equal(fcf, fcd, decimal=6, err_msg='fch-fcd %s' % f)
assert_almost_equal(fcl, fcd, decimal=15, err_msg='fch-fcl %s' % f)
示例10: test_complex_scalar_warning
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_scalar_warning(self):
for tp in [np.csingle, np.cdouble, np.clongdouble]:
x = tp(1+2j)
assert_warns(np.ComplexWarning, float, x)
with suppress_warnings() as sup:
sup.filter(np.ComplexWarning)
assert_equal(float(x), float(x.real))
示例11: test_complex_scalar_complex_cast
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_scalar_complex_cast(self):
for tp in [np.csingle, np.cdouble, np.clongdouble]:
x = tp(1+2j)
assert_equal(complex(x), 1+2j)
示例12: test_complex_boolean_cast
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_complex_boolean_cast(self):
# Ticket #2218
for tp in [np.csingle, np.cdouble, np.clongdouble]:
x = np.array([0, 0+0.5j, 0.5+0j], dtype=tp)
assert_equal(x.astype(bool), np.array([0, 1, 1], dtype=bool))
assert_(np.any(x))
assert_(np.all(x[1:]))
示例13: test_types
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_types(self):
def check(dtype):
x = np.array([[1, 0.5], [0.5, 1]], dtype=dtype)
assert_equal(linalg.solve(x, x).dtype, dtype)
for dtype in [single, double, csingle, cdouble]:
yield check, dtype
示例14: test_zero
# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import cdouble [as 別名]
def test_zero(self):
assert_equal(linalg.det([[0.0]]), 0.0)
assert_equal(type(linalg.det([[0.0]])), double)
assert_equal(linalg.det([[0.0j]]), 0.0)
assert_equal(type(linalg.det([[0.0j]])), cdouble)
assert_equal(linalg.slogdet([[0.0]]), (0.0, -inf))
assert_equal(type(linalg.slogdet([[0.0]])[0]), double)
assert_equal(type(linalg.slogdet([[0.0]])[1]), double)
assert_equal(linalg.slogdet([[0.0j]]), (0.0j, -inf))
assert_equal(type(linalg.slogdet([[0.0j]])[0]), cdouble)
assert_equal(type(linalg.slogdet([[0.0j]])[1]), double)