本文整理汇总了Python中sympy.functions.ceiling函数的典型用法代码示例。如果您正苦于以下问题:Python ceiling函数的具体用法?Python ceiling怎么用?Python ceiling使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ceiling函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_ccode_exceptions
def test_ccode_exceptions():
assert ccode(gamma(x), standard='C99') == "tgamma(x)"
gamma_c89 = ccode(gamma(x), standard='C89')
assert 'not supported in c' in gamma_c89.lower()
gamma_c89 = ccode(gamma(x), standard='C89', allow_unknown_functions=False)
assert 'not supported in c' in gamma_c89.lower()
gamma_c89 = ccode(gamma(x), standard='C89', allow_unknown_functions=True)
assert not 'not supported in c' in gamma_c89.lower()
assert ccode(ceiling(x)) == "ceil(x)"
assert ccode(Abs(x)) == "fabs(x)"
assert ccode(gamma(x)) == "tgamma(x)"
r, s = symbols('r,s', real=True)
assert ccode(Mod(ceiling(r), ceiling(s))) == "((ceil(r)) % (ceil(s)))"
assert ccode(Mod(r, s)) == "fmod(r, s)"
开发者ID:Lenqth,项目名称:sympy,代码行数:14,代码来源:test_ccode.py
示例2: _eval_evalf
def _eval_evalf(self, prec):
# The default code is insufficient for polar arguments.
# mpmath provides an optional argument "r", which evaluates
# G(z**(1/r)). I am not sure what its intended use is, but we hijack it
# here in the following way: to evaluate at a number z of |argument|
# less than (say) n*pi, we put r=1/n, compute z' = root(z, n)
# (carefully so as not to loose the branch information), and evaluate
# G(z'**(1/r)) = G(z'**n) = G(z).
from sympy.functions import exp_polar, ceiling
from sympy import Expr
import mpmath
z = self.argument
znum = self.argument._eval_evalf(prec)
if znum.has(exp_polar):
znum, branch = znum.as_coeff_mul(exp_polar)
if len(branch) != 1:
return
branch = branch[0].args[0]/I
else:
branch = S(0)
n = ceiling(abs(branch/S.Pi)) + 1
znum = znum**(S(1)/n)*exp(I*branch / n)
# Convert all args to mpf or mpc
try:
[z, r, ap, bq] = [arg._to_mpmath(prec)
for arg in [znum, 1/n, self.args[0], self.args[1]]]
except ValueError:
return
with mpmath.workprec(prec):
v = mpmath.meijerg(ap, bq, z, r)
return Expr._from_mpmath(v, prec)
开发者ID:moorepants,项目名称:sympy,代码行数:34,代码来源:hyper.py
示例3: crack_when_pq_close
def crack_when_pq_close(n):
t = ceiling(sqrt(n))
while True:
k = t**2 - n
if k > 0:
s = round(int(sqrt(t**2 - n)))
if s**2 + n == t**2:
return t + s, t - s
t += 1
开发者ID:wangjiezhe,项目名称:ent_note,代码行数:9,代码来源:rsa.py
示例4: test_C99CodePrinter__precision
def test_C99CodePrinter__precision():
n = symbols('n', integer=True)
f32_printer = C99CodePrinter(dict(type_aliases={real: float32}))
f64_printer = C99CodePrinter(dict(type_aliases={real: float64}))
f80_printer = C99CodePrinter(dict(type_aliases={real: float80}))
assert f32_printer.doprint(sin(x+2.1)) == 'sinf(x + 2.1F)'
assert f64_printer.doprint(sin(x+2.1)) == 'sin(x + 2.1000000000000001)'
assert f80_printer.doprint(sin(x+Float('2.0'))) == 'sinl(x + 2.0L)'
for printer, suffix in zip([f32_printer, f64_printer, f80_printer], ['f', '', 'l']):
def check(expr, ref):
assert printer.doprint(expr) == ref.format(s=suffix, S=suffix.upper())
check(Abs(n), 'abs(n)')
check(Abs(x + 2.0), 'fabs{s}(x + 2.0{S})')
check(sin(x + 4.0)**cos(x - 2.0), 'pow{s}(sin{s}(x + 4.0{S}), cos{s}(x - 2.0{S}))')
check(exp(x*8.0), 'exp{s}(8.0{S}*x)')
check(exp2(x), 'exp2{s}(x)')
check(expm1(x*4.0), 'expm1{s}(4.0{S}*x)')
check(Mod(n, 2), '((n) % (2))')
check(Mod(2*n + 3, 3*n + 5), '((2*n + 3) % (3*n + 5))')
check(Mod(x + 2.0, 3.0), 'fmod{s}(1.0{S}*x + 2.0{S}, 3.0{S})')
check(Mod(x, 2.0*x + 3.0), 'fmod{s}(1.0{S}*x, 2.0{S}*x + 3.0{S})')
check(log(x/2), 'log{s}((1.0{S}/2.0{S})*x)')
check(log10(3*x/2), 'log10{s}((3.0{S}/2.0{S})*x)')
check(log2(x*8.0), 'log2{s}(8.0{S}*x)')
check(log1p(x), 'log1p{s}(x)')
check(2**x, 'pow{s}(2, x)')
check(2.0**x, 'pow{s}(2.0{S}, x)')
check(x**3, 'pow{s}(x, 3)')
check(x**4.0, 'pow{s}(x, 4.0{S})')
check(sqrt(3+x), 'sqrt{s}(x + 3)')
check(Cbrt(x-2.0), 'cbrt{s}(x - 2.0{S})')
check(hypot(x, y), 'hypot{s}(x, y)')
check(sin(3.*x + 2.), 'sin{s}(3.0{S}*x + 2.0{S})')
check(cos(3.*x - 1.), 'cos{s}(3.0{S}*x - 1.0{S})')
check(tan(4.*y + 2.), 'tan{s}(4.0{S}*y + 2.0{S})')
check(asin(3.*x + 2.), 'asin{s}(3.0{S}*x + 2.0{S})')
check(acos(3.*x + 2.), 'acos{s}(3.0{S}*x + 2.0{S})')
check(atan(3.*x + 2.), 'atan{s}(3.0{S}*x + 2.0{S})')
check(atan2(3.*x, 2.*y), 'atan2{s}(3.0{S}*x, 2.0{S}*y)')
check(sinh(3.*x + 2.), 'sinh{s}(3.0{S}*x + 2.0{S})')
check(cosh(3.*x - 1.), 'cosh{s}(3.0{S}*x - 1.0{S})')
check(tanh(4.0*y + 2.), 'tanh{s}(4.0{S}*y + 2.0{S})')
check(asinh(3.*x + 2.), 'asinh{s}(3.0{S}*x + 2.0{S})')
check(acosh(3.*x + 2.), 'acosh{s}(3.0{S}*x + 2.0{S})')
check(atanh(3.*x + 2.), 'atanh{s}(3.0{S}*x + 2.0{S})')
check(erf(42.*x), 'erf{s}(42.0{S}*x)')
check(erfc(42.*x), 'erfc{s}(42.0{S}*x)')
check(gamma(x), 'tgamma{s}(x)')
check(loggamma(x), 'lgamma{s}(x)')
check(ceiling(x + 2.), "ceil{s}(x + 2.0{S})")
check(floor(x + 2.), "floor{s}(x + 2.0{S})")
check(fma(x, y, -z), 'fma{s}(x, y, -z)')
check(Max(x, 8.0, x**4.0), 'fmax{s}(8.0{S}, fmax{s}(x, pow{s}(x, 4.0{S})))')
check(Min(x, 2.0), 'fmin{s}(2.0{S}, x)')
开发者ID:Lenqth,项目名称:sympy,代码行数:57,代码来源:test_ccode.py
示例5: test_Function
def test_Function():
assert mcode(sin(x) ** cos(x)) == "sin(x).^cos(x)"
assert mcode(abs(x)) == "abs(x)"
assert mcode(ceiling(x)) == "ceil(x)"
assert mcode(arg(x)) == "angle(x)"
assert mcode(im(x)) == "imag(x)"
assert mcode(re(x)) == "real(x)"
assert mcode(Max(x, y) + Min(x, y)) == "max(x, y) + min(x, y)"
assert mcode(Max(x, y, z)) == "max(x, max(y, z))"
assert mcode(Min(x, y, z)) == "min(x, min(y, z))"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:10,代码来源:test_octave.py
示例6: decimal_dig
def decimal_dig(self):
""" Number of digits needed to store & load without loss.
Number of decimal digits needed to guarantee that two consecutive conversions
(float -> text -> float) to be idempotent. This is useful when one do not want
to loose precision due to rounding errors when storing a floating point value
as text.
"""
from sympy.functions import ceiling, log
return ceiling((self.nmant + 1) * log(2)/log(10) + 1)
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:10,代码来源:ast.py
示例7: test_user_functions
def test_user_functions():
x = symbols('x', integer=False)
n = symbols('n', integer=True)
custom_functions = {
"ceiling": "ceil",
"Abs": [(lambda x: not x.is_integer, "fabs", 4), (lambda x: x.is_integer, "abs", 4)],
}
assert rust_code(ceiling(x), user_functions=custom_functions) == "x.ceil()"
assert rust_code(Abs(x), user_functions=custom_functions) == "fabs(x)"
assert rust_code(Abs(n), user_functions=custom_functions) == "abs(n)"
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:10,代码来源:test_rust.py
示例8: test_Matrices
def test_Matrices():
assert mcode(Matrix(1, 1, [10])) == "10"
A = Matrix([[1, sin(x/2), abs(x)],
[0, 1, pi],
[0, exp(1), ceiling(x)]]);
expected = "[1 sin(x/2) abs(x); 0 1 pi; 0 exp(1) ceil(x)]"
assert mcode(A) == expected
# row and columns
assert mcode(A[:,0]) == "[1; 0; 0]"
assert mcode(A[0,:]) == "[1 sin(x/2) abs(x)]"
# empty matrices
assert mcode(Matrix(0, 0, [])) == '[]'
assert mcode(Matrix(0, 3, [])) == 'zeros(0, 3)'
# annoying to read but correct
assert mcode(Matrix([[x, x - y, -y]])) == "[x x - y -y]"
开发者ID:Lenqth,项目名称:sympy,代码行数:15,代码来源:test_octave.py
示例9: test_Function_change_name
def test_Function_change_name():
assert mcode(abs(x)) == "abs(x)"
assert mcode(ceiling(x)) == "ceil(x)"
assert mcode(arg(x)) == "angle(x)"
assert mcode(im(x)) == "imag(x)"
assert mcode(re(x)) == "real(x)"
assert mcode(conjugate(x)) == "conj(x)"
assert mcode(chebyshevt(y, x)) == "chebyshevT(y, x)"
assert mcode(chebyshevu(y, x)) == "chebyshevU(y, x)"
assert mcode(laguerre(x, y)) == "laguerreL(x, y)"
assert mcode(Chi(x)) == "coshint(x)"
assert mcode(Shi(x)) == "sinhint(x)"
assert mcode(Ci(x)) == "cosint(x)"
assert mcode(Si(x)) == "sinint(x)"
assert mcode(li(x)) == "logint(x)"
assert mcode(loggamma(x)) == "gammaln(x)"
assert mcode(polygamma(x, y)) == "psi(x, y)"
assert mcode(RisingFactorial(x, y)) == "pochhammer(x, y)"
assert mcode(DiracDelta(x)) == "dirac(x)"
assert mcode(DiracDelta(x, 3)) == "dirac(3, x)"
assert mcode(Heaviside(x)) == "heaviside(x)"
assert mcode(Heaviside(x, y)) == "heaviside(x, y)"
开发者ID:Lenqth,项目名称:sympy,代码行数:22,代码来源:test_octave.py
示例10: test_Functions
def test_Functions():
assert rust_code(sin(x) ** cos(x)) == "x.sin().powf(x.cos())"
assert rust_code(abs(x)) == "x.abs()"
assert rust_code(ceiling(x)) == "x.ceil()"
开发者ID:abhi98khandelwal,项目名称:sympy,代码行数:4,代码来源:test_rust.py
示例11: test_jscode_exceptions
def test_jscode_exceptions():
assert jscode(ceiling(x)) == "Math.ceil(x)"
assert jscode(Abs(x)) == "Math.abs(x)"
开发者ID:cbr-washington-edu,项目名称:branch,代码行数:3,代码来源:test_jscode.py
示例12: test_rcode_exceptions
def test_rcode_exceptions():
assert rcode(ceiling(x)) == "ceiling(x)"
assert rcode(Abs(x)) == "abs(x)"
assert rcode(gamma(x)) == "gamma(x)"
开发者ID:chris-turner137,项目名称:sympy,代码行数:4,代码来源:test_rcode.py
示例13: _eval_nseries
#.........这里部分代码省略.........
# we need to handle the log(x) singularity:
assert x0 == 0
y = Symbol("y", dummy=True)
self0 = 1 / base
p = self0.subs(log(x), -1 / y)
if not p.has(x):
p = p.nseries(y, x0, n)
p = p.subs(y, -1 / log(x))
return p
prefactor = base.as_leading_term(x)
# express "rest" as: rest = 1 + k*x**l + ... + O(x**n)
rest = ((base - prefactor) / prefactor)._eval_expand_mul()
if rest == 0:
# if prefactor == w**4 + x**2*w**4 + 2*x*w**4, we need to
# factor the w**4 out using collect:
return 1 / collect(prefactor, x)
if rest.is_Order:
return (1 + rest) / prefactor
n2 = getn(rest)
if n2 is not None:
n = n2
term2 = collect(rest.as_leading_term(x), x)
k, l = Wild("k"), Wild("l")
r = term2.match(k * x ** l)
k, l = r[k], r[l]
if l.is_Rational and l > 0:
pass
elif l.is_number and l > 0:
l = l.evalf()
else:
raise NotImplementedError()
from sympy.functions import ceiling
terms = [1 / prefactor]
for m in xrange(1, ceiling(n / l)):
new_term = terms[-1] * (-rest)
if new_term.is_Pow:
new_term = new_term._eval_expand_multinomial(deep=False)
else:
new_term = new_term._eval_expand_mul(deep=False)
terms.append(new_term)
r = Add(*terms)
if n2 is None:
# Append O(...) because it is not included in "r"
from sympy import O
r += O(x ** n)
return powsimp(r, deep=True, combine="exp")
else:
# negative powers are rewritten to the cases above, for example:
# sin(x)**(-4) = 1/( sin(x)**4) = ...
# and expand the denominator:
denominator = (base ** (-exp)).nseries(x, x0, n)
if 1 / denominator == self:
return self
# now we have a type 1/f(x), that we know how to expand
return (1 / denominator).nseries(x, x0, n)
if exp.has(x):
import sympy
return sympy.exp(exp * sympy.log(base)).nseries(x, x0, n)
if base == x:
开发者ID:hazelnusse,项目名称:sympy-old,代码行数:67,代码来源:power.py
示例14: test_ccode_exceptions
def test_ccode_exceptions():
assert ccode(ceiling(x)) == "ceil(x)"
assert ccode(Abs(x)) == "fabs(x)"
assert ccode(gamma(x)) == "tgamma(x)"
开发者ID:B-Rich,项目名称:sympy,代码行数:4,代码来源:test_ccode.py
示例15: test_ccode_exceptions
def test_ccode_exceptions():
assert ccode(gamma(x), standard='C99') == "tgamma(x)"
assert 'not supported in c' in ccode(gamma(x), standard='C89').lower()
assert ccode(ceiling(x)) == "ceil(x)"
assert ccode(Abs(x)) == "fabs(x)"
assert ccode(gamma(x)) == "tgamma(x)"
开发者ID:rpmuller,项目名称:sympy,代码行数:6,代码来源:test_ccode.py
示例16: test_glsl_code_exceptions
def test_glsl_code_exceptions():
assert glsl_code(ceiling(x)) == "ceil(x)"
assert glsl_code(Abs(x)) == "abs(x)"
开发者ID:KonstantinTogoi,项目名称:sympy,代码行数:3,代码来源:test_glsl.py
示例17: test_Function
def test_Function():
assert julia_code(sin(x) ** cos(x)) == "sin(x).^cos(x)"
assert julia_code(abs(x)) == "abs(x)"
assert julia_code(ceiling(x)) == "ceil(x)"
开发者ID:asmeurer,项目名称:sympy,代码行数:4,代码来源:test_julia.py
示例18: test_ccode_functions
def test_ccode_functions():
assert ccode(sin(x) ** cos(x)) == "pow(sin(x), cos(x))"
assert ccode(ceiling(x)) == "ceil(x)"
assert ccode(Abs(x)) == "fabs(x)"
assert ccode(gamma(x)) == "tgamma(x)"
开发者ID:jcrist,项目名称:symcc,代码行数:5,代码来源:test_ccode.py
注:本文中的sympy.functions.ceiling函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论