#include "lst.h"
#include "matrix.h"
#include "mul.h"
-#include "ncmul.h"
-#include "numeric.h"
#include "power.h"
#include "relational.h"
#include "pseries.h"
TYPECHECK(arg,numeric)
END_TYPECHECK(abs(arg))
- return abs(ex_to_numeric(arg));
+ return abs(ex_to<numeric>(arg));
}
static ex abs_eval(const ex & arg)
{
if (is_ex_exactly_of_type(arg, numeric))
- return abs(ex_to_numeric(arg));
+ return abs(ex_to<numeric>(arg));
else
return abs(arg).hold();
}
TYPECHECK(arg,numeric)
END_TYPECHECK(csgn(arg))
- return csgn(ex_to_numeric(arg));
+ return csgn(ex_to<numeric>(arg));
}
static ex csgn_eval(const ex & arg)
{
if (is_ex_exactly_of_type(arg, numeric))
- return csgn(ex_to_numeric(arg));
+ return csgn(ex_to<numeric>(arg));
else if (is_ex_of_type(arg, mul) &&
is_ex_of_type(arg.op(arg.nops()-1),numeric)) {
- numeric oc = ex_to_numeric(arg.op(arg.nops()-1));
+ numeric oc = ex_to<numeric>(arg.op(arg.nops()-1));
if (oc.is_real()) {
if (oc > 0)
// csgn(42*x) -> csgn(x)
{
const ex arg_pt = arg.subs(rel);
if (arg_pt.info(info_flags::numeric)
- && ex_to_numeric(arg_pt).real().is_zero()
+ && ex_to<numeric>(arg_pt).real().is_zero()
&& !(options & series_options::suppress_branchcut))
throw (std::domain_error("csgn_series(): on imaginary axis"));
TYPECHECK(y,numeric)
END_TYPECHECK(eta(x,y))
- numeric xim = imag(ex_to_numeric(x));
- numeric yim = imag(ex_to_numeric(y));
- numeric xyim = imag(ex_to_numeric(x*y));
+ numeric xim = imag(ex_to<numeric>(x));
+ numeric yim = imag(ex_to<numeric>(y));
+ numeric xyim = imag(ex_to<numeric>(x*y));
return evalf(I/4*Pi)*((csgn(-xim)+1)*(csgn(-yim)+1)*(csgn(xyim)+1)-(csgn(xim)+1)*(csgn(yim)+1)*(csgn(-xyim)+1));
}
if (is_ex_exactly_of_type(x, numeric) &&
is_ex_exactly_of_type(y, numeric)) {
// don't call eta_evalf here because it would call Pi.evalf()!
- numeric xim = imag(ex_to_numeric(x));
- numeric yim = imag(ex_to_numeric(y));
- numeric xyim = imag(ex_to_numeric(x*y));
+ numeric xim = imag(ex_to<numeric>(x));
+ numeric yim = imag(ex_to<numeric>(y));
+ numeric xyim = imag(ex_to<numeric>(x*y));
return (I/4)*Pi*((csgn(-xim)+1)*(csgn(-yim)+1)*(csgn(xyim)+1)-(csgn(xim)+1)*(csgn(yim)+1)*(csgn(-xyim)+1));
}
{
const ex arg1_pt = arg1.subs(rel);
const ex arg2_pt = arg2.subs(rel);
- if (ex_to_numeric(arg1_pt).imag().is_zero() ||
- ex_to_numeric(arg2_pt).imag().is_zero() ||
- ex_to_numeric(arg1_pt*arg2_pt).imag().is_zero()) {
+ if (ex_to<numeric>(arg1_pt).imag().is_zero() ||
+ ex_to<numeric>(arg2_pt).imag().is_zero() ||
+ ex_to<numeric>(arg1_pt*arg2_pt).imag().is_zero()) {
throw (std::domain_error("eta_series(): on discontinuity"));
}
epvector seq;
TYPECHECK(x,numeric)
END_TYPECHECK(Li2(x))
- return Li2(ex_to_numeric(x)); // -> numeric Li2(numeric)
+ return Li2(ex_to<numeric>(x)); // -> numeric Li2(numeric)
}
static ex Li2_eval(const ex & x)
}
// third special case: x real, >=1 (branch cut)
if (!(options & series_options::suppress_branchcut) &&
- ex_to_numeric(x_pt).is_real() && ex_to_numeric(x_pt)>1) {
+ ex_to<numeric>(x_pt).is_real() && ex_to<numeric>(x_pt)>1) {
// method:
// This is the branch cut: assemble the primitive series manually
// and then add the corresponding complex step function.
static ex factorial_eval(const ex & x)
{
if (is_ex_exactly_of_type(x, numeric))
- return factorial(ex_to_numeric(x));
+ return factorial(ex_to<numeric>(x));
else
return factorial(x).hold();
}
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))
- return binomial(ex_to_numeric(x), ex_to_numeric(y));
+ return binomial(ex_to<numeric>(x), ex_to<numeric>(y));
else
return binomial(x, y).hold();
}
ex eq = eqns.op(r).op(0)-eqns.op(r).op(1); // lhs-rhs==0
ex linpart = eq;
for (unsigned c=0; c<symbols.nops(); c++) {
- ex co = eq.coeff(ex_to_symbol(symbols.op(c)),1);
+ ex co = eq.coeff(ex_to<symbol>(symbols.op(c)),1);
linpart -= co*symbols.op(c);
sys(r,c) = co;
}
return sollist;
}
-// Symmetrize/antisymmetrize over a vector of objects
-static ex symm(const ex & e, exvector::const_iterator first, exvector::const_iterator last, bool asymmetric)
-{
- // Need at least 2 objects for this operation
- int num = last - first;
- if (num < 2)
- return e;
-
- // Transform object vector to a list
- exlist iv_lst;
- iv_lst.insert(iv_lst.begin(), first, last);
- lst orig_lst(iv_lst, true);
-
- // Create index vectors for permutation
- unsigned *iv = new unsigned[num], *iv2;
- for (unsigned i=0; i<num; i++)
- iv[i] = i;
- iv2 = (asymmetric ? new unsigned[num] : NULL);
-
- // Loop over all permutations (the first permutation, which is the
- // identity, is unrolled)
- ex sum = e;
- while (std::next_permutation(iv, iv + num)) {
- 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);
- if (asymmetric) {
- memcpy(iv2, iv, num * sizeof(unsigned));
- term *= permutation_sign(iv2, iv2 + num);
- }
- sum += term;
- }
-
- delete[] iv;
- delete[] iv2;
-
- return sum / factorial(numeric(num));
-}
-
-ex symmetrize(const ex & e, exvector::const_iterator first, exvector::const_iterator last)
-{
- return symm(e, first, last, false);
-}
-
-ex antisymmetrize(const ex & e, exvector::const_iterator first, exvector::const_iterator last)
-{
- return symm(e, first, last, true);
-}
-
-ex symmetrize_cyclic(const ex & e, exvector::const_iterator first, exvector::const_iterator last)
-{
- // Need at least 2 objects for this operation
- int num = last - first;
- if (num < 2)
- return e;
-
- // Transform object vector to a list
- exlist iv_lst;
- iv_lst.insert(iv_lst.begin(), first, last);
- lst orig_lst(iv_lst, true);
- lst new_lst = orig_lst;
-
- // Loop over all cyclic permutations (the first permutation, which is
- // the identity, is unrolled)
- ex sum = e;
- 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);
- }
- return sum / num;
-}
-
-/** Symmetrize expression over a list of objects (symbols, indices). */
-ex ex::symmetrize(const lst & l) const
-{
- exvector v;
- v.reserve(l.nops());
- for (unsigned i=0; i<l.nops(); i++)
- v.push_back(l.op(i));
- return symm(*this, v.begin(), v.end(), false);
-}
-
-/** Antisymmetrize expression over a list of objects (symbols, indices). */
-ex ex::antisymmetrize(const lst & l) const
-{
- exvector v;
- v.reserve(l.nops());
- for (unsigned i=0; i<l.nops(); i++)
- v.push_back(l.op(i));
- return symm(*this, v.begin(), v.end(), true);
-}
-
-/** Symmetrize expression by cyclic permutation over a list of objects
- * (symbols, indices). */
-ex ex::symmetrize_cyclic(const lst & l) const
-{
- exvector v;
- v.reserve(l.nops());
- for (unsigned i=0; i<l.nops(); i++)
- v.push_back(l.op(i));
- return GiNaC::symmetrize_cyclic(*this, v.begin(), v.end());
-}
-
-/** Force inclusion of functions from initcns_gamma and inifcns_zeta
- * for static lib (so ginsh will see them). */
+/* Force inclusion of functions from inifcns_gamma and inifcns_zeta
+ * for static lib (so ginsh will see them). */
unsigned force_include_tgamma = function_index_tgamma;
unsigned force_include_zeta1 = function_index_zeta1;