]> www.ginac.de Git - ginac.git/commitdiff
- added stream manipulators index_dimensions and no_index_dimensions
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 26 Mar 2003 19:59:47 +0000 (19:59 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 26 Mar 2003 19:59:47 +0000 (19:59 +0000)
- using print() and print_context (and derived classes) in user code is now
  deprecated in favor of the manipulators
- print_options moved from flags.h to print.h
- a symbol that appears multiple times in archives but is not listed in the
  sym_lst passed to unarchive_ex() now receives the same serial number in
  all occurrences, so GiNaC will treat it as one and the same symbol; this
  made it necessary to remove the "const" from the second argument of
  basic::unarchive() and the unarchiving constructor

29 files changed:
ginac/archive.cpp
ginac/archive.h
ginac/basic.cpp
ginac/clifford.cpp
ginac/color.cpp
ginac/constant.cpp
ginac/container.pl
ginac/ex.cpp
ginac/ex.h
ginac/expairseq.cpp
ginac/fderivative.cpp
ginac/flags.h
ginac/function.pl
ginac/idx.cpp
ginac/indexed.cpp
ginac/matrix.cpp
ginac/numeric.cpp
ginac/operators.cpp
ginac/operators.h
ginac/power.cpp
ginac/print.h
ginac/pseries.cpp
ginac/registrar.h
ginac/relational.cpp
ginac/symbol.cpp
ginac/symmetry.cpp
ginac/tensor.cpp
ginac/utils.h
ginac/wildcard.cpp

index 28d8afc3dbde5ca0daccfcf1ab0d0fcafd34049e..69a73441bc2776a62e71c9329d6f9e514339d3b4 100644 (file)
@@ -26,6 +26,7 @@
 #include "archive.h"
 #include "registrar.h"
 #include "ex.h"
+#include "lst.h"
 #include "config.h"
 #include "tostring.h"
 
@@ -89,7 +90,8 @@ ex archive::unarchive_ex(const lst &sym_lst, const char *name) const
 
 found:
        // Recursively unarchive all nodes, starting at the root node
-       return nodes[i->root].unarchive(sym_lst);
+       lst sym_lst_copy = sym_lst;
+       return nodes[i->root].unarchive(sym_lst_copy);
 }
 
 ex archive::unarchive_ex(const lst &sym_lst, unsigned index) const
@@ -98,7 +100,8 @@ ex archive::unarchive_ex(const lst &sym_lst, unsigned index) const
                throw (std::range_error("index of archived expression out of range"));
 
        // Recursively unarchive all nodes, starting at the root node
-       return nodes[exprs[index].root].unarchive(sym_lst);
+       lst sym_lst_copy = sym_lst;
+       return nodes[exprs[index].root].unarchive(sym_lst_copy);
 }
 
 ex archive::unarchive_ex(const lst &sym_lst, std::string &name, unsigned index) const
@@ -110,7 +113,8 @@ ex archive::unarchive_ex(const lst &sym_lst, std::string &name, unsigned index)
        name = unatomize(exprs[index].name);
 
        // Recursively unarchive all nodes, starting at the root node
-       return nodes[exprs[index].root].unarchive(sym_lst);
+       lst sym_lst_copy = sym_lst;
+       return nodes[exprs[index].root].unarchive(sym_lst_copy);
 }
 
 unsigned archive::num_expressions(void) const
@@ -432,7 +436,7 @@ bool archive_node::find_string(const std::string &name, std::string &ret, unsign
        return false;
 }
 
-bool archive_node::find_ex(const std::string &name, ex &ret, const lst &sym_lst, unsigned index) const
+bool archive_node::find_ex(const std::string &name, ex &ret, lst &sym_lst, unsigned index) const
 {
        archive_atom name_atom = a.atomize(name);
        std::vector<property>::const_iterator i = props.begin(), iend = props.end();
@@ -493,7 +497,7 @@ void archive_node::get_properties(propinfovector &v) const
 
 
 /** Convert archive node to GiNaC expression. */
-ex archive_node::unarchive(const lst &sym_lst) const
+ex archive_node::unarchive(lst &sym_lst) const
 {
        // Already unarchived? Then return cached unarchived expression.
        if (has_expression)
index b7e9ba989e296a55e907a547ac0dcb3193236801..8b7ae4f3943ff5470da35056a0e09598f85c4e24 100644 (file)
@@ -110,7 +110,7 @@ public:
 
        /** Retrieve property of type "ex" from node.
         *  @return "true" if property was found, "false" otherwise */
-       bool find_ex(const std::string &name, ex &ret, const lst &sym_lst, unsigned index = 0) const;
+       bool find_ex(const std::string &name, ex &ret, lst &sym_lst, unsigned index = 0) const;
 
        /** Retrieve property of type "ex" from node, returning the node of
         *  the sub-expression. */
@@ -119,7 +119,7 @@ public:
        /** Return vector of properties stored in node. */
        void get_properties(propinfovector &v) const;
 
-       ex unarchive(const lst &sym_lst) const;
+       ex unarchive(lst &sym_lst) const;
        bool has_same_ex_as(const archive_node &other) const;
 
        void forget(void);
index a79ac0652d50a7d5cb364448c0d761671ac91883..85294cac3a30fe32cc3f200307856e419e27a973 100644 (file)
@@ -79,7 +79,7 @@ const basic & basic::operator=(const basic & other)
 //////////
 
 /** Construct object from archive_node. */
-basic::basic(const archive_node &n, const lst &sym_lst) : flags(0), refcount(0)
+basic::basic(const archive_node &n, lst &sym_lst) : flags(0), refcount(0)
 {
        // Reconstruct tinfo_key from class name
        std::string class_name;
@@ -128,7 +128,8 @@ void basic::print(const print_context & c, unsigned level) const
  *  debugger because it might not know what cout is.  This method can be
  *  invoked with no argument and it will simply print to stdout.
  *
- *  @see basic::print */
+ *  @see basic::print
+ *  @see basic::dbgprinttree */
 void basic::dbgprint(void) const
 {
        this->print(std::cerr);
@@ -137,8 +138,7 @@ void basic::dbgprint(void) const
 
 /** Little wrapper around printtree to be called within a debugger.
  *
- *  @see basic::dbgprint
- *  @see basic::printtree */
+ *  @see basic::dbgprint */
 void basic::dbgprinttree(void) const
 {
        this->print(print_tree(std::cerr));
index 1ab5eef55485fa0e8613564cfe2c55dbb7fbe87c..a8b87343ba838f7cdfca4568d941e863d266eec6 100644 (file)
@@ -104,7 +104,7 @@ clifford::clifford(unsigned char rl, exvector * vp) : inherited(sy_none(), vp),
 // archiving
 //////////
 
-clifford::clifford(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+clifford::clifford(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        unsigned rl;
        n.find_unsigned("label", rl);
index 9600065d58532bd596573f234cb18fde7759e92b..7405c4aad9b0bdd8466254585f08e242aec0aa45 100644 (file)
@@ -99,7 +99,7 @@ color::color(unsigned char rl, exvector * vp) : inherited(sy_none(), vp), repres
 // archiving
 //////////
 
-color::color(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+color::color(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        unsigned rl;
        n.find_unsigned("label", rl);
index 1557bc00ac562f048f571d2b33a34de5cde4f48c..6fc37366eae6b399b7a9e8d0d2234d7f10498b31 100644 (file)
@@ -96,9 +96,9 @@ constant::constant(const std::string & initname, const numeric & initnumber, con
 // archiving
 //////////
 
-constant::constant(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) {}
+constant::constant(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) {}
 
-ex constant::unarchive(const archive_node &n, const lst &sym_lst)
+ex constant::unarchive(const archive_node &n, lst &sym_lst)
 {
        // Find constant by name (!! this is bad: 'twould be better if there
        // was a list of all global constants that we could search)
index 945622feaea8f6598cc1da3ac5e49c0fa6df63df..7dcd0be68fd6449f38c752bfc32fef5735fbbf8a 100755 (executable)
@@ -398,7 +398,7 @@ ${constructors_implementation}
 //////////
 
 /** Construct object from archive_node. */
-${CONTAINER}::${CONTAINER}(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+${CONTAINER}::${CONTAINER}(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        for (unsigned int i=0; true; i++) {
                ex e;
@@ -410,7 +410,7 @@ ${CONTAINER}::${CONTAINER}(const archive_node &n, const lst &sym_lst) : inherite
 }
 
 /** Unarchive the object. */
-ex ${CONTAINER}::unarchive(const archive_node &n, const lst &sym_lst)
+ex ${CONTAINER}::unarchive(const archive_node &n, lst &sym_lst)
 {
        return (new ${CONTAINER}(n, sym_lst))->setflag(status_flags::dynallocated);
 }
index 2c31212ce5328bfb1a60a18180133b577d540a55..3c6d504876e826b37e288c6261f2d197ab6e27ea 100644 (file)
@@ -59,13 +59,6 @@ void ex::print(const print_context & c, unsigned level) const
        bp->print(c, level);
 }
 
-/** Print expression to stream in a tree-like format suitable for debugging. */
-void ex::printtree(std::ostream & os) const
-{
-       GINAC_ASSERT(bp!=0);
-       bp->print(print_tree(os));
-}
-
 /** Little wrapper arount print to be called within a debugger. */
 void ex::dbgprint(void) const
 {
index 5e8ac0de1529d803271165ab5895b063e1a75f5c..3c8094b1b405b1717f5cc05ce8ae74f0563055a7 100644 (file)
@@ -111,7 +111,6 @@ public:
        }
 
        void print(const print_context & c, unsigned level = 0) const;
-       void printtree(std::ostream & os) const;
        void dbgprint(void) const;
        void dbgprinttree(void) const;
        bool info(unsigned inf) const { return bp->info(inf); }
index 3e2b549c8e53e1fe809f6a069d5256e31169493d..c41c694b82e3c3ed10f5458e62782abf56e33391 100644 (file)
@@ -146,7 +146,7 @@ expairseq::expairseq(epvector *vp, const ex &oc)
 // archiving
 //////////
 
-expairseq::expairseq(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+expairseq::expairseq(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 #if EXPAIRSEQ_USE_HASHTAB
        , hashtabsize(0)
 #endif
index 8216179d668d2d265786b285adfb7755bf0920ad..3b209387ea80582c8e72969f0a4a8ed396f1a10f 100644 (file)
@@ -73,7 +73,7 @@ fderivative::fderivative(unsigned ser, const paramset & params, exvector * vp) :
 // archiving
 //////////
 
-fderivative::fderivative(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+fderivative::fderivative(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        unsigned i = 0;
        while (true) {
index 0427bc51cb4c25e861e42ad6f1132785588e4ed5..04c430c4caae87540983a6bfae53a4341430774a 100644 (file)
@@ -248,14 +248,6 @@ public:
        };
 };
 
-/** Flags to control the behavior of print(). */
-class print_options {
-public:
-       enum {
-               print_index_dimensions = 0x0001 ///< print the dimensions of indices
-       };
-};
-
 } // namespace GiNaC
 
 #endif // ndef __GINAC_FLAGS_H__
index fba34e20e371181b8ea10ba802f3ef63012fe3d4..ad372f556a9b051334d1041655013c371d27b757 100755 (executable)
@@ -630,7 +630,7 @@ function::function(unsigned ser, exvector * vp)
 //////////
 
 /** Construct object from archive_node. */
-function::function(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+function::function(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        // Find serial number by function name
        std::string s;
@@ -650,7 +650,7 @@ function::function(const archive_node &n, const lst &sym_lst) : inherited(n, sym
 }
 
 /** Unarchive the object. */
-ex function::unarchive(const archive_node &n, const lst &sym_lst)
+ex function::unarchive(const archive_node &n, lst &sym_lst)
 {
        return (new function(n, sym_lst))->setflag(status_flags::dynallocated);
 }
index 277bc3163bfeb72af56dc65f2a6d4e93ff4769e6..55475568bb12b58e9f077f461b929892c46d96a3 100644 (file)
@@ -103,18 +103,18 @@ spinidx::spinidx(const ex & v, const ex & d, bool cov, bool dot) : inherited(v,
 // archiving
 //////////
 
-idx::idx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+idx::idx(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        n.find_ex("value", value, sym_lst);
        n.find_ex("dim", dim, sym_lst);
 }
 
-varidx::varidx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+varidx::varidx(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        n.find_bool("covariant", covariant);
 }
 
-spinidx::spinidx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+spinidx::spinidx(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        n.find_bool("dotted", dotted);
 }
index 5799642a0ab325b06ad2bdddd31832154cb5e311..695768f69ddb825d0fed921873183d0a0fcc1742 100644 (file)
@@ -144,7 +144,7 @@ indexed::indexed(const symmetry & symm, exvector * vp) : inherited(vp), symtree(
 // archiving
 //////////
 
-indexed::indexed(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+indexed::indexed(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        if (!n.find_ex("symmetry", symtree, sym_lst)) {
                // GiNaC versions <= 0.9.0 had an unsigned "symmetry" property
index fe24e09ec51f2d0f56ffbd03eee095b84224612b..df1b4c9178f62565c7d7fc03f21d9a1552917cfa 100644 (file)
@@ -108,7 +108,7 @@ matrix::matrix(unsigned r, unsigned c, const lst & l)
 // archiving
 //////////
 
-matrix::matrix(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+matrix::matrix(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        if (!(n.find_unsigned("row", row)) || !(n.find_unsigned("col", col)))
                throw (std::runtime_error("unknown matrix dimensions in archive"));
index 9eaa715b1cfdc36c32013e2f3e57fb7fae580eda..37a1ba3f02283fada1e439f97c89ae9c471ca3b4 100644 (file)
@@ -245,7 +245,7 @@ numeric::numeric(const cln::cl_N &z) : basic(TINFO_numeric)
 // archiving
 //////////
 
-numeric::numeric(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+numeric::numeric(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        cln::cl_N ctorval = 0;
 
index ae1987061b499a98edd09eb30e3d5ae4a1d2c9bf..d588b98d995560a9f5c8850d7f5427fae685cdf1 100644 (file)
@@ -283,26 +283,29 @@ static int my_ios_index()
        return i;
 }
 
+// Stream format gets copied or destroyed
 static void my_ios_callback(std::ios_base::event ev, std::ios_base & s, int i)
 {
        print_context *p = static_cast<print_context *>(s.pword(i));
        if (ev == std::ios_base::erase_event) {
                delete p;
                s.pword(i) = 0;
-       } else if (ev == std::ios_base::copyfmt_event && p != 0) {
+       } else if (ev == std::ios_base::copyfmt_event && p != 0)
                s.pword(i) = p->duplicate();
-       }
 }
 
 enum {
        callback_registered = 1
 };
 
-static print_context *get_print_context(std::ios_base & s)
+// Get print_context associated with stream, may return 0 if no context has
+// been associated yet
+static inline print_context *get_print_context(std::ios_base & s)
 {
        return static_cast<print_context *>(s.pword(my_ios_index()));
 }
 
+// Set print_context associated with stream, retain options
 static void set_print_context(std::ios_base & s, const print_context & c)
 {
        int i = my_ios_index();
@@ -311,16 +314,38 @@ static void set_print_context(std::ios_base & s, const print_context & c)
                s.register_callback(my_ios_callback, i);
                s.iword(i) = flags | callback_registered;
        }
-       delete static_cast<print_context *>(s.pword(i));
-       s.pword(i) = c.duplicate();
+       print_context *p = static_cast<print_context *>(s.pword(i));
+       unsigned options = p ? p->options : c.options;
+       delete p;
+       p = c.duplicate();
+       p->options = options;
+       s.pword(i) = p;
+}
+
+// Get options for print_context associated with stream
+static inline unsigned get_print_options(std::ios_base & s)
+{
+       print_context *p = get_print_context(s);
+       return p ? p->options : 0;
+}
+
+// Set options for print_context associated with stream
+static void set_print_options(std::ostream & s, unsigned options)
+{
+       print_context *p = get_print_context(s);
+       if (p == 0)
+               set_print_context(s, print_context(s, options));
+       else
+               p->options = options;
 }
 
 std::ostream & operator<<(std::ostream & os, const ex & e)
 {
-       if (get_print_context(os) == 0)
+       print_context *p = get_print_context(os);
+       if (p == 0)
                e.print(print_context(os));
        else
-               e.print(*get_print_context(os));
+               e.print(*p);
        return os;
 }
 
@@ -332,6 +357,7 @@ std::istream & operator>>(std::istream & is, ex & e)
 std::ostream & dflt(std::ostream & os)
 {
        set_print_context(os, print_context(os));
+       set_print_options(os, 0);
        return os;
 }
 
@@ -359,6 +385,12 @@ std::ostream & tree(std::ostream & os)
        return os;
 }
 
+std::ostream & csrc(std::ostream & os)
+{
+       set_print_context(os, print_csrc_double(os));
+       return os;
+}
+
 std::ostream & csrc_float(std::ostream & os)
 {
        set_print_context(os, print_csrc_float(os));
@@ -377,9 +409,15 @@ std::ostream & csrc_cl_N(std::ostream & os)
        return os;
 }
 
-std::ostream & csrc(std::ostream & os)
+std::ostream & index_dimensions(std::ostream & os)
 {
-       set_print_context(os, print_csrc_double(os));
+       set_print_options(os, get_print_options(os) | print_options::print_index_dimensions);
+       return os;
+}
+
+std::ostream & no_index_dimensions(std::ostream & os)
+{
+       set_print_options(os, get_print_options(os) & ~print_options::print_index_dimensions);
        return os;
 }
 
index fe72e6e3cca146a32f74b426390ca6d3bb5e3c09..33e1c3e650275984cb7b671cddda05e29c501cdf 100644 (file)
@@ -91,10 +91,13 @@ std::ostream & latex(std::ostream & os);
 std::ostream & python(std::ostream & os);
 std::ostream & python_repr(std::ostream & os);
 std::ostream & tree(std::ostream & os);
+std::ostream & csrc(std::ostream & os); // same as csrc_double
 std::ostream & csrc_float(std::ostream & os);
 std::ostream & csrc_double(std::ostream & os);
 std::ostream & csrc_cl_N(std::ostream & os);
-std::ostream & csrc(std::ostream & os); // same as csrc_double
+
+std::ostream & index_dimensions(std::ostream & os);
+std::ostream & no_index_dimensions(std::ostream & os);
 
 } // namespace GiNaC
 
index 6ca771a8d74615460a022b21a51d8b3d398dd761..07a52ebeefbde2d82266dd42eb05b04b817db1b1 100644 (file)
@@ -73,7 +73,7 @@ DEFAULT_DESTROY(power)
 // archiving
 //////////
 
-power::power(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+power::power(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        n.find_ex("basis", basis, sym_lst);
        n.find_ex("exponent", exponent, sym_lst);
index b98318c0b5af6f4a1ecf1bb2bcd98612ac91635f..8d4fc2f8612eeebe0367a2b4bf71bea454bd8bd9 100644 (file)
 
 namespace GiNaC {
 
+
+/*
+ *  The following classes remain publicly visible for compatibility
+ *  reasons only. New code should use the iostream manipulators defined
+ *  in operators.h instead.
+ */
+
+
+/** Flags to control the behavior of a print_context. */
+class print_options {
+public:
+       enum {
+               print_index_dimensions = 0x0001 ///< print the dimensions of indices
+       };
+};
+
+
 /** Context for default (ginsh-parsable) output. */
 class print_context
 {
index 0f1f08d992227966ca3f10ca9f673be1106bdb3c..0d2dde29caf41ece49ce808b54ec3f2394351042 100644 (file)
@@ -85,7 +85,7 @@ pseries::pseries(const ex &rel_, const epvector &ops_) : basic(TINFO_pseries), s
  *  Archiving
  */
 
-pseries::pseries(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+pseries::pseries(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        for (unsigned int i=0; true; ++i) {
                ex rest;
index e620250ec7cc8537896d13db67c57e57bcb0c741..77a6e873c79f71f833cf853c60b43509f1572493 100644 (file)
@@ -34,7 +34,7 @@ class lst;
 
 
 /** Unarchiving function (static member function of every GiNaC class). */
-typedef ex (*unarch_func)(const archive_node &n, const lst &sym_lst);
+typedef ex (*unarch_func)(const archive_node &n, lst &sym_lst);
 
 
 /** Head of list of all registered_class_info structures. */
@@ -65,9 +65,9 @@ public: \
        typedef supername inherited; \
        static registered_class_info reg_info; \
        virtual const char *class_name(void) const; \
-       classname(const archive_node &n, const lst &sym_lst); \
+       classname(const archive_node &n, lst &sym_lst); \
        virtual void archive(archive_node &n) const; \
-       static ex unarchive(const archive_node &n, const lst &sym_lst);
+       static ex unarchive(const archive_node &n, lst &sym_lst);
 
 /** Macro for inclusion in the declaration of each registered class.
  *  It declares some functions that are common to all classes derived
index 70dc5bd0e094b32e7350e3ebca39e6cc98742462..24fd7a05a0d8c67606bf5475bf871d0706258f5f 100644 (file)
@@ -62,7 +62,7 @@ relational::relational(const ex & lhs, const ex & rhs, operators oper) : basic(T
 // archiving
 //////////
 
-relational::relational(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+relational::relational(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        unsigned int opi;
        if (!(n.find_unsigned("op", opi)))
index af98215a5bcc882b372133659008ae4082373bc3..43e3684cee97d1b645bd643aae02700d260292a4 100644 (file)
@@ -93,7 +93,7 @@ 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)
+symbol::symbol(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        serial = next_serial++;
        if (!(n.find_string("name", name)))
@@ -105,15 +105,18 @@ symbol::symbol(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst
 }
 
 /** Unarchive the object. */
-ex symbol::unarchive(const archive_node &n, const lst &sym_lst)
+ex symbol::unarchive(const archive_node &n, lst &sym_lst)
 {
        ex s = (new symbol(n, sym_lst))->setflag(status_flags::dynallocated);
-       
+
        // If symbol is in sym_lst, return the existing symbol
        for (size_t i=0; i<sym_lst.nops(); i++) {
                if (is_a<symbol>(sym_lst.op(i)) && (ex_to<symbol>(sym_lst.op(i)).name == ex_to<symbol>(s).name))
                        return sym_lst.op(i);
        }
+
+       // Otherwise add new symbol to list and return it
+       sym_lst.append(s);
        return s;
 }
 
index 473bd5b91ebd4978348bc5a9f41a155627536cca..2058a27974fa4a155a7e553e84fc2af317113b47 100644 (file)
@@ -90,7 +90,7 @@ symmetry::symmetry(symmetry_type t, const symmetry &c1, const symmetry &c2) : ty
 //////////
 
 /** Construct object from archive_node. */
-symmetry::symmetry(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+symmetry::symmetry(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        unsigned t;
        if (!(n.find_unsigned("type", t)))
index eef89a1ee43ec2e07131e0cb9fda92e5be3f75cf..5e95a414fad3378d6913274319ecac620ea8d2f0 100644 (file)
@@ -107,7 +107,7 @@ DEFAULT_ARCHIVING(spinmetric)
 DEFAULT_UNARCHIVE(minkmetric)
 DEFAULT_UNARCHIVE(tensepsilon)
 
-minkmetric::minkmetric(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+minkmetric::minkmetric(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        n.find_bool("pos_sig", pos_sig);
 }
@@ -118,7 +118,7 @@ void minkmetric::archive(archive_node &n) const
        n.add_bool("pos_sig", pos_sig);
 }
 
-tensepsilon::tensepsilon(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+tensepsilon::tensepsilon(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        n.find_bool("minkowski", minkowski);
        n.find_bool("pos_sig", pos_sig);
index b2ae4b1b0cda3fdae1141f0e492c76c2d5e9d238..f21dfed4f35cb5f04399e3c8c0ed4a9631d0c30f 100644 (file)
@@ -465,13 +465,13 @@ DEFAULT_COPY(classname) \
 DEFAULT_DESTROY(classname)
 
 #define DEFAULT_UNARCHIVE(classname) \
-ex classname::unarchive(const archive_node &n, const lst &sym_lst) \
+ex classname::unarchive(const archive_node &n, lst &sym_lst) \
 { \
        return (new classname(n, sym_lst))->setflag(status_flags::dynallocated); \
 }
 
 #define DEFAULT_ARCHIVING(classname) \
-classname::classname(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) {} \
+classname::classname(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst) {} \
 DEFAULT_UNARCHIVE(classname) \
 void classname::archive(archive_node &n) const \
 { \
index c389c98f1452b9a94b90368a249bb26507c70117..22ab5f0729777575369e1a878c7b36a47c2bd515 100644 (file)
@@ -61,7 +61,7 @@ wildcard::wildcard(unsigned l) : label(l)
 // archiving
 //////////
 
-wildcard::wildcard(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+wildcard::wildcard(const archive_node &n, lst &sym_lst) : inherited(n, sym_lst)
 {
        n.find_unsigned("label", label);
 }