- Cleanups: My evil plot of making ex::bp private may finally be carried
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Wed, 22 Aug 2001 20:11:48 +0000 (20:11 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Wed, 22 Aug 2001 20:11:48 +0000 (20:11 +0000)
  out, provided one changes all the is_of_type(obj,type) to is_a<type>(obj)
  which we don't do right now because it would degrade performance on
  gcc-2.95.x.  Also, ex_to_type(obj) has gone for good now, we have been
  having ex_to<type>(obj) long enough.  ex_to_nonconst_type(obj) have gone
  as well, since they are almost never used and one can always cast aways
  the constness explicitly if need should arise.

51 files changed:
NEWS
ginac/add.cpp
ginac/add.h
ginac/basic.cpp
ginac/basic.h
ginac/clifford.cpp
ginac/clifford.h
ginac/color.cpp
ginac/color.h
ginac/constant.cpp
ginac/constant.h
ginac/container.pl
ginac/ex.cpp
ginac/ex.h
ginac/expairseq.cpp
ginac/expairseq.h
ginac/fderivative.cpp
ginac/function.pl
ginac/idx.cpp
ginac/idx.h
ginac/indexed.cpp
ginac/indexed.h
ginac/inifcns.cpp
ginac/inifcns_gamma.cpp
ginac/inifcns_trans.cpp
ginac/input_parser.yy
ginac/matrix.cpp
ginac/matrix.h
ginac/mul.cpp
ginac/mul.h
ginac/ncmul.cpp
ginac/ncmul.h
ginac/normal.cpp
ginac/numeric.cpp
ginac/numeric.h
ginac/power.cpp
ginac/power.h
ginac/pseries.cpp
ginac/pseries.h
ginac/relational.cpp
ginac/relational.h
ginac/structure.cpp
ginac/symbol.cpp
ginac/symbol.h
ginac/symmetry.cpp
ginac/symmetry.h
ginac/tensor.cpp
ginac/tensor.h
ginac/wildcard.cpp
ginac/wildcard.h
ginsh/ginsh_parser.yy

diff --git a/NEWS b/NEWS
index 6bbe8f5..6c882d7 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
 This file records noteworthy changes.
 
+0.9.4 (<date>)
+* interface cleanups and bugfixes.
+
 0.9.3 (16 August 2001)
 * series expansion now much more consistent for small order expansion.
 * lsolve() accepts algorithmic hint as parameter.
index c14c158..4cb1182 100644 (file)
@@ -328,10 +328,10 @@ ex add::eval(int level) const
 #ifdef DO_GINAC_ASSERT
        epvector::const_iterator i = seq.begin(), end = seq.end();
        while (i != end) {
-               GINAC_ASSERT(!is_ex_exactly_of_type(i->rest,add));
+               GINAC_ASSERT(!is_exactly_a<add>(i->rest));
                if (is_ex_exactly_of_type(i->rest,numeric))
                        dbgprint();
-               GINAC_ASSERT(!is_ex_exactly_of_type(i->rest,numeric));
+               GINAC_ASSERT(!is_exactly_a<numeric>(i->rest));
                ++i;
        }
 #endif // def DO_GINAC_ASSERT
@@ -470,7 +470,7 @@ expair add::split_ex_to_pair(const ex & e) const
 expair add::combine_ex_with_coeff_to_pair(const ex & e,
                                                                                  const ex & c) const
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(c, numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(c));
        if (is_ex_exactly_of_type(e, mul)) {
                const mul &mulref(ex_to<mul>(e));
                ex numfactor = mulref.overall_coeff;
@@ -496,8 +496,8 @@ expair add::combine_ex_with_coeff_to_pair(const ex & e,
 expair add::combine_pair_with_coeff_to_pair(const expair & p,
                                                                                        const ex & c) const
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(p.coeff,numeric));
-       GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(p.coeff));
+       GINAC_ASSERT(is_exactly_a<numeric>(c));
 
        if (is_ex_exactly_of_type(p.rest,numeric)) {
                GINAC_ASSERT(ex_to<numeric>(p.coeff).is_equal(_num1())); // should be normalized
index fe8d20b..7400056 100644 (file)
@@ -79,13 +79,6 @@ protected:
 
 // utility functions
 
-/** Return the add object handled by an ex.  Deprecated: use ex_to<add>().
- *  This is unsafe: you need to check the type first. */
-inline const add &ex_to_add(const ex &e)
-{
-       return static_cast<const add &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<add>(obj) for add objects. */
 template<> inline bool is_exactly_a<add>(const basic & obj)
 {
index 1aff2e1..2065eac 100644 (file)
@@ -34,6 +34,7 @@
 #include "lst.h"
 #include "ncmul.h"
 #include "relational.h"
+#include "wildcard.h"
 #include "print.h"
 #include "archive.h"
 #include "utils.h"
@@ -213,9 +214,8 @@ ex basic::operator[](int i) const
  *  but e.has(x+y) is false. */
 bool basic::has(const ex & pattern) const
 {
-       GINAC_ASSERT(pattern.bp!=0);
        lst repl_lst;
-       if (match(*pattern.bp, repl_lst))
+       if (match(pattern, repl_lst))
                return true;
        for (unsigned i=0; i<nops(); i++)
                if (op(i).has(pattern))
@@ -471,7 +471,7 @@ bool basic::match(const ex & pattern, lst & repl_lst) const
                // be the same expression)
                for (unsigned i=0; i<repl_lst.nops(); i++) {
                        if (repl_lst.op(i).op(0).is_equal(pattern))
-                               return is_equal(*repl_lst.op(i).op(1).bp);
+                               return is_equal(ex_to<basic>(repl_lst.op(i).op(1)));
                }
                repl_lst.append(pattern == *this);
                return true;
@@ -479,7 +479,7 @@ bool basic::match(const ex & pattern, lst & repl_lst) const
        } else {
 
                // Expression must be of the same type as the pattern
-               if (tinfo() != pattern.bp->tinfo())
+               if (tinfo() != ex_to<basic>(pattern).tinfo())
                        return false;
 
                // Number of subexpressions must match
@@ -489,10 +489,10 @@ bool basic::match(const ex & pattern, lst & repl_lst) const
                // No subexpressions? Then just compare the objects (there can't be
                // wildcards in the pattern)
                if (nops() == 0)
-                       return is_equal_same_type(*pattern.bp);
+                       return is_equal_same_type(ex_to<basic>(pattern));
 
                // Check whether attributes that are not subexpressions match
-               if (!match_same_type(*pattern.bp))
+               if (!match_same_type(ex_to<basic>(pattern)))
                        return false;
 
                // Otherwise the subexpressions must match one-to-one
@@ -513,14 +513,14 @@ ex basic::subs(const lst & ls, const lst & lr, bool no_pattern) const
 
        if (no_pattern) {
                for (unsigned i=0; i<ls.nops(); i++) {
-                       if (is_equal(*ls.op(i).bp))
+                       if (is_equal(ex_to<basic>(ls.op(i))))
                                return lr.op(i);
                }
        } else {
                for (unsigned i=0; i<ls.nops(); i++) {
                        lst repl_lst;
-                       if (match(*ls.op(i).bp, repl_lst))
-                               return lr.op(i).bp->subs(repl_lst, true); // avoid infinite recursion when re-substituting the wildcards
+                       if (match(ex_to<basic>(ls.op(i)), repl_lst))
+                               return lr.op(i).subs(repl_lst, true); // avoid infinite recursion when re-substituting the wildcards
                }
        }
 
@@ -675,7 +675,7 @@ ex basic::expand(unsigned options) const
                return (options == 0) ? setflag(status_flags::expanded) : *this;
        else {
                expand_map_function map_expand(options);
-               return map(map_expand).bp->setflag(options == 0 ? status_flags::expanded : 0);
+               return ex_to<basic>(map(map_expand)).setflag(options == 0 ? status_flags::expanded : 0);
        }
 }
 
index b319e0d..1268d00 100644 (file)
@@ -179,7 +179,7 @@ extern int max_recursion_level;
 
 /** Check if obj is a T, including base classes. */
 template <class T>
-inline bool is_a(const basic & obj)
+inline bool is_a(const basic &obj)
 {
        return dynamic_cast<const T *>(&obj)!=0;
 }
@@ -188,28 +188,29 @@ inline bool is_a(const basic & obj)
  *  inefficient default.  It should in all time-critical cases be overridden
  *  by template specializations that don't create a temporary. */
 template <class T>
-inline bool is_exactly_a(const class basic & obj)
+inline bool is_exactly_a(const class basic &obj)
 {
        const T foo; return foo.tinfo()==obj.tinfo();
 }
 
 /** Check if ex is a handle to a T, including base classes. */
 template <class T>
-inline bool is_a(const ex & obj)
+inline bool is_a(const ex &obj)
 {
        return is_a<T>(*obj.bp);
 }
 
 /** Check if ex is a handle to a T, not including base classes. */
 template <class T>
-inline bool is_exactly_a(const ex & obj)
+inline bool is_exactly_a(const ex &obj)
 {
        return is_exactly_a<T>(*obj.bp);
 }
 
 /** Return a reference to the basic-derived class T object embedded in an
  *  expression.  This is fast but unsafe: the result is undefined if the
- *  expression does not contain a T object at its top level.
+ *  expression does not contain a T object at its top level.  Hence, you
+ *  should generally check the type of e first.
  *
  *  @param e expression
  *  @return reference to pseries object
index bee4618..d488d3b 100644 (file)
@@ -129,7 +129,7 @@ DEFAULT_ARCHIVING(diracgamma5)
 
 int clifford::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, clifford));
+       GINAC_ASSERT(is_a<clifford>(other));
        const clifford &o = static_cast<const clifford &>(other);
 
        if (representation_label != o.representation_label) {
@@ -142,7 +142,7 @@ int clifford::compare_same_type(const basic & other) const
 
 bool clifford::match_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, clifford));
+       GINAC_ASSERT(is_a<clifford>(other));
        const clifford &o = static_cast<const clifford &>(other);
 
        return representation_label == o.representation_label;
index 50a0c70..b6c88d9 100644 (file)
@@ -106,13 +106,6 @@ public:
 
 // global functions
 
-/** Return the clifford object handled by an ex.  Deprecated: use ex_to<clifford>().
- *  This is unsafe: you need to check the type first. */
-inline const clifford &ex_to_clifford(const ex &e)
-{
-       return static_cast<const clifford &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<clifford>(obj) for clifford objects. */
 template<> inline bool is_exactly_a<clifford>(const basic & obj)
 {
index 561f88b..3c316d4 100644 (file)
@@ -28,6 +28,7 @@
 #include "ncmul.h"
 #include "symmetry.h"
 #include "numeric.h"
+#include "mul.h"
 #include "power.h" // for sqrt()
 #include "symbol.h"
 #include "print.h"
@@ -129,7 +130,7 @@ DEFAULT_ARCHIVING(su3d)
 
 int color::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, color));
+       GINAC_ASSERT(is_a<color>(other));
        const color &o = static_cast<const color &>(other);
 
        if (representation_label != o.representation_label) {
@@ -142,7 +143,7 @@ int color::compare_same_type(const basic & other) const
 
 bool color::match_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, color));
+       GINAC_ASSERT(is_a<color>(other));
        const color &o = static_cast<const color &>(other);
 
        return representation_label == o.representation_label;
@@ -223,9 +224,9 @@ static ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2
 /** Automatic symbolic evaluation of indexed symmetric structure constant. */
 ex su3d::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() == 4);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), su3d));
+       GINAC_ASSERT(is_a<su3d>(i.op(0)));
 
        // Convolutions are zero
        if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
@@ -268,9 +269,9 @@ ex su3d::eval_indexed(const basic & i) const
 /** Automatic symbolic evaluation of indexed antisymmetric structure constant. */
 ex su3f::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() == 4);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), su3f));
+       GINAC_ASSERT(is_a<su3f>(i.op(0)));
 
        // Numeric evaluation
        if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
@@ -306,10 +307,10 @@ ex su3f::eval_indexed(const basic & i) const
 /** Contraction of generator with something else. */
 bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 2);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), su3t));
+       GINAC_ASSERT(is_a<su3t>(self->op(0)));
        unsigned char rl = ex_to<color>(*self).get_representation_label();
 
        if (is_ex_exactly_of_type(other->op(0), su3t)) {
@@ -356,10 +357,10 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve
 /** Contraction of an indexed symmetric structure constant with something else. */
 bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 4);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), su3d));
+       GINAC_ASSERT(is_a<su3d>(self->op(0)));
 
        if (is_ex_exactly_of_type(other->op(0), su3d)) {
 
@@ -415,10 +416,10 @@ bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exve
 /** Contraction of an indexed antisymmetric structure constant with something else. */
 bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 4);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), su3f));
+       GINAC_ASSERT(is_a<su3f>(self->op(0)));
 
        if (is_ex_exactly_of_type(other->op(0), su3f)) { // f*d is handled by su3d class
 
index 03b9d8d..cc7ac31 100644 (file)
@@ -117,13 +117,6 @@ public:
 
 // global functions
 
-/** Return the color object handled by an ex.  Deprecated: use ex_to<color>().
- *  This is unsafe: you need to check the type first. */
-inline const color &ex_to_color(const ex &e)
-{
-       return static_cast<const color &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<color>(obj) for color objects. */
 template<> inline bool is_exactly_a<color>(const basic & obj)
 {
index 844a08a..d2a74b2 100644 (file)
@@ -190,7 +190,7 @@ ex constant::derivative(const symbol & s) const
 
 int constant::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other, constant));
+       GINAC_ASSERT(is_exactly_a<constant>(other));
        const constant &o = static_cast<const constant &>(other);
 
        if (serial == o.serial)
@@ -201,7 +201,7 @@ int constant::compare_same_type(const basic & other) const
 
 bool constant::is_equal_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other, constant));
+       GINAC_ASSERT(is_exactly_a<constant>(other));
        const constant &o = static_cast<const constant &>(other);
 
        return serial == o.serial;
index bdd8d69..c43465a 100644 (file)
@@ -81,13 +81,6 @@ extern const constant Euler;
 
 // utility functions
 
-/** Return the constant object handled by an ex.  Deprecated: use ex_to<constant>().
- *  This is unsafe: you need to check the type first. */
-inline const constant &ex_to_constant(const ex &e)
-{
-       return static_cast<const constant &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<constant>(obj) for constant objects. */
 template<> inline bool is_exactly_a<constant>(const basic & obj)
 {
index 8374b9b..8004383 100755 (executable)
@@ -271,24 +271,12 @@ protected:
 
 // utility functions
 
-/** Return the ${CONTAINER} object handled by an ex.  Deprecated: use ex_to<${CONTAINER}>().
- *  This is unsafe: you need to check the type first. */
-inline const ${CONTAINER} &ex_to_${CONTAINER}(const ex &e)
-{
-       return static_cast<const ${CONTAINER} &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<${CONTAINER}>(obj) for ${CONTAINER} objects. */
 template<> inline bool is_exactly_a<${CONTAINER}>(const basic & obj)
 {
        return obj.tinfo()==TINFO_${CONTAINER};
 }
 
-inline ${CONTAINER} &ex_to_nonconst_${CONTAINER}(const ex &e)
-{
-       return static_cast<${CONTAINER} &>(*e.bp);
-}
-
 } // namespace GiNaC
 
 #endif // ndef __GINAC_${CONTAINER_UC}_H__
@@ -495,7 +483,7 @@ ex ${CONTAINER}::subs(const lst & ls, const lst & lr, bool no_pattern) const
 {
        ${STLT} *vp = subschildren(ls, lr, no_pattern);
        if (vp)
-               return this${CONTAINER}(vp).bp->basic::subs(ls, lr, no_pattern);
+               return ex_to<basic>(this${CONTAINER}(vp)).basic::subs(ls, lr, no_pattern);
        else
                return basic::subs(ls, lr, no_pattern);
 }
index b6b9685..0d0657a 100644 (file)
@@ -215,7 +215,7 @@ void ex::makewriteable()
 void ex::construct_from_basic(const basic & other)
 {
        if (!(other.flags & status_flags::evaluated)) {
-               const ex & tmpex(other.eval(1)); // evaluate only one (top) level
+               const ex & tmpex = other.eval(1); // evaluate only one (top) level
                bp = tmpex.bp;
                GINAC_ASSERT(bp->flags & status_flags::dynallocated);
                ++bp->refcount;
index aefb6af..e9f72bb 100644 (file)
@@ -46,7 +46,11 @@ class scalar_products;
  *  a thing a proxy class.) */
 class ex
 {
-       friend class basic;
+       friend class archive_node;
+       friend bool are_ex_trivially_equal(const ex &, const ex &);
+       template<class T> friend const T &ex_to(const ex &);
+       template<class T> friend bool is_a(const ex &);
+       template<class T> friend bool is_exactly_a(const ex &);
        
 // member functions
        
@@ -172,7 +176,7 @@ protected:
 // member variables
 
 public:
-       basic *bp;      ///< pointer to basic object managed by this
+       basic *bp;      ///< pointer to basic object managed by this, direct manipulation deprecated
 #ifdef OBSCURE_CINT_HACK
        static basic * last_created_or_assigned_bp;
        static basic * dummy_bp;
index 5f3dd29..c2dfc6a 100644 (file)
 
 #include "expairseq.h"
 #include "lst.h"
+#include "mul.h"
+#include "power.h"
 #include "relational.h"
+#include "wildcard.h"
 #include "print.h"
 #include "archive.h"
 #include "debugmsg.h"
@@ -38,6 +41,7 @@
 
 namespace GiNaC {
 
+       
 GINAC_IMPLEMENT_REGISTERED_CLASS_NO_CTORS(expairseq, basic)
 
 //////////
@@ -188,7 +192,7 @@ basic *expairseq::duplicate() const
        return new expairseq(*this);
 }
 
-void expairseq::print(const print_context & c, unsigned level) const
+void expairseq::print(const print_context &c, unsigned level) const
 {
        debugmsg("expairseq print",LOGLEVEL_PRINT);
 
@@ -300,7 +304,7 @@ ex &expairseq::let_op(int i)
        throw(std::logic_error("let_op not defined for expairseq and derived classes (add,mul,...)"));
 }
 
-ex expairseq::map(map_function & f) const
+ex expairseq::map(map_function &f) const
 {
        epvector *v = new epvector;
        v->reserve(seq.size());
@@ -335,7 +339,7 @@ bool expairseq::match(const ex & pattern, lst & repl_lst) const
        // This differs from basic::match() because we want "a+b+c+d" to
        // match "d+*+b" with "*" being "a+c", and we want to honor commutativity
 
-       if (tinfo() == pattern.bp->tinfo()) {
+       if (this->tinfo() == ex_to<basic>(pattern).tinfo()) {
 
                // Check whether global wildcard (one that matches the "rest of the
                // expression", like "*" above) is present
@@ -389,7 +393,7 @@ found:              ;
                        ex rest = thisexpairseq(vp, default_overall_coeff());
                        for (unsigned i=0; i<repl_lst.nops(); i++) {
                                if (repl_lst.op(i).op(0).is_equal(global_wildcard))
-                                       return rest.is_equal(*repl_lst.op(i).op(1).bp);
+                                       return rest.is_equal(repl_lst.op(i).op(1));
                        }
                        repl_lst.append(global_wildcard == rest);
                        return true;
@@ -408,7 +412,7 @@ ex expairseq::subs(const lst &ls, const lst &lr, bool no_pattern) const
 {
        epvector *vp = subschildren(ls, lr, no_pattern);
        if (vp)
-               return thisexpairseq(vp, overall_coeff).bp->basic::subs(ls, lr, no_pattern);
+               return ex_to<basic>(thisexpairseq(vp, overall_coeff)).basic::subs(ls, lr, no_pattern);
        else
                return basic::subs(ls, lr, no_pattern);
 }
@@ -417,7 +421,7 @@ ex expairseq::subs(const lst &ls, const lst &lr, bool no_pattern) const
 
 int expairseq::compare_same_type(const basic &other) const
 {
-       GINAC_ASSERT(is_of_type(other, expairseq));
+       GINAC_ASSERT(is_a<expairseq>(other));
        const expairseq &o = static_cast<const expairseq &>(other);
        
        int cmpval;
@@ -552,7 +556,7 @@ unsigned expairseq::return_type(void) const
 
 unsigned expairseq::calchash(void) const
 {
-       unsigned v = golden_ratio_hash(tinfo());
+       unsigned v = golden_ratio_hash(this->tinfo());
        epvector::const_iterator i = seq.begin(), end = seq.end();
        while (i != end) {
 #if !EXPAIRSEQ_USE_HASHTAB
@@ -615,9 +619,9 @@ ex expairseq::thisexpairseq(epvector *vp, const ex &oc) const
 void expairseq::printpair(const print_context & c, const expair & p, unsigned upper_precedence) const
 {
        c.s << "[[";
-       p.rest.bp->print(c, precedence());
+       p.rest.print(c, precedence());
        c.s << ",";
-       p.coeff.bp->print(c, precedence());
+       p.coeff.print(c, precedence());
        c.s << "]]";
 }
 
@@ -654,7 +658,7 @@ expair expairseq::split_ex_to_pair(const ex &e) const
 expair expairseq::combine_ex_with_coeff_to_pair(const ex &e,
                                                 const ex &c) const
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(c));
        
        return expair(e,c);
 }
@@ -663,8 +667,8 @@ expair expairseq::combine_ex_with_coeff_to_pair(const ex &e,
 expair expairseq::combine_pair_with_coeff_to_pair(const expair &p,
                                                   const ex &c) const
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(p.coeff,numeric));
-       GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(p.coeff));
+       GINAC_ASSERT(is_exactly_a<numeric>(c));
        
        return expair(p.rest,ex_to<numeric>(p.coeff).mul_dyn(ex_to<numeric>(c)));
 }
@@ -692,16 +696,16 @@ ex expairseq::default_overall_coeff(void) const
 
 void expairseq::combine_overall_coeff(const ex &c)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
-       GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
+       GINAC_ASSERT(is_exactly_a<numeric>(c));
        overall_coeff = ex_to<numeric>(overall_coeff).add_dyn(ex_to<numeric>(c));
 }
 
 void expairseq::combine_overall_coeff(const ex &c1, const ex &c2)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
-       GINAC_ASSERT(is_ex_exactly_of_type(c1,numeric));
-       GINAC_ASSERT(is_ex_exactly_of_type(c2,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
+       GINAC_ASSERT(is_exactly_a<numeric>(c1));
+       GINAC_ASSERT(is_exactly_a<numeric>(c2));
        overall_coeff = ex_to<numeric>(overall_coeff).
                        add_dyn(ex_to<numeric>(c1).mul(ex_to<numeric>(c2)));
 }
@@ -731,8 +735,8 @@ void expairseq::construct_from_2_ex_via_exvector(const ex &lh, const ex &rh)
 
 void expairseq::construct_from_2_ex(const ex &lh, const ex &rh)
 {
-       if (lh.bp->tinfo()==tinfo()) {
-               if (rh.bp->tinfo()==tinfo()) {
+       if (ex_to<basic>(lh).tinfo()==this->tinfo()) {
+               if (ex_to<basic>(rh).tinfo()==this->tinfo()) {
 #if EXPAIRSEQ_USE_HASHTAB
                        unsigned totalsize = ex_to<expairseq>(lh).seq.size() +
                                             ex_to<expairseq>(rh).seq.size();
@@ -759,7 +763,7 @@ void expairseq::construct_from_2_ex(const ex &lh, const ex &rh)
 #endif // EXPAIRSEQ_USE_HASHTAB
                        return;
                }
-       } else if (rh.bp->tinfo()==tinfo()) {
+       } else if (ex_to<basic>(rh).tinfo()==this->tinfo()) {
 #if EXPAIRSEQ_USE_HASHTAB
                unsigned totalsize=ex_to<expairseq>(rh).seq.size()+1;
                if (calc_hashtabsize(totalsize)!=0) {
@@ -799,7 +803,7 @@ void expairseq::construct_from_2_ex(const ex &lh, const ex &rh)
                        
                        int cmpval = p1.rest.compare(p2.rest);
                        if (cmpval==0) {
-                               p1.coeff=ex_to<numeric>(p1.coeff).add_dyn(ex_to<numeric>(p2.coeff));
+                               p1.coeff = ex_to<numeric>(p1.coeff).add_dyn(ex_to<numeric>(p2.coeff));
                                if (!ex_to<numeric>(p1.coeff).is_zero()) {
                                        // no further processing is necessary, since this
                                        // one element will usually be recombined in eval()
@@ -838,10 +842,10 @@ void expairseq::construct_from_2_expairseq(const expairseq &s1,
                int cmpval = (*first1).rest.compare((*first2).rest);
                if (cmpval==0) {
                        // combine terms
-                       const numeric &newcoeff = ex_to<numeric>((*first1).coeff).
-                                                  add(ex_to<numeric>((*first2).coeff));
+                       const numeric &newcoeff = ex_to<numeric>(first1->coeff).
+                                                  add(ex_to<numeric>(first2->coeff));
                        if (!newcoeff.is_zero()) {
-                               seq.push_back(expair((*first1).rest,newcoeff));
+                               seq.push_back(expair(first1->rest,newcoeff));
                                if (expair_needs_further_processing(seq.end()-1)) {
                                        needs_further_processing = true;
                                }
@@ -980,7 +984,7 @@ void expairseq::make_flat(const exvector &v)
        
        cit = v.begin();
        while (cit!=v.end()) {
-               if (cit->bp->tinfo()==this->tinfo()) {
+               if (ex_to<basic>(*cit).tinfo()==this->tinfo()) {
                        ++nexpairseqs;
                        noperands += ex_to<expairseq>(*cit).seq.size();
                }
@@ -993,7 +997,7 @@ void expairseq::make_flat(const exvector &v)
        // copy elements and split off numerical part
        cit = v.begin();
        while (cit!=v.end()) {
-               if (cit->bp->tinfo()==this->tinfo()) {
+               if (ex_to<basic>(*cit).tinfo()==this->tinfo()) {
                        const expairseq &subseqref = ex_to<expairseq>(*cit);
                        combine_overall_coeff(subseqref.overall_coeff);
                        epvector::const_iterator cit_s = subseqref.seq.begin();
@@ -1024,7 +1028,7 @@ void expairseq::make_flat(const epvector &v)
        
        cit = v.begin();
        while (cit!=v.end()) {
-               if (cit->rest.bp->tinfo()==this->tinfo()) {
+               if (ex_to<basic>(cit->rest).tinfo()==this->tinfo()) {
                        ++nexpairseqs;
                        noperands += ex_to<expairseq>(cit->rest).seq.size();
                }
@@ -1037,7 +1041,7 @@ void expairseq::make_flat(const epvector &v)
        // copy elements and split off numerical part
        cit = v.begin();
        while (cit!=v.end()) {
-               if (cit->rest.bp->tinfo()==this->tinfo() &&
+               if (ex_to<basic>(cit->rest).tinfo()==this->tinfo() &&
                    this->can_make_flat(*cit)) {
                        const expairseq &subseqref = ex_to<expairseq>(cit->rest);
                        combine_overall_coeff(ex_to<numeric>(subseqref.overall_coeff),
index 9fe72d5..5a24edd 100644 (file)
@@ -182,13 +182,6 @@ protected:
 
 // utility functions
 
-/** Return the expairseq object handled by an ex.  Deprecated: use ex_to<expairseq>().
- *  This is unsafe: you need to check the type first. */
-inline const expairseq &ex_to_expairseq(const ex &e)
-{
-       return static_cast<const expairseq &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<expairseq>(obj) for expairseq objects. */
 template<> inline bool is_exactly_a<expairseq>(const basic & obj)
 {
index 7f40359..23fc837 100644 (file)
@@ -198,7 +198,7 @@ ex fderivative::derivative(const symbol & s) const
 
 int fderivative::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, fderivative));
+       GINAC_ASSERT(is_a<fderivative>(other));
        const fderivative & o = static_cast<const fderivative &>(other);
 
        if (parameter_set != o.parameter_set)
@@ -209,7 +209,7 @@ int fderivative::compare_same_type(const basic & other) const
 
 bool fderivative::is_equal_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, fderivative));
+       GINAC_ASSERT(is_a<fderivative>(other));
        const fderivative & o = static_cast<const fderivative &>(other);
 
        if (parameter_set != o.parameter_set)
@@ -220,7 +220,7 @@ bool fderivative::is_equal_same_type(const basic & other) const
 
 bool fderivative::match_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, fderivative));
+       GINAC_ASSERT(is_a<fderivative>(other));
        const fderivative & o = static_cast<const fderivative &>(other);
 
        return parameter_set == o.parameter_set;
index 26f37af..80f9c5e 100755 (executable)
@@ -365,12 +365,6 @@ protected:
 };
 
 // utility functions/macros
-/** Return the object of type function handled by an ex.
- *  This is unsafe: you need to check the type first. */
-inline const function &ex_to_function(const ex &e)
-{
-       return static_cast<const function &>(*e.bp);
-}
 
 /** Specialization of is_exactly_a<function>(obj) for objects of type function. */
 template<> inline bool is_exactly_a<function>(const basic & obj)
@@ -379,7 +373,7 @@ template<> inline bool is_exactly_a<function>(const basic & obj)
 }
 
 #define is_ex_the_function(OBJ, FUNCNAME) \\
-       (is_exactly_a<function>(OBJ) && static_cast<GiNaC::function *>(OBJ.bp)->get_serial() == function_index_##FUNCNAME)
+       (is_exactly_a<GiNaC::function>(OBJ) && ex_to<GiNaC::function>(OBJ).get_serial() == function_index_##FUNCNAME)
 
 } // namespace GiNaC
 
@@ -707,17 +701,17 @@ ex function::expand(unsigned options) const
 
 int function::degree(const ex & s) const
 {
-       return is_equal(*s.bp) ? 1 : 0;
+       return is_equal(ex_to<basic>(s)) ? 1 : 0;
 }
 
 int function::ldegree(const ex & s) const
 {
-       return is_equal(*s.bp) ? 1 : 0;
+       return is_equal(ex_to<basic>(s)) ? 1 : 0;
 }
 
 ex function::coeff(const ex & s, int n) const
 {
-       if (is_equal(*s.bp))
+       if (is_equal(ex_to<basic>(s)))
                return n==1 ? _ex1() : _ex0();
        else
                return n==0 ? ex(*this) : _ex0();
index d704cbd..9017a9c 100644 (file)
@@ -276,7 +276,7 @@ ex & idx::let_op(int i)
  *  must be such that dummy indices lie next to each other. */
 int idx::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, idx));
+       GINAC_ASSERT(is_a<idx>(other));
        const idx &o = static_cast<const idx &>(other);
 
        int cmpval = value.compare(o.value);
@@ -287,7 +287,7 @@ int idx::compare_same_type(const basic & other) const
 
 bool idx::match_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, idx));
+       GINAC_ASSERT(is_a<idx>(other));
        const idx &o = static_cast<const idx &>(other);
 
        return dim.is_equal(o.dim);
@@ -295,7 +295,7 @@ bool idx::match_same_type(const basic & other) const
 
 int varidx::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, varidx));
+       GINAC_ASSERT(is_a<varidx>(other));
        const varidx &o = static_cast<const varidx &>(other);
 
        int cmpval = inherited::compare_same_type(other);
@@ -310,7 +310,7 @@ int varidx::compare_same_type(const basic & other) const
 
 bool varidx::match_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, varidx));
+       GINAC_ASSERT(is_a<varidx>(other));
        const varidx &o = static_cast<const varidx &>(other);
 
        if (covariant != o.covariant)
@@ -320,7 +320,7 @@ bool varidx::match_same_type(const basic & other) const
 
 int spinidx::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, spinidx));
+       GINAC_ASSERT(is_a<spinidx>(other));
        const spinidx &o = static_cast<const spinidx &>(other);
 
        // Check dottedness first so dummy indices will end up next to each other
@@ -336,7 +336,7 @@ int spinidx::compare_same_type(const basic & other) const
 
 bool spinidx::match_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, spinidx));
+       GINAC_ASSERT(is_a<spinidx>(other));
        const spinidx &o = static_cast<const spinidx &>(other);
 
        if (dotted != o.dotted)
@@ -357,7 +357,7 @@ ex idx::subs(const lst & ls, const lst & lr, bool no_pattern) const
 
        // First look for index substitutions
        for (unsigned i=0; i<ls.nops(); i++) {
-               if (is_equal(*(ls.op(i)).bp)) {
+               if (is_equal(ex_to<basic>(ls.op(i)))) {
 
                        // Substitution index->index
                        if (is_ex_of_type(lr.op(i), idx))
index fd1ed47..1ce32d2 100644 (file)
@@ -184,27 +184,6 @@ protected:
 
 // utility functions
 
-/** Return the idx object handled by an ex.  Deprecated: use ex_to<idx>().
- *  This is unsafe: you need to check the type first. */
-inline const idx &ex_to_idx(const ex & e)
-{
-       return static_cast<const idx &>(*e.bp);
-}
-
-/** Return the varidx object handled by an ex.  Deprecated: use ex_to<varidx>().
- *  This is unsafe: you need to check the type first. */
-inline const varidx &ex_to_varidx(const ex & e)
-{
-       return static_cast<const varidx &>(*e.bp);
-}
-
-/** Return the spinidx object handled by an ex.  Deprecated: use ex_to<spinidx>().
- *  This is unsafe: you need to check the type first. */
-inline const spinidx &ex_to_spinidx(const ex & e)
-{
-       return static_cast<const spinidx &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<idx>(obj) for idx objects. */
 template<> inline bool is_exactly_a<idx>(const basic & obj)
 {
index bc6aa83..5759b24 100644 (file)
@@ -174,7 +174,7 @@ indexed::indexed(const archive_node &n, const lst &sym_lst) : inherited(n, sym_l
                                symtree = sy_none();
                                break;
                }
-               ex_to_nonconst_symmetry(symtree).validate(seq.size() - 1);
+               const_cast<symmetry &>(ex_to<symmetry>(symtree)).validate(seq.size() - 1);
        }
 }
 
@@ -250,7 +250,7 @@ bool indexed::all_index_values_are(unsigned inf) const
 
 int indexed::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, indexed));
+       GINAC_ASSERT(is_a<indexed>(other));
        return inherited::compare_same_type(other);
 }
 
@@ -277,7 +277,7 @@ ex indexed::eval(int level) const
        // Canonicalize indices according to the symmetry properties
        if (seq.size() > 2) {
                exvector v = seq;
-               GINAC_ASSERT(is_ex_exactly_of_type(symtree, symmetry));
+               GINAC_ASSERT(is_exactly_a<symmetry>(symtree));
                int sig = canonicalize(v.begin() + 1, ex_to<symmetry>(symtree));
                if (sig != INT_MAX) {
                        // Something has changed while sorting indices, more evaluations later
@@ -288,22 +288,22 @@ ex indexed::eval(int level) const
        }
 
        // Let the class of the base object perform additional evaluations
-       return base.bp->eval_indexed(*this);
+       return ex_to<basic>(base).eval_indexed(*this);
 }
 
 int indexed::degree(const ex & s) const
 {
-       return is_equal(*s.bp) ? 1 : 0;
+       return is_equal(ex_to<basic>(s)) ? 1 : 0;
 }
 
 int indexed::ldegree(const ex & s) const
 {
-       return is_equal(*s.bp) ? 1 : 0;
+       return is_equal(ex_to<basic>(s)) ? 1 : 0;
 }
 
 ex indexed::coeff(const ex & s, int n) const
 {
-       if (is_equal(*s.bp))
+       if (is_equal(ex_to<basic>(s)))
                return n==1 ? _ex1() : _ex0();
        else
                return n==0 ? ex(*this) : _ex0();
@@ -406,7 +406,7 @@ void indexed::validate(void) const
        if (!symtree.is_zero()) {
                if (!is_ex_exactly_of_type(symtree, symmetry))
                        throw(std::invalid_argument("symmetry of indexed object must be of type symmetry"));
-               ex_to_nonconst_symmetry(symtree).validate(seq.size() - 1);
+               const_cast<symmetry &>(ex_to<symmetry>(symtree)).validate(seq.size() - 1);
        }
 }
 
@@ -669,12 +669,12 @@ try_again:
                        }
 
                        // Try to contract the first one with the second one
-                       contracted = it1->op(0).bp->contract_with(it1, it2, v);
+                       contracted = ex_to<basic>(it1->op(0)).contract_with(it1, it2, v);
                        if (!contracted) {
 
                                // That didn't work; maybe the second object knows how to
                                // contract itself with the first one
-                               contracted = it2->op(0).bp->contract_with(it2, it1, v);
+                               contracted = ex_to<basic>(it2->op(0)).contract_with(it2, it1, v);
                        }
                        if (contracted) {
 contraction_done:
@@ -745,7 +745,7 @@ contraction_done:
        // Product of indexed object with a scalar?
        if (is_ex_exactly_of_type(r, mul) && r.nops() == 2
         && is_ex_exactly_of_type(r.op(1), numeric) && is_ex_of_type(r.op(0), indexed))
-               return r.op(0).op(0).bp->scalar_mul_indexed(r.op(0), ex_to<numeric>(r.op(1)));
+               return ex_to<basic>(r.op(0).op(0)).scalar_mul_indexed(r.op(0), ex_to<numeric>(r.op(1)));
        else
                return r;
 }
@@ -784,7 +784,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi
                                        if (!indices_consistent(free_indices, free_indices_of_term))
                                                throw (std::runtime_error("simplify_indexed: inconsistent indices in sum"));
                                        if (is_ex_of_type(sum, indexed) && is_ex_of_type(term, indexed))
-                                               sum = sum.op(0).bp->add_indexed(sum, term);
+                                               sum = ex_to<basic>(sum.op(0)).add_indexed(sum, term);
                                        else
                                                sum += term;
                                }
index b5a0dce..a2ee749 100644 (file)
@@ -235,13 +235,6 @@ private:
 
 // utility functions
 
-/** Return the indexed object handled by an ex.  Deprecated: use ex_to<indexed>().
- *  This is unsafe: you need to check the type first. */
-inline const indexed &ex_to_indexed(const ex &e)
-{
-       return static_cast<const indexed &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<indexed>(obj) for indexed objects. */
 template<> inline bool is_exactly_a<indexed>(const basic & obj)
 {
index ebf0451..440354a 100644 (file)
@@ -407,10 +407,10 @@ static ex Order_eval(const ex & x)
                else
                        return _ex0();
        } else if (is_ex_exactly_of_type(x, mul)) {
-               mul *m = static_cast<mul *>(x.bp);
+               const mul &m = ex_to<mul>(x);
                // O(c*expr) -> O(expr)
-               if (is_ex_exactly_of_type(m->op(m->nops() - 1), numeric))
-                       return Order(x / m->op(m->nops() - 1)).hold();
+               if (is_ex_exactly_of_type(m.op(m.nops() - 1), numeric))
+                       return Order(x / m.op(m.nops() - 1)).hold();
        }
        return Order(x).hold();
 }
@@ -419,7 +419,7 @@ static ex Order_series(const ex & x, const relational & r, int order, unsigned o
 {
        // Just wrap the function into a pseries object
        epvector new_seq;
-       GINAC_ASSERT(is_ex_exactly_of_type(r.lhs(),symbol));
+       GINAC_ASSERT(is_exactly_a<symbol>(r.lhs()));
        const symbol &s = ex_to<symbol>(r.lhs());
        new_seq.push_back(expair(Order(_ex1()), numeric(std::min(x.ldegree(s), order))));
        return pseries(r, new_seq);
@@ -444,7 +444,7 @@ ex lsolve(const ex &eqns, const ex &symbols, unsigned options)
                const ex sol = lsolve(lst(eqns),lst(symbols));
                
                GINAC_ASSERT(sol.nops()==1);
-               GINAC_ASSERT(is_ex_exactly_of_type(sol.op(0),relational));
+               GINAC_ASSERT(is_exactly_a<relational>(sol.op(0)));
                
                return sol.op(0).op(1); // return rhs of first solution
        }
index ef0169b..928a6b5 100644 (file)
@@ -291,7 +291,7 @@ static ex beta_series(const ex & arg1,
        // tgamma series directly.
        const ex arg1_pt = arg1.subs(rel);
        const ex arg2_pt = arg2.subs(rel);
-       GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol));
+       GINAC_ASSERT(is_exactly_a<symbol>(rel.lhs()));
        const symbol &s = ex_to<symbol>(rel.lhs());
        ex arg1_ser, arg2_ser, arg1arg2_ser;
        if ((!arg1_pt.info(info_flags::integer) || arg1_pt.info(info_flags::positive)) &&
index 3b2608e..507e18f 100644 (file)
@@ -146,7 +146,7 @@ static ex log_series(const ex &arg,
                      int order,
                      unsigned options)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol));
+       GINAC_ASSERT(is_exactly_a<symbol>(rel.lhs()));
        ex arg_pt;
        bool must_expand_arg = false;
        // maybe substitution of rel into arg fails because of a pole
@@ -460,7 +460,7 @@ static ex tan_series(const ex &x,
                      int order,
                      unsigned options)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol));
+       GINAC_ASSERT(is_exactly_a<symbol>(rel.lhs()));
        // method:
        // Taylor series where there is no pole falls back to tan_deriv.
        // On a pole simply expand sin(x)/cos(x).
@@ -626,7 +626,7 @@ static ex atan_series(const ex &arg,
                       int order,
                       unsigned options)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol));
+       GINAC_ASSERT(is_exactly_a<symbol>(rel.lhs()));
        // method:
        // Taylor series where there is no pole or cut falls back to atan_deriv.
        // There are two branch cuts, one runnig from I up the imaginary axis and
@@ -870,7 +870,7 @@ static ex tanh_series(const ex &x,
                       int order,
                       unsigned options)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol));
+       GINAC_ASSERT(is_exactly_a<symbol>(rel.lhs()));
        // method:
        // Taylor series where there is no pole falls back to tanh_deriv.
        // On a pole simply expand sinh(x)/cosh(x).
@@ -1011,7 +1011,7 @@ static ex atanh_series(const ex &arg,
                        int order,
                        unsigned options)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol));
+       GINAC_ASSERT(is_exactly_a<symbol>(rel.lhs()));
        // method:
        // Taylor series where there is no pole or cut falls back to atanh_deriv.
        // There are two branch cuts, one runnig from 1 up the real axis and one
index 5e29e48..bbc0764 100644 (file)
@@ -89,13 +89,13 @@ exp : T_NUMBER              {$$ = $1;}
                if (is_lexer_symbol_predefined($1))
                        $$ = $1.eval();
                else
-                       throw (std::runtime_error("unknown symbol '" + ex_to_symbol($1).get_name() + "'"));
+                       throw (std::runtime_error("unknown symbol '" + ex_to<symbol>($1).get_name() + "'"));
        }
        | T_LITERAL             {$$ = $1;}
        | T_DIGITS              {$$ = $1;}
        | T_SYMBOL '(' exprseq ')' {
-               unsigned i = function::find_function(ex_to_symbol($1).get_name(), $3.nops());
-               $$ = function(i, static_cast<const exprseq &>(*($3.bp))).eval(1);
+               unsigned i = function::find_function(ex_to<symbol>($1).get_name(), $3.nops());
+               $$ = function(i, ex_to<exprseq>($3)).eval(1);
        }
        | exp T_EQUAL exp       {$$ = $1 == $3;}
        | exp T_NOTEQ exp       {$$ = $1 != $3;}
@@ -113,11 +113,11 @@ exp       : T_NUMBER              {$$ = $1;}
        | exp '!'               {$$ = factorial($1);}
        | '(' exp ')'           {$$ = $2;}
        | '{' list_or_empty '}' {$$ = $2;}
-       | '[' matrix ']'        {$$ = lst_to_matrix(ex_to_lst($2));}
+       | '[' matrix ']'        {$$ = lst_to_matrix(ex_to<lst>($2));}
        ;
 
 exprseq        : exp                   {$$ = exprseq($1);}
-       | exprseq ',' exp       {exprseq es(static_cast<exprseq &>(*($1.bp))); $$ = es.append($3);}
+       | exprseq ',' exp       {exprseq es(ex_to<exprseq>($1)); $$ = es.append($3);}
        ;
 
 list_or_empty: /* empty */     {$$ = *new lst;}
@@ -125,15 +125,15 @@ list_or_empty: /* empty */        {$$ = *new lst;}
        ;
 
 list   : exp                   {$$ = lst($1);}
-       | list ',' exp          {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($3);}
+       | list ',' exp          {lst l(ex_to<lst>($1)); $$ = l.append($3);}
        ;
 
 matrix : '[' row ']'           {$$ = lst($2);}
-       | matrix ',' '[' row ']' {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($4);}
+       | matrix ',' '[' row ']' {lst l(ex_to<lst>($1)); $$ = l.append($4);}
        ;
 
 row    : exp                   {$$ = lst($1);}
-       | row ',' exp           {lst l(static_cast<lst &>(*($1.bp))); $$ = l.append($3);}
+       | row ',' exp           {lst l(ex_to<lst>($1)); $$ = l.append($3);}
        ;
 
 
index e9c6817..c48fb6b 100644 (file)
@@ -150,7 +150,7 @@ void matrix::print(const print_context & c, unsigned level) const
 {
        debugmsg("matrix print", LOGLEVEL_PRINT);
 
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
 
                inherited::print(c, level);
 
@@ -236,8 +236,8 @@ ex matrix::subs(const lst & ls, const lst & lr, bool no_pattern) const
 
 int matrix::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other, matrix));
-       const matrix & o = static_cast<const matrix &>(other);
+       GINAC_ASSERT(is_exactly_a<matrix>(other));
+       const matrix &o = static_cast<const matrix &>(other);
        
        // compare number of rows
        if (row != o.rows())
@@ -261,7 +261,7 @@ int matrix::compare_same_type(const basic & other) const
 
 bool matrix::match_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other, matrix));
+       GINAC_ASSERT(is_exactly_a<matrix>(other));
        const matrix & o = static_cast<const matrix &>(other);
        
        // The number of rows and columns must be the same. This is necessary to
@@ -272,8 +272,8 @@ bool matrix::match_same_type(const basic & other) const
 /** Automatic symbolic evaluation of an indexed matrix. */
 ex matrix::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
-       GINAC_ASSERT(is_ex_of_type(i.op(0), matrix));
+       GINAC_ASSERT(is_a<indexed>(i));
+       GINAC_ASSERT(is_a<matrix>(i.op(0)));
 
        bool all_indices_unsigned = static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint);
 
@@ -349,9 +349,9 @@ ex matrix::eval_indexed(const basic & i) const
 /** Sum of two indexed matrices. */
 ex matrix::add_indexed(const ex & self, const ex & other) const
 {
-       GINAC_ASSERT(is_ex_of_type(self, indexed));
-       GINAC_ASSERT(is_ex_of_type(self.op(0), matrix));
-       GINAC_ASSERT(is_ex_of_type(other, indexed));
+       GINAC_ASSERT(is_a<indexed>(self));
+       GINAC_ASSERT(is_a<matrix>(self.op(0)));
+       GINAC_ASSERT(is_a<indexed>(other));
        GINAC_ASSERT(self.nops() == 2 || self.nops() == 3);
 
        // Only add two matrices
@@ -385,8 +385,8 @@ ex matrix::add_indexed(const ex & self, const ex & other) const
 /** Product of an indexed matrix with a number. */
 ex matrix::scalar_mul_indexed(const ex & self, const numeric & other) const
 {
-       GINAC_ASSERT(is_ex_of_type(self, indexed));
-       GINAC_ASSERT(is_ex_of_type(self.op(0), matrix));
+       GINAC_ASSERT(is_a<indexed>(self));
+       GINAC_ASSERT(is_a<matrix>(self.op(0)));
        GINAC_ASSERT(self.nops() == 2 || self.nops() == 3);
 
        const matrix &self_matrix = ex_to<matrix>(self.op(0));
@@ -400,10 +400,10 @@ ex matrix::scalar_mul_indexed(const ex & self, const numeric & other) const
 /** Contraction of an indexed matrix with something else. */
 bool matrix::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 2 || self->nops() == 3);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), matrix));
+       GINAC_ASSERT(is_a<matrix>(self->op(0)));
 
        // Only contract with other matrices
        if (!is_ex_of_type(other->op(0), matrix))
@@ -1401,11 +1401,11 @@ int matrix::pivot(unsigned ro, unsigned co, bool symbolic)
                        ++k;
        } else {
                // search largest element in column co beginning at row ro
-               GINAC_ASSERT(is_ex_of_type(this->m[k*col+co],numeric));
+               GINAC_ASSERT(is_a<numeric>(this->m[k*col+co]));
                unsigned kmax = k+1;
                numeric mmax = abs(ex_to<numeric>(m[kmax*col+co]));
                while (kmax<row) {
-                       GINAC_ASSERT(is_ex_of_type(this->m[kmax*col+co],numeric));
+                       GINAC_ASSERT(is_a<numeric>(this->m[kmax*col+co]));
                        numeric tmp = ex_to<numeric>(this->m[kmax*col+co]);
                        if (abs(tmp) > mmax) {
                                mmax = tmp;
index 5921374..acc5254 100644 (file)
@@ -132,13 +132,6 @@ inline matrix inverse(const matrix & m)
 
 // utility functions
 
-/** Return the matrix object handled by an ex.  Deprecated: use ex_to<matrix>().
- *  This is unsafe: you need to check the type first. */
-inline const matrix &ex_to_matrix(const ex &e)
-{
-       return static_cast<const matrix &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<matrix>(obj) for matrix objects. */
 template<> inline bool is_exactly_a<matrix>(const basic & obj)
 {
index 542e802..da23307 100644 (file)
@@ -353,12 +353,12 @@ ex mul::eval(int level) const
 #ifdef DO_GINAC_ASSERT
        epvector::const_iterator i = seq.begin(), end = seq.end();
        while (i != end) {
-               GINAC_ASSERT((!is_ex_exactly_of_type(i->rest, mul)) ||
+               GINAC_ASSERT((!is_exactly_a<mul>(i->rest)) ||
                             (!(ex_to<numeric>(i->coeff).is_integer())));
                GINAC_ASSERT(!(i->is_canonical_numeric()));
                if (is_ex_exactly_of_type(recombine_pair_to_ex(*i), numeric))
                    print(print_tree(std::cerr));
-               GINAC_ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*i), numeric));
+               GINAC_ASSERT(!is_exactly_a<numeric>(recombine_pair_to_ex(*i)));
                /* for paranoia */
                expair p = split_ex_to_pair(recombine_pair_to_ex(*i));
                GINAC_ASSERT(p.rest.is_equal(i->rest));
@@ -648,22 +648,22 @@ ex mul::default_overall_coeff(void) const
 
 void mul::combine_overall_coeff(const ex & c)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
-       GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
+       GINAC_ASSERT(is_exactly_a<numeric>(c));
        overall_coeff = ex_to<numeric>(overall_coeff).mul_dyn(ex_to<numeric>(c));
 }
 
 void mul::combine_overall_coeff(const ex & c1, const ex & c2)
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
-       GINAC_ASSERT(is_ex_exactly_of_type(c1,numeric));
-       GINAC_ASSERT(is_ex_exactly_of_type(c2,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
+       GINAC_ASSERT(is_exactly_a<numeric>(c1));
+       GINAC_ASSERT(is_exactly_a<numeric>(c2));
        overall_coeff = ex_to<numeric>(overall_coeff).mul_dyn(ex_to<numeric>(c1).power(ex_to<numeric>(c2)));
 }
 
 bool mul::can_make_flat(const expair & p) const
 {
-       GINAC_ASSERT(is_ex_exactly_of_type(p.coeff,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(p.coeff));
        // this assertion will probably fail somewhere
        // it would require a more careful make_flat, obeying the power laws
        // probably should return true only if p.coeff is integer
index 23e0e1f..830c213 100644 (file)
@@ -91,13 +91,6 @@ protected:
 
 // utility functions
 
-/** Return the mul object handled by an ex.  Deprecated: use ex_to<mul>().
- *  This is unsafe: you need to check the type first. */
-inline const mul &ex_to_mul(const ex &e)
-{
-       return static_cast<const mul &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<mul>(obj) for mul objects. */
 template<> inline bool is_exactly_a<mul>(const basic & obj)
 {
index eecafef..473a1c9 100644 (file)
@@ -118,11 +118,11 @@ void ncmul::print(const print_context & c, unsigned level) const
 {
        debugmsg("ncmul print", LOGLEVEL_PRINT);
 
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
 
                inherited::print(c, level);
 
-       } else if (is_of_type(c, print_csrc)) {
+       } else if (is_a<print_csrc>(c)) {
 
                c.s << "ncmul(";
                exvector::const_iterator it = seq.begin(), itend = seq.end()-1;
index 67d381b..6369621 100644 (file)
@@ -89,13 +89,6 @@ ex simplified_ncmul(const exvector & v);
 
 // utility functions
 
-/** Return the ncmul object handled by an ex.  Deprecated: use ex_to<ncmul>().
- *  This is unsafe: you need to check the type first. */
-inline const ncmul &ex_to_ncmul(const ex &e)
-{
-       return static_cast <const ncmul &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<ncmul>(obj) for ncmul objects. */
 template<> inline bool is_exactly_a<ncmul>(const basic & obj)
 {
index c948680..e9117c4 100644 (file)
@@ -322,12 +322,12 @@ numeric add::integer_content(void) const
        epvector::const_iterator itend = seq.end();
        numeric c = _num0();
        while (it != itend) {
-               GINAC_ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
-               GINAC_ASSERT(is_ex_exactly_of_type(it->coeff,numeric));
+               GINAC_ASSERT(!is_exactly_a<numeric>(it->rest));
+               GINAC_ASSERT(is_exactly_a<numeric>(it->coeff));
                c = gcd(ex_to<numeric>(it->coeff), c);
                it++;
        }
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
        c = gcd(ex_to<numeric>(overall_coeff),c);
        return c;
 }
@@ -338,11 +338,11 @@ numeric mul::integer_content(void) const
        epvector::const_iterator it = seq.begin();
        epvector::const_iterator itend = seq.end();
        while (it != itend) {
-               GINAC_ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
+               GINAC_ASSERT(!is_exactly_a<numeric>(recombine_pair_to_ex(*it)));
                ++it;
        }
 #endif // def DO_GINAC_ASSERT
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
        return abs(ex_to<numeric>(overall_coeff));
 }
 
@@ -1228,11 +1228,11 @@ numeric add::max_coefficient(void) const
 {
        epvector::const_iterator it = seq.begin();
        epvector::const_iterator itend = seq.end();
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
        numeric cur_max = abs(ex_to<numeric>(overall_coeff));
        while (it != itend) {
                numeric a;
-               GINAC_ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
+               GINAC_ASSERT(!is_exactly_a<numeric>(it->rest));
                a = abs(ex_to<numeric>(it->coeff));
                if (a > cur_max)
                        cur_max = a;
@@ -1247,11 +1247,11 @@ numeric mul::max_coefficient(void) const
        epvector::const_iterator it = seq.begin();
        epvector::const_iterator itend = seq.end();
        while (it != itend) {
-               GINAC_ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
+               GINAC_ASSERT(!is_exactly_a<numeric>(recombine_pair_to_ex(*it)));
                it++;
        }
 #endif // def DO_GINAC_ASSERT
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
        return abs(ex_to<numeric>(overall_coeff));
 }
 
@@ -1279,13 +1279,13 @@ ex add::smod(const numeric &xi) const
        epvector::const_iterator it = seq.begin();
        epvector::const_iterator itend = seq.end();
        while (it != itend) {
-               GINAC_ASSERT(!is_ex_exactly_of_type(it->rest,numeric));
+               GINAC_ASSERT(!is_exactly_a<numeric>(it->rest));
                numeric coeff = GiNaC::smod(ex_to<numeric>(it->coeff), xi);
                if (!coeff.is_zero())
                        newseq.push_back(expair(it->rest, coeff));
                it++;
        }
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
        numeric coeff = GiNaC::smod(ex_to<numeric>(overall_coeff), xi);
        return (new add(newseq,coeff))->setflag(status_flags::dynallocated);
 }
@@ -1296,12 +1296,12 @@ ex mul::smod(const numeric &xi) const
        epvector::const_iterator it = seq.begin();
        epvector::const_iterator itend = seq.end();
        while (it != itend) {
-               GINAC_ASSERT(!is_ex_exactly_of_type(recombine_pair_to_ex(*it),numeric));
+               GINAC_ASSERT(!is_exactly_a<numeric>(recombine_pair_to_ex(*it)));
                it++;
        }
 #endif // def DO_GINAC_ASSERT
        mul * mulcopyp = new mul(*this);
-       GINAC_ASSERT(is_ex_exactly_of_type(overall_coeff,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(overall_coeff));
        mulcopyp->overall_coeff = GiNaC::smod(ex_to<numeric>(overall_coeff),xi);
        mulcopyp->clearflag(status_flags::evaluated);
        mulcopyp->clearflag(status_flags::hash_calculated);
@@ -2030,7 +2030,7 @@ static ex frac_cancel(const ex &n, const ex &d)
        // as defined by get_first_symbol() is made positive)
        const symbol *x;
        if (get_first_symbol(den, x)) {
-               GINAC_ASSERT(is_ex_exactly_of_type(den.unit(*x),numeric));
+               GINAC_ASSERT(is_exactly_a<numeric>(den.unit(*x)));
                if (ex_to<numeric>(den.unit(*x)).is_negative()) {
                        num *= _ex_1();
                        den *= _ex_1();
@@ -2226,7 +2226,7 @@ ex ex::normal(int level) const
        lst sym_lst, repl_lst;
 
        ex e = bp->normal(sym_lst, repl_lst, level);
-       GINAC_ASSERT(is_ex_of_type(e, lst));
+       GINAC_ASSERT(is_a<lst>(e));
 
        // Re-insert replaced symbols
        if (sym_lst.nops() > 0)
@@ -2247,7 +2247,7 @@ ex ex::numer(void) const
        lst sym_lst, repl_lst;
 
        ex e = bp->normal(sym_lst, repl_lst, 0);
-       GINAC_ASSERT(is_ex_of_type(e, lst));
+       GINAC_ASSERT(is_a<lst>(e));
 
        // Re-insert replaced symbols
        if (sym_lst.nops() > 0)
@@ -2267,7 +2267,7 @@ ex ex::denom(void) const
        lst sym_lst, repl_lst;
 
        ex e = bp->normal(sym_lst, repl_lst, 0);
-       GINAC_ASSERT(is_ex_of_type(e, lst));
+       GINAC_ASSERT(is_a<lst>(e));
 
        // Re-insert replaced symbols
        if (sym_lst.nops() > 0)
@@ -2287,7 +2287,7 @@ ex ex::numer_denom(void) const
        lst sym_lst, repl_lst;
 
        ex e = bp->normal(sym_lst, repl_lst, 0);
-       GINAC_ASSERT(is_ex_of_type(e, lst));
+       GINAC_ASSERT(is_a<lst>(e));
 
        // Re-insert replaced symbols
        if (sym_lst.nops() > 0)
index bdd8903..9d5f7f0 100644 (file)
@@ -583,7 +583,7 @@ ex numeric::evalf(int level) const
 
 int numeric::compare_same_type(const basic &other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other, numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(other));
        const numeric &o = static_cast<const numeric &>(other);
        
        return this->compare(o);
@@ -592,7 +592,7 @@ int numeric::compare_same_type(const basic &other) const
 
 bool numeric::is_equal_same_type(const basic &other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other,numeric));
+       GINAC_ASSERT(is_exactly_a<numeric>(other));
        const numeric &o = static_cast<const numeric &>(other);
        
        return this->is_equal(o);
index 09f1523..6599ffb 100644 (file)
@@ -286,13 +286,6 @@ ex CatalanEvalf(void);
 
 // utility functions
 
-/** Return the numeric object handled by an ex.  Deprecated: use ex_to<numeric>().
- *  This is unsafe: you need to check the type first. */
-inline const numeric &ex_to_numeric(const ex &e)
-{
-       return static_cast<const numeric &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<numeric>(obj) for numeric objects. */
 template<> inline bool is_exactly_a<numeric>(const basic & obj)
 {
index 6618194..33f572f 100644 (file)
@@ -551,7 +551,7 @@ ex power::derivative(const symbol & s) const
 
 int power::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other, power));
+       GINAC_ASSERT(is_exactly_a<power>(other));
        const power &o = static_cast<const power &>(other);
 
        int cmpval = basis.compare(o.basis);
@@ -671,13 +671,13 @@ ex power::expand_add(const add & a, int n) const
                term.reserve(m+1);
                for (l=0; l<m-1; l++) {
                        const ex & b = a.op(l);
-                       GINAC_ASSERT(!is_ex_exactly_of_type(b,add));
-                       GINAC_ASSERT(!is_ex_exactly_of_type(b,power) ||
-                                    !is_ex_exactly_of_type(ex_to<power>(b).exponent,numeric) ||
+                       GINAC_ASSERT(!is_exactly_a<add>(b));
+                       GINAC_ASSERT(!is_exactly_a<power>(b) ||
+                                    !is_exactly_a<numeric>(ex_to<power>(b).exponent) ||
                                     !ex_to<numeric>(ex_to<power>(b).exponent).is_pos_integer() ||
-                                    !is_ex_exactly_of_type(ex_to<power>(b).basis,add) ||
-                                    !is_ex_exactly_of_type(ex_to<power>(b).basis,mul) ||
-                                    !is_ex_exactly_of_type(ex_to<power>(b).basis,power));
+                                    !is_exactly_a<add>(ex_to<power>(b).basis) ||
+                                    !is_exactly_a<mul>(ex_to<power>(b).basis) ||
+                                    !is_exactly_a<power>(ex_to<power>(b).basis));
                        if (is_ex_exactly_of_type(b,mul))
                                term.push_back(expand_mul(ex_to<mul>(b),numeric(k[l])));
                        else
@@ -685,13 +685,13 @@ ex power::expand_add(const add & a, int n) const
                }
                
                const ex & b = a.op(l);
-               GINAC_ASSERT(!is_ex_exactly_of_type(b,add));
-               GINAC_ASSERT(!is_ex_exactly_of_type(b,power) ||
-                            !is_ex_exactly_of_type(ex_to<power>(b).exponent,numeric) ||
+               GINAC_ASSERT(!is_exactly_a<add>(b));
+               GINAC_ASSERT(!is_exactly_a<power>(b) ||
+                            !is_exactly_a<numeric>(ex_to<power>(b).exponent) ||
                             !ex_to<numeric>(ex_to<power>(b).exponent).is_pos_integer() ||
-                            !is_ex_exactly_of_type(ex_to<power>(b).basis,add) ||
-                            !is_ex_exactly_of_type(ex_to<power>(b).basis,mul) ||
-                            !is_ex_exactly_of_type(ex_to<power>(b).basis,power));
+                            !is_exactly_a<add>(ex_to<power>(b).basis) ||
+                            !is_exactly_a<mul>(ex_to<power>(b).basis) ||
+                            !is_exactly_a<power>(ex_to<power>(b).basis));
                if (is_ex_exactly_of_type(b,mul))
                        term.push_back(expand_mul(ex_to<mul>(b),numeric(n-k_cum[m-2])));
                else
@@ -746,13 +746,13 @@ ex power::expand_add_2(const add & a) const
                const ex & r = cit0->rest;
                const ex & c = cit0->coeff;
                
-               GINAC_ASSERT(!is_ex_exactly_of_type(r,add));
-               GINAC_ASSERT(!is_ex_exactly_of_type(r,power) ||
-                            !is_ex_exactly_of_type(ex_to<power>(r).exponent,numeric) ||
+               GINAC_ASSERT(!is_exactly_a<add>(r));
+               GINAC_ASSERT(!is_exactly_a<power>(r) ||
+                            !is_exactly_a<numeric>(ex_to<power>(r).exponent) ||
                             !ex_to<numeric>(ex_to<power>(r).exponent).is_pos_integer() ||
-                            !is_ex_exactly_of_type(ex_to<power>(r).basis,add) ||
-                            !is_ex_exactly_of_type(ex_to<power>(r).basis,mul) ||
-                            !is_ex_exactly_of_type(ex_to<power>(r).basis,power));
+                            !is_exactly_a<add>(ex_to<power>(r).basis) ||
+                            !is_exactly_a<mul>(ex_to<power>(r).basis) ||
+                            !is_exactly_a<power>(ex_to<power>(r).basis));
                
                if (are_ex_trivially_equal(c,_ex1())) {
                        if (is_ex_exactly_of_type(r,mul)) {
index 175fea0..06f9681 100644 (file)
@@ -90,13 +90,6 @@ protected:
 
 // utility functions
 
-/** Return the power object handled by an ex.  Deprecated: use ex_to<power>().
- *  This is unsafe: you need to check the type first. */
-inline const power &ex_to_power(const ex &e)
-{
-       return static_cast<const power &>(*e.bp);
-}
-
 /** Efficient specialization of is_exactly_a<power>(obj) for power objects. */
 template<> inline bool is_exactly_a<power>(const basic & obj)
 {
index 441ee40..b348fd3 100644 (file)
@@ -208,7 +208,7 @@ void pseries::print(const print_context & c, unsigned level) const
 
 int pseries::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, pseries));
+       GINAC_ASSERT(is_a<pseries>(other));
        const pseries &o = static_cast<const pseries &>(other);
        
        // first compare the lengths of the series...
index bd2db15..2ab9bfc 100644 (file)
@@ -101,17 +101,8 @@ protected:
        ex point;
 };
 
-/** Return a reference to the pseries object embedded in an expression.
- *  The result is undefined if the expression does not contain a pseries
- *  object at its top level.
- *
- *  @param e expression
- *  @return reference to pseries object
- *  @see is_a<> */
-inline const pseries &ex_to_pseries(const ex &e)
-{
-       return static_cast<const pseries &>(*e.bp);
-}
+
+// utility functions
 
 /** Specialization of is_exactly_a<pseries>(obj) for pseries objects. */
 template<> inline bool is_exactly_a<pseries>(const basic & obj)
@@ -129,7 +120,7 @@ template<> inline bool is_exactly_a<pseries>(const basic & obj)
  *  @see pseries::convert_to_poly */
 inline ex series_to_poly(const ex &e)
 {
-       return (static_cast<const pseries &>(*e.bp).convert_to_poly(true));
+       return (ex_to<pseries>(e).convert_to_poly(true));
 }
 
 inline bool is_terminating(const pseries & s)
index c4e34dd..6d51a56 100644 (file)
@@ -101,7 +101,7 @@ void relational::print(const print_context & c, unsigned level) const
 {
        debugmsg("relational print",LOGLEVEL_PRINT);
 
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
 
                inherited::print(c, level);
 
@@ -192,7 +192,7 @@ ex relational::simplify_ncmul(const exvector & v) const
 
 int relational::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other, relational));
+       GINAC_ASSERT(is_exactly_a<relational>(other));
        const relational &oth = static_cast<const relational &>(other);
        
        if (o == oth.o) {
@@ -207,7 +207,7 @@ int relational::compare_same_type(const basic & other) const
 
 bool relational::match_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_exactly_of_type(other, relational));
+       GINAC_ASSERT(is_exactly_a<relational>(other));
        const relational &oth = static_cast<const relational &>(other);
 
        return o == oth.o;
index 40c799b..fb11115 100644 (file)
@@ -83,13 +83,6 @@ protected:
 
 // utility functions
 
-/** Return the relational object handled by an ex.  Deprecated: use ex_to<relational>().
- *  This is unsafe: you need to check the type first. */
-inline const relational &ex_to_relational(const ex &e)
-{
-       return static_cast<const relational &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<relational>(obj) for relational objects. */
 template<> inline bool is_exactly_a<relational>(const basic & obj)
 {
index e1ea6d5..b094c09 100644 (file)
@@ -52,7 +52,7 @@ void structure::print(const print_context & c, unsigned level) const
 {
        debugmsg("structure print",LOGLEVEL_PRINT);
 
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
 
                c.s << std::string(level, ' ') << class_name()
                    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
@@ -68,7 +68,7 @@ DEFAULT_COMPARE(structure)
 
 bool structure::is_equal_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, structure));
+       GINAC_ASSERT(is_a<structure>(other));
        return true; // all structures are the same
 }
 
index 322a45c..9d29168 100644 (file)
@@ -153,14 +153,14 @@ void symbol::print(const print_context & c, unsigned level) const
 {
        debugmsg("symbol print", LOGLEVEL_PRINT);
 
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
 
                c.s << std::string(level, ' ') << name << " (" << class_name() << ")"
                    << ", serial=" << serial
                    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
                    << std::endl;
 
-       } else if (is_of_type(c, print_latex))
+       } else if (is_a<print_latex>(c))
                c.s << TeX_name;
        else
                c.s << name;
@@ -230,7 +230,7 @@ ex symbol::derivative(const symbol & s) const
 
 int symbol::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other,symbol));
+       GINAC_ASSERT(is_a<symbol>(other));
        const symbol *o = static_cast<const symbol *>(&other);
        if (serial==o->serial) return 0;
        return serial < o->serial ? -1 : 1;
@@ -238,7 +238,7 @@ int symbol::compare_same_type(const basic & other) const
 
 bool symbol::is_equal_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other,symbol));
+       GINAC_ASSERT(is_a<symbol>(other));
        const symbol *o = static_cast<const symbol *>(&other);
        return serial==o->serial;
 }
index 2d9ec3b..fb4b99e 100644 (file)
@@ -113,18 +113,6 @@ private:
 
 // utility functions
 
-/** Return the symbol object handled by an ex.  Deprecated: use ex_to<symbol>().
- *  This is unsafe: you need to check the type first. */
-inline const symbol &ex_to_symbol(const ex &e)
-{
-       return static_cast<const symbol &>(*e.bp);
-}
-
-inline symbol &ex_to_nonconst_symbol(const ex &e)
-{
-       return static_cast<symbol &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<symbol>(obj) for symbol objects. */
 template<> inline bool is_exactly_a<symbol>(const basic & obj)
 {
index 2312526..e0f1ba3 100644 (file)
@@ -154,7 +154,7 @@ DEFAULT_UNARCHIVE(symmetry)
 
 int symmetry::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, symmetry));
+       GINAC_ASSERT(is_a<symmetry>(other));
 
        // All symmetry trees are equal. They are not supposed to appear in
        // ordinary expressions anyway...
@@ -165,7 +165,7 @@ void symmetry::print(const print_context & c, unsigned level) const
 {
        debugmsg("symmetry print", LOGLEVEL_PRINT);
 
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
 
                c.s << std::string(level, ' ') << class_name()
                    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
@@ -231,7 +231,7 @@ symmetry &symmetry::add(const symmetry &c)
 {
        // All children must have the same number of indices
        if (type != none && !children.empty()) {
-               GINAC_ASSERT(is_ex_exactly_of_type(children[0], symmetry));
+               GINAC_ASSERT(is_exactly_a<symmetry>(children[0]));
                if (ex_to<symmetry>(children[0]).indices.size() != c.indices.size())
                        throw (std::logic_error("symmetry:add(): children must have same number of indices"));
        }
@@ -272,8 +272,8 @@ public:
 
        bool operator() (const ex &lh, const ex &rh) const
        {
-               GINAC_ASSERT(is_ex_exactly_of_type(lh, symmetry));
-               GINAC_ASSERT(is_ex_exactly_of_type(rh, symmetry));
+               GINAC_ASSERT(is_exactly_a<symmetry>(lh));
+               GINAC_ASSERT(is_exactly_a<symmetry>(rh));
                GINAC_ASSERT(ex_to<symmetry>(lh).indices.size() == ex_to<symmetry>(rh).indices.size());
                std::set<unsigned>::const_iterator ait = ex_to<symmetry>(lh).indices.begin(), aitend = ex_to<symmetry>(lh).indices.end(), bit = ex_to<symmetry>(rh).indices.begin();
                while (ait != aitend) {
@@ -298,8 +298,8 @@ public:
 
        void operator() (const ex &lh, const ex &rh)
        {
-               GINAC_ASSERT(is_ex_exactly_of_type(lh, symmetry));
-               GINAC_ASSERT(is_ex_exactly_of_type(rh, symmetry));
+               GINAC_ASSERT(is_exactly_a<symmetry>(lh));
+               GINAC_ASSERT(is_exactly_a<symmetry>(rh));
                GINAC_ASSERT(ex_to<symmetry>(lh).indices.size() == ex_to<symmetry>(rh).indices.size());
                std::set<unsigned>::const_iterator ait = ex_to<symmetry>(lh).indices.begin(), aitend = ex_to<symmetry>(lh).indices.end(), bit = ex_to<symmetry>(rh).indices.begin();
                while (ait != aitend) {
@@ -321,7 +321,7 @@ int canonicalize(exvector::iterator v, const symmetry &symm)
        int sign = 1;
        exvector::const_iterator first = symm.children.begin(), last = symm.children.end();
        while (first != last) {
-               GINAC_ASSERT(is_ex_exactly_of_type(*first, symmetry));
+               GINAC_ASSERT(is_exactly_a<symmetry>(*first));
                int child_sign = canonicalize(v, ex_to<symmetry>(*first));
                if (child_sign == 0)
                        return 0;
index 21ab09f..bdcd261 100644 (file)
@@ -99,10 +99,6 @@ private:
 
 
 // global functions
-inline symmetry &ex_to_nonconst_symmetry(const ex &e)
-{
-       return static_cast<symmetry &>(*e.bp);
-}
 
 inline symmetry sy_none(void) { return symmetry(); }
 inline symmetry sy_none(const symmetry &c1, const symmetry &c2) { return symmetry(symmetry::none, c1, c2); }
index 7b3d141..8881425 100644 (file)
@@ -153,7 +153,7 @@ DEFAULT_COMPARE(spinmetric)
 
 int minkmetric::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, minkmetric));
+       GINAC_ASSERT(is_a<minkmetric>(other));
        const minkmetric &o = static_cast<const minkmetric &>(other);
 
        if (pos_sig != o.pos_sig)
@@ -164,7 +164,7 @@ int minkmetric::compare_same_type(const basic & other) const
 
 int tensepsilon::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, tensepsilon));
+       GINAC_ASSERT(is_a<tensepsilon>(other));
        const tensepsilon &o = static_cast<const tensepsilon &>(other);
 
        if (minkowski != o.minkowski)
@@ -184,9 +184,9 @@ DEFAULT_PRINT_LATEX(tensepsilon, "eps", "\\varepsilon")
 /** Automatic symbolic evaluation of an indexed delta tensor. */
 ex tensdelta::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() == 3);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), tensdelta));
+       GINAC_ASSERT(is_a<tensdelta>(i.op(0)));
 
        const idx & i1 = ex_to<idx>(i.op(1));
        const idx & i2 = ex_to<idx>(i.op(2));
@@ -211,11 +211,11 @@ ex tensdelta::eval_indexed(const basic & i) const
 /** Automatic symbolic evaluation of an indexed metric tensor. */
 ex tensmetric::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() == 3);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), tensmetric));
-       GINAC_ASSERT(is_ex_of_type(i.op(1), varidx));
-       GINAC_ASSERT(is_ex_of_type(i.op(2), varidx));
+       GINAC_ASSERT(is_a<tensmetric>(i.op(0)));
+       GINAC_ASSERT(is_a<varidx>(i.op(1)));
+       GINAC_ASSERT(is_a<varidx>(i.op(2)));
 
        const varidx & i1 = ex_to<varidx>(i.op(1));
        const varidx & i2 = ex_to<varidx>(i.op(2));
@@ -232,11 +232,11 @@ ex tensmetric::eval_indexed(const basic & i) const
 /** Automatic symbolic evaluation of an indexed Lorentz metric tensor. */
 ex minkmetric::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() == 3);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), minkmetric));
-       GINAC_ASSERT(is_ex_of_type(i.op(1), varidx));
-       GINAC_ASSERT(is_ex_of_type(i.op(2), varidx));
+       GINAC_ASSERT(is_a<minkmetric>(i.op(0)));
+       GINAC_ASSERT(is_a<varidx>(i.op(1)));
+       GINAC_ASSERT(is_a<varidx>(i.op(2)));
 
        const varidx & i1 = ex_to<varidx>(i.op(1));
        const varidx & i2 = ex_to<varidx>(i.op(2));
@@ -259,11 +259,11 @@ ex minkmetric::eval_indexed(const basic & i) const
 /** Automatic symbolic evaluation of an indexed metric tensor. */
 ex spinmetric::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() == 3);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), spinmetric));
-       GINAC_ASSERT(is_ex_of_type(i.op(1), spinidx));
-       GINAC_ASSERT(is_ex_of_type(i.op(2), spinidx));
+       GINAC_ASSERT(is_a<spinmetric>(i.op(0)));
+       GINAC_ASSERT(is_a<spinidx>(i.op(1)));
+       GINAC_ASSERT(is_a<spinidx>(i.op(2)));
 
        const spinidx & i1 = ex_to<spinidx>(i.op(1));
        const spinidx & i2 = ex_to<spinidx>(i.op(2));
@@ -290,9 +290,9 @@ ex spinmetric::eval_indexed(const basic & i) const
 /** Automatic symbolic evaluation of an indexed epsilon tensor. */
 ex tensepsilon::eval_indexed(const basic & i) const
 {
-       GINAC_ASSERT(is_of_type(i, indexed));
+       GINAC_ASSERT(is_a<indexed>(i));
        GINAC_ASSERT(i.nops() > 1);
-       GINAC_ASSERT(is_ex_of_type(i.op(0), tensepsilon));
+       GINAC_ASSERT(is_a<tensepsilon>(i.op(0)));
 
        // Convolutions are zero
        if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
@@ -333,10 +333,10 @@ ex tensepsilon::eval_indexed(const basic & i) const
 /** Contraction of an indexed delta tensor with something else. */
 bool tensdelta::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 3);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), tensdelta));
+       GINAC_ASSERT(is_a<tensdelta>(self->op(0)));
 
        // Try to contract first index
        const idx *self_idx = &ex_to<idx>(self->op(1));
@@ -373,10 +373,10 @@ again:
 /** Contraction of an indexed metric tensor with something else. */
 bool tensmetric::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 3);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), tensmetric));
+       GINAC_ASSERT(is_a<tensmetric>(self->op(0)));
 
        // If contracting with the delta tensor, let the delta do it
        // (don't raise/lower delta indices)
@@ -418,10 +418,10 @@ again:
 /** Contraction of an indexed spinor metric with something else. */
 bool spinmetric::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
        GINAC_ASSERT(self->nops() == 3);
-       GINAC_ASSERT(is_ex_of_type(self->op(0), spinmetric));
+       GINAC_ASSERT(is_a<spinmetric>(self->op(0)));
 
        // Contractions between spinor metrics
        if (is_ex_of_type(other->op(0), spinmetric)) {
@@ -497,9 +497,9 @@ again:
 /** Contraction of epsilon tensor with something else. */
 bool tensepsilon::contract_with(exvector::iterator self, exvector::iterator other, exvector & v) const
 {
-       GINAC_ASSERT(is_ex_of_type(*self, indexed));
-       GINAC_ASSERT(is_ex_of_type(*other, indexed));
-       GINAC_ASSERT(is_ex_of_type(self->op(0), tensepsilon));
+       GINAC_ASSERT(is_a<indexed>(*self));
+       GINAC_ASSERT(is_a<indexed>(*other));
+       GINAC_ASSERT(is_a<tensepsilon>(self->op(0)));
        unsigned num = self->nops() - 1;
 
        if (is_ex_exactly_of_type(other->op(0), tensepsilon) && num+1 == other->nops()) {
index e30a91a..d3b27b6 100644 (file)
@@ -139,13 +139,6 @@ private:
 
 // utility functions
 
-/** Return the tensor object handled by an ex.  Deprecated: use ex_to<tensor>().
- *  This is unsafe: you need to check the type first. */
-inline const tensor &ex_to_tensor(const ex &e)
-{
-       return static_cast<const tensor &>(*e.bp);
-}
-
 /** Create a delta tensor with specified indices. The indices must be of class
  *  idx or a subclass. The delta tensor is always symmetric and its trace is
  *  the dimension of the index space.
index c6dca58..f203c5f 100644 (file)
@@ -82,7 +82,7 @@ DEFAULT_UNARCHIVE(wildcard)
 
 int wildcard::compare_same_type(const basic & other) const
 {
-       GINAC_ASSERT(is_of_type(other, wildcard));
+       GINAC_ASSERT(is_a<wildcard>(other));
        const wildcard &o = static_cast<const wildcard &>(other);
 
        if (label == o.label)
@@ -95,7 +95,7 @@ void wildcard::print(const print_context & c, unsigned level) const
 {
        debugmsg("wildcard print", LOGLEVEL_PRINT);
 
-       if (is_of_type(c, print_tree)) {
+       if (is_a<print_tree>(c)) {
                c.s << std::string(level, ' ') << class_name() << " (" << label << ")"
                    << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
                    << std::endl;
index f787bcb..4b0e31f 100644 (file)
@@ -59,13 +59,6 @@ private:
 
 // utility functions
 
-/** Return the wildcard object handled by an ex.  Deprecated: use ex_to<wildcard>().
- *  This is unsafe: you need to check the type first. */
-inline const wildcard &ex_to_wildcard(const ex &e)
-{
-       return static_cast<const wildcard &>(*e.bp);
-}
-
 /** Specialization of is_exactly_a<wildcard>(obj) for wildcard objects. */
 template<> inline bool is_exactly_a<wildcard>(const basic & obj)
 {
index 50d2a23..bcd963b 100644 (file)
@@ -209,7 +209,7 @@ exp : T_NUMBER              {$$ = $1;}
                }
        }
        | T_DIGITS '=' T_NUMBER {$$ = $3; Digits = ex_to<numeric>($3).to_int();}
-       | T_SYMBOL '=' exp      {$$ = $3; ex_to_nonconst_symbol($1).assign($3);}
+       | T_SYMBOL '=' exp      {$$ = $3; const_cast<symbol&>(ex_to<symbol>($1)).assign($3);}
        | exp T_EQUAL exp       {$$ = $1 == $3;}
        | exp T_NOTEQ exp       {$$ = $1 != $3;}
        | exp '<' exp           {$$ = $1 < $3;}
@@ -490,7 +490,7 @@ static ex f_transpose(const exprseq &e)
 static ex f_unassign(const exprseq &e)
 {
        CHECK_ARG(0, symbol, unassign);
-       ex_to_nonconst_symbol(e[0]).unassign();
+       const_cast<symbol&>(ex_to<symbol>(e[0])).unassign();
        return e[0];
 }