Loading...
Searching...
No Matches
SymEngine::MathMLPrinter Class Reference
+ Inheritance diagram for SymEngine::MathMLPrinter:
+ Collaboration diagram for SymEngine::MathMLPrinter:

Public Member Functions

void bvisit (const Basic &x)
 
void bvisit (const Symbol &x)
 
void bvisit (const Integer &x)
 
void bvisit (const Rational &x)
 
void bvisit (const ComplexBase &x)
 
void bvisit (const Interval &x)
 
void bvisit (const Piecewise &x)
 
void bvisit (const EmptySet &x)
 
void bvisit (const Complexes &x)
 
void bvisit (const Reals &x)
 
void bvisit (const Rationals &x)
 
void bvisit (const Integers &x)
 
void bvisit (const FiniteSet &x)
 
void bvisit (const ConditionSet &x)
 
void bvisit (const Contains &x)
 
void bvisit (const BooleanAtom &x)
 
void bvisit (const And &x)
 
void bvisit (const Or &x)
 
void bvisit (const Xor &x)
 
void bvisit (const Not &x)
 
void bvisit (const Union &x)
 
void bvisit (const Complement &x)
 
void bvisit (const ImageSet &x)
 
void bvisit (const Add &x)
 
void bvisit (const Mul &x)
 
void bvisit (const Pow &x)
 
void bvisit (const Constant &x)
 
void bvisit (const Function &x)
 
void bvisit (const FunctionSymbol &x)
 
void bvisit (const Derivative &x)
 
void bvisit (const UnevaluatedExpr &x)
 
void bvisit (const RealDouble &x)
 
void bvisit (const Equality &x)
 
void bvisit (const Unequality &x)
 
void bvisit (const LessThan &x)
 
void bvisit (const StrictLessThan &x)
 
std::string apply (const Basic &b)
 
- Public Member Functions inherited from SymEngine::StrPrinter
void bvisit (const Basic &x)
 
void bvisit (const Symbol &x)
 
void bvisit (const Integer &x)
 
void bvisit (const Rational &x)
 
void bvisit (const Complex &x)
 
void bvisit (const Interval &x)
 
void bvisit (const Complexes &x)
 
void bvisit (const Reals &x)
 
void bvisit (const Rationals &x)
 
void bvisit (const Integers &x)
 
void bvisit (const Naturals &x)
 
void bvisit (const Naturals0 &x)
 
void bvisit (const Piecewise &x)
 
void bvisit (const EmptySet &x)
 
void bvisit (const FiniteSet &x)
 
void bvisit (const UniversalSet &x)
 
void bvisit (const ConditionSet &x)
 
void bvisit (const Contains &x)
 
void bvisit (const BooleanAtom &x)
 
void bvisit (const And &x)
 
void bvisit (const Or &x)
 
void bvisit (const Xor &x)
 
void bvisit (const Not &x)
 
void bvisit (const Union &x)
 
void bvisit (const Complement &x)
 
void bvisit (const ImageSet &x)
 
void bvisit (const Add &x)
 
void bvisit (const Mul &x)
 
void bvisit (const Pow &x)
 
void bvisit (const UIntPoly &x)
 
void bvisit (const MIntPoly &x)
 
void bvisit (const URatPoly &x)
 
void bvisit (const UExprPoly &x)
 
void bvisit (const MExprPoly &x)
 
void bvisit (const GaloisField &x)
 
void bvisit (const Infty &x)
 
void bvisit (const NaN &x)
 
void bvisit (const UnivariateSeries &x)
 
void bvisit (const Constant &x)
 
void bvisit (const Function &x)
 
void bvisit (const FunctionSymbol &x)
 
void bvisit (const Derivative &x)
 
void bvisit (const Subs &x)
 
void bvisit (const RealDouble &x)
 
void bvisit (const ComplexDouble &x)
 
void bvisit (const Equality &x)
 
void bvisit (const Unequality &x)
 
void bvisit (const LessThan &x)
 
void bvisit (const StrictLessThan &x)
 
void bvisit (const NumberWrapper &x)
 
void bvisit (const Tuple &x)
 
std::string apply (const RCP< const Basic > &b)
 
std::string apply (const vec_basic &v)
 
std::string apply (const Basic &b)
 

Static Public Attributes

static const std::vector< std::stringnames_
 

Protected Attributes

std::ostringstream s
 
- Protected Attributes inherited from SymEngine::StrPrinter
std::string str_
 

Additional Inherited Members

- Protected Member Functions inherited from SymEngine::StrPrinter
virtual std::string print_mul ()
 
virtual bool split_mul_coef ()
 
virtual void _print_pow (std::ostringstream &o, const RCP< const Basic > &a, const RCP< const Basic > &b)
 
virtual std::string print_div (const std::string &num, const std::string &den, bool paren)
 
virtual std::string get_imag_symbol ()
 
virtual std::string parenthesize (const std::string &expr)
 
std::string parenthesizeLT (const RCP< const Basic > &x, PrecedenceEnum precedenceEnum)
 
std::string parenthesizeLE (const RCP< const Basic > &x, PrecedenceEnum precedenceEnum)
 

Detailed Description

Definition at line 9 of file mathml.h.

Member Function Documentation

◆ apply()

std::string SymEngine::MathMLPrinter::apply ( const Basic b)

Definition at line 347 of file mathml.cpp.

348{
349 b.accept(*this);
350 return s.str();
351}
T str(T... args)

◆ bvisit() [1/36]

void SymEngine::MathMLPrinter::bvisit ( const Add x)

Definition at line 234 of file mathml.cpp.

235{
236 s << "<apply><plus/>";
237 auto args = x.get_args();
238 for (auto arg : args) {
239 arg->accept(*this);
240 }
241 s << "</apply>";
242}

◆ bvisit() [2/36]

void SymEngine::MathMLPrinter::bvisit ( const And x)

Definition at line 167 of file mathml.cpp.

168{
169 s << "<apply><and/>";
170 const auto &conditions = x.get_args();
171 for (const auto &condition : conditions) {
172 condition->accept(*this);
173 }
174 s << "</apply>";
175}

◆ bvisit() [3/36]

void SymEngine::MathMLPrinter::bvisit ( const Basic x)

Definition at line 27 of file mathml.cpp.

28{
29 throw SymEngineException("Error: not supported");
30}

◆ bvisit() [4/36]

void SymEngine::MathMLPrinter::bvisit ( const BooleanAtom x)

Definition at line 158 of file mathml.cpp.

159{
160 if (x.get_val()) {
161 s << "<true/>";
162 } else {
163 s << "<false/>";
164 }
165}

◆ bvisit() [5/36]

void SymEngine::MathMLPrinter::bvisit ( const Complement x)

Definition at line 214 of file mathml.cpp.

215{
216 s << "<apply><setdiff/>";
217 x.get_universe()->accept(*this);
218 x.get_container()->accept(*this);
219 s << "</apply>";
220}

◆ bvisit() [6/36]

void SymEngine::MathMLPrinter::bvisit ( const ComplexBase x)

Definition at line 62 of file mathml.cpp.

63{
64 s << "<apply><csymbol cd=\"nums1\">complex_cartesian</csymbol>";
65 x.real_part()->accept(*this);
66 x.imaginary_part()->accept(*this);
67 s << "</apply>";
68}

◆ bvisit() [7/36]

void SymEngine::MathMLPrinter::bvisit ( const Complexes x)

Definition at line 109 of file mathml.cpp.

110{
111 s << "<complexes/>";
112}

◆ bvisit() [8/36]

void SymEngine::MathMLPrinter::bvisit ( const ConditionSet x)

Definition at line 139 of file mathml.cpp.

140{
141 s << "<set><bvar>";
142 x.get_symbol()->accept(*this);
143 s << "</bvar><condition>";
144 x.get_condition()->accept(*this);
145 s << "</condition>";
146 x.get_symbol()->accept(*this);
147 s << "</set>";
148}

◆ bvisit() [9/36]

void SymEngine::MathMLPrinter::bvisit ( const Constant x)

Definition at line 262 of file mathml.cpp.

263{
264 s << "<";
265 if (eq(x, *pi)) {
266 s << "pi/";
267 } else if (eq(x, *E)) {
268 s << "exponentiale/";
269 } else if (eq(x, *EulerGamma)) {
270 s << "eulergamma/";
271 } else {
272 s << "cn type=\"real\">" << eval_double(x) << "</cn";
273 }
274 s << ">";
275}
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21

◆ bvisit() [10/36]

void SymEngine::MathMLPrinter::bvisit ( const Contains x)

Definition at line 150 of file mathml.cpp.

151{
152 s << "<apply><in/>";
153 x.get_expr()->accept(*this);
154 x.get_set()->accept(*this);
155 s << "</apply>";
156}

◆ bvisit() [11/36]

void SymEngine::MathMLPrinter::bvisit ( const Derivative x)

Definition at line 336 of file mathml.cpp.

337{
338 s << "<apply><partialdiff/><bvar>";
339 for (const auto &elem : x.get_symbols()) {
340 elem->accept(*this);
341 }
342 s << "</bvar>";
343 x.get_arg()->accept(*this);
344 s << "</apply>";
345}

◆ bvisit() [12/36]

void SymEngine::MathMLPrinter::bvisit ( const EmptySet x)

Definition at line 104 of file mathml.cpp.

105{
106 s << "<emptyset/>";
107}

◆ bvisit() [13/36]

void SymEngine::MathMLPrinter::bvisit ( const Equality x)

Definition at line 304 of file mathml.cpp.

305{
306 s << "<apply><eq/>";
307 x.get_arg1()->accept(*this);
308 x.get_arg2()->accept(*this);
309 s << "</apply>";
310}

◆ bvisit() [14/36]

void SymEngine::MathMLPrinter::bvisit ( const FiniteSet x)

Definition at line 129 of file mathml.cpp.

130{
131 s << "<set>";
132 const auto &args = x.get_args();
133 for (const auto &arg : args) {
134 arg->accept(*this);
135 }
136 s << "</set>";
137}

◆ bvisit() [15/36]

void SymEngine::MathMLPrinter::bvisit ( const Function x)

Definition at line 277 of file mathml.cpp.

278{
279 static const std::vector<std::string> names_ = init_mathml_printer_names();
280 s << "<apply>";
281 s << "<" << names_[x.get_type_code()] << "/>";
282 const auto &args = x.get_args();
283 for (const auto &arg : args) {
284 arg->accept(*this);
285 }
286 s << "</apply>";
287}

◆ bvisit() [16/36]

void SymEngine::MathMLPrinter::bvisit ( const FunctionSymbol x)

Definition at line 294 of file mathml.cpp.

295{
296 s << "<apply><ci>" << x.get_name() << "</ci>";
297 const auto &args = x.get_args();
298 for (const auto &arg : args) {
299 arg->accept(*this);
300 }
301 s << "</apply>";
302}

◆ bvisit() [17/36]

void SymEngine::MathMLPrinter::bvisit ( const ImageSet x)

Definition at line 222 of file mathml.cpp.

223{
224 s << "<set><bvar>";
225 x.get_expr()->accept(*this);
226 s << "</bvar><condition><apply><in/>";
227 x.get_symbol()->accept(*this);
228 x.get_baseset()->accept(*this);
229 s << "</apply></condition>";
230 x.get_symbol()->accept(*this);
231 s << "</set>";
232}

◆ bvisit() [18/36]

void SymEngine::MathMLPrinter::bvisit ( const Integer x)

Definition at line 37 of file mathml.cpp.

38{
39 s << "<cn type=\"integer\">" << x.as_integer_class() << "</cn>";
40}

◆ bvisit() [19/36]

void SymEngine::MathMLPrinter::bvisit ( const Integers x)

Definition at line 124 of file mathml.cpp.

125{
126 s << "<integers/>";
127}

◆ bvisit() [20/36]

void SymEngine::MathMLPrinter::bvisit ( const Interval x)

Definition at line 70 of file mathml.cpp.

71{
72 s << "<interval closure=";
73 if (x.get_left_open()) {
74 if (x.get_right_open()) {
75 s << "\"open\">";
76 } else {
77 s << "\"open-closed\">";
78 }
79 } else {
80 if (x.get_right_open()) {
81 s << "\"closed-open\">";
82 } else {
83 s << "\"closed\">";
84 }
85 }
86 x.get_start()->accept(*this);
87 x.get_end()->accept(*this);
88 s << "</interval>";
89}

◆ bvisit() [21/36]

void SymEngine::MathMLPrinter::bvisit ( const LessThan x)

Definition at line 320 of file mathml.cpp.

321{
322 s << "<apply><leq/>";
323 x.get_arg1()->accept(*this);
324 x.get_arg2()->accept(*this);
325 s << "</apply>";
326}

◆ bvisit() [22/36]

void SymEngine::MathMLPrinter::bvisit ( const Mul x)

Definition at line 244 of file mathml.cpp.

245{
246 s << "<apply><times/>";
247 auto args = x.get_args();
248 for (auto arg : args) {
249 arg->accept(*this);
250 }
251 s << "</apply>";
252}

◆ bvisit() [23/36]

void SymEngine::MathMLPrinter::bvisit ( const Not x)

Definition at line 197 of file mathml.cpp.

198{
199 s << "<apply><not/>";
200 x.get_arg()->accept(*this);
201 s << "</apply>";
202}

◆ bvisit() [24/36]

void SymEngine::MathMLPrinter::bvisit ( const Or x)

Definition at line 177 of file mathml.cpp.

178{
179 s << "<apply><or/>";
180 const auto &conditions = x.get_args();
181 for (const auto &condition : conditions) {
182 condition->accept(*this);
183 }
184 s << "</apply>";
185}

◆ bvisit() [25/36]

void SymEngine::MathMLPrinter::bvisit ( const Piecewise x)

Definition at line 91 of file mathml.cpp.

92{
93 s << "<piecewise>";
94 const auto &equations = x.get_vec();
95 for (const auto &equation : equations) {
96 s << "<piece>";
97 equation.first->accept(*this);
98 equation.second->accept(*this);
99 s << "</piece>";
100 }
101 s << "</piecewise>";
102}

◆ bvisit() [26/36]

void SymEngine::MathMLPrinter::bvisit ( const Pow x)

Definition at line 254 of file mathml.cpp.

255{
256 s << "<apply><power/>";
257 x.get_base()->accept(*this);
258 x.get_exp()->accept(*this);
259 s << "</apply>";
260}

◆ bvisit() [27/36]

void SymEngine::MathMLPrinter::bvisit ( const Rational x)

Definition at line 42 of file mathml.cpp.

43{
44 const auto &rational = x.as_rational_class();
45 s << "<cn type=\"rational\">" << get_num(rational) << "<sep/>"
46 << get_den(rational) << "</cn>";
47}
RCP< const Number > rational(long n, long d)
convenience creator from two longs
Definition: rational.h:328

◆ bvisit() [28/36]

void SymEngine::MathMLPrinter::bvisit ( const Rationals x)

Definition at line 119 of file mathml.cpp.

120{
121 s << "<rationals/>";
122}

◆ bvisit() [29/36]

void SymEngine::MathMLPrinter::bvisit ( const RealDouble x)

Definition at line 49 of file mathml.cpp.

50{
51 s << "<cn type=\"real\">" << x << "</cn>";
52}

◆ bvisit() [30/36]

void SymEngine::MathMLPrinter::bvisit ( const Reals x)

Definition at line 114 of file mathml.cpp.

115{
116 s << "<reals/>";
117}

◆ bvisit() [31/36]

void SymEngine::MathMLPrinter::bvisit ( const StrictLessThan x)

Definition at line 328 of file mathml.cpp.

329{
330 s << "<apply><lt/>";
331 x.get_arg1()->accept(*this);
332 x.get_arg2()->accept(*this);
333 s << "</apply>";
334}

◆ bvisit() [32/36]

void SymEngine::MathMLPrinter::bvisit ( const Symbol x)

Definition at line 32 of file mathml.cpp.

33{
34 s << "<ci>" << x.get_name() << "</ci>";
35}

◆ bvisit() [33/36]

void SymEngine::MathMLPrinter::bvisit ( const Unequality x)

Definition at line 312 of file mathml.cpp.

313{
314 s << "<apply><neq/>";
315 x.get_arg1()->accept(*this);
316 x.get_arg2()->accept(*this);
317 s << "</apply>";
318}

◆ bvisit() [34/36]

void SymEngine::MathMLPrinter::bvisit ( const UnevaluatedExpr x)

Definition at line 289 of file mathml.cpp.

290{
291 apply(*x.get_arg());
292}

◆ bvisit() [35/36]

void SymEngine::MathMLPrinter::bvisit ( const Union x)

Definition at line 204 of file mathml.cpp.

205{
206 s << "<apply><union/>";
207 const auto &sets = x.get_args();
208 for (const auto &set : sets) {
209 set->accept(*this);
210 }
211 s << "</apply>";
212}

◆ bvisit() [36/36]

void SymEngine::MathMLPrinter::bvisit ( const Xor x)

Definition at line 187 of file mathml.cpp.

188{
189 s << "<apply><xor/>";
190 const auto &conditions = x.get_args();
191 for (const auto &condition : conditions) {
192 condition->accept(*this);
193 }
194 s << "</apply>";
195}

Field Documentation

◆ names_

const std::vector<std::string> SymEngine::MathMLPrinter::names_
static

Definition at line 15 of file mathml.h.

◆ s

std::ostringstream SymEngine::MathMLPrinter::s
protected

Definition at line 12 of file mathml.h.


The documentation for this class was generated from the following files: