1 #include <symengine/printers/sbml.h>
2 #include <symengine/printers.h>
10 names[SYMENGINE_LOG] =
"ln";
11 names[SYMENGINE_ASIN] =
"arcsin";
12 names[SYMENGINE_ACOS] =
"arccos";
13 names[SYMENGINE_ASEC] =
"arcsec";
14 names[SYMENGINE_ACSC] =
"arccsc";
15 names[SYMENGINE_ATAN] =
"arctan";
16 names[SYMENGINE_ACOT] =
"arccot";
17 names[SYMENGINE_ASINH] =
"arcsinh";
18 names[SYMENGINE_ACSCH] =
"arccsch";
19 names[SYMENGINE_ACOSH] =
"arccosh";
20 names[SYMENGINE_ATANH] =
"arctanh";
21 names[SYMENGINE_ACOTH] =
"arccoth";
22 names[SYMENGINE_ASECH] =
"arcsech";
27 const RCP<const Basic> &b)
30 o <<
"exp(" << apply(b) <<
")";
32 o <<
"sqrt(" << apply(a) <<
")";
34 o << parenthesizeLE(a, PrecedenceEnum::Pow);
36 o << parenthesizeLE(b, PrecedenceEnum::Pow);
40 void SbmlPrinter::bvisit(
const BooleanAtom &x)
49 void SbmlPrinter::bvisit(
const And &x)
52 const auto &container = x.get_container();
54 s << apply(*container.begin());
55 for (
auto it = ++(container.begin()); it != container.end(); ++it) {
56 s <<
", " << apply(*it);
62 void SbmlPrinter::bvisit(
const Or &x)
65 const auto &container = x.get_container();
67 s << apply(*container.begin());
68 for (
auto it = ++(container.begin()); it != container.end(); ++it) {
69 s <<
", " << apply(*it);
75 void SbmlPrinter::bvisit(
const Xor &x)
78 const auto &container = x.get_container();
80 s << apply(*container.begin());
81 for (
auto it = ++(container.begin()); it != container.end(); ++it) {
82 s <<
", " << apply(*it);
88 void SbmlPrinter::bvisit(
const Not &x)
91 s <<
"not(" << *x.get_arg() <<
")";
95 void SbmlPrinter::bvisit(
const Piecewise &x)
98 auto vec = x.get_vec();
99 auto it = vec.begin();
101 while (it != vec.end()) {
102 s << apply((*it).first);
103 if (!(it + 1 == vec.end() &&
eq(*(*it).second, *boolTrue))) {
105 s << apply((*it).second);
108 if (it != vec.end()) {
116 void SbmlPrinter::bvisit(
const Infty &x)
121 void SbmlPrinter::bvisit(
const Constant &x)
124 str_ =
"exponentiale";
131 void SbmlPrinter::bvisit(
const Function &x)
135 vec_basic vec = x.get_args();
136 if (x.get_type_code() == SYMENGINE_GAMMA) {
138 o <<
"factorial(" << apply(vec) <<
" - 1)";
139 }
else if (x.get_type_code() == SYMENGINE_LOG && vec.size() == 2) {
141 o <<
"log(" << apply(vec[1]) <<
", " << apply(vec[0]) <<
")";
143 o << names_[x.get_type_code()];
144 o << parenthesize(apply(vec));
Main namespace for SymEngine package.
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
RCP< const Number > rational(long n, long d)
convenience creator from two longs