inifcns_trans.cpp inifcns_gamma.cpp inifcns_nstdsums.cpp \
integral.cpp lst.cpp matrix.cpp mul.cpp ncmul.cpp normal.cpp numeric.cpp \
operators.cpp power.cpp registrar.cpp relational.cpp remember.cpp \
- pseries.cpp print.cpp structure.cpp symbol.cpp symmetry.cpp tensor.cpp \
+ pseries.cpp print.cpp symbol.cpp symmetry.cpp tensor.cpp \
utils.cpp wildcard.cpp input_parser.yy input_lexer.ll \
input_lexer.h remember.h tostring.h utils.h
libginac_la_LDFLAGS = -version-info $(LT_VERSION_INFO) -release $(LT_RELEASE)
exprseq.h fail.h fderivative.h flags.h function.h hash_map.h idx.h indexed.h \
inifcns.h integral.h lst.h matrix.h mul.h ncmul.h normal.h numeric.h operators.h \
power.h print.h pseries.h ptr.h registrar.h relational.h structure.h \
- symbol.h symmetry.h tensor.h tinfos.h version.h wildcard.h
+ symbol.h symmetry.h tensor.h version.h wildcard.h
AM_LFLAGS = -Pginac_yy -olex.yy.c
AM_YFLAGS = -p ginac_yy -d
EXTRA_DIST = function.pl input_parser.h version.h.in
* Implementation of GiNaC's sums of expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
add::add()
{
- tinfo_key = TINFO_add;
+ tinfo_key = &add::tinfo_static;
}
//////////
add::add(const ex & lh, const ex & rh)
{
- tinfo_key = TINFO_add;
+ tinfo_key = &add::tinfo_static;
overall_coeff = _ex0;
construct_from_2_ex(lh,rh);
GINAC_ASSERT(is_canonical());
add::add(const exvector & v)
{
- tinfo_key = TINFO_add;
+ tinfo_key = &add::tinfo_static;
overall_coeff = _ex0;
construct_from_exvector(v);
GINAC_ASSERT(is_canonical());
add::add(const epvector & v)
{
- tinfo_key = TINFO_add;
+ tinfo_key = &add::tinfo_static;
overall_coeff = _ex0;
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
add::add(const epvector & v, const ex & oc)
{
- tinfo_key = TINFO_add;
+ tinfo_key = &add::tinfo_static;
overall_coeff = oc;
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
add::add(std::auto_ptr<epvector> vp, const ex & oc)
{
- tinfo_key = TINFO_add;
+ tinfo_key = &add::tinfo_static;
GINAC_ASSERT(vp.get()!=0);
overall_coeff = oc;
construct_from_epvector(*vp);
return seq.begin()->rest.return_type();
}
-unsigned add::return_type_tinfo() const
+const basic* add::return_type_tinfo() const
{
if (seq.empty())
- return tinfo_key;
+ return this;
else
return seq.begin()->rest.return_type_tinfo();
}
* Interface to GiNaC's sums of expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
protected:
ex derivative(const symbol & s) const;
unsigned return_type() const;
- unsigned return_type_tinfo() const;
+ const basic* return_type_tinfo() const;
ex thisexpairseq(const epvector & v, const ex & oc) const;
ex thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc) const;
expair split_ex_to_pair(const ex & e) const;
void do_print_python_repr(const print_python_repr & c, unsigned level) const;
};
-// utility functions
-
-/** Specialization of is_exactly_a<add>(obj) for add objects. */
-template<> inline bool is_exactly_a<add>(const basic & obj)
-{
- return obj.tinfo()==TINFO_add;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_ADD_H__
* Implementation of GiNaC's ABC. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
return return_types::commutative;
}
-unsigned basic::return_type_tinfo() const
+const basic* basic::return_type_tinfo() const
{
- return tinfo();
+ return this;
}
/** Compute the hash value of an object and if it makes sense to store it in
* would all end up with the same hashvalue. */
unsigned basic::calchash() const
{
- unsigned v = golden_ratio_hash(tinfo());
+ unsigned v = golden_ratio_hash((unsigned)tinfo());
for (size_t i=0; i<nops(); i++) {
v = rotate_left(v);
v ^= this->op(i).gethash();
compare_statistics.compare_same_hashvalue++;
#endif
- const unsigned typeid_this = tinfo();
- const unsigned typeid_other = other.tinfo();
+ const tinfo_t typeid_this = tinfo();
+ const tinfo_t typeid_other = other.tinfo();
if (typeid_this==typeid_other) {
GINAC_ASSERT(typeid(*this)==typeid(other));
// int cmpval = compare_same_type(other);
* Interface to GiNaC's ABC. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
#include <algorithm>
#include "flags.h"
-#include "tinfos.h"
#include "ptr.h"
#include "assertion.h"
#include "registrar.h"
typedef std::vector<ex> exvector;
typedef std::map<ex, ex, ex_is_less> exmap;
-
// Define this to enable some statistical output for comparisons and hashing
#undef GINAC_COMPARE_STATISTICS
// default constructor, destructor, copy constructor and assignment operator
protected:
- basic() : tinfo_key(TINFO_basic), flags(0) {}
+ basic() : tinfo_key(&tinfo_static), flags(0) {}
public:
/** basic destructor, virtual because class ex will delete objects of
protected:
/** Constructor with specified tinfo_key (used by derived classes instead
* of the default constructor to avoid assigning tinfo_key twice). */
- basic(unsigned ti) : tinfo_key(ti), flags(0) {}
+ basic(tinfo_t ti) : tinfo_key(ti), flags(0) {}
// new virtual functions which can be overridden by derived classes
public: // only const functions please (may break reference counting)
// noncommutativity
virtual unsigned return_type() const;
- virtual unsigned return_type_tinfo() const;
+ virtual const basic* return_type_tinfo() const;
// complex conjugation
virtual ex conjugate() const;
}
}
- unsigned tinfo() const {return tinfo_key;}
+ tinfo_t tinfo() const {return tinfo_key;}
/** Set some status_flags. */
const basic & setflag(unsigned f) const {flags |= f; return *this;}
// member variables
protected:
- unsigned tinfo_key; ///< typeinfo
+ tinfo_t tinfo_key; ///< type info
mutable unsigned flags; ///< of type status_flags
mutable unsigned hashvalue; ///< hash value
};
return dynamic_cast<const T *>(&obj) != 0;
}
-/** Check if obj is a T, not including base classes. This one is just an
- * inefficient default. It should in all time-critical cases be overridden
- * by template specializations that use the TINFO_* constants directly. */
+/** Check if obj is a T, not including base classes. */
template <class T>
-inline bool is_exactly_a(const basic &obj)
+inline bool is_exactly_a(const basic & obj)
{
- return obj.tinfo() == T::get_class_info_static().options.get_id();
+ return obj.tinfo() == &T::tinfo_static;
}
} // namespace GiNaC
* Implementation of GiNaC's clifford algebra (Dirac gamma) objects. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
clifford::clifford() : representation_label(0), metric(0), anticommuting(true), commutator_sign(-1)
{
- tinfo_key = TINFO_clifford;
+ tinfo_key = &clifford::tinfo_static;
}
DEFAULT_CTOR(diracone)
* @see dirac_ONE */
clifford::clifford(const ex & b, unsigned char rl, bool anticommut) : inherited(b), representation_label(rl), metric(0), anticommuting(anticommut), commutator_sign(-1)
{
- tinfo_key = TINFO_clifford;
+ tinfo_key = &clifford::tinfo_static;
}
/** Construct object with one Lorentz index. This constructor is for internal
clifford::clifford(const ex & b, const ex & mu, const ex & metr, unsigned char rl, bool anticommut, int comm_sign) : inherited(b, mu), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign)
{
GINAC_ASSERT(is_a<varidx>(mu));
- tinfo_key = TINFO_clifford;
+ tinfo_key = &clifford::tinfo_static;
}
clifford::clifford(unsigned char rl, const ex & metr, bool anticommut, int comm_sign, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign)
{
- tinfo_key = TINFO_clifford;
+ tinfo_key = &clifford::tinfo_static;
}
clifford::clifford(unsigned char rl, const ex & metr, bool anticommut, int comm_sign, std::auto_ptr<exvector> vp) : inherited(not_symmetric(), vp), representation_label(rl), metric(metr), anticommuting(anticommut), commutator_sign(comm_sign)
{
- tinfo_key = TINFO_clifford;
+ tinfo_key = &clifford::tinfo_static;
}
//////////
return clifford(e, varidx(0, dim), indexed((new minkmetric)->setflag(status_flags::dynallocated), symmetric2(), xi, chi), rl, true);
}
-/** Check whether a given tinfo key (as returned by return_type_tinfo()
- * is that of a clifford object with the specified representation label. */
-static bool is_clifford_tinfo(unsigned ti, unsigned char rl)
-{
- return ti == (TINFO_clifford + rl);
-}
-
/** Check whether a given tinfo key (as returned by return_type_tinfo()
* is that of a clifford object (with an arbitrary representation label). */
-static bool is_clifford_tinfo(unsigned ti)
+static bool is_clifford_tinfo(const basic* ti)
{
- return (ti & ~0xff) == TINFO_clifford;
+ return ti->tinfo() == &clifford::tinfo_static;
}
/** Extract representation label from tinfo key (as returned by
* return_type_tinfo()). */
-static unsigned char get_representation_label(unsigned ti)
+static unsigned char get_representation_label(const basic* ti)
{
- return ti & 0xff;
+ return ((clifford*)ti)->get_representation_label();
}
/** Take trace of a string of an even number of Dirac gammas given a vector
* Interface to GiNaC's clifford algebra (Dirac gamma) objects. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
ex thiscontainer(const exvector & v) const;
ex thiscontainer(std::auto_ptr<exvector> vp) const;
unsigned return_type() const { return return_types::noncommutative; }
- unsigned return_type_tinfo() const { return TINFO_clifford + representation_label; }
+ const basic* return_type_tinfo() const { return this; }
// non-virtual functions in this class
public:
// other constructors
protected:
- cliffordunit(unsigned ti) : inherited(ti) {}
+ cliffordunit(tinfo_t ti) : inherited(ti) {}
// functions overriding virtual functions from base classes
public:
// global functions
-/** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
-template<> inline bool is_exactly_a<clifford>(const basic & obj)
-{
- return obj.tinfo()==TINFO_clifford;
-}
-
/** Create a Clifford unity object.
*
* @param rl Representation label
* Implementation of GiNaC's color (SU(3) Lie algebra) objects. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
color::color() : representation_label(0)
{
- tinfo_key = TINFO_color;
+ tinfo_key = &color::tinfo_static;
}
DEFAULT_CTOR(su3one)
* @see color_ONE */
color::color(const ex & b, unsigned char rl) : inherited(b), representation_label(rl)
{
- tinfo_key = TINFO_color;
+ tinfo_key = &color::tinfo_static;
}
/** Construct object with one color index. This constructor is for internal
* @see color_T */
color::color(const ex & b, const ex & i1, unsigned char rl) : inherited(b, i1), representation_label(rl)
{
- tinfo_key = TINFO_color;
+ tinfo_key = &color::tinfo_static;
}
color::color(unsigned char rl, const exvector & v, bool discardable) : inherited(not_symmetric(), v, discardable), representation_label(rl)
{
- tinfo_key = TINFO_color;
+ tinfo_key = &color::tinfo_static;
}
color::color(unsigned char rl, std::auto_ptr<exvector> vp) : inherited(not_symmetric(), vp), representation_label(rl)
{
- tinfo_key = TINFO_color;
+ tinfo_key = &color::tinfo_static;
}
//////////
return color_d(a, b, c) + I * color_f(a, b, c);
}
-/** Check whether a given tinfo key (as returned by return_type_tinfo()
- * is that of a color object with the specified representation label. */
-static bool is_color_tinfo(unsigned ti, unsigned char rl)
-{
- return ti == (TINFO_color + rl);
-}
-
/** Check whether a given tinfo key (as returned by return_type_tinfo()
* is that of a color object (with an arbitrary representation label). */
-static bool is_color_tinfo(unsigned ti)
+static bool is_color_tinfo(const basic* ti)
{
- return (ti & ~0xff) == TINFO_color;
+ return ti->tinfo() == &color::tinfo_static;
}
/** Extract representation label from tinfo key (as returned by
* return_type_tinfo()). */
-static unsigned char get_representation_label(unsigned ti)
+static unsigned char get_representation_label(const basic* ti)
{
- return ti & 0xff;
+ return ((color*)ti)->get_representation_label();
}
ex color_trace(const ex & e, const std::set<unsigned char> & rls)
* Interface to GiNaC's color (SU(3) Lie algebra) objects. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
ex thiscontainer(const exvector & v) const;
ex thiscontainer(std::auto_ptr<exvector> vp) const;
unsigned return_type() const { return return_types::noncommutative; }
- unsigned return_type_tinfo() const { return TINFO_color + representation_label; }
+ const basic* return_type_tinfo() const { return this; }
// non-virtual functions in this class
public:
// global functions
-/** Specialization of is_exactly_a<color>(obj) for color objects. */
-template<> inline bool is_exactly_a<color>(const basic & obj)
-{
- return obj.tinfo()==TINFO_color;
-}
-
/** Create the su(3) unity element. This is an indexed object, although it
* has no indices.
*
* Implementation of GiNaC's constant types and some special constants. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// public
-constant::constant() : basic(TINFO_constant), ef(0), serial(next_serial++)
+constant::constant() : basic(&constant::tinfo_static), ef(0), serial(next_serial++)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
// public
constant::constant(const std::string & initname, evalffunctype efun, const std::string & texname)
- : basic(TINFO_constant), name(initname), ef(efun), serial(next_serial++)
+ : basic(&constant::tinfo_static), name(initname), ef(efun), serial(next_serial++)
{
if (texname.empty())
TeX_name = "\\mbox{" + name + "}";
}
constant::constant(const std::string & initname, const numeric & initnumber, const std::string & texname)
- : basic(TINFO_constant), name(initname), ef(0), number(initnumber), serial(next_serial++)
+ : basic(&constant::tinfo_static), name(initname), ef(0), number(initnumber), serial(next_serial++)
{
if (texname.empty())
TeX_name = "\\mbox{" + name + "}";
unsigned constant::calchash() const
{
- hashvalue = golden_ratio_hash(tinfo() ^ serial);
+ hashvalue = golden_ratio_hash((unsigned)tinfo() ^ serial);
setflag(status_flags::hash_calculated);
* Interface to GiNaC's constant types and some special constants. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
extern const constant Catalan;
extern const constant Euler;
-// utility functions
-
-/** Specialization of is_exactly_a<constant>(obj) for constant objects. */
-template<> inline bool is_exactly_a<constant>(const basic & obj)
-{
- return obj.tinfo()==TINFO_constant;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_CONSTANT_H__
* Wrapper template for making GiNaC classes out of STL containers. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
protected:
// helpers
- static unsigned get_tinfo() { return TINFO_fail; }
+ static tinfo_t get_tinfo() { return NULL; }
static unsigned get_default_flags() { return 0; }
static char get_open_delim() { return '('; }
static char get_close_delim() { return ')'; }
* Interface to GiNaC's light-weight expression handles. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// noncommutativity
unsigned return_type() const { return bp->return_type(); }
- unsigned return_type_tinfo() const { return bp->return_type_tinfo(); }
+ const basic* return_type_tinfo() const { return bp->return_type_tinfo(); }
unsigned gethash() const { return bp->gethash(); }
* Implementation of sequences of expression pairs. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// public
-expairseq::expairseq() : inherited(TINFO_expairseq)
+expairseq::expairseq() : inherited(&expairseq::tinfo_static)
#if EXPAIRSEQ_USE_HASHTAB
, hashtabsize(0)
#endif // EXPAIRSEQ_USE_HASHTAB
// other constructors
//////////
-expairseq::expairseq(const ex &lh, const ex &rh) : inherited(TINFO_expairseq)
+expairseq::expairseq(const ex &lh, const ex &rh) : inherited(&expairseq::tinfo_static)
{
construct_from_2_ex(lh,rh);
GINAC_ASSERT(is_canonical());
}
-expairseq::expairseq(const exvector &v) : inherited(TINFO_expairseq)
+expairseq::expairseq(const exvector &v) : inherited(&expairseq::tinfo_static)
{
construct_from_exvector(v);
GINAC_ASSERT(is_canonical());
}
expairseq::expairseq(const epvector &v, const ex &oc)
- : inherited(TINFO_expairseq), overall_coeff(oc)
+ : inherited(&expairseq::tinfo_static), overall_coeff(oc)
{
GINAC_ASSERT(is_a<numeric>(oc));
construct_from_epvector(v);
}
expairseq::expairseq(std::auto_ptr<epvector> vp, const ex &oc)
- : inherited(TINFO_expairseq), overall_coeff(oc)
+ : inherited(&expairseq::tinfo_static), overall_coeff(oc)
{
GINAC_ASSERT(vp.get()!=0);
GINAC_ASSERT(is_a<numeric>(oc));
unsigned expairseq::calchash() const
{
- unsigned v = golden_ratio_hash(this->tinfo());
+ unsigned v = golden_ratio_hash((unsigned)this->tinfo());
epvector::const_iterator i = seq.begin();
const epvector::const_iterator end = seq.end();
while (i != end) {
while (first1!=last1 && first2!=last2) {
int cmpval = (*first1).rest.compare((*first2).rest);
+
if (cmpval==0) {
// combine terms
const numeric &newcoeff = ex_to<numeric>(first1->coeff).
* Interface to sequences of expression pairs. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
#endif // EXPAIRSEQ_USE_HASHTAB
};
-// utility functions
-
-/** Specialization of is_exactly_a<expairseq>(obj) for expairseq objects. */
-template<> inline bool is_exactly_a<expairseq>(const basic & obj)
-{
- return obj.tinfo()==TINFO_expairseq;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_EXPAIRSEQ_H__
* Implementation of GiNaC's exprseq. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
namespace GiNaC {
-template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(exprseq, basic,
+template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(exprseq, basic,
print_func<print_context>(&exprseq::do_print).
print_func<print_tree>(&exprseq::do_print_tree))
* Definition of GiNaC's exprseq. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
typedef container<std::vector> exprseq;
/** Specialization of container::get_tinfo() for exprseq. */
-template<> inline unsigned exprseq::get_tinfo() { return TINFO_exprseq; }
+template<> inline tinfo_t exprseq::get_tinfo() { return &exprseq::tinfo_static; }
// defined in exprseq.cpp
template<> bool exprseq::info(unsigned inf) const;
-/** Specialization of is_exactly_a<exprseq>(obj) for exprseq objects. */
-template<> inline bool is_exactly_a<exprseq>(const basic & obj)
-{
- return obj.tinfo() == TINFO_exprseq;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_EXPRSEQ_H__
* somewhat obsolete (most of this can be replaced by exceptions). */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
void do_print(const print_context & c, unsigned level) const;
};
-/** Specialization of is_exactly_a<fail>(obj) for fail objects. */
-template<> inline bool is_exactly_a<fail>(const basic & obj)
-{
- return obj.tinfo()==TINFO_fail;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_FAIL_H__
* Implementation of abstract derivatives of functions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
fderivative::fderivative()
{
- tinfo_key = TINFO_fderivative;
+ tinfo_key = &fderivative::tinfo_static;
}
//////////
fderivative::fderivative(unsigned ser, unsigned param, const exvector & args) : function(ser, args)
{
parameter_set.insert(param);
- tinfo_key = TINFO_fderivative;
+ tinfo_key = &fderivative::tinfo_static;
}
fderivative::fderivative(unsigned ser, const paramset & params, const exvector & args) : function(ser, args), parameter_set(params)
{
- tinfo_key = TINFO_fderivative;
+ tinfo_key = &fderivative::tinfo_static;
}
fderivative::fderivative(unsigned ser, const paramset & params, std::auto_ptr<exvector> vp) : function(ser, vp), parameter_set(params)
{
- tinfo_key = TINFO_fderivative;
+ tinfo_key = &fderivative::tinfo_static;
}
//////////
* Interface to abstract derivatives of functions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
paramset parameter_set; /**< Set of parameter numbers with respect to which to take the derivative */
};
-// utility functions
-
-/** Specialization of is_exactly_a<T>(obj) for derivatives. */
-template<> inline bool is_exactly_a<fderivative>(const basic & obj)
-{
- return obj.tinfo()==TINFO_fderivative;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_DERIVATIVE_H__
# function.pl options: \$maxargs=${maxargs}
#
-# GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+# GiNaC Copyright (C) 1999-2006 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
function::function(unsigned ser, ${SEQ1})
: exprseq(${SEQ2}), serial(ser)
{
- tinfo_key = TINFO_function;
+ tinfo_key = &function::tinfo_static;
}
END_OF_CONSTRUCTORS_IMPLEMENTATION
return *this;
}
- function_options & set_return_type(unsigned rt, unsigned rtt=0);
+ function_options & set_return_type(unsigned rt);
function_options & do_not_evalf_params();
function_options & remember(unsigned size, unsigned assoc_size=0,
unsigned strategy=remember_strategies::delete_never);
bool use_return_type;
unsigned return_type;
- unsigned return_type_tinfo;
+ const basic* return_type_tinfo;
bool use_remember;
unsigned remember_size;
bool is_equal_same_type(const basic & other) const;
bool match_same_type(const basic & other) const;
unsigned return_type() const;
- unsigned return_type_tinfo() const;
+ const basic* return_type_tinfo() const;
// new virtual functions which can be overridden by derived classes
// none
// utility functions/macros
-/** Specialization of is_exactly_a<function>(obj) for objects of type function. */
-template<> inline bool is_exactly_a<function>(const basic & obj)
-{
- return obj.tinfo()==TINFO_function;
-}
-
template <typename T>
inline bool is_the_function(const ex & x)
{
return *this;
}
-function_options & function_options::set_return_type(unsigned rt, unsigned rtt)
+function_options & function_options::set_return_type(unsigned rt)
{
use_return_type = true;
return_type = rt;
- return_type_tinfo = rtt;
return *this;
}
function::function() : serial(0)
{
- tinfo_key = TINFO_function;
+ tinfo_key = &function::tinfo_static;
}
//////////
function::function(unsigned ser) : serial(ser)
{
- tinfo_key = TINFO_function;
+ tinfo_key = &function::tinfo_static;
}
// the following lines have been generated for max. ${maxargs} parameters
function::function(unsigned ser, const exprseq & es) : exprseq(es), serial(ser)
{
- tinfo_key = TINFO_function;
+ tinfo_key = &function::tinfo_static;
// Force re-evaluation even if the exprseq was already evaluated
// (the exprseq copy constructor copies the flags)
function::function(unsigned ser, const exvector & v, bool discardable)
: exprseq(v,discardable), serial(ser)
{
- tinfo_key = TINFO_function;
+ tinfo_key = &function::tinfo_static;
}
function::function(unsigned ser, std::auto_ptr<exvector> vp)
: exprseq(vp), serial(ser)
{
- tinfo_key = TINFO_function;
+ tinfo_key = &function::tinfo_static;
}
//////////
unsigned function::calchash() const
{
- unsigned v = golden_ratio_hash(golden_ratio_hash(tinfo()) ^ serial);
+ unsigned v = golden_ratio_hash(golden_ratio_hash((unsigned)tinfo()) ^ serial);
for (size_t i=0; i<nops(); i++) {
v = rotate_left(v);
v ^= this->op(i).gethash();
}
}
-unsigned function::return_type_tinfo() const
+const basic* function::return_type_tinfo() const
{
GINAC_ASSERT(serial<registered_functions().size());
const function_options &opt = registered_functions()[serial];
if (opt.use_return_type) {
// Return type was explicitly specified
- return opt.return_type_tinfo;
+ return this;
} else {
// Default behavior is to use the return type of the first
// argument. Thus, exp() of a matrix behaves like a matrix, etc.
if (seq.empty())
- return tinfo_key;
+ return this;
else
return seq.begin()->return_type_tinfo();
}
* Implementation of GiNaC's indices. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// default constructor
//////////
-idx::idx() : inherited(TINFO_idx) {}
+idx::idx() : inherited(&idx::tinfo_static) {}
varidx::varidx() : covariant(false)
{
- tinfo_key = TINFO_varidx;
+ tinfo_key = &varidx::tinfo_static;
}
spinidx::spinidx() : dotted(false)
{
- tinfo_key = TINFO_spinidx;
+ tinfo_key = &spinidx::tinfo_static;
}
//////////
// other constructors
//////////
-idx::idx(const ex & v, const ex & d) : inherited(TINFO_idx), value(v), dim(d)
+idx::idx(const ex & v, const ex & d) : inherited(&idx::tinfo_static), value(v), dim(d)
{
if (is_dim_numeric())
if (!dim.info(info_flags::posint))
varidx::varidx(const ex & v, const ex & d, bool cov) : inherited(v, d), covariant(cov)
{
- tinfo_key = TINFO_varidx;
+ tinfo_key = &varidx::tinfo_static;
}
spinidx::spinidx(const ex & v, const ex & d, bool cov, bool dot) : inherited(v, d, cov), dotted(dot)
{
- tinfo_key = TINFO_spinidx;
+ tinfo_key = &spinidx::tinfo_static;
}
//////////
// hash keys. That is, the hash values must not depend on the index
// dimensions or other attributes (variance etc.).
// The compare_same_type() methods will take care of the rest.
- unsigned v = golden_ratio_hash(tinfo());
+ unsigned v = golden_ratio_hash((unsigned)tinfo());
v = rotate_left(v);
v ^= value.gethash();
* Interface to GiNaC's indices. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// utility functions
-/** Specialization of is_exactly_a<idx>(obj) for idx objects. */
-template<> inline bool is_exactly_a<idx>(const basic & obj)
-{
- return obj.tinfo()==TINFO_idx;
-}
-
-/** Specialization of is_exactly_a<varidx>(obj) for varidx objects. */
-template<> inline bool is_exactly_a<varidx>(const basic & obj)
-{
- return obj.tinfo()==TINFO_varidx;
-}
-
-/** Specialization of is_exactly_a<spinidx>(obj) for spinidx objects. */
-template<> inline bool is_exactly_a<spinidx>(const basic & obj)
-{
- return obj.tinfo()==TINFO_spinidx;
-}
-
/** Check whether two indices form a dummy pair. */
bool is_dummy_pair(const idx & i1, const idx & i2);
* Implementation of GiNaC's indexed expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
indexed::indexed() : symtree(not_symmetric())
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
}
//////////
indexed::indexed(const ex & b) : inherited(b), symtree(not_symmetric())
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const ex & i1) : inherited(b, i1), symtree(not_symmetric())
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const ex & i1, const ex & i2) : inherited(b, i1, i2), symtree(not_symmetric())
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3) : inherited(b, i1, i2, i3), symtree(not_symmetric())
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited(b, i1, i2, i3, i4), symtree(not_symmetric())
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2) : inherited(b, i1, i2), symtree(symm)
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3) : inherited(b, i1, i2, i3), symtree(symm)
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const symmetry & symm, const ex & i1, const ex & i2, const ex & i3, const ex & i4) : inherited(b, i1, i2, i3, i4), symtree(symm)
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const exvector & v) : inherited(b), symtree(not_symmetric())
{
seq.insert(seq.end(), v.begin(), v.end());
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const ex & b, const symmetry & symm, const exvector & v) : inherited(b), symtree(symm)
{
seq.insert(seq.end(), v.begin(), v.end());
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
validate();
}
indexed::indexed(const symmetry & symm, const exprseq & es) : inherited(es), symtree(symm)
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
}
indexed::indexed(const symmetry & symm, const exvector & v, bool discardable) : inherited(v, discardable), symtree(symm)
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
}
indexed::indexed(const symmetry & symm, std::auto_ptr<exvector> vp) : inherited(vp), symtree(symm)
{
- tinfo_key = TINFO_indexed;
+ tinfo_key = &indexed::tinfo_static;
}
//////////
return f * thiscontainer(v);
}
- if(this->tinfo()==TINFO_indexed && seq.size()==1)
+ if(this->tinfo()==&indexed::tinfo_static && seq.size()==1)
return base;
// Canonicalize indices according to the symmetry properties
* Interface to GiNaC's indexed expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
ex thiscontainer(const exvector & v) const;
ex thiscontainer(std::auto_ptr<exvector> vp) const;
unsigned return_type() const;
- unsigned return_type_tinfo() const { return op(0).return_type_tinfo(); }
+ const basic* return_type_tinfo() const { return op(0).return_type_tinfo(); }
ex expand(unsigned options = 0) const;
// new virtual functions which can be overridden by derived classes
// utility functions
-/** Specialization of is_exactly_a<indexed>(obj) for indexed objects. */
-template<> inline bool is_exactly_a<indexed>(const basic & obj)
-{
- return obj.tinfo()==TINFO_indexed;
-}
-
/** Returns all dummy indices from the expression */
exvector get_all_dummy_indices(const ex & e);
* Implementation of GiNaC's symbolic integral. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
//////////
integral::integral()
- : inherited(TINFO_integral),
+ : inherited(&integral::tinfo_static),
x((new symbol())->setflag(status_flags::dynallocated))
{}
// public
integral::integral(const ex & x_, const ex & a_, const ex & b_, const ex & f_)
- : inherited(TINFO_integral), x(x_), a(a_), b(b_), f(f_)
+ : inherited(&integral::tinfo_static), x(x_), a(a_), b(b_), f(f_)
{
if (!is_a<symbol>(x)) {
throw(std::invalid_argument("first argument of integral must be of type symbol"));
return f.return_type();
}
-unsigned integral::return_type_tinfo() const
+const basic* integral::return_type_tinfo() const
{
return f.return_type_tinfo();
}
* Interface to GiNaC's symbolic integral. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
ex expand(unsigned options = 0) const;
exvector get_free_indices() const;
unsigned return_type() const;
- unsigned return_type_tinfo() const;
+ const basic* return_type_tinfo() const;
ex conjugate() const;
ex eval_integ() const;
protected:
// utility functions
-/** Specialization of is_exactly_a<integral>(obj) for integral objects. */
-template<> inline bool is_exactly_a<integral>(const basic & obj)
-{
- return obj.tinfo()==TINFO_integral;
-}
-
-
GiNaC::ex adaptivesimpson(
const GiNaC::ex &x,
const GiNaC::ex &a,
* Implementation of GiNaC's lst. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
namespace GiNaC {
-template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(lst, basic,
+template <> GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(lst, basic,
print_func<print_context>(&lst::do_print).
print_func<print_tree>(&lst::do_print_tree))
* Definition of GiNaC's lst. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
typedef container<std::list> lst;
/** Specialization of container::get_tinfo() for lst. */
-template<> inline unsigned lst::get_tinfo() { return TINFO_lst; }
+template<> inline tinfo_t lst::get_tinfo() { return &lst::tinfo_static; }
/** Specialization of container::get_default_flags() for lst. */
template<> inline unsigned lst::get_default_flags() { return status_flags::not_shareable; }
// defined in lst.cpp
template<> bool lst::info(unsigned inf) const;
-/** Specialization of is_exactly_a<lst>(obj) for lst objects. */
-template<> inline bool is_exactly_a<lst>(const basic & obj)
-{
- return obj.tinfo() == TINFO_lst;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_LST_H__
* Implementation of symbolic matrices */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
//////////
/** Default ctor. Initializes to 1 x 1-dimensional zero-matrix. */
-matrix::matrix() : inherited(TINFO_matrix), row(1), col(1), m(1, _ex0)
+matrix::matrix() : inherited(&matrix::tinfo_static), row(1), col(1), m(1, _ex0)
{
setflag(status_flags::not_shareable);
}
* @param r number of rows
* @param c number of cols */
matrix::matrix(unsigned r, unsigned c)
- : inherited(TINFO_matrix), row(r), col(c), m(r*c, _ex0)
+ : inherited(&matrix::tinfo_static), row(r), col(c), m(r*c, _ex0)
{
setflag(status_flags::not_shareable);
}
/** Ctor from representation, for internal use only. */
matrix::matrix(unsigned r, unsigned c, const exvector & m2)
- : inherited(TINFO_matrix), row(r), col(c), m(m2)
+ : inherited(&matrix::tinfo_static), row(r), col(c), m(m2)
{
setflag(status_flags::not_shareable);
}
* If the list has more elements than the matrix, the excessive elements are
* thrown away. */
matrix::matrix(unsigned r, unsigned c, const lst & l)
- : inherited(TINFO_matrix), row(r), col(c), m(r*c, _ex0)
+ : inherited(&matrix::tinfo_static), row(r), col(c), m(r*c, _ex0)
{
setflag(status_flags::not_shareable);
* Interface to symbolic matrices */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// utility functions
-/** Specialization of is_exactly_a<matrix>(obj) for matrix objects. */
-template<> inline bool is_exactly_a<matrix>(const basic & obj)
-{
- return obj.tinfo()==TINFO_matrix;
-}
-
/** Convert list of lists to matrix. */
extern ex lst_to_matrix(const lst & l);
* Implementation of GiNaC's products of expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
#include "mul.h"
#include "add.h"
+#include "color.h"
+#include "clifford.h"
#include "power.h"
#include "operators.h"
#include "matrix.h"
mul::mul()
{
- tinfo_key = TINFO_mul;
+ tinfo_key = &mul::tinfo_static;
}
//////////
mul::mul(const ex & lh, const ex & rh)
{
- tinfo_key = TINFO_mul;
+ tinfo_key = &mul::tinfo_static;
overall_coeff = _ex1;
construct_from_2_ex(lh,rh);
GINAC_ASSERT(is_canonical());
mul::mul(const exvector & v)
{
- tinfo_key = TINFO_mul;
+ tinfo_key = &mul::tinfo_static;
overall_coeff = _ex1;
construct_from_exvector(v);
GINAC_ASSERT(is_canonical());
mul::mul(const epvector & v)
{
- tinfo_key = TINFO_mul;
+ tinfo_key = &mul::tinfo_static;
overall_coeff = _ex1;
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
mul::mul(const epvector & v, const ex & oc)
{
- tinfo_key = TINFO_mul;
+ tinfo_key = &mul::tinfo_static;
overall_coeff = oc;
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
mul::mul(std::auto_ptr<epvector> vp, const ex & oc)
{
- tinfo_key = TINFO_mul;
+ tinfo_key = &mul::tinfo_static;
GINAC_ASSERT(vp.get()!=0);
overall_coeff = oc;
construct_from_epvector(*vp);
mul::mul(const ex & lh, const ex & mh, const ex & rh)
{
- tinfo_key = TINFO_mul;
+ tinfo_key = &mul::tinfo_static;
exvector factors;
factors.reserve(3);
factors.push_back(lh);
}
if ((rt == return_types::noncommutative) && (!all_commutative)) {
// another nc element found, compare type_infos
- if (noncommutative_element->rest.return_type_tinfo() != i->rest.return_type_tinfo()) {
- // diffent types -> mul is ncc
- return return_types::noncommutative_composite;
+ if (noncommutative_element->rest.return_type_tinfo()->tinfo() == &clifford::tinfo_static) {
+ if (i->rest.return_type_tinfo()->tinfo() != &clifford::tinfo_static ||
+ ((clifford*)(noncommutative_element->rest.return_type_tinfo()))->get_representation_label() !=
+ ((clifford*)(i->rest.return_type_tinfo()))->get_representation_label()) {
+ // diffent types -> mul is ncc
+ return return_types::noncommutative_composite;
+ }
+ } else if (noncommutative_element->rest.return_type_tinfo()->tinfo() == &color::tinfo_static) {
+ if (i->rest.return_type_tinfo()->tinfo() != &color::tinfo_static ||
+ ((color*)(noncommutative_element->rest.return_type_tinfo()))->get_representation_label() !=
+ ((color*)(i->rest.return_type_tinfo()))->get_representation_label()) {
+ // diffent types -> mul is ncc
+ return return_types::noncommutative_composite;
+ }
+ } else if (noncommutative_element->rest.return_type_tinfo()->tinfo() != i->rest.return_type_tinfo()->tinfo()) {
+ return return_types::noncommutative_composite;
}
}
++i;
return all_commutative ? return_types::commutative : return_types::noncommutative;
}
-unsigned mul::return_type_tinfo() const
+const basic* mul::return_type_tinfo() const
{
if (seq.empty())
- return tinfo_key; // mul without factors: should not happen
+ return this; // mul without factors: should not happen
// return type_info of first noncommutative element
epvector::const_iterator i = seq.begin(), end = seq.end();
++i;
}
// no noncommutative element found, should not happen
- return tinfo_key;
+ return this;
}
ex mul::thisexpairseq(const epvector & v, const ex & oc) const
* Interface to GiNaC's products of expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
ex derivative(const symbol & s) const;
ex eval_ncmul(const exvector & v) const;
unsigned return_type() const;
- unsigned return_type_tinfo() const;
+ const basic* return_type_tinfo() const;
ex thisexpairseq(const epvector & v, const ex & oc) const;
ex thisexpairseq(std::auto_ptr<epvector> vp, const ex & oc) const;
expair split_ex_to_pair(const ex & e) const;
std::auto_ptr<epvector> expandchildren(unsigned options) const;
};
-// utility functions
-
-/** Specialization of is_exactly_a<mul>(obj) for mul objects. */
-template<> inline bool is_exactly_a<mul>(const basic & obj)
-{
- return obj.tinfo()==TINFO_mul;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_MUL_H__
* Implementation of GiNaC's non-commutative products of expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
#include "ex.h"
#include "add.h"
#include "mul.h"
+#include "clifford.h"
+#include "color.h"
#include "matrix.h"
#include "archive.h"
#include "indexed.h"
ncmul::ncmul()
{
- tinfo_key = TINFO_ncmul;
+ tinfo_key = &ncmul::tinfo_static;
}
//////////
ncmul::ncmul(const ex & lh, const ex & rh) : inherited(lh,rh)
{
- tinfo_key = TINFO_ncmul;
+ tinfo_key = &ncmul::tinfo_static;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3) : inherited(f1,f2,f3)
{
- tinfo_key = TINFO_ncmul;
+ tinfo_key = &ncmul::tinfo_static;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
const ex & f4) : inherited(f1,f2,f3,f4)
{
- tinfo_key = TINFO_ncmul;
+ tinfo_key = &ncmul::tinfo_static;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
const ex & f4, const ex & f5) : inherited(f1,f2,f3,f4,f5)
{
- tinfo_key = TINFO_ncmul;
+ tinfo_key = &ncmul::tinfo_static;
}
ncmul::ncmul(const ex & f1, const ex & f2, const ex & f3,
const ex & f4, const ex & f5, const ex & f6) : inherited(f1,f2,f3,f4,f5,f6)
{
- tinfo_key = TINFO_ncmul;
+ tinfo_key = &ncmul::tinfo_static;
}
ncmul::ncmul(const exvector & v, bool discardable) : inherited(v,discardable)
{
- tinfo_key = TINFO_ncmul;
+ tinfo_key = &ncmul::tinfo_static;
}
ncmul::ncmul(std::auto_ptr<exvector> vp) : inherited(vp)
{
- tinfo_key = TINFO_ncmul;
+ tinfo_key = &ncmul::tinfo_static;
}
//////////
// ncmul(x) -> x
if (assocseq.size()==1) return *(seq.begin());
-
+
// ncmul() -> 1
if (assocseq.empty()) return _ex1;
size_t assoc_num = assocseq.size();
exvectorvector evv;
- unsignedvector rttinfos;
+ std::vector<const basic*> rttinfos;
evv.reserve(assoc_num);
rttinfos.reserve(assoc_num);
cit = assocseq.begin(), citend = assocseq.end();
while (cit != citend) {
- unsigned ti = cit->return_type_tinfo();
+ const basic* ti = cit->return_type_tinfo();
size_t rtt_num = rttinfos.size();
// search type in vector of known types
for (i=0; i<rtt_num; ++i) {
- if (ti == rttinfos[i]) {
- evv[i].push_back(*cit);
- break;
+ tinfo_t tinf = ti->tinfo();
+ if (tinf == rttinfos[i]->tinfo()) {
+ if (tinf == &clifford::tinfo_static) {
+ if (((clifford*)ti)->get_representation_label() == ((clifford*)rttinfos[i])->get_representation_label()) {
+ evv[i].push_back(*cit);
+ break;
+ }
+ } else if (tinf == &color::tinfo_static) {
+ if (((color*)ti)->get_representation_label() == ((color*)rttinfos[i])->get_representation_label()) {
+ evv[i].push_back(*cit);
+ break;
+ }
+ } else {
+ evv[i].push_back(*cit);
+ break;
+ }
}
}
if (i >= rtt_num) {
#endif // def DO_GINAC_ASSERT
// if all elements are of same type, simplify the string
- if (evv_num == 1)
+ if (evv_num == 1) {
return evv[0][0].eval_ncmul(evv[0]);
+ }
exvector splitseq;
splitseq.reserve(evv_num);
return exprseq::conjugate();
}
- if ((return_type_tinfo() & 0xffffff00U) != TINFO_clifford) {
+ if (return_type_tinfo()->tinfo() != &clifford::tinfo_static) {
return exprseq::conjugate();
}
}
if ((rt == return_types::noncommutative) && (!all_commutative)) {
// another nc element found, compare type_infos
- if (noncommutative_element->return_type_tinfo() != i->return_type_tinfo()) {
- // diffent types -> mul is ncc
- return return_types::noncommutative_composite;
+ if (noncommutative_element->return_type_tinfo()->tinfo() == &clifford::tinfo_static) {
+ if (i->return_type_tinfo()->tinfo() != &clifford::tinfo_static ||
+ ((clifford*)(noncommutative_element->return_type_tinfo()))->get_representation_label() !=
+ ((clifford*)(i->return_type_tinfo()))->get_representation_label()) {
+ // diffent types -> mul is ncc
+ return return_types::noncommutative_composite;
+ }
+ } else if (noncommutative_element->return_type_tinfo()->tinfo() == &color::tinfo_static) {
+ if (i->return_type_tinfo()->tinfo() != &color::tinfo_static ||
+ ((color*)(noncommutative_element->return_type_tinfo()))->get_representation_label() !=
+ ((color*)(i->return_type_tinfo()))->get_representation_label()) {
+ // diffent types -> mul is ncc
+ return return_types::noncommutative_composite;
+ }
+ } else if (noncommutative_element->return_type_tinfo()->tinfo() != i->return_type_tinfo()->tinfo()) {
+ return return_types::noncommutative_composite;
}
}
++i;
return all_commutative ? return_types::commutative : return_types::noncommutative;
}
-unsigned ncmul::return_type_tinfo() const
+const basic* ncmul::return_type_tinfo() const
{
if (seq.empty())
- return tinfo_key;
+ return this;
// return type_info of first noncommutative element
exvector::const_iterator i = seq.begin(), end = seq.end();
}
// no noncommutative element found, should not happen
- return tinfo_key;
+ return this;
}
//////////
* Interface to GiNaC's non-commutative products of expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
protected:
ex derivative(const symbol & s) const;
unsigned return_type() const;
- unsigned return_type_tinfo() const;
+ const basic* return_type_tinfo() const;
// new virtual functions which can be overridden by derived classes
// none
ex reeval_ncmul(const exvector & v);
ex hold_ncmul(const exvector & v);
-// utility functions
-
-/** Specialization of is_exactly_a<ncmul>(obj) for ncmul objects. */
-template<> inline bool is_exactly_a<ncmul>(const basic & obj)
-{
- return obj.tinfo()==TINFO_ncmul;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_NCMUL_H__
* of special functions or implement the interface to the bignum package. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
//////////
/** default ctor. Numerically it initializes to an integer zero. */
-numeric::numeric() : basic(TINFO_numeric)
+numeric::numeric() : basic(&numeric::tinfo_static)
{
value = cln::cl_I(0);
setflag(status_flags::evaluated | status_flags::expanded);
// public
-numeric::numeric(int i) : basic(TINFO_numeric)
+numeric::numeric(int i) : basic(&numeric::tinfo_static)
{
// Not the whole int-range is available if we don't cast to long
// first. This is due to the behaviour of the cl_I-ctor, which
}
-numeric::numeric(unsigned int i) : basic(TINFO_numeric)
+numeric::numeric(unsigned int i) : basic(&numeric::tinfo_static)
{
// Not the whole uint-range is available if we don't cast to ulong
// first. This is due to the behaviour of the cl_I-ctor, which
}
-numeric::numeric(long i) : basic(TINFO_numeric)
+numeric::numeric(long i) : basic(&numeric::tinfo_static)
{
value = cln::cl_I(i);
setflag(status_flags::evaluated | status_flags::expanded);
}
-numeric::numeric(unsigned long i) : basic(TINFO_numeric)
+numeric::numeric(unsigned long i) : basic(&numeric::tinfo_static)
{
value = cln::cl_I(i);
setflag(status_flags::evaluated | status_flags::expanded);
/** Constructor for rational numerics a/b.
*
* @exception overflow_error (division by zero) */
-numeric::numeric(long numer, long denom) : basic(TINFO_numeric)
+numeric::numeric(long numer, long denom) : basic(&numeric::tinfo_static)
{
if (!denom)
throw std::overflow_error("division by zero");
}
-numeric::numeric(double d) : basic(TINFO_numeric)
+numeric::numeric(double d) : basic(&numeric::tinfo_static)
{
// We really want to explicitly use the type cl_LF instead of the
// more general cl_F, since that would give us a cl_DF only which
/** ctor from C-style string. It also accepts complex numbers in GiNaC
* notation like "2+5*I". */
-numeric::numeric(const char *s) : basic(TINFO_numeric)
+numeric::numeric(const char *s) : basic(&numeric::tinfo_static)
{
cln::cl_N ctorval = 0;
// parse complex numbers (functional but not completely safe, unfortunately
/** Ctor from CLN types. This is for the initiated user or internal use
* only. */
-numeric::numeric(const cln::cl_N &z) : basic(TINFO_numeric)
+numeric::numeric(const cln::cl_N &z) : basic(&numeric::tinfo_static)
{
value = z;
setflag(status_flags::evaluated | status_flags::expanded);
* Makes the interface to the underlying bignum package available. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
ex CatalanEvalf();
-// utility functions
-
-/** Specialization of is_exactly_a<numeric>(obj) for numeric objects. */
-template<> inline bool is_exactly_a<numeric>(const basic & obj)
-{
- return obj.tinfo()==TINFO_numeric;
-}
-
} // namespace GiNaC
#ifdef __MAKECINT__
// ncmul::eval()'s rule to pull out commutative elements we need to check
// only one of the elements.
if (rh.return_type()==return_types::commutative ||
- lh.return_type()==return_types::commutative)
+ lh.return_type()==return_types::commutative) {
return (new mul(lh,rh))->setflag(status_flags::dynallocated);
- else
+ } else {
return (new ncmul(lh,rh))->setflag(status_flags::dynallocated);
+ }
}
/** Used internally by operator-() and friends to change the sign of an argument. */
* Implementation of GiNaC's symbolic exponentiation (basis^exponent). */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// default constructor
//////////
-power::power() : inherited(TINFO_power) { }
+power::power() : inherited(&power::tinfo_static) { }
//////////
// other constructors
return basis.return_type();
}
-unsigned power::return_type_tinfo() const
+const basic* power::return_type_tinfo() const
{
return basis.return_type_tinfo();
}
* Interface to GiNaC's symbolic exponentiation (basis^exponent). */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// other constructors
public:
- power(const ex & lh, const ex & rh) : inherited(TINFO_power), basis(lh), exponent(rh) {}
- template<typename T> power(const ex & lh, const T & rh) : inherited(TINFO_power), basis(lh), exponent(rh) {}
+ power(const ex & lh, const ex & rh) : inherited(&power::tinfo_static), basis(lh), exponent(rh) {}
+ template<typename T> power(const ex & lh, const T & rh) : inherited(&power::tinfo_static), basis(lh), exponent(rh) {}
// functions overriding virtual functions from base classes
public:
ex derivative(const symbol & s) const;
ex eval_ncmul(const exvector & v) const;
unsigned return_type() const;
- unsigned return_type_tinfo() const;
+ const basic* return_type_tinfo() const;
ex expand(unsigned options = 0) const;
// new virtual functions which can be overridden by derived classes
ex exponent;
};
-// utility functions
-
-/** Efficient specialization of is_exactly_a<power>(obj) for power objects. */
-template<> inline bool is_exactly_a<power>(const basic & obj)
-{
- return obj.tinfo()==TINFO_power;
-}
-
// wrapper functions
/** Symbolic exponentiation. Returns a power-object as a new expression.
* methods for series expansion. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
* Default constructor
*/
-pseries::pseries() : inherited(TINFO_pseries) { }
+pseries::pseries() : inherited(&pseries::tinfo_static) { }
/*
* @param rel_ expansion variable and point (must hold a relational)
* @param ops_ vector of {coefficient, power} pairs (coefficient must not be zero)
* @return newly constructed pseries */
-pseries::pseries(const ex &rel_, const epvector &ops_) : basic(TINFO_pseries), seq(ops_)
+pseries::pseries(const ex &rel_, const epvector &ops_) : basic(&pseries::tinfo_static), seq(ops_)
{
GINAC_ASSERT(is_a<relational>(rel_));
GINAC_ASSERT(is_a<symbol>(rel_.lhs()));
* Interface to class for extended truncated power series. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// utility functions
-/** Specialization of is_exactly_a<pseries>(obj) for pseries objects. */
-template<> inline bool is_exactly_a<pseries>(const basic & obj)
-{
- return obj.tinfo()==TINFO_pseries;
-}
-
/** Convert the pseries object embedded in an expression to an ordinary
* polynomial in the expansion variable. The result is undefined if the
* expression does not contain a pseries object at its top level.
namespace GiNaC {
-unsigned find_tinfo_key(const std::string &class_name)
+tinfo_t find_tinfo_key(const std::string &class_name)
{
return registered_class_info::find(class_name)->options.get_id();
}
* GiNaC's class registrar (for class basic and all classes derived from it). */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
template <template <class> class> class container;
typedef container<std::list> lst;
+/** Definitions for the tinfo mechanism. */
+typedef const void * tinfo_t;
+struct tinfo_static_t {};
/** Unarchiving function (static member function of every GiNaC class). */
typedef ex (*unarch_func)(const archive_node &n, lst &sym_lst);
/** This class stores information about a registered GiNaC class. */
class registered_class_options {
public:
- registered_class_options(const char *n, const char *p, unsigned ti, unarch_func f)
+ registered_class_options(const char *n, const char *p, tinfo_t ti, unarch_func f)
: name(n), parent_name(p), tinfo_key(ti), unarchive(f) {}
const char *get_name() const { return name; }
const char *get_parent_name() const { return parent_name; }
- unsigned get_id() const { return tinfo_key; }
+ tinfo_t get_id() const { return tinfo_key; }
unarch_func get_unarch_func() const { return unarchive; }
const std::vector<print_functor> &get_print_dispatch_table() const { return print_dispatch_table; }
private:
const char *name; /**< Class name. */
const char *parent_name; /**< Name of superclass. */
- unsigned tinfo_key; /**< TINFO_* key. */
+ tinfo_t tinfo_key; /**< Type information key. */
unarch_func unarchive; /**< Pointer to unarchiving function. */
std::vector<print_functor> print_dispatch_table; /**< Method table for print() dispatch */
};
#define GINAC_DECLARE_REGISTERED_CLASS_NO_CTORS(classname, supername) \
public: \
typedef supername inherited; \
+ static const tinfo_static_t tinfo_static; \
private: \
static GiNaC::registered_class_info reg_info; \
public: \
virtual int compare_same_type(const GiNaC::basic & other) const; \
private:
+
/** Macro for inclusion in the implementation of each registered class. */
#define GINAC_IMPLEMENT_REGISTERED_CLASS(classname, supername) \
- GiNaC::registered_class_info classname::reg_info = GiNaC::registered_class_info(GiNaC::registered_class_options(#classname, #supername, TINFO_##classname, &classname::unarchive));
+ GiNaC::registered_class_info classname::reg_info = GiNaC::registered_class_info(GiNaC::registered_class_options(#classname, #supername, &classname::tinfo_static, &classname::unarchive)); \
+ const tinfo_static_t classname::tinfo_static = {};
/** Macro for inclusion in the implementation of each registered class.
* Additional options can be specified. */
#define GINAC_IMPLEMENT_REGISTERED_CLASS_OPT(classname, supername, options) \
- GiNaC::registered_class_info classname::reg_info = GiNaC::registered_class_info(GiNaC::registered_class_options(#classname, #supername, TINFO_##classname, &classname::unarchive).options);
+ GiNaC::registered_class_info classname::reg_info = GiNaC::registered_class_info(GiNaC::registered_class_options(#classname, #supername, &classname::tinfo_static, &classname::unarchive).options); \
+ const tinfo_static_t classname::tinfo_static = {};
+
+/** Macro for inclusion in the implementation of each registered class.
+ * Additional options can be specified. */
+#define GINAC_IMPLEMENT_REGISTERED_CLASS_OPT_T(classname, supername, options) \
+ GiNaC::registered_class_info classname::reg_info = GiNaC::registered_class_info(GiNaC::registered_class_options(#classname, #supername, &classname::tinfo_static, &classname::unarchive).options); \
+ template<> const tinfo_static_t classname::tinfo_static = {};
-/** Find TINFO_* key by class name. */
-extern unsigned find_tinfo_key(const std::string &class_name);
+/** Find type information key by class name. */
+extern tinfo_t find_tinfo_key(const std::string &class_name);
/** Find unarchiving function by class name. */
extern unarch_func find_unarch_func(const std::string &class_name);
* Implementation of relations between expressions */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// default constructor
//////////
-relational::relational() : basic(TINFO_relational) {}
+relational::relational() : basic(&relational::tinfo_static) {}
//////////
// other constructors
// public
-relational::relational(const ex & lhs, const ex & rhs, operators oper) : basic(TINFO_relational), lh(lhs), rh(rhs), o(oper) {}
+relational::relational(const ex & lhs, const ex & rhs, operators oper) : basic(&relational::tinfo_static), lh(lhs), rh(rhs), o(oper) {}
//////////
// archiving
return lh.return_type();
}
-unsigned relational::return_type_tinfo() const
+const basic* relational::return_type_tinfo() const
{
GINAC_ASSERT(lh.return_type_tinfo()==rh.return_type_tinfo());
return lh.return_type_tinfo();
unsigned relational::calchash() const
{
- unsigned v = golden_ratio_hash(tinfo());
+ unsigned v = golden_ratio_hash((unsigned)tinfo());
unsigned lhash = lh.gethash();
unsigned rhash = rh.gethash();
* Interface to relations between expressions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
ex eval_ncmul(const exvector & v) const;
bool match_same_type(const basic & other) const;
unsigned return_type() const;
- unsigned return_type_tinfo() const;
+ const basic* return_type_tinfo() const;
unsigned calchash() const;
// new virtual functions which can be overridden by derived classes
// utility functions
-/** Specialization of is_exactly_a<relational>(obj) for relational objects. */
-template<> inline bool is_exactly_a<relational>(const basic & obj)
-{
- return obj.tinfo()==TINFO_relational;
-}
-
// inlined functions for efficiency
inline relational::safe_bool relational::operator!() const
{
+++ /dev/null
-/** @file structure.cpp
- *
- * Wrapper template for making GiNaC classes out of C++ structures. */
-
-/*
- * GiNaC Copyright (C) 1999-2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "structure.h"
-
-namespace GiNaC {
-
-/** Next free tinfo_key for structure types. */
-unsigned next_structure_tinfo_key = TINFO_structure;
-
-} // namespace GiNaC
* Wrapper template for making GiNaC classes out of C++ structures. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
namespace GiNaC {
-extern unsigned next_structure_tinfo_key;
-
/** Comparison policy: all structures of one type are equal */
template <class T>
GINAC_DECLARE_REGISTERED_CLASS(structure, basic)
// helpers
- static unsigned get_tinfo() { return reg_info.options.get_id(); }
+ static tinfo_t get_tinfo() { return reg_info.options.get_id(); }
static const char *get_class_name() { return "structure"; }
+ static tinfo_t next_structure_tinfo_key() { return new tinfo_static_t; }
// constructors
public:
// noncommutativity
unsigned return_type() const { return return_types::commutative; }
- unsigned return_type_tinfo() const { return tinfo(); }
+ const basic* return_type_tinfo() const { return this; }
protected:
bool is_equal_same_type(const basic & other) const
const T *operator->() const { return &obj; }
T &get_struct() { return obj; }
const T &get_struct() const { return obj; }
-
private:
T obj;
};
}
template <class T, template <class> class CP>
-registered_class_info structure<T, CP>::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", next_structure_tinfo_key++, &structure::unarchive));
+registered_class_info structure<T, CP>::reg_info = registered_class_info(registered_class_options(structure::get_class_name(), "basic", structure::next_structure_tinfo_key(), &structure::unarchive));
} // namespace GiNaC
* Implementation of GiNaC's symbolic objects. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// symbol
symbol::symbol()
- : inherited(TINFO_symbol), asexinfop(new assigned_ex_info), serial(next_serial++), name(autoname_prefix() + ToString(serial)), TeX_name(name), ret_type(return_types::commutative), ret_type_tinfo(TINFO_symbol), domain(domain::complex)
+ : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(autoname_prefix() + ToString(serial)), TeX_name(name), ret_type(return_types::commutative), domain(domain::complex)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
// symbol
symbol::symbol(const std::string & initname, unsigned domain)
- : inherited(TINFO_symbol), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), ret_type(return_types::commutative), ret_type_tinfo(TINFO_symbol), domain(domain)
+ : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), ret_type(return_types::commutative), domain(domain)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
-symbol::symbol(const std::string & initname, const std::string & texname, unsigned domain)
- : inherited(TINFO_symbol), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(texname), ret_type(return_types::commutative), ret_type_tinfo(TINFO_symbol), domain(domain)
+symbol::symbol(const std::string & initname, unsigned rt, unsigned domain)
+ : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), ret_type(rt), domain(domain)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
-symbol::symbol(const std::string & initname, unsigned rt, unsigned rtt, unsigned domain)
- : inherited(TINFO_symbol), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(default_TeX_name()), ret_type(rt), ret_type_tinfo(rtt), domain(domain)
+symbol::symbol(const std::string & initname, const std::string & texname, unsigned domain)
+ : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(texname), ret_type(return_types::commutative), domain(domain)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
-symbol::symbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned rtt, unsigned domain)
- : inherited(TINFO_symbol), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(texname), ret_type(rt), ret_type_tinfo(rtt), domain(domain)
+symbol::symbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain)
+ : inherited(&symbol::tinfo_static), asexinfop(new assigned_ex_info), serial(next_serial++), name(initname), TeX_name(texname), ret_type(rt), domain(domain)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned domain)
: symbol(initname, texname, domain) { }
-realsymbol::realsymbol(const std::string & initname, unsigned rt, unsigned rtt, unsigned domain)
- : symbol(initname, rt, rtt, domain) { }
+realsymbol::realsymbol(const std::string & initname, unsigned rt, unsigned domain)
+ : symbol(initname, rt, domain) { }
-realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned rtt, unsigned domain)
- : symbol(initname, texname, rt, rtt, domain) { }
+realsymbol::realsymbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain)
+ : symbol(initname, texname, rt, domain) { }
//////////
// archiving
domain = domain::complex;
if (!n.find_unsigned("return_type", ret_type))
ret_type = return_types::commutative;
- if (!n.find_unsigned("return_type_tinfo", ret_type_tinfo))
- ret_type_tinfo = TINFO_symbol;
setflag(status_flags::evaluated | status_flags::expanded);
}
n.add_unsigned("domain", domain);
if (ret_type != return_types::commutative)
n.add_unsigned("return_type", ret_type);
- if (ret_type_tinfo != TINFO_symbol)
- n.add_unsigned("return_type_tinfo", ret_type_tinfo);
}
//////////
unsigned symbol::calchash() const
{
- hashvalue = golden_ratio_hash(tinfo() ^ serial);
+ hashvalue = golden_ratio_hash((unsigned)tinfo() ^ serial);
setflag(status_flags::hash_calculated);
return hashvalue;
}
* Interface to GiNaC's symbolic objects. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// other constructors
public:
explicit symbol(const std::string & initname, unsigned domain = domain::complex);
+ symbol(const std::string & initname, unsigned rt, unsigned domain);
symbol(const std::string & initname, const std::string & texname, unsigned domain = domain::complex);
- symbol(const std::string & initname, unsigned rt, unsigned rtt, unsigned domain = domain::complex);
- symbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned rtt, unsigned domain = domain::complex);
+ symbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain);
// functions overriding virtual functions from base classes
public:
ex to_rational(exmap & repl) const;
ex to_polynomial(exmap & repl) const;
unsigned return_type() const { return ret_type; }
- unsigned return_type_tinfo() const { return ret_type_tinfo; }
ex conjugate() const;
protected:
ex derivative(const symbol & s) const;
std::string TeX_name; ///< LaTeX name of this symbol
unsigned domain; ///< domain of symbol, complex (default) or real
unsigned ret_type; ///< value returned by return_type()
- unsigned ret_type_tinfo; ///< value returned by return_type_tinfo()
private:
static unsigned next_serial;
};
realsymbol();
explicit realsymbol(const std::string & initname, unsigned domain = domain::real);
realsymbol(const std::string & initname, const std::string & texname, unsigned domain = domain::real);
- realsymbol(const std::string & initname, unsigned rt, unsigned rtt, unsigned domain = domain::real);
- realsymbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned rtt, unsigned domain = domain::real);
+ realsymbol(const std::string & initname, unsigned rt, unsigned domain = domain::real);
+ realsymbol(const std::string & initname, const std::string & texname, unsigned rt, unsigned domain = domain::real);
};
// utility functions
-/** Specialization of is_exactly_a<symbol>(obj) for symbol objects. */
-template<> inline bool is_exactly_a<symbol>(const basic & obj)
-{
- return obj.tinfo() == TINFO_symbol;
-}
-
/** Specialization of is_exactly_a<realsymbol>(obj) for realsymbol objects. */
template<> inline bool is_exactly_a<realsymbol>(const basic & obj)
{
- return (obj.tinfo() == TINFO_symbol) && (static_cast<const symbol &>(obj).get_domain() == domain::real);
+ return (obj.tinfo() == &symbol::tinfo_static) && (static_cast<const symbol &>(obj).get_domain() == domain::real);
}
// wrapper functions around member functions
* Implementation of GiNaC's symmetry definitions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// default constructor
//////////
-symmetry::symmetry() : inherited(TINFO_symmetry), type(none)
+symmetry::symmetry() : inherited(&symmetry::tinfo_static), type(none)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
// other constructors
//////////
-symmetry::symmetry(unsigned i) : inherited(TINFO_symmetry), type(none)
+symmetry::symmetry(unsigned i) : inherited(&symmetry::tinfo_static), type(none)
{
indices.insert(i);
setflag(status_flags::evaluated | status_flags::expanded);
}
-symmetry::symmetry(symmetry_type t, const symmetry &c1, const symmetry &c2) : inherited(TINFO_symmetry), type(t)
+symmetry::symmetry(symmetry_type t, const symmetry &c1, const symmetry &c2) : inherited(&symmetry::tinfo_static), type(t)
{
add(c1); add(c2);
setflag(status_flags::evaluated | status_flags::expanded);
* Interface to GiNaC's symmetry definitions. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
return symmetrize(e, v.begin(), v.end());
}
-// utility functions
-
-/** Specialization of is_exactly_a<symmetry>(obj) for symmetry objects. */
-template<> inline bool is_exactly_a<symmetry>(const basic & obj)
-{
- return obj.tinfo()==TINFO_symmetry;
-}
-
} // namespace GiNaC
#endif // ndef __GINAC_SYMMETRY_H__
* Implementation of GiNaC's special tensors. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// constructors
//////////
-tensor::tensor() : inherited(TINFO_tensor)
+tensor::tensor() : inherited(&tensor::tinfo_static)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
minkmetric::minkmetric() : pos_sig(false)
{
- tinfo_key = TINFO_minkmetric;
+ tinfo_key = &minkmetric::tinfo_static;
}
spinmetric::spinmetric()
{
- tinfo_key = TINFO_spinmetric;
+ tinfo_key = &spinmetric::tinfo_static;
}
minkmetric::minkmetric(bool ps) : pos_sig(ps)
{
- tinfo_key = TINFO_minkmetric;
+ tinfo_key = &minkmetric::tinfo_static;
}
tensepsilon::tensepsilon() : minkowski(false), pos_sig(false)
{
- tinfo_key = TINFO_tensepsilon;
+ tinfo_key = &tensepsilon::tinfo_static;
}
tensepsilon::tensepsilon(bool mink, bool ps) : minkowski(mink), pos_sig(ps)
{
- tinfo_key = TINFO_tensepsilon;
+ tinfo_key = &tensepsilon::tinfo_static;
}
//////////
// other constructors
protected:
- tensor(unsigned ti) : inherited(ti) {}
+ tensor(tinfo_t ti) : inherited(ti) {}
// functions overriding virtual functions from base classes
protected:
+++ /dev/null
-/** @file tinfos.h
- *
- * Values for a do-it-yourself typeinfo scheme. */
-
-/*
- * GiNaC Copyright (C) 1999-2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef __GINAC_TINFOS_H__
-#define __GINAC_TINFOS_H__
-
-namespace GiNaC {
-
-const unsigned TINFO_basic = 0x00000001U;
-
-const unsigned TINFO_expairseq = 0x00010001U;
-const unsigned TINFO_add = 0x00011001U;
-const unsigned TINFO_mul = 0x00011002U;
-
-const unsigned TINFO_symbol = 0x00020001U;
-const unsigned TINFO_constant = 0x00021001U;
-
-const unsigned TINFO_exprseq = 0x00030001U;
-const unsigned TINFO_function = 0x00031001U;
-const unsigned TINFO_fderivative = 0x00032001U;
-const unsigned TINFO_ncmul = 0x00031002U;
-const unsigned TINFO_integral = 0x00033001U;
-
-const unsigned TINFO_lst = 0x00040001U;
-
-const unsigned TINFO_matrix = 0x00050001U;
-
-const unsigned TINFO_power = 0x00060001U;
-
-const unsigned TINFO_relational = 0x00070001U;
-
-const unsigned TINFO_fail = 0x00080001U;
-
-const unsigned TINFO_numeric = 0x00090001U;
-
-const unsigned TINFO_pseries = 0x000a0001U;
-
-const unsigned TINFO_indexed = 0x000b0001U;
-const unsigned TINFO_color = 0x000b1000U;
-// reserved up to 0x000b10ffU
-// for color algebras (only used for return_type_tinfo())
-const unsigned TINFO_clifford = 0x000b1100U;
-// reserved up to 0x000b11ffU
-// for clifford algebras (only used for return_type_tinfo())
-
-const unsigned TINFO_structure = 0x000c0001U;
-// reserved up to 0x000cffffU
-// for user defined structures
-
-const unsigned TINFO_idx = 0x000d0001U;
-const unsigned TINFO_varidx = 0x000d1001U;
-const unsigned TINFO_spinidx = 0x000d2001U;
-
-const unsigned TINFO_tensor = 0x000e0001U;
-const unsigned TINFO_tensdelta = 0x000e1001U;
-const unsigned TINFO_tensmetric = 0x000e1002U;
-const unsigned TINFO_minkmetric = 0x000e2001U;
-const unsigned TINFO_spinmetric = 0x000e2002U;
-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_diracone = 0x000e100cU;
-const unsigned TINFO_diracgamma = 0x000e100dU;
-const unsigned TINFO_cliffordunit = 0x000e101dU;
-const unsigned TINFO_diracgamma5 = 0x000e100eU;
-const unsigned TINFO_diracgammaL = 0x000e100fU;
-const unsigned TINFO_diracgammaR = 0x000e1010U;
-
-const unsigned TINFO_wildcard = 0x000f0001U;
-
-const unsigned TINFO_symmetry = 0x00100001U;
-
-} // namespace GiNaC
-
-#endif // ndef __GINAC_TINFOS_H__
* of any interest to the user of the library. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// Helper macros for class implementations (mostly useful for trivial classes)
#define DEFAULT_CTOR(classname) \
-classname::classname() : inherited(TINFO_##classname) { setflag(status_flags::evaluated | status_flags::expanded); }
+classname::classname() : inherited(&classname::tinfo_static) { setflag(status_flags::evaluated | status_flags::expanded); }
#define DEFAULT_UNARCHIVE(classname) \
ex classname::unarchive(const archive_node &n, lst &sym_lst) \
* Implementation of GiNaC's wildcard objects. */
/*
- * GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
+ * GiNaC Copyright (C) 1999-2006 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
// default constructor
//////////
-wildcard::wildcard() : inherited(TINFO_wildcard), label(0)
+wildcard::wildcard() : inherited(&wildcard::tinfo_static), label(0)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
// other constructors
//////////
-wildcard::wildcard(unsigned l) : inherited(TINFO_wildcard), label(l)
+wildcard::wildcard(unsigned l) : inherited(&wildcard::tinfo_static), label(l)
{
setflag(status_flags::evaluated | status_flags::expanded);
}
// this is where the schoolbook method
// (golden_ratio_hash(tinfo()) ^ label)
// is not good enough yet...
- hashvalue = golden_ratio_hash(golden_ratio_hash(tinfo()) ^ label);
+ hashvalue = golden_ratio_hash(golden_ratio_hash((unsigned)tinfo()) ^ label);
setflag(status_flags::hash_calculated);
return hashvalue;
}
// utility functions
-/** Specialization of is_exactly_a<wildcard>(obj) for wildcard objects. */
-template<> inline bool is_exactly_a<wildcard>(const basic & obj)
-{
- return obj.tinfo()==TINFO_wildcard;
-}
-
/** Create a wildcard object with the specified label. */
inline ex wild(unsigned label = 0)
{