本文整理汇总了Python中sage.all.latex函数的典型用法代码示例。如果您正苦于以下问题:Python latex函数的具体用法?Python latex怎么用?Python latex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了latex函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: render_group_webpage
def render_group_webpage(args):
data = None
info = {}
if 'label' in args:
label = clean_input(args['label'])
label = label.replace('t', 'T')
C = base.getDBConnection()
data = C.transitivegroups.groups.find_one({'label': label})
if data is None:
bread = get_bread([("Search error", url_for('.search'))])
info['err'] = "Group " + label + " was not found in the database."
info['label'] = label
return search_input_error(info, bread)
title = 'Galois Group:' + label
n = data['n']
t = data['t']
data['yesno'] = yesno
order = data['order']
data['orderfac'] = latex(ZZ(order).factor())
orderfac = latex(ZZ(order).factor())
data['ordermsg'] = "$%s=%s$" % (order, latex(orderfac))
if ZZ(order) == 1:
data['ordermsg'] = "$1$"
if ZZ(order).is_prime():
data['ordermsg'] = "$%s$ (is prime)" % order
pgroup = len(ZZ(order).prime_factors()) < 2
if n == 1:
G = gap.SmallGroup(n, t)
else:
G = gap.TransitiveGroup(n, t)
if ZZ(order) < ZZ('10000000000'):
ctable = chartable(n, t)
else:
ctable = 'Group too large'
data['gens'] = generators(n, t)
if n == 1 and t == 1:
data['gens'] = 'None needed'
data['chartable'] = ctable
data['parity'] = "$%s$" % data['parity']
data['cclasses'] = conjclasses(G, n)
data['subinfo'] = subfield_display(C, n, data['subs'])
data['resolve'] = resolve_display(C, data['resolve'])
# if len(data['resolve']) == 0: data['resolve'] = 'None'
data['otherreps'] = otherrep_display(n, t, C, data['repns'])
prop2 = [
('Order:', '\(%s\)' % order),
('n:', '\(%s\)' % data['n']),
('Cyclic:', yesno(data['cyc'])),
('Abelian:', yesno(data['ab'])),
('Solvable:', yesno(data['solv'])),
('Primitive:', yesno(data['prim'])),
('$p$-group:', yesno(pgroup)),
('Name:', group_display_short(n, t, C)),
]
info.update(data)
bread = get_bread([(label, ' ')])
return render_template("gg-show-group.html", credit=GG_credit, title=title, bread=bread, info=info, properties2=prop2)
开发者ID:CleryFabien,项目名称:lmfdb,代码行数:58,代码来源:main.py
示例2: splitint
def splitint(a,p):
if a==1:
return ' '
j = valuation(a,p)
if j==0:
return str(a)
a = a/p**j
if a==1:
return latex(ZZ(p**j).factor())
return str(a)+r'\cdot'+latex(ZZ(p**j).factor())
开发者ID:sanni85,项目名称:lmfdb,代码行数:10,代码来源:main.py
示例3: safe_reduce
def safe_reduce(f):
if not m:
return latex(f)
try:
if f in sam.field():
return latex(redc(f))
else:
return latex(redp(f))
except ZeroDivisionError:
return '\\textrm{Unable to reduce} \\bmod\\mathfrak{m}'
开发者ID:jwj61,项目名称:lmfdb,代码行数:10,代码来源:siegel_modular_form.py
示例4: make_map_latex
def make_map_latex(map_str):
# FIXME: Get rid of nu when map is defined over QQ
if "nu" not in map_str:
R0 = QQ
else:
R0 = PolynomialRing(QQ,'nu')
R = PolynomialRing(R0,2,'x,y')
F = FractionField(R)
phi = F(map_str)
num = phi.numerator()
den = phi.denominator()
c_num = num.denominator()
c_den = den.denominator()
lc = c_den/c_num
# rescale coeffs to make them integral. then try to factor out gcds
# numerator
num_new = c_num*num
num_cs = num_new.coefficients()
if R0 == QQ:
num_cs_ZZ = num_cs
else:
num_cs_ZZ = []
for el in num_cs:
num_cs_ZZ = num_cs_ZZ + el.coefficients()
num_gcd = gcd(num_cs_ZZ)
# denominator
den_new = c_den*den
den_cs = den_new.coefficients()
if R0 == QQ:
den_cs_ZZ = den_cs
else:
den_cs_ZZ = []
for el in den_cs:
den_cs_ZZ = den_cs_ZZ + el.coefficients()
den_gcd = gcd(den_cs_ZZ)
lc = lc*(num_gcd/den_gcd)
num_new = num_new/num_gcd
den_new = den_new/den_gcd
# make strings for lc, num, and den
num_str = latex(num_new)
den_str = latex(den_new)
if lc==1:
lc_str=""
else:
lc_str = latex(lc)
if den_new==1:
if lc ==1:
phi_str = num_str
else:
phi_str = lc_str+"("+num_str+")"
else:
phi_str = lc_str+"\\frac{"+num_str+"}"+"{"+den_str+"}"
return phi_str
开发者ID:kedlaya,项目名称:lmfdb,代码行数:53,代码来源:web_belyi.py
示例5: make_curve_latex
def make_curve_latex(crv_str):
# FIXME: Get rid of nu when map is defined over QQ
if "nu" not in crv_str:
R0 = QQ
else:
R0 = PolynomialRing(QQ,'nu')
R = PolynomialRing(R0,2,'x,y')
F = FractionField(R)
sides = crv_str.split("=")
lhs = latex(F(sides[0]))
rhs = latex(F(sides[1]))
eqn_str = lhs + '=' + rhs
return eqn_str
开发者ID:kedlaya,项目名称:lmfdb,代码行数:13,代码来源:web_belyi.py
示例6: _latex_using_dpd_depth1
def _latex_using_dpd_depth1(self, dpd_dct):
names = [dpd_dct[c] for c in self._consts]
_gcd = QQ(gcd(self._coeffs))
coeffs = [c / _gcd for c in self._coeffs]
coeffs_names = [(c, n) for c, n in zip(coeffs, names) if c != 0]
tail_terms = ["%s %s %s" % ("+" if c > 0 else "", c, n) for c, n in coeffs_names[1:]]
c0, n0 = coeffs_names[0]
head_term = str(c0) + " " + str(n0)
return r"\frac{{{pol_num}}}{{{pol_dnm}}} \left({terms}\right)".format(
pol_dnm=latex(_gcd.denominator() * self._scalar_const._polynomial_expr()),
pol_num=latex(_gcd.numerator()),
terms=" ".join([head_term] + tail_terms),
)
开发者ID:stakemori,项目名称:degree2,代码行数:13,代码来源:const.py
示例7: disc_factored_latex
def disc_factored_latex(self):
D = self.disc()
s = ''
if D < 0:
D = -D
s = r'-\,'
return s + latex(D.factor())
开发者ID:AurelPage,项目名称:lmfdb,代码行数:7,代码来源:WebNumberField.py
示例8: latex
def latex(self, prec=None, name=None, keepzeta=False):
"""
Change the name of the variable in a polynomial. If keepzeta, then don't change
the name of zetaN in the defining polynomial of a cyclotomic field.
(keepzeta not implemented yet)
"""
if prec is None:
qe = self.value()
else:
qe = self.value()
if not qe is None:
qe = qe.truncate_powerseries(prec)
wl = web_latex_split_on_re(qe)
if name is not None and self.value().base_ring().absolute_degree()>1:
oldname = latex(self.value().base_ring().gen())
subfrom = oldname.strip()
subfrom = subfrom.replace("\\","\\\\")
subfrom = subfrom.replace("{","\\{") # because x_{0} means something in a regular expression
if subfrom[0].isalpha():
subfrom = "\\b" + subfrom
subto = name.replace("\\","\\\\") + " "
if keepzeta and "zeta" in subfrom:
pass # keep the variable as-is
else:
wl = re.sub(subfrom, subto, wl)
return wl
else:
return wl
开发者ID:jwj61,项目名称:lmfdb,代码行数:29,代码来源:web_newforms.py
示例9: web_latex_split_on_re
def web_latex_split_on_re(x, r = '(q[^+-]*[+-])'):
def insert_latex(s):
return s.group(1) + '\) \('
if isinstance(x, (str, unicode)):
return x
else:
A = "\( %s \)" % latex(x)
c = re.compile(r)
A = A.replace('+', '\) \( {}+ ')
A = A.replace('-', '\) \( {}- ')
# A = A.replace('\left(','\left( {}\\right.') # parantheses needs to be balanced
# A = A.replace('\\right)','\left.\\right)')
A = A.replace('\left(','\\bigl(')
A = A.replace('\\right)','\\bigr)')
A = c.sub(insert_latex, A)
# the above will be re-done using a more sophisticated method involving
# regular expressions. Below fixes bad spacing when the current approach
# encounters terms like (-3+x)
A = A.replace('( {}','(')
A = A.replace('(\) \(','(')
A = A.replace('\(+','\(\mathstrut+')
A = A.replace('\(-','\(\mathstrut-')
A = A.replace('( ','(')
A = A.replace('( ','(')
A = A.replace('+\) \(O','+O')
return A
开发者ID:sehlen,项目名称:lmfdb,代码行数:29,代码来源:utils.py
示例10: eigs_as_seqseq_to_qexp
def eigs_as_seqseq_to_qexp(self, prec_max):
# Takes a sequence of sequence of integers (or pairs of integers in the hecke_ring_cyclotomic_generator != 0 case) and returns a string for the corresponding q expansion
# For example, eigs_as_seqseq_to_qexp([[0,0],[1,3]]) returns "\((1+3\beta_{1})q\)\(+O(q^2)\)"
prec = min(self.qexp_prec, prec_max)
if prec == 0:
return 'O(1)'
eigseq = self.qexp[:prec]
use_knowl = too_big(eigseq, 10**24)
s = ''
for j in range(len(eigseq)):
term = self._elt(eigseq[j])
if term != 0:
latexterm = latex(term)
if use_knowl:
latexterm = make_bigint(latexterm)
if term.number_of_terms() > 1:
latexterm = r"(" + latexterm + r")"
if j > 0:
if term == 1:
latexterm = ''
elif term == -1:
latexterm = '-'
if j == 1:
latexterm += ' q'
else:
latexterm += ' q^{%d}' % j
if s != '' and latexterm[0] != '-':
latexterm = '+' + latexterm
s += '\(' + latexterm + '\) '
# Work around bug in Sage's latex
s = s.replace('betaq', 'beta q')
return s + '\(+O(q^{%d})\)' % prec
开发者ID:davidfarmer,项目名称:lmfdb,代码行数:32,代码来源:web_newform.py
示例11: web_latex_split_on_pm
def web_latex_split_on_pm(x):
on = ['+', '-']
# A = "\( %s \)" % latex(x)
try:
A = "\(" + x + "\)" # assume we are given LaTeX to split on
except:
A = "\( %s \)" % latex(x)
# need a more clever split_on_pm that inserts left and right properly
A = A.replace("\\left","")
A = A.replace("\\right","")
for s in on:
# A = A.replace(s, '\) ' + s + ' \( ')
# A = A.replace(s, '\) ' + ' \( \mathstrut ' + s )
A = A.replace(s, '\)' + ' \(\mathstrut ' + s + '\mathstrut ')
# the above will be re-done using a more sophisticated method involving
# regular expressions. Below fixes bad spacing when the current approach
# encounters terms like (-3+x)
for s in on:
A = A.replace('(\) \(\mathstrut '+s,'(' + s)
A = A.replace('( {}','(')
A = A.replace('(\) \(','(')
A = A.replace('\(+','\(\mathstrut+')
A = A.replace('\(-','\(\mathstrut-')
A = A.replace('( ','(')
A = A.replace('( ','(')
return A
开发者ID:sehlen,项目名称:lmfdb,代码行数:28,代码来源:utils.py
示例12: eigs_as_seqseq_to_qexp
def eigs_as_seqseq_to_qexp(self, prec_max):
# Takes a sequence of sequence of integers and returns a string for the corresponding q expansion
# For example, eigs_as_seqseq_to_qexp([[0,0],[1,3]]) returns "\((1+3\beta_{1})q\)\(+O(q^2)\)"
prec = min(self.qexp_prec, prec_max)
if prec == 0:
return 'O(1)'
eigseq = self.qexp[:prec]
d = self.dim
Rgens = self._get_Rgens()
s = ''
for j in range(len(eigseq)):
term = sum([Rgens[i]*eigseq[j][i] for i in range(d)])
if term != 0:
latexterm = latex(term)
if term.number_of_terms() > 1:
latexterm = r"\left(" + latexterm + r"\right)"
if j > 0:
if term == 1:
latexterm = ''
elif term == -1:
latexterm = '-'
if j == 1:
latexterm += ' q'
else:
latexterm += ' q^{%d}' % j
#print latexterm
if s != '' and latexterm[0] != '-':
latexterm = '+' + latexterm
s += '\(' + latexterm + '\) '
# Work around bug in Sage's latex
s = s.replace('betaq', 'beta q')
return s + '\(+O(q^{%d})\)' % prec
开发者ID:koffie,项目名称:lmfdb,代码行数:33,代码来源:web_newform.py
示例13: nf_knowl_guts
def nf_knowl_guts(label):
out = ''
wnf = WebNumberField(label)
if wnf.is_null():
return 'Cannot find global number field %s' % label
out += "Global number field %s" % label
out += '<div>'
out += 'Defining polynomial: '
out += "\(%s\)" % latex(wnf.poly())
D = wnf.disc()
Dfact = wnf.disc_factored_latex()
if D.abs().is_prime() or D == 1:
Dfact = "\(%s\)" % str(D)
else:
Dfact = '%s = \(%s\)' % (str(D),Dfact)
out += '<br>Discriminant: '
out += Dfact
out += '<br>Signature: '
out += str(wnf.signature())
out += '<br>Galois group: '+group_pretty_and_nTj(wnf.degree(),wnf.galois_t(), True)
out += '<br>Class number: %s ' % str(wnf.class_number_latex())
if wnf.can_class_number():
out += wnf.short_grh_string()
out += '</div>'
out += '<div align="right">'
out += '<a href="%s">%s home page</a>' % (str(url_for("number_fields.number_field_render_webpage", natural=label)),label)
out += '</div>'
return out
开发者ID:pascalmolin,项目名称:lmfdb,代码行数:28,代码来源:web_number_field.py
示例14: get_local_algebra
def get_local_algebra(self, p):
local_algebra_dict = self._data.get('loc_algebras', None)
if local_algebra_dict is None:
return None
if str(p) in local_algebra_dict:
R = PolynomialRing(QQ, 'x')
palg = local_algebra_dict[str(p)]
palgs = [R(str(s)) for s in palg.split(',')]
try:
palgstr = [
list2string([int(c) for c in pol.coefficients(sparse=False)])
for pol in palgs]
palgrec = [db.lf_fields.lucky({'p': p, 'coeffs': map(int, c.split(','))}) for c in palgstr]
return [
[
LF['label'],
latex(f),
int(LF['e']),
int(LF['f']),
int(LF['c']),
group_display_knowl(LF['n'], LF['galT']),
LF['t'],
LF['u'],
LF['slopes']
]
for LF, f in zip(palgrec, palgs) ]
except: # we were unable to find the local fields in the database
return None
开发者ID:pascalmolin,项目名称:lmfdb,代码行数:28,代码来源:web_number_field.py
示例15: web_latex_split_on
def web_latex_split_on(x, on=['+', '-']):
if isinstance(x, (str, unicode)):
return x
else:
A = "\( %s \)" % latex(x)
for s in on:
A = A.replace(s, '\) ' + s + ' \( ')
return A
开发者ID:sehlen,项目名称:lmfdb,代码行数:8,代码来源:utils.py
示例16: render_hgm_webpage
def render_hgm_webpage(args):
data = None
info = {}
if 'label' in args:
label = clean_input(args['label'])
C = base.getDBConnection()
data = C.hgm.motives.find_one({'label': label})
if data is None:
bread = get_bread([("Search error", url_for('.search'))])
info['err'] = "Motive " + label + " was not found in the database."
info['label'] = label
return search_input_error(info, bread)
title = 'Hypergeometric Motive:' + label
A = data['A']
B = data['B']
tn,td = data['t']
t = latex(QQ(str(tn)+'/'+str(td)))
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71]
locinfo = data['locinfo']
for j in range(len(locinfo)):
locinfo[j] = [primes[j]] + locinfo[j]
locinfo[j][2] = poly_with_factored_coeffs(locinfo[j][2], primes[j])
hodge = data['hodge']
prop2 = [
('Degree', '\(%s\)' % data['degree']),
('Weight', '\(%s\)' % data['weight']),
('Conductor', '\(%s\)' % data['cond']),
]
# Now add factorization of conductor
Cond = ZZ(data['cond'])
if not (Cond.abs().is_prime() or Cond == 1):
data['cond'] = "%s=%s" % (str(Cond), factorint(data['cond']))
info.update({
'A': A,
'B': B,
't': t,
'degree': data['degree'],
'weight': data['weight'],
'sign': data['sign'],
'sig': data['sig'],
'hodge': hodge,
'cond': data['cond'],
'req': data['req'],
'locinfo': locinfo
})
AB_data, t_data = data["label"].split("_t")
#AB_data = data["label"].split("_t")[0]
friends = [("Motive family "+AB_data.replace("_"," "), url_for(".by_family_label", label = AB_data))]
friends.append(('L-function', url_for("l_functions.l_function_hgm_page", label=AB_data, t='t'+t_data)))
# if rffriend != '':
# friends.append(('Discriminant root field', rffriend))
bread = get_bread([(label, ' ')])
return render_template("hgm-show-motive.html", credit=HGM_credit, title=title, bread=bread, info=info, properties2=prop2, friends=friends)
开发者ID:StockpotCreative,项目名称:lmfdb,代码行数:56,代码来源:main.py
示例17: web_latex
def web_latex(x, enclose=True):
"""
Convert input to latex string unless it's a string or unicode. The key word
argument `enclose` indicates whether to surround the string with
`\(` and `\)` to tag it as an equation in html.
Note:
if input is a factored ideal, use web_latex_ideal_fact instead.
Example:
>>> x = var('x')
>>> web_latex(x**23 + 2*x + 1)
'\\( x^{23} + 2 \\, x + 1 \\)'
"""
if isinstance(x, (str, unicode)):
return x
if enclose == True:
return "\( %s \)" % latex(x)
return " %s " % latex(x)
开发者ID:LMFDB,项目名称:lmfdb,代码行数:19,代码来源:utilities.py
示例18: web_latex_poly
def web_latex_poly(pol, name='x', keepzeta=False):
"""
Change the name of the variable in a polynomial. If keepzeta, then don't change
the name of zetaN in the defining polynomial of a cyclotomic field.
(keepzeta not implemented yet)
"""
# the next few lines were adapted from the lines after line 117 of web_newforms.py
oldname = latex(pol.parent().gen())
subfrom = oldname.strip()
subfrom = subfrom.replace("\\","\\\\")
subfrom = subfrom.replace("{","\\{") # because x_{0} means somethgn in a regular expression
if subfrom[0].isalpha():
subfrom = "\\b" + subfrom
subto = name.replace("\\","\\\\")
subto += " "
# print "converting from",subfrom,"to", subto, "of", latex(pol)
newpol = re.sub(subfrom, subto, latex(pol))
# print "result is",newpol
return web_latex_split_on_pm(newpol)
开发者ID:am-github,项目名称:lmfdb,代码行数:19,代码来源:web_object.py
示例19: latex
def latex(self, prec=None, name=None):
if prec is None:
qe = self.value()
else:
qe = self.value().truncate_powerseries(prec)
wl = web_latex_split_on_re(qe)
if name is not None and self.value().base_ring().degree()>1:
return wl.replace(latex(self.value().base_ring().gen()), name)
else:
return wl
开发者ID:sfrechet,项目名称:lmfdb,代码行数:10,代码来源:web_newforms.py
示例20: myhelper
def myhelper(self, coefmult):
coef = string2list(coefmult[0])
subfield = self.from_coeffs(coef)
if subfield._data is None:
deg = len(coef) - 1
mypol = latex(coeff_to_poly(coef))
mypol = mypol.replace(' ','').replace('+','%2B').replace('{', '%7B').replace('}','%7d')
mypol = '<a title = "Field missing" knowl="nf.field.missing" kwargs="poly=%s">Deg %d</a>' % (mypol,deg)
return [mypol, coefmult[1]]
return [nf_display_knowl(subfield.get_label(),subfield.field_pretty()), coefmult[1]]
开发者ID:pascalmolin,项目名称:lmfdb,代码行数:10,代码来源:web_number_field.py
注:本文中的sage.all.latex函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论