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


Python abc.a方法代码示例

本文整理汇总了Python中sympy.abc.a方法的典型用法代码示例。如果您正苦于以下问题:Python abc.a方法的具体用法?Python abc.a怎么用?Python abc.a使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sympy.abc的用法示例。


在下文中一共展示了abc.a方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wigner_d_function

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def wigner_d_function(l, m, n, beta,
                      field='real', normalization='quantum', order='centered', condon_shortley='cs'):
    """
    Evaluate a single Wigner-d function d^l_mn(beta)

    NOTE: for now, we implement this by computing the entire degree-l Wigner-d matrix and then selecting
    the (m,n) element, so this function is not fast.

    :param l: the degree of the Wigner-d function. l >= 0
    :param m: the order of the Wigner-d function. -l <= m <= l
    :param n: the order of the Wigner-d function. -l <= n <= l
    :param beta: the argument. 0 <= beta <= pi
    :param field: 'real' or 'complex'
    :param normalization: 'quantum', 'seismology', 'geodesy' or 'nfft'
    :param order: 'centered' or 'block'
    :param condon_shortley: 'cs' or 'nocs'
    :return: d^l_mn(beta) in the chosen basis
    """
    return wigner_d_matrix(l, beta, field, normalization, order, condon_shortley)[l + m, l + n] 
开发者ID:AMLab-Amsterdam,项目名称:lie_learn,代码行数:21,代码来源:wigner_d.py

示例2: wigner_D_function

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def wigner_D_function(l, m, n, alpha, beta, gamma,
                      field='real', normalization='quantum', order='centered', condon_shortley='cs'):
    """
    Evaluate a single Wigner-d function d^l_mn(beta)

    NOTE: for now, we implement this by computing the entire degree-l Wigner-D matrix and then selecting
    the (m,n) element, so this function is not fast.

    :param l: the degree of the Wigner-d function. l >= 0
    :param m: the order of the Wigner-d function. -l <= m <= l
    :param n: the order of the Wigner-d function. -l <= n <= l
    :param alpha: the argument. 0 <= alpha <= 2 pi
    :param beta: the argument. 0 <= beta <= pi
    :param gamma: the argument. 0 <= gamma <= 2 pi
    :param field: 'real' or 'complex'
    :param normalization: 'quantum', 'seismology', 'geodesy' or 'nfft'
    :param order: 'centered' or 'block'
    :param condon_shortley: 'cs' or 'nocs'
    :return: d^l_mn(beta) in the chosen basis
    """
    return wigner_D_matrix(l, alpha, beta, gamma, field, normalization, order, condon_shortley)[l + m, l + n] 
开发者ID:AMLab-Amsterdam,项目名称:lie_learn,代码行数:23,代码来源:wigner_d.py

示例3: wigner_D_norm

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def wigner_D_norm(l, normalized_haar=True):
    """
    Compute the squared norm of the Wigner-D functions.

    The squared norm of a function on the SO(3) is defined as
    |f|^2 = int_SO(3) |f(g)|^2 dg
    where dg is a Haar measure.

    :param l: for some normalization conventions, the norm of a Wigner-D function D^l_mn depends on the degree l
    :param normalized_haar: whether to use the Haar measure da db sinb dc or the normalized Haar measure
     da db sinb dc / 8pi^2
    :return: the squared norm of the spherical harmonic with respect to given measure

    :param l:
    :param normalization:
    :return:
    """
    if normalized_haar:
        return 1. / (2 * l + 1)
    else:
        return (8 * np.pi ** 2) / (2 * l + 1) 
开发者ID:AMLab-Amsterdam,项目名称:lie_learn,代码行数:23,代码来源:wigner_d.py

示例4: wigner_d_naive_v2

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def wigner_d_naive_v2(l, m, n, beta):
    """
    Wigner d functions as defined in the SOFT 2.0 documentation.
    When approx_lim is set to a high value, this function appears to give
    identical results to Johann Goetz' wignerd() function.

    However, integration fails: does not satisfy orthogonality relations everywhere...
    """
    from scipy.special import jacobi

    if n >= m:
        xi = 1
    else:
        xi = (-1)**(n - m)

    mu = np.abs(m - n)
    nu = np.abs(n + m)
    s = l - (mu + nu) * 0.5

    sq = np.sqrt((np.math.factorial(s) * np.math.factorial(s + mu + nu))
                 / (np.math.factorial(s + mu) * np.math.factorial(s + nu)))
    sinb = np.sin(beta * 0.5) ** mu
    cosb = np.cos(beta * 0.5) ** nu
    P = jacobi(s, mu, nu)(np.cos(beta))
    return xi * sq * sinb * cosb * P 
开发者ID:AMLab-Amsterdam,项目名称:lie_learn,代码行数:27,代码来源:wigner_d.py

示例5: test_get_most_simple_representation

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def test_get_most_simple_representation(self):
        cpl = get_most_simple_representation(qc_sympify('1 + 1j'))
        self.assertIsInstance(cpl, str)
        self.assertTrue(bool(sympy.Eq(sympy.sympify(cpl), 1 + 1j)))

        integer = get_most_simple_representation(qc_sympify('3'))
        self.assertIsInstance(integer, int)
        self.assertEqual(integer, 3)

        flt = get_most_simple_representation(qc_sympify('3.1'))
        self.assertIsInstance(flt, float)
        self.assertEqual(flt, 3.1)

        st = get_most_simple_representation(qc_sympify('a + b'))
        self.assertIsInstance(st, str)
        self.assertEqual(st, 'a + b') 
开发者ID:qutech,项目名称:qupulse,代码行数:18,代码来源:sympy_tests.py

示例6: test_symbolic_shape

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def test_symbolic_shape(self):
        symbolic = Broadcast(a, (b,))
        self.assertIs(symbolic.func, Broadcast)
        self.assertEqual(symbolic.args, (a, (b,)))

        subs_b = symbolic.subs({b: 6})
        self.assertIs(subs_b.func, Broadcast)
        self.assertEqual(subs_b.args, (a, (6,)))

        subs_a = symbolic.subs({a: 3})
        self.assertIs(subs_a.func, Broadcast)
        self.assertEqual(subs_a.args, (3, (b,)))

        subs_both_scalar = symbolic.subs({a: 3, b: 6})
        self.assertEqual(subs_both_scalar, sympy.Array([3, 3, 3, 3, 3, 3]))

        subs_both_array = symbolic.subs({a: (1, 2, 3, 4, 5, 6), b: 6})
        self.assertEqual(subs_both_array, sympy.Array([1, 2, 3, 4, 5, 6]))

        with self.assertRaises(ValueError):
            symbolic.subs({a: (1, 2, 3, 4, 5, 6), b: 7}) 
开发者ID:qutech,项目名称:qupulse,代码行数:23,代码来源:sympy_tests.py

示例7: test_scalar_broad_cast

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def test_scalar_broad_cast(self):
        symbolic = Broadcast(a, (6,))
        self.assertIs(symbolic.func, Broadcast)
        self.assertEqual(symbolic.args, (a, (6,)))

        subs_symbol = symbolic.subs({a: b})
        self.assertIs(subs_symbol.func, Broadcast)
        self.assertEqual(subs_symbol.args, (b, (6,)))

        subs_scalar = symbolic.subs({a: 3.4})
        self.assertEqual(subs_scalar, sympy.Array([3.4, 3.4, 3.4, 3.4, 3.4, 3.4]))

        subs_symbol_vector = symbolic.subs({a: (b, 1, 2, 3, 4, 5)})
        self.assertEqual(subs_symbol_vector, sympy.Array([b, 1, 2, 3, 4, 5]))

        subs_numeric_vector = symbolic.subs({a: (0, 1, 2, 3, 4, 5)})
        self.assertEqual(subs_numeric_vector, sympy.Array([0, 1, 2, 3, 4, 5]))

        with self.assertRaises(ValueError):
            symbolic.subs({a: (b, 4, 5)})

        with self.assertRaises(ValueError):
            symbolic.subs({a: (8, 5, 3, 5, 5, 4, 4, 5)}) 
开发者ID:qutech,项目名称:qupulse,代码行数:25,代码来源:sympy_tests.py

示例8: test_numeric_evaluation

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def test_numeric_evaluation(self):
        symbolic = Broadcast(a, (b,))

        arguments = {'a': (1, 2., 3), 'b': 3}
        expected = np.asarray([1, 2., 3])
        result, _ = evaluate_lambdified(symbolic, ['a', 'b'], arguments, None)
        np.testing.assert_array_equal(expected, result)

        with self.assertRaises(ValueError):
            arguments = {'a': (1, 2., 3), 'b': 4}
            evaluate_lambdified(symbolic, ['a', 'b'], arguments, None)

        arguments = {'a': 1, 'b': 3}
        expected = np.asarray([1, 1, 1])
        result, _ = evaluate_lambdified(symbolic, ['a', 'b'], arguments, None)
        np.testing.assert_array_equal(expected, result) 
开发者ID:qutech,项目名称:qupulse,代码行数:18,代码来源:sympy_tests.py

示例9: test_RandomDomain

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def test_RandomDomain():
    from sympy.stats import Normal, Die, Exponential, pspace, where
    X = Normal('x1', 0, 1)
    assert upretty(where(X > 0)) == u("Domain: x₁ > 0")

    D = Die('d1', 6)
    assert upretty(where(D > 4)) == u('Domain: d₁ = 5 ∨ d₁ = 6')

    A = Exponential('a', 1)
    B = Exponential('b', 1)
    assert upretty(pspace(Tuple(A, B)).domain) == u('Domain: a ≥ 0 ∧ b ≥ 0') 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:13,代码来源:test_pretty.py

示例10: theano_simplify

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def theano_simplify(fgraph):
    """ Simplify a Theano Computation """
    mode = theano.compile.get_default_mode().excluding("fusion")
    fgraph = fgraph.clone()
    mode.optimizer.optimize(fgraph)
    return fgraph 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:8,代码来源:test_theanocode.py

示例11: theq

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def theq(a, b):
    """ theano equality """
    astr = theano.printing.debugprint(a, file='str')
    bstr = theano.printing.debugprint(b, file='str')

    if not astr == bstr:
        print()
        print(astr)
        print(bstr)

    return astr == bstr 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:13,代码来源:test_theanocode.py

示例12: wigner_d_naive

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def wigner_d_naive(l, m, n, beta):
    """
    Numerically naive implementation of the Wigner-d function.
    This is useful for checking the correctness of other implementations.

    :param l: the degree of the Wigner-d function. l >= 0
    :param m: the order of the Wigner-d function. -l <= m <= l
    :param n: the order of the Wigner-d function. -l <= n <= l
    :param beta: the argument. 0 <= beta <= pi
    :return: d^l_mn(beta) in the TODO: what basis? complex, quantum(?), centered, cs(?)
    """
    from scipy.special import eval_jacobi
    try:
        from scipy.misc import factorial
    except:
        from scipy.special import factorial

    from sympy.functions.special.polynomials import jacobi, jacobi_normalized
    from sympy.abc import j, a, b, x
    from sympy import N
    #jfun = jacobi_normalized(j, a, b, x)
    jfun = jacobi(j, a, b, x)
    # eval_jacobi = lambda q, r, p, o: float(jfun.eval(int(q), int(r), int(p), float(o)))
    # eval_jacobi = lambda q, r, p, o: float(N(jfun, int(q), int(r), int(p), float(o)))
    eval_jacobi = lambda q, r, p, o: float(jfun.subs({j:int(q), a:int(r), b:int(p), x:float(o)}))

    mu = np.abs(m - n)
    nu = np.abs(m + n)
    s = l - (mu + nu) / 2
    xi = 1 if n >= m else (-1) ** (n - m)

    # print(s, mu, nu, np.cos(beta), type(s), type(mu), type(nu), type(np.cos(beta)))
    jac = eval_jacobi(s, mu, nu, np.cos(beta))
    z = np.sqrt((factorial(s) * factorial(s + mu + nu)) / (factorial(s + mu) * factorial(s + nu)))

    # print(l, m, n, beta, np.isfinite(mu), np.isfinite(nu), np.isfinite(s), np.isfinite(xi), np.isfinite(jac), np.isfinite(z))
    assert np.isfinite(mu) and np.isfinite(nu) and np.isfinite(s) and np.isfinite(xi) and np.isfinite(jac) and np.isfinite(z)
    assert np.isfinite(xi * z * np.sin(beta / 2) ** mu * np.cos(beta / 2) ** nu * jac)
    return xi * z * np.sin(beta / 2) ** mu * np.cos(beta / 2) ** nu * jac 
开发者ID:AMLab-Amsterdam,项目名称:lie_learn,代码行数:41,代码来源:wigner_d.py

示例13: test_get_free_symbols

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def test_get_free_symbols(self):
        expr = a * b / 5
        self.assert_symbol_sets_equal([a, b], get_free_symbols(expr)) 
开发者ID:qutech,项目名称:qupulse,代码行数:5,代码来源:sympy_tests.py

示例14: test_get_free_symbols_indexed

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def test_get_free_symbols_indexed(self):
        expr = a_[i] * IndexedBase(a*b)[j]
        self.assert_symbol_sets_equal({a, b, i, j}, set(get_free_symbols(expr))) 
开发者ID:qutech,项目名称:qupulse,代码行数:5,代码来源:sympy_tests.py

示例15: test_get_variables

# 需要导入模块: from sympy import abc [as 别名]
# 或者: from sympy.abc import a [as 别名]
def test_get_variables(self):
        expr = a * b / 5
        self.assertEqual({'a', 'b'}, set(get_variables(expr))) 
开发者ID:qutech,项目名称:qupulse,代码行数:5,代码来源:sympy_tests.py


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