当前位置: 首页>>代码示例>>Python>>正文


Python Q.real_elements方法代码示例

本文整理汇总了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
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_elemental.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_core.py

示例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
开发者ID:mrocklin,项目名称:computations,代码行数:11,代码来源:test_profile.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:12,代码来源:test_integrative.py

示例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')
开发者ID:mrocklin,项目名称:computations,代码行数:12,代码来源:test_integrative.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:12,代码来源:test_blocks.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:13,代码来源:test_integrative.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:16,代码来源:test_integrative.py

示例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))
开发者ID:mrocklin,项目名称:computations,代码行数:9,代码来源:test_permutation.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_core.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_mpi.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:10,代码来源:test_mpi.py

示例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
开发者ID:mrocklin,项目名称:computations,代码行数:11,代码来源:test_integrative.py

示例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)))
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:11,代码来源:test_matrices.py

示例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)
开发者ID:mrocklin,项目名称:computations,代码行数:11,代码来源:test_blocks.py


注:本文中的sympy.Q.real_elements方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。