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


Python Catalan.n方法代码示例

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


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

示例1: test_jscode_inline_function

# 需要导入模块: from sympy.core import Catalan [as 别名]
# 或者: from sympy.core.Catalan import n [as 别名]
def test_jscode_inline_function():
    x = symbols("x")
    g = implemented_function("g", Lambda(x, 2 * x))
    assert jscode(g(x)) == "2*x"
    g = implemented_function("g", Lambda(x, 2 * x / Catalan))
    assert jscode(g(x)) == "var Catalan = %s;\n2*x/Catalan" % Catalan.n()
    A = IndexedBase("A")
    i = Idx("i", symbols("n", integer=True))
    g = implemented_function("g", Lambda(x, x * (1 + x) * (2 + x)))
    assert jscode(g(A[i]), assign_to=A[i]) == (
        "for (var i=0; i<n; i++){\n" "   A[i] = A[i]*(1 + A[i])*(2 + A[i]);\n" "}"
    )
开发者ID:cbr-washington-edu,项目名称:branch,代码行数:14,代码来源:test_jscode.py

示例2: test_jscode_inline_function

# 需要导入模块: from sympy.core import Catalan [as 别名]
# 或者: from sympy.core.Catalan import n [as 别名]
def test_jscode_inline_function():
    x = symbols('x')
    g = implemented_function('g', Lambda(x, 2*x))
    assert jscode(g(x)) == "2*x"
    g = implemented_function('g', Lambda(x, 2*x/Catalan))
    assert jscode(g(x)) == "var Catalan = %s;\n2*x/Catalan" % Catalan.n()
    A = IndexedBase('A')
    i = Idx('i', symbols('n', integer=True))
    g = implemented_function('g', Lambda(x, x*(1 + x)*(2 + x)))
    assert jscode(g(A[i]), assign_to=A[i]) == (
        "for (var i=0; i<n; i++){\n"
        "   A[i] = (A[i] + 1)*(A[i] + 2)*A[i];\n"
        "}"
    )
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:16,代码来源:test_jscode.py

示例3: test_ccode_inline_function

# 需要导入模块: from sympy.core import Catalan [as 别名]
# 或者: from sympy.core.Catalan import n [as 别名]
def test_ccode_inline_function():
    x = symbols('x')
    g = implemented_function('g', Lambda(x, 2*x))
    assert ccode(g(x)) == "2*x"
    g = implemented_function('g', Lambda(x, 2*x/Catalan))
    assert ccode(g(x)) == "double const Catalan = %s;\n2*x/Catalan" %Catalan.n()
    A = IndexedBase('A')
    i = Idx('i', symbols('n', integer=True))
    g = implemented_function('g', Lambda(x, x*(1 + x)*(2 + x)))
    assert ccode(g(A[i]), assign_to=A[i]) == (
            "for (int i=0; i<n; i++){\n"
            "   A[i] = A[i]*(1 + A[i])*(2 + A[i]);\n"
            "}"
            )
开发者ID:bibile,项目名称:sympy,代码行数:16,代码来源:test_ccode.py

示例4: test_inline_function

# 需要导入模块: from sympy.core import Catalan [as 别名]
# 或者: from sympy.core.Catalan import n [as 别名]
def test_inline_function():
    x = symbols('x')
    g = implemented_function('g', Lambda(x, 2*x))
    assert rust_code(g(x)) == "2*x"

    g = implemented_function('g', Lambda(x, 2*x/Catalan))
    assert rust_code(g(x)) == (
        "const Catalan: f64 = %s;\n2*x/Catalan" % Catalan.n())

    A = IndexedBase('A')
    i = Idx('i', symbols('n', integer=True))
    g = implemented_function('g', Lambda(x, x*(1 + x)*(2 + x)))
    assert rust_code(g(A[i]), assign_to=A[i]) == (
        "for i in 0..n {\n"
        "    A[i] = (A[i] + 1)*(A[i] + 2)*A[i];\n"
        "}")
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:18,代码来源:test_rust.py

示例5: test_rcode_inline_function

# 需要导入模块: from sympy.core import Catalan [as 别名]
# 或者: from sympy.core.Catalan import n [as 别名]
def test_rcode_inline_function():
    x = symbols('x')
    g = implemented_function('g', Lambda(x, 2*x))
    assert rcode(g(x)) == "2*x"
    g = implemented_function('g', Lambda(x, 2*x/Catalan))
    assert rcode(
        g(x)) == "Catalan = %s;\n2*x/Catalan" % Catalan.n()
    A = IndexedBase('A')
    i = Idx('i', symbols('n', integer=True))
    g = implemented_function('g', Lambda(x, x*(1 + x)*(2 + x)))
    res=rcode(g(A[i]), assign_to=A[i])
    ref=(
        "for (i in 1:n){\n"
        "   A[i] = (A[i] + 1)*(A[i] + 2)*A[i];\n"
        "}"
    )
    assert res == ref
开发者ID:chris-turner137,项目名称:sympy,代码行数:19,代码来源:test_rcode.py


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