From: Christian Bauer Date: Tue, 3 Dec 2002 21:52:34 +0000 (+0000) Subject: cleaned up some is_a<> vs. is_exactly_a<> stuff X-Git-Tag: release_1-1-0~49 X-Git-Url: https://www.ginac.de/ginac.git/static/gitweb.css/ginac.git?a=commitdiff_plain;h=391e81ad4f94a94d91d68c9a8c86b2111223eb39;p=ginac.git cleaned up some is_a<> vs. is_exactly_a<> stuff --- diff --git a/ginac/idx.cpp b/ginac/idx.cpp index d663be71..b60da944 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -411,7 +411,7 @@ bool idx::is_dummy_pair_same_type(const basic & other) const if (dim.is_equal(o.dim)) return true; - return (dim < o.dim || dim > o.dim || (is_a(dim) && is_a(o.dim)) || (is_a(dim) && is_a(o.dim))); + return (dim < o.dim || dim > o.dim || (is_exactly_a(dim) && is_a(o.dim)) || (is_a(dim) && is_exactly_a(o.dim))); } bool varidx::is_dummy_pair_same_type(const basic & other) const @@ -544,9 +544,9 @@ void find_free_and_dummy(exvector::const_iterator it, exvector::const_iterator i ex minimal_dim(const ex & dim1, const ex & dim2) { - if (dim1.is_equal(dim2) || dim1 < dim2 || (is_a(dim1) && is_a(dim2))) + if (dim1.is_equal(dim2) || dim1 < dim2 || (is_exactly_a(dim1) && is_a(dim2))) return dim1; - else if (dim1 > dim2 || (is_a(dim1) && is_a(dim2))) + else if (dim1 > dim2 || (is_a(dim1) && is_exactly_a(dim2))) return dim2; else throw (std::runtime_error("minimal_dim(): index dimensions cannot be ordered")); diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index 7978327a..ae2328ad 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -838,13 +838,13 @@ public: symminfo(const ex & symmterm_, const ex & orig_) { - if (is_a(orig_) && is_a(orig_.op(orig_.nops()-1))) { + if (is_exactly_a(orig_) && is_exactly_a(orig_.op(orig_.nops()-1))) { ex tmp = orig_.op(orig_.nops()-1); orig = orig_ / tmp; } else orig = orig_; - if (is_a(symmterm_) && is_a(symmterm_.op(symmterm_.nops()-1))) { + if (is_exactly_a(symmterm_) && is_exactly_a(symmterm_.op(symmterm_.nops()-1))) { coeff = symmterm_.op(symmterm_.nops()-1); symmterm = symmterm_ / coeff; } else { @@ -955,7 +955,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi } // Symmetrizing over the dummy indices may cancel terms - int num_terms_orig = (is_a(sum) ? sum.nops() : 1); + int num_terms_orig = (is_exactly_a(sum) ? sum.nops() : 1); if (num_terms_orig > 1 && dummy_indices.size() >= 2) { // Construct list of all dummy index symbols @@ -968,7 +968,7 @@ ex simplify_indexed(const ex & e, exvector & free_indices, exvector & dummy_indi std::vector v; for (int i=0; i(sum_symm)) + if (is_exactly_a(sum_symm)) for (int j=0; j(arg)) return csgn(ex_to(arg)); - else if (is_a(arg) && - is_a(arg.op(arg.nops()-1))) { + else if (is_exactly_a(arg) && + is_exactly_a(arg.op(arg.nops()-1))) { numeric oc = ex_to(arg.op(arg.nops()-1)); if (oc.is_real()) { if (oc > 0) @@ -420,7 +420,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_exactly_a(r.lhs())); + GINAC_ASSERT(is_a(r.lhs())); const symbol &s = ex_to(r.lhs()); new_seq.push_back(expair(Order(_ex1), numeric(std::min(x.ldegree(s), order)))); return pseries(r, new_seq); diff --git a/ginac/inifcns_gamma.cpp b/ginac/inifcns_gamma.cpp index 14b9ae87..e8a01a7e 100644 --- a/ginac/inifcns_gamma.cpp +++ b/ginac/inifcns_gamma.cpp @@ -296,7 +296,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_exactly_a(rel.lhs())); + GINAC_ASSERT(is_a(rel.lhs())); const symbol &s = ex_to(rel.lhs()); ex arg1_ser, arg2_ser, arg1arg2_ser; if ((!arg1_pt.info(info_flags::integer) || arg1_pt.info(info_flags::positive)) && diff --git a/ginac/inifcns_trans.cpp b/ginac/inifcns_trans.cpp index 877e2c28..e37c66db 100644 --- a/ginac/inifcns_trans.cpp +++ b/ginac/inifcns_trans.cpp @@ -155,7 +155,7 @@ static ex log_series(const ex &arg, int order, unsigned options) { - GINAC_ASSERT(is_exactly_a(rel.lhs())); + GINAC_ASSERT(is_a(rel.lhs())); ex arg_pt; bool must_expand_arg = false; // maybe substitution of rel into arg fails because of a pole @@ -469,7 +469,7 @@ static ex tan_series(const ex &x, int order, unsigned options) { - GINAC_ASSERT(is_exactly_a(rel.lhs())); + GINAC_ASSERT(is_a(rel.lhs())); // method: // Taylor series where there is no pole falls back to tan_deriv. // On a pole simply expand sin(x)/cos(x). @@ -635,7 +635,7 @@ static ex atan_series(const ex &arg, int order, unsigned options) { - GINAC_ASSERT(is_exactly_a(rel.lhs())); + GINAC_ASSERT(is_a(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 @@ -879,7 +879,7 @@ static ex tanh_series(const ex &x, int order, unsigned options) { - GINAC_ASSERT(is_exactly_a(rel.lhs())); + GINAC_ASSERT(is_a(rel.lhs())); // method: // Taylor series where there is no pole falls back to tanh_deriv. // On a pole simply expand sinh(x)/cosh(x). @@ -1020,7 +1020,7 @@ static ex atanh_series(const ex &arg, int order, unsigned options) { - GINAC_ASSERT(is_exactly_a(rel.lhs())); + GINAC_ASSERT(is_a(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 diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index 33e38a63..1b6d1b72 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -1419,11 +1419,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_a(this->m[k*col+co])); + GINAC_ASSERT(is_exactly_a(this->m[k*col+co])); unsigned kmax = k+1; numeric mmax = abs(ex_to(m[kmax*col+co])); while (kmax(this->m[kmax*col+co])); + GINAC_ASSERT(is_exactly_a(this->m[kmax*col+co])); numeric tmp = ex_to(this->m[kmax*col+co]); if (abs(tmp) > mmax) { mmax = tmp; diff --git a/ginac/mul.cpp b/ginac/mul.cpp index aeb8c30e..ca92a7b8 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -224,7 +224,7 @@ void mul::print(const print_context & c, unsigned level) const // and all others exvector neg_powers, others; while (it != itend) { - GINAC_ASSERT(is_a(it->coeff)); + GINAC_ASSERT(is_exactly_a(it->coeff)); if (ex_to(it->coeff).is_negative()) neg_powers.push_back(recombine_pair_to_ex(expair(it->rest, -(it->coeff)))); else diff --git a/ginac/normal.cpp b/ginac/normal.cpp index f2cb382a..03712797 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -93,7 +93,7 @@ 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_exactly_a(e)) { + if (is_a(e)) { x = &ex_to(e); return true; } else if (is_exactly_a(e) || is_exactly_a(e)) { @@ -170,7 +170,7 @@ 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_exactly_a(e)) { + if (is_a(e)) { add_symbol(&ex_to(e), v); } else if (is_exactly_a(e) || is_exactly_a(e)) { for (unsigned i=0; i(e)) { - if (is_exactly_a(e.op(0))) + if (is_a(e.op(0))) return l; else return pow(lcmcoeff(e.op(0), l), ex_to(e.op(1))); @@ -287,7 +287,7 @@ static ex multiply_lcm(const ex &e, const numeric &lcm) v.push_back(multiply_lcm(e.op(i), lcm)); return (new add(v))->setflag(status_flags::dynallocated); } else if (is_exactly_a(e)) { - if (is_exactly_a(e.op(0))) + if (is_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)); @@ -1780,7 +1780,7 @@ static exvector sqrfree_yun(const ex &a, const symbol &x) */ ex sqrfree(const ex &a, const lst &l) { - if (is_a(a) || // algorithm does not trap a==0 + if (is_exactly_a(a) || // algorithm does not trap a==0 is_a(a)) // shortcut return a; @@ -2421,7 +2421,7 @@ ex expairseq::to_rational(lst &repl_lst) const * to 1, unless you're accumulating factors). */ static ex find_common_factor(const ex & e, ex & factor, lst & repl) { - if (is_a(e)) { + if (is_exactly_a(e)) { unsigned num = e.nops(); exvector terms; terms.reserve(num); @@ -2431,7 +2431,7 @@ static ex find_common_factor(const ex & e, ex & factor, lst & repl) for (unsigned i=0; i(x) || is_a(x)) { + if (is_exactly_a(x) || is_exactly_a(x)) { ex f = 1; x = find_common_factor(x, f, repl); x *= f; @@ -2457,7 +2457,7 @@ static ex find_common_factor(const ex & e, ex & factor, lst & repl) // Try to avoid divide() because it expands the polynomial ex &t = terms[i]; - if (is_a(t)) { + if (is_exactly_a(t)) { for (unsigned j=0; jsetflag(status_flags::dynallocated); - } else if (is_a(e)) { + } else if (is_exactly_a(e)) { unsigned num = e.nops(); exvector v; v.reserve(num); @@ -2489,10 +2489,10 @@ term_done: ; return (new mul(v))->setflag(status_flags::dynallocated); - } else if (is_a(e)) { + } else if (is_exactly_a(e)) { ex x = e.to_rational(repl); - if (is_a(x) && x.op(1).info(info_flags::negative)) + if (is_exactly_a(x) && x.op(1).info(info_flags::negative)) return replace_with_symbol(x, repl); else return x; @@ -2506,7 +2506,7 @@ term_done: ; * 'a*(b*x+b*y)' to 'a*b*(x+y)'. */ ex collect_common_factors(const ex & e) { - if (is_a(e) || is_a(e)) { + if (is_exactly_a(e) || is_exactly_a(e)) { lst repl; ex factor = 1; diff --git a/ginac/power.cpp b/ginac/power.cpp index 86c684c3..ed26a4f7 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -126,7 +126,7 @@ void power::print(const print_context & c, unsigned level) const // Integer powers of symbols are printed in a special, optimized way if (exponent.info(info_flags::integer) - && (is_exactly_a(basis) || is_exactly_a(basis))) { + && (is_a(basis) || is_a(basis))) { int exp = ex_to(exponent).to_int(); if (exp > 0) c.s << '('; @@ -173,7 +173,7 @@ void power::print(const print_context & c, unsigned level) const bool is_tex = is_a(c); - if (is_tex && is_a(exponent) && ex_to(exponent).is_negative()) { + if (is_tex && is_exactly_a(exponent) && ex_to(exponent).is_negative()) { // Powers with negative numeric exponents are printed as fractions in TeX c.s << "\\frac{1}{"; @@ -516,7 +516,7 @@ ex power::evalm(void) const const ex ebasis = basis.evalm(); const ex eexponent = exponent.evalm(); if (is_a(ebasis)) { - if (is_a(eexponent)) { + if (is_exactly_a(eexponent)) { return (new matrix(ex_to(ebasis).pow(eexponent)))->setflag(status_flags::dynallocated); } } diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index b32953f4..3eedd8f8 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -74,8 +74,8 @@ DEFAULT_DESTROY(pseries) * @return newly constructed pseries */ pseries::pseries(const ex &rel_, const epvector &ops_) : basic(TINFO_pseries), seq(ops_) { - GINAC_ASSERT(is_exactly_a(rel_)); - GINAC_ASSERT(is_exactly_a(rel_.lhs())); + GINAC_ASSERT(is_a(rel_)); + GINAC_ASSERT(is_a(rel_.lhs())); point = rel_.rhs(); var = rel_.lhs(); } @@ -552,7 +552,7 @@ ex symbol::series(const relational & r, int order, unsigned options) const { epvector seq; const ex point = r.rhs(); - GINAC_ASSERT(is_exactly_a(r.lhs())); + GINAC_ASSERT(is_a(r.lhs())); if (this->is_equal_same_type(ex_to(r.lhs()))) { if (order > 0 && !point.is_zero()) @@ -908,7 +908,7 @@ ex power::series(const relational & r, int order, unsigned options) const ex pseries::series(const relational & r, int order, unsigned options) const { const ex p = r.rhs(); - GINAC_ASSERT(is_exactly_a(r.lhs())); + GINAC_ASSERT(is_a(r.lhs())); const symbol &s = ex_to(r.lhs()); if (var.is_equal(s) && point.is_equal(p)) { @@ -948,9 +948,9 @@ ex ex::series(const ex & r, int order, unsigned options) const ex e; relational rel_; - if (is_exactly_a(r)) + if (is_a(r)) rel_ = ex_to(r); - else if (is_exactly_a(r)) + else if (is_a(r)) rel_ = relational(r,_ex0); else throw (std::logic_error("ex::series(): expansion point has unknown type"));