def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: ct = CartanType(['A',4]).marked_nodes([1, 3]) sage: latex(ct) A_{4} \text{ with nodes $\left(1, 3\right)$ marked} A more compact, but potentially confusing, representation can be obtained using the ``latex_marked`` global option:: sage: CartanType.options['latex_marked'] = False sage: latex(ct) A_{4} sage: CartanType.options['latex_marked'] = True Kac's notations are implemented:: sage: CartanType.options['notation'] = 'Kac' sage: latex(CartanType(['D',4,3]).marked_nodes([0])) D_4^{(3)} \text{ with node $0$ marked} sage: CartanType.options._reset() """ from sage.misc.latex import latex ret = self._type._latex_() if self.options('latex_marked'): if len(self._marked_nodes) == 1: ret += " \\text{{ with node ${}$ marked}} ".format(latex(self._marked_nodes[0])) else: ret += " \\text{{ with nodes ${}$ marked}} ".format(latex(self._marked_nodes)) return ret
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: B = crystals.infinity.PBW(['F', 4]) sage: u = B.highest_weight_vector() sage: b = u.f_string([1,2,3,4,2,3,2,3,4,1,2]) sage: latex(b) f_{\alpha_{4}}^{2} f_{\alpha_{3}} f_{\alpha_{1} + \alpha_{2} + 2\alpha_{3}} f_{\alpha_{1} + \alpha_{2}} f_{\alpha_{2}}^{2} """ pbw_datum = self._pbw_datum.convert_to_new_long_word(self.parent()._default_word) lusztig_datum = list(pbw_datum.lusztig_datum) al = self.parent()._pbw_datum_parent._root_list_from(self.parent()._default_word) from sage.misc.latex import latex ret_str = ' '.join("f_{%s}%s"%(latex(al[i]), "^{%s}"%latex(exp) if exp > 1 else "") for i, exp in enumerate(lusztig_datum) if exp) if ret_str == '': return '1' return ret_str
def _latex_(self): r""" Return LaTeX representation of ``self``. EXAMPLES:: sage: from sage.numerical.knapsack import Superincreasing sage: latex(Superincreasing()) \left[\right] sage: seq = Superincreasing([1, 2, 5, 21, 69, 189, 376, 919]) sage: latex(seq) <BLANKLINE> \left[1, 2, 5, 21, 69, 189, 376, 919\right] """ if self._seq is None: return latex([]) else: return latex(self._seq)
def list_functions(ex, list_f): r""" Function to find the occurences of symbolic functions in the expression. INPUT: - ``ex`` -- symbolic expression to be analyzed OUTPUT: - ``list_f`` -- tuple containing the details of a symbolic function found, in a following order: 1. operator 2. function name 3. arguments 4. LaTeX version of function name 5. LaTeX version of arguments TESTS:: sage: var('x y z') (x, y, z) sage: f = function('f', x, y, latex_name=r"{\cal F}") sage: g = function('g_x', x, y) sage: d = sin(x)*g.diff(x)*x*f - x^2*f.diff(x,y)/g sage: from sage.geometry.manifolds.utilities import list_functions sage: list_f = [] sage: list_functions(d, list_f) sage: list_f [(f, 'f', '(x, y)', {\cal F}, \left(x, y\right)), (g_x, 'g_x', '(x, y)', 'g_{x}', \left(x, y\right))] """ op = ex.operator() operands = ex.operands() from sage.misc.latex import latex, latex_variable_name if op: if str(type(op)) == "<class 'sage.symbolic.function_factory.NewSymbolicFunction'>": repr_function = repr(op) latex_function = latex(op) # case when no latex_name given if repr_function == latex_function: latex_function = latex_variable_name(str(op)) repr_args = repr(ex.arguments()) # remove comma in case of singleton if len(ex.arguments())==1: repr_args = repr_args.replace(",","") latex_args = latex(ex.arguments()) list_f.append((op, repr_function, repr_args, latex_function, latex_args)) for operand in operands: list_functions(operand, list_f)
def _print_latex_(self, z, m): """ EXAMPLES:: sage: latex(elliptic_e(pi, x)) E(\pi\,|\,x) """ return r"E(%s\,|\,%s)" % (latex(z), latex(m))
def _print_latex_(self, u, m): """ EXAMPLES:: sage: latex(elliptic_eu(1,x)) E(1;x) """ return r"E(%s;%s)" % (latex(u), latex(m))
def _print_latex_(self, z, m): """ EXAMPLES:: sage: latex(elliptic_f(x,pi)) F(x\,|\,\pi) """ return r"F(%s\,|\,%s)" % (latex(z), latex(m))
def _print_latex_(self, n, z, m): """ EXAMPLES:: sage: latex(elliptic_pi(x,pi,0)) \Pi(x,\pi,0) """ return r"\Pi(%s,%s,%s)" % (latex(n), latex(z), latex(m))
def _print_latex_(self, n, m, theta, phi): r""" TESTS:: sage: y = var('y') sage: latex(spherical_harmonic(3, 2, x, y, hold=True)) Y_{3}^{2}\left(x, y\right) """ return r"Y_{{{}}}^{{{}}}\left({}, {}\right)".format(latex(n), latex(m), latex(theta), latex(phi))
def _OG(n, R, special, e=0, var='a', invariant_form=None): r""" This function is commonly used by the functions GO and SO to avoid uneccessarily duplicated code. For documentation and examples see the individual functions. TESTS: Check that :trac:`26028` is fixed:: sage: GO(3,25).order() # indirect doctest 31200 """ prefix = 'General' ltx_prefix ='G' if special: prefix = 'Special' ltx_prefix ='S' degree, ring = normalize_args_vectorspace(n, R, var=var) e = normalize_args_e(degree, ring, e) if e == 0: if invariant_form is not None: if is_FiniteField(ring): raise NotImplementedError("invariant_form for finite groups is fixed by GAP") invariant_form = normalize_args_invariant_form(ring, degree, invariant_form) if not invariant_form.is_symmetric(): raise ValueError("invariant_form must be symmetric") try: if invariant_form.is_positive_definite(): inserted_text = "with respect to positive definite symmetric form" else: inserted_text = "with respect to non positive definite symmetric form" except ValueError: inserted_text = "with respect to symmetric form" name = '{0} Orthogonal Group of degree {1} over {2} {3}\n{4}'.format( prefix, degree, ring, inserted_text,invariant_form) ltx = r'\text{{{0}O}}_{{{1}}}({2})\text{{ {3} }}{4}'.format( ltx_prefix, degree, latex(ring), inserted_text, latex(invariant_form)) else: name = '{0} Orthogonal Group of degree {1} over {2}'.format(prefix, degree, ring) ltx = r'\text{{{0}O}}_{{{1}}}({2})'.format(ltx_prefix, degree, latex(ring)) else: name = '{0} Orthogonal Group of degree {1} and form parameter {2} over {3}'.format(prefix, degree, e, ring) ltx = r'\text{{{0}O}}_{{{1}}}({2}, {3})'.format(ltx_prefix, degree, latex(ring), '+' if e == 1 else '-') if is_FiniteField(ring): cmd = '{0}O({1}, {2}, {3})'.format(ltx_prefix, e, degree, ring.order()) return OrthogonalMatrixGroup_gap(degree, ring, False, name, ltx, cmd) else: return OrthogonalMatrixGroup_generic(degree, ring, False, name, ltx, invariant_form=invariant_form)
def _latex_(self) : r""" TESTS:: sage: from psage.modform.fourier_expansion_framework.gradedexpansions.gradedexpansion_grading import * sage: latex( TrivialGrading( 3, "t" ) ) \text{Trivial grading on $3$ generators with index $\verb|t|$} """ return r"\text{Trivial grading on $%s$ generators with index $%s$}" \ % (latex(self.__ngens), latex(self.__index))
def _print_latex_(self, n, z): """ Custom _print_latex_ method. EXAMPLES:: sage: latex(bessel_K(1, x)) \operatorname{K_{1}}(x) """ return r"\operatorname{K_{%s}}(%s)" % (latex(n), latex(z))
def _latex_(self): """ EXAMPLES:: sage: R.<x> = PolynomialRing(ZZ,'x') sage: I = R.ideal([4 + 3*x + x^2, 1 + x^2]) sage: R.quotient_ring(I)._latex_() '\\Bold{Z}[x]/\\left(x^{2} + 3x + 4, x^{2} + 1\\right)\\Bold{Z}[x]' """ return "%s/%s"%(latex.latex(self.cover_ring()), latex.latex(self.defining_ideal()))
def half_term(mon, polynomial): total = sum(mon) if total == 0: return '1' ret = ' '.join('{}{}'.format(latex(R.gen(i)), exp(power)) if polynomial else '\\partial {}{}'.format(latex(R.gen(i)), exp(power)) for i,power in enumerate(mon) if power > 0) if not polynomial: return '\\frac{{\\partial{}}}{{{}}}'.format(exp(total), ret) return ret
def _latex_(self): r""" Return latex representation of self. EXAMPLES:: sage: latex(Set(ZZ).union(Set(GF(5)))) \Bold{Z} \cup \left\{0, 1, 2, 3, 4\right\} """ return '%s \\cup %s'%(latex(self.__X), latex(self.__Y))
def _latex_(self): r""" Return a latex representation of this set. EXAMPLES:: sage: latex(Set(ZZ).union(Set(GF(5)))) \Bold{Z} \cup \left\{0, 1, 2, 3, 4\right\} """ return latex(self._X) + self._latex_op + latex(self._Y)
def _latex_(self): r""" Return latex representation of self. EXAMPLES:: sage: X = Set(ZZ).intersection(Set(QQ)) sage: latex(X) \Bold{Z} \cap \Bold{Q} """ return '%s \\cap %s'%(latex(self.__X), latex(self.__Y))
def _latex_(self): r""" Return latex representation of self. EXAMPLES:: sage: X = Set(QQ).difference(Set(ZZ)) sage: latex(X) \Bold{Q} - \Bold{Z} """ return '%s - %s'%(latex(self.__X), latex(self.__Y))
def _latex_(self): r""" Return latex representation of self. EXAMPLES:: sage: X = Set(ZZ).symmetric_difference(Set(QQ)) sage: latex(X) \Bold{Z} \bigtriangleup \Bold{Q} """ return '%s \\bigtriangleup %s'%(latex(self.__X), latex(self.__Y))
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: latex(3*ZZ) # indirect doctest \left(3\right)\Bold{Z} """ return '\\left(%s\\right)%s'%(", ".join([latex.latex(g) for g in \ self.gens()]), latex.latex(self.ring()))
def _print_latex_(self, a, b, z): r""" TESTS:: sage: latex(hypergeometric([1, 1], [2], -1)) \,_2F_1\left(\begin{matrix} 1,1 \\ 2 \end{matrix} ; -1 \right) """ aa = ",".join(latex(c) for c in a) bb = ",".join(latex(c) for c in b) z = latex(z) return (r"\,_{}F_{}\left(\begin{{matrix}} {} \\ {} \end{{matrix}} ; " r"{} \right)").format(len(a), len(b), aa, bb, z)
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: S = SymmetricGroupAlgebra(QQ, 3) sage: W = S.cell_module([2,1]) sage: latex(W) W_{...}\left(...\right) """ from sage.misc.latex import latex return "W_{{{}}}\\left({}\\right)".format(latex(self._algebra), latex(self._la))
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: m = matrix([[0,1],[1,1]]) sage: J.<a,b,c> = JordanAlgebra(m) sage: latex(a + 2*b - c) 1 + \left(2,\,-1\right) """ from sage.misc.latex import latex return "{} + {}".format(latex(self._s), latex(self._v))
def _latex_(self): """ Return a latex representation of ``self``. EXAMPLES:: sage: print(Bimodules(QQ, ZZ)._latex_()) {\mathbf{Bimodules}}_{\Bold{Q}, \Bold{Z}} """ from sage.misc.latex import latex return "{{{0}}}_{{{1}, {2}}}".format(Category._latex_(self), latex(self._left_base_ring), latex(self._right_base_ring))
def _print_latex_(self, m, n, **kwds): r""" Return latex expression EXAMPLES:: sage: from sage.misc.latex import latex sage: m,n=var('m,n') sage: latex(kronecker_delta(m,n)) \delta_{m,n} """ from sage.misc.latex import latex return r"\delta_{%s,%s}" % (latex(m), latex(n))
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: SGA = SymmetricGroupAlgebra(QQ, 3) sage: T = SGA.trivial_representation() sage: H = SGA.hochschild_complex(T) sage: latex(H) C_{\bullet}\left(..., ...\right) """ from sage.misc.latex import latex return "C_{{\\bullet}}\\left({}, {}\\right)".format(latex(self._A), latex(self._M))
def _UG(n, R, special, var='a', invariant_form=None): r""" This function is commonly used by the functions :func:`GU` and :func:`SU` to avoid duplicated code. For documentation and examples see the individual functions. TESTS:: sage: GU(3,25).order() # indirect doctest 3961191000000 """ prefix = 'General' latex_prefix ='G' if special: prefix = 'Special' latex_prefix ='S' degree, ring = normalize_args_vectorspace(n, R, var=var) if is_FiniteField(ring): q = ring.cardinality() ring = GF(q**2, name=var) if invariant_form is not None: raise NotImplementedError("invariant_form for finite groups is fixed by GAP") if invariant_form is not None: invariant_form = normalize_args_invariant_form(ring, degree, invariant_form) if not invariant_form.is_hermitian(): raise ValueError("invariant_form must be hermitian") try: if invariant_form.is_positive_definite(): inserted_text = "with respect to positive definite hermitian form" else: inserted_text = "with respect to non positive definite hermitian form" except ValueError: inserted_text = "with respect to hermitian form" name = '{0} Unitary Group of degree {1} over {2} {3}\n{4}'.format(prefix, degree, ring, inserted_text, invariant_form) ltx = r'\text{{{0}U}}_{{{1}}}({2})\text{{ {3} }}{4}'.format(latex_prefix, degree, latex(ring), inserted_text, latex(invariant_form)) else: name = '{0} Unitary Group of degree {1} over {2}'.format(prefix, degree, ring) ltx = r'\text{{{0}U}}_{{{1}}}({2})'.format(latex_prefix, degree, latex(ring)) if is_FiniteField(ring): cmd = '{0}U({1}, {2})'.format(latex_prefix, degree, q) return UnitaryMatrixGroup_gap(degree, ring, special, name, ltx, cmd) else: return UnitaryMatrixGroup_generic(degree, ring, special, name, ltx, invariant_form=invariant_form)
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: O = lie_algebras.OnsagerAlgebra(QQ) sage: Q = O.quantum_group(q=-1) sage: latex(Q) U_{-1}(\mathcal{O}_{\Bold{Q}})_{-1} """ from sage.misc.latex import latex return "U_{{{}}}(\\mathcal{{O}}_{{{}}})_{{{}}}".format(latex(self._q), latex(self._g.base_ring()), latex(self._c))
def _latex_(self): r""" Returns LaTeX representation of ``self``. EXAMPLES:: sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: latex(RC(partition_list=[[2],[2,2],[2,1],[2]])[2]) { \begin{array}[t]{r|c|c|l} \cline{2-3} 0 &\phantom{|}&\phantom{|}& 0 \\ \cline{2-3} -1 &\phantom{|}& \multicolumn{2 }{l}{ -1 } \\ \cline{2-2} \end{array} } """ num_rows = len(self._list) if num_rows == 0: return "{\\emptyset}" num_cols = self._list[0] ret_string = ( "{\n\\begin{array}[t]{r|" + "c|" * num_cols + "l}\n" + "\\cline{2-" + repr(1 + num_cols) + "} " + latex(self.vacancy_numbers[0]) ) for i, row_len in enumerate(self._list): ret_string += " &" + "\\phantom{|}&" * row_len if num_cols == row_len: ret_string += " " + latex(self.rigging[i]) else: ret_string += " \\multicolumn{" + repr(num_cols - row_len + 1) ret_string += "}{l}{" + latex(self.rigging[i]) + "}" ret_string += " \\\\\n" ret_string += "\\cline{2-" + repr(1 + row_len) + "} " if i != num_rows - 1 and row_len != self._list[i + 1]: ret_string += latex(self.vacancy_numbers[i + 1]) ret_string += "\n\\end{array}\n}" return ret_string
def _latex_(self): r""" Return a LaTeX representation of ``self``. TESTS:: sage: Gamma = graphs.CycleGraph(5) sage: G = RightAngledArtinGroup(Gamma) sage: a,b,c,d,e = G.gens() sage: latex(a*b*e^-4*d^3) \sigma_{0}\sigma_{1}\sigma_{4}^{-4}\sigma_{3}^{3} sage: latex(G.one()) 1 sage: Gamma = Graph([('x', 'y'), ('y', 'zeta')]) sage: G = RightAngledArtinGroup(Gamma) sage: x,y,z = G.gens() sage: latex(x^-5*y*z^3) \sigma_{\text{\texttt{x}}}^{-5}\sigma_{\text{\texttt{y}}}\sigma_{\text{\texttt{zeta}}}^{3} """ if not self._data: return '1' from sage.misc.latex import latex latexrepr = '' v = self.parent()._graph.vertices() for i, p in self._data: latexrepr += "\\sigma_{{{}}}".format(latex(v[i])) if p != 1: latexrepr += "^{{{}}}".format(p) return latexrepr
def _latex_(self): """ Return a latex representation of ``self``. EXAMPLES:: sage: latex(Frac(GF(7)['x,y,z'])) # indirect doctest \mathrm{Frac}(\Bold{F}_{7}[x, y, z]) """ return "\\mathrm{Frac}(%s)" % latex.latex(self._R)
def make_class(self): self.decompositioninfo = decomposition_display( list(zip(self.simple_distinct, self.simple_multiplicities))) self.basechangeinfo = self.basechange_display() self.formatted_polynomial = list_to_factored_poly_otherorder( self.polynomial, galois=False, vari="x") if self.is_simple and QQ['x'](self.polynomial).is_irreducible(): self.expanded_polynomial = '' else: self.expanded_polynomial = latex.latex(QQ[['x']](self.polynomial))
def __init__(self, monoid): """ The nerve of a multiplicative monoid. INPUT: - ``monoid`` -- a multiplicative monoid See :meth:`sage.categories.finite_monoids.FiniteMonoids.ParentMethods.nerve` for full documentation. EXAMPLES:: sage: M = FiniteMonoids().example() sage: M An example of a finite multiplicative monoid: the integers modulo 12 sage: X = M.nerve() sage: list(M) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] sage: X.n_cells(0) [1] sage: X.n_cells(1) [0, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9] """ category = SimplicialSets().Pointed() Parent.__init__(self, category=category) self.rename("Nerve of {}".format(str(monoid))) self.rename_latex("B{}".format(latex(monoid))) e = AbstractSimplex(0, name=str(monoid.one()), latex_name=latex(monoid.one())) self._basepoint = e vertex = SimplicialSet_finite({e: None}, base_point=e) # self._n_skeleton: cache the highest dimensional skeleton # calculated so far for this simplicial set, along with its # dimension. self._n_skeleton = (0, vertex) self._monoid = monoid # self._simplex_data: a tuple whose elements are pairs (simplex, list # of monoid elements). Omit the base point. self._simplex_data = ()
def _print_latex_(self, z): r""" Custom ``_print_latex_`` method. EXAMPLES:: sage: latex(exp_integral_e1(2)) E_{1}\left(2\right) """ return r"E_{{1}}\left({}\right)".format(latex(z))
def _latex_(self): r""" EXAMPLES:: sage: V = VectorSpace(QQ,3) sage: x = V.0 sage: latex(x.category()) # indirect doctest \mathbf{Elt}_{\Bold{Q}^{3}} """ return "\\mathbf{Elt}_{%s}" % latex(self.__object)
def _latex_(self): r""" EXAMPLES:: sage: v = Sequence([1,2,3]) sage: latex(v.category()) # indirect doctest \mathbf{Seq}_{\Bold{Z}} """ return "\\mathbf{Seq}_{%s}" % latex(self.__object)
def __init__(self, real_line, lower, upper): r""" Construct an open inverval. TESTS:: sage: from sage.geometry.manifolds.manifold import OpenInterval sage: R = RealLine() sage: I = OpenInterval(R, -1, 1) ; I Real interval (-1, 1) sage: TestSuite(I).run() sage: J = OpenInterval(R, -oo, 2) ; J Real interval (-Infinity, 2) sage: TestSuite(J).run() """ from sage.misc.latex import latex if not isinstance(real_line, RealLine): raise TypeError( "{} is not an instance of RealLine".format(real_line)) name = "({}, {})".format(lower, upper) latex_name = r"\left(" + latex(lower) + ", " + latex( upper) + r"\right)" ManifoldOpenSubset.__init__(self, real_line, name, latex_name=latex_name) t = real_line.canonical_coordinate() if lower != minus_infinity: if upper != infinity: restrictions = [t > lower, t < upper] else: restrictions = t > lower else: if upper != infinity: restrictions = t < upper else: restrictions = None self._lower = lower self._upper = upper self._canon_chart = real_line.canonical_chart().restrict( self, restrictions=restrictions) self._canon_chart._bounds = (((lower, False), (upper, False)), )
def _print_latex_(self, f, x): """ EXAMPLES:: sage: from sage.symbolic.integration.integral import indefinite_integral sage: print_latex = indefinite_integral._print_latex_ sage: var('x,a,b') (x, a, b) sage: f = function('f') sage: print_latex(f(x),x) '\\int f\\left(x\\right)\\,{d x}' """ from sage.misc.latex import latex if not is_SymbolicVariable(x): dx_str = "{d \\left(%s\\right)}" % (latex(x)) else: dx_str = "{d %s}" % (latex(x)) return "\\int %s\\,%s" % (latex(f), dx_str)
def _latex_(self): r""" LaTeX representation of self. EXAMPLES:: sage: latex(CuspForms(3, 24).hecke_algebra()) # indirect doctest \mathbf{T}_{\text{\texttt{Cuspidal...Gamma0(3)...24...} """ return "\\mathbf{T}_{%s}" % latex(self.__M)
def _latex_(self): r""" EXAMPLES:: sage: latex(LaurentPolynomialRing(QQ,2,'x')) \Bold{Q}[x_{0}^{\pm 1}, x_{1}^{\pm 1}] """ vars = ', '.join( [a + r'^{\pm 1}' for a in self.latex_variable_names()]) return "%s[%s]" % (latex(self.base_ring()), vars)
def _latex_(self): r""" Returns LaTeX representation of ``self``. EXAMPLES:: sage: RC = RiggedConfigurations(['A', 4, 1], [[2, 2]]) sage: latex(RC(partition_list=[[2],[2,2],[2,1],[2]])[2]) { \begin{array}[t]{r|c|c|l} \cline{2-3} 0 &\phantom{|}&\phantom{|}& 0 \\ \cline{2-3} -1 &\phantom{|}& \multicolumn{2 }{l}{ -1 } \\ \cline{2-2} \end{array} } """ num_rows = len(self._list) if num_rows == 0: return "{\\emptyset}" num_cols = self._list[0] ret_string = ("{\n\\begin{array}[t]{r|" + "c|"*num_cols + "l}\n" + "\\cline{2-" + repr(1 + num_cols) + "} " + latex(self.vacancy_numbers[0])) for i, row_len in enumerate(self._list): ret_string += " &" + "\\phantom{|}&"*row_len if num_cols == row_len: ret_string += " " + latex(self.rigging[i]) else: ret_string += " \\multicolumn{" + repr(num_cols - row_len + 1) ret_string += "}{l}{" + latex(self.rigging[i]) + "}" ret_string += " \\\\\n" ret_string += "\\cline{2-" + repr(1 + row_len) + "} " if i != num_rows - 1 and row_len != self._list[i + 1]: ret_string += latex(self.vacancy_numbers[i + 1]) ret_string += "\n\\end{array}\n}" return ret_string
def quoted_latex(x): """ Strips the latex representation of ``x`` to make it suitable for a ``dot2tex`` string. EXAMPLES:: sage: sage.graphs.dot2tex_utils.quoted_latex(matrix([[1,1],[0,1],[0,0]])) '\\left(\\begin{array}{rr}1 & 1 \\\\0 & 1 \\\\0 & 0\\end{array}\\right)' """ return re.sub("\"|\r|(%[^\n]*)?\n", "", latex(x))
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: H = groups.matrix.Heisenberg() sage: latex(H) H_{1}({\Bold{Z}}) """ return "H_{{{}}}({{{}}})".format(self._n, latex(self._ring))
def Sp(n, R, var='a'): r""" Return the symplectic group. The special linear group `GL( d, R )` consists of all `d \times d` matrices that are invertible over the ring `R` with determinant one. .. note:: This group is also available via ``groups.matrix.Sp()``. INPUT: - ``n`` -- a positive integer. - ``R`` -- ring or an integer. If an integer is specified, the corresponding finite field is used. - ``var`` -- variable used to represent generator of the finite field, if needed. EXAMPLES:: sage: Sp(4, 5) Symplectic Group of degree 4 over Finite Field of size 5 sage: Sp(4, IntegerModRing(15)) Symplectic Group of degree 4 over Ring of integers modulo 15 sage: Sp(3, GF(7)) Traceback (most recent call last): ... ValueError: the degree must be even TESTS:: sage: groups.matrix.Sp(2, 3) Symplectic Group of degree 2 over Finite Field of size 3 sage: G = Sp(4,5) sage: TestSuite(G).run() """ degree, ring = normalize_args_vectorspace(n, R, var=var) if degree % 2 != 0: raise ValueError('the degree must be even') name = 'Symplectic Group of degree {0} over {1}'.format(degree, ring) ltx = r'\text{{Sp}}_{{{0}}}({1})'.format(degree, latex(ring)) from sage.libs.gap.libgap import libgap try: cmd = 'Sp({0}, {1})'.format(degree, ring._gap_init_()) return SymplecticMatrixGroup_gap(degree, ring, True, name, ltx, cmd) except ValueError: return SymplecticMatrixGroup_generic(degree, ring, True, name, ltx)
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: latex(Yangian(QQ, 4)) Y(\mathfrak{gl}_{4}, \Bold{Q}) """ from sage.misc.latex import latex return "Y(\\mathfrak{{gl}}_{{{}}}, {})".format(self._n, latex(self.base_ring()))
def _latex_(self): r""" Return the LaTeX representation of ``self``. EXAMPLES:: sage: S = Set(GF(2)) sage: latex(S) \left\{0, 1\right\} """ return '\\left\\{' + ', '.join([latex(x) for x in self.set()]) + '\\right\\}'
def suppress1(x): '''Returns the LaTeX string "x", where x is a number, unless x = 1 (resp. -1), in which case it returns "+" (resp. "-"). This is useful when x is a coefficient of something. ''' if x == 1: return ("") if x == -1: return ("-") else: return (latex(x))
def _latex_(self): """ Return the LaTeX representation of the divisor. EXAMPLES:: sage: K.<x>=FunctionField(GF(2)); _.<Y>=K[] sage: L.<y>=K.extension(Y^3+x+x^3*Y) sage: p = L.places_finite()[0] sage: p Place (x, y) """ mul = '' plus = ' + ' minus = ' - ' cr = '' places = sorted(self._data.keys()) if len(places) == 0: return '0' p = places.pop(0) m = self._data[p] if m == 1: r = latex(p) elif m == -1: r = '-' + latex(p) # seems more readable then `-1*` else: # nonzero r = latex(m) + mul + latex(p) for p in places: m = self._data[p] if m == 1: r += cr + plus + latex(p) elif m == -1: r += cr + minus + latex(p) elif m > 0: r += cr + plus + latex(m) + mul + latex(p) elif m < 0: r += cr + minus + latex(-m) + mul + latex(p) return r
def _latex_(self): r""" Latex method for ``self``. EXAMPLES:: sage: C = CrystalOfLSPaths(['A',2],[1,1]) sage: c = C.module_generators[0] sage: c._latex_() [\Lambda_{1} + \Lambda_{2}] """ return [latex(p) for p in self.value]
def _latex_(self): r""" Return the LaTeX representation of ``self``. EXAMPLES:: sage: from sage.modular.modform_hecketriangle.hecke_triangle_groups import HeckeTriangleGroup sage: a = HeckeTriangleGroup(5) sage: latex(a) \Gamma^{(5)} """ return '\\Gamma^{(%s)}' % latex(self._n)
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: A = Algebras(QQ).WithBasis().Filtered().example() sage: latex(A.graded_algebra()) \operatorname{gr} ... """ from sage.misc.latex import latex return "\\operatorname{gr} " + latex(self._A)
def _latex_(self): r""" Return a string representation of ``self``. EXAMPLES:: sage: O = lie_algebras.OnsagerAlgebra(QQ) sage: latex(O) \mathcal{O}_{\Bold{Q}} """ from sage.misc.latex import latex return "\\mathcal{{O}}_{{{}}}".format(latex(self.base_ring()))
def _latex_(self): """ EXAMPLES:: sage: from sage.structure.element_wrapper import DummyParent sage: ElementWrapper(1, parent = DummyParent("A parent"))._latex_() 1 sage: ElementWrapper(3/5, parent = DummyParent("A parent"))._latex_() \frac{3}{5} """ from sage.misc.latex import latex return latex(self.value)
def _latex_(self): r""" Return a latex representation of ``self``. EXAMPLES:: sage: L = LazyLaurentSeriesRing(GF(2), 'z') sage: latex(L) \Bold{F}_{2} (\!(z)\!) """ from sage.misc.latex import latex return latex(self.base_ring()) + r"(\!({})\!)".format(self.variable_name())
def _latex_(self): r""" EXAMPLES:: sage: from sage.geometry.hyperbolic_space.hyperbolic_point import * sage: p = HyperbolicPlane().UHP().get_point(0) sage: latex(p) 0 sage: q = HyperbolicPlane().HM().get_point((0,0,1)) sage: latex(q) \left(0,\,0,\,1\right) """ return latex(self._coordinates)
def _repr_(self, do_latex=False): """ Returns a print representation of this extension. EXAMPLES:: sage: A = Zp(7,10) sage: S.<x> = A[] sage: B.<t> = A.ext(x^2+7) sage: B #indirect doctest Eisenstein Extension in t defined by x^2 + 7 with capped relative precision 20 over 7-adic Ring """ if do_latex: return "Eisenstein Extension in %s defined by %s over %s" % ( self.latex_name(), latex(self.defining_polynomial(exact=True)), latex(self.ground_ring())) else: return "Eisenstein Extension in %s defined by %s %s over %s-adic %s" % ( self.variable_name(), self.defining_polynomial(exact=True), precprint(self._prec_type(), self.precision_cap(), self.variable_name()), self.prime(), "Field" if self.is_field() else "Ring")
def _print_latex_(self, f, x, a, b): r""" Returns LaTeX expression for integration of a symbolic function. EXAMPLES:: sage: from sage.symbolic.integration.integral import definite_integral sage: print_latex = definite_integral._print_latex_ sage: var('x,a,b') (x, a, b) sage: f = function('f') sage: print_latex(f(x),x,0,1) '\\int_{0}^{1} f\\left(x\\right)\\,{d x}' sage: latex(integrate(tan(x)/x, x, 0, 1)) \int_{0}^{1} \frac{\tan\left(x\right)}{x}\,{d x} """ from sage.misc.latex import latex if not is_SymbolicVariable(x): dx_str = "{d \\left(%s\\right)}"%(latex(x)) else: dx_str = "{d %s}"%(latex(x)) return "\\int_{%s}^{%s} %s\\,%s"%(latex(a), latex(b), latex(f), dx_str)
def _latex_(self): """ Returns latex code for self. EXAMPLES:: sage: C = CrystalOfLetters(["A",2]) sage: D = CrystalOfTableaux(["A",2], shape=[2]) sage: E = TensorProductOfCrystals(C,D) sage: E.module_generators[0]._latex_() '1\\otimes{\\def\\lr#1{\\multicolumn{1}{|@{\\hspace{.6ex}}c@{\\hspace{.6ex}}|}{\\raisebox{-.3ex}{$#1$}}}\n\\raisebox{-.6ex}{$\\begin{array}[b]{cc}\n\\cline{1-1}\\cline{2-2}\n\\lr{1}&\\lr{1}\\\\\n\\cline{1-1}\\cline{2-2}\n\\end{array}$}\n}' """ return '\otimes'.join(latex(c) for c in self)
def _latex_(self): """ Returns latex representation of power series ring EXAMPLES:: sage: M = PowerSeriesRing(QQ,4,'v'); M Multivariate Power Series Ring in v0, v1, v2, v3 over Rational Field sage: M._latex_() '\\Bold{Q}[[v_{0}, v_{1}, v_{2}, v_{3}]]' """ generators_latex = ", ".join(self.latex_variable_names()) return "%s[[%s]]" % (latex.latex(self.base_ring()), generators_latex)
def _latex_(self): """ EXAMPLES:: sage: latex(Semigroups().Subquotients()) # indirect doctest \mathbf{Subquotients}(\mathbf{Semigroups}) sage: latex(ModulesWithBasis(QQ).TensorProducts()) \mathbf{TensorProducts}(\mathbf{ModulesWithBasis}_{\Bold{Q}}) sage: latex(Semigroups().Algebras(QQ)) \mathbf{Algebras}(\mathbf{Semigroups}) """ from sage.misc.latex import latex return "\\mathbf{%s}(%s)"%(self._short_name(), latex(self.base_category()))