![]() |
aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
|
Root abstract node for the AST of algebraic expressions. More...
#include <doAST.h>
Public Member Functions | |
| ASTtree (std::string_view type) | |
| Construct an AST node with a descriptive type string (used in dumps). | |
| virtual | ~ASTtree () |
| ASTtree (const ASTtree &)=delete | |
| ASTtree & | operator= (const ASTtree &)=delete |
| ASTtree (ASTtree &&) noexcept | |
| ASTtree & | operator= (ASTtree &&) noexcept=default |
| const std::string & | type () const noexcept |
| virtual std::string | toString (std::string_view prefix="") const =0 |
| Human-readable multi-line rendering (for debugging / logs). | |
| virtual std::string | protectToLatex (HashTable< std::string, int > &nameOccur) const =0 |
| LaTeX rendering with full name protection. | |
| virtual std::string | fastToLatex (HashTable< std::string, int > &nameOccur) const =0 |
| Fast LaTeX rendering (lighter protection). | |
| std::string | toLatex (HashTable< std::string, int > nameOccur=HashTable< std::string, int >()) const |
| Convenience wrapper using an empty occurrence table. | |
| virtual std::unique_ptr< ASTtree< GUM_SCALAR > > | copy () const =0 |
| Deep clone of the sub-tree. | |
| virtual Tensor< GUM_SCALAR > | eval (const IBayesNet< GUM_SCALAR > &contextual_bn) const =0 |
| Evaluate the expression against a contextual BN. | |
Static Protected Member Functions | |
| static std::string | _latexCorrect (std::string_view srcName, HashTable< std::string, int > &nameOccur) |
| Sanitize a single variable name for LaTeX and ensure uniqueness. | |
| static std::vector< std::string > | _latexCorrect (const Set< std::string > &srcNames, HashTable< std::string, int > &nameOccur) |
| Sanitize a set of variable names for LaTeX and ensure uniqueness. | |
Protected Attributes | |
| std::string | _type |
Static Protected Attributes | |
| static constexpr const char * | CONTINUE_PREFIX = "| " |
| Prefix used to draw tree branches in toString. | |
Root abstract node for the AST of algebraic expressions.
This hierarchy represents symbolic probability expressions (e.g., ( \mathbb{P}(Y\mid X) ), products, sums) that can be:
|
explicit |
Construct an AST node with a descriptive type string (used in dumps).
Definition at line 60 of file doAST_tpl.h.
Referenced by gum::ASTBinaryOp< GUM_SCALAR >::ASTBinaryOp(), gum::ASTjointProba< GUM_SCALAR >::ASTjointProba(), gum::ASTposteriorProba< GUM_SCALAR >::ASTposteriorProba(), gum::ASTsum< GUM_SCALAR >::ASTsum(), gum::ASTsum< GUM_SCALAR >::ASTsum(), ASTtree(), ASTtree(), ~ASTtree(), copy(), gum::ASTBinaryOp< GUM_SCALAR >::operator=(), operator=(), and operator=().
|
virtual |
Definition at line 63 of file doAST_tpl.h.
References ASTtree().
|
delete |
|
inlinenoexcept |
|
staticprotected |
Sanitize a set of variable names for LaTeX and ensure uniqueness.
Definition at line 89 of file doAST_tpl.h.
References _latexCorrect().
|
staticprotected |
Sanitize a single variable name for LaTeX and ensure uniqueness.
Definition at line 79 of file doAST_tpl.h.
References gum::HashTable< Key, Val >::getWithDefault().
Referenced by _latexCorrect(), gum::ASTjointProba< GUM_SCALAR >::fastToLatex(), gum::ASTposteriorProba< GUM_SCALAR >::fastToLatex(), gum::ASTsum< GUM_SCALAR >::fastToLatex(), gum::ASTjointProba< GUM_SCALAR >::toString(), and gum::ASTposteriorProba< GUM_SCALAR >::toString().
|
pure virtual |
Deep clone of the sub-tree.
Implemented in gum::ASTdiv< GUM_SCALAR >, gum::ASTjointProba< GUM_SCALAR >, gum::ASTminus< GUM_SCALAR >, gum::ASTmult< GUM_SCALAR >, gum::ASTplus< GUM_SCALAR >, gum::ASTposteriorProba< GUM_SCALAR >, and gum::ASTsum< GUM_SCALAR >.
References ASTtree(), and copy().
Referenced by copy().
|
pure virtual |
Evaluate the expression against a contextual BN.
| contextual_bn | Bayesian network providing CPTs and variable domains |
Implemented in gum::ASTdiv< GUM_SCALAR >, gum::ASTjointProba< GUM_SCALAR >, gum::ASTminus< GUM_SCALAR >, gum::ASTmult< GUM_SCALAR >, gum::ASTplus< GUM_SCALAR >, gum::ASTposteriorProba< GUM_SCALAR >, and gum::ASTsum< GUM_SCALAR >.
References eval().
Referenced by eval().
|
pure virtual |
Fast LaTeX rendering (lighter protection).
Assumes prior hygiene of names; typically avoids heavier bookkeeping performed in protectToLatex.
| nameOccur | symbol occurrence table (may be consulted/updated) |
Implemented in gum::ASTdiv< GUM_SCALAR >, gum::ASTjointProba< GUM_SCALAR >, gum::ASTminus< GUM_SCALAR >, gum::ASTmult< GUM_SCALAR >, gum::ASTplus< GUM_SCALAR >, gum::ASTposteriorProba< GUM_SCALAR >, and gum::ASTsum< GUM_SCALAR >.
References fastToLatex(), and toLatex().
Referenced by fastToLatex(), and toLatex().
|
defaultnoexcept |
|
delete |
|
pure virtual |
LaTeX rendering with full name protection.
Produces LaTeX with variable-name disambiguation, using nameOccur as a registry of encountered names and their occurrence counts.
| nameOccur | symbol occurrence table (updated in place) |
Implemented in gum::ASTdiv< GUM_SCALAR >, gum::ASTjointProba< GUM_SCALAR >, gum::ASTminus< GUM_SCALAR >, gum::ASTmult< GUM_SCALAR >, gum::ASTplus< GUM_SCALAR >, gum::ASTposteriorProba< GUM_SCALAR >, and gum::ASTsum< GUM_SCALAR >.
References protectToLatex().
Referenced by protectToLatex().
| std::string gum::ASTtree< GUM_SCALAR >::toLatex | ( | HashTable< std::string, int > | nameOccur = HashTable< std::string, int >() | ) | const |
Convenience wrapper using an empty occurrence table.
Definition at line 73 of file doAST_tpl.h.
References fastToLatex().
Referenced by fastToLatex().
|
pure virtual |
Human-readable multi-line rendering (for debugging / logs).
| prefix | indentation prefix propagated to children |
Implemented in gum::ASTBinaryOp< GUM_SCALAR >, gum::ASTjointProba< GUM_SCALAR >, gum::ASTposteriorProba< GUM_SCALAR >, and gum::ASTsum< GUM_SCALAR >.
References toString().
Referenced by toString().
|
noexcept |
Definition at line 68 of file doAST_tpl.h.
References _type.
Referenced by gum::ASTBinaryOp< GUM_SCALAR >::ASTBinaryOp(), ASTtree(), and operator=().
|
protected |
Definition at line 154 of file doAST.h.
Referenced by ASTtree(), gum::ASTBinaryOp< GUM_SCALAR >::toString(), and type().
|
staticconstexprprotected |
Prefix used to draw tree branches in toString.
Definition at line 153 of file doAST.h.
Referenced by gum::ASTBinaryOp< GUM_SCALAR >::toString(), and gum::ASTsum< GUM_SCALAR >::toString().