本文整理匯總了Python中odl.FunctionSpace.zero方法的典型用法代碼示例。如果您正苦於以下問題:Python FunctionSpace.zero方法的具體用法?Python FunctionSpace.zero怎麽用?Python FunctionSpace.zero使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類odl.FunctionSpace
的用法示例。
在下文中一共展示了FunctionSpace.zero方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_fspace_vector_real_imag
# 需要導入模塊: from odl import FunctionSpace [as 別名]
# 或者: from odl.FunctionSpace import zero [as 別名]
def test_fspace_vector_real_imag():
rect, _, mg = _standard_setup_2d()
cspace = FunctionSpace(rect, field=odl.ComplexNumbers())
f = cspace.element(cfunc_2d_vec_oop)
# real / imag on complex functions
assert all_equal(f.real(mg), cfunc_2d_vec_oop(mg).real)
assert all_equal(f.imag(mg), cfunc_2d_vec_oop(mg).imag)
out_mg = np.empty((2, 3))
f.real(mg, out=out_mg)
assert all_equal(out_mg, cfunc_2d_vec_oop(mg).real)
f.imag(mg, out=out_mg)
assert all_equal(out_mg, cfunc_2d_vec_oop(mg).imag)
# real / imag on real functions, should be the function itself / zero
rspace = FunctionSpace(rect)
f = rspace.element(func_2d_vec_oop)
assert all_equal(f.real(mg), f(mg))
assert all_equal(f.imag(mg), rspace.zero()(mg))
# Complex conjugate
f = cspace.element(cfunc_2d_vec_oop)
fbar = f.conj()
assert all_equal(fbar(mg), cfunc_2d_vec_oop(mg).conj())
out_mg = np.empty((2, 3), dtype='complex128')
fbar(mg, out=out_mg)
assert all_equal(out_mg, cfunc_2d_vec_oop(mg).conj())
示例2: test_fspace_zero
# 需要導入模塊: from odl import FunctionSpace [as 別名]
# 或者: from odl.FunctionSpace import zero [as 別名]
def test_fspace_zero():
rect, points, mg = _standard_setup_2d()
# real
fspace = FunctionSpace(rect)
zero_vec = fspace.zero()
assert zero_vec([0.5, 1.5]) == 0.0
assert all_equal(zero_vec(points), np.zeros(5, dtype=float))
assert all_equal(zero_vec(mg), np.zeros((2, 3), dtype=float))
# complex
fspace = FunctionSpace(rect, field=odl.ComplexNumbers())
zero_vec = fspace.zero()
assert zero_vec([0.5, 1.5]) == 0.0 + 1j * 0.0
assert all_equal(zero_vec(points), np.zeros(5, dtype=complex))
assert all_equal(zero_vec(mg), np.zeros((2, 3), dtype=complex))