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 574a8e8ec662eb96e71f5414dcce322a4e59776b..9cc2cc01c4e05908cd304813edb67e6b6b248fdd 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 924eb407ce893d0e9ac5e5116ebb2cc439a1402d..0c8e37ca771f4fe371e07ba06f4dbe23fbe8c7e8 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 c3c0d9f3a3ba9b9944f1bd96626aed8863c99ed3..0dc0518dcd64c7b309910d4669b38f5d85c457ab 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 2d02ebcb8df7a4c6bc3db1d12c0fb34ca00aeae2..aed2b16669140567512f05318b328cacbacd5dbf 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 4b59877aeb4e03ba228f66330782cd92b0715bf9..f2360c3d460510d11f0c3ed65bacc0f2a395103a 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 2d44aa8f530177581235e9f444afc166765a8e86..6f126a345129bbaaa0e375517119ed58ad65d68e 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 221e86b6aeaf261e995d7fb823b25131a8bf81cf..d034ba48a7fdb9965afb10e760cec206b39e34d4 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 780aac4275e0d3bc246be7883b9af90acae33371..a727b912ad592bf3ac2c8539ce16bed85709662d 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 ae71579c777bd25d3ea5ceeb51a0d76bba396a9f..bc1179c5edbcdd8b6250d3c2024b401a5a273040 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 0c9394f88c24eea75e4ab4b749b639a44709d0bc..cf31814f510939ac94e952ac602056bdff7ed417 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 232d299c6fc12e0bb073ab5aa59c9a7923b1d694..d2c5bb443fc554f5e542d4d6c14dc357d465cfea 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 c11180406ad3a654f2c0d31a1af726ada1d8758a..0bbe01c67bd8dd07e1149429e6fd45603601484a 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 248c593c6d1002805e53458b0e6e165717c8de85..c2942cc7e32185a40cdb2a1a2ead328a478e37cb 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 8a96a3290ff852cfca3c8f6552c8524695b93459..de453fe552a29286ad84df36f46fbfc4369b9dba 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 af463a80f4a71cfe9c3ebf33ec486f1fed16c1e3..480da0f24cde7b5c3e0d17892aa8d5c70727ed09 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 981fee68d041f66e321c9f7addbf611c0d5773ac..3c8ec34e904655bc0c40e6dcd88daa7af41f8fc8 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 7127e9a4786a9b201443a96396b7ad794059a1ca..be4a7cb7a43c4fe1d5e412adb68770eec3785aa3 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 b1d8844aaf83995bd0ac0020db66ebad0a98c4f4..cc604f1378f43654bbd6ae86acaeb5ce86548abf 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 a74e05f79eb01100206a0f25b525bc79b0bffdfe..1be79d590533be4a88defdad96d2ead28c35fbd8 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 3facb90bf0094c5034e24c8a0002226af33ebf64..d9d93a849172e66dd3a33c56f6b1b6be5c0c6c4a 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 6a367be65c1deec6068f2e08546de67dbec7efbf..ca88d94a5ca5ddc4f3ab3edc1fc791df5830838c 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 099f36b528dc3c8edc1f7f6abcbcf79cf3702b42..20be2b50eb07077c98aab9f9d575f731aed00a4f 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 7a97887ae71852fc33974827dc55778a126c9b6d..6c326e2b01af3dfe4fe1d4b168352802b700814d 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 d25211fe053d9285eacfe343610d65e7fb01f56e..8da739d835dc1e853dd0c2aba2076e754913bdb5 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 0b87ed5d3ba843511e144bc3c316bd99dd0a4d50..81d31bdb9e8739a5d073a2e20ddbb95e58f25c3f 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 7c2b9c0178a6627e7d482167c6afbc35e9a48354..c04a592e3aa8a204debb5476da58d2485d75de48 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 80901d773573f19973546880ea2378dceba82f3c..02029c54791df100aba6d89f8655334b85324168 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 c6d607dbeb844a71cbd0fd2ce98aa20267db0d1d..cad3b9b3e5302b90666302897d5d2a3eb4eda83e 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 86b76e718aa85f250247185968043655789779c6..865011119cf3ce27f9b1d87e6fc5846cfa714132 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 a4a77eb027e5423becdf5aff1f7dd437336ec38c..5373a75ba329fe697a75e2a19ea00b202a3dbd8d 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 3398f60db6aca79a82bd5b27244a03ebe8b70cf9..358ad45d3f5df37d72a05ae8d08b041ce4b3f619 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 1eda94d44b5affd180942ad2d23498f20c4190c0..3a972bc925d036569cb0a6f4a272da879763c6f5 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 30697335c437e2a88b5415d145652fe473c6809d..7324ca97259974140e073c50dc8705f8640a2f28 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 65c86b7e8618cd68a3b4875e9eaa9dcad7d81a8f..24e46f889ecf8219a6554d1718a6c6a7cd3ff507 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 d447aaa64de9d98e135beb67ec7e32a03509cc62..2d873a2626c5eae2591b5549a56caa82aca3ac45 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 14b011af6af401b09ca558f55763697e2aaa1f4f..95d85b283d0e460f649b11afd5a5152fb1be5c52 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 f665ccd87cd830969479262469a659fdb7e87148..2737325bb8fbb91a59590d46c85f551a72f5733c 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 c8b504313bde667710232fd5ad8d6b2c22029cd3..8f7b4b65effc7a5d2dba3388b6060998f6e0fde6 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 5a9fe443164d9d9120210905ad1b665e2cd22e47..c988a631f2e59fad825badbeee29e62073f0d905 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 23bd24a31bca5e375935a2ce4a2ff36476fa0eb6..3454b5a0166eb011b506eb3488f2aef69c0ab917 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 d76f6c5694da7c1a113809309bdfff1ec438d64b..4b4e239c1bff3e080c5ec5962e0c4ef079307a4f 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 4aa4f10c6aa13cb1a9a5114df7a6c6380721ede4..39c09bf19e56bddbaf505f3ec5591cb338c150a1 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 6c5400336732bafef22bab16c9ddd5dd4b88793a..365f569134b04403eb66b044898b6ea552d08a28 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