GINAC_DECLARE_REGISTERED_CLASS declares duplicate() and compare_same_type(),
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Fri, 16 Feb 2001 20:25:47 +0000 (20:25 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Fri, 16 Feb 2001 20:25:47 +0000 (20:25 +0000)
GINAC_IMPLEMENT_REGISTERED_CLASS implements duplicate()

43 files changed:
ginac/add.cpp
ginac/add.h
ginac/clifford.cpp
ginac/clifford.h
ginac/color.cpp
ginac/color.h
ginac/coloridx.cpp
ginac/coloridx.h
ginac/constant.cpp
ginac/constant.h
ginac/container.pl
ginac/fail.cpp
ginac/fail.h
ginac/function.pl
ginac/idx.cpp
ginac/idx.h
ginac/indexed.cpp
ginac/indexed.h
ginac/isospin.cpp
ginac/isospin.h
ginac/lorentzidx.cpp
ginac/lorentzidx.h
ginac/lortensor.cpp
ginac/lortensor.h
ginac/matrix.cpp
ginac/matrix.h
ginac/mul.cpp
ginac/mul.h
ginac/ncmul.cpp
ginac/ncmul.h
ginac/numeric.cpp
ginac/numeric.h
ginac/power.cpp
ginac/power.h
ginac/pseries.cpp
ginac/pseries.h
ginac/registrar.h
ginac/relational.cpp
ginac/relational.h
ginac/simp_lor.cpp
ginac/simp_lor.h
ginac/structure.cpp
ginac/structure.h

index 574a8e8..9cc2cc0 100644 (file)
@@ -157,12 +157,6 @@ void add::archive(archive_node &n) const
 
 // public
 
-basic * add::duplicate() const
-{
-       debugmsg("add duplicate",LOGLEVEL_DUPLICATE);
-       return new add(*this);
-}
-
 void add::print(std::ostream & os, unsigned upper_precedence) const
 {
        debugmsg("add print",LOGLEVEL_PRINT);
index 924eb40..0c8e37c 100644 (file)
@@ -49,7 +49,6 @@ public:
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printraw(std::ostream & os) const;
        void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const;
@@ -67,7 +66,6 @@ public:
        ex simplify_ncmul(const exvector & v) const;
 protected:
        ex derivative(const symbol & s) const;
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
index c3c0d9f..0dc0518 100644 (file)
@@ -114,12 +114,6 @@ void clifford::archive(archive_node &n) const
 
 // public
 
-basic * clifford::duplicate() const
-{
-       debugmsg("clifford duplicate",LOGLEVEL_DUPLICATE);
-       return new clifford(*this);
-}
-
 void clifford::printraw(std::ostream & os) const
 {
        debugmsg("clifford printraw",LOGLEVEL_PRINT);
index 2d02ebc..aed2b16 100644 (file)
@@ -50,14 +50,12 @@ public:
 
        // functions overriding virtual functions from base classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        bool info(unsigned inf) const;
        // ex eval(int level=0) const;
 protected:
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        ex simplify_ncmul(const exvector & v) const;
        ex thisexprseq(const exvector & v) const;
index 4b59877..f2360c3 100644 (file)
@@ -181,12 +181,6 @@ void color::archive(archive_node &n) const
 
 // public
 
-basic * color::duplicate() const
-{
-       debugmsg("color duplicate",LOGLEVEL_DUPLICATE);
-       return new color(*this);
-}
-
 void color::printraw(std::ostream & os) const
 {
        debugmsg("color printraw",LOGLEVEL_PRINT);
index 2d44aa8..6f126a3 100644 (file)
@@ -106,14 +106,12 @@ protected:
        
        // functions overriding virtual functions from base classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        bool info(unsigned inf) const;
        ex eval(int level=0) const;
 protected:
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        ex simplify_ncmul(const exvector & v) const;
        ex thisexprseq(const exvector & v) const;
index 221e86b..d034ba4 100644 (file)
@@ -138,12 +138,6 @@ void coloridx::archive(archive_node &n) const
 
 // public
 
-basic * coloridx::duplicate() const
-{
-       debugmsg("coloridx duplicate",LOGLEVEL_DUPLICATE);
-       return new coloridx(*this);
-}
-
 void coloridx::printraw(std::ostream & os) const
 {
        debugmsg("coloridx printraw",LOGLEVEL_PRINT);
@@ -213,6 +207,11 @@ bool coloridx::info(unsigned inf) const
        return idx::info(inf);
 }
 
+int coloridx::compare_same_type(const basic & other) const
+{
+       return inherited::compare_same_type(other);
+}
+
 #ifndef NO_NAMESPACE_GINAC
 } // namespace GiNaC
 #endif // ndef NO_NAMESPACE_GINAC
index 780aac4..a727b91 100644 (file)
@@ -54,7 +54,6 @@ public:
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
index ae71579..bc1179c 100644 (file)
@@ -129,12 +129,6 @@ void constant::archive(archive_node &n) const
 
 // public
 
-basic * constant::duplicate() const
-{
-       debugmsg("constant duplicate",LOGLEVEL_DUPLICATE);
-       return new constant(*this);
-}
-
 void constant::print(std::ostream & os, unsigned upper_precedence) const
 {
        debugmsg("constant print",LOGLEVEL_PRINT);
index 0c9394f..cf31814 100644 (file)
@@ -49,7 +49,6 @@ public:
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
@@ -57,7 +56,6 @@ public:
        ex evalf(int level=0) const;
 protected:
        ex derivative(const symbol & s) const;
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        
        // new virtual functions which can be overridden by derived classes
index 232d299..d2c5bb4 100755 (executable)
@@ -206,7 +206,6 @@ public:
 ${constructors_interface}
 
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printtree(std::ostream & os, unsigned indent) const;
@@ -221,7 +220,6 @@ public:
        ex derivative(const symbol & s) const;
        ex subs(const lst & ls, const lst & lr) const;
 protected:
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned return_type(void) const;
 
@@ -414,12 +412,6 @@ void ${CONTAINER}::archive(archive_node &n) const
 
 // public
 
-basic * ${CONTAINER}::duplicate() const
-{
-       debugmsg("${CONTAINER} duplicate",LOGLEVEL_DUPLICATE);
-       return new ${CONTAINER}(*this);
-}
-
 void ${CONTAINER}::printraw(std::ostream & os) const
 {
        debugmsg("${CONTAINER} printraw",LOGLEVEL_PRINT);
index c111804..0bbe01c 100644 (file)
@@ -82,12 +82,6 @@ void fail::archive(archive_node &n) const
 
 // public
 
-basic * fail::duplicate() const
-{
-       debugmsg("fail duplicate",LOGLEVEL_DUPLICATE);
-       return new fail(*this);
-}
-
 void fail::print(std::ostream & os, unsigned upper_precedence) const
 {
        debugmsg("fail print",LOGLEVEL_PRINT);
index 248c593..c2942cc 100644 (file)
@@ -39,11 +39,9 @@ class fail : public basic
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printraw(std::ostream & os) const;
 protected:
-       int compare_same_type(const basic & other) const;
        unsigned return_type(void) const { return return_types::noncommutative_composite; };
        
        // new virtual functions which can be overridden by derived classes
index 8a96a32..de453fe 100755 (executable)
@@ -398,7 +398,6 @@ $constructors_interface
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const; 
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printtree(std::ostream & os, unsigned indent) const;
@@ -411,7 +410,6 @@ public:
        ex thisexprseq(exvector * vp) const;
 protected:
        ex derivative(const symbol & s) const;
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
@@ -715,12 +713,6 @@ void function::archive(archive_node &n) const
 
 // public
 
-basic * function::duplicate() const
-{
-       debugmsg("function duplicate",LOGLEVEL_DUPLICATE);
-       return new function(*this);
-}
-
 void function::printraw(std::ostream & os) const
 {
        debugmsg("function printraw",LOGLEVEL_PRINT);
index af463a8..480da0f 100644 (file)
@@ -170,12 +170,6 @@ void idx::archive(archive_node &n) const
 
 // public
 
-basic * idx::duplicate() const
-{
-       debugmsg("idx duplicate",LOGLEVEL_DUPLICATE);
-       return new idx(*this);
-}
-
 void idx::printraw(std::ostream & os) const
 {
        debugmsg("idx printraw",LOGLEVEL_PRINT);
@@ -268,7 +262,7 @@ ex idx::subs(const lst & ls, const lst & lr) const
 int idx::compare_same_type(const basic & other) const
 {
        GINAC_ASSERT(is_of_type(other,idx));
-       const idx &o = static_cast<const idx &>(&other);
+       const idx &o = static_cast<const idx &>(other);
 
        if (covariant!=o.covariant) {
                // different co/contravariant
index 981fee6..3c8ec34 100644 (file)
@@ -49,13 +49,11 @@ public:
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        bool info(unsigned inf) const;
 protected:
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned calchash(void) const;
        ex subs(const lst & ls, const lst & lr) const;
index 7127e9a..be4a7cb 100644 (file)
@@ -169,12 +169,6 @@ void indexed::archive(archive_node &n) const
 
 // public
 
-basic * indexed::duplicate() const
-{
-       debugmsg("indexed duplicate",LOGLEVEL_DUPLICATE);
-       return new indexed(*this);
-}
-
 void indexed::printraw(std::ostream & os) const
 {
        debugmsg("indexed printraw",LOGLEVEL_PRINT);
index b1d8844..cc604f1 100644 (file)
@@ -47,7 +47,6 @@ public:
 
        // functions overriding virtual functions from base classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
@@ -59,7 +58,6 @@ public:
 
 protected:
        ex derivative(const symbol & s) const;
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
index a74e05f..1be79d5 100644 (file)
@@ -121,12 +121,6 @@ void isospin::archive(archive_node &n) const
 
 // public
 
-basic * isospin::duplicate() const
-{
-       debugmsg("isospin duplicate",LOGLEVEL_DUPLICATE);
-       return new isospin(*this);
-}
-
 void isospin::printraw(std::ostream & os) const
 {
        debugmsg("isospin printraw",LOGLEVEL_PRINT);
index 3facb90..d9d93a8 100644 (file)
@@ -41,14 +41,12 @@ public:
 
        // functions overriding virtual functions from base classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const;
        bool info(unsigned inf) const;
 protected:
-       int compare_same_type(const basic & other) const;
        ex simplify_ncmul(const exvector & v) const;
        unsigned calchash(void) const;
 
index 6a367be..ca88d94 100644 (file)
@@ -171,12 +171,6 @@ void lorentzidx::archive(archive_node &n) const
 
 // public
 
-basic * lorentzidx::duplicate() const
-{
-       debugmsg("lorentzidx duplicate",LOGLEVEL_DUPLICATE);
-       return new lorentzidx(*this);
-}
-
 void lorentzidx::printraw(std::ostream & os) const
 {
        debugmsg("lorentzidx printraw",LOGLEVEL_PRINT);
@@ -260,6 +254,18 @@ bool lorentzidx::info(unsigned inf) const
        return inherited::info(inf);
 }
 
+int lorentzidx::compare_same_type(const basic & other) const
+{
+       GINAC_ASSERT(is_of_type(other, lorentzidx));
+       const lorentzidx &o = static_cast<const lorentzidx &>(other);
+
+       if (orthogonal_only != o.orthogonal_only)
+               return orthogonal_only ? -1 : 1;
+       if (dim_parallel_space != o.dim_parallel_space)
+               return dim_parallel_space < o.dim_parallel_space ? -1 : 1;
+       return inherited::compare_same_type(other);
+}
+
 //////////
 // non-virtual functions in this class
 //////////
index 099f36b..20be2b5 100644 (file)
@@ -59,7 +59,6 @@ public:
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
index 7a97887..6c326e2 100644 (file)
@@ -238,12 +238,6 @@ void lortensor::archive(archive_node &n) const
 
 //public
 
-basic * lortensor::duplicate() const
-{
-       debugmsg("lortensor duplicate",LOGLEVEL_DUPLICATE);
-       return new lortensor(*this);
-}
-
 void lortensor::printraw(std::ostream & os) const
 {
        debugmsg("lortensor printraw",LOGLEVEL_PRINT);
index d25211f..8da739d 100644 (file)
@@ -80,14 +80,12 @@ protected:
 
        //functions overriding virtual functions from base classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        bool info(unsigned inf) const;
        ex eval(int level=0) const;
 protected:
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
index 0b87ed5..81d31bd 100644 (file)
@@ -140,12 +140,6 @@ void matrix::archive(archive_node &n) const
 
 // public
 
-basic * matrix::duplicate() const
-{
-       debugmsg("matrix duplicate",LOGLEVEL_DUPLICATE);
-       return new matrix(*this);
-}
-
 void matrix::print(std::ostream & os, unsigned upper_precedence) const
 {
        debugmsg("matrix print",LOGLEVEL_PRINT);
index 7c2b9c0..c04a592 100644 (file)
@@ -43,7 +43,6 @@ public:
    
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printraw(std::ostream & os) const;
        unsigned nops() const;
@@ -55,7 +54,6 @@ public:
        ex evalf(int level=0) const;
        // ex subs(const lst & ls, const lst & lr) const;
 protected:
-       int compare_same_type(const basic & other) const;
        unsigned return_type(void) const { return return_types::noncommutative; };
        // new virtual functions which can be overridden by derived classes
        // (none)
index 80901d7..02029c5 100644 (file)
@@ -155,12 +155,6 @@ void mul::archive(archive_node &n) const
 
 // public
 
-basic * mul::duplicate() const
-{
-       debugmsg("mul duplicate",LOGLEVEL_ASSIGNMENT);
-       return new mul(*this);
-}
-
 void mul::print(std::ostream & os, unsigned upper_precedence) const
 {
        debugmsg("mul print",LOGLEVEL_PRINT);
index c6d607d..cad3b9b 100644 (file)
@@ -49,7 +49,6 @@ public:
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned upper_precedence) const;
        void printraw(std::ostream & os) const;
        void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const;
@@ -68,7 +67,6 @@ public:
        ex simplify_ncmul(const exvector & v) const;
 protected:
        ex derivative(const symbol & s) const;
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
index 86b76e7..8650111 100644 (file)
@@ -142,12 +142,6 @@ void ncmul::archive(archive_node &n) const
 
 // public
 
-basic * ncmul::duplicate() const
-{
-       debugmsg("ncmul duplicate",LOGLEVEL_ASSIGNMENT);
-       return new ncmul(*this);
-}
-
 void ncmul::print(std::ostream & os, unsigned upper_precedence) const
 {
        debugmsg("ncmul print",LOGLEVEL_PRINT);
index a4a77eb..5373a75 100644 (file)
@@ -55,7 +55,6 @@ public:
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned upper_precedence) const;
        void printraw(std::ostream & os) const;
        void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence = 0) const;
@@ -71,7 +70,6 @@ public:
        ex thisexprseq(exvector * vp) const;
 protected:
        ex derivative(const symbol & s) const;
-       int compare_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
        
index 3398f60..358ad45 100644 (file)
@@ -381,15 +381,6 @@ void numeric::archive(archive_node &n) const
 // functions overriding virtual functions from bases classes
 //////////
 
-// public
-
-basic * numeric::duplicate() const
-{
-       debugmsg("numeric duplicate", LOGLEVEL_DUPLICATE);
-       return new numeric(*this);
-}
-
-
 /** Helper function to print a real number in a nicer way than is CLN's
  *  default.  Instead of printing 42.0L0 this just prints 42.0 to ostream os
  *  and instead of 3.99168L7 it prints 3.99168E7.  This is fine in GiNaC as
index 1eda94d..3a972bc 100644 (file)
@@ -87,7 +87,6 @@ public:
        
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned precedence=0) const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
@@ -103,7 +102,6 @@ public:
        numeric max_coefficient(void) const;
 protected:
        ex derivative(const symbol & s) const;
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned calchash(void) const;
 
index 3069733..7324ca9 100644 (file)
@@ -119,12 +119,6 @@ void power::archive(archive_node &n) const
 
 // public
 
-basic * power::duplicate() const
-{
-       debugmsg("power duplicate",LOGLEVEL_DUPLICATE);
-       return new power(*this);
-}
-
 void power::print(std::ostream & os, unsigned upper_precedence) const
 {
        debugmsg("power print",LOGLEVEL_PRINT);
index 65c86b7..24e46f8 100644 (file)
@@ -50,7 +50,6 @@ public:
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned upper_precedence = 0) const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
@@ -70,7 +69,6 @@ public:
        ex simplify_ncmul(const exvector & v) const;
 protected:
        ex derivative(const symbol & s) const;
-       int compare_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
        ex expand(unsigned options = 0) const;
index d447aaa..2d873a2 100644 (file)
@@ -132,12 +132,6 @@ void pseries::archive(archive_node &n) const
 // functions overriding virtual functions from bases classes
 //////////
 
-basic *pseries::duplicate() const
-{
-       debugmsg("pseries duplicate", LOGLEVEL_DUPLICATE);
-       return new pseries(*this);
-}
-
 void pseries::print(std::ostream &os, unsigned upper_precedence) const
 {
        debugmsg("pseries print", LOGLEVEL_PRINT);
@@ -207,6 +201,31 @@ void pseries::printtree(std::ostream & os, unsigned indent) const
        point.printtree(os, indent+delta_indent);
 }
 
+int pseries::compare_same_type(const basic & other) const
+{
+       GINAC_ASSERT(is_of_type(other, pseries));
+       const pseries &o = static_cast<const pseries &>(other);
+
+       int cmpval = var.compare(o.var);
+       if (cmpval)
+               return cmpval;
+       cmpval = point.compare(o.point);
+       if (cmpval)
+               return cmpval;
+
+       epvector::const_iterator it1 = seq.begin(), it2 = o.seq.begin(), it1end = seq.end(), it2end = o.seq.end();
+       while ((it1 != it1end) && (it2 != it2end)) {
+               cmpval = it1->compare(*it2);
+               if (cmpval)
+                       return cmpval;
+               it1++; it2++;
+       }
+       if (it1 == it1end)
+               return it2 == it2end ? 0 : -1;
+
+       return 0;
+}
+
 /** Return the number of operands including a possible order term. */
 unsigned pseries::nops(void) const
 {
index 14b011a..95d85b2 100644 (file)
@@ -44,7 +44,6 @@ public:
 
        // functions overriding virtual functions from base classes
 public:
-       basic *duplicate() const;
        void print(std::ostream &os, unsigned upper_precedence = 0) const;
        void printraw(std::ostream &os) const;
        void printtree(std::ostream & os, unsigned indent) const;
@@ -85,6 +84,7 @@ protected:
 
        /** Expansion point */
        ex point;
+
        static unsigned precedence;
 };
 
index f665ccd..2737325 100644 (file)
@@ -70,7 +70,10 @@ public: \
        virtual void archive(archive_node &n) const; \
        static ex unarchive(const archive_node &n, const lst &sym_lst);
 
-/** Macro for inclusion in the declaration of each registered class. */
+/** Macro for inclusion in the declaration of each registered class.
+ *  It declares some functions that are common to all classes derived
+ *  from 'basic' as well as all required stuff for the GiNaC class
+ *  registry (mainly needed for archiving). */
 #define GINAC_DECLARE_REGISTERED_CLASS(classname, supername) \
        GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(classname, supername) \
 public: \
@@ -78,16 +81,21 @@ public: \
        ~classname(); \
        classname(const classname & other); \
        const classname & operator=(const classname & other); \
+       basic * duplicate() const; \
 protected: \
        void copy(const classname & other); \
        void destroy(bool call_parent); \
+       int compare_same_type(const basic & other) const; \
 private:
 
 #define GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(classname, supername) \
        registered_class_info classname::reg_info(#classname, #supername, TINFO_##classname, &classname::unarchive); \
        const char *classname::class_name(void) const {return reg_info.name;}
 
-/** Macro for inclusion in the implementation of each registered class. */
+/** Macro for inclusion in the implementation of each registered class.
+ *  It implements some functions that are the same in all classes derived
+ *  from 'basic' (such as the destructor, the copy constructor and the
+ *  assignment operator). */
 #define GINAC_IMPLEMENT_REGISTERED_CLASS(classname, supername) \
        GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(classname, supername) \
 classname::~classname() \
@@ -108,8 +116,14 @@ const classname & classname::operator=(const classname & other) \
                copy(other); \
        } \
        return *this; \
+} \
+basic * classname::duplicate() const \
+{ \
+       debugmsg(#classname " duplicate", LOGLEVEL_DUPLICATE); \
+       return new classname(*this); \
 }
 
+
 /** Find TINFO_* key by class name. */
 extern unsigned int find_tinfo_key(const std::string &class_name);
 
index c8b5043..8f7b4b6 100644 (file)
@@ -111,12 +111,6 @@ void relational::archive(archive_node &n) const
 
 // public
 
-basic * relational::duplicate() const
-{
-       debugmsg("relational duplicate",LOGLEVEL_DUPLICATE);
-       return new relational(*this);
-}
-
 void relational::print(std::ostream & os, unsigned upper_precedence) const
 {
        debugmsg("relational print",LOGLEVEL_PRINT);
index 5a9fe44..c988a63 100644 (file)
@@ -53,7 +53,6 @@ public:
        
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printraw(std::ostream & os) const;
        void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const;
@@ -65,7 +64,6 @@ public:
        ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
        ex simplify_ncmul(const exvector & v) const;
 protected:
-       int compare_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
 
index 23bd24a..3454b5a 100644 (file)
@@ -149,12 +149,6 @@ void simp_lor::archive(archive_node &n) const
 
 // public
 
-basic * simp_lor::duplicate() const
-{
-       debugmsg("simp_lor duplicate",LOGLEVEL_DUPLICATE);
-       return new simp_lor(*this);
-}
-
 void simp_lor::printraw(std::ostream & os) const
 {
        debugmsg("simp_lor printraw",LOGLEVEL_PRINT);
index d76f6c5..4b4e239 100644 (file)
@@ -99,7 +99,6 @@ protected:
        
        // functions overriding virtual functions from base classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void print(std::ostream & os, unsigned upper_precedence=0) const;
@@ -107,7 +106,6 @@ public:
        bool info(unsigned inf) const;
        ex eval(int level=0) const;
 protected:
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        unsigned return_type(void) const;
        unsigned return_type_tinfo(void) const;
index 4aa4f10..39c09bf 100644 (file)
@@ -90,12 +90,6 @@ void structure::archive(archive_node &n) const
 
 // public
 
-basic * structure::duplicate() const
-{
-       debugmsg("structure duplicate",LOGLEVEL_DUPLICATE);
-       return new structure(*this);
-}
-
 void structure::printraw(std::ostream & os) const
 {
        debugmsg("structure printraw",LOGLEVEL_PRINT);
index 6c54003..365f569 100644 (file)
@@ -48,13 +48,11 @@ class structure : public basic
 
        // functions overriding virtual functions from bases classes
 public:
-       basic * duplicate() const;
        void printraw(std::ostream & os) const; 
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        void printtree(std::ostream & os, unsigned indent) const;
        void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const;
 protected:
-       int compare_same_type(const basic & other) const;
        bool is_equal_same_type(const basic & other) const;
        
        // new virtual functions which can be overridden by derived classes