Cadabra
Computer algebra system for field theory problems
DisplayMMA.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include "DisplayBase.hh"
5 #include <ostream>
6 #include <map>
7 #include <set>
8 
9 typedef uint32_t kunichar;
10 
11 namespace cadabra {
12 
19 
20  class DisplayMMA : public DisplayBase {
21  public:
22  DisplayMMA(const Kernel&, const Ex&, bool use_unicode);
23 
29 
30  void import(Ex&);
31 
32  std::string preparse_import(const std::string&);
33 
34  protected:
36 
37  virtual bool needs_brackets(Ex::iterator it) override;
38 
39  private:
44 
45  void print_multiplier(std::ostream&, Ex::iterator);
46  void print_opening_bracket(std::ostream&, str_node::bracket_t);
47  void print_closing_bracket(std::ostream&, str_node::bracket_t);
48  void print_parent_rel(std::ostream&, str_node::parent_rel_t, bool first);
49  void print_children(std::ostream&, Ex::iterator, int skip=0);
50 
51 
58 
59  virtual void dispatch(std::ostream&, Ex::iterator) override;
60 
66 
67  void print_productlike(std::ostream&, Ex::iterator, const std::string& inbetween);
68  void print_sumlike(std::ostream&, Ex::iterator);
69  void print_fraclike(std::ostream&, Ex::iterator);
70  void print_commalike(std::ostream&, Ex::iterator);
71  void print_arrowlike(std::ostream&, Ex::iterator);
72  void print_powlike(std::ostream&, Ex::iterator);
73  void print_intlike(std::ostream&, Ex::iterator);
74  void print_equalitylike(std::ostream&, Ex::iterator);
75  void print_components(std::ostream&, Ex::iterator);
76  void print_partial(std::ostream& str, Ex::iterator it);
77  void print_matrix(std::ostream& str, Ex::iterator it);
78  void print_other(std::ostream& str, Ex::iterator it);
79 
80  bool children_have_brackets(Ex::iterator ch) const;
81 
88  std::map<std::string, std::string> symmap;
89  std::multimap<std::string, std::string> regex_map;
90 
93  std::map<nset_t::iterator, Ex, nset_it_less> depsyms;
94  };
95 
96  const char *unichar(kunichar c);
97 
98  }
DisplayBase.hh
cadabra::DisplayMMA::print_intlike
void print_intlike(std::ostream &, Ex::iterator)
Definition: DisplayMMA.cc:513
cadabra::DisplayMMA::print_arrowlike
void print_arrowlike(std::ostream &, Ex::iterator)
Definition: DisplayMMA.cc:399
cadabra::Kernel
Definition: Kernel.hh:14
cadabra::DisplayMMA::print_other
void print_other(std::ostream &str, Ex::iterator it)
Definition: DisplayMMA.cc:179
cadabra::DisplayMMA::DisplayMMA
DisplayMMA(const Kernel &, const Ex &, bool use_unicode)
Definition: DisplayMMA.cc:13
cadabra::DisplayMMA::needs_brackets
virtual bool needs_brackets(Ex::iterator it) override
Determine if a node needs extra brackets around it.
Definition: DisplayMMA.cc:154
cadabra::DisplayMMA::dispatch
virtual void dispatch(std::ostream &, Ex::iterator) override
For every object encountered, dispatch will figure out the most appropriate way to convert it into a ...
Definition: DisplayMMA.cc:363
cadabra::DisplayMMA::print_fraclike
void print_fraclike(std::ostream &, Ex::iterator)
Definition: DisplayMMA.cc:408
cadabra::DisplayMMA::print_commalike
void print_commalike(std::ostream &, Ex::iterator)
Definition: DisplayMMA.cc:382
cadabra::DisplayMMA::print_closing_bracket
void print_closing_bracket(std::ostream &, str_node::bracket_t)
Definition: DisplayMMA.cc:323
cadabra::DisplayMMA::print_sumlike
void print_sumlike(std::ostream &, Ex::iterator)
Definition: DisplayMMA.cc:469
cadabra::DisplayMMA::print_powlike
void print_powlike(std::ostream &, Ex::iterator)
Definition: DisplayMMA.cc:495
cadabra::unichar
const char * unichar(kunichar c)
Definition: DisplayTeX.cc:860
cadabra::DisplayMMA::print_matrix
void print_matrix(std::ostream &str, Ex::iterator it)
Definition: DisplayMMA.cc:584
cadabra::DisplayMMA::print_partial
void print_partial(std::ostream &str, Ex::iterator it)
Definition: DisplayMMA.cc:559
kunichar
uint32_t kunichar
Definition: DisplayMMA.hh:9
cadabra::DisplayMMA::print_opening_bracket
void print_opening_bracket(std::ostream &, str_node::bracket_t)
Definition: DisplayMMA.cc:303
cadabra::DisplayMMA::print_multiplier
void print_multiplier(std::ostream &, Ex::iterator)
Output the expression to a mathematica-readable form.
Definition: DisplayMMA.cc:279
cadabra::DisplayBase
Definition: DisplayBase.hh:18
cadabra::DisplayMMA::regex_map
std::multimap< std::string, std::string > regex_map
Definition: DisplayMMA.hh:89
cadabra::Ex
Definition: Storage.hh:140
cadabra::DisplayMMA::print_children
void print_children(std::ostream &, Ex::iterator, int skip=0)
Definition: DisplayMMA.cc:225
cadabra::DisplayMMA::use_unicode
bool use_unicode
Definition: DisplayMMA.hh:35
cadabra::DisplayMMA
Definition: DisplayMMA.hh:20
cadabra::DisplayMMA::children_have_brackets
bool children_have_brackets(Ex::iterator ch) const
Definition: DisplayMMA.cc:604
cadabra
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Adjform.cc:80
cadabra::str_node::bracket_t
bracket_t
Definition: Storage.hh:57
cadabra::DisplayMMA::print_parent_rel
void print_parent_rel(std::ostream &, str_node::parent_rel_t, bool first)
Definition: DisplayMMA.cc:343
cadabra::DisplayMMA::depsyms
std::map< nset_t::iterator, Ex, nset_it_less > depsyms
Map from symbols which have had dependencies added to an expression containing these dependencies.
Definition: DisplayMMA.hh:93
cadabra::DisplayMMA::preparse_import
std::string preparse_import(const std::string &)
Definition: DisplayMMA.cc:613
cadabra::DisplayMMA::print_components
void print_components(std::ostream &, Ex::iterator)
Definition: DisplayMMA.cc:539
cadabra::DisplayMMA::print_equalitylike
void print_equalitylike(std::ostream &, Ex::iterator)
Definition: DisplayMMA.cc:528
cadabra::str_node::parent_rel_t
parent_rel_t
Child nodes are related to their parent node by a so-called parent relation, which can be one of thes...
Definition: Storage.hh:61
cadabra::DisplayMMA::print_productlike
void print_productlike(std::ostream &, Ex::iterator, const std::string &inbetween)
Printing members for various standard constructions, e.g.
Definition: DisplayMMA.cc:425
cadabra::DisplayMMA::symmap
std::map< std::string, std::string > symmap
Map from Cadabra symbols to Mathematica symbols.
Definition: DisplayMMA.hh:88