本文整理汇总了Python中basic.C.log方法的典型用法代码示例。如果您正苦于以下问题:Python C.log方法的具体用法?Python C.log怎么用?Python C.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类basic.C
的用法示例。
在下文中一共展示了C.log方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: evalf_log
# 需要导入模块: from basic import C [as 别名]
# 或者: from basic.C import log [as 别名]
def evalf_log(expr, prec, options):
arg = expr.args[0]
workprec = prec+10
xre, xim, xacc, _ = evalf(arg, workprec, options)
if xim:
# XXX: use get_abs etc instead
re = evalf_log(C.log(C.abs(arg, evaluate=False), evaluate=False), prec, options)
im = mpf_atan2(xim, xre or fzero, prec)
return re[0], im, re[2], prec
imaginary_term = (mpf_cmp(xre, fzero) < 0)
re = mpf_log(mpf_abs(xre), prec, round_nearest)
size = fastlog(re)
if prec - size > workprec:
# We actually need to compute 1+x accurately, not x
arg = C.Add(S.NegativeOne,arg,evaluate=False)
xre, xim, xre_acc, xim_acc = evalf_add(arg, prec, options)
prec2 = workprec - fastlog(xre)
re = mpf_log(mpf_add(xre, fone, prec2), prec, round_nearest)
re_acc = prec
if imaginary_term:
return re, mpf_pi(prec), re_acc, prec
else:
return re, None, re_acc, None
示例2: _eval_subs
# 需要导入模块: from basic import C [as 别名]
# 或者: from basic.C import log [as 别名]
def _eval_subs(self, old, new):
if self==old: return new
if isinstance(old, self.__class__) and self.base==old.base:
coeff1,terms1 = self.exp.as_coeff_terms()
coeff2,terms2 = old.exp.as_coeff_terms()
if terms1==terms2: return new ** (coeff1/coeff2) # (x**(2*y)).subs(x**(3*y),z) -> z**(2/3*y)
if old.func is C.exp:
coeff1,terms1 = old.args[0].as_coeff_terms()
coeff2,terms2 = (self.exp * C.log(self.base)).as_coeff_terms()
if terms1==terms2: return new ** (coeff1/coeff2) # (x**(2*y)).subs(exp(3*y*log(x)),z) -> z**(2/3*y)
return self.base._eval_subs(old, new) ** self.exp._eval_subs(old, new)
示例3: _eval_as_leading_term
# 需要导入模块: from basic import C [as 别名]
# 或者: from basic.C import log [as 别名]
def _eval_as_leading_term(self, x):
if not self.exp.has(x):
return self.base.as_leading_term(x) ** self.exp
return C.exp(self.exp * C.log(self.base)).as_leading_term(x)
示例4: _eval_derivative
# 需要导入模块: from basic import C [as 别名]
# 或者: from basic.C import log [as 别名]
def _eval_derivative(self, s):
dbase = self.base.diff(s)
dexp = self.exp.diff(s)
return self * (dexp * C.log(self.base) + dbase * self.exp / self.base)