generous use of subs_options::no_pattern
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Mon, 21 Jul 2003 18:15:48 +0000 (18:15 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Mon, 21 Jul 2003 18:15:48 +0000 (18:15 +0000)
ginac/clifford.cpp
ginac/indexed.cpp
ginac/inifcns.cpp
ginac/inifcns_gamma.cpp
ginac/inifcns_trans.cpp
ginac/matrix.cpp
ginac/normal.cpp
ginac/pseries.cpp
ginac/symmetry.cpp
ginac/tensor.cpp

index 547285d..0b3801e 100644 (file)
@@ -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<ncmul>(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
index c899e13..48bb142 100644 (file)
@@ -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<varidx>(*it2).toggle_variance(),
                                                ex_to<varidx>(*it2).toggle_variance() == *it2
-                                       ));
+                                       ), subs_options::no_pattern);
                                        something_changed = true;
                                        it2 = ex_to<indexed>(e).seq.begin() + (it2 - it2start);
                                        it2start = ex_to<indexed>(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<varidx>(*it2).is_contravariant()) {
-                                       e = e.subs(*it2 == ex_to<varidx>(*it2).toggle_variance());
+                                       e = e.subs(*it2 == ex_to<varidx>(*it2).toggle_variance(), subs_options::no_pattern);
                                        something_changed = true;
                                        it2 = ex_to<indexed>(e).seq.begin() + (it2 - it2start);
                                        it2start = ex_to<indexed>(e).seq.begin();
index 73f9c22..7b9a0c6 100644 (file)
@@ -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<numeric>(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<order; ++i)
                                ser += pow(s,i) / pow(numeric(i), _num2);
                        // substitute the argument's series expansion
-                       ser = ser.subs(s==x.series(rel, order));
+                       ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
                        epvector nseq;
                        nseq.push_back(expair(Order(_ex1), order));
@@ -302,7 +302,7 @@ static ex Li2_series(const ex &x, const relational &rel, int order, unsigned opt
                        for (int i=1; i<order; ++i)
                                ser += pow(1-s,i) * (numeric(1,i)*(I*Pi+log(s-1)) - numeric(1,i*i));
                        // substitute the argument's series expansion
-                       ser = ser.subs(s==x.series(rel, order));
+                       ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
                        epvector nseq;
                        nseq.push_back(expair(Order(_ex1), order));
@@ -325,7 +325,7 @@ static ex Li2_series(const ex &x, const relational &rel, int order, unsigned opt
                        // compute the intermediate terms:
                        ex replarg = series(Li2(x), s==foo, order);
                        for (size_t i=1; i<replarg.nops()-1; ++i)
-                               seq.push_back(expair((replarg.op(i)/power(s-foo,i)).series(foo==point,1,options).op(0).subs(foo==s),i));
+                               seq.push_back(expair((replarg.op(i)/power(s-foo,i)).series(foo==point,1,options).op(0).subs(foo==s, subs_options::no_pattern),i));
                        // append an order term:
                        seq.push_back(expair(Order(_ex1), replarg.nops()-1));
                        return pseries(rel, seq);
index fc4a992..6bf8562 100644 (file)
@@ -98,7 +98,7 @@ static ex lgamma_series(const ex & arg,
        // from which follows
        //   series(lgamma(x),x==-m,order) ==
        //   series(lgamma(x+m+1)-log(x)...-log(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 of tgamma(-m):
@@ -194,7 +194,7 @@ static ex tgamma_series(const ex & arg,
        // from which follows
        //   series(tgamma(x),x==-m,order) ==
        //   series(tgamma(x+m+1)/(x*(x+1)*...*(x+m)),x==-m,order+1);
-       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:
@@ -294,8 +294,8 @@ static ex beta_series(const ex & arg1,
        // Taylor series where there is no pole of one of the tgamma functions
        // falls back to beta function evaluation.  Otherwise, fall back to
        // tgamma series directly.
-       const ex arg1_pt = arg1.subs(rel);
-       const ex arg2_pt = arg2.subs(rel);
+       const ex arg1_pt = arg1.subs(rel, subs_options::no_pattern);
+       const ex arg2_pt = arg2.subs(rel, subs_options::no_pattern);
        GINAC_ASSERT(is_a<symbol>(rel.lhs()));
        const symbol &s = ex_to<symbol>(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:
index 79d7cd4..239b1ea 100644 (file)
@@ -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<symbol>(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<symbol>(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<symbol>(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;
index cdb875d..4828bb9 100644 (file)
@@ -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;
 }
index 3a8a82f..8e2ec00 100644 (file)
@@ -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<fail>(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;
index 22d7b77..48dfa1e 100644 (file)
@@ -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<symbol>(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)?
index a0a2af1..504a9fc 100644 (file)
@@ -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<num; i++)
                        new_lst.append(orig_lst.op(iv[i]));
-               ex term = e.subs(orig_lst, new_lst);
+               ex term = e.subs(orig_lst, new_lst, subs_options::no_pattern);
                if (asymmetric) {
                        memcpy(iv2, iv, num * sizeof(unsigned));
                        term *= permutation_sign(iv2, iv2 + num);
@@ -404,7 +404,7 @@ ex symmetrize_cyclic(const ex & e, exvector::const_iterator first, exvector::con
        for (unsigned i=0; i<num-1; i++) {
                ex perm = new_lst.op(0);
                new_lst.remove_first().append(perm);
-               sum += e.subs(orig_lst, new_lst);
+               sum += e.subs(orig_lst, new_lst, subs_options::no_pattern);
        }
        return sum / num;
 }
index f8e5635..302c0f6 100644 (file)
@@ -174,7 +174,7 @@ ex tensdelta::eval_indexed(const basic & i) const
                exmap m;
                m[i1] = i1.replace_dim(min_dim);
                m[i2] = i2.replace_dim(min_dim);
-               return i.subs(m);
+               return i.subs(m, subs_options::no_pattern);
        }
 
        // Trace of delta tensor is the (effective) dimension of the space
@@ -218,7 +218,7 @@ ex tensmetric::eval_indexed(const basic & i) const
                exmap m;
                m[i1] = i1.replace_dim(min_dim);
                m[i2] = i2.replace_dim(min_dim);
-               return i.subs(m);
+               return i.subs(m, subs_options::no_pattern);
        }
 
        // A metric tensor with one covariant and one contravariant index gets