import sympy from sympy.printing.latex import LatexPrinter class CustomLatexPrinter(LatexPrinter): def _print_Adjoint(self, expr): mat = expr.arg from sympy.matrices import MatrixSymbol if not isinstance(mat, MatrixSymbol): return r"\left(%s\right)^H" % self._print(mat) else: return "%s^H" % self._print(mat)
sympy.init_session() sympy.Basic.__str__ = lambda self: CustomLatexPrinter().doprint(self) Nk, Nx = sympy.symbols('N_k N_x') FT = sympy.MatrixSymbol('\mathcal{F}', Nx, Nk) s = sympy.MatrixSymbol('s',Nk,1) Sigmax = sympy.MatrixSymbol('\Sigma_x', Nx, Nx) Sigmak = sympy.MatrixSymbol('\Sigma_k', Nk, Nk) W = sympy.MatrixSymbol('W',Nk,Nk) F = FT*W m = sympy.MatrixSymbol('m',1,Nx) Sigmax = m*F*Sigmak*F.adjoint()*m.adjoint() latex(Sigmax) Last line's result is: 'm \\mathcal{F} W \\Sigma_{k} W^\\dag \\mathcal{F}^\\dag m^\\dag' If I do: tmp = CustomLatexPrinter() tmp.doprint(Sigmax) The result is: 'm \\mathcal{F} W \\Sigma_{k} W^H \\mathcal{F}^H m^H' I think I just don't know what to overload. On Sunday, January 31, 2016 at 3:04:32 PM UTC-5, Michael Hansen wrote: > > Quick question. Is there a way to change what symbols are used for things > like adjoint for a matrix. In latex, it is currently \dagger but I would > rather use "H" or something like that. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/bd7962ee-edd1-4d9e-af36-b3537f99055a%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.