From: Richard Kreckel Date: Fri, 8 Mar 2002 22:52:37 +0000 (+0000) Subject: * Removed deprecated macros is_ex_a, is_ex_exactly_a and friends. X-Git-Tag: release_1-1-0~120 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?a=commitdiff_plain;h=c954fb45427efc034382a2a3aa2a783fea2ab0d3;p=ginac.git * Removed deprecated macros is_ex_a, is_ex_exactly_a and friends. --- diff --git a/NEWS b/NEWS index 6536046b..407dea55 100644 --- a/NEWS +++ b/NEWS @@ -1,25 +1,22 @@ This file records noteworthy changes. 1.1.0 () -* "(x+1).subs(x==x-1)" now returns the correct result "x" instead of "x-1". -* Fixed LaTeX output of indexed objects. +* Removed deprecated macros is_ex_a, is_ex_exactly_a and friends. -1.0.5 () +Backlog from 1.0.n: +* Fixed LaTeX output of indexed and matrix objects. +* Fixed matrix::pow(n) for n==0. +* "(x+1).subs(x==x-1)" now returns the correct result "x" instead of "x-1". * (l)degree(s), coeff(s, n) and collect(s) were extended to accept expressions of any class (except add/mul/ncmul/numeric) for "s". They should even work if "s" is a "power" object, as long as the exponent is non-integer, but with some limitations. For example, you can "collect(a*2^x+b*2^x, 2^x)" to get "(a+b)*2^x", but "degree(2^(3*x), 2^x)" yields 0 instead of 3). - -1.0.4 (24 January 2001) * Speedup in expand(). * Faster Bernoulli numbers (Markus Nullmeier). -* Some minor bugfixes and documentation updates. - -1.0.3 (21 December 2001) * Fixed a bug where quo() would call vector::reserve() with a negative argument. -* Fix several bugs in code generation. +* Several small bugfices in code generation, output and documentation. 1.0.2 (19 December 2001) * Input parser recognizes "sqrt()", which is also used in the output. diff --git a/ginac/add.cpp b/ginac/add.cpp index 821649d2..e6fb727e 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -328,7 +328,7 @@ ex add::eval(int level) const epvector::const_iterator i = seq.begin(), end = seq.end(); while (i != end) { GINAC_ASSERT(!is_exactly_a(i->rest)); - if (is_ex_exactly_of_type(i->rest,numeric)) + if (is_exactly_a(i->rest)) dbgprint(); GINAC_ASSERT(!is_exactly_a(i->rest)); ++i; @@ -369,7 +369,7 @@ ex add::evalm(void) const while (it != itend) { const ex &m = recombine_pair_to_ex(*it).evalm(); s->push_back(split_ex_to_pair(m)); - if (is_ex_of_type(m, matrix)) { + if (is_a(m)) { if (first_term) { sum = ex_to(m); first_term = false; @@ -453,7 +453,7 @@ ex add::thisexpairseq(epvector * vp, const ex & oc) const expair add::split_ex_to_pair(const ex & e) const { - if (is_ex_exactly_of_type(e,mul)) { + if (is_exactly_a(e)) { const mul &mulref(ex_to(e)); const ex &numfactor = mulref.overall_coeff; mul *mulcopyp = new mul(mulref); @@ -470,7 +470,7 @@ expair add::combine_ex_with_coeff_to_pair(const ex & e, const ex & c) const { GINAC_ASSERT(is_exactly_a(c)); - if (is_ex_exactly_of_type(e, mul)) { + if (is_exactly_a(e)) { const mul &mulref(ex_to(e)); const ex &numfactor = mulref.overall_coeff; mul *mulcopyp = new mul(mulref); @@ -484,7 +484,7 @@ expair add::combine_ex_with_coeff_to_pair(const ex & e, return expair(*mulcopyp, c); else return expair(*mulcopyp, ex_to(numfactor).mul_dyn(ex_to(c))); - } else if (is_ex_exactly_of_type(e, numeric)) { + } else if (is_exactly_a(e)) { if (are_ex_trivially_equal(c, _ex1)) return expair(e, _ex1); return expair(ex_to(e).mul_dyn(ex_to(c)), _ex1); @@ -498,7 +498,7 @@ expair add::combine_pair_with_coeff_to_pair(const expair & p, GINAC_ASSERT(is_exactly_a(p.coeff)); GINAC_ASSERT(is_exactly_a(c)); - if (is_ex_exactly_of_type(p.rest,numeric)) { + if (is_exactly_a(p.rest)) { GINAC_ASSERT(ex_to(p.coeff).is_equal(_num1)); // should be normalized return expair(ex_to(p.rest).mul_dyn(ex_to(c)),_ex1); } diff --git a/ginac/basic.cpp b/ginac/basic.cpp index fb73096f..26ec8667 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -109,7 +109,7 @@ void basic::archive(archive_node &n) const * level for placing parentheses and formatting */ void basic::print(const print_context & c, unsigned level) const { - if (is_of_type(c, print_tree)) { + if (is_a(c)) { c.s << std::string(level, ' ') << class_name() << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec @@ -189,7 +189,7 @@ ex & basic::let_op(int i) ex basic::operator[](const ex & index) const { - if (is_ex_exactly_of_type(index,numeric)) + if (is_exactly_a(index)) return op(ex_to(index).to_int()); throw(std::invalid_argument("non-numeric indices not supported by this type")); @@ -260,7 +260,7 @@ ex basic::coeff(const ex & s, int n) const ex basic::collect(const ex & s, bool distributed) const { ex x; - if (is_ex_of_type(s, lst)) { + if (is_a(s)) { // List of objects specified if (s.nops() == 0) @@ -459,7 +459,7 @@ bool basic::match(const ex & pattern, lst & repl_lst) const Bog is the king of Pattern. */ - if (is_ex_exactly_of_type(pattern, wildcard)) { + if (is_exactly_a(pattern)) { // Wildcard matches anything, but check whether we already have found // a match for that wildcard first (if so, it the earlier match must diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index e3c0ffd4..ecbfe9ea 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -458,7 +458,7 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE) else return _ex0; - } else if (is_ex_exactly_of_type(e, mul)) { + } else if (is_exactly_a(e)) { // Trace of product: pull out non-clifford factors ex prod = _ex1; @@ -471,7 +471,7 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE) } return prod; - } else if (is_ex_exactly_of_type(e, ncmul)) { + } else if (is_exactly_a(e)) { if (!is_clifford_tinfo(e.return_type_tinfo(), rl)) return _ex0; @@ -578,7 +578,7 @@ ex canonicalize_clifford(const ex & e) ex lhs = srl.op(i).lhs(); ex rhs = srl.op(i).rhs(); - if (is_ex_exactly_of_type(rhs, ncmul) + if (is_exactly_a(rhs) && rhs.return_type() == return_types::noncommutative && is_clifford_tinfo(rhs.return_type_tinfo())) { diff --git a/ginac/color.cpp b/ginac/color.cpp index aeaf112c..0327b908 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -162,7 +162,7 @@ ex color::simplify_ncmul(const exvector & v) const // Remove superfluous ONEs exvector::const_iterator it = v.begin(), itend = v.end(); while (it != itend) { - if (!is_ex_of_type(it->op(0), su3one)) + if (!is_a(it->op(0))) s.push_back(*it); it++; } @@ -306,7 +306,7 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve GINAC_ASSERT(is_a(self->op(0))); unsigned char rl = ex_to(*self).get_representation_label(); - if (is_ex_exactly_of_type(other->op(0), su3t)) { + if (is_exactly_a(other->op(0))) { // T.a T.a = 4/3 ONE if (other - self == 1) { @@ -316,7 +316,7 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve // T.a T.b T.a = -1/6 T.b } else if (other - self == 2 - && is_ex_of_type(self[1], color)) { + && is_a(self[1])) { *self = numeric(-1, 6); *other = _ex1; return true; @@ -325,7 +325,7 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve } else { exvector::iterator it = self + 1; while (it != other) { - if (!is_ex_of_type(*it, color)) { + if (!is_a(*it)) { return false; } it++; @@ -355,7 +355,7 @@ bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exve GINAC_ASSERT(self->nops() == 4); GINAC_ASSERT(is_a(self->op(0))); - if (is_ex_exactly_of_type(other->op(0), su3d)) { + if (is_exactly_a(other->op(0))) { // Find the dummy indices of the contraction exvector self_indices = ex_to(*self).get_indices(); @@ -383,11 +383,11 @@ bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exve return true; } - } else if (is_ex_exactly_of_type(other->op(0), su3t)) { + } else if (is_exactly_a(other->op(0))) { // d.abc T.b T.c = 5/6 T.a if (other+1 != v.end() - && is_ex_exactly_of_type(other[1].op(0), su3t) + && is_exactly_a(other[1].op(0)) && ex_to(*self).has_dummy_index_for(other[1].op(1))) { exvector self_indices = ex_to(*self).get_indices(); @@ -414,7 +414,7 @@ bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exve GINAC_ASSERT(self->nops() == 4); GINAC_ASSERT(is_a(self->op(0))); - if (is_ex_exactly_of_type(other->op(0), su3f)) { // f*d is handled by su3d class + if (is_exactly_a(other->op(0))) { // f*d is handled by su3d class // Find the dummy indices of the contraction exvector dummy_indices; @@ -436,11 +436,11 @@ bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exve return true; } - } else if (is_ex_exactly_of_type(other->op(0), su3t)) { + } else if (is_exactly_a(other->op(0))) { // f.abc T.b T.c = 3/2 I T.a if (other+1 != v.end() - && is_ex_exactly_of_type(other[1].op(0), su3t) + && is_exactly_a(other[1].op(0)) && ex_to(*self).has_dummy_index_for(other[1].op(1))) { exvector self_indices = ex_to(*self).get_indices(); @@ -470,7 +470,7 @@ ex color_ONE(unsigned char rl) ex color_T(const ex & a, unsigned char rl) { - if (!is_ex_of_type(a, idx)) + if (!is_a(a)) throw(std::invalid_argument("indices of color_T must be of type idx")); if (!ex_to(a).get_dim().is_equal(8)) throw(std::invalid_argument("index dimension for color_T must be 8")); @@ -480,7 +480,7 @@ ex color_T(const ex & a, unsigned char rl) ex color_f(const ex & a, const ex & b, const ex & c) { - if (!is_ex_of_type(a, idx) || !is_ex_of_type(b, idx) || !is_ex_of_type(c, idx)) + if (!is_a(a) || !is_a(b) || !is_a(c)) throw(std::invalid_argument("indices of color_f must be of type idx")); if (!ex_to(a).get_dim().is_equal(8) || !ex_to(b).get_dim().is_equal(8) || !ex_to(c).get_dim().is_equal(8)) throw(std::invalid_argument("index dimension for color_f must be 8")); @@ -490,7 +490,7 @@ ex color_f(const ex & a, const ex & b, const ex & c) ex color_d(const ex & a, const ex & b, const ex & c) { - if (!is_ex_of_type(a, idx) || !is_ex_of_type(b, idx) || !is_ex_of_type(c, idx)) + if (!is_a(a) || !is_a(b) || !is_a(c)) throw(std::invalid_argument("indices of color_d must be of type idx")); if (!ex_to(a).get_dim().is_equal(8) || !ex_to(b).get_dim().is_equal(8) || !ex_to(c).get_dim().is_equal(8)) throw(std::invalid_argument("index dimension for color_d must be 8")); @@ -512,15 +512,15 @@ static bool is_color_tinfo(unsigned ti, unsigned char rl) ex color_trace(const ex & e, unsigned char rl) { - if (is_ex_of_type(e, color)) { + if (is_a(e)) { if (ex_to(e).get_representation_label() == rl - && is_ex_of_type(e.op(0), su3one)) + && is_a(e.op(0))) return _ex3; else return _ex0; - } else if (is_ex_exactly_of_type(e, mul)) { + } else if (is_exactly_a(e)) { // Trace of product: pull out non-color factors ex prod = _ex1; @@ -533,14 +533,14 @@ ex color_trace(const ex & e, unsigned char rl) } return prod; - } else if (is_ex_exactly_of_type(e, ncmul)) { + } else if (is_exactly_a(e)) { if (!is_color_tinfo(e.return_type_tinfo(), rl)) return _ex0; // Expand product, if necessary ex e_expanded = e.expand(); - if (!is_ex_of_type(e_expanded, ncmul)) + if (!is_a(e_expanded)) return color_trace(e_expanded, rl); unsigned num = e.nops(); diff --git a/ginac/ex.cpp b/ginac/ex.cpp index b22ceef8..8b6a88ea 100644 --- a/ginac/ex.cpp +++ b/ginac/ex.cpp @@ -166,7 +166,7 @@ ex & ex::let_op(int i) /** Left hand side of relational expression. */ ex ex::lhs(void) const { - if (!is_ex_of_type(*this,relational)) + if (!is_a(*this)) throw std::runtime_error("ex::lhs(): not a relation"); return (*static_cast(bp)).lhs(); } @@ -174,7 +174,7 @@ ex ex::lhs(void) const /** Right hand side of relational expression. */ ex ex::rhs(void) const { - if (!is_ex_of_type(*this,relational)) + if (!is_a(*this)) throw std::runtime_error("ex::rhs(): not a relation"); return (*static_cast(bp)).rhs(); } diff --git a/ginac/ex.h b/ginac/ex.h index 0aa96ebc..ad598007 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -196,9 +196,10 @@ protected: // member variables -public: - basic *bp; ///< pointer to basic object managed by this, direct manipulation deprecated +private: + basic *bp; ///< pointer to basic object managed by this #ifdef OBSCURE_CINT_HACK +public: static basic * last_created_or_assigned_bp; static basic * dummy_bp; static long last_created_or_assigned_exp; diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index 36261a98..9736b834 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -186,7 +186,7 @@ basic *expairseq::duplicate() const void expairseq::print(const print_context &c, unsigned level) const { - if (is_of_type(c, print_tree)) { + if (is_a(c)) { unsigned delta_indent = static_cast(c).delta_indent; @@ -336,7 +336,7 @@ bool expairseq::match(const ex & pattern, lst & repl_lst) const bool has_global_wildcard = false; ex global_wildcard; for (unsigned int i=0; i(pattern.op(i))) { has_global_wildcard = true; global_wildcard = pattern.op(i); break; @@ -775,8 +775,8 @@ void expairseq::construct_from_2_ex(const ex &lh, const ex &rh) hashtabsize = 0; #endif // EXPAIRSEQ_USE_HASHTAB - if (is_ex_exactly_of_type(lh,numeric)) { - if (is_ex_exactly_of_type(rh,numeric)) { + if (is_exactly_a(lh)) { + if (is_exactly_a(rh)) { combine_overall_coeff(lh); combine_overall_coeff(rh); } else { @@ -784,7 +784,7 @@ void expairseq::construct_from_2_ex(const ex &lh, const ex &rh) seq.push_back(split_ex_to_pair(rh)); } } else { - if (is_ex_exactly_of_type(rh,numeric)) { + if (is_exactly_a(rh)) { combine_overall_coeff(rh); seq.push_back(split_ex_to_pair(lh)); } else { @@ -871,7 +871,7 @@ void expairseq::construct_from_expairseq_ex(const expairseq &s, const ex &e) { combine_overall_coeff(s.overall_coeff); - if (is_ex_exactly_of_type(e,numeric)) { + if (is_exactly_a(e)) { combine_overall_coeff(e); seq = s.seq; return; @@ -996,7 +996,7 @@ void expairseq::make_flat(const exvector &v) ++cit_s; } } else { - if (is_ex_exactly_of_type(*cit,numeric)) + if (is_exactly_a(*cit)) combine_overall_coeff(*cit); else seq.push_back(split_ex_to_pair(*cit)); @@ -1247,7 +1247,7 @@ void expairseq::build_hashtab_and_combine(epvector::iterator &first_numeric, epp current = seq.begin(); while (current!=first_numeric) { - if (is_ex_exactly_of_type(current->rest,numeric)) { + if (is_exactly_a(current->rest)) { --first_numeric; iter_swap(current,first_numeric); } else { @@ -1435,11 +1435,11 @@ bool expairseq::is_canonical() const epvector::const_iterator it_last = it; for (++it; it!=itend; it_last=it, ++it) { if (!(it_last->is_less(*it) || it_last->is_equal(*it))) { - if (!is_ex_exactly_of_type(it_last->rest,numeric) || - !is_ex_exactly_of_type(it->rest,numeric)) { + if (!is_exactly_a(it_last->rest) || + !is_exactly_a(it->rest)) { // double test makes it easier to set a breakpoint... - if (!is_ex_exactly_of_type(it_last->rest,numeric) || - !is_ex_exactly_of_type(it->rest,numeric)) { + if (!is_exactly_a(it_last->rest) || + !is_exactly_a(it->rest)) { printpair(std::clog, *it_last, 0); std::clog << ">"; printpair(std::clog, *it, 0); @@ -1568,7 +1568,7 @@ epvector * expairseq::subschildren(const lst &ls, const lst &lr, bool no_pattern // because the numeric coefficients may be part of the search pattern. bool complex_subs = false; for (unsigned i=0; i(ls.op(i)) || is_exactly_a(ls.op(i))) { complex_subs = true; break; } diff --git a/ginac/function.pl b/ginac/function.pl index ba1b02ae..0f8c74c1 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -667,7 +667,7 @@ void function::print(const print_context & c, unsigned level) const { GINAC_ASSERT(serial(c)) { c.s << std::string(level, ' ') << class_name() << " " << registered_functions()[serial].name @@ -679,7 +679,7 @@ void function::print(const print_context & c, unsigned level) const seq[i].print(c, level + delta_indent); c.s << std::string(level + delta_indent, ' ') << "=====" << std::endl; - } else if (is_of_type(c, print_csrc)) { + } else if (is_a(c)) { // Print function name in lowercase std::string lname = registered_functions()[serial].name; @@ -698,7 +698,7 @@ void function::print(const print_context & c, unsigned level) const } c.s << ")"; - } else if (is_of_type(c, print_latex)) { + } else if (is_a(c)) { c.s << registered_functions()[serial].TeX_name; printseq(c, '(', ',', ')', exprseq::precedence(), function::precedence()); } else { @@ -883,7 +883,7 @@ ex function::derivative(const symbol & s) const int function::compare_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other, function)); + GINAC_ASSERT(is_a(other)); const function & o = static_cast(other); if (serial != o.serial) @@ -894,7 +894,7 @@ int function::compare_same_type(const basic & other) const bool function::is_equal_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other, function)); + GINAC_ASSERT(is_a(other)); const function & o = static_cast(other); if (serial != o.serial) @@ -905,7 +905,7 @@ bool function::is_equal_same_type(const basic & other) const bool function::match_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other, function)); + GINAC_ASSERT(is_a(other)); const function & o = static_cast(other); return serial == o.serial; diff --git a/ginac/idx.cpp b/ginac/idx.cpp index a3767fe8..bf103f0f 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -145,7 +145,7 @@ DEFAULT_UNARCHIVE(spinidx) void idx::print(const print_context & c, unsigned level) const { - if (is_of_type(c, print_tree)) { + if (is_a(c)) { c.s << std::string(level, ' ') << class_name() << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec @@ -160,7 +160,7 @@ void idx::print(const print_context & c, unsigned level) const c.s << "{"; else c.s << "."; - bool need_parens = !(is_ex_exactly_of_type(value, numeric) || is_ex_of_type(value, symbol)); + bool need_parens = !(is_exactly_a(value) || is_a(value)); if (need_parens) c.s << "("; value.print(c); @@ -173,7 +173,7 @@ void idx::print(const print_context & c, unsigned level) const void varidx::print(const print_context & c, unsigned level) const { - if (is_of_type(c, print_tree)) { + if (is_a(c)) { c.s << std::string(level, ' ') << class_name() << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec @@ -192,7 +192,7 @@ void varidx::print(const print_context & c, unsigned level) const else c.s << "~"; } - bool need_parens = !(is_ex_exactly_of_type(value, numeric) || is_ex_of_type(value, symbol)); + bool need_parens = !(is_exactly_a(value) || is_a(value)); if (need_parens) c.s << "("; value.print(c); @@ -205,7 +205,7 @@ void varidx::print(const print_context & c, unsigned level) const void spinidx::print(const print_context & c, unsigned level) const { - if (is_of_type(c, print_tree)) { + if (is_a(c)) { c.s << std::string(level, ' ') << class_name() << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec @@ -218,7 +218,7 @@ void spinidx::print(const print_context & c, unsigned level) const } else { - bool is_tex = is_of_type(c, print_latex); + bool is_tex = is_a(c); if (is_tex) { if (covariant) c.s << "_{"; @@ -236,7 +236,7 @@ void spinidx::print(const print_context & c, unsigned level) const else c.s << "*"; } - bool need_parens = !(is_ex_exactly_of_type(value, numeric) || is_ex_of_type(value, symbol)); + bool need_parens = !(is_exactly_a(value) || is_a(value)); if (need_parens) c.s << "("; value.print(c); @@ -356,7 +356,7 @@ ex idx::subs(const lst & ls, const lst & lr, bool no_pattern) const if (is_equal(ex_to(ls.op(i)))) { // Substitution index->index - if (is_ex_of_type(lr.op(i), idx)) + if (is_a(lr.op(i))) return lr.op(i); // Otherwise substitute value @@ -395,7 +395,7 @@ bool idx::is_dummy_pair_same_type(const basic & other) const const idx &o = static_cast(other); // Only pure symbols form dummy pairs, "2n+1" doesn't - if (!is_ex_of_type(value, symbol)) + if (!is_a(value)) return false; // Value must be equal, of course @@ -475,7 +475,7 @@ bool is_dummy_pair(const idx & i1, const idx & i2) bool is_dummy_pair(const ex & e1, const ex & e2) { // The expressions must be indices - if (!is_ex_of_type(e1, idx) || !is_ex_of_type(e2, idx)) + if (!is_a(e1) || !is_a(e2)) return false; return is_dummy_pair(ex_to(e1), ex_to(e2)); diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index 765a07c8..ce284170 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -178,7 +178,7 @@ void indexed::print(const print_context & c, unsigned level) const { GINAC_ASSERT(seq.size() > 0); - if (is_of_type(c, print_tree)) { + if (is_a(c)) { c.s << std::string(level, ' ') << class_name() << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec @@ -190,11 +190,11 @@ void indexed::print(const print_context & c, unsigned level) const } else { - bool is_tex = is_of_type(c, print_latex); + bool is_tex = is_a(c); const ex & base = seq[0]; - bool need_parens = is_ex_exactly_of_type(base, add) || is_ex_exactly_of_type(base, mul) - || is_ex_exactly_of_type(base, ncmul) || is_ex_exactly_of_type(base, power) - || is_ex_of_type(base, indexed); + bool need_parens = is_exactly_a(base) || is_exactly_a(base) + || is_exactly_a(base) || is_exactly_a(base) + || is_a(base); if (is_tex) c.s << "{"; if (need_parens) @@ -250,7 +250,7 @@ ex indexed::eval(int level) const return _ex0; // If the base object is a product, pull out the numeric factor - if (is_ex_exactly_of_type(base, mul) && is_ex_exactly_of_type(base.op(base.nops() - 1), numeric)) { + if (is_exactly_a(base) && is_exactly_a(base.op(base.nops() - 1))) { exvector v(seq); ex f = ex_to(base.op(base.nops() - 1)); v[0] = seq[0] / f; @@ -288,7 +288,7 @@ ex indexed::expand(unsigned options) const { GINAC_ASSERT(seq.size() > 0); - if ((options & expand_options::expand_indexed) && is_ex_exactly_of_type(seq[0], add)) { + if ((options & expand_options::expand_indexed) && is_exactly_a(seq[0])) { // expand_indexed expands (a+b).i -> a.i + b.i const ex & base = seq[0]; @@ -320,14 +320,14 @@ void indexed::printindices(const print_context & c, unsigned level) const exvector::const_iterator it=seq.begin() + 1, itend = seq.end(); - if (is_of_type(c, print_latex)) { + if (is_a(c)) { // TeX output: group by variance bool first = true; bool covariant = true; while (it != itend) { - bool cur_covariant = (is_ex_of_type(*it, varidx) ? ex_to(*it).is_covariant() : true); + bool cur_covariant = (is_a(*it) ? ex_to(*it).is_covariant() : true); if (first || cur_covariant != covariant) { // Variance changed // The empty {} prevents indices from ending up on top of each other if (!first) @@ -364,13 +364,13 @@ void indexed::validate(void) const GINAC_ASSERT(seq.size() > 0); exvector::const_iterator it = seq.begin() + 1, itend = seq.end(); while (it != itend) { - if (!is_ex_of_type(*it, idx)) + if (!is_a(*it)) throw(std::invalid_argument("indices of indexed object must be of type idx")); it++; } if (!symtree.is_zero()) { - if (!is_ex_exactly_of_type(symtree, symmetry)) + if (!is_exactly_a(symtree)) throw(std::invalid_argument("symmetry of indexed object must be of type symmetry")); const_cast(ex_to(symtree)).validate(seq.size() - 1); } @@ -559,13 +559,13 @@ ex simplify_indexed_product(const ex & e, exvector & free_indices, exvector & du { // Remember whether the product was commutative or noncommutative // (because we chop it into factors and need to reassemble later) - bool non_commutative = is_ex_exactly_of_type(e, ncmul); + bool non_commutative = is_exactly_a(e); // Collect factors in an exvector, store squares twice exvector v; v.reserve(e.nops() * 2); - if (is_ex_exactly_of_type(e, power)) { + if (is_exactly_a(e)) { // We only get called for simple squares, split a^2 -> a*a GINAC_ASSERT(e.op(1).is_equal(_ex2)); v.push_back(e.op(0)); @@ -573,10 +573,10 @@ ex simplify_indexed_product(const ex & e, exvector & free_indices, exvector & du } else { for (unsigned i=0; i(f) && f.op(1).is_equal(_ex2)) { v.push_back(f.op(0)); v.push_back(f.op(0)); - } else if (is_ex_exactly_of_type(f, ncmul)) { + } else if (is_exactly_a(f)) { // Noncommutative factor found, split it as well non_commutative = true; // everything becomes noncommutative, ncmul will sort out the commutative factors later for (unsigned j=0; j(*it1)) continue; bool first_noncommutative = (it1->return_type() != return_types::commutative); @@ -606,7 +606,7 @@ try_again: exvector::iterator it2; for (it2 = it1 + 1; it2 != itend; it2++) { - if (!is_ex_of_type(*it2, indexed)) + if (!is_a(*it2)) continue; bool second_noncommutative = (it2->return_type() != return_types::commutative); @@ -645,9 +645,9 @@ try_again: if (contracted) { contraction_done: if (first_noncommutative || second_noncommutative - || is_ex_exactly_of_type(*it1, add) || is_ex_exactly_of_type(*it2, add) - || is_ex_exactly_of_type(*it1, mul) || is_ex_exactly_of_type(*it2, mul) - || is_ex_exactly_of_type(*it1, ncmul) || is_ex_exactly_of_type(*it2, ncmul)) { + || is_exactly_a(*it1) || is_exactly_a(*it2) + || is_exactly_a(*it1) || is_exactly_a(*it2) + || is_exactly_a(*it1) || is_exactly_a(*it2)) { // One of the factors became a sum or product: // re-expand expression and run again @@ -673,7 +673,7 @@ contraction_done: it1 = v.begin(); itend = v.end(); while (it1 != itend) { exvector free_indices_of_factor; - if (is_ex_of_type(*it1, indexed)) { + if (is_a(*it1)) { exvector dummy_indices_of_factor; find_free_and_dummy(ex_to(*it1).seq.begin() + 1, ex_to(*it1).seq.end(), free_indices_of_factor, dummy_indices_of_factor); individual_dummy_indices.insert(individual_dummy_indices.end(), dummy_indices_of_factor.begin(), dummy_indices_of_factor.end()); @@ -709,8 +709,8 @@ contraction_done: r = rename_dummy_indices(r, dummy_indices, local_dummy_indices); // 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)) + if (is_exactly_a(r) && r.nops() == 2 + && is_exactly_a(r.op(1)) && is_a(r.op(0))) return ex_to(r.op(0).op(0)).scalar_mul_indexed(r.op(0), ex_to(r.op(1))); else return r; @@ -724,7 +724,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi // Simplification of single indexed object: just find the free indices // and perform dummy index renaming - if (is_ex_of_type(e_expanded, indexed)) { + if (is_a(e_expanded)) { const indexed &i = ex_to(e_expanded); exvector local_dummy_indices; find_free_and_dummy(i.seq.begin() + 1, i.seq.end(), free_indices, local_dummy_indices); @@ -733,7 +733,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi // Simplification of sum = sum of simplifications, check consistency of // free indices in each term - if (is_ex_exactly_of_type(e_expanded, add)) { + if (is_exactly_a(e_expanded)) { bool first = true; ex sum = _ex0; free_indices.clear(); @@ -749,7 +749,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi } else { 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)) + if (is_a(sum) && is_a(term)) sum = ex_to(sum.op(0)).add_indexed(sum, term); else sum += term; @@ -761,9 +761,9 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi } // Simplification of products - if (is_ex_exactly_of_type(e_expanded, mul) - || is_ex_exactly_of_type(e_expanded, ncmul) - || (is_ex_exactly_of_type(e_expanded, power) && is_ex_of_type(e_expanded.op(0), indexed) && e_expanded.op(1).is_equal(_ex2))) + if (is_exactly_a(e_expanded) + || is_exactly_a(e_expanded) + || (is_exactly_a(e_expanded) && is_a(e_expanded.op(0)) && e_expanded.op(1).is_equal(_ex2))) return simplify_indexed_product(e_expanded, free_indices, dummy_indices, sp); // Cannot do anything @@ -869,8 +869,8 @@ void scalar_products::debugprint(void) const spmapkey scalar_products::make_key(const ex & v1, const ex & v2) { // If indexed, extract base objects - ex s1 = is_ex_of_type(v1, indexed) ? v1.op(0) : v1; - ex s2 = is_ex_of_type(v2, indexed) ? v2.op(0) : v2; + ex s1 = is_a(v1) ? v1.op(0) : v1; + ex s2 = is_a(v2) ? v2.op(0) : v2; // Enforce canonical order in pair if (s1.compare(s2) > 0) diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index c6b14c6b..52220b5b 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -52,7 +52,7 @@ static ex abs_evalf(const ex & arg) static ex abs_eval(const ex & arg) { - if (is_ex_exactly_of_type(arg, numeric)) + if (is_exactly_a(arg)) return abs(ex_to(arg)); else return abs(arg).hold(); @@ -76,11 +76,11 @@ static ex csgn_evalf(const ex & arg) static ex csgn_eval(const ex & arg) { - if (is_ex_exactly_of_type(arg, numeric)) + if (is_exactly_a(arg)) return csgn(ex_to(arg)); - else if (is_ex_of_type(arg, mul) && - is_ex_of_type(arg.op(arg.nops()-1),numeric)) { + else if (is_a(arg) && + is_a(arg.op(arg.nops()-1))) { numeric oc = ex_to(arg.op(arg.nops()-1)); if (oc.is_real()) { if (oc > 0) @@ -365,7 +365,7 @@ static ex factorial_evalf(const ex & x) static ex factorial_eval(const ex & x) { - if (is_ex_exactly_of_type(x, numeric)) + if (is_exactly_a(x)) return factorial(ex_to(x)); else return factorial(x).hold(); @@ -385,7 +385,7 @@ static ex binomial_evalf(const ex & x, const ex & y) static ex binomial_eval(const ex & x, const ex &y) { - if (is_ex_exactly_of_type(x, numeric) && is_ex_exactly_of_type(y, numeric)) + if (is_exactly_a(x) && is_exactly_a(y)) return binomial(ex_to(x), ex_to(y)); else return binomial(x, y).hold(); @@ -400,16 +400,16 @@ REGISTER_FUNCTION(binomial, eval_func(binomial_eval). static ex Order_eval(const ex & x) { - if (is_ex_exactly_of_type(x, numeric)) { + if (is_exactly_a(x)) { // O(c) -> O(1) or 0 if (!x.is_zero()) return Order(_ex1).hold(); else return _ex0; - } else if (is_ex_exactly_of_type(x, mul)) { + } else if (is_exactly_a(x)) { const mul &m = ex_to(x); // O(c*expr) -> O(expr) - if (is_ex_exactly_of_type(m.op(m.nops() - 1), numeric)) + if (is_exactly_a(m.op(m.nops() - 1))) return Order(x / m.op(m.nops() - 1)).hold(); } return Order(x).hold(); diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index 8daa11db..5a68f132 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -365,7 +365,7 @@ ex matrix::add_indexed(const ex & self, const ex & other) const GINAC_ASSERT(self.nops() == 2 || self.nops() == 3); // Only add two matrices - if (is_ex_of_type(other.op(0), matrix)) { + if (is_a(other.op(0))) { GINAC_ASSERT(other.nops() == 2 || other.nops() == 3); const matrix &self_matrix = ex_to(self.op(0)); @@ -416,7 +416,7 @@ bool matrix::contract_with(exvector::iterator self, exvector::iterator other, ex GINAC_ASSERT(is_a(self->op(0))); // Only contract with other matrices - if (!is_ex_of_type(other->op(0), matrix)) + if (!is_a(other->op(0))) return false; GINAC_ASSERT(other->nops() == 2 || other->nops() == 3); @@ -605,7 +605,7 @@ matrix matrix::pow(const ex & expn) const if (col!=row) throw (std::logic_error("matrix::pow(): matrix not square")); - if (is_ex_exactly_of_type(expn, numeric)) { + if (is_exactly_a(expn)) { // Integer cases are computed by successive multiplication, using the // obvious shortcut of storing temporaries, like A^4 == (A*A)*(A*A). if (expn.info(info_flags::integer)) { diff --git a/ginac/mul.cpp b/ginac/mul.cpp index 80f48571..6d2e0212 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -353,7 +353,7 @@ ex mul::eval(int level) const GINAC_ASSERT((!is_exactly_a(i->rest)) || (!(ex_to(i->coeff).is_integer()))); GINAC_ASSERT(!(i->is_canonical_numeric())); - if (is_ex_exactly_of_type(recombine_pair_to_ex(*i), numeric)) + if (is_exactly_a(recombine_pair_to_ex(*i))) print(print_tree(std::cerr)); GINAC_ASSERT(!is_exactly_a(recombine_pair_to_ex(*i))); /* for paranoia */ @@ -382,7 +382,7 @@ ex mul::eval(int level) const // *(x;1) -> x return recombine_pair_to_ex(*(seq.begin())); } else if ((seq_size==1) && - is_ex_exactly_of_type((*seq.begin()).rest,add) && + is_exactly_a((*seq.begin()).rest) && ex_to((*seq.begin()).coeff).is_equal(_num1)) { // *(+(x,y,...);c) -> +(*(x,c),*(y,c),...) (c numeric(), no powers of +()) const add & addref = ex_to((*seq.begin()).rest); @@ -426,7 +426,7 @@ ex mul::evalm(void) const { // numeric*matrix if (seq.size() == 1 && seq[0].coeff.is_equal(_ex1) - && is_ex_of_type(seq[0].rest, matrix)) + && is_a(seq[0].rest)) return ex_to(seq[0].rest).mul(ex_to(overall_coeff)); // Evaluate children first, look whether there are any matrices at all @@ -442,7 +442,7 @@ ex mul::evalm(void) const while (i != end) { const ex &m = recombine_pair_to_ex(*i).evalm(); s->push_back(split_ex_to_pair(m)); - if (is_ex_of_type(m, matrix)) { + if (is_a(m)) { have_matrix = true; the_matrix = s->end() - 1; } @@ -573,9 +573,9 @@ ex mul::thisexpairseq(epvector * vp, const ex & oc) const expair mul::split_ex_to_pair(const ex & e) const { - if (is_ex_exactly_of_type(e,power)) { + if (is_exactly_a(e)) { const power & powerref = ex_to(e); - if (is_ex_exactly_of_type(powerref.exponent,numeric)) + if (is_exactly_a(powerref.exponent)) return expair(powerref.basis,powerref.exponent); } return expair(e,_ex1); @@ -617,13 +617,13 @@ ex mul::recombine_pair_to_ex(const expair & p) const bool mul::expair_needs_further_processing(epp it) { - if (is_ex_exactly_of_type((*it).rest,mul) && + if (is_exactly_a((*it).rest) && ex_to((*it).coeff).is_integer()) { // combined pair is product with integer power -> expand it *it = split_ex_to_pair(recombine_pair_to_ex(*it)); return true; } - if (is_ex_exactly_of_type((*it).rest,numeric)) { + if (is_exactly_a((*it).rest)) { expair ep=split_ex_to_pair(recombine_pair_to_ex(*it)); if (!ep.is_equal(*it)) { // combined pair is a numeric power which can be simplified @@ -682,10 +682,10 @@ ex mul::expand(unsigned options) const non_adds.reserve(expanded_seq.size()); epvector::const_iterator cit = expanded_seq.begin(), last = expanded_seq.end(); while (cit != last) { - if (is_ex_exactly_of_type(cit->rest, add) && + if (is_exactly_a(cit->rest) && (cit->coeff.is_equal(_ex1))) { ++number_of_adds; - if (is_ex_exactly_of_type(last_expanded, add)) { + if (is_exactly_a(last_expanded)) { const add & add1 = ex_to(last_expanded); const add & add2 = ex_to(cit->rest); int n1 = add1.nops(); @@ -714,7 +714,7 @@ ex mul::expand(unsigned options) const // Now the only remaining thing to do is to multiply the factors which // were not sums into the "last_expanded" sum - if (is_ex_exactly_of_type(last_expanded, add)) { + if (is_exactly_a(last_expanded)) { const add & finaladd = ex_to(last_expanded); exvector distrseq; int n = finaladd.nops(); diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index 6931279d..d6e14d75 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -253,8 +253,8 @@ ex ncmul::coeff(const ex & s, int n) const unsigned ncmul::count_factors(const ex & e) const { - if ((is_ex_exactly_of_type(e,mul)&&(e.return_type()!=return_types::commutative))|| - (is_ex_exactly_of_type(e,ncmul))) { + if ((is_exactly_a(e)&&(e.return_type()!=return_types::commutative))|| + (is_exactly_a(e))) { unsigned factors=0; for (unsigned i=0; i(e)&&(e.return_type()!=return_types::commutative))|| + (is_exactly_a(e))) { for (unsigned i=0; ibegin(); itend = s->end(); - if (is_ex_of_type(*it, matrix)) { + if (is_a(*it)) { matrix prod(ex_to(*it)); it++; while (it != itend) { - if (!is_ex_of_type(*it, matrix)) + if (!is_a(*it)) goto no_matrix; prod = prod.mul(ex_to(*it)); it++; diff --git a/ginac/normal.cpp b/ginac/normal.cpp index 610c48d6..956b646e 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -92,14 +92,14 @@ static struct _stat_print { * @return "false" if no symbol was found, "true" otherwise */ static bool get_first_symbol(const ex &e, const symbol *&x) { - if (is_ex_exactly_of_type(e, symbol)) { + if (is_exactly_a(e)) { x = &ex_to(e); return true; - } else if (is_ex_exactly_of_type(e, add) || is_ex_exactly_of_type(e, mul)) { + } else if (is_exactly_a(e) || is_exactly_a(e)) { for (unsigned i=0; i(e)) { if (get_first_symbol(e.op(0), x)) return true; } @@ -169,12 +169,12 @@ static void add_symbol(const symbol *s, sym_desc_vec &v) // Collect all symbols of an expression (used internally by get_symbol_stats()) static void collect_symbols(const ex &e, sym_desc_vec &v) { - if (is_ex_exactly_of_type(e, symbol)) { + if (is_exactly_a(e)) { add_symbol(&ex_to(e), v); - } else if (is_ex_exactly_of_type(e, add) || is_ex_exactly_of_type(e, mul)) { + } else if (is_exactly_a(e) || is_exactly_a(e)) { for (unsigned i=0; i(e)) { collect_symbols(e.op(0), v); } } @@ -230,18 +230,18 @@ static numeric lcmcoeff(const ex &e, const numeric &l) { if (e.info(info_flags::rational)) return lcm(ex_to(e).denom(), l); - else if (is_ex_exactly_of_type(e, add)) { + else if (is_exactly_a(e)) { numeric c = _num1; for (unsigned i=0; i(e)) { numeric c = _num1; for (unsigned i=0; i(e)) { + if (is_exactly_a(e.op(0))) return l; else return pow(lcmcoeff(e.op(0), l), ex_to(e.op(1))); @@ -268,7 +268,7 @@ static numeric lcm_of_coefficients_denominators(const ex &e) * @param lcm LCM to multiply in */ static ex multiply_lcm(const ex &e, const numeric &lcm) { - if (is_ex_exactly_of_type(e, mul)) { + if (is_exactly_a(e)) { unsigned num = e.nops(); exvector v; v.reserve(num + 1); numeric lcm_accum = _num1; @@ -279,14 +279,14 @@ static ex multiply_lcm(const ex &e, const numeric &lcm) } v.push_back(lcm / lcm_accum); return (new mul(v))->setflag(status_flags::dynallocated); - } else if (is_ex_exactly_of_type(e, add)) { + } else if (is_exactly_a(e)) { unsigned num = e.nops(); exvector v; v.reserve(num); for (unsigned i=0; isetflag(status_flags::dynallocated); - } else if (is_ex_exactly_of_type(e, power)) { - if (is_ex_exactly_of_type(e.op(0), symbol)) + } else if (is_exactly_a(e)) { + if (is_exactly_a(e.op(0))) return e * lcm; else return pow(multiply_lcm(e.op(0), lcm.power(ex_to(e.op(1)).inverse())), e.op(1)); @@ -364,7 +364,7 @@ ex quo(const ex &a, const ex &b, const symbol &x, bool check_args) { if (b.is_zero()) throw(std::overflow_error("quo: division by zero")); - if (is_ex_exactly_of_type(a, numeric) && is_ex_exactly_of_type(b, numeric)) + if (is_exactly_a(a) && is_exactly_a(b)) return a / b; #if FAST_COMPARE if (a.is_equal(b)) @@ -380,7 +380,7 @@ ex quo(const ex &a, const ex &b, const symbol &x, bool check_args) int bdeg = b.degree(x); int rdeg = r.degree(x); ex blcoeff = b.expand().coeff(x, bdeg); - bool blcoeff_is_numeric = is_ex_exactly_of_type(blcoeff, numeric); + bool blcoeff_is_numeric = is_exactly_a(blcoeff); exvector v; v.reserve(std::max(rdeg - bdeg + 1, 0)); while (rdeg >= bdeg) { ex term, rcoeff = r.coeff(x, rdeg); @@ -414,8 +414,8 @@ ex rem(const ex &a, const ex &b, const symbol &x, bool check_args) { if (b.is_zero()) throw(std::overflow_error("rem: division by zero")); - if (is_ex_exactly_of_type(a, numeric)) { - if (is_ex_exactly_of_type(b, numeric)) + if (is_exactly_a(a)) { + if (is_exactly_a(b)) return _ex0; else return a; @@ -434,7 +434,7 @@ ex rem(const ex &a, const ex &b, const symbol &x, bool check_args) int bdeg = b.degree(x); int rdeg = r.degree(x); ex blcoeff = b.expand().coeff(x, bdeg); - bool blcoeff_is_numeric = is_ex_exactly_of_type(blcoeff, numeric); + bool blcoeff_is_numeric = is_exactly_a(blcoeff); while (rdeg >= bdeg) { ex term, rcoeff = r.coeff(x, rdeg); if (blcoeff_is_numeric) @@ -464,7 +464,7 @@ ex decomp_rational(const ex &a, const symbol &x) ex nd = numer_denom(a); ex numer = nd.op(0), denom = nd.op(1); ex q = quo(numer, denom, x); - if (is_ex_exactly_of_type(q, fail)) + if (is_exactly_a(q)) return a; else return q + rem(numer, denom, x) / denom; @@ -483,8 +483,8 @@ ex prem(const ex &a, const ex &b, const symbol &x, bool check_args) { if (b.is_zero()) throw(std::overflow_error("prem: division by zero")); - if (is_ex_exactly_of_type(a, numeric)) { - if (is_ex_exactly_of_type(b, numeric)) + if (is_exactly_a(a)) { + if (is_exactly_a(b)) return _ex0; else return b; @@ -535,8 +535,8 @@ ex sprem(const ex &a, const ex &b, const symbol &x, bool check_args) { if (b.is_zero()) throw(std::overflow_error("prem: division by zero")); - if (is_ex_exactly_of_type(a, numeric)) { - if (is_ex_exactly_of_type(b, numeric)) + if (is_exactly_a(a)) { + if (is_exactly_a(b)) return _ex0; else return b; @@ -590,10 +590,10 @@ bool divide(const ex &a, const ex &b, ex &q, bool check_args) q = _ex0; return true; } - if (is_ex_exactly_of_type(b, numeric)) { + if (is_exactly_a(b)) { q = a / b; return true; - } else if (is_ex_exactly_of_type(a, numeric)) + } else if (is_exactly_a(a)) return false; #if FAST_COMPARE if (a.is_equal(b)) { @@ -619,7 +619,7 @@ bool divide(const ex &a, const ex &b, ex &q, bool check_args) int bdeg = b.degree(*x); int rdeg = r.degree(*x); ex blcoeff = b.expand().coeff(*x, bdeg); - bool blcoeff_is_numeric = is_ex_exactly_of_type(blcoeff, numeric); + bool blcoeff_is_numeric = is_exactly_a(blcoeff); exvector v; v.reserve(std::max(rdeg - bdeg + 1, 0)); while (rdeg >= bdeg) { ex term, rcoeff = r.coeff(*x, rdeg); @@ -686,8 +686,8 @@ static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_ite q = a; return true; } - if (is_ex_exactly_of_type(a, numeric)) { - if (is_ex_exactly_of_type(b, numeric)) { + if (is_exactly_a(a)) { + if (is_exactly_a(b)) { q = a / b; return q.info(info_flags::integer); } else @@ -821,7 +821,7 @@ static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_ite ex ex::unit(const symbol &x) const { ex c = expand().lcoeff(x); - if (is_ex_exactly_of_type(c, numeric)) + if (is_exactly_a(c)) return c < _ex0 ? _ex_1 : _ex1; else { const symbol *y; @@ -844,7 +844,7 @@ ex ex::content(const symbol &x) const { if (is_zero()) return _ex0; - if (is_ex_exactly_of_type(*this, numeric)) + if (is_exactly_a(*this)) return info(info_flags::negative) ? -*this : *this; ex e = expand(); if (e.is_zero()) @@ -880,14 +880,14 @@ ex ex::primpart(const symbol &x) const { if (is_zero()) return _ex0; - if (is_ex_exactly_of_type(*this, numeric)) + if (is_exactly_a(*this)) return _ex1; ex c = content(x); if (c.is_zero()) return _ex0; ex u = unit(x); - if (is_ex_exactly_of_type(c, numeric)) + if (is_exactly_a(c)) return *this / (c * u); else return quo(*this, c * u, x, false); @@ -907,11 +907,11 @@ ex ex::primpart(const symbol &x, const ex &c) const return _ex0; if (c.is_zero()) return _ex0; - if (is_ex_exactly_of_type(*this, numeric)) + if (is_exactly_a(*this)) return _ex1; ex u = unit(x); - if (is_ex_exactly_of_type(c, numeric)) + if (is_exactly_a(c)) return *this / (c * u); else return quo(*this, c * u, x, false); @@ -1110,7 +1110,7 @@ static ex red_gcd(const ex &a, const ex &b, const symbol *x) throw(std::runtime_error("invalid expression in red_gcd(), division failed")); ddeg = d.degree(*x); if (ddeg == 0) { - if (is_ex_exactly_of_type(r, numeric)) + if (is_exactly_a(r)) return gamma; else return gamma * r.primpart(*x); @@ -1185,7 +1185,7 @@ static ex sr_gcd(const ex &a, const ex &b, sym_desc_vec::const_iterator var) throw(std::runtime_error("invalid expression in sr_gcd(), division failed")); ddeg = d.degree(x); if (ddeg == 0) { - if (is_ex_exactly_of_type(r, numeric)) + if (is_exactly_a(r)) return gamma; else return gamma * r.primpart(x); @@ -1356,7 +1356,7 @@ static ex heur_gcd(const ex &a, const ex &b, ex *ca, ex *cb, sym_desc_vec::const return (new fail())->setflag(status_flags::dynallocated); // GCD of two numeric values -> CLN - if (is_ex_exactly_of_type(a, numeric) && is_ex_exactly_of_type(b, numeric)) { + if (is_exactly_a(a) && is_exactly_a(b)) { numeric g = gcd(ex_to(a), ex_to(b)); if (ca) *ca = ex_to(a) / g; @@ -1394,7 +1394,7 @@ static ex heur_gcd(const ex &a, const ex &b, ex *ca, ex *cb, sym_desc_vec::const // Apply evaluation homomorphism and calculate GCD ex cp, cq; ex gamma = heur_gcd(p.subs(x == xi), q.subs(x == xi), &cp, &cq, var+1).expand(); - if (!is_ex_exactly_of_type(gamma, fail)) { + if (!is_exactly_a(gamma)) { // Reconstruct polynomial from GCD of mapped polynomials ex g = interpolate(gamma, xi, x, maxdeg); @@ -1407,7 +1407,7 @@ static ex heur_gcd(const ex &a, const ex &b, ex *ca, ex *cb, sym_desc_vec::const if (divide_in_z(p, g, ca ? *ca : dummy, var) && divide_in_z(q, g, cb ? *cb : dummy, var)) { g *= gc; ex lc = g.lcoeff(x); - if (is_ex_exactly_of_type(lc, numeric) && ex_to(lc).is_negative()) + if (is_exactly_a(lc) && ex_to(lc).is_negative()) return -g; else return g; @@ -1420,7 +1420,7 @@ static ex heur_gcd(const ex &a, const ex &b, ex *ca, ex *cb, sym_desc_vec::const if (ca) *ca = cp; ex lc = g.lcoeff(x); - if (is_ex_exactly_of_type(lc, numeric) && ex_to(lc).is_negative()) + if (is_exactly_a(lc) && ex_to(lc).is_negative()) return -g; else return g; @@ -1433,7 +1433,7 @@ static ex heur_gcd(const ex &a, const ex &b, ex *ca, ex *cb, sym_desc_vec::const if (cb) *cb = cq; ex lc = g.lcoeff(x); - if (is_ex_exactly_of_type(lc, numeric) && ex_to(lc).is_negative()) + if (is_exactly_a(lc) && ex_to(lc).is_negative()) return -g; else return g; @@ -1465,7 +1465,7 @@ ex gcd(const ex &a, const ex &b, ex *ca, ex *cb, bool check_args) #endif // GCD of numerics -> CLN - if (is_ex_exactly_of_type(a, numeric) && is_ex_exactly_of_type(b, numeric)) { + if (is_exactly_a(a) && is_exactly_a(b)) { numeric g = gcd(ex_to(a), ex_to(b)); if (ca || cb) { if (g.is_zero()) { @@ -1489,8 +1489,8 @@ ex gcd(const ex &a, const ex &b, ex *ca, ex *cb, bool check_args) } // Partially factored cases (to avoid expanding large expressions) - if (is_ex_exactly_of_type(a, mul)) { - if (is_ex_exactly_of_type(b, mul) && b.nops() > a.nops()) + if (is_exactly_a(a)) { + if (is_exactly_a(b) && b.nops() > a.nops()) goto factored_b; factored_a: unsigned num = a.nops(); @@ -1508,8 +1508,8 @@ factored_a: if (cb) *cb = part_b; return (new mul(g))->setflag(status_flags::dynallocated); - } else if (is_ex_exactly_of_type(b, mul)) { - if (is_ex_exactly_of_type(a, mul) && a.nops() > b.nops()) + } else if (is_exactly_a(b)) { + if (is_exactly_a(a) && a.nops() > b.nops()) goto factored_a; factored_b: unsigned num = b.nops(); @@ -1531,9 +1531,9 @@ factored_b: #if FAST_COMPARE // Input polynomials of the form poly^n are sometimes also trivial - if (is_ex_exactly_of_type(a, power)) { + if (is_exactly_a(a)) { ex p = a.op(0); - if (is_ex_exactly_of_type(b, power)) { + if (is_exactly_a(b)) { if (p.is_equal(b.op(0))) { // a = p^n, b = p^m, gcd = p^min(n, m) ex exp_a = a.op(1), exp_b = b.op(1); @@ -1561,7 +1561,7 @@ factored_b: return p; } } - } else if (is_ex_exactly_of_type(b, power)) { + } else if (is_exactly_a(b)) { ex p = b.op(0); if (p.is_equal(a)) { // a = p, b = p^n, gcd = p @@ -1650,7 +1650,7 @@ factored_b: } catch (gcdheu_failed) { g = fail(); } - if (is_ex_exactly_of_type(g, fail)) { + if (is_exactly_a(g)) { //std::clog << "heuristics failed" << std::endl; #if STATISTICS heur_gcd_failed++; @@ -1698,7 +1698,7 @@ factored_b: * @return the LCM as a new expression */ ex lcm(const ex &a, const ex &b, bool check_args) { - if (is_ex_exactly_of_type(a, numeric) && is_ex_exactly_of_type(b, numeric)) + if (is_exactly_a(a) && is_exactly_a(b)) return lcm(ex_to(a), ex_to(b)); if (check_args && (!a.info(info_flags::rational_polynomial) || !b.info(info_flags::rational_polynomial))) throw(std::invalid_argument("lcm: arguments must be polynomials over the rationals")); @@ -1799,7 +1799,7 @@ ex sqrfree(const ex &a, const lst &l) } // Find the symbol to factor in at this stage - if (!is_ex_of_type(args.op(0), symbol)) + if (!is_a(args.op(0))) throw (std::runtime_error("sqrfree(): invalid factorization variable")); const symbol &x = ex_to(args.op(0)); diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 55d5d556..c70b64ff 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -515,7 +515,7 @@ ex numeric::coeff(const ex & s, int n) const * sign as a multiplicative factor. */ bool numeric::has(const ex &other) const { - if (!is_ex_exactly_of_type(other, numeric)) + if (!is_exactly_a(other)) return false; const numeric &o = ex_to(other); if (this->is_equal(o) || this->is_equal(-o)) diff --git a/ginac/power.cpp b/ginac/power.cpp index 4c7519ec..1841a07b 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -246,7 +246,7 @@ int power::degree(const ex & s) const { if (is_equal(ex_to(s))) return 1; - else if (is_ex_exactly_of_type(exponent, numeric) && ex_to(exponent).is_integer()) { + else if (is_exactly_a(exponent) && ex_to(exponent).is_integer()) { if (basis.is_equal(s)) return ex_to(exponent).to_int(); else @@ -261,7 +261,7 @@ int power::ldegree(const ex & s) const { if (is_equal(ex_to(s))) return 1; - else if (is_ex_exactly_of_type(exponent, numeric) && ex_to(exponent).is_integer()) { + else if (is_exactly_a(exponent) && ex_to(exponent).is_integer()) { if (basis.is_equal(s)) return ex_to(exponent).to_int(); else @@ -284,7 +284,7 @@ ex power::coeff(const ex & s, int n) const return _ex0; } else { // basis equal to s - if (is_ex_exactly_of_type(exponent, numeric) && ex_to(exponent).is_integer()) { + if (is_exactly_a(exponent) && ex_to(exponent).is_integer()) { // integer exponent int int_exp = ex_to(exponent).to_int(); if (n == int_exp) @@ -330,11 +330,11 @@ ex power::eval(int level) const const numeric *num_basis; const numeric *num_exponent; - if (is_ex_exactly_of_type(ebasis, numeric)) { + if (is_exactly_a(ebasis)) { basis_is_numerical = true; num_basis = &ex_to(ebasis); } - if (is_ex_exactly_of_type(eexponent, numeric)) { + if (is_exactly_a(eexponent)) { exponent_is_numerical = true; num_exponent = &ex_to(eexponent); } @@ -425,11 +425,11 @@ ex power::eval(int level) const // ^(^(x,c1),c2) -> ^(x,c1*c2) // (c1, c2 numeric(), c2 integer or -1 < c1 <= 1, // case c1==1 should not happen, see below!) - if (is_ex_exactly_of_type(ebasis,power)) { + if (is_exactly_a(ebasis)) { const power & sub_power = ex_to(ebasis); const ex & sub_basis = sub_power.basis; const ex & sub_exponent = sub_power.exponent; - if (is_ex_exactly_of_type(sub_exponent,numeric)) { + if (is_exactly_a(sub_exponent)) { const numeric & num_sub_exponent = ex_to(sub_exponent); GINAC_ASSERT(num_sub_exponent!=numeric(1)); if (num_exponent->is_integer() || (abs(num_sub_exponent) - _num1).is_negative()) @@ -438,13 +438,13 @@ ex power::eval(int level) const } // ^(*(x,y,z),c1) -> *(x^c1,y^c1,z^c1) (c1 integer) - if (num_exponent->is_integer() && is_ex_exactly_of_type(ebasis,mul)) { + if (num_exponent->is_integer() && is_exactly_a(ebasis)) { return expand_mul(ex_to(ebasis), *num_exponent); } // ^(*(...,x;c1),c2) -> *(^(*(...,x;1),c2),c1^c2) (c1, c2 numeric(), c1>0) // ^(*(...,x;c1),c2) -> *(^(*(...,x;-1),c2),(-c1)^c2) (c1, c2 numeric(), c1<0) - if (is_ex_exactly_of_type(ebasis,mul)) { + if (is_exactly_a(ebasis)) { GINAC_ASSERT(!num_exponent->is_integer()); // should have been handled above const mul & mulref = ex_to(ebasis); if (!mulref.overall_coeff.is_equal(_ex1)) { @@ -475,7 +475,7 @@ ex power::eval(int level) const // ^(nc,c1) -> ncmul(nc,nc,...) (c1 positive integer, unless nc is a matrix) if (num_exponent->is_pos_integer() && ebasis.return_type() != return_types::commutative && - !is_ex_of_type(ebasis,matrix)) { + !is_a(ebasis)) { return ncmul(exvector(num_exponent->to_int(), ebasis), true); } } @@ -513,8 +513,8 @@ ex power::evalm(void) const { const ex ebasis = basis.evalm(); const ex eexponent = exponent.evalm(); - if (is_ex_of_type(ebasis,matrix)) { - if (is_ex_of_type(eexponent,numeric)) { + if (is_a(ebasis)) { + if (is_a(eexponent)) { return (new matrix(ex_to(ebasis).pow(eexponent)))->setflag(status_flags::dynallocated); } } @@ -590,7 +590,7 @@ ex power::expand(unsigned options) const const ex expanded_exponent = exponent.expand(options); // x^(a+b) -> x^a * x^b - if (is_ex_exactly_of_type(expanded_exponent, add)) { + if (is_exactly_a(expanded_exponent)) { const add &a = ex_to(expanded_exponent); exvector distrseq; distrseq.reserve(a.seq.size() + 1); @@ -605,7 +605,7 @@ ex power::expand(unsigned options) const if (ex_to(a.overall_coeff).is_integer()) { const numeric &num_exponent = ex_to(a.overall_coeff); int int_exponent = num_exponent.to_int(); - if (int_exponent > 0 && is_ex_exactly_of_type(expanded_basis, add)) + if (int_exponent > 0 && is_exactly_a(expanded_basis)) distrseq.push_back(expand_add(ex_to(expanded_basis), int_exponent)); else distrseq.push_back(power(expanded_basis, a.overall_coeff)); @@ -617,7 +617,7 @@ ex power::expand(unsigned options) const return r.expand(); } - if (!is_ex_exactly_of_type(expanded_exponent, numeric) || + if (!is_exactly_a(expanded_exponent) || !ex_to(expanded_exponent).is_integer()) { if (are_ex_trivially_equal(basis,expanded_basis) && are_ex_trivially_equal(exponent,expanded_exponent)) { return this->hold(); @@ -631,11 +631,11 @@ ex power::expand(unsigned options) const int int_exponent = num_exponent.to_int(); // (x+y)^n, n>0 - if (int_exponent > 0 && is_ex_exactly_of_type(expanded_basis,add)) + if (int_exponent > 0 && is_exactly_a(expanded_basis)) return expand_add(ex_to(expanded_basis), int_exponent); // (x*y)^n -> x^n * y^n - if (is_ex_exactly_of_type(expanded_basis,mul)) + if (is_exactly_a(expanded_basis)) return expand_mul(ex_to(expanded_basis), num_exponent); // cannot expand further @@ -688,7 +688,7 @@ ex power::expand_add(const add & a, int n) const !is_exactly_a(ex_to(b).basis) || !is_exactly_a(ex_to(b).basis) || !is_exactly_a(ex_to(b).basis)); - if (is_ex_exactly_of_type(b,mul)) + if (is_exactly_a(b)) term.push_back(expand_mul(ex_to(b),numeric(k[l]))); else term.push_back(power(b,k[l])); @@ -702,7 +702,7 @@ ex power::expand_add(const add & a, int n) const !is_exactly_a(ex_to(b).basis) || !is_exactly_a(ex_to(b).basis) || !is_exactly_a(ex_to(b).basis)); - if (is_ex_exactly_of_type(b,mul)) + if (is_exactly_a(b)) term.push_back(expand_mul(ex_to(b),numeric(n-k_cum[m-2]))); else term.push_back(power(b,n-k_cum[m-2])); @@ -765,7 +765,7 @@ ex power::expand_add_2(const add & a) const !is_exactly_a(ex_to(r).basis)); if (are_ex_trivially_equal(c,_ex1)) { - if (is_ex_exactly_of_type(r,mul)) { + if (is_exactly_a(r)) { sum.push_back(expair(expand_mul(ex_to(r),_num2), _ex1)); } else { @@ -773,7 +773,7 @@ ex power::expand_add_2(const add & a) const _ex1)); } } else { - if (is_ex_exactly_of_type(r,mul)) { + if (is_exactly_a(r)) { sum.push_back(expair(expand_mul(ex_to(r),_num2), ex_to(c).power_dyn(_num2))); } else { @@ -819,7 +819,7 @@ ex power::expand_mul(const mul & m, const numeric & n) const epvector::const_iterator last = m.seq.end(); epvector::const_iterator cit = m.seq.begin(); while (cit!=last) { - if (is_ex_exactly_of_type((*cit).rest,numeric)) { + if (is_exactly_a((*cit).rest)) { distrseq.push_back(m.combine_pair_with_coeff_to_pair(*cit,n)); } else { // it is safe not to call mul::combine_pair_with_coeff_to_pair() diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index 9a9045da..dab286f5 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -643,7 +643,7 @@ ex add::series(const relational & r, int order, unsigned options) const epvector::const_iterator itend = seq.end(); for (; it!=itend; ++it) { ex op; - if (is_ex_exactly_of_type(it->rest, pseries)) + if (is_exactly_a(it->rest)) op = it->rest; else op = it->rest.series(r, order, options); @@ -856,7 +856,7 @@ pseries pseries::shift_exponents(int deg) const ex power::series(const relational & r, int order, unsigned options) const { // If basis is already a series, just power it - if (is_ex_exactly_of_type(basis, pseries)) + if (is_exactly_a(basis)) return ex_to(basis).power_const(ex_to(exponent), order); // Basis is not a series, may there be a singularity? @@ -935,9 +935,9 @@ ex ex::series(const ex & r, int order, unsigned options) const ex e; relational rel_; - if (is_ex_exactly_of_type(r,relational)) + if (is_exactly_a(r)) rel_ = ex_to(r); - else if (is_ex_exactly_of_type(r,symbol)) + else if (is_exactly_a(r)) rel_ = relational(r,_ex0); else throw (std::logic_error("ex::series(): expansion point has unknown type")); diff --git a/ginac/relational.cpp b/ginac/relational.cpp index 3482f909..4f4dc9ff 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -318,7 +318,7 @@ relational::safe_bool relational::make_safe_bool(bool cond) const relational::operator relational::safe_bool() const { const ex df = lh-rh; - if (!is_ex_exactly_of_type(df,numeric)) + if (!is_exactly_a(df)) // cannot decide on non-numerical results return o==not_equal ? make_safe_bool(true) : make_safe_bool(false); diff --git a/ginac/structure.pl b/ginac/structure.pl index 809ae268..deb7f2db 100755 --- a/ginac/structure.pl +++ b/ginac/structure.pl @@ -113,7 +113,7 @@ $compare_statements=generate( $is_equal_statements=generate(' if (!m_${MEMBER}.is_equal(o.m_${MEMBER})) return false;',"\n"); $types_ok_statements=generate( '#ifndef SKIP_TYPE_CHECK_FOR_${TYPE}'."\n". -' if (!is_ex_exactly_of_type(m_${MEMBER},${TYPE})) return false;'."\n". +' if (!is_exactly_a<${TYPE}>(m_${MEMBER})) return false;'."\n". '#endif // ndef SKIP_TYPE_CHECK_FOR_${TYPE}',"\n"); $interface=<(other)); ${STRUCTURE} const &o = static_cast(other); int cmpval; ${compare_statements} @@ -434,7 +434,7 @@ ${compare_statements} bool ${STRUCTURE}::is_equal_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other,${STRUCTURE})); + GINAC_ASSERT(is_a<${STRUCTURE}>(other)); ${STRUCTURE} const &o = static_cast(other); ${is_equal_statements} return true; @@ -458,8 +458,7 @@ unsigned ${STRUCTURE}::return_type(void) const // public #define SKIP_TYPE_CHECK_FOR_ex -// this is a hack since there is no meaningful -// is_ex_exactly_of_type(...,ex) macro definition +// this is a hack since there is no meaningful is_a(...) definition bool ${STRUCTURE}::types_ok(void) const { diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 94d01e4c..dae17b34 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -116,7 +116,7 @@ ex symbol::unarchive(const archive_node &n, const lst &sym_lst) // If symbol is in sym_lst, return the existing symbol for (unsigned i=0; i(sym_lst.op(i)).name == ex_to(s).name)) + if (is_a(sym_lst.op(i)) && (ex_to(sym_lst.op(i)).name == ex_to(s).name)) return sym_lst.op(i); } return s; diff --git a/ginac/tensor.cpp b/ginac/tensor.cpp index 0ef65cc8..d330f586 100644 --- a/ginac/tensor.cpp +++ b/ginac/tensor.cpp @@ -301,7 +301,7 @@ ex tensepsilon::eval_indexed(const basic & i) const if (minkowski) { for (unsigned j=1; j(x)) throw(std::runtime_error("indices of epsilon tensor in Minkowski space must be of type varidx")); if (ex_to(x).is_covariant()) if (ex_to(x).get_value().is_zero()) @@ -368,7 +368,7 @@ bool tensmetric::contract_with(exvector::iterator self, exvector::iterator other // If contracting with the delta tensor, let the delta do it // (don't raise/lower delta indices) - if (is_ex_of_type(other->op(0), tensdelta)) + if (is_a(other->op(0))) return false; // Try to contract first index @@ -412,7 +412,7 @@ bool spinmetric::contract_with(exvector::iterator self, exvector::iterator other GINAC_ASSERT(is_a(self->op(0))); // Contractions between spinor metrics - if (is_ex_of_type(other->op(0), spinmetric)) { + if (is_a(other->op(0))) { const idx &self_i1 = ex_to(self->op(1)); const idx &self_i2 = ex_to(self->op(2)); const idx &other_i1 = ex_to(other->op(1)); @@ -445,7 +445,7 @@ bool spinmetric::contract_with(exvector::iterator self, exvector::iterator other // If contracting with the delta tensor, let the delta do it // (don't raise/lower delta indices) - if (is_ex_of_type(other->op(0), tensdelta)) + if (is_a(other->op(0))) return false; // Try to contract first index @@ -490,7 +490,7 @@ bool tensepsilon::contract_with(exvector::iterator self, exvector::iterator othe GINAC_ASSERT(is_a(self->op(0))); unsigned num = self->nops() - 1; - if (is_ex_exactly_of_type(other->op(0), tensepsilon) && num+1 == other->nops()) { + if (is_exactly_a(other->op(0)) && num+1 == other->nops()) { // Contraction of two epsilon tensors is a determinant ex dim = ex_to(self->op(1)).get_dim(); @@ -556,7 +556,7 @@ bool tensepsilon::contract_with(exvector::iterator self, exvector::iterator othe ex delta_tensor(const ex & i1, const ex & i2) { - if (!is_ex_of_type(i1, idx) || !is_ex_of_type(i2, idx)) + if (!is_a(i1) || !is_a(i2)) throw(std::invalid_argument("indices of delta tensor must be of type idx")); return indexed(tensdelta(), sy_symm(), i1, i2); @@ -564,7 +564,7 @@ ex delta_tensor(const ex & i1, const ex & i2) ex metric_tensor(const ex & i1, const ex & i2) { - if (!is_ex_of_type(i1, varidx) || !is_ex_of_type(i2, varidx)) + if (!is_a(i1) || !is_a(i2)) throw(std::invalid_argument("indices of metric tensor must be of type varidx")); return indexed(tensmetric(), sy_symm(), i1, i2); @@ -572,7 +572,7 @@ ex metric_tensor(const ex & i1, const ex & i2) ex lorentz_g(const ex & i1, const ex & i2, bool pos_sig) { - if (!is_ex_of_type(i1, varidx) || !is_ex_of_type(i2, varidx)) + if (!is_a(i1) || !is_a(i2)) throw(std::invalid_argument("indices of metric tensor must be of type varidx")); return indexed(minkmetric(pos_sig), sy_symm(), i1, i2); @@ -580,7 +580,7 @@ ex lorentz_g(const ex & i1, const ex & i2, bool pos_sig) ex spinor_metric(const ex & i1, const ex & i2) { - if (!is_ex_of_type(i1, spinidx) || !is_ex_of_type(i2, spinidx)) + if (!is_a(i1) || !is_a(i2)) throw(std::invalid_argument("indices of spinor metric must be of type spinidx")); if (!ex_to(i1).get_dim().is_equal(2) || !ex_to(i2).get_dim().is_equal(2)) throw(std::runtime_error("index dimension for spinor metric must be 2")); @@ -590,7 +590,7 @@ ex spinor_metric(const ex & i1, const ex & i2) ex epsilon_tensor(const ex & i1, const ex & i2) { - if (!is_ex_of_type(i1, idx) || !is_ex_of_type(i2, idx)) + if (!is_a(i1) || !is_a(i2)) throw(std::invalid_argument("indices of epsilon tensor must be of type idx")); ex dim = ex_to(i1).get_dim(); @@ -604,7 +604,7 @@ ex epsilon_tensor(const ex & i1, const ex & i2) ex epsilon_tensor(const ex & i1, const ex & i2, const ex & i3) { - if (!is_ex_of_type(i1, idx) || !is_ex_of_type(i2, idx) || !is_ex_of_type(i3, idx)) + if (!is_a(i1) || !is_a(i2) || !is_a(i3)) throw(std::invalid_argument("indices of epsilon tensor must be of type idx")); ex dim = ex_to(i1).get_dim(); @@ -618,7 +618,7 @@ ex epsilon_tensor(const ex & i1, const ex & i2, const ex & i3) ex lorentz_eps(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool pos_sig) { - if (!is_ex_of_type(i1, varidx) || !is_ex_of_type(i2, varidx) || !is_ex_of_type(i3, varidx) || !is_ex_of_type(i4, varidx)) + if (!is_a(i1) || !is_a(i2) || !is_a(i3) || !is_a(i4)) throw(std::invalid_argument("indices of Lorentz epsilon tensor must be of type varidx")); ex dim = ex_to(i1).get_dim(); @@ -632,7 +632,7 @@ ex lorentz_eps(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool ex eps0123(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool pos_sig) { - if (!is_ex_of_type(i1, varidx) || !is_ex_of_type(i2, varidx) || !is_ex_of_type(i3, varidx) || !is_ex_of_type(i4, varidx)) + if (!is_a(i1) || !is_a(i2) || !is_a(i3) || !is_a(i4)) throw(std::invalid_argument("indices of epsilon tensor must be of type varidx")); ex dim = ex_to(i1).get_dim(); diff --git a/ginac/utils.h b/ginac/utils.h index 791cfb5d..a161ee2b 100644 --- a/ginac/utils.h +++ b/ginac/utils.h @@ -517,21 +517,6 @@ void classname::print(const print_context & c, unsigned level) const \ c.s << text; \ } -// Obsolete convenience macros. TO BE PHASED OUT SOON! -// Use the inlined template functions in basic.h instead. (FIXME: remove them) - -#define is_of_type(OBJ,TYPE) \ - (dynamic_cast(&OBJ)!=0) - -#define is_exactly_of_type(OBJ,TYPE) \ - ((OBJ).tinfo()==GiNaC::TINFO_##TYPE) - -#define is_ex_of_type(OBJ,TYPE) \ - (dynamic_cast((OBJ).bp)!=0) - -#define is_ex_exactly_of_type(OBJ,TYPE) \ - ((*(OBJ).bp).tinfo()==GiNaC::TINFO_##TYPE) - } // namespace GiNaC