本文整理汇总了Python中sympy.core.Catalan类的典型用法代码示例。如果您正苦于以下问题:Python Catalan类的具体用法?Python Catalan怎么用?Python Catalan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Catalan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_octave_noninline
def test_octave_noninline():
source = mcode((x+y)/Catalan, assign_to='me', inline=False)
expected = (
"Catalan = %s;\n"
"me = (x + y)/Catalan;"
) % Catalan.evalf(17)
assert source == expected
开发者ID:Lenqth,项目名称:sympy,代码行数:7,代码来源:test_octave.py
示例2: test_julia_noninline
def test_julia_noninline():
source = julia_code((x+y)/Catalan, assign_to='me', inline=False)
expected = (
"const Catalan = %s\n"
"me = (x + y)/Catalan"
) % Catalan.evalf(17)
assert source == expected
开发者ID:asmeurer,项目名称:sympy,代码行数:7,代码来源:test_julia.py
示例3: test_m_numbersymbol
def test_m_numbersymbol():
name_expr = ("test", pi**Catalan)
result, = codegen(name_expr, "Octave", header=False, empty=False)
source = result[1]
expected = (
"function out1 = test()\n"
" out1 = pi^%s;\n"
"end\n"
) % Catalan.evalf(17)
assert source == expected
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:10,代码来源:test_codegen_octave.py
示例4: test_jscode_inline_function
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,代码行数:12,代码来源:test_jscode.py
示例5: test_numbersymbol
def test_numbersymbol():
name_expr = ("test", pi**Catalan)
result, = codegen(name_expr, "Rust", header=False, empty=False)
source = result[1]
expected = (
"fn test() -> f64 {\n"
" const Catalan: f64 = %s;\n"
" let out1 = PI.powf(Catalan);\n"
" out1\n"
"}\n"
) % Catalan.evalf(17)
assert source == expected
开发者ID:baoqchau,项目名称:sympy,代码行数:12,代码来源:test_codegen_rust.py
示例6: test_C99CodePrinter_custom_type
def test_C99CodePrinter_custom_type():
# We will look at __float128 (new in glibc 2.26)
f128 = FloatType('_Float128', float128.nbits, float128.nmant, float128.nexp)
p128 = C99CodePrinter(dict(
type_aliases={real: f128},
type_literal_suffixes={f128: 'Q'},
type_func_suffixes={f128: 'f128'},
type_math_macro_suffixes={
real: 'f128',
f128: 'f128'
},
type_macros={
f128: ('__STDC_WANT_IEC_60559_TYPES_EXT__',)
}
))
assert p128.doprint(x) == 'x'
assert not p128.headers
assert not p128.libraries
assert not p128.macros
assert p128.doprint(2.0) == '2.0Q'
assert not p128.headers
assert not p128.libraries
assert p128.macros == {'__STDC_WANT_IEC_60559_TYPES_EXT__'}
assert p128.doprint(Rational(1, 2)) == '1.0Q/2.0Q'
assert p128.doprint(sin(x)) == 'sinf128(x)'
assert p128.doprint(cos(2., evaluate=False)) == 'cosf128(2.0Q)'
var5 = Variable(x, f128, attrs={value_const})
dcl5a = Declaration(var5)
assert ccode(dcl5a) == 'const _Float128 x'
var5b = Variable(x, f128, pi, attrs={value_const})
dcl5b = Declaration(var5b)
assert p128.doprint(dcl5b) == 'const _Float128 x = M_PIf128'
var5b = Variable(x, f128, value=Catalan.evalf(38), attrs={value_const})
dcl5c = Declaration(var5b)
assert p128.doprint(dcl5c) == 'const _Float128 x = %sQ' % Catalan.evalf(f128.decimal_dig)
开发者ID:Lenqth,项目名称:sympy,代码行数:38,代码来源:test_ccode.py
示例7: test_jscode_inline_function
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,代码行数:14,代码来源:test_jscode.py
示例8: test_ccode_inline_function
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,代码行数:14,代码来源:test_ccode.py
示例9: test_inline_function
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,代码行数:16,代码来源:test_rust.py
示例10: test_numbersymbol_inline
def test_numbersymbol_inline():
# FIXME: how to pass inline to the RustCodePrinter?
name_expr = ("test", [pi**Catalan, EulerGamma])
result, = codegen(name_expr, "Rust", header=False,
empty=False, inline=True)
source = result[1]
expected = (
"fn test() -> (f64, f64) {\n"
" const Catalan: f64 = %s;\n"
" const EulerGamma: f64 = %s;\n"
" let out1 = PI.powf(Catalan);\n"
" let out2 = EulerGamma);\n"
" (out1, out2)\n"
"}\n"
) % (Catalan.evalf(17), EulerGamma.evalf(17))
assert source == expected
开发者ID:baoqchau,项目名称:sympy,代码行数:16,代码来源:test_codegen_rust.py
示例11: test_rcode_inline_function
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,代码行数:17,代码来源:test_rcode.py
示例12: test_ccode_constants_other
def test_ccode_constants_other():
assert ccode(2*GoldenRatio) == "const double GoldenRatio = %s;\n2*GoldenRatio" % GoldenRatio.evalf(17)
assert ccode(
2*Catalan) == "const double Catalan = %s;\n2*Catalan" % Catalan.evalf(17)
assert ccode(2*EulerGamma) == "const double EulerGamma = %s;\n2*EulerGamma" % EulerGamma.evalf(17)
开发者ID:Lenqth,项目名称:sympy,代码行数:5,代码来源:test_ccode.py
示例13: test_constants_other
def test_constants_other():
assert mcode(2*GoldenRatio) == "2*(1+sqrt(5))/2"
assert mcode(2*Catalan) == "2*%s" % Catalan.evalf(17)
assert mcode(2*EulerGamma) == "2*%s" % EulerGamma.evalf(17)
开发者ID:Lenqth,项目名称:sympy,代码行数:4,代码来源:test_octave.py
示例14: test_jscode_constants_other
def test_jscode_constants_other():
assert jscode(
2*GoldenRatio) == "var GoldenRatio = %s;\n2*GoldenRatio" % GoldenRatio.evalf(17)
assert jscode(2*Catalan) == "var Catalan = %s;\n2*Catalan" % Catalan.evalf(17)
assert jscode(
2*EulerGamma) == "var EulerGamma = %s;\n2*EulerGamma" % EulerGamma.evalf(17)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:6,代码来源:test_jscode.py
示例15: test_constants_other
def test_constants_other():
assert rust_code(2*GoldenRatio) == "const GoldenRatio: f64 = %s;\n2*GoldenRatio" % GoldenRatio.evalf(17)
assert rust_code(
2*Catalan) == "const Catalan: f64 = %s;\n2*Catalan" % Catalan.evalf(17)
assert rust_code(2*EulerGamma) == "const EulerGamma: f64 = %s;\n2*EulerGamma" % EulerGamma.evalf(17)
开发者ID:baoqchau,项目名称:sympy,代码行数:5,代码来源:test_rust.py
注:本文中的sympy.core.Catalan类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论