srtree-2.0.0.0: A general library to work with Symbolic Regression expression trees.
Copyright(c) Fabricio Olivetti 2021 - 2024
LicenseBSD3
Maintainerfabricio.olivetti@gmail.com
Stabilityexperimental
Portability
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.SRTree.Print

Description

Conversion functions to display the expression trees in different formats.

Synopsis

Documentation

showExpr :: Fix SRTree -> String #

convert a tree into a string in math notation

>>> showExpr $ "x0" + sin ( tanh ("t0" + 2) )
"(x0 + Sin(Tanh((t0 + 2.0))))"

showExprWithVars :: [String] -> Fix SRTree -> String #

convert a tree into a string in math notation given named vars.

>>> showExprWithVar ["mu", "eps"] $ "x0" + sin ( "x1" * tanh ("t0" + 2) )
"(mu + Sin(Tanh(eps * (t0 + 2.0))))"

printExpr :: Fix SRTree -> IO () #

prints the expression

printExprWithVars :: [String] -> Fix SRTree -> IO () #

prints the expression

showTikz :: Fix SRTree -> String #

Displays a tree in Tikz format

printTikz :: Fix SRTree -> IO () #

prints the tree in TikZ format

showPython :: Fix SRTree -> String #

Displays a tree as a numpy compatible expression.

>>> showPython $ "x0" + sin ( tanh ("t0" + 2) )
"(x[:, 0] + np.sin(np.tanh((t[:, 0] + 2.0))))"

printPython :: Fix SRTree -> IO () #

print the expression in numpy notation

showLatex :: Fix SRTree -> String #

Displays a tree as a LaTeX compatible expression.

>>> showLatex $ "x0" + sin ( tanh ("t0" + 2) )
"\\left(x_{, 0} + \\operatorname{sin}(\\operatorname{tanh}(\\left(\\theta_{, 0} + 2.0\\right)))\\right)"

printLatex :: Fix SRTree -> IO () #

prints expression in LaTeX notation.