X-Git-Url: https://ginac.de/ginac.git//ginac.git?a=blobdiff_plain;f=ginac%2Fsymbol.cpp;h=e093e6c74a07a989a747dd6285952073848916eb;hb=85ce9664ddba79c28a6945b1e5b4e2b71f77cb51;hp=4328d19bfd59634b34e079c805dff796c2e4ab02;hpb=094911eb78cacb6f2877a70c9ac74766df58ccea;p=ginac.git diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 4328d19b..e093e6c7 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -25,6 +25,7 @@ #include "symbol.h" #include "lst.h" +#include "print.h" #include "archive.h" #include "debugmsg.h" #include "utils.h" @@ -131,33 +132,19 @@ basic *symbol::duplicate() const return new symbol(*this); } -void symbol::print(std::ostream & os, unsigned upper_precedence) const +void symbol::print(const print_context & c, unsigned level) const { - debugmsg("symbol print",LOGLEVEL_PRINT); - os << name; -} + debugmsg("symbol print", LOGLEVEL_PRINT); -void symbol::printraw(std::ostream & os) const -{ - debugmsg("symbol printraw",LOGLEVEL_PRINT); - os << class_name() << "(" << "name=" << name << ",serial=" << serial - << ",hash=" << hashvalue << ",flags=" << flags << ")"; -} + if (is_of_type(c, print_tree)) { -void symbol::printtree(std::ostream & os, unsigned indent) const -{ - debugmsg("symbol printtree",LOGLEVEL_PRINT); - os << std::string(indent,' ') << name << " (symbol): " - << "serial=" << serial - << ", hash=" << hashvalue - << " (0x" << std::hex << hashvalue << std::dec << ")" - << ", flags=" << flags << std::endl; -} + c.s << std::string(level, ' ') << name << " (" << class_name() << ")" + << ", serial=" << serial + << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec + << std::endl; -void symbol::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const -{ - debugmsg("symbol print csrc", LOGLEVEL_PRINT); - os << name; + } else + c.s << name; } bool symbol::info(unsigned inf) const @@ -187,19 +174,19 @@ bool symbol::has(const ex & other) const return false; } -int symbol::degree(const symbol & s) const +int symbol::degree(const ex & s) const { - return compare_same_type(s)==0 ? 1 : 0; + return is_equal(*s.bp) ? 1 : 0; } -int symbol::ldegree(const symbol & s) const +int symbol::ldegree(const ex & s) const { - return compare_same_type(s)==0 ? 1 : 0; + return is_equal(*s.bp) ? 1 : 0; } -ex symbol::coeff(const symbol & s, int n) const +ex symbol::coeff(const ex & s, int n) const { - if (compare_same_type(s)==0) + if (is_equal(*s.bp)) return n==1 ? _ex1() : _ex0(); else return n==0 ? *this : _ex0(); @@ -221,19 +208,6 @@ ex symbol::eval(int level) const } } -ex symbol::subs(const lst & ls, const lst & lr) const -{ - GINAC_ASSERT(ls.nops()==lr.nops()); - - for (unsigned i=0; i