galgebra.printer

ANSI Enhanced Text Printing, Text Printer and LaTeX Printer for all Geometric Algebra classes

Members

galgebra.printer.Format(Fmode=True, Dmode=True, dop=1, inverse='full')[source]

Set modes for latex printer -

Fmode: Suppress function arguments (True) Use sympy latex for functions (False) Dmode: Use compact form of derivatives (True) Use sympy latex for derivatives (False)

and redirects printer output so that latex compiler can capture it.

galgebra.printer.GAeval(s, pstr=False)[source]

GAeval converts a string to a multivector expression where the user can control the precedence of the of the multivector operators so that one does not need to put parenthesis around every multivector operation. The default precedence used (high to low) is <,>, and | have an have the highest precedence, then comes ^, and finally *. The default precedence can be changed with the def_prec function.

class galgebra.printer.GaLatexPrinter(settings=None)[source]

The latex printer is turned on with the function (in ga.py) -

Format(Fmode=True,Dmode=True,ipy=False)

where Fmode is the function printing mode that surpresses printing arguments, Dmode is the derivative printing mode that does not use fractions, and ipy=True is the Ipython notebook mode that does not redirect the print output.

The latex output is post processed and displayed with the function (in GAPrint.py) -

xpdf(filename=’tmplatex.tex’,debug=False)

where filename is the name of the tex file one would keep for future inclusion in documents and debug=True would display the tex file immediately.

There are three options for printing multivectors in latex. They are acessed with the multivector member function -

A.Fmt(self,fmt=1,title=None)

where fmt=1, 2, or 3 determines whether the entire multivector A is printed entirely on one line, or one grade is printed per line, or one base is printed per line. If title is not None then the latex string generated is of the form -

title+’ = ‘+str(A)

where it is assumed that title is a latex math mode string. If title contains ‘%’ it is treated as a pure latex math mode string. If it does not contain ‘%’ then the following character mappings are applied -

‘grad’ -> ‘bm{nabla} ‘ ‘*’ -> ‘’ ‘^’ -> ‘W ‘ ‘|’ -> ‘cdot ‘ ‘>’ -> ‘lfloor ‘ ‘<’ -> ‘rfloor ‘

In the case of a print statement of the form -

print title,A

everthing in the title processing still applies except that the multivector formatting is one multivector per line.

For print statements of the form -

print title

where no program variables are printed if title contains ‘#’ then title is printed as regular latex line. If title does not contain ‘#’ then title is printed in equation mode. ‘%’ has the same effect in title as in the Fmt() member function.

doprint(expr)

Returns printer’s representation for expr (as a string)

embed_super(s)

Embed s in {} if there is a superscript in s

emptyPrinter

alias of builtins.str

parenthesize_super(s)

Parenthesize s if there is a superscript in s

classmethod set_global_settings(**settings)

Set system-wide printing settings.

static split_super_sub(text)[source]

Split a symbol name into a name, superscripts and subscripts

The first part of the symbol name is considered to be its actual ‘name’, followed by super- and subscripts. Each superscript is preceded with a “^” character or by “__”. Each subscript is preceded by a “_” character. The three return values are the actual name, a list with superscripts and a list with subscripts.

>>> from sympy.printing.conventions import split_super_sub
>>> split_super_sub('a_x^1')
('a', ['1'], ['x'])
>>> split_super_sub('var_sub1__sup_sub2')
('var', ['sup'], ['sub1', 'sub2'])
class galgebra.printer.GaPrinter(settings=None)[source]
doprint(expr)

Returns printer’s representation for expr (as a string)

emptyPrinter(expr)

str(object=’‘) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

classmethod set_global_settings(**settings)

Set system-wide printing settings.

galgebra.printer.coef_simplify(expr)[source]

fcts = find_functions(expr) return expr.collect(fcts)

galgebra.printer.find_executable(executable, path=None)[source]

Try to find ‘executable’ in the directories listed in ‘path’ (a string listing directories separated by ‘os.pathsep’; defaults to os.environ[‘PATH’]). Returns the complete filename or None if not found

galgebra.printer.isinteractive()[source]

We will assume that if ipython is running then jupyter notebook is running.

galgebra.printer.oprint(*args, dict_mode=False)[source]

Debug printing for iterated (list/tuple/dict/set) objects. args is of form (title1,object1,title2,object2,…) and prints:

title1 = object1 title2 = object2 …

If you only wish to print a title set object = None.

galgebra.printer.ostr(obj, dict_mode=False, indent=True)[source]

Recursively convert iterated object (list/tuple/dict/set) to string.

galgebra.printer.print_latex(expr, **settings)[source]

Prints LaTeX representation of the given expression.

galgebra.printer.tex(paper=(14, 11), debug=False, prog=False, pt='10pt')[source]

Post processes LaTeX output (see comments below), adds preamble and postscript.

We assume that if tex() is called then Format() has been called at the beginning of the program.

galgebra.printer.xpdf(filename=None, paper=(14, 11), crop=False, png=False, prog=False, debug=False, pt='10pt', pdfprog='pdflatex')[source]

Post processes LaTeX output (see comments below), adds preamble and postscript, generates tex file, inputs file to latex, displays resulting pdf file.

Arg Value Result pdfprog ‘pdflatex’ Use pdfprog to generate pdf output, only generate tex if pdfprog is None crop True Use “pdfcrop” to crop output file (pdfcrop must be installed, linux only) png True Use “convert” to produce png output (imagemagick must be installed, linux only)

We assume that if xpdf() is called then Format() has been called at the beginning of the program.