本文整理汇总了Python中sympy.mpmath.mpi函数的典型用法代码示例。如果您正苦于以下问题:Python mpi函数的具体用法?Python mpi怎么用?Python mpi使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mpi函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: arithmeticalOperationX
def arithmeticalOperationX(self, i2, alpha, operation):
""" Wrapper class for performing Fuzzy Arithmetic on X-mu Functions using SymPy/MPI. Primarily used as a private class, but could be used publicly.
@param i2 the target sympy formula.
@param alpha the level on which to perform the operation.
@param operation One of the following: +, -, *, /, **
"""
res = self.get_xequals().subs(ALPHA, float(alpha))
res2 = i2.get_xequals().subs(ALPHA, float(alpha))
if (not res.is_EmptySet) and (not res2.is_EmptySet):
if (type(res) != FiniteSet) and (type(res2) != FiniteSet):
result = eval("res.to_mpi() " + operation + " res2.to_mpi()")
else:
res_mpi = mpmath.mpi(res.inf, res.sup)
res2_mpi = mpmath.mpi(res2.inf, res2.sup)
result = eval("res_mpi " + operation + " res2_mpi")
return BasicXmu(self.u, Interval(float(mpmath.mpf(result.a)), float(mpmath.mpf(result.b))))
else:
return None
示例2: test_special_printers
def test_special_printers():
class IntervalPrinter(LambdaPrinter):
"""Use ``lambda`` printer but print numbers as ``mpi`` intervals. """
def _print_Integer(self, expr):
return "mpi('%s')" % super(IntervalPrinter, self)._print_Integer(expr)
def _print_Rational(self, expr):
return "mpi('%s')" % super(IntervalPrinter, self)._print_Rational(expr)
def intervalrepr(expr):
return IntervalPrinter().doprint(expr)
expr = sympy.sqrt(sympy.sqrt(2) + sympy.sqrt(3)) + sympy.S(1)/2
func0 = lambdify((), expr, modules="mpmath", printer=intervalrepr)
func1 = lambdify((), expr, modules="mpmath", printer=IntervalPrinter)
func2 = lambdify((), expr, modules="mpmath", printer=IntervalPrinter())
mpi = type(mpmath.mpi(1, 2))
assert isinstance(func0(), mpi)
assert isinstance(func1(), mpi)
assert isinstance(func2(), mpi)
示例3: to_mpi
def to_mpi(self, prec=53):
return mpi(mpf(self.start.evalf(prec)), mpf(self.end.evalf(prec)))
示例4: test_interval_to_mpi
def test_interval_to_mpi():
assert Interval(0, 1).to_mpi() == mpi(0, 1)
assert Interval(0, 1, True, False).to_mpi() == mpi(0, 1)
assert type(Interval(0, 1).to_mpi()) == type(mpi(0, 1))
示例5: test_D12
def test_D12():
assert (mpi(-4, 2) * x + mpi(1, 3)) ** 2 == mpi(-8, 16)*x**2 + mpi(-24, 12)*x + mpi(1, 9)
示例6: _eval_evalf
def _eval_evalf(self, prec):
return mpi(self.start.evalf(prec), self.end.evalf(prec))
示例7: test_interval_evalf
def test_interval_evalf():
assert Interval(0, 1).evalf() == mpi(0, 1)
assert Interval(0, 1, True, False).evalf() == mpi(0, 1)
示例8: test_interval_to_mpi
def test_interval_to_mpi():
raises(SymPyDeprecationWarning, "Interval(0, 1).to_mpi()")
assert Interval(0, 1).to_mpi() == mpi(0, 1)
assert Interval(0, 1, True, False).to_mpi() == mpi(0, 1)
assert type(Interval(0, 1).to_mpi()) == type(mpi(0, 1))