本文整理汇总了Python中sympy.Q.real_elements方法的典型用法代码示例。如果您正苦于以下问题:Python Q.real_elements方法的具体用法?Python Q.real_elements怎么用?Python Q.real_elements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.Q
的用法示例。
在下文中一共展示了Q.real_elements方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ElemProd_code
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_ElemProd_code():
from computations.matrices.fortran.core import generate
ic = inplace_compile(c)
with assuming(Q.real_elements(x), Q.real_elements(y)):
s = generate(ic, [x,y], [HadamardProduct(x,y)])
with open('tmp/elem_test.f90','w') as f:
f.write(s)
assert "= X * Y" in s
示例2: test_numerics
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_numerics():
import numpy as np
with assuming(Q.real_elements(X), Q.real_elements(y)):
f = build(ic, inputs, outputs, filename='numerics.f90',
modname='numerics')
nX, ny = np.ones((5, 5)), np.ones(5)
result = np.matrix(nX) * np.matrix(ny).T
assert np.allclose(f(nX, ny), result)
示例3: test_execution
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_execution():
with assuming(Q.real_elements(X), Q.real_elements(Y)):
f = build(pgemm, [X, Y], [pgemm.duration], filename='tmp/profile.f90',
modname='profile')
assert callable(f)
nX, nY = np.random.rand(500, 500), np.random.rand(500, 500)
result = f(nX, nY)
assert isinstance(result, float)
assert result > 0
示例4: test_GEMM
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_GEMM():
with assuming(Q.real_elements(A), Q.real_elements(X)):
f = build(GEMM(1.0, A, X, 0.0, ZeroMatrix(A.rows, X.cols)),
[A, X], [A*X], modname='gemmtest', filename='tmp/gemmtest.f90')
nA = np.asarray([[1, 2], [3, 4]], dtype=np.float64, order='F')
nX = np.asarray([[1, 1], [1, 1]], dtype=np.float64, order='F')
expected = np.asarray([[3., 3.], [7., 7.]])
result = f(nA, nX)
assert np.allclose(expected, result)
示例5: test_es_toy
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_es_toy():
K = MatrixSymbol('K',n,1)
phi = MatrixSymbol('phi', n, 1)
V = MatrixSymbol('V',n,1)
c = AXPY(1.0, HP(K,phi), DFT(n).T*HP(V,DFT(n)*phi)) + ElemProd(K,phi) + IFFTW(HP(V, DFT(n) * phi)) + FFTW(phi) + ElemProd(V, DFT(n) * phi)
# show(c)
with assuming(Q.complex_elements(phi), Q.real_elements(K), Q.real_elements(V)):
f = build(c, [K,V,phi], [HP(K,phi) + DFT(n).T * HP(V,DFT(n) * phi)],
modname='es', filename='tmp/es.f90')
示例6: test_Join_build
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_Join_build():
c = Join(B)
with assuming(Q.real_elements(X), Q.real_elements(Y)):
f = build(c, [X, Y], [B], filename='tmp/join.f90', modname='join')
nX = np.ones((2, 3), dtype=np.float64)
nY = np.ones((2, 3), dtype=np.float64)
result = f(nX, nY)
expected = np.ones((2, 6), dtype=np.float64)
assert np.allclose(result, expected)
示例7: test_POSV
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_POSV():
c = POSV(A, y)
with assuming(Q.real_elements(A), Q.real_elements(y)):
f = build(c, [A, y], [A.I*y], modname='posv', filename='tmp/posv.f90')
nA, ny = np.asarray([[2, 1], [1, 2]], dtype='float64').reshape((2, 2)), np.ones(2)
mA = np.matrix(nA)
my = np.matrix(ny).T
expected = np.linalg.solve(mA, my)
f(nA, ny)
assert np.allclose(expected, ny)
示例8: test_POTRS
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_POTRS():
from sympy.matrices.expressions.factorizations import UofCholesky
from computations.matrices.lapack import POTRS
c = POTRS(UofCholesky(A), X)
with assuming(Q.real_elements(A), Q.real_elements(X),
Q.positive_definite(A)):
f = build(c, [UofCholesky(A), X], [A.I*X], modname='potrs',
filename='tmp/potrs.f90')
nA = np.asarray([[1, 0], [0, 1]], dtype=np.float64, order='F')
nX = np.asarray([[1, 2], [3, 4]], dtype=np.float64, order='F')
expected = np.asarray([[1., 2.], [3., 4.]])
f(nA, nX); result = nX
assert np.allclose(expected, result)
示例9: test_assumptions
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_assumptions():
n = Symbol('n')
A = MatrixSymbol('A', 1, n)
P = PermutationMatrix(A)
assert ask(Q.integer_elements(P))
assert ask(Q.real_elements(P))
assert ask(Q.complex_elements(P))
示例10: test_dtype_of
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_dtype_of():
X = MatrixSymbol('X', n, n)
assert 'integer' in dtype_of(X, Q.integer_elements(X))
assert 'real' in dtype_of(X, Q.real_elements(X))
assert 'complex' in dtype_of(X, Q.complex_elements(X))
alpha = Symbol('alpha', integer=True)
assert 'integer' in dtype_of(alpha)
示例11: test_send_fortran_generate
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_send_fortran_generate():
from computations.inplace import inplace_compile
from computations.matrices.fortran.core import generate
A = MatrixSymbol('A', 10, 10)
s = Send(A, 1)
iss = inplace_compile(s)
with assuming(Q.real_elements(A)): code = generate(iss, [A], [])
assert isinstance(code, str)
示例12: test_recv_fortran_generate
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_recv_fortran_generate():
from computations.inplace import inplace_compile
from computations.matrices.fortran.core import generate
A = MatrixSymbol('A', 10, 10)
r = Recv(A, 2)
irr = inplace_compile(r)
with assuming(Q.real_elements(A)): code = generate(irr, [], [A])
assert isinstance(code, str)
示例13: test_ReadFromFile
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_ReadFromFile():
from computations.matrices.io import ReadFromFile
X = MatrixSymbol('X', 2, 3)
with assuming(Q.real_elements(X)):
f = build(ReadFromFile('tmp/test_read.dat', X), [], [X],
modname='readtest', filename='tmp/readtest.f90')
result = f()
assert result[0, 0] == 1.0
示例14: test_matrix_element_sets
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_matrix_element_sets():
X = MatrixSymbol('X', 4, 4)
assert ask(Q.real(X[1, 2]), Q.real_elements(X))
assert ask(Q.integer(X[1, 2]), Q.integer_elements(X))
assert ask(Q.complex(X[1, 2]), Q.complex_elements(X))
assert ask(Q.integer_elements(Identity(3)))
assert ask(Q.integer_elements(ZeroMatrix(3, 3)))
from sympy.matrices.expressions.fourier import DFT
assert ask(Q.complex_elements(DFT(3)))
示例15: test_Slice_build
# 需要导入模块: from sympy import Q [as 别名]
# 或者: from sympy.Q import real_elements [as 别名]
def test_Slice_build():
c = Slice(X[:2, :2])
with assuming(Q.real_elements(X)):
f = build(c, [X], [X[:2, :2]], filename='tmp/slice.f90', modname='slice')
nX = np.eye(3, dtype=np.float64)
result = f(nX)
expected = np.eye(2, dtype=np.float64)
assert np.allclose(result, expected)