]> www.ginac.de Git - ginac.git/blobdiff - ginac/symbol.cpp
* Bump up version, fix typos.
[ginac.git] / ginac / symbol.cpp
index b15f9b784e47f18960a34687b56fb61fd25c7146..5d2ac8ced8459b84a1df3f3c1a0d43e7a8ca363b 100644 (file)
@@ -27,7 +27,7 @@
 #include "lst.h"
 #include "print.h"
 #include "archive.h"
-#include "debugmsg.h"
+#include "tostring.h"
 #include "utils.h"
 
 namespace GiNaC {
@@ -35,12 +35,11 @@ namespace GiNaC {
 GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(symbol, basic)
 
 //////////
-// default ctor, dtor, copy ctor assignment operator and helpers
+// default ctor, dtor, copy ctor, assignment operator and helpers
 //////////
 
 symbol::symbol() : inherited(TINFO_symbol), serial(next_serial++)
 {
-       debugmsg("symbol default ctor", LOGLEVEL_CONSTRUCT);
        name = TeX_name = autoname_prefix()+ToString(serial);
        asexinfop = new assigned_ex_info;
        setflag(status_flags::evaluated | status_flags::expanded);
@@ -73,13 +72,11 @@ void symbol::destroy(bool call_parent)
 
 symbol::symbol(const symbol & other)
 {
-       debugmsg("symbol copy ctor", LOGLEVEL_CONSTRUCT);
        copy(other);
 }
 
 symbol::symbol(const std::string & initname) : inherited(TINFO_symbol)
 {
-       debugmsg("symbol ctor from string", LOGLEVEL_CONSTRUCT);
        name = initname;
        TeX_name = default_TeX_name();
        serial = next_serial++;
@@ -89,7 +86,6 @@ symbol::symbol(const std::string & initname) : inherited(TINFO_symbol)
 
 symbol::symbol(const std::string & initname, const std::string & texname) : inherited(TINFO_symbol)
 {
-       debugmsg("symbol ctor from string", LOGLEVEL_CONSTRUCT);
        name = initname;
        TeX_name = texname;
        serial = next_serial++;
@@ -104,7 +100,6 @@ symbol::symbol(const std::string & initname, const std::string & texname) : inhe
 /** Construct object from archive_node. */
 symbol::symbol(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
-       debugmsg("symbol ctor from archive_node", LOGLEVEL_CONSTRUCT);
        serial = next_serial++;
        if (!(n.find_string("name", name)))
                name = autoname_prefix() + ToString(serial);
@@ -137,29 +132,26 @@ void symbol::archive(archive_node &n) const
 }
 
 //////////
-// functions overriding virtual functions from bases classes
+// functions overriding virtual functions from base classes
 //////////
 
 // public
 
 basic *symbol::duplicate() const
 {
-       debugmsg("symbol duplicate", LOGLEVEL_DUPLICATE);
        return new symbol(*this);
 }
 
 void symbol::print(const print_context & c, unsigned level) const
 {
-       debugmsg("symbol print", LOGLEVEL_PRINT);
-
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
 
                c.s << std::string(level, ' ') << name << " (" << class_name() << ")"
                    << ", serial=" << serial
                    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
                    << std::endl;
 
-       } else if (is_of_type(c, print_latex))
+       } else if (is_a<print_latex>(c))
                c.s << TeX_name;
        else
                c.s << name;
@@ -179,30 +171,22 @@ bool symbol::info(unsigned inf) const
                return inherited::info(inf);
 }
 
-bool symbol::has(const ex & other) const
-{
-       if (this->is_equal(*other.bp))
-               return true;
-       else
-               return false;
-}
-
 int symbol::degree(const ex & s) const
 {
-       return is_equal(*s.bp) ? 1 : 0;
+       return is_equal(ex_to<basic>(s)) ? 1 : 0;
 }
 
 int symbol::ldegree(const ex & s) const
 {
-       return is_equal(*s.bp) ? 1 : 0;
+       return is_equal(ex_to<basic>(s)) ? 1 : 0;
 }
 
 ex symbol::coeff(const ex & s, int n) const
 {
-       if (is_equal(*s.bp))
-               return n==1 ? _ex1() : _ex0();
+       if (is_equal(ex_to<basic>(s)))
+               return n==1 ? _ex1 : _ex0;
        else
-               return n==0 ? *this : _ex0();
+               return n==0 ? *this : _ex0;
 }
 
 ex symbol::eval(int level) const
@@ -230,14 +214,14 @@ ex symbol::eval(int level) const
 ex symbol::derivative(const symbol & s) const
 {
        if (compare_same_type(s))
-               return _ex0();
+               return _ex0;
        else
-               return _ex1();
+               return _ex1;
 }
 
 int symbol::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other,symbol));
+       GINAC_ASSERT(is_a<symbol>(other));
        const symbol *o = static_cast<const symbol *>(&other);
        if (serial==o->serial) return 0;
        return serial < o->serial ? -1 : 1;
@@ -245,21 +229,11 @@ int symbol::compare_same_type(const basic & other) const
 
 bool symbol::is_equal_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other,symbol));
+       GINAC_ASSERT(is_a<symbol>(other));
        const symbol *o = static_cast<const symbol *>(&other);
        return serial==o->serial;
 }
 
-unsigned symbol::return_type(void) const
-{
-       return return_types::commutative;
-}
-   
-unsigned symbol::return_type_tinfo(void) const
-{
-       return tinfo_key;
-}
-
 unsigned symbol::calchash(void) const
 {
        // this is where the schoolbook method
@@ -293,7 +267,7 @@ void symbol::unassign(void)
 {
        if (asexinfop->is_assigned) {
                asexinfop->is_assigned = 0;
-               asexinfop->assigned_expression = _ex0();
+               asexinfop->assigned_expression = _ex0;
        }
        setflag(status_flags::evaluated | status_flags::expanded);
 }