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);
next_sym: ;
}
}
- return aux.subs(srl).simplify_indexed();
+ return aux.subs(srl, subs_options::no_pattern).simplify_indexed();
}
} // namespace GiNaC
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);
}
}
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();
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();
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))
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)))
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()) {
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));
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));
// 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);
// 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):
// 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:
// 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;
// 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:
// 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:
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;
}
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));
// 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
// 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)
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;
// 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
// 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)
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;
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;
}
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);
// 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
// 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;
}
// 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;
}
// 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);
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
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
if (repl.empty())
return e;
else
- return e.subs(repl);
+ return e.subs(repl, subs_options::no_pattern);
}
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;
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())
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));
}
// 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;
}
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)?
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);
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;
}
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
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