]> www.ginac.de Git - ginac.git/commitdiff
synced to 1.0
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 18 Sep 2002 17:18:13 +0000 (17:18 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 18 Sep 2002 17:18:13 +0000 (17:18 +0000)
ginac/symbol.cpp
ginac/symbol.h
ginac/tensor.cpp

index e393e95d2fd5f82034bc95069ef53c0e9c1244b7..6a07e2bd8967d80e6597ca3bdc02c963417e1ae7 100644 (file)
@@ -32,7 +32,7 @@
 
 namespace GiNaC {
 
-GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(symbol, basic)
+GINAC_IMPLEMENT_REGISTERED_CLASS(symbol, basic)
 
 //////////
 // default ctor, dtor, copy ctor, assignment operator and helpers
@@ -53,7 +53,7 @@ void symbol::copy(const symbol & other)
        TeX_name = other.TeX_name;
        serial = other.serial;
        asexinfop = other.asexinfop;
-       ++asexinfop->refcount;
+       ++(asexinfop->refcount);
 }
 
 void symbol::destroy(bool call_parent)
@@ -70,11 +70,6 @@ void symbol::destroy(bool call_parent)
 
 // public
 
-symbol::symbol(const symbol & other)
-{
-       copy(other);
-}
-
 symbol::symbol(const std::string & initname) : inherited(TINFO_symbol)
 {
        name = initname;
@@ -137,11 +132,6 @@ void symbol::archive(archive_node &n) const
 
 // public
 
-basic *symbol::duplicate() const
-{
-       return new symbol(*this);
-}
-
 void symbol::print(const print_context & c, unsigned level) const
 {
        if (is_a<print_tree>(c)) {
index 7c96312cf8aec70f7c0ac8141b603966e1db55d7..15490253eb9f0a2b54b3f620fd41f0d444cea42f 100644 (file)
@@ -37,7 +37,7 @@ namespace GiNaC {
  *  first place. */
 class symbol : public basic
 {
-       GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(symbol, basic)
+       GINAC_DECLARE_REGISTERED_CLASS(symbol, basic)
        
 // types
        
@@ -52,15 +52,6 @@ class symbol : public basic
        
 // member functions
        
-       // default ctor, dtor, copy ctor, assignment operator and helpers
-public:
-       symbol();
-       ~symbol() { destroy(false); }
-       symbol(const symbol & other);
-protected:
-       void copy(const symbol & other); 
-       void destroy(bool call_parent);
-       
        // other ctors
 public:
        explicit symbol(const std::string & initname);
@@ -68,7 +59,6 @@ public:
        
        // functions overriding virtual functions from base classes
 public:
-       basic * duplicate() const;
        void print(const print_context & c, unsigned level = 0) const;
        bool info(unsigned inf) const;
        ex eval(int level = 0) const;
@@ -78,7 +68,6 @@ public:
        ex to_rational(lst &repl_lst) 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 a1daf6255143b53603469b7d51e4faa8d2cce19f..4d514d14b7a526efa5caee69c1a1530c853882db 100644 (file)
@@ -349,8 +349,8 @@ again:
                                try {
                                        // minimal_dim() throws an exception when index dimensions are not comparable
                                        ex min_dim = self_idx->minimal_dim(other_idx);
-                                       *self = _ex1;
                                        *other = other->subs(other_idx == free_idx->replace_dim(min_dim));
+                                       *self = _ex1; // *other is assigned first because assigning *self invalidates free_idx
                                        return true;
                                } catch (std::exception &e) {
                                        return false;
@@ -460,9 +460,10 @@ again:
                        if (is_dummy_pair(*self_idx, other_idx)) {
 
                                // Contraction found, remove metric tensor and substitute
-                               // index in second object
-                               *self = (static_cast<const spinidx *>(self_idx)->is_covariant() ? sign : -sign);
+                               // index in second object (assign *self last because this
+                               // invalidates free_idx)
                                *other = other->subs(other_idx == *free_idx);
+                               *self = (static_cast<const spinidx *>(self_idx)->is_covariant() ? sign : -sign);
                                return true;
                        }
                }