]> www.ginac.de Git - ginac.git/commitdiff
- added skeleton implementation of color and clifford classes (don't bother
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 28 Mar 2001 00:36:37 +0000 (00:36 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Wed, 28 Mar 2001 00:36:37 +0000 (00:36 +0000)
  trying it, it doesn't work yet)
- some macros in utils.h (DEFAULT_*) provide shorthands for implementing
  many required class member functions

23 files changed:
ginac/Makefile.am
ginac/add.cpp
ginac/basic.cpp
ginac/clifford.cpp [new file with mode: 0644]
ginac/constant.cpp
ginac/expairseq.cpp
ginac/fail.cpp
ginac/fail.h
ginac/ginac.h
ginac/idx.cpp
ginac/indexed.cpp
ginac/matrix.cpp
ginac/mul.cpp
ginac/ncmul.cpp
ginac/numeric.cpp
ginac/power.cpp
ginac/pseries.cpp
ginac/relational.cpp
ginac/structure.cpp
ginac/structure.h
ginac/tensor.cpp
ginac/tinfos.h
ginac/utils.h

index fffe951c44ff16ddd631d6c75018013706977882..45fe8611df77f7a8ccf3fcde5e22c6ff7ddc85a8 100644 (file)
@@ -7,7 +7,8 @@ libginac_la_SOURCES = add.cpp archive.cpp basic.cpp constant.cpp ex.cpp \
   normal.cpp numeric.cpp operators.cpp power.cpp registrar.cpp relational.cpp \
   symbol.cpp pseries.cpp utils.cpp ncmul.cpp structure.cpp exprseq_suppl.cpp \
   lst.cpp lst_suppl.cpp input_parser.yy input_lexer.ll input_lexer.h \
   normal.cpp numeric.cpp operators.cpp power.cpp registrar.cpp relational.cpp \
   symbol.cpp pseries.cpp utils.cpp ncmul.cpp structure.cpp exprseq_suppl.cpp \
   lst.cpp lst_suppl.cpp input_parser.yy input_lexer.ll input_lexer.h \
-  remember.h remember.cpp debugmsg.h utils.h idx.cpp indexed.cpp tensor.cpp
+  remember.h remember.cpp debugmsg.h utils.h idx.cpp indexed.cpp tensor.cpp \
+  color.cpp clifford.cpp
 libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
   -release $(LT_RELEASE)
 ginacincludedir = $(includedir)/ginac
 libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
   -release $(LT_RELEASE)
 ginacincludedir = $(includedir)/ginac
@@ -15,7 +16,7 @@ ginacinclude_HEADERS = ginac.h add.h archive.h basic.h constant.h ex.h \
   expair.h expairseq.h exprseq.h fail.h flags.h function.h inifcns.h \
   lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h power.h \
   registrar.h relational.h pseries.h structure.h symbol.h tinfos.h assertion.h \
   expair.h expairseq.h exprseq.h fail.h flags.h function.h inifcns.h \
   lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h power.h \
   registrar.h relational.h pseries.h structure.h symbol.h tinfos.h assertion.h \
-  version.h idx.h indexed.h tensor.h
+  version.h idx.h indexed.h tensor.h color.h clifford.h
 LFLAGS = -Pginac_yy -olex.yy.c
 YFLAGS = -p ginac_yy -d
 EXTRA_DIST = container.pl function.pl structure.pl input_parser.h version.h.in
 LFLAGS = -Pginac_yy -olex.yy.c
 YFLAGS = -p ginac_yy -d
 EXTRA_DIST = container.pl function.pl structure.pl input_parser.h version.h.in
index 6c6a163831a9e3a0e6856e6144f288fc9dedfc04..150b4f8222d0df346dd357b104656f9fd70aaf15 100644 (file)
@@ -37,26 +37,14 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(add, expairseq)
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 
-// public
-
 add::add()
 {
        debugmsg("add default constructor",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_add;
 }
 
 add::add()
 {
        debugmsg("add default constructor",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_add;
 }
 
-// protected
-
-/** For use by copy ctor and assignment operator. */
-void add::copy(const add & other)
-{
-       inherited::copy(other);
-}
-
-void add::destroy(bool call_parent)
-{
-       if (call_parent) inherited::destroy(call_parent);
-}
+DEFAULT_COPY(add)
+DEFAULT_DESTROY(add)
 
 //////////
 // other constructors
 
 //////////
 // other constructors
@@ -115,23 +103,7 @@ add::add(epvector * vp, const ex & oc)
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
-add::add(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
-{
-       debugmsg("add constructor from archive_node", LOGLEVEL_CONSTRUCT);
-}
-
-/** Unarchive the object. */
-ex add::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new add(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
-void add::archive(archive_node &n) const
-{
-       inherited::archive(n);
-}
+DEFAULT_ARCHIVING(add)
 
 //////////
 // functions overriding virtual functions from bases classes
 
 //////////
 // functions overriding virtual functions from bases classes
index 1c6fe6fa0d1bf5553cafb38e81cc8f1c991de894..42d1f86632c436b8e9bafde8d53d07065e1d7350 100644 (file)
@@ -89,10 +89,7 @@ basic::basic(const archive_node &n, const lst &sym_lst) : flags(0), refcount(0)
 }
 
 /** Unarchive the object. */
 }
 
 /** Unarchive the object. */
-ex basic::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new basic(n, sym_lst))->setflag(status_flags::dynallocated);
-}
+DEFAULT_UNARCHIVE(basic)
 
 /** Archive the object. */
 void basic::archive(archive_node &n) const
 
 /** Archive the object. */
 void basic::archive(archive_node &n) const
diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp
new file mode 100644 (file)
index 0000000..5875bbb
--- /dev/null
@@ -0,0 +1,126 @@
+/** @file clifford.cpp
+ *
+ *  Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
+
+/*
+ *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "clifford.h"
+#include "ex.h"
+#include "idx.h"
+#include "ncmul.h"
+#include "archive.h"
+#include "debugmsg.h"
+#include "utils.h"
+
+#include <stdexcept>
+
+namespace GiNaC {
+
+GINAC_IMPLEMENT_REGISTERED_CLASS(clifford, indexed)
+GINAC_IMPLEMENT_REGISTERED_CLASS(diracgamma, tensor)
+
+//////////
+// default constructor, destructor, copy constructor assignment operator and helpers
+//////////
+
+clifford::clifford()
+{
+       debugmsg("clifford default constructor", LOGLEVEL_CONSTRUCT);
+       tinfo_key = TINFO_clifford;
+}
+
+DEFAULT_COPY(clifford)
+DEFAULT_DESTROY(clifford)
+DEFAULT_CTORS(diracgamma)
+
+//////////
+// other constructors
+//////////
+
+/** Construct object with one Lorentz index. This constructor is for internal
+ *  use only. Use the dirac_gamma() function instead.
+ *  @see dirac_gamma */
+clifford::clifford(const ex & b, const ex & mu) : inherited(b, mu)
+{
+       debugmsg("clifford constructor from ex,ex", LOGLEVEL_CONSTRUCT);
+       GINAC_ASSERT(is_ex_of_type(mu, varidx));
+       tinfo_key = TINFO_clifford;
+}
+
+clifford::clifford(const exvector & v, bool discardable) : inherited(indexed::unknown, v, discardable)
+{
+       debugmsg("clifford constructor from exvector", LOGLEVEL_CONSTRUCT);
+       tinfo_key = TINFO_clifford;
+}
+
+clifford::clifford(exvector * vp) : inherited(indexed::unknown, vp)
+{
+       debugmsg("clifford constructor from exvector *", LOGLEVEL_CONSTRUCT);
+       tinfo_key = TINFO_clifford;
+}
+
+//////////
+// archiving
+//////////
+
+DEFAULT_ARCHIVING(clifford)
+DEFAULT_ARCHIVING(diracgamma)
+
+//////////
+// functions overriding virtual functions from bases classes
+//////////
+
+int clifford::compare_same_type(const basic & other) const
+{
+       return inherited::compare_same_type(other);
+}
+
+DEFAULT_COMPARE(diracgamma)
+DEFAULT_PRINT(diracgamma, "gamma")
+
+/** Perform automatic simplification on noncommutative product of clifford
+ *  objects. */
+ex clifford::simplify_ncmul(const exvector & v) const
+{
+       //!! to be implemented
+       return nonsimplified_ncmul(v);
+}
+
+ex clifford::thisexprseq(const exvector & v) const
+{
+       return clifford(v);
+}
+
+ex clifford::thisexprseq(exvector * vp) const
+{
+       return clifford(vp);
+}
+
+//////////
+// global functions
+//////////
+
+ex dirac_gamma(const ex & mu)
+{
+       if (!is_ex_of_type(mu, varidx))
+               throw(std::invalid_argument("index of Dirac gamma must be of type varidx"));
+       return clifford(diracgamma(), mu);
+}
+
+} // namespace GiNaC
index 9002515452c7dc7eed3b39532aa4badec8b9ad3b..5b2bfebe89c0dbfadcfb54fe2337c9e9631bd94b 100644 (file)
@@ -91,13 +91,11 @@ constant::constant(const std::string & initname, const numeric & initnumber)
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
 constant::constant(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("constant ctor from archive_node", LOGLEVEL_CONSTRUCT);
 }
 
 constant::constant(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("constant ctor from archive_node", LOGLEVEL_CONSTRUCT);
 }
 
-/** Unarchive the object. */
 ex constant::unarchive(const archive_node &n, const lst &sym_lst)
 {
        // Find constant by name (!! this is bad: 'twould be better if there
 ex constant::unarchive(const archive_node &n, const lst &sym_lst)
 {
        // Find constant by name (!! this is bad: 'twould be better if there
@@ -116,7 +114,6 @@ ex constant::unarchive(const archive_node &n, const lst &sym_lst)
                throw (std::runtime_error("unnamed constant in archive"));
 }
 
                throw (std::runtime_error("unnamed constant in archive"));
 }
 
-/** Archive the object. */
 void constant::archive(archive_node &n) const
 {
        inherited::archive(n);
 void constant::archive(archive_node &n) const
 {
        inherited::archive(n);
index cfcfa16d0cb8401d222e36c7a4ce45bcf56f09cf..43754ea2dfc1ee16fb670d8259743923449c1a43 100644 (file)
@@ -101,11 +101,7 @@ void expairseq::copy(const expairseq &other)
 #endif // EXPAIRSEQ_USE_HASHTAB
 }
 
 #endif // EXPAIRSEQ_USE_HASHTAB
 }
 
-void expairseq::destroy(bool call_parent)
-{
-       if (call_parent)
-               basic::destroy(call_parent);
-}
+DEFAULT_DESTROY(expairseq)
 
 //////////
 // other ctors
 
 //////////
 // other ctors
@@ -147,7 +143,6 @@ expairseq::expairseq(epvector *vp, const ex &oc)
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
 expairseq::expairseq(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 #if EXPAIRSEQ_USE_HASHTAB
        , hashtabsize(0)
 expairseq::expairseq(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 #if EXPAIRSEQ_USE_HASHTAB
        , hashtabsize(0)
@@ -165,13 +160,6 @@ expairseq::expairseq(const archive_node &n, const lst &sym_lst) : inherited(n, s
        n.find_ex("overall_coeff", overall_coeff, sym_lst);
 }
 
        n.find_ex("overall_coeff", overall_coeff, sym_lst);
 }
 
-/** Unarchive the object. */
-ex expairseq::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new expairseq(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
 void expairseq::archive(archive_node &n) const
 {
        inherited::archive(n);
 void expairseq::archive(archive_node &n) const
 {
        inherited::archive(n);
@@ -184,6 +172,8 @@ void expairseq::archive(archive_node &n) const
        n.add_ex("overall_coeff", overall_coeff);
 }
 
        n.add_ex("overall_coeff", overall_coeff);
 }
 
+DEFAULT_UNARCHIVE(expairseq)
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index 4fd01997fda73b5c0b1779e31f8d1e204e0e94ea..7de656a52e9acfc9de7d9bebe0af8181655e4ee0 100644 (file)
@@ -24,6 +24,7 @@
 #include "fail.h"
 #include "archive.h"
 #include "debugmsg.h"
 #include "fail.h"
 #include "archive.h"
 #include "debugmsg.h"
+#include "utils.h"
 
 namespace GiNaC {
 
 
 namespace GiNaC {
 
@@ -33,71 +34,19 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(fail, basic)
 // default ctor, dtor, copy ctor assignment operator and helpers
 //////////
 
 // default ctor, dtor, copy ctor assignment operator and helpers
 //////////
 
-// public
-
-fail::fail() : inherited(TINFO_fail)
-{
-       debugmsg("fail default ctor",LOGLEVEL_CONSTRUCT);
-}
-
-// protected
-
-void fail::copy(const fail & other)
-{
-       inherited::copy(other);
-}
-
-void fail::destroy(bool call_parent)
-{
-       if (call_parent) inherited::destroy(call_parent);
-}
+DEFAULT_CTORS(fail)
 
 //////////
 // archiving
 //////////
 
 
 //////////
 // archiving
 //////////
 
-/** Construct object from archive_node. */
-fail::fail(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
-{
-       debugmsg("fail ctor from archive_node", LOGLEVEL_CONSTRUCT);
-}
-
-/** Unarchive the object. */
-ex fail::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new fail(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
-void fail::archive(archive_node &n) const
-{
-       inherited::archive(n);
-}
+DEFAULT_ARCHIVING(fail)
 
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 
 
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 
-// public
-
-void fail::print(std::ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("fail print",LOGLEVEL_PRINT);
-       os << "FAIL";
-}
-
-void fail::printraw(std::ostream & os) const
-{
-       debugmsg("fail printraw",LOGLEVEL_PRINT);
-       os << "FAIL";
-}
-
-// protected
-
-int fail::compare_same_type(const basic & other) const
-{
-       // two fails are always identical
-       return 0;
-}
+DEFAULT_COMPARE(fail)
+DEFAULT_PRINT(fail, "FAIL")
 
 } // namespace GiNaC
 
 } // namespace GiNaC
index f3104d85fcb7f3b6f7c7eaca73334803cf1842b8..415aba598bab91bfe85806341dcf70f8c5735a6c 100644 (file)
@@ -32,24 +32,11 @@ class fail : public basic
 {
        GINAC_DECLARE_REGISTERED_CLASS(fail, basic)
        
 {
        GINAC_DECLARE_REGISTERED_CLASS(fail, basic)
        
-       // other ctors
-       // none
-       
        // functions overriding virtual functions from bases classes
 public:
        void print(std::ostream & os, unsigned upper_precedence=0) const;
        // functions overriding virtual functions from bases classes
 public:
        void print(std::ostream & os, unsigned upper_precedence=0) const;
-       void printraw(std::ostream & os) const;
 protected:
        unsigned return_type(void) const { return return_types::noncommutative_composite; };
 protected:
        unsigned return_type(void) const { return return_types::noncommutative_composite; };
-       
-       // new virtual functions which can be overridden by derived classes
-       // none
-       
-       // non-virtual functions in this class
-       // none
-       
-       // member variables
-       // none
 };
 
 } // namespace GiNaC
 };
 
 } // namespace GiNaC
index 5e08ce3345e9850c341bd47b9fff37ebdef7182d..a21eb1c9b9df143b307f2da93675536dd086b367 100644 (file)
@@ -58,6 +58,8 @@
 #include "idx.h"
 #include "indexed.h"
 #include "tensor.h"
 #include "idx.h"
 #include "indexed.h"
 #include "tensor.h"
+#include "color.h"
+#include "clifford.h"
 #endif // ndef GINAC_BASE_ONLY
 
 #ifdef __MAKECINT__
 #endif // ndef GINAC_BASE_ONLY
 
 #ifdef __MAKECINT__
index 89373cc465ad4a770607cc98de49f55d95c563b5..994d532ecc80c1da10729b58ffadeefc87f35fee 100644 (file)
@@ -62,17 +62,8 @@ void varidx::copy(const varidx & other)
        covariant = other.covariant;
 }
 
        covariant = other.covariant;
 }
 
-void idx::destroy(bool call_parent)
-{
-       if (call_parent)
-               inherited::destroy(call_parent);
-}
-
-void varidx::destroy(bool call_parent)
-{
-       if (call_parent)
-               inherited::destroy(call_parent);
-}
+DEFAULT_DESTROY(idx)
+DEFAULT_DESTROY(varidx)
 
 //////////
 // other constructors
 
 //////////
 // other constructors
@@ -109,16 +100,6 @@ varidx::varidx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst
        n.find_bool("covariant", covariant);
 }
 
        n.find_bool("covariant", covariant);
 }
 
-ex idx::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new idx(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-ex varidx::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new varidx(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
 void idx::archive(archive_node &n) const
 {
        inherited::archive(n);
 void idx::archive(archive_node &n) const
 {
        inherited::archive(n);
@@ -132,6 +113,9 @@ void varidx::archive(archive_node &n) const
        n.add_bool("covariant", covariant);
 }
 
        n.add_bool("covariant", covariant);
 }
 
+DEFAULT_UNARCHIVE(idx)
+DEFAULT_UNARCHIVE(varidx)
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index 27379fec258572b7cc8606a8dc0875e7071d53e6..dfd9a3812876c9707e9e35a0f6ae03e1dddddf15 100644 (file)
@@ -52,11 +52,7 @@ void indexed::copy(const indexed & other)
        symmetry = other.symmetry;
 }
 
        symmetry = other.symmetry;
 }
 
-void indexed::destroy(bool call_parent)
-{
-       if (call_parent)
-               inherited::destroy(call_parent);
-}
+DEFAULT_DESTROY(indexed)
 
 //////////
 // other constructors
 
 //////////
 // other constructors
@@ -159,7 +155,6 @@ indexed::indexed(symmetry_type symm, exvector * vp) : inherited(vp), symmetry(sy
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
 indexed::indexed(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("indexed constructor from archive_node", LOGLEVEL_CONSTRUCT);
 indexed::indexed(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("indexed constructor from archive_node", LOGLEVEL_CONSTRUCT);
@@ -168,19 +163,14 @@ indexed::indexed(const archive_node &n, const lst &sym_lst) : inherited(n, sym_l
                throw (std::runtime_error("unknown indexed symmetry type in archive"));
 }
 
                throw (std::runtime_error("unknown indexed symmetry type in archive"));
 }
 
-/** Unarchive the object. */
-ex indexed::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new indexed(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
 void indexed::archive(archive_node &n) const
 {
        inherited::archive(n);
        n.add_unsigned("symmetry", symmetry);
 }
 
 void indexed::archive(archive_node &n) const
 {
        inherited::archive(n);
        n.add_unsigned("symmetry", symmetry);
 }
 
+DEFAULT_UNARCHIVE(indexed)
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index cc80f7cae43b66d1223f0364acdac57ba533cf9f..380a45e718b047a9c44db0bf2aa980813d03d012 100644 (file)
@@ -44,8 +44,6 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(matrix, basic)
 // default ctor, dtor, copy ctor, assignment operator and helpers:
 //////////
 
 // default ctor, dtor, copy ctor, assignment operator and helpers:
 //////////
 
-// public
-
 /** Default ctor.  Initializes to 1 x 1-dimensional zero-matrix. */
 matrix::matrix() : inherited(TINFO_matrix), row(1), col(1)
 {
 /** Default ctor.  Initializes to 1 x 1-dimensional zero-matrix. */
 matrix::matrix() : inherited(TINFO_matrix), row(1), col(1)
 {
@@ -53,9 +51,6 @@ matrix::matrix() : inherited(TINFO_matrix), row(1), col(1)
        m.push_back(_ex0());
 }
 
        m.push_back(_ex0());
 }
 
-// protected
-
-/** For use by copy ctor and assignment operator. */
 void matrix::copy(const matrix & other)
 {
        inherited::copy(other);
 void matrix::copy(const matrix & other)
 {
        inherited::copy(other);
@@ -64,10 +59,7 @@ void matrix::copy(const matrix & other)
        m = other.m;  // STL's vector copying invoked here
 }
 
        m = other.m;  // STL's vector copying invoked here
 }
 
-void matrix::destroy(bool call_parent)
-{
-       if (call_parent) inherited::destroy(call_parent);
-}
+DEFAULT_DESTROY(matrix)
 
 //////////
 // other ctors
 
 //////////
 // other ctors
@@ -118,7 +110,6 @@ matrix::matrix(unsigned r, unsigned c, const lst & l)
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
 matrix::matrix(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("matrix ctor from archive_node", LOGLEVEL_CONSTRUCT);
 matrix::matrix(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("matrix ctor from archive_node", LOGLEVEL_CONSTRUCT);
@@ -134,13 +125,6 @@ matrix::matrix(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst
        }
 }
 
        }
 }
 
-/** Unarchive the object. */
-ex matrix::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new matrix(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
 void matrix::archive(archive_node &n) const
 {
        inherited::archive(n);
 void matrix::archive(archive_node &n) const
 {
        inherited::archive(n);
@@ -153,6 +137,8 @@ void matrix::archive(archive_node &n) const
        }
 }
 
        }
 }
 
+DEFAULT_UNARCHIVE(matrix)
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index 8eef91763736fe0a759a699a8d0d4670c7b99a84..e156a0fff00c5ad50ff05a91cd77e2fcde1721ea 100644 (file)
@@ -38,26 +38,14 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(mul, expairseq)
 // default ctor, dctor, copy ctor assignment operator and helpers
 //////////
 
 // default ctor, dctor, copy ctor assignment operator and helpers
 //////////
 
-// public
-
 mul::mul()
 {
        debugmsg("mul default ctor",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
 }
 
 mul::mul()
 {
        debugmsg("mul default ctor",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_mul;
 }
 
-// protected
-
-/** For use by copy ctor and assignment operator. */
-void mul::copy(const mul & other)
-{
-       inherited::copy(other);
-}
-
-void mul::destroy(bool call_parent)
-{
-       if (call_parent) inherited::destroy(call_parent);
-}
+DEFAULT_COPY(mul)
+DEFAULT_DESTROY(mul)
 
 //////////
 // other ctors
 
 //////////
 // other ctors
@@ -130,23 +118,7 @@ mul::mul(const ex & lh, const ex & mh, const ex & rh)
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
-mul::mul(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
-{
-       debugmsg("mul ctor from archive_node", LOGLEVEL_CONSTRUCT);
-}
-
-/** Unarchive the object. */
-ex mul::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new mul(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
-void mul::archive(archive_node &n) const
-{
-       inherited::archive(n);
-}
+DEFAULT_ARCHIVING(mul)
 
 //////////
 // functions overriding virtual functions from bases classes
 
 //////////
 // functions overriding virtual functions from bases classes
index 44c5d30e074a686873f4e866a7c7a54782098bcb..12c1d5e41fcf799eae4485967196222989a282a1 100644 (file)
@@ -40,25 +40,14 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(ncmul, exprseq)
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 
-// public
-
 ncmul::ncmul()
 {
        debugmsg("ncmul default constructor",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_ncmul;
 }
 
 ncmul::ncmul()
 {
        debugmsg("ncmul default constructor",LOGLEVEL_CONSTRUCT);
        tinfo_key = TINFO_ncmul;
 }
 
-// protected
-
-void ncmul::copy(const ncmul & other)
-{
-       inherited::copy(other);
-}
-
-void ncmul::destroy(bool call_parent)
-{
-       if (call_parent) inherited::destroy(call_parent);
-}
+DEFAULT_COPY(ncmul)
+DEFAULT_DESTROY(ncmul)
 
 //////////
 // other constructors
 
 //////////
 // other constructors
@@ -115,24 +104,7 @@ ncmul::ncmul(exvector * vp) : inherited(vp)
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
-ncmul::ncmul(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
-{
-       debugmsg("ncmul constructor from archive_node", LOGLEVEL_CONSTRUCT);
-}
-
-/** Unarchive the object. */
-ex ncmul::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new ncmul(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
-void ncmul::archive(archive_node &n) const
-{
-       inherited::archive(n);
-}
-
+DEFAULT_ARCHIVING(ncmul)
        
 //////////
 // functions overriding virtual functions from bases classes
        
 //////////
 // functions overriding virtual functions from bases classes
@@ -336,7 +308,7 @@ ex ncmul::eval(int level) const
        //                      *(c1,c2,ncmul(...)) (pull out commutative elements)
        //                  ncmul(x1,y1,x2,y2) -> *(ncmul(x1,x2),ncmul(y1,y2))
        //                      (collect elements of same type)
        //                      *(c1,c2,ncmul(...)) (pull out commutative elements)
        //                  ncmul(x1,y1,x2,y2) -> *(ncmul(x1,x2),ncmul(y1,y2))
        //                      (collect elements of same type)
-       //                  ncmul(x1,x2,x3,...) -> x::eval_ncmul(x1,x2,x3,...)
+       //                  ncmul(x1,x2,x3,...) -> x::simplify_ncmul(x1,x2,x3,...)
        // the following rule would be nice, but produces a recursion,
        // which must be trapped by introducing a flag that the sub-ncmuls()
        // are already evaluated (maybe later...)
        // the following rule would be nice, but produces a recursion,
        // which must be trapped by introducing a flag that the sub-ncmuls()
        // are already evaluated (maybe later...)
index 995672e3c3372a845d3a250f1b95321a1a4eb02b..a4a40c8c013dbaf3765d2b9cacb75f435db19548 100644 (file)
@@ -72,8 +72,6 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(numeric, basic)
 // operator and helpers
 //////////
 
 // operator and helpers
 //////////
 
-// public
-
 /** default ctor. Numerically it initializes to an integer zero. */
 numeric::numeric() : basic(TINFO_numeric)
 {
 /** default ctor. Numerically it initializes to an integer zero. */
 numeric::numeric() : basic(TINFO_numeric)
 {
@@ -82,19 +80,13 @@ numeric::numeric() : basic(TINFO_numeric)
        setflag(status_flags::evaluated | status_flags::expanded);
 }
 
        setflag(status_flags::evaluated | status_flags::expanded);
 }
 
-// protected
-
-/** For use by copy ctor and assignment operator. */
 void numeric::copy(const numeric &other)
 {
        inherited::copy(other);
        value = other.value;
 }
 
 void numeric::copy(const numeric &other)
 {
        inherited::copy(other);
        value = other.value;
 }
 
-void numeric::destroy(bool call_parent)
-{
-       if (call_parent) inherited::destroy(call_parent);
-}
+DEFAULT_DESTROY(numeric)
 
 //////////
 // other ctors
 
 //////////
 // other ctors
@@ -266,7 +258,6 @@ numeric::numeric(const cln::cl_N &z) : basic(TINFO_numeric)
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
 numeric::numeric(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("numeric ctor from archive_node", LOGLEVEL_CONSTRUCT);
 numeric::numeric(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("numeric ctor from archive_node", LOGLEVEL_CONSTRUCT);
@@ -304,13 +295,6 @@ numeric::numeric(const archive_node &n, const lst &sym_lst) : inherited(n, sym_l
        setflag(status_flags::evaluated | status_flags::expanded);
 }
 
        setflag(status_flags::evaluated | status_flags::expanded);
 }
 
-/** Unarchive the object. */
-ex numeric::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new numeric(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
 void numeric::archive(archive_node &n) const
 {
        inherited::archive(n);
 void numeric::archive(archive_node &n) const
 {
        inherited::archive(n);
@@ -348,6 +332,8 @@ void numeric::archive(archive_node &n) const
 #endif
 }
 
 #endif
 }
 
+DEFAULT_UNARCHIVE(numeric)
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index b0f9cd2d293aad258475067ee4693a820e671f9a..14fac0ad1dce7b3202a9b741656500a12966b482 100644 (file)
@@ -46,15 +46,11 @@ typedef std::vector<int> intvector;
 // default ctor, dtor, copy ctor assignment operator and helpers
 //////////
 
 // default ctor, dtor, copy ctor assignment operator and helpers
 //////////
 
-// public
-
 power::power() : basic(TINFO_power)
 {
        debugmsg("power default ctor",LOGLEVEL_CONSTRUCT);
 }
 
 power::power() : basic(TINFO_power)
 {
        debugmsg("power default ctor",LOGLEVEL_CONSTRUCT);
 }
 
-// protected
-
 void power::copy(const power & other)
 {
        inherited::copy(other);
 void power::copy(const power & other)
 {
        inherited::copy(other);
@@ -62,17 +58,12 @@ void power::copy(const power & other)
        exponent = other.exponent;
 }
 
        exponent = other.exponent;
 }
 
-void power::destroy(bool call_parent)
-{
-       if (call_parent) inherited::destroy(call_parent);
-}
+DEFAULT_DESTROY(power)
 
 //////////
 // other ctors
 //////////
 
 
 //////////
 // other ctors
 //////////
 
-// public
-
 power::power(const ex & lh, const ex & rh) : basic(TINFO_power), basis(lh), exponent(rh)
 {
        debugmsg("power ctor from ex,ex",LOGLEVEL_CONSTRUCT);
 power::power(const ex & lh, const ex & rh) : basic(TINFO_power), basis(lh), exponent(rh)
 {
        debugmsg("power ctor from ex,ex",LOGLEVEL_CONSTRUCT);
@@ -89,7 +80,6 @@ power::power(const ex & lh, const numeric & rh) : basic(TINFO_power), basis(lh),
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
 power::power(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("power ctor from archive_node", LOGLEVEL_CONSTRUCT);
 power::power(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("power ctor from archive_node", LOGLEVEL_CONSTRUCT);
@@ -97,13 +87,6 @@ power::power(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
        n.find_ex("exponent", exponent, sym_lst);
 }
 
        n.find_ex("exponent", exponent, sym_lst);
 }
 
-/** Unarchive the object. */
-ex power::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new power(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
 void power::archive(archive_node &n) const
 {
        inherited::archive(n);
 void power::archive(archive_node &n) const
 {
        inherited::archive(n);
@@ -111,6 +94,8 @@ void power::archive(archive_node &n) const
        n.add_ex("exponent", exponent);
 }
 
        n.add_ex("exponent", exponent);
 }
 
+DEFAULT_UNARCHIVE(power)
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index 3b2ac7010e051a5d2b49fb2dd90e65aab7c24b82..5a92218335a0689777b518f54815bbad044d81de 100644 (file)
@@ -39,6 +39,7 @@ namespace GiNaC {
 
 GINAC_IMPLEMENT_REGISTERED_CLASS(pseries, basic)
 
 
 GINAC_IMPLEMENT_REGISTERED_CLASS(pseries, basic)
 
+
 /*
  *  Default ctor, dtor, copy ctor, assignment operator and helpers
  */
 /*
  *  Default ctor, dtor, copy ctor, assignment operator and helpers
  */
@@ -56,11 +57,7 @@ void pseries::copy(const pseries &other)
        point = other.point;
 }
 
        point = other.point;
 }
 
-void pseries::destroy(bool call_parent)
-{
-       if (call_parent)
-               inherited::destroy(call_parent);
-}
+DEFAULT_DESTROY(pseries)
 
 
 /*
 
 
 /*
@@ -90,7 +87,6 @@ pseries::pseries(const ex &rel_, const epvector &ops_) : basic(TINFO_pseries), s
  *  Archiving
  */
 
  *  Archiving
  */
 
-/** Construct object from archive_node. */
 pseries::pseries(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("pseries ctor from archive_node", LOGLEVEL_CONSTRUCT);
 pseries::pseries(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("pseries ctor from archive_node", LOGLEVEL_CONSTRUCT);
@@ -106,13 +102,6 @@ pseries::pseries(const archive_node &n, const lst &sym_lst) : inherited(n, sym_l
        n.find_ex("point", point, sym_lst);
 }
 
        n.find_ex("point", point, sym_lst);
 }
 
-/** Unarchive the object. */
-ex pseries::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new pseries(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
 void pseries::archive(archive_node &n) const
 {
        inherited::archive(n);
 void pseries::archive(archive_node &n) const
 {
        inherited::archive(n);
@@ -126,6 +115,8 @@ void pseries::archive(archive_node &n) const
        n.add_ex("point", point);
 }
 
        n.add_ex("point", point);
 }
 
+DEFAULT_UNARCHIVE(pseries)
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index 20ff40b8386a7e3460e90b2366501b7fe5cafd65..6c417deac403fc746a5e28266c58e4185b3a46fd 100644 (file)
@@ -36,15 +36,11 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(relational, basic)
 // default ctor, dtor, copy ctor assignment operator and helpers
 //////////
 
 // default ctor, dtor, copy ctor assignment operator and helpers
 //////////
 
-// public
-
 relational::relational() : basic(TINFO_relational)
 {
        debugmsg("relational default ctor",LOGLEVEL_CONSTRUCT);
 }
 
 relational::relational() : basic(TINFO_relational)
 {
        debugmsg("relational default ctor",LOGLEVEL_CONSTRUCT);
 }
 
-// protected
-
 void relational::copy(const relational & other)
 {
        basic::copy(other);
 void relational::copy(const relational & other)
 {
        basic::copy(other);
@@ -53,10 +49,7 @@ void relational::copy(const relational & other)
        o=other.o;
 }
 
        o=other.o;
 }
 
-void relational::destroy(bool call_parent)
-{
-       if (call_parent) basic::destroy(call_parent);
-}
+DEFAULT_DESTROY(relational)
 
 //////////
 // other ctors
 
 //////////
 // other ctors
@@ -76,7 +69,6 @@ relational::relational(const ex & lhs, const ex & rhs, operators oper) : basic(T
 // archiving
 //////////
 
 // archiving
 //////////
 
-/** Construct object from archive_node. */
 relational::relational(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("relational ctor from archive_node", LOGLEVEL_CONSTRUCT);
 relational::relational(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
        debugmsg("relational ctor from archive_node", LOGLEVEL_CONSTRUCT);
@@ -88,13 +80,6 @@ relational::relational(const archive_node &n, const lst &sym_lst) : inherited(n,
        n.find_ex("rh", rh, sym_lst);
 }
 
        n.find_ex("rh", rh, sym_lst);
 }
 
-/** Unarchive the object. */
-ex relational::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new relational(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
 void relational::archive(archive_node &n) const
 {
        inherited::archive(n);
 void relational::archive(archive_node &n) const
 {
        inherited::archive(n);
@@ -103,6 +88,8 @@ void relational::archive(archive_node &n) const
        n.add_unsigned("op", o);
 }
 
        n.add_unsigned("op", o);
 }
 
+DEFAULT_UNARCHIVE(relational)
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index e9c3b0213f45cb9055cbd2f3404604b4325328b7..0bd1d4fb6e869e178a760470df0af0967d721e3a 100644 (file)
@@ -25,6 +25,7 @@
 #include "structure.h"
 #include "archive.h"
 #include "debugmsg.h"
 #include "structure.h"
 #include "archive.h"
 #include "debugmsg.h"
+#include "utils.h"
 
 namespace GiNaC {
 
 
 namespace GiNaC {
 
@@ -34,60 +35,18 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(structure, basic)
 // default ctor, dtor, copy ctor assignment operator and helpers
 //////////
 
 // default ctor, dtor, copy ctor assignment operator and helpers
 //////////
 
-// public
-
-structure::structure()
-{
-       debugmsg("structure default ctor",LOGLEVEL_CONSTRUCT);
-       tinfo_key = TINFO_structure;
-}
-
-// protected
-
-void structure::copy(const structure & other)
-{
-       basic::copy(other);
-}
-
-void structure::destroy(bool call_parent)
-{
-       if (call_parent) basic::destroy(call_parent);
-}
-
-//////////
-// other ctors
-//////////
-
-// none
+DEFAULT_CTORS(structure)
 
 //////////
 // archiving
 //////////
 
 
 //////////
 // archiving
 //////////
 
-/** Construct object from archive_node. */
-structure::structure(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
-{
-       debugmsg("structure ctor from archive_node", LOGLEVEL_CONSTRUCT);
-}
-
-/** Unarchive the object. */
-ex structure::unarchive(const archive_node &n, const lst &sym_lst)
-{
-       return (new structure(n, sym_lst))->setflag(status_flags::dynallocated);
-}
-
-/** Archive the object. */
-void structure::archive(archive_node &n) const
-{
-       inherited::archive(n);
-}
+DEFAULT_ARCHIVING(structure)
 
 //////////
 
 //////////
-// structures overriding virtual structures from bases classes
+// functions overriding virtual functions from bases classes
 //////////
 
 //////////
 
-// public
-
 void structure::printraw(std::ostream & os) const
 {
        debugmsg("structure printraw",LOGLEVEL_PRINT);
 void structure::printraw(std::ostream & os) const
 {
        debugmsg("structure printraw",LOGLEVEL_PRINT);
@@ -121,11 +80,7 @@ void structure::printcsrc(std::ostream & os, unsigned type, unsigned upper_prece
 
 // protected
 
 
 // protected
 
-int structure::compare_same_type(const basic & other) const
-{
-       GINAC_ASSERT(is_of_type(other, structure));
-       return 0; // all structures are the same
-}
+DEFAULT_COMPARE(structure)
 
 bool structure::is_equal_same_type(const basic & other) const
 {
 
 bool structure::is_equal_same_type(const basic & other) const
 {
@@ -134,13 +89,7 @@ bool structure::is_equal_same_type(const basic & other) const
 }
 
 //////////
 }
 
 //////////
-// new virtual structures which can be overridden by derived classes
-//////////
-
-// none
-
-//////////
-// non-virtual structures in this class
+// non-virtual functions in this class
 //////////
 
 // protected
 //////////
 
 // protected
index 12b86d1c4a1b8f6c7f241e82b25c47ce5d1caac8..9ad049fda6fdc7bbdddcedc19c22eaead38fa1ef 100644 (file)
@@ -41,9 +41,6 @@ class structure : public basic
 {
        GINAC_DECLARE_REGISTERED_CLASS(structure, basic)
        
 {
        GINAC_DECLARE_REGISTERED_CLASS(structure, basic)
        
-       // other ctors
-       // none
-
        // functions overriding virtual functions from bases classes
 public:
        void printraw(std::ostream & os) const; 
        // functions overriding virtual functions from bases classes
 public:
        void printraw(std::ostream & os) const; 
@@ -53,18 +50,11 @@ public:
 protected:
        bool is_equal_same_type(const basic & other) const;
        
 protected:
        bool is_equal_same_type(const basic & other) const;
        
-       // new virtual functions which can be overridden by derived classes
-       // none
-       
        // non-virtual functions in this class
 protected:
        static std::vector<registered_structure_info> & registered_structures(void);
 public:
        static unsigned register_new(const char * nm);
        // non-virtual functions in this class
 protected:
        static std::vector<registered_structure_info> & registered_structures(void);
 public:
        static unsigned register_new(const char * nm);
-
-// member variables
-// none
-
 };
 
 } // namespace GiNaC
 };
 
 } // namespace GiNaC
index 0e6b116250e69281283c012650dc674253c2ff97..ed6ad9dc4fbe373ac590d40b6ab48e64d424cbf2 100644 (file)
@@ -44,24 +44,6 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(tensepsilon, tensor)
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 
-#define DEFAULT_DESTROY(classname) \
-void classname::destroy(bool call_parent) \
-{ \
-       if (call_parent) \
-               inherited::destroy(call_parent); \
-}
-
-#define DEFAULT_CTORS(classname) \
-classname::classname() : inherited(TINFO_##classname) \
-{ \
-       debugmsg(#classname " default constructor", LOGLEVEL_CONSTRUCT); \
-} \
-void classname::copy(const classname & other) \
-{ \
-       inherited::copy(other); \
-} \
-DEFAULT_DESTROY(classname)
-
 tensor::tensor(unsigned ti) : inherited(ti)
 {
        debugmsg("tensor constructor from unsigned", LOGLEVEL_CONSTRUCT); \
 tensor::tensor(unsigned ti) : inherited(ti)
 {
        debugmsg("tensor constructor from unsigned", LOGLEVEL_CONSTRUCT); \
@@ -114,23 +96,6 @@ void tensepsilon::copy(const tensepsilon & other)
 // archiving
 //////////
 
 // archiving
 //////////
 
-#define DEFAULT_UNARCHIVE(classname) \
-ex classname::unarchive(const archive_node &n, const 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) \
-{ \
-       debugmsg(#classname " constructor from archive_node", LOGLEVEL_CONSTRUCT); \
-} \
-DEFAULT_UNARCHIVE(classname) \
-void classname::archive(archive_node &n) const \
-{ \
-       inherited::archive(n); \
-}
-
 DEFAULT_ARCHIVING(tensor)
 DEFAULT_ARCHIVING(tensdelta)
 DEFAULT_ARCHIVING(tensmetric)
 DEFAULT_ARCHIVING(tensor)
 DEFAULT_ARCHIVING(tensdelta)
 DEFAULT_ARCHIVING(tensmetric)
@@ -167,13 +132,6 @@ void tensepsilon::archive(archive_node &n) const
 // functions overriding virtual functions from bases classes
 //////////
 
 // functions overriding virtual functions from bases classes
 //////////
 
-#define DEFAULT_COMPARE(classname) \
-int classname::compare_same_type(const basic & other) const \
-{ \
-       /* by default, two tensors of the same class are always identical */ \
-       return 0; \
-}
-
 DEFAULT_COMPARE(tensor)
 DEFAULT_COMPARE(tensdelta)
 DEFAULT_COMPARE(tensmetric)
 DEFAULT_COMPARE(tensor)
 DEFAULT_COMPARE(tensdelta)
 DEFAULT_COMPARE(tensmetric)
@@ -202,29 +160,10 @@ int tensepsilon::compare_same_type(const basic & other) const
                return inherited::compare_same_type(other);
 }
 
                return inherited::compare_same_type(other);
 }
 
-void tensdelta::print(std::ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("tensdelta print",LOGLEVEL_PRINT);
-       os << "delta";
-}
-
-void tensmetric::print(std::ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("tensmetric print",LOGLEVEL_PRINT);
-       os << "g";
-}
-
-void minkmetric::print(std::ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("minkmetric print",LOGLEVEL_PRINT);
-       os << "eta";
-}
-
-void tensepsilon::print(std::ostream & os, unsigned upper_precedence) const
-{
-       debugmsg("tensepsilon print",LOGLEVEL_PRINT);
-       os << "eps";
-}
+DEFAULT_PRINT(tensdelta, "delta")
+DEFAULT_PRINT(tensmetric, "g")
+DEFAULT_PRINT(minkmetric, "eta")
+DEFAULT_PRINT(tensepsilon, "eps")
 
 /** Automatic symbolic evaluation of an indexed delta tensor. */
 ex tensdelta::eval_indexed(const basic & i) const
 
 /** Automatic symbolic evaluation of an indexed delta tensor. */
 ex tensdelta::eval_indexed(const basic & i) const
index 2b189595d5ae5f96442cafd6a736f94d458f1d5f..767285576bfb19eba4ce71ffc291621e7eb910c2 100644 (file)
@@ -53,6 +53,8 @@ const unsigned TINFO_numeric       = 0x00090001U;
 const unsigned TINFO_pseries       = 0x000a0001U;
 
 const unsigned TINFO_indexed       = 0x000b0001U;
 const unsigned TINFO_pseries       = 0x000a0001U;
 
 const unsigned TINFO_indexed       = 0x000b0001U;
+const unsigned TINFO_color         = 0x000b1001U;
+const unsigned TINFO_clifford      = 0x000b1002U;
 
 const unsigned TINFO_structure     = 0x000c0001U;
 // reserved up to                    0x000cffffU
 
 const unsigned TINFO_structure     = 0x000c0001U;
 // reserved up to                    0x000cffffU
@@ -66,6 +68,11 @@ const unsigned TINFO_tensdelta     = 0x000e1001U;
 const unsigned TINFO_tensmetric    = 0x000e1002U;
 const unsigned TINFO_minkmetric    = 0x000e2001U;
 const unsigned TINFO_tensepsilon   = 0x000e1003U;
 const unsigned TINFO_tensmetric    = 0x000e1002U;
 const unsigned TINFO_minkmetric    = 0x000e2001U;
 const unsigned TINFO_tensepsilon   = 0x000e1003U;
+const unsigned TINFO_su3one        = 0x000e1008U;
+const unsigned TINFO_su3t          = 0x000e1009U;
+const unsigned TINFO_su3f          = 0x000e100aU;
+const unsigned TINFO_su3d          = 0x000e100bU;
+const unsigned TINFO_diracgamma    = 0x000e100cU;
 
 } // namespace GiNaC
 
 
 } // namespace GiNaC
 
index 5f34d02534bcf04e02708853dab8b40adcf5d703..6e1d3ae8a55caa31987db800a2da7180fe712bba 100644 (file)
@@ -243,6 +243,61 @@ const ex & _ex60(void);
 const numeric & _num120(void);    //  120
 const ex & _ex120(void);
 
 const numeric & _num120(void);    //  120
 const ex & _ex120(void);
 
+
+// Helper macros for class implementations (mostly useful for trivial classes)
+
+#define DEFAULT_COPY(classname) \
+void classname::copy(const classname & other) \
+{ \
+       inherited::copy(other); \
+}
+
+#define DEFAULT_DESTROY(classname) \
+void classname::destroy(bool call_parent) \
+{ \
+       if (call_parent) \
+               inherited::destroy(call_parent); \
+}
+
+#define DEFAULT_CTORS(classname) \
+classname::classname() : inherited(TINFO_##classname) \
+{ \
+       debugmsg(#classname " default constructor", LOGLEVEL_CONSTRUCT); \
+} \
+DEFAULT_COPY(classname) \
+DEFAULT_DESTROY(classname)
+
+#define DEFAULT_UNARCHIVE(classname) \
+ex classname::unarchive(const archive_node &n, const 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) \
+{ \
+       debugmsg(#classname " constructor from archive_node", LOGLEVEL_CONSTRUCT); \
+} \
+DEFAULT_UNARCHIVE(classname) \
+void classname::archive(archive_node &n) const \
+{ \
+       inherited::archive(n); \
+}
+
+#define DEFAULT_COMPARE(classname) \
+int classname::compare_same_type(const basic & other) const \
+{ \
+       /* by default, the objects are always identical */ \
+       return 0; \
+}
+
+#define DEFAULT_PRINT(classname, text) \
+void classname::print(std::ostream & os, unsigned upper_precedence) const \
+{ \
+       debugmsg(#classname " print", LOGLEVEL_PRINT); \
+       os << text; \
+}
+
 } // namespace GiNaC
 
 #endif // ndef __GINAC_UTILS_H__
 } // namespace GiNaC
 
 #endif // ndef __GINAC_UTILS_H__