本文整理汇总了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" "}"
)
示例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"
"}"
)
示例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"
"}"
)
示例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"
"}")
示例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