From: Christian Bauer Date: Mon, 21 Jul 2003 18:15:48 +0000 (+0000) Subject: generous use of subs_options::no_pattern X-Git-Tag: release_1-0-15~18 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=b301f03a61bc9f72b27940ca7fe1f8d0b343a4e2 generous use of subs_options::no_pattern --- diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 547285d0..0b3801e1 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -588,7 +588,7 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE) ex e_expanded = e.subs(lst( dirac_gammaL(rl) == (dirac_ONE(rl)-dirac_gamma5(rl))/2, dirac_gammaR(rl) == (dirac_ONE(rl)+dirac_gamma5(rl))/2 - )).expand(); + ), subs_options::no_pattern).expand(); if (!is_a(e_expanded)) return dirac_trace(e_expanded, rl, trONE); @@ -734,7 +734,7 @@ ex canonicalize_clifford(const ex & e) next_sym: ; } } - return aux.subs(srl).simplify_indexed(); + return aux.subs(srl, subs_options::no_pattern).simplify_indexed(); } } // namespace GiNaC diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index c899e13c..48bb1421 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -560,7 +560,7 @@ static ex rename_dummy_indices(const ex & e, exvector & global_dummy_indices, ex else { while (global_uniq.size() > local_uniq.size()) global_uniq.pop_back(); - return e.subs(lst(local_uniq.begin(), local_uniq.end()), lst(global_uniq.begin(), global_uniq.end())); + return e.subs(lst(local_uniq.begin(), local_uniq.end()), lst(global_uniq.begin(), global_uniq.end()), subs_options::no_pattern); } } @@ -599,7 +599,7 @@ bool reposition_dummy_indices(ex & e, exvector & variant_dummy_indices, exvector e = e.subs(lst( *it2 == ex_to(*it2).toggle_variance(), ex_to(*it2).toggle_variance() == *it2 - )); + ), subs_options::no_pattern); something_changed = true; it2 = ex_to(e).seq.begin() + (it2 - it2start); it2start = ex_to(e).seq.begin(); @@ -614,7 +614,7 @@ bool reposition_dummy_indices(ex & e, exvector & variant_dummy_indices, exvector for (vit = moved_indices.begin(), vitend = moved_indices.end(); vit != vitend; ++vit) { if (it2->op(0).is_equal(vit->op(0))) { if (ex_to(*it2).is_contravariant()) { - e = e.subs(*it2 == ex_to(*it2).toggle_variance()); + e = e.subs(*it2 == ex_to(*it2).toggle_variance(), subs_options::no_pattern); something_changed = true; it2 = ex_to(e).seq.begin() + (it2 - it2start); it2start = ex_to(e).seq.begin(); diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index 73f9c221..7b9a0c68 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -109,7 +109,7 @@ static ex csgn_series(const ex & arg, int order, unsigned options) { - const ex arg_pt = arg.subs(rel); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (arg_pt.info(info_flags::numeric) && ex_to(arg_pt).real().is_zero() && !(options & series_options::suppress_branchcut)) @@ -186,8 +186,8 @@ static ex eta_series(const ex & x, const ex & y, int order, unsigned options) { - const ex x_pt = x.subs(rel); - const ex y_pt = y.subs(rel); + const ex x_pt = x.subs(rel, subs_options::no_pattern); + const ex y_pt = y.subs(rel, subs_options::no_pattern); if ((x_pt.info(info_flags::numeric) && x_pt.info(info_flags::negative)) || (y_pt.info(info_flags::numeric) && y_pt.info(info_flags::negative)) || ((x_pt*y_pt).info(info_flags::numeric) && (x_pt*y_pt).info(info_flags::negative))) @@ -255,7 +255,7 @@ static ex Li2_deriv(const ex & x, unsigned deriv_param) static ex Li2_series(const ex &x, const relational &rel, int order, unsigned options) { - const ex x_pt = x.subs(rel); + const ex x_pt = x.subs(rel, subs_options::no_pattern); if (x_pt.info(info_flags::numeric)) { // First special case: x==0 (derivatives have poles) if (x_pt.is_zero()) { @@ -277,7 +277,7 @@ static ex Li2_series(const ex &x, const relational &rel, int order, unsigned opt for (int i=1; i(rel.lhs())); const symbol &s = ex_to(rel.lhs()); ex arg1_ser, arg2_ser, arg1arg2_ser; @@ -411,7 +411,7 @@ static ex psi1_series(const ex & arg, // from which follows // series(psi(x),x==-m,order) == // series(psi(x+m+1) - 1/x - 1/(x+1) - 1/(x+m)),x==-m,order); - const ex arg_pt = arg.subs(rel); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole at -m: @@ -538,7 +538,7 @@ static ex psi2_series(const ex & n, // series(psi(x),x==-m,order) == // series(psi(x+m+1) - (-1)^n * n! * ((x)^(-n-1) + (x+1)^(-n-1) + ... // ... + (x+m)^(-n-1))),x==-m,order); - const ex arg_pt = arg.subs(rel); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a pole of order n+1 at -m: diff --git a/ginac/inifcns_trans.cpp b/ginac/inifcns_trans.cpp index 79d7cd47..239b1ea2 100644 --- a/ginac/inifcns_trans.cpp +++ b/ginac/inifcns_trans.cpp @@ -152,7 +152,7 @@ static ex log_series(const ex &arg, bool must_expand_arg = false; // maybe substitution of rel into arg fails because of a pole try { - arg_pt = arg.subs(rel); + arg_pt = arg.subs(rel, subs_options::no_pattern); } catch (pole_error) { must_expand_arg = true; } @@ -206,7 +206,7 @@ static ex log_series(const ex &arg, const symbol &s = ex_to(rel.lhs()); const ex &point = rel.rhs(); const symbol foo; - const ex replarg = series(log(arg), s==foo, order).subs(foo==point); + const ex replarg = series(log(arg), s==foo, order).subs(foo==point, subs_options::no_pattern); epvector seq; seq.push_back(expair(-I*csgn(arg*I)*Pi, _ex0)); seq.push_back(expair(Order(_ex1), order)); @@ -465,7 +465,7 @@ static ex tan_series(const ex &x, // method: // Taylor series where there is no pole falls back to tan_deriv. // On a pole simply expand sin(x)/cos(x). - const ex x_pt = x.subs(rel); + const ex x_pt = x.subs(rel, subs_options::no_pattern); if (!(2*x_pt/Pi).info(info_flags::odd)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole @@ -636,7 +636,7 @@ static ex atan_series(const ex &arg, // On the branch cuts and the poles series expand // (log(1+I*x)-log(1-I*x))/(2*I) // instead. - const ex arg_pt = arg.subs(rel); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!(I*arg_pt).info(info_flags::real)) throw do_taylor(); // Re(x) != 0 if ((I*arg_pt).info(info_flags::real) && abs(I*arg_pt)<_ex1) @@ -651,7 +651,7 @@ static ex atan_series(const ex &arg, const symbol &s = ex_to(rel.lhs()); const ex &point = rel.rhs(); const symbol foo; - const ex replarg = series(atan(arg), s==foo, order).subs(foo==point); + const ex replarg = series(atan(arg), s==foo, order).subs(foo==point, subs_options::no_pattern); ex Order0correction = replarg.op(0)+csgn(arg)*Pi*_ex_1_2; if ((I*arg_pt)<_ex0) Order0correction += log((I*arg_pt+_ex_1)/(I*arg_pt+_ex1))*I*_ex_1_2; @@ -875,7 +875,7 @@ static ex tanh_series(const ex &x, // method: // Taylor series where there is no pole falls back to tanh_deriv. // On a pole simply expand sinh(x)/cosh(x). - const ex x_pt = x.subs(rel); + const ex x_pt = x.subs(rel, subs_options::no_pattern); if (!(2*I*x_pt/Pi).info(info_flags::odd)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole @@ -1020,7 +1020,7 @@ static ex atanh_series(const ex &arg, // On the branch cuts and the poles series expand // (log(1+x)-log(1-x))/2 // instead. - const ex arg_pt = arg.subs(rel); + const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!(arg_pt).info(info_flags::real)) throw do_taylor(); // Im(x) != 0 if ((arg_pt).info(info_flags::real) && abs(arg_pt)<_ex1) @@ -1036,7 +1036,7 @@ static ex atanh_series(const ex &arg, const symbol &s = ex_to(rel.lhs()); const ex &point = rel.rhs(); const symbol foo; - const ex replarg = series(atanh(arg), s==foo, order).subs(foo==point); + const ex replarg = series(atanh(arg), s==foo, order).subs(foo==point, subs_options::no_pattern); ex Order0correction = replarg.op(0)+csgn(I*arg)*Pi*I*_ex1_2; if (arg_pt<_ex0) Order0correction += log((arg_pt+_ex_1)/(arg_pt+_ex1))*_ex1_2; diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index cdb875d3..4828bb93 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -1388,7 +1388,7 @@ int matrix::fraction_free_elimination(const bool det) tmp_n_it = tmp_n.m.begin(); tmp_d_it = tmp_d.m.begin(); while (it != itend) - *it++ = ((*tmp_n_it++)/(*tmp_d_it++)).subs(srl); + *it++ = ((*tmp_n_it++)/(*tmp_d_it++)).subs(srl, subs_options::no_pattern); return sign; } diff --git a/ginac/normal.cpp b/ginac/normal.cpp index 3a8a82fc..8e2ec00e 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -730,12 +730,12 @@ static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_ite numeric point = _num0; ex c; for (i=0; i<=adeg; i++) { - ex bs = b.subs(*x == point); + ex bs = b.subs(*x == point, subs_options::no_pattern); while (bs.is_zero()) { point += _num1; - bs = b.subs(*x == point); + bs = b.subs(*x == point, subs_options::no_pattern); } - if (!divide_in_z(a.subs(*x == point), bs, c, var+1)) + if (!divide_in_z(a.subs(*x == point, subs_options::no_pattern), bs, c, var+1)) return false; alpha.push_back(point); u.push_back(c); @@ -1187,7 +1187,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(); + ex gamma = heur_gcd(p.subs(x == xi, subs_options::no_pattern), q.subs(x == xi, subs_options::no_pattern), &cp, &cq, var+1).expand(); if (!is_exactly_a(gamma)) { // Reconstruct polynomial from GCD of mapped polynomials @@ -1695,7 +1695,7 @@ static ex replace_with_symbol(const ex & e, exmap & repl) // replacement expression doesn't itself contain symbols from repl, // because subs() is not recursive ex es = (new symbol)->setflag(status_flags::dynallocated); - ex e_replaced = e.subs(repl); + ex e_replaced = e.subs(repl, subs_options::no_pattern); repl[es] = e_replaced; return es; } @@ -1716,7 +1716,7 @@ static ex replace_with_symbol(const ex & e, lst & repl_lst) // replacement expression doesn't itself contain symbols from the repl_lst, // because subs() is not recursive ex es = (new symbol)->setflag(status_flags::dynallocated); - ex e_replaced = e.subs(repl_lst); + ex e_replaced = e.subs(repl_lst, subs_options::no_pattern); repl_lst.append(es == e_replaced); return es; } @@ -2027,7 +2027,7 @@ ex ex::normal(int level) const // Re-insert replaced symbols if (!repl.empty()) - e = e.subs(repl); + e = e.subs(repl, subs_options::no_pattern); // Convert {numerator, denominator} form back to fraction return e.op(0) / e.op(1); @@ -2050,7 +2050,7 @@ ex ex::numer() const if (repl.empty()) return e.op(0); else - return e.op(0).subs(repl); + return e.op(0).subs(repl, subs_options::no_pattern); } /** Get denominator of an expression. If the expression is not of the normal @@ -2070,7 +2070,7 @@ ex ex::denom() const if (repl.empty()) return e.op(1); else - return e.op(1).subs(repl); + return e.op(1).subs(repl, subs_options::no_pattern); } /** Get numerator and denominator of an expression. If the expresison is not @@ -2090,7 +2090,7 @@ ex ex::numer_denom() const if (repl.empty()) return e; else - return e.subs(repl); + return e.subs(repl, subs_options::no_pattern); } @@ -2333,7 +2333,7 @@ ex collect_common_factors(const ex & e) lst repl; ex factor = 1; ex r = find_common_factor(e, factor, repl); - return factor.subs(repl) * r.subs(repl); + return factor.subs(repl, subs_options::no_pattern) * r.subs(repl, subs_options::no_pattern); } else return e; diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index 22d7b777..48dfa1eb 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -503,7 +503,7 @@ ex basic::series(const relational & r, int order, unsigned options) const epvector seq; numeric fac = 1; ex deriv = *this; - ex coeff = deriv.subs(r); + ex coeff = deriv.subs(r, subs_options::no_pattern); const symbol &s = ex_to(r.lhs()); if (!coeff.is_zero()) @@ -519,7 +519,7 @@ ex basic::series(const relational & r, int order, unsigned options) const if (deriv.is_zero()) // Series terminates return pseries(r, seq); - coeff = deriv.subs(r); + coeff = deriv.subs(r, subs_options::no_pattern); if (!coeff.is_zero()) seq.push_back(expair(fac.inverse() * coeff, n)); } @@ -861,7 +861,7 @@ ex power::series(const relational & r, int order, unsigned options) const // Basis is not a series, may there be a singularity? bool must_expand_basis = false; try { - basis.subs(r); + basis.subs(r, subs_options::no_pattern); } catch (pole_error) { must_expand_basis = true; } @@ -871,7 +871,7 @@ ex power::series(const relational & r, int order, unsigned options) const return basic::series(r, order, options); // Is the expression of type 0^something? - if (!must_expand_basis && !basis.subs(r).is_zero()) + if (!must_expand_basis && !basis.subs(r, subs_options::no_pattern).is_zero()) return basic::series(r, order, options); // Singularity encountered, is the basis equal to (var - point)? diff --git a/ginac/symmetry.cpp b/ginac/symmetry.cpp index a0a2af1d..504a9fc4 100644 --- a/ginac/symmetry.cpp +++ b/ginac/symmetry.cpp @@ -363,7 +363,7 @@ static ex symm(const ex & e, exvector::const_iterator first, exvector::const_ite lst new_lst; for (unsigned i=0; i