Cadabra
Computer algebra system for field theory problems
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DisplaySympy.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 
20 
21 class DisplaySympy : public DisplayBase {
22  public:
23  DisplaySympy(const Kernel&, const Ex&);
24 
30 
31  void import(Ex&);
32 
33  protected:
34  virtual bool needs_brackets(Ex::iterator it) override;
35 
36  private:
41 
42  void print_multiplier(std::ostream&, Ex::iterator);
43  void print_opening_bracket(std::ostream&, str_node::bracket_t);
44  void print_closing_bracket(std::ostream&, str_node::bracket_t);
45  void print_parent_rel(std::ostream&, str_node::parent_rel_t, bool first);
46  void print_children(std::ostream&, Ex::iterator, int skip=0);
47 
48 
55 
56  virtual void dispatch(std::ostream&, Ex::iterator) override;
57 
63 
64  void print_productlike(std::ostream&, Ex::iterator, const std::string& inbetween);
65  void print_sumlike(std::ostream&, Ex::iterator);
66  void print_fraclike(std::ostream&, Ex::iterator);
67  void print_commalike(std::ostream&, Ex::iterator);
68  void print_arrowlike(std::ostream&, Ex::iterator);
69  void print_powlike(std::ostream&, Ex::iterator);
70  void print_intlike(std::ostream&, Ex::iterator);
71  void print_equalitylike(std::ostream&, Ex::iterator);
72  void print_components(std::ostream&, Ex::iterator);
73  void print_partial(std::ostream& str, Ex::iterator it);
74  void print_matrix(std::ostream& str, Ex::iterator it);
75  void print_other(std::ostream& str, Ex::iterator it);
76 
77  bool children_have_brackets(Ex::iterator ch) const;
78 
80  std::map<std::string, std::string> symmap;
81 
84  std::map<nset_t::iterator, Ex, nset_it_less> depsyms;
85 };
86 
87 const char *unichar(kunichar c);
88 
89 }
void print_commalike(std::ostream &, Ex::iterator)
Definition: DisplaySympy.cc:288
Basic storage class for symbolic mathemematical expressions.
Definition: Storage.hh:130
void print_equalitylike(std::ostream &, Ex::iterator)
Definition: DisplaySympy.cc:430
std::map< std::string, std::string > symmap
Map from Cadabra symbols to Sympy symbols.
Definition: DisplaySympy.hh:80
Class to display expressions in a format that Sympy can parse.
Definition: DisplaySympy.hh:21
bool children_have_brackets(Ex::iterator ch) const
Definition: DisplaySympy.cc:506
void print_other(std::ostream &str, Ex::iterator it)
Definition: DisplaySympy.cc:114
void print_multiplier(std::ostream &, Ex::iterator)
Output the expression to a sympy-readable form.
Definition: DisplaySympy.cc:208
void print_opening_bracket(std::ostream &, str_node::bracket_t)
Definition: DisplaySympy.cc:232
void print_productlike(std::ostream &, Ex::iterator, const std::string &inbetween)
Printing members for various standard constructions, e.g.
Definition: DisplaySympy.cc:333
void print_sumlike(std::ostream &, Ex::iterator)
Definition: DisplaySympy.cc:377
Base class for all display classes.
Definition: DisplayBase.hh:18
void print_partial(std::ostream &str, Ex::iterator it)
Definition: DisplaySympy.cc:461
uint32_t kunichar
Definition: DisplayMMA.hh:9
DisplaySympy(const Kernel &, const Ex &)
Definition: DisplaySympy.cc:10
void print_powlike(std::ostream &, Ex::iterator)
Definition: DisplaySympy.cc:403
const char * unichar(kunichar c)
Definition: DisplayTeX.cc:747
virtual bool needs_brackets(Ex::iterator it) override
Determine if a node needs extra brackets around it.
Definition: DisplaySympy.cc:90
void print_arrowlike(std::ostream &, Ex::iterator)
Definition: DisplaySympy.cc:305
void print_matrix(std::ostream &str, Ex::iterator it)
Definition: DisplaySympy.cc:486
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: DisplaySympy.cc:269
void print_fraclike(std::ostream &, Ex::iterator)
Definition: DisplaySympy.cc:316
void print_components(std::ostream &, Ex::iterator)
Definition: DisplaySympy.cc:441
void print_closing_bracket(std::ostream &, str_node::bracket_t)
Definition: DisplaySympy.cc:244
uint32_t kunichar
Definition: DisplaySympy.hh:9
void print_parent_rel(std::ostream &, str_node::parent_rel_t, bool first)
Definition: DisplaySympy.cc:256
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
Definition: Kernel.hh:15
bracket_t
Definition: Storage.hh:57
void print_children(std::ostream &, Ex::iterator, int skip=0)
Definition: DisplaySympy.cc:154
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: DisplaySympy.hh:84
void print_intlike(std::ostream &, Ex::iterator)
Definition: DisplaySympy.cc:415