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

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 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 Intersection &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)
 
void bvisit (const IdentityMatrix &x)
 
void bvisit (const ZeroMatrix &x)
 
std::string apply (const RCP< const Basic > &b)
 
std::string apply (const vec_basic &v)
 
std::string apply (const Basic &b)
 

Protected Member Functions

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)
 

Protected Attributes

std::string str_
 

Static Private Attributes

static const std::vector< std::stringnames_
 

Detailed Description

Definition at line 106 of file strprinter.h.

Member Function Documentation

◆ _print_pow()

void SymEngine::StrPrinter::_print_pow ( std::ostringstream o,
const RCP< const Basic > &  a,
const RCP< const Basic > &  b 
)
protectedvirtual

Definition at line 553 of file strprinter.cpp.

555{
556 if (eq(*a, *E)) {
557 o << "exp(" << apply(b) << ")";
558 } else if (eq(*b, *rational(1, 2))) {
559 o << "sqrt(" << apply(a) << ")";
560 } else {
561 o << parenthesizeLE(a, PrecedenceEnum::Pow);
562 o << "**";
563 o << parenthesizeLE(b, PrecedenceEnum::Pow);
564 }
565}
bool eq(const Basic &a, const Basic &b)
Checks equality for a and b
Definition: basic-inl.h:21
RCP< const Number > rational(long n, long d)
convenience creator from two longs
Definition: rational.h:328

◆ apply() [1/3]

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

Definition at line 1073 of file strprinter.cpp.

1074{
1075 b.accept(*this);
1076 return str_;
1077}

◆ apply() [2/3]

std::string SymEngine::StrPrinter::apply ( const RCP< const Basic > &  b)

Definition at line 1067 of file strprinter.cpp.

1068{
1069 b->accept(*this);
1070 return str_;
1071}

◆ apply() [3/3]

std::string SymEngine::StrPrinter::apply ( const vec_basic v)

Definition at line 861 of file strprinter.cpp.

862{
864 for (auto p = d.begin(); p != d.end(); p++) {
865 if (p != d.begin()) {
866 o << ", ";
867 }
868 o << this->apply(*p);
869 }
870 return o.str();
871}
T str(T... args)

◆ bvisit() [1/54]

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

Definition at line 517 of file strprinter.cpp.

518{
520 bool first = true;
521 std::map<RCP<const Basic>, RCP<const Number>, PrinterBasicCmp> dict(
522 x.get_dict().begin(), x.get_dict().end());
523
524 if (neq(*(x.get_coef()), *zero)) {
525 o << this->apply(x.get_coef());
526 first = false;
527 }
528 for (const auto &p : dict) {
529 std::string t;
530 if (eq(*(p.second), *one)) {
531 t = parenthesizeLT(p.first, PrecedenceEnum::Add);
532 } else if (eq(*(p.second), *minus_one)) {
533 t = "-" + parenthesizeLT(p.first, PrecedenceEnum::Mul);
534 } else {
535 t = parenthesizeLT(p.second, PrecedenceEnum::Mul) + print_mul()
536 + parenthesizeLT(p.first, PrecedenceEnum::Mul);
537 }
538
539 if (not first) {
540 if (t[0] == '-') {
541 o << " - " << t.substr(1);
542 } else {
543 o << " + " << t;
544 }
545 } else {
546 o << t;
547 first = false;
548 }
549 }
550 str_ = o.str();
551}
bool neq(const Basic &a, const Basic &b)
Checks inequality for a and b
Definition: basic-inl.h:29
T substr(T... args)

◆ bvisit() [2/54]

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

Definition at line 296 of file strprinter.cpp.

297{
299 auto container = x.get_container();
300 s << "And(";
301 s << apply(*container.begin());
302 for (auto it = ++(container.begin()); it != container.end(); ++it) {
303 s << ", " << apply(*it);
304 }
305 s << ")";
306 str_ = s.str();
307}

◆ bvisit() [3/54]

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

Definition at line 133 of file strprinter.cpp.

134{
136 s << "<" << typeName<Basic>(x) << " instance at " << (const void *)this
137 << ">";
138 str_ = s.str();
139}

◆ bvisit() [4/54]

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

Definition at line 287 of file strprinter.cpp.

288{
289 if (x.get_val()) {
290 str_ = "True";
291 } else {
292 str_ = "False";
293 }
294}

◆ bvisit() [5/54]

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

Definition at line 428 of file strprinter.cpp.

429{
431 s << apply(*x.get_universe());
432 s << " \\ " << apply(*x.get_container());
433 str_ = s.str();
434}

◆ bvisit() [6/54]

void SymEngine::StrPrinter::bvisit ( const Complex x)

Definition at line 177 of file strprinter.cpp.

178{
180 if (x.real_ != 0) {
181 s << x.real_;
182 // Since Complex is in canonical form, imaginary_ is not 0.
183 if (mp_sign(x.imaginary_) == 1) {
184 s << " + ";
185 } else {
186 s << " - ";
187 }
188 // If imaginary_ is not 1 or -1, print the absolute value
189 if (x.imaginary_ != mp_sign(x.imaginary_)) {
190 s << mp_abs(x.imaginary_);
191 s << print_mul() << get_imag_symbol();
192 } else {
193 s << "I";
194 }
195 } else {
196 if (x.imaginary_ != mp_sign(x.imaginary_)) {
197 s << x.imaginary_;
198 s << print_mul() << get_imag_symbol();
199 } else {
200 if (mp_sign(x.imaginary_) == 1) {
201 s << get_imag_symbol();
202 } else {
203 s << "-" << get_imag_symbol();
204 }
205 }
206 }
207 str_ = s.str();
208}

◆ bvisit() [7/54]

void SymEngine::StrPrinter::bvisit ( const ComplexDouble x)

Definition at line 232 of file strprinter.cpp.

233{
234 str_ = print_double(x.i.real());
235 if (x.i.imag() < 0) {
236 str_ += " - " + print_double(-x.i.imag()) + print_mul()
237 + get_imag_symbol();
238 } else {
239 str_ += " + " + print_double(x.i.imag()) + print_mul()
240 + get_imag_symbol();
241 }
242}

◆ bvisit() [8/54]

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

Definition at line 373 of file strprinter.cpp.

374{
375 str_ = "Complexes";
376}

◆ bvisit() [9/54]

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

Definition at line 457 of file strprinter.cpp.

458{
460 s << "{" << apply(*x.get_symbol());
461 s << " | " << apply(x.get_condition()) << "}";
462 str_ = s.str();
463}

◆ bvisit() [10/54]

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

Definition at line 856 of file strprinter.cpp.

857{
858 str_ = x.get_name();
859}

◆ bvisit() [11/54]

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

Definition at line 342 of file strprinter.cpp.

343{
345 s << "Contains(" << apply(x.get_expr()) << ", " << apply(x.get_set())
346 << ")";
347 str_ = s.str();
348}

◆ bvisit() [12/54]

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

Definition at line 892 of file strprinter.cpp.

893{
895 o << "Derivative(" << this->apply(x.get_arg());
896 auto m1 = x.get_symbols();
897 for (const auto &elem : m1) {
898 o << ", " << this->apply(elem);
899 }
900 o << ")";
901 str_ = o.str();
902}

◆ bvisit() [13/54]

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

Definition at line 403 of file strprinter.cpp.

404{
405 str_ = "EmptySet";
406}

◆ bvisit() [14/54]

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

Definition at line 244 of file strprinter.cpp.

245{
247 s << apply(x.get_arg1()) << " == " << apply(x.get_arg2());
248 str_ = s.str();
249}

◆ bvisit() [15/54]

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

Definition at line 450 of file strprinter.cpp.

451{
453 s << x.get_container();
454 str_ = s.str();
455}

◆ bvisit() [16/54]

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

Definition at line 873 of file strprinter.cpp.

874{
875 static const std::vector<std::string> names_ = init_str_printer_names();
877 o << names_[x.get_type_code()];
878 vec_basic vec = x.get_args();
879 o << parenthesize(apply(vec));
880 str_ = o.str();
881}

◆ bvisit() [17/54]

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

Definition at line 883 of file strprinter.cpp.

884{
886 o << x.get_name();
887 vec_basic vec = x.get_args();
888 o << parenthesize(apply(vec));
889 str_ = o.str();
890}

◆ bvisit() [18/54]

void SymEngine::StrPrinter::bvisit ( const GaloisField x)

Definition at line 668 of file strprinter.cpp.

669{
671 // bool variable needed to take care of cases like -5, -x, -3*x etc.
672 bool first = true;
673 // we iterate over the map in reverse order so that highest degree gets
674 // printed first
675 auto dict = x.get_dict();
676 if (x.get_dict().size() == 0)
677 s << "0";
678 else {
679 for (auto it = dict.size(); it-- != 0;) {
680 if (dict[it] == 0)
681 continue;
682 // if exponent is 0, then print only coefficient
683 if (it == 0) {
684 if (first) {
685 s << dict[it];
686 } else {
687 s << " " << _print_sign(dict[it]) << " "
688 << mp_abs(dict[it]);
689 }
690 first = false;
691 break;
692 }
693 // if the coefficient of a term is +1 or -1
694 if (mp_abs(dict[it]) == 1) {
695 // in cases of -x, print -x
696 // in cases of x**2 - x, print - x
697 if (first) {
698 if (dict[it] == -1)
699 s << "-";
700 s << detail::poly_print(x.get_var());
701 } else {
702 s << " " << _print_sign(dict[it]) << " "
703 << detail::poly_print(x.get_var());
704 }
705 }
706 // same logic is followed as above
707 else {
708 // in cases of -2*x, print -2*x
709 // in cases of x**2 - 2*x, print - 2*x
710 if (first) {
711 s << dict[it] << "*" << detail::poly_print(x.get_var());
712 } else {
713 s << " " << _print_sign(dict[it]) << " " << mp_abs(dict[it])
714 << "*" << detail::poly_print(x.get_var());
715 }
716 }
717 // if exponent is not 1, print the exponent;
718 if (it != 1) {
719 s << "**" << it;
720 }
721 // corner cases of only first term handled successfully, switch the
722 // bool
723 first = false;
724 }
725 }
726 str_ = s.str();
727}

◆ bvisit() [19/54]

void SymEngine::StrPrinter::bvisit ( const IdentityMatrix x)

Definition at line 1030 of file strprinter.cpp.

1031{
1032 str_ = "I";
1033}

◆ bvisit() [20/54]

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

Definition at line 436 of file strprinter.cpp.

437{
439 s << "{" << apply(*x.get_expr()) << " | ";
440 s << apply(*x.get_symbol());
441 s << " in " << apply(*x.get_baseset()) << "}";
442 str_ = s.str();
443}

◆ bvisit() [21/54]

void SymEngine::StrPrinter::bvisit ( const Infty x)

Definition at line 146 of file strprinter.cpp.

147{
149 if (x.is_negative_infinity())
150 s << "-oo";
151 else if (x.is_positive_infinity())
152 s << "oo";
153 else
154 s << "zoo";
155 str_ = s.str();
156}

◆ bvisit() [22/54]

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

Definition at line 163 of file strprinter.cpp.

164{
166 s << x.as_integer_class();
167 str_ = s.str();
168}

◆ bvisit() [23/54]

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

Definition at line 388 of file strprinter.cpp.

389{
390 str_ = "Integers";
391}

◆ bvisit() [24/54]

void SymEngine::StrPrinter::bvisit ( const Intersection x)

Definition at line 419 of file strprinter.cpp.

420{
422 vec_basic vec = x.get_args();
423 s << "Intersection";
424 s << parenthesize(apply(vec));
425 str_ = s.str();
426}

◆ bvisit() [25/54]

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

Definition at line 272 of file strprinter.cpp.

273{
275 if (x.get_left_open())
276 s << "(";
277 else
278 s << "[";
279 s << *x.get_start() << ", " << *x.get_end();
280 if (x.get_right_open())
281 s << ")";
282 else
283 s << "]";
284 str_ = s.str();
285}

◆ bvisit() [26/54]

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

Definition at line 258 of file strprinter.cpp.

259{
261 s << apply(x.get_arg1()) << " <= " << apply(x.get_arg2());
262 str_ = s.str();
263}

◆ bvisit() [27/54]

void SymEngine::StrPrinter::bvisit ( const MExprPoly x)

Definition at line 973 of file strprinter.cpp.

974{
976 bool first = true; // is this the first term being printed out?
977 // To change the ordering in which the terms will print out, change
978 // vec_uint_compare in dict.h
979 std::vector<vec_int> v = sorted_keys(x.get_poly().dict_);
980
981 for (vec_int exps : v) {
982 Expression c = x.get_poly().dict_.find(exps)->second;
983 std::string t = parenthesizeLT(c.get_basic(), PrecedenceEnum::Mul);
984 if ('-' == t[0] && !first) {
985 s << " - ";
986 t = t.substr(1);
987 } else if (!first) {
988 s << " + ";
989 }
990 unsigned int i = 0;
992 bool first_var = true;
993 for (auto it : x.get_vars()) {
994 if (exps[i] != 0) {
995 if (!first_var) {
996 expr << "*";
997 }
998 expr << it->__str__();
999 if (exps[i] > 1 or exps[i] < 0)
1000 expr << "**" << exps[i];
1001 first_var = false;
1002 }
1003 i++;
1004 }
1005 if (c != 1 && c != -1) {
1006 s << t;
1007 if (!expr.str().empty()) {
1008 s << "*";
1009 }
1010 } else if (expr.str().empty()) {
1011 s << "1";
1012 }
1013 s << expr.str();
1014 first = false;
1015 }
1016
1017 if (s.str().empty())
1018 s << "0";
1019 str_ = s.str();
1020}

◆ bvisit() [28/54]

void SymEngine::StrPrinter::bvisit ( const MIntPoly x)

Definition at line 925 of file strprinter.cpp.

926{
928 bool first = true; // is this the first term being printed out?
929 // To change the ordering in which the terms will print out, change
930 // vec_uint_compare in dict.h
931 std::vector<vec_uint> v = sorted_keys(x.get_poly().dict_);
932
933 for (vec_uint exps : v) {
934 integer_class c = x.get_poly().dict_.find(exps)->second;
935 if (!first) {
936 s << " " << _print_sign(c) << " ";
937 } else if (c < 0) {
938 s << "-";
939 }
940
941 unsigned int i = 0;
943 bool first_var = true;
944 for (auto it : x.get_vars()) {
945 if (exps[i] != 0) {
946 if (!first_var) {
947 expr << "*";
948 }
949 expr << it->__str__();
950 if (exps[i] > 1)
951 expr << "**" << exps[i];
952 first_var = false;
953 }
954 i++;
955 }
956 if (mp_abs(c) != 1) {
957 s << mp_abs(c);
958 if (!expr.str().empty()) {
959 s << "*";
960 }
961 } else if (expr.str().empty()) {
962 s << "1";
963 }
964 s << expr.str();
965 first = false;
966 }
967
968 if (s.str().empty())
969 s << "0";
970 str_ = s.str();
971}

◆ bvisit() [29/54]

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

Definition at line 567 of file strprinter.cpp.

568{
569 std::ostringstream o, o2;
570 bool num = false;
571 unsigned den = 0;
572
573 if (eq(*(x.get_coef()), *minus_one)) {
574 o << "-";
575 } else if (neq(*(x.get_coef()), *one)) {
576 if (not split_mul_coef()) {
577 o << parenthesizeLT(x.get_coef(), PrecedenceEnum::Mul)
578 << print_mul();
579 num = true;
580 } else {
581 RCP<const Basic> numer, denom;
582 as_numer_denom(x.get_coef(), outArg(numer), outArg(denom));
583 if (neq(*numer, *one)) {
584 num = true;
585 o << parenthesizeLT(numer, PrecedenceEnum::Mul) << print_mul();
586 }
587 if (neq(*denom, *one)) {
588 den++;
589 o2 << parenthesizeLT(denom, PrecedenceEnum::Mul) << print_mul();
590 }
591 }
592 }
593
594 for (const auto &p : x.get_dict()) {
595 if ((is_a<Integer>(*p.second) or is_a<Rational>(*p.second))
596 and down_cast<const Number &>(*p.second).is_negative()
597 and neq(*(p.first), *E)) {
598 if (eq(*(p.second), *minus_one)) {
599 o2 << parenthesizeLT(p.first, PrecedenceEnum::Mul);
600 } else {
601 _print_pow(o2, p.first, neg(p.second));
602 }
603 o2 << print_mul();
604 den++;
605 } else {
606 if (eq(*(p.second), *one)) {
607 o << parenthesizeLT(p.first, PrecedenceEnum::Mul);
608 } else {
609 _print_pow(o, p.first, p.second);
610 }
611 o << print_mul();
612 num = true;
613 }
614 }
615
616 if (not num) {
617 o << "1" << print_mul();
618 }
619
620 std::string s = o.str();
621 s = s.substr(0, s.size() - 1);
622
623 if (den != 0) {
624 std::string s2 = o2.str();
625 s2 = s2.substr(0, s2.size() - 1);
626 if (den > 1) {
627 str_ = print_div(s, s2, true);
628 } else {
629 str_ = print_div(s, s2, false);
630 }
631 } else {
632 str_ = s;
633 }
634}
RCP< const Basic > neg(const RCP< const Basic > &a)
Negation.
Definition: mul.cpp:443
T size(T... args)

◆ bvisit() [30/54]

void SymEngine::StrPrinter::bvisit ( const NaN x)

Definition at line 158 of file strprinter.cpp.

159{
160 str_ = "nan";
161}

◆ bvisit() [31/54]

void SymEngine::StrPrinter::bvisit ( const Naturals x)

Definition at line 393 of file strprinter.cpp.

394{
395 str_ = "Naturals";
396}

◆ bvisit() [32/54]

void SymEngine::StrPrinter::bvisit ( const Naturals0 x)

Definition at line 398 of file strprinter.cpp.

399{
400 str_ = "Naturals0";
401}

◆ bvisit() [33/54]

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

Definition at line 335 of file strprinter.cpp.

336{
338 s << "Not(" << *x.get_arg() << ")";
339 str_ = s.str();
340}

◆ bvisit() [34/54]

void SymEngine::StrPrinter::bvisit ( const NumberWrapper x)

Definition at line 920 of file strprinter.cpp.

921{
922 str_ = x.__str__();
923}

◆ bvisit() [35/54]

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

Definition at line 309 of file strprinter.cpp.

310{
312 auto container = x.get_container();
313 s << "Or(";
314 s << apply(*container.begin());
315 for (auto it = ++(container.begin()); it != container.end(); ++it) {
316 s << ", " << apply(*it);
317 }
318 s << ")";
319 str_ = s.str();
320}

◆ bvisit() [36/54]

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

Definition at line 350 of file strprinter.cpp.

351{
353 auto vec = x.get_vec();
354 auto it = vec.begin();
355 s << "Piecewise(";
356 while (true) {
357 s << "(";
358 s << apply((*it).first);
359 s << ", ";
360 s << apply((*it).second);
361 s << ")";
362 ++it;
363 if (it != vec.end()) {
364 s << ", ";
365 } else {
366 break;
367 }
368 }
369 s << ")";
370 str_ = s.str();
371}

◆ bvisit() [37/54]

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

Definition at line 651 of file strprinter.cpp.

652{
654 _print_pow(o, x.get_base(), x.get_exp());
655 str_ = o.str();
656}

◆ bvisit() [38/54]

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

Definition at line 170 of file strprinter.cpp.

171{
173 s << x.as_rational_class();
174 str_ = s.str();
175}

◆ bvisit() [39/54]

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

Definition at line 383 of file strprinter.cpp.

384{
385 str_ = "Rationals";
386}

◆ bvisit() [40/54]

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

Definition at line 227 of file strprinter.cpp.

228{
229 str_ = print_double(x.i);
230}

◆ bvisit() [41/54]

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

Definition at line 378 of file strprinter.cpp.

379{
380 str_ = "Reals";
381}

◆ bvisit() [42/54]

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

Definition at line 265 of file strprinter.cpp.

266{
268 s << apply(x.get_arg1()) << " < " << apply(x.get_arg2());
269 str_ = s.str();
270}

◆ bvisit() [43/54]

void SymEngine::StrPrinter::bvisit ( const Subs x)

Definition at line 904 of file strprinter.cpp.

905{
906 std::ostringstream o, vars, point;
907 for (auto p = x.get_dict().begin(); p != x.get_dict().end(); p++) {
908 if (p != x.get_dict().begin()) {
909 vars << ", ";
910 point << ", ";
911 }
912 vars << apply(p->first);
913 point << apply(p->second);
914 }
915 o << "Subs(" << apply(x.get_arg()) << ", (" << vars.str() << "), ("
916 << point.str() << "))";
917 str_ = o.str();
918}

◆ bvisit() [44/54]

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

Definition at line 141 of file strprinter.cpp.

142{
143 str_ = x.get_name();
144}

◆ bvisit() [45/54]

void SymEngine::StrPrinter::bvisit ( const Tuple x)

Definition at line 1022 of file strprinter.cpp.

1023{
1025 vec_basic vec = x.get_args();
1026 o << parenthesize(apply(vec));
1027 str_ = o.str();
1028}

◆ bvisit() [46/54]

void SymEngine::StrPrinter::bvisit ( const UExprPoly x)

Definition at line 821 of file strprinter.cpp.

822{
824 if (x.get_dict().size() == 0)
825 s << "0";
826 else
827 s << x.get_poly().__str__(detail::poly_print(x.get_var()));
828 str_ = s.str();
829}

◆ bvisit() [47/54]

void SymEngine::StrPrinter::bvisit ( const UIntPoly x)

Definition at line 787 of file strprinter.cpp.

788{
789 str_ = upoly_print<UIntPoly>(x);
790}

◆ bvisit() [48/54]

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

Definition at line 251 of file strprinter.cpp.

252{
254 s << apply(x.get_arg1()) << " != " << apply(x.get_arg2());
255 str_ = s.str();
256}

◆ bvisit() [49/54]

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

Definition at line 408 of file strprinter.cpp.

409{
411 s << apply(*x.get_container().begin());
412 for (auto it = ++(x.get_container().begin()); it != x.get_container().end();
413 ++it) {
414 s << " U " << apply(*it);
415 }
416 str_ = s.str();
417}

◆ bvisit() [50/54]

void SymEngine::StrPrinter::bvisit ( const UnivariateSeries x)

Definition at line 831 of file strprinter.cpp.

832{
834 o << x.get_poly().__str__(x.get_var()) << " + O(" << x.get_var() << "**"
835 << x.get_degree() << ")";
836 str_ = o.str();
837}

◆ bvisit() [51/54]

void SymEngine::StrPrinter::bvisit ( const UniversalSet x)

Definition at line 445 of file strprinter.cpp.

446{
447 str_ = "UniversalSet";
448}

◆ bvisit() [52/54]

void SymEngine::StrPrinter::bvisit ( const URatPoly x)

Definition at line 792 of file strprinter.cpp.

793{
794 str_ = upoly_print<URatPoly>(x);
795}

◆ bvisit() [53/54]

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

Definition at line 322 of file strprinter.cpp.

323{
325 auto container = x.get_container();
326 s << "Xor(";
327 s << apply(*container.begin());
328 for (auto it = ++(container.begin()); it != container.end(); ++it) {
329 s << ", " << apply(*it);
330 }
331 s << ")";
332 str_ = s.str();
333}

◆ bvisit() [54/54]

void SymEngine::StrPrinter::bvisit ( const ZeroMatrix x)

Definition at line 1035 of file strprinter.cpp.

1036{
1037 str_ = "0";
1038}

◆ get_imag_symbol()

std::string SymEngine::StrPrinter::get_imag_symbol ( )
protectedvirtual

Definition at line 1189 of file strprinter.cpp.

1190{
1191 return "I";
1192}

◆ parenthesize()

std::string SymEngine::StrPrinter::parenthesize ( const std::string expr)
protectedvirtual

Definition at line 1062 of file strprinter.cpp.

1063{
1064 return "(" + x + ")";
1065}

◆ parenthesizeLE()

std::string SymEngine::StrPrinter::parenthesizeLE ( const RCP< const Basic > &  x,
PrecedenceEnum  precedenceEnum 
)
protected

Definition at line 1051 of file strprinter.cpp.

1053{
1054 Precedence prec;
1055 if (prec.getPrecedence(x) <= precedenceEnum) {
1056 return parenthesize(apply(x));
1057 } else {
1058 return apply(x);
1059 }
1060}

◆ parenthesizeLT()

std::string SymEngine::StrPrinter::parenthesizeLT ( const RCP< const Basic > &  x,
PrecedenceEnum  precedenceEnum 
)
protected

Definition at line 1040 of file strprinter.cpp.

1042{
1043 Precedence prec;
1044 if (prec.getPrecedence(x) < precedenceEnum) {
1045 return parenthesize(apply(x));
1046 } else {
1047 return apply(x);
1048 }
1049}

◆ print_div()

std::string SymEngine::StrPrinter::print_div ( const std::string num,
const std::string den,
bool  paren 
)
protectedvirtual

Definition at line 636 of file strprinter.cpp.

638{
639 if (paren) {
640 return num + "/" + parenthesize(den);
641 } else {
642 return num + "/" + den;
643 }
644}

◆ print_mul()

std::string SymEngine::StrPrinter::print_mul ( )
protectedvirtual

Definition at line 1137 of file strprinter.cpp.

1138{
1139 return "*";
1140}

◆ split_mul_coef()

bool SymEngine::StrPrinter::split_mul_coef ( )
protectedvirtual

Definition at line 646 of file strprinter.cpp.

647{
648 return false;
649}

Field Documentation

◆ names_

const std::vector<std::string> SymEngine::StrPrinter::names_
staticprivate

Definition at line 109 of file strprinter.h.

◆ str_

std::string SymEngine::StrPrinter::str_
protected

Definition at line 112 of file strprinter.h.


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