本文整理汇总了Python中sympy.printing.latex.LatexPrinter类的典型用法代码示例。如果您正苦于以下问题:Python LatexPrinter类的具体用法?Python LatexPrinter怎么用?Python LatexPrinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LatexPrinter类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _print_Mul
def _print_Mul(self, expr):
args = expr.args
if args[-1] is I:
if len(args) == 2 and args[0] == -1:
return LatexPrinter._print_Mul(self, expr)
return '%s %s' % (self._print(Mul(*args[:-1])), self._print(I))
return LatexPrinter._print_Mul(self, expr)
开发者ID:wxgeo,项目名称:geophar,代码行数:7,代码来源:printers.py
示例2: test_matAdd
def test_matAdd():
from sympy import MatrixSymbol
from sympy.printing.latex import LatexPrinter
C = MatrixSymbol('C', 5, 5)
B = MatrixSymbol('B', 5, 5)
l = LatexPrinter()
assert l._print_MatAdd(C - 2*B) in ['- 2 B + C', '+ C - 2 B']
assert l._print_MatAdd(C + 2*B) in ['+ 2 B + C', '+ C + 2 B']
开发者ID:MichaelMayorov,项目名称:sympy,代码行数:8,代码来源:test_latex.py
示例3: test_matAdd
def test_matAdd():
from sympy import MatrixSymbol
from sympy.printing.latex import LatexPrinter
C = MatrixSymbol("C", 5, 5)
B = MatrixSymbol("B", 5, 5)
l = LatexPrinter()
assert l._print_MatAdd(C - 2 * B) in ["- 2 B + C", "+ C - 2 B"]
assert l._print_MatAdd(C + 2 * B) in ["+ 2 B + C", "+ C + 2 B"]
开发者ID:ness01,项目名称:sympy,代码行数:9,代码来源:test_latex.py
示例4: __init__
def __init__(self, profile = None):
_profile = {
"mat_str" : "pmatrix",
"mat_delim" : "",
"mode": "inline",
}
if profile is not None:
_profile.update(profile)
LatexPrinter.__init__(self, _profile)
开发者ID:TeddyBoomer,项目名称:geophar,代码行数:9,代码来源:printers.py
示例5: __init__
def __init__(self, settings):
defaults = {'decimales': 18,
'mode_scientifique': False,
'decimales_sci': 2,
"mat_str" : "pmatrix",
"mat_delim" : "",
"mode": "inline",
"fold_frac_powers": False,
"fold_short_frac": False,
}
self._default_settings.update(defaults)
LatexPrinter.__init__(self, settings)
开发者ID:wxgeo,项目名称:geophar,代码行数:12,代码来源:printers.py
示例6: _print_Float
def _print_Float(self, expr):
if self._settings['mode_scientifique']:
# Gestion de l'écriture scientifique.
n = int(floor(log(expr, 10)))
s = LatexPrinter._print_Float(self, self._float_evalf(expr*10**-n))
return r"%s \times 10^{%s}" % (s, n)
s = LatexPrinter._print_Float(self, self._float_evalf(expr))
if s.startswith(r'1.0 \times '): # sympy 0.7.3
return s[11:]
elif s.startswith(r'1.0 \cdot '): # sympy 0.7.5
return s[10:]
elif r'\times' not in s:
# Ne pas supprimer un zéro de la puissance !
s = s.rstrip('0').rstrip('.')
return s
开发者ID:wxgeo,项目名称:geophar,代码行数:15,代码来源:printers.py
示例7: _print_Float
def _print_Float(self, expr):
s = LatexPrinter._print_Float(self, expr)
if "e" in s:
nombre, exposant = s.split("e")
return nombre + "\\times 10^{" + exposant.lstrip("+") + "}"
else:
return s
开发者ID:jpg32,项目名称:geophar,代码行数:7,代码来源:printers.py
示例8: _print_Float
def _print_Float(self, expr):
# If not finite we use parent printer
if expr.is_zero:
return "0"
if not expr.is_finite:
return _LatexPrinter._print_Float(self, expr)
return self._number_to_latex(expr.evalf())
开发者ID:andossy,项目名称:SUURPh-summer-school,代码行数:10,代码来源:codegeneration.py
示例9: test_matMul
def test_matMul():
from sympy import MatrixSymbol
from sympy.printing.latex import LatexPrinter
A = MatrixSymbol("A", 5, 5)
B = MatrixSymbol("B", 5, 5)
x = Symbol("x")
l = LatexPrinter()
assert l._print_MatMul(2 * A) == "2 A"
assert l._print_MatMul(2 * x * A) == "2 x A"
assert l._print_MatMul(-2 * A) == "-2 A"
assert l._print_MatMul(1.5 * A) == "1.5 A"
assert l._print_MatMul(sqrt(2) * A) == r"\sqrt{2} A"
assert l._print_MatMul(-sqrt(2) * A) == r"- \sqrt{2} A"
assert l._print_MatMul(2 * sqrt(2) * x * A) == r"2 \sqrt{2} x A"
assert l._print_MatMul(-2 * A * (A + 2 * B)) in [r"-2 A \left(A + 2 B\right)", r"-2 A \left(2 B + A\right)"]
开发者ID:kushal124,项目名称:sympy,代码行数:16,代码来源:test_latex.py
示例10: test_matMul
def test_matMul():
from sympy import MatrixSymbol
from sympy.printing.latex import LatexPrinter
A = MatrixSymbol('A', 5, 5)
B = MatrixSymbol('B', 5, 5)
x = Symbol('x')
l = LatexPrinter()
assert l._print_MatMul(2*A) == '2 A'
assert l._print_MatMul(2*x*A) == '2 x A'
assert l._print_MatMul(-2*A) == '-2 A'
assert l._print_MatMul(1.5*A) == '1.5 A'
assert l._print_MatMul(sqrt(2)*A) == r'\sqrt{2} A'
assert l._print_MatMul(-sqrt(2)*A) == r'- \sqrt{2} A'
assert l._print_MatMul(2*sqrt(2)*x*A) == r'2 \sqrt{2} x A'
assert l._print_MatMul(-2*A*(A + 2*B)) in [r'-2 A \left(A + 2 B\right)',
r'-2 A \left(2 B + A\right)']
开发者ID:Tarang1993,项目名称:sympy,代码行数:16,代码来源:test_latex.py
示例11: _print_Function
def _print_Function(self, expr, exp=None):
'''
For ite() only
'''
func = expr.func.__name__
args = [ str(self._print(arg)) for arg in expr.args ]
if func == 'ite':
return """\\begin{cases}
%(then_code)s \qquad \\text{if} \quad %(if_code)s \\\\
%(else_code)s \qquad \\text{otherwise.}
\end{cases}""" % {'if_code': args[0], 'then_code': args[1], 'else_code': args[2]}
elif func in ['positive', 'pos']:
return "\left(" + str(self._print(args[0])) + "\\right)^+"
elif func in ['negative', 'neg']:
return "(" + str(self._print(args[0])) + ")^-"
return LatexPrinter._print_Function(self, expr, exp)
开发者ID:ANNarchy,项目名称:ANNarchy,代码行数:19,代码来源:LatexParser.py
示例12: doprint
def doprint(self, expr):
##expr = expr.subs(Float(1), S.One)
tex = LatexPrinter.doprint(self, expr)
return tex.replace(r'\operatorname{', r'\mathrm{')
开发者ID:jpg32,项目名称:geophar,代码行数:4,代码来源:printers.py
示例13: parenthesize
def parenthesize(self, item, level, strict=False):
item_latex = self._print(item)
if item_latex.startswith(r"\dot") or item_latex.startswith(r"\ddot") or item_latex.startswith(r"\dddot"):
return self._print(item)
else:
return LatexPrinter.parenthesize(self, item, level, strict)
开发者ID:AStorus,项目名称:sympy,代码行数:6,代码来源:printing.py
示例14: doprint
def doprint(self, expr):
expr = self._convert_Decim(expr)
tex = LatexPrinter.doprint(self, expr)
return tex.replace(r'\operatorname{', r'\mathrm{')
开发者ID:wxgeo,项目名称:geophar,代码行数:4,代码来源:printers.py
示例15: _print_Function
def _print_Function(self, expr, *args, **kwargs):
if isinstance(expr, _AppliedUndef):
return self._print_Symbol(sp.Symbol(expr.func.__name__))
return expr.func.__name__
return _LatexPrinter._print_Function(self, expr, *args, **kwargs)
开发者ID:andossy,项目名称:SUURPh-summer-school,代码行数:6,代码来源:codegeneration.py
示例16: _print_Abs
def _print_Abs(self, *args, **kw):
res = LatexPrinter._print_Abs(self, *args, **kw)
return res.replace(r'\lvert', r'|').replace(r'\rvert', r'|')
开发者ID:wxgeo,项目名称:geophar,代码行数:3,代码来源:printers.py
示例17: doprint
def doprint(self, expr):
# #if isinstance(expr,)'
print expr
#tex = SLP().doprint(expr)
tex = SLP.doprint(self,expr)
print tex
#tex = self.doprint( expr)
return r"%s" % tex
开发者ID:BasileGrassi,项目名称:dynare-python,代码行数:8,代码来源:preview_latex.py
示例18: doprint
def doprint(self, expr):
tex = SLP.doprint(self,expr)
return r"%s" % tex
开发者ID:TomAugspurger,项目名称:dolo,代码行数:3,代码来源:preview_latex.py
注:本文中的sympy.printing.latex.LatexPrinter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论