resulting in a general speed-up.
Wherever thou hast written _ex7() thou shalt write _ex7 from now on.
This file records noteworthy changes.
+0.9.5 (<date>)
+* Some internal reorganization resulting in a general speed-up.
+
0.9.4 (20 September 2001)
* Functions have better support for external scripting languages.
* Interface cleanups and bugfixes.
{
debugmsg("add constructor from ex,ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
- overall_coeff = _ex0();
+ overall_coeff = _ex0;
construct_from_2_ex(lh,rh);
GINAC_ASSERT(is_canonical());
}
{
debugmsg("add constructor from exvector",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
- overall_coeff = _ex0();
+ overall_coeff = _ex0;
construct_from_exvector(v);
GINAC_ASSERT(is_canonical());
}
{
debugmsg("add constructor from epvector",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_add;
- overall_coeff = _ex0();
+ overall_coeff = _ex0;
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
}
while (it != itend) {
// If the coefficient is -1, it is replaced by a single minus sign
- if (it->coeff.compare(_num1()) == 0) {
+ if (it->coeff.compare(_num1) == 0) {
it->rest.print(c, precedence());
- } else if (it->coeff.compare(_num_1()) == 0) {
+ } else if (it->coeff.compare(_num_1) == 0) {
c.s << "-";
it->rest.print(c, precedence());
- } else if (ex_to<numeric>(it->coeff).numer().compare(_num1()) == 0) {
+ } else if (ex_to<numeric>(it->coeff).numer().compare(_num1) == 0) {
it->rest.print(c, precedence());
c.s << "/";
ex_to<numeric>(it->coeff).denom().print(c, precedence());
- } else if (ex_to<numeric>(it->coeff).numer().compare(_num_1()) == 0) {
+ } else if (ex_to<numeric>(it->coeff).numer().compare(_num_1) == 0) {
c.s << "-";
it->rest.print(c, precedence());
c.s << "/";
// Separator is "+", except if the following expression would have a leading minus sign
++it;
- if (it != itend && !(it->coeff.compare(_num0()) < 0 || (it->coeff.compare(_num1()) == 0 && is_exactly_a<numeric>(it->rest) && it->rest.compare(_num0()) < 0)))
+ if (it != itend && !(it->coeff.compare(_num0) < 0 || (it->coeff.compare(_num1) == 0 && is_exactly_a<numeric>(it->rest) && it->rest.compare(_num0) < 0)))
c.s << "+";
}
if (coeff.csgn() == -1) c.s << '-';
first = false;
}
- if (!coeff.is_equal(_num1()) &&
- !coeff.is_equal(_num_1())) {
+ if (!coeff.is_equal(_num1) &&
+ !coeff.is_equal(_num_1)) {
if (coeff.is_rational()) {
if (coeff.is_negative())
(-coeff).print(c);
++i;
}
- return (new add(coeffseq, n==0 ? overall_coeff : _ex0()))->setflag(status_flags::dynallocated);
+ return (new add(coeffseq, n==0 ? overall_coeff : _ex0))->setflag(status_flags::dynallocated);
}
/** Perform automatic term rewriting rules in this class. In the following
s->push_back(combine_ex_with_coeff_to_pair(i->rest.diff(y), i->coeff));
++i;
}
- return (new add(s, _ex0()))->setflag(status_flags::dynallocated);
+ return (new add(s, _ex0))->setflag(status_flags::dynallocated);
}
int add::compare_same_type(const basic & other) const
const mul &mulref(ex_to<mul>(e));
ex numfactor = mulref.overall_coeff;
mul *mulcopyp = new mul(mulref);
- mulcopyp->overall_coeff = _ex1();
+ mulcopyp->overall_coeff = _ex1;
mulcopyp->clearflag(status_flags::evaluated);
mulcopyp->clearflag(status_flags::hash_calculated);
mulcopyp->setflag(status_flags::dynallocated);
return expair(*mulcopyp,numfactor);
}
- return expair(e,_ex1());
+ return expair(e,_ex1);
}
expair add::combine_ex_with_coeff_to_pair(const ex & e,
const mul &mulref(ex_to<mul>(e));
ex numfactor = mulref.overall_coeff;
mul *mulcopyp = new mul(mulref);
- mulcopyp->overall_coeff = _ex1();
+ mulcopyp->overall_coeff = _ex1;
mulcopyp->clearflag(status_flags::evaluated);
mulcopyp->clearflag(status_flags::hash_calculated);
mulcopyp->setflag(status_flags::dynallocated);
- if (are_ex_trivially_equal(c, _ex1()))
+ if (are_ex_trivially_equal(c, _ex1))
return expair(*mulcopyp, numfactor);
- else if (are_ex_trivially_equal(numfactor, _ex1()))
+ else if (are_ex_trivially_equal(numfactor, _ex1))
return expair(*mulcopyp, c);
else
return expair(*mulcopyp, ex_to<numeric>(numfactor).mul_dyn(ex_to<numeric>(c)));
} else if (is_ex_exactly_of_type(e, numeric)) {
- if (are_ex_trivially_equal(c, _ex1()))
- return expair(e, _ex1());
- return expair(ex_to<numeric>(e).mul_dyn(ex_to<numeric>(c)), _ex1());
+ if (are_ex_trivially_equal(c, _ex1))
+ return expair(e, _ex1);
+ return expair(ex_to<numeric>(e).mul_dyn(ex_to<numeric>(c)), _ex1);
}
return expair(e, c);
}
GINAC_ASSERT(is_exactly_a<numeric>(c));
if (is_ex_exactly_of_type(p.rest,numeric)) {
- GINAC_ASSERT(ex_to<numeric>(p.coeff).is_equal(_num1())); // should be normalized
- return expair(ex_to<numeric>(p.rest).mul_dyn(ex_to<numeric>(c)),_ex1());
+ GINAC_ASSERT(ex_to<numeric>(p.coeff).is_equal(_num1)); // should be normalized
+ return expair(ex_to<numeric>(p.rest).mul_dyn(ex_to<numeric>(c)),_ex1);
}
return expair(p.rest,ex_to<numeric>(p.coeff).mul_dyn(ex_to<numeric>(c)));
ex add::recombine_pair_to_ex(const expair & p) const
{
- if (ex_to<numeric>(p.coeff).is_equal(_num1()))
+ if (ex_to<numeric>(p.coeff).is_equal(_num1))
return p.rest;
else
return p.rest*p.coeff;
/** Return coefficient of degree n in object s. */
ex basic::coeff(const ex & s, int n) const
{
- return n==0 ? *this : _ex0();
+ return n==0 ? *this : _ex0;
}
/** Sort expanded expression in terms of powers of some object(s).
while (true) {
// Calculate coeff*x1^c1*...*xn^cn
- ex y = _ex1();
+ ex y = _ex1;
for (int i=0; i<num; i++) {
int cnt = si[i].cnt;
y *= power(si[i].sym, cnt);
ex basic::derivative(const symbol & s) const
{
if (nops() == 0)
- return _ex0();
+ return _ex0;
else {
derivative_map_function map_derivative(s);
return map(map_derivative);
if (is_a<diracgamma>(c.op(0))) { // proper dirac gamma object
i = c.op(1);
- b = _ex1();
+ b = _ex1;
} else { // slash object, generate new dummy index
varidx ix((new symbol)->setflag(status_flags::dynallocated), ex_to<idx>(c.op(1)).get_dim());
b = indexed(c.op(0), ix.toggle_variance());
} else if (other - self == 2
&& is_a<clifford>(self[1])) {
*self = 2 - dim;
- *other = _ex1();
+ *other = _ex1;
return true;
// gamma~mu gamma~alpha gamma~beta gamma.mu = 4 g~alpha~beta + (dim-4) gamam~alpha gamma~beta
base_and_index(self[1], b1, i1);
base_and_index(self[2], b2, i2);
*self = 4 * lorentz_g(i1, i2) * b1 * b2 * dirac_ONE(rl) + (dim - 4) * self[1] * self[2];
- self[1] = _ex1();
- self[2] = _ex1();
- *other = _ex1();
+ self[1] = _ex1;
+ self[2] = _ex1;
+ *other = _ex1;
return true;
// gamma~mu gamma~alpha gamma~beta gamma~delta gamma.mu = -2 gamma~delta gamma~beta gamma~alpha - (dim-4) gamam~alpha gamma~beta gamma~delta
&& is_a<clifford>(self[2])
&& is_a<clifford>(self[3])) {
*self = -2 * self[3] * self[2] * self[1] - (dim - 4) * self[1] * self[2] * self[3];
- self[1] = _ex1();
- self[2] = _ex1();
- self[3] = _ex1();
- *other = _ex1();
+ self[1] = _ex1;
+ self[2] = _ex1;
+ self[3] = _ex1;
+ *other = _ex1;
return true;
// gamma~mu S gamma~alpha gamma.mu = 2 gamma~alpha S - gamma~mu S gamma.mu gamma~alpha
}
it = self + 1;
- ex S = _ex1();
+ ex S = _ex1;
while (it != next_to_last) {
S *= *it;
- *it++ = _ex1();
+ *it++ = _ex1;
}
*self = 2 * (*next_to_last) * S - (*self) * S * (*other) * (*next_to_last);
- *next_to_last = _ex1();
- *other = _ex1();
+ *next_to_last = _ex1;
+ *other = _ex1;
return true;
}
}
&& is_a<diracone>(e.op(0)))
return trONE;
else
- return _ex0();
+ return _ex0;
} else if (is_ex_exactly_of_type(e, mul)) {
// Trace of product: pull out non-clifford factors
- ex prod = _ex1();
+ ex prod = _ex1;
for (unsigned i=0; i<e.nops(); i++) {
const ex &o = e.op(i);
if (is_clifford_tinfo(o.return_type_tinfo(), rl))
} else if (is_ex_exactly_of_type(e, ncmul)) {
if (!is_clifford_tinfo(e.return_type_tinfo(), rl))
- return _ex0();
+ return _ex0;
// Expand product, if necessary
ex e_expanded = e.expand();
// Trace of gamma5 * odd number of gammas and trace of
// gamma5 * gamma.mu * gamma.nu are zero
if ((num & 1) == 0 || num == 3)
- return _ex0();
+ return _ex0;
// Tr gamma5 gamma.mu gamma.nu gamma.rho gamma.sigma = 4I * epsilon(mu, nu, rho, sigma)
if (num == 5) {
// Trace of odd number of gammas is zero
if ((num & 1) == 1)
- return _ex0();
+ return _ex0;
// Tr gamma.mu gamma.nu = 4 g.mu.nu
if (num == 2) {
return e.map(fcn);
} else
- return _ex0();
+ return _ex0;
}
ex canonicalize_clifford(const ex & e)
base_and_index(it[0], b1, i1);
base_and_index(it[1], b2, i2);
it[0] = (lorentz_g(i1, i2) * b1 * b2).simplify_indexed();
- it[1] = _ex2();
+ it[1] = _ex2;
ex sum = ncmul(v);
it[0] = save1;
it[1] = save0;
// Convolutions are zero
if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
- return _ex0();
+ return _ex0;
// Numeric evaluation
if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
// Check for non-zero elements
if (CMPINDICES(1,4,6) || CMPINDICES(1,5,7) || CMPINDICES(2,5,6)
|| CMPINDICES(3,4,4) || CMPINDICES(3,5,5))
- return _ex1_2();
+ return _ex1_2;
else if (CMPINDICES(2,4,7) || CMPINDICES(3,6,6) || CMPINDICES(3,7,7))
- return _ex_1_2();
+ return _ex_1_2;
else if (CMPINDICES(1,1,8) || CMPINDICES(2,2,8) || CMPINDICES(3,3,8))
- return sqrt(_ex3())/3;
+ return sqrt(_ex3)*_ex1_3;
else if (CMPINDICES(8,8,8))
- return -sqrt(_ex3())/3;
+ return sqrt(_ex3)*_ex_1_3;
else if (CMPINDICES(4,4,8) || CMPINDICES(5,5,8)
|| CMPINDICES(6,6,8) || CMPINDICES(7,7,8))
- return -sqrt(_ex3())/6;
+ return sqrt(_ex3)/_ex_6;
else
- return _ex0();
+ return _ex0;
}
// No further simplifications
return sign;
else if (CMPINDICES(1,4,7) || CMPINDICES(2,4,6)
|| CMPINDICES(2,5,7) || CMPINDICES(3,4,5))
- return _ex1_2() * sign;
+ return _ex1_2 * sign;
else if (CMPINDICES(1,5,6) || CMPINDICES(3,6,7))
- return _ex_1_2() * sign;
+ return _ex_1_2 * sign;
else if (CMPINDICES(4,5,8) || CMPINDICES(6,7,8))
- return sqrt(_ex3())/2 * sign;
+ return sqrt(_ex3)/2 * sign;
else
- return _ex0();
+ return _ex0;
}
// No further simplifications
} else if (other - self == 2
&& is_ex_of_type(self[1], color)) {
*self = numeric(-1, 6);
- *other = _ex1();
+ *other = _ex1;
return true;
// T.a S T.a = 1/2 Tr(S) - 1/6 S
}
it = self + 1;
- ex S = _ex1();
+ ex S = _ex1;
while (it != other) {
S *= *it;
- *it++ = _ex1();
+ *it++ = _ex1;
}
*self = color_trace(S, rl) * color_ONE(rl) / 2 - S / 6;
- *other = _ex1();
+ *other = _ex1;
return true;
}
}
// d.abc d.abc = 40/3
if (dummy_indices.size() == 3) {
*self = numeric(40, 3);
- *other = _ex1();
+ *other = _ex1;
return true;
// d.akl d.bkl = 5/3 delta.ab
ita = set_difference(other_indices.begin(), other_indices.end(), dummy_indices.begin(), dummy_indices.end(), ita, ex_is_less());
GINAC_ASSERT(a.size() == 2);
*self = numeric(5, 3) * delta_tensor(a[0], a[1]);
- *other = _ex1();
+ *other = _ex1;
return true;
}
ex a = permute_free_index_to_front(self_indices, dummy_indices, sig);
*self = numeric(5, 6);
other[0] = color_T(a, ex_to<color>(other[0]).get_representation_label());
- other[1] = _ex1();
+ other[1] = _ex1;
return true;
}
}
// f.abc f.abc = 24
if (dummy_indices.size() == 3) {
*self = 24;
- *other = _ex1();
+ *other = _ex1;
return true;
// f.akl f.bkl = 3 delta.ab
ex a = permute_free_index_to_front(ex_to<indexed>(*self).get_indices(), dummy_indices, sign1);
ex b = permute_free_index_to_front(ex_to<indexed>(*other).get_indices(), dummy_indices, sign2);
*self = sign1 * sign2 * 3 * delta_tensor(a, b);
- *other = _ex1();
+ *other = _ex1;
return true;
}
ex a = permute_free_index_to_front(self_indices, dummy_indices, sig);
*self = numeric(3, 2) * sig * I;
other[0] = color_T(a, ex_to<color>(other[0]).get_representation_label());
- other[1] = _ex1();
+ other[1] = _ex1;
return true;
}
}
if (ex_to<color>(e).get_representation_label() == rl
&& is_ex_of_type(e.op(0), su3one))
- return _ex3();
+ return _ex3;
else
- return _ex0();
+ return _ex0;
} else if (is_ex_exactly_of_type(e, mul)) {
// Trace of product: pull out non-color factors
- ex prod = _ex1();
+ ex prod = _ex1;
for (unsigned i=0; i<e.nops(); i++) {
const ex &o = e.op(i);
if (is_color_tinfo(o.return_type_tinfo(), rl))
} else if (is_ex_exactly_of_type(e, ncmul)) {
if (!is_color_tinfo(e.return_type_tinfo(), rl))
- return _ex0();
+ return _ex0;
// Expand product, if necessary
ex e_expanded = e.expand();
return e.map(fcn);
} else
- return _ex0();
+ return _ex0;
}
} // namespace GiNaC
ex constant::coeff(const ex & s, int n) const
{
if (is_equal(ex_to<basic>(s)))
- return n==1 ? _ex1() : _ex0();
+ return n==1 ? _ex1 : _ex0;
else
- return n==0 ? *this : _ex0();
+ return n==0 ? *this : _ex0;
}
ex constant::evalf(int level) const
* @see ex::diff */
ex constant::derivative(const symbol & s) const
{
- return _ex0();
+ return _ex0;
}
int constant::compare_same_type(const basic & other) const
//////////
// public
-
+
/** Efficiently swap the contents of two expressions. */
void ex::swap(ex & other)
{
void ex::construct_from_int(int i)
{
- switch (i) { // some tiny efficiency-hack
+ switch (i) { // prefer flyweights over new objects
+ case -12:
+ bp = (basic*)_num_12_p;
+ ++bp->refcount;
+ break;
+ case -11:
+ bp = (basic*)_num_11_p;
+ ++bp->refcount;
+ break;
+ case -10:
+ bp = (basic*)_num_10_p;
+ ++bp->refcount;
+ break;
+ case -9:
+ bp = (basic*)_num_9_p;
+ ++bp->refcount;
+ break;
+ case -8:
+ bp = (basic*)_num_8_p;
+ ++bp->refcount;
+ break;
+ case -7:
+ bp = (basic*)_num_7_p;
+ ++bp->refcount;
+ break;
+ case -6:
+ bp = (basic*)_num_6_p;
+ ++bp->refcount;
+ break;
+ case -5:
+ bp = (basic*)_num_5_p;
+ ++bp->refcount;
+ break;
+ case -4:
+ bp = (basic*)_num_4_p;
+ ++bp->refcount;
+ break;
+ case -3:
+ bp = (basic*)_num_3_p;
+ ++bp->refcount;
+ break;
case -2:
- bp = _ex_2().bp;
+ bp = (basic*)_num_2_p;
++bp->refcount;
break;
case -1:
- bp = _ex_1().bp;
+ bp = (basic*)_num_1_p;
++bp->refcount;
break;
case 0:
- bp = _ex0().bp;
+ bp = (basic*)_num0_p;
++bp->refcount;
break;
case 1:
- bp = _ex1().bp;
+ bp = (basic*)_num1_p;
++bp->refcount;
break;
case 2:
- bp = _ex2().bp;
+ bp = (basic*)_num2_p;
+ ++bp->refcount;
+ break;
+ case 3:
+ bp = (basic*)_num3_p;
+ ++bp->refcount;
+ break;
+ case 4:
+ bp = (basic*)_num4_p;
+ ++bp->refcount;
+ break;
+ case 5:
+ bp = (basic*)_num5_p;
+ ++bp->refcount;
+ break;
+ case 6:
+ bp = (basic*)_num6_p;
+ ++bp->refcount;
+ break;
+ case 7:
+ bp = (basic*)_num7_p;
+ ++bp->refcount;
+ break;
+ case 8:
+ bp = (basic*)_num8_p;
+ ++bp->refcount;
+ break;
+ case 9:
+ bp = (basic*)_num9_p;
+ ++bp->refcount;
+ break;
+ case 10:
+ bp = (basic*)_num10_p;
+ ++bp->refcount;
+ break;
+ case 11:
+ bp = (basic*)_num11_p;
+ ++bp->refcount;
+ break;
+ case 12:
+ bp = (basic*)_num12_p;
++bp->refcount;
break;
default:
void ex::construct_from_uint(unsigned int i)
{
- switch (i) { // some tiny efficiency-hack
+ switch (i) { // prefer flyweights over new objects
case 0:
- bp = _ex0().bp;
+ bp = (basic*)_num0_p;
++bp->refcount;
break;
case 1:
- bp = _ex1().bp;
+ bp = (basic*)_num1_p;
++bp->refcount;
break;
case 2:
- bp = _ex2().bp;
+ bp = (basic*)_num2_p;
+ ++bp->refcount;
+ break;
+ case 3:
+ bp = (basic*)_num3_p;
+ ++bp->refcount;
+ break;
+ case 4:
+ bp = (basic*)_num4_p;
+ ++bp->refcount;
+ break;
+ case 5:
+ bp = (basic*)_num5_p;
+ ++bp->refcount;
+ break;
+ case 6:
+ bp = (basic*)_num6_p;
+ ++bp->refcount;
+ break;
+ case 7:
+ bp = (basic*)_num7_p;
+ ++bp->refcount;
+ break;
+ case 8:
+ bp = (basic*)_num8_p;
+ ++bp->refcount;
+ break;
+ case 9:
+ bp = (basic*)_num9_p;
+ ++bp->refcount;
+ break;
+ case 10:
+ bp = (basic*)_num10_p;
+ ++bp->refcount;
+ break;
+ case 11:
+ bp = (basic*)_num11_p;
+ ++bp->refcount;
+ break;
+ case 12:
+ bp = (basic*)_num12_p;
++bp->refcount;
break;
default:
void ex::construct_from_long(long i)
{
- switch (i) { // some tiny efficiency-hack
+ switch (i) { // prefer flyweights over new objects
+ case -12:
+ bp = (basic*)_num_12_p;
+ ++bp->refcount;
+ break;
+ case -11:
+ bp = (basic*)_num_11_p;
+ ++bp->refcount;
+ break;
+ case -10:
+ bp = (basic*)_num_10_p;
+ ++bp->refcount;
+ break;
+ case -9:
+ bp = (basic*)_num_9_p;
+ ++bp->refcount;
+ break;
+ case -8:
+ bp = (basic*)_num_8_p;
+ ++bp->refcount;
+ break;
+ case -7:
+ bp = (basic*)_num_7_p;
+ ++bp->refcount;
+ break;
+ case -6:
+ bp = (basic*)_num_6_p;
+ ++bp->refcount;
+ break;
+ case -5:
+ bp = (basic*)_num_5_p;
+ ++bp->refcount;
+ break;
+ case -4:
+ bp = (basic*)_num_4_p;
+ ++bp->refcount;
+ break;
+ case -3:
+ bp = (basic*)_num_3_p;
+ ++bp->refcount;
+ break;
case -2:
- bp = _ex_2().bp;
+ bp = (basic*)_num_2_p;
++bp->refcount;
break;
case -1:
- bp = _ex_1().bp;
+ bp = (basic*)_num_1_p;
++bp->refcount;
break;
case 0:
- bp = _ex0().bp;
+ bp = (basic*)_num0_p;
++bp->refcount;
break;
case 1:
- bp = _ex1().bp;
+ bp = (basic*)_num1_p;
++bp->refcount;
break;
case 2:
- bp = _ex2().bp;
+ bp = (basic*)_num2_p;
+ ++bp->refcount;
+ break;
+ case 3:
+ bp = (basic*)_num3_p;
+ ++bp->refcount;
+ break;
+ case 4:
+ bp = (basic*)_num4_p;
+ ++bp->refcount;
+ break;
+ case 5:
+ bp = (basic*)_num5_p;
+ ++bp->refcount;
+ break;
+ case 6:
+ bp = (basic*)_num6_p;
+ ++bp->refcount;
+ break;
+ case 7:
+ bp = (basic*)_num7_p;
+ ++bp->refcount;
+ break;
+ case 8:
+ bp = (basic*)_num8_p;
+ ++bp->refcount;
+ break;
+ case 9:
+ bp = (basic*)_num9_p;
+ ++bp->refcount;
+ break;
+ case 10:
+ bp = (basic*)_num10_p;
+ ++bp->refcount;
+ break;
+ case 11:
+ bp = (basic*)_num11_p;
+ ++bp->refcount;
+ break;
+ case 12:
+ bp = (basic*)_num12_p;
++bp->refcount;
break;
default:
void ex::construct_from_ulong(unsigned long i)
{
- switch (i) { // some tiny efficiency-hack
+ switch (i) { // prefer flyweights over new objects
case 0:
- bp = _ex0().bp;
+ bp = (basic*)_num0_p;
++bp->refcount;
break;
case 1:
- bp = _ex1().bp;
+ bp = (basic*)_num1_p;
++bp->refcount;
break;
case 2:
- bp = _ex2().bp;
+ bp = (basic*)_num2_p;
+ ++bp->refcount;
+ break;
+ case 3:
+ bp = (basic*)_num3_p;
+ ++bp->refcount;
+ break;
+ case 4:
+ bp = (basic*)_num4_p;
+ ++bp->refcount;
+ break;
+ case 5:
+ bp = (basic*)_num5_p;
+ ++bp->refcount;
+ break;
+ case 6:
+ bp = (basic*)_num6_p;
+ ++bp->refcount;
+ break;
+ case 7:
+ bp = (basic*)_num7_p;
+ ++bp->refcount;
+ break;
+ case 8:
+ bp = (basic*)_num8_p;
+ ++bp->refcount;
+ break;
+ case 9:
+ bp = (basic*)_num9_p;
+ ++bp->refcount;
+ break;
+ case 10:
+ bp = (basic*)_num10_p;
+ ++bp->refcount;
+ break;
+ case 11:
+ bp = (basic*)_num11_p;
+ ++bp->refcount;
+ break;
+ case 12:
+ bp = (basic*)_num12_p;
++bp->refcount;
break;
default:
namespace GiNaC {
-// Sorry, this is the only constant to pollute the global scope, the other ones
-// are defined in utils.h and not visible from outside.
-class ex;
-extern const ex & _ex0(void); ///< single ex(numeric(0))
+/** Helper class to initialize the library. There must be one static object
+ * of this class in every object file that makes use of our flyweights in
+ * order to guarantee proper initialization. Hence we put it into this
+ * file which is included by every relevant file anyways. This is modeled
+ * after section 27.4.2.1.6 of the C++ standard, where cout and friends are
+ * set up.
+ *
+ * @see utils.cpp */
+class library_init {
+public:
+ library_init();
+ ~library_init();
+private:
+ static int count;
+};
+/** For construction of flyweights, etc. */
+static library_init library_initializer;
+
+// Current versions of Cint don't link data declared extern within functions.
+// FIXME: Fix Cint and later remove this from here.
+#if defined(G__CINTVERSION)
+extern const class numeric *_num0_p;
+#endif
+
class symbol;
class lst;
ex rhs(void) const;
int compare(const ex & other) const;
bool is_equal(const ex & other) const;
- bool is_zero(void) const { return is_equal(_ex0()); }
+ bool is_zero(void) const { extern const ex _ex0; return is_equal(_ex0); }
unsigned return_type(void) const { return bp->return_type(); }
unsigned return_type_tinfo(void) const { return bp->return_type_tinfo(); }
// performance-critical inlined method implementations
inline
-ex::ex() : bp(_ex0().bp)
+ex::ex()
{
- /*debugmsg("ex default ctor",LOGLEVEL_CONSTRUCT);*/
- GINAC_ASSERT(_ex0().bp!=0);
- GINAC_ASSERT(_ex0().bp->flags & status_flags::dynallocated);
+ /* debugmsg("ex default ctor",LOGLEVEL_CONSTRUCT); */
+ extern const class numeric *_num0_p;
+ bp = (basic*)_num0_p;
GINAC_ASSERT(bp!=0);
+ GINAC_ASSERT(bp->flags & status_flags::dynallocated);
++bp->refcount;
#ifdef OBSCURE_CINT_HACK
update_last_created_or_assigned_bp();
* @see expairseq::recombine_pair_to_ex() */
expair expairseq::split_ex_to_pair(const ex &e) const
{
- return expair(e,_ex1());
+ return expair(e,_ex1);
}
ex expairseq::default_overall_coeff(void) const
{
- return _ex0();
+ return _ex0;
}
void expairseq::combine_overall_coeff(const ex &c)
ex function::coeff(const ex & s, int n) const
{
if (is_equal(ex_to<basic>(s)))
- return n==1 ? _ex1() : _ex0();
+ return n==1 ? _ex1 : _ex0;
else
- return n==0 ? ex(*this) : _ex0();
+ return n==0 ? ex(*this) : _ex0;
}
ex function::eval(int level) const
if (sig != INT_MAX) {
// Something has changed while sorting arguments, more evaluations later
if (sig == 0)
- return _ex0();
+ return _ex0;
return ex(sig) * thisexprseq(v);
}
}
* @see ex::diff */
ex idx::derivative(const symbol & s) const
{
- return _ex0();
+ return _ex0;
}
//////////
// If the base object is 0, the whole object is 0
if (base.is_zero())
- return _ex0();
+ return _ex0;
// If the base object is a product, pull out the numeric factor
if (is_ex_exactly_of_type(base, mul) && is_ex_exactly_of_type(base.op(base.nops() - 1), numeric)) {
if (sig != INT_MAX) {
// Something has changed while sorting indices, more evaluations later
if (sig == 0)
- return _ex0();
+ return _ex0;
return ex(sig) * thisexprseq(v);
}
}
ex indexed::coeff(const ex & s, int n) const
{
if (is_equal(ex_to<basic>(s)))
- return n==1 ? _ex1() : _ex0();
+ return n==1 ? _ex1 : _ex0;
else
- return n==0 ? ex(*this) : _ex0();
+ return n==0 ? ex(*this) : _ex0;
}
ex indexed::thisexprseq(const exvector & v) const
// expand_indexed expands (a+b).i -> a.i + b.i
const ex & base = seq[0];
- ex sum = _ex0();
+ ex sum = _ex0;
for (unsigned i=0; i<base.nops(); i++) {
exvector s = seq;
s[0] = base.op(i);
* @see ex::diff */
ex indexed::derivative(const symbol & s) const
{
- return _ex0();
+ return _ex0;
}
//////////
if (is_ex_exactly_of_type(e, power)) {
// We only get called for simple squares, split a^2 -> a*a
- GINAC_ASSERT(e.op(1).is_equal(_ex2()));
+ GINAC_ASSERT(e.op(1).is_equal(_ex2));
v.push_back(e.op(0));
v.push_back(e.op(0));
} else {
for (unsigned i=0; i<e.nops(); i++) {
ex f = e.op(i);
- if (is_ex_exactly_of_type(f, power) && f.op(1).is_equal(_ex2())) {
+ if (is_ex_exactly_of_type(f, power) && f.op(1).is_equal(_ex2)) {
v.push_back(f.op(0));
v.push_back(f.op(0));
} else if (is_ex_exactly_of_type(f, ncmul)) {
if (free.empty()) {
if (sp.is_defined(*it1, *it2)) {
*it1 = sp.evaluate(*it1, *it2);
- *it2 = _ex1();
+ *it2 = _ex1;
goto contraction_done;
}
}
dummy_syms.append(local_dummy_indices[i].op(0));
if (r.symmetrize(dummy_syms).is_zero()) {
free_indices.clear();
- return _ex0();
+ return _ex0;
}
}
// free indices in each term
if (is_ex_exactly_of_type(e_expanded, add)) {
bool first = true;
- ex sum = _ex0();
+ ex sum = _ex0;
free_indices.clear();
for (unsigned i=0; i<e_expanded.nops(); i++) {
// Simplification of products
if (is_ex_exactly_of_type(e_expanded, mul)
|| is_ex_exactly_of_type(e_expanded, ncmul)
- || (is_ex_exactly_of_type(e_expanded, power) && is_ex_of_type(e_expanded.op(0), indexed) && e_expanded.op(1).is_equal(_ex2())))
+ || (is_ex_exactly_of_type(e_expanded, power) && is_ex_of_type(e_expanded.op(0), indexed) && e_expanded.op(1).is_equal(_ex2)))
return simplify_indexed_product(e_expanded, free_indices, dummy_indices, sp);
// Cannot do anything
throw (std::domain_error("csgn_series(): on imaginary axis"));
epvector seq;
- seq.push_back(expair(csgn(arg_pt), _ex0()));
+ seq.push_back(expair(csgn(arg_pt), _ex0));
return pseries(rel,seq);
}
// It seems like we basically have to replicate the eval function here,
// since the expression might not be fully evaluated yet.
if (x.info(info_flags::positive) || y.info(info_flags::positive))
- return _ex0();
+ return _ex0;
if (x.info(info_flags::numeric) && y.info(info_flags::numeric)) {
const numeric nx = ex_to<numeric>(x);
{
// trivial: eta(x,c) -> 0 if c is real and positive
if (x.info(info_flags::positive) || y.info(info_flags::positive))
- return _ex0();
+ return _ex0;
if (x.info(info_flags::numeric) && y.info(info_flags::numeric)) {
// don't call eta_evalf here because it would call Pi.evalf()!
((x_pt*y_pt).info(info_flags::numeric) && (x_pt*y_pt).info(info_flags::negative)))
throw (std::domain_error("eta_series(): on discontinuity"));
epvector seq;
- seq.push_back(expair(eta(x_pt,y_pt), _ex0()));
+ seq.push_back(expair(eta(x_pt,y_pt), _ex0));
return pseries(rel,seq);
}
if (x.info(info_flags::numeric)) {
// Li2(0) -> 0
if (x.is_zero())
- return _ex0();
+ return _ex0;
// Li2(1) -> Pi^2/6
- if (x.is_equal(_ex1()))
- return power(Pi,_ex2())/_ex6();
+ if (x.is_equal(_ex1))
+ return power(Pi,_ex2)/_ex6;
// Li2(1/2) -> Pi^2/12 - log(2)^2/2
- if (x.is_equal(_ex1_2()))
- return power(Pi,_ex2())/_ex12() + power(log(_ex2()),_ex2())*_ex_1_2();
+ if (x.is_equal(_ex1_2))
+ return power(Pi,_ex2)/_ex12 + power(log(_ex2),_ex2)*_ex_1_2;
// Li2(-1) -> -Pi^2/12
- if (x.is_equal(_ex_1()))
- return -power(Pi,_ex2())/_ex12();
+ if (x.is_equal(_ex_1))
+ return -power(Pi,_ex2)/_ex12;
// Li2(I) -> -Pi^2/48+Catalan*I
if (x.is_equal(I))
- return power(Pi,_ex2())/_ex_48() + Catalan*I;
+ return power(Pi,_ex2)/_ex_48 + Catalan*I;
// Li2(-I) -> -Pi^2/48-Catalan*I
if (x.is_equal(-I))
- return power(Pi,_ex2())/_ex_48() - Catalan*I;
+ return power(Pi,_ex2)/_ex_48 - Catalan*I;
// Li2(float)
if (!x.info(info_flags::crational))
return Li2(ex_to<numeric>(x));
GINAC_ASSERT(deriv_param==0);
// d/dx Li2(x) -> -log(1-x)/x
- return -log(_ex1()-x)/x;
+ return -log(_ex1-x)/x;
}
static ex Li2_series(const ex &x, const relational &rel, int order, unsigned options)
ex ser;
// manually construct the primitive expansion
for (int i=1; i<order; ++i)
- ser += pow(s,i) / pow(numeric(i), _num2());
+ ser += pow(s,i) / pow(numeric(i), _num2);
// substitute the argument's series expansion
ser = ser.subs(s==x.series(rel, order));
// maybe that was terminating, so add a proper order term
epvector nseq;
- nseq.push_back(expair(Order(_ex1()), order));
+ nseq.push_back(expair(Order(_ex1), order));
ser += pseries(rel, nseq);
// reexpanding it will collapse the series again
return ser.series(rel, order);
// obsolete!
}
// second special case: x==1 (branch point)
- if (x_pt.is_equal(_ex1())) {
+ if (x_pt.is_equal(_ex1)) {
// method:
// construct series manually in a dummy symbol s
const symbol s;
- ex ser = zeta(_ex2());
+ ex ser = zeta(_ex2);
// manually construct the primitive expansion
for (int i=1; i<order; ++i)
ser += pow(1-s,i) * (numeric(1,i)*(I*Pi+log(s-1)) - numeric(1,i*i));
ser = ser.subs(s==x.series(rel, order));
// maybe that was terminating, so add a proper order term
epvector nseq;
- nseq.push_back(expair(Order(_ex1()), order));
+ nseq.push_back(expair(Order(_ex1), order));
ser += pseries(rel, nseq);
// reexpanding it will collapse the series again
return ser.series(rel, order);
const symbol foo;
epvector seq;
// zeroth order term:
- seq.push_back(expair(Li2(x_pt), _ex0()));
+ seq.push_back(expair(Li2(x_pt), _ex0));
// compute the intermediate terms:
ex replarg = series(Li2(x), s==foo, order);
for (unsigned 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));
// append an order term:
- seq.push_back(expair(Order(_ex1()), replarg.nops()-1));
+ seq.push_back(expair(Order(_ex1), replarg.nops()-1));
return pseries(rel, seq);
}
}
if (is_ex_exactly_of_type(x, numeric)) {
// O(c) -> O(1) or 0
if (!x.is_zero())
- return Order(_ex1()).hold();
+ return Order(_ex1).hold();
else
- return _ex0();
+ return _ex0;
} else if (is_ex_exactly_of_type(x, mul)) {
const mul &m = ex_to<mul>(x);
// O(c*expr) -> O(expr)
epvector new_seq;
GINAC_ASSERT(is_exactly_a<symbol>(r.lhs()));
const symbol &s = ex_to<symbol>(r.lhs());
- new_seq.push_back(expair(Order(_ex1()), numeric(std::min(x.ldegree(s), order))));
+ new_seq.push_back(expair(Order(_ex1), numeric(std::min(x.ldegree(s), order))));
return pseries(r, new_seq);
}
if (x.info(info_flags::integer)) {
// lgamma(n) -> log((n-1)!) for postitive n
if (x.info(info_flags::posint))
- return log(factorial(x + _ex_1()));
+ return log(factorial(x + _ex_1));
else
throw (pole_error("lgamma_eval(): logarithmic pole",0));
}
ex recur;
for (numeric p = 0; p<=m; ++p)
recur += log(arg+p);
- return (lgamma(arg+m+_ex1())-recur).series(rel, order, options);
+ return (lgamma(arg+m+_ex1)-recur).series(rel, order, options);
}
{
if (x.info(info_flags::numeric)) {
// trap integer arguments:
- const numeric two_x = _num2()*ex_to<numeric>(x);
+ const numeric two_x = _num2*ex_to<numeric>(x);
if (two_x.is_even()) {
// tgamma(n) -> (n-1)! for postitive n
if (two_x.is_positive()) {
- return factorial(ex_to<numeric>(x).sub(_num1()));
+ return factorial(ex_to<numeric>(x).sub(_num1));
} else {
throw (pole_error("tgamma_eval(): simple pole",1));
}
// trap positive x==(n+1/2)
// tgamma(n+1/2) -> Pi^(1/2)*(1*3*..*(2*n-1))/(2^n)
if (two_x.is_positive()) {
- const numeric n = ex_to<numeric>(x).sub(_num1_2());
- return (doublefactorial(n.mul(_num2()).sub(_num1())).div(pow(_num2(),n))) * pow(Pi,_ex1_2());
+ const numeric n = ex_to<numeric>(x).sub(_num1_2);
+ return (doublefactorial(n.mul(_num2).sub(_num1)).div(pow(_num2,n))) * sqrt(Pi);
} else {
// trap negative x==(-n+1/2)
// tgamma(-n+1/2) -> Pi^(1/2)*(-2)^n/(1*3*..*(2*n-1))
- const numeric n = abs(ex_to<numeric>(x).sub(_num1_2()));
- return (pow(_num_2(), n).div(doublefactorial(n.mul(_num2()).sub(_num1()))))*power(Pi,_ex1_2());
+ const numeric n = abs(ex_to<numeric>(x).sub(_num1_2));
+ return (pow(_num_2, n).div(doublefactorial(n.mul(_num2).sub(_num1))))*sqrt(Pi);
}
}
// tgamma_evalf should be called here once it becomes available
throw do_taylor(); // caught by function::series()
// if we got here we have to care for a simple pole at -m:
const numeric m = -ex_to<numeric>(arg_pt);
- ex ser_denom = _ex1();
+ ex ser_denom = _ex1;
for (numeric p; p<=m; ++p)
ser_denom *= arg+p;
- return (tgamma(arg+m+_ex1())/ser_denom).series(rel, order+1, options);
+ return (tgamma(arg+m+_ex1)/ser_denom).series(rel, order+1, options);
}
ny.is_real() && ny.is_integer()) {
if (nx.is_negative()) {
if (nx<=-ny)
- return pow(_num_1(), ny)*beta(1-x-y, y);
+ return pow(_num_1, ny)*beta(1-x-y, y);
else
throw (pole_error("beta_eval(): simple pole",1));
}
if (ny.is_negative()) {
if (ny<=-nx)
- return pow(_num_1(), nx)*beta(1-y-x, x);
+ return pow(_num_1, nx)*beta(1-y-x, x);
else
throw (pole_error("beta_eval(): simple pole",1));
}
if ((nx+ny).is_real() &&
(nx+ny).is_integer() &&
!(nx+ny).is_positive())
- return _ex0();
+ return _ex0;
// beta_evalf should be called here once it becomes available
}
if (nx.is_positive()) {
// psi(n) -> 1 + 1/2 +...+ 1/(n-1) - Euler
numeric rat = 0;
- for (numeric i(nx+_num_1()); i>0; --i)
+ for (numeric i(nx+_num_1); i>0; --i)
rat += i.inverse();
return rat-Euler;
} else {
throw (pole_error("psi_eval(): simple pole",1));
}
}
- if ((_num2()*nx).is_integer()) {
+ if ((_num2*nx).is_integer()) {
// half integer case
if (nx.is_positive()) {
// psi((2m+1)/2) -> 2/(2m+1) + 2/2m +...+ 2/1 - Euler - 2log(2)
numeric rat = 0;
- for (numeric i = (nx+_num_1())*_num2(); i>0; i-=_num2())
- rat += _num2()*i.inverse();
- return rat-Euler-_ex2()*log(_ex2());
+ for (numeric i = (nx+_num_1)*_num2; i>0; i-=_num2)
+ rat += _num2*i.inverse();
+ return rat-Euler-_ex2*log(_ex2);
} else {
// use the recurrence relation
// psi(-m-1/2) == psi(-m-1/2+1) - 1 / (-m-1/2)
// where r == ((-1/2)^(-1) + ... + (-m-1/2)^(-1))
numeric recur = 0;
for (numeric p = nx; p<0; ++p)
- recur -= pow(p, _num_1());
- return recur+psi(_ex1_2());
+ recur -= pow(p, _num_1);
+ return recur+psi(_ex1_2);
}
}
// psi1_evalf should be called here once it becomes available
GINAC_ASSERT(deriv_param==0);
// d/dx psi(x) -> psi(1,x)
- return psi(_ex1(), x);
+ return psi(_ex1, x);
}
static ex psi1_series(const ex & arg,
const numeric m = -ex_to<numeric>(arg_pt);
ex recur;
for (numeric p; p<=m; ++p)
- recur += power(arg+p,_ex_1());
- return (psi(arg+m+_ex1())-recur).series(rel, order, options);
+ recur += power(arg+p,_ex_1);
+ return (psi(arg+m+_ex1)-recur).series(rel, order, options);
}
const unsigned function_index_psi1 =
if (n.is_zero())
return psi(x);
// psi(-1,x) -> log(tgamma(x))
- if (n.is_equal(_ex_1()))
+ if (n.is_equal(_ex_1))
return log(tgamma(x));
if (n.info(info_flags::numeric) && n.info(info_flags::posint) &&
x.info(info_flags::numeric)) {
const numeric nx = ex_to<numeric>(x);
if (nx.is_integer()) {
// integer case
- if (nx.is_equal(_num1()))
+ if (nx.is_equal(_num1))
// use psi(n,1) == (-)^(n+1) * n! * zeta(n+1)
- return pow(_num_1(),nn+_num1())*factorial(nn)*zeta(ex(nn+_num1()));
+ return pow(_num_1,nn+_num1)*factorial(nn)*zeta(ex(nn+_num1));
if (nx.is_positive()) {
// use the recurrence relation
// psi(n,m) == psi(n,m+1) - (-)^n * n! / m^(n+1)
// where r == (-)^n * n! * (1^(-n-1) + ... + (m-1)^(-n-1))
numeric recur = 0;
for (numeric p = 1; p<nx; ++p)
- recur += pow(p, -nn+_num_1());
- recur *= factorial(nn)*pow(_num_1(), nn);
- return recur+psi(n,_ex1());
+ recur += pow(p, -nn+_num_1);
+ recur *= factorial(nn)*pow(_num_1, nn);
+ return recur+psi(n,_ex1);
} else {
// for non-positive integers there is a pole:
throw (pole_error("psi2_eval(): pole",1));
}
}
- if ((_num2()*nx).is_integer()) {
+ if ((_num2*nx).is_integer()) {
// half integer case
- if (nx.is_equal(_num1_2()))
+ if (nx.is_equal(_num1_2))
// use psi(n,1/2) == (-)^(n+1) * n! * (2^(n+1)-1) * zeta(n+1)
- return pow(_num_1(),nn+_num1())*factorial(nn)*(pow(_num2(),nn+_num1()) + _num_1())*zeta(ex(nn+_num1()));
+ return pow(_num_1,nn+_num1)*factorial(nn)*(pow(_num2,nn+_num1) + _num_1)*zeta(ex(nn+_num1));
if (nx.is_positive()) {
- const numeric m = nx - _num1_2();
+ const numeric m = nx - _num1_2;
// use the multiplication formula
// psi(n,2*m) == (psi(n,m) + psi(n,m+1/2)) / 2^(n+1)
// to revert to positive integer case
- return psi(n,_num2()*m)*pow(_num2(),nn+_num1())-psi(n,m);
+ return psi(n,_num2*m)*pow(_num2,nn+_num1)-psi(n,m);
} else {
// use the recurrence relation
// psi(n,-m-1/2) == psi(n,-m-1/2+1) - (-)^n * n! / (-m-1/2)^(n+1)
// where r == (-)^(n+1) * n! * ((-1/2)^(-n-1) + ... + (-m-1/2)^(-n-1))
numeric recur = 0;
for (numeric p = nx; p<0; ++p)
- recur += pow(p, -nn+_num_1());
- recur *= factorial(nn)*pow(_num_1(), nn+_num_1());
- return recur+psi(n,_ex1_2());
+ recur += pow(p, -nn+_num_1);
+ recur *= factorial(nn)*pow(_num_1, nn+_num_1);
+ return recur+psi(n,_ex1_2);
}
}
// psi2_evalf should be called here once it becomes available
throw(std::logic_error("cannot diff psi(n,x) with respect to n"));
}
// d/dx psi(n,x) -> psi(n+1,x)
- return psi(n+_ex1(), x);
+ return psi(n+_ex1, x);
}
static ex psi2_series(const ex & n,
const numeric m = -ex_to<numeric>(arg_pt);
ex recur;
for (numeric p; p<=m; ++p)
- recur += power(arg+p,-n+_ex_1());
- recur *= factorial(n)*power(_ex_1(),n);
- return (psi(n, arg+m+_ex1())-recur).series(rel, order, options);
+ recur += power(arg+p,-n+_ex_1);
+ recur *= factorial(n)*power(_ex_1,n);
+ return (psi(n, arg+m+_ex1)-recur).series(rel, order, options);
}
const unsigned function_index_psi2 =
{
// exp(0) -> 1
if (x.is_zero()) {
- return _ex1();
+ return _ex1;
}
// exp(n*Pi*I/2) -> {+1|+I|-1|-I}
- const ex TwoExOverPiI=(_ex2()*x)/(Pi*I);
+ const ex TwoExOverPiI=(_ex2*x)/(Pi*I);
if (TwoExOverPiI.info(info_flags::integer)) {
- numeric z=mod(ex_to<numeric>(TwoExOverPiI),_num4());
- if (z.is_equal(_num0()))
- return _ex1();
- if (z.is_equal(_num1()))
+ numeric z = mod(ex_to<numeric>(TwoExOverPiI),_num4);
+ if (z.is_equal(_num0))
+ return _ex1;
+ if (z.is_equal(_num1))
return ex(I);
- if (z.is_equal(_num2()))
- return _ex_1();
- if (z.is_equal(_num3()))
+ if (z.is_equal(_num2))
+ return _ex_1;
+ if (z.is_equal(_num3))
return ex(-I);
}
// exp(log(x)) -> x
throw(pole_error("log_eval(): log(0)",0));
if (x.info(info_flags::real) && x.info(info_flags::negative))
return (log(-x)+I*Pi);
- if (x.is_equal(_ex1())) // log(1) -> 0
- return _ex0();
+ if (x.is_equal(_ex1)) // log(1) -> 0
+ return _ex0;
if (x.is_equal(I)) // log(I) -> Pi*I/2
- return (Pi*I*_num1_2());
+ return (Pi*I*_num1_2);
if (x.is_equal(-I)) // log(-I) -> -Pi*I/2
- return (Pi*I*_num_1_2());
+ return (Pi*I*_num_1_2);
// log(float)
if (!x.info(info_flags::crational))
return log(ex_to<numeric>(x));
GINAC_ASSERT(deriv_param==0);
// d/dx log(x) -> 1/x
- return power(x, _ex_1());
+ return power(x, _ex_1);
}
static ex log_series(const ex &arg,
// expand the log, but only if coeff is real and > 0, since otherwise
// it would make the branch cut run into the wrong direction
if (coeff.info(info_flags::positive))
- seq.push_back(expair(n*log(s-point)+log(coeff), _ex0()));
+ seq.push_back(expair(n*log(s-point)+log(coeff), _ex0));
else
- seq.push_back(expair(log(coeff*pow(s-point, n)), _ex0()));
+ seq.push_back(expair(log(coeff*pow(s-point, n)), _ex0));
if (!argser.is_terminating() || argser.nops()!=1) {
// in this case n more (or less) terms are needed
const symbol foo;
const ex replarg = series(log(arg), s==foo, order).subs(foo==point);
epvector seq;
- seq.push_back(expair(-I*csgn(arg*I)*Pi, _ex0()));
- seq.push_back(expair(Order(_ex1()), order));
+ seq.push_back(expair(-I*csgn(arg*I)*Pi, _ex0));
+ seq.push_back(expair(Order(_ex1), order));
return series(replarg - I*Pi + pseries(rel, seq), rel, order);
}
throw do_taylor(); // caught by function::series()
static ex sin_eval(const ex & x)
{
// sin(n/d*Pi) -> { all known non-nested radicals }
- const ex SixtyExOverPi = _ex60()*x/Pi;
- ex sign = _ex1();
+ const ex SixtyExOverPi = _ex60*x/Pi;
+ ex sign = _ex1;
if (SixtyExOverPi.info(info_flags::integer)) {
- numeric z = mod(ex_to<numeric>(SixtyExOverPi),_num120());
- if (z>=_num60()) {
+ numeric z = mod(ex_to<numeric>(SixtyExOverPi),_num120);
+ if (z>=_num60) {
// wrap to interval [0, Pi)
- z -= _num60();
- sign = _ex_1();
+ z -= _num60;
+ sign = _ex_1;
}
- if (z>_num30()) {
+ if (z>_num30) {
// wrap to interval [0, Pi/2)
- z = _num60()-z;
+ z = _num60-z;
}
- if (z.is_equal(_num0())) // sin(0) -> 0
- return _ex0();
- if (z.is_equal(_num5())) // sin(Pi/12) -> sqrt(6)/4*(1-sqrt(3)/3)
- return sign*_ex1_4()*power(_ex6(),_ex1_2())*(_ex1()+_ex_1_3()*power(_ex3(),_ex1_2()));
- if (z.is_equal(_num6())) // sin(Pi/10) -> sqrt(5)/4-1/4
- return sign*(_ex1_4()*power(_ex5(),_ex1_2())+_ex_1_4());
- if (z.is_equal(_num10())) // sin(Pi/6) -> 1/2
- return sign*_ex1_2();
- if (z.is_equal(_num15())) // sin(Pi/4) -> sqrt(2)/2
- return sign*_ex1_2()*power(_ex2(),_ex1_2());
- if (z.is_equal(_num18())) // sin(3/10*Pi) -> sqrt(5)/4+1/4
- return sign*(_ex1_4()*power(_ex5(),_ex1_2())+_ex1_4());
- if (z.is_equal(_num20())) // sin(Pi/3) -> sqrt(3)/2
- return sign*_ex1_2()*power(_ex3(),_ex1_2());
- if (z.is_equal(_num25())) // sin(5/12*Pi) -> sqrt(6)/4*(1+sqrt(3)/3)
- return sign*_ex1_4()*power(_ex6(),_ex1_2())*(_ex1()+_ex1_3()*power(_ex3(),_ex1_2()));
- if (z.is_equal(_num30())) // sin(Pi/2) -> 1
- return sign*_ex1();
+ if (z.is_equal(_num0)) // sin(0) -> 0
+ return _ex0;
+ if (z.is_equal(_num5)) // sin(Pi/12) -> sqrt(6)/4*(1-sqrt(3)/3)
+ return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex_1_3*sqrt(_ex3));
+ if (z.is_equal(_num6)) // sin(Pi/10) -> sqrt(5)/4-1/4
+ return sign*(_ex1_4*sqrt(_ex5)+_ex_1_4);
+ if (z.is_equal(_num10)) // sin(Pi/6) -> 1/2
+ return sign*_ex1_2;
+ if (z.is_equal(_num15)) // sin(Pi/4) -> sqrt(2)/2
+ return sign*_ex1_2*sqrt(_ex2);
+ if (z.is_equal(_num18)) // sin(3/10*Pi) -> sqrt(5)/4+1/4
+ return sign*(_ex1_4*sqrt(_ex5)+_ex1_4);
+ if (z.is_equal(_num20)) // sin(Pi/3) -> sqrt(3)/2
+ return sign*_ex1_2*sqrt(_ex3);
+ if (z.is_equal(_num25)) // sin(5/12*Pi) -> sqrt(6)/4*(1+sqrt(3)/3)
+ return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex1_3*sqrt(_ex3));
+ if (z.is_equal(_num30)) // sin(Pi/2) -> 1
+ return sign;
}
if (is_exactly_a<function>(x)) {
return t;
// sin(acos(x)) -> sqrt(1-x^2)
if (is_ex_the_function(x, acos))
- return power(_ex1()-power(t,_ex2()),_ex1_2());
- // sin(atan(x)) -> x*(1+x^2)^(-1/2)
+ return sqrt(_ex1-power(t,_ex2));
+ // sin(atan(x)) -> x/sqrt(1+x^2)
if (is_ex_the_function(x, atan))
- return t*power(_ex1()+power(t,_ex2()),_ex_1_2());
+ return t*power(_ex1+power(t,_ex2),_ex_1_2);
}
// sin(float) -> float
static ex cos_eval(const ex & x)
{
// cos(n/d*Pi) -> { all known non-nested radicals }
- const ex SixtyExOverPi = _ex60()*x/Pi;
- ex sign = _ex1();
+ const ex SixtyExOverPi = _ex60*x/Pi;
+ ex sign = _ex1;
if (SixtyExOverPi.info(info_flags::integer)) {
- numeric z = mod(ex_to<numeric>(SixtyExOverPi),_num120());
- if (z>=_num60()) {
+ numeric z = mod(ex_to<numeric>(SixtyExOverPi),_num120);
+ if (z>=_num60) {
// wrap to interval [0, Pi)
- z = _num120()-z;
+ z = _num120-z;
}
- if (z>=_num30()) {
+ if (z>=_num30) {
// wrap to interval [0, Pi/2)
- z = _num60()-z;
- sign = _ex_1();
+ z = _num60-z;
+ sign = _ex_1;
}
- if (z.is_equal(_num0())) // cos(0) -> 1
- return sign*_ex1();
- if (z.is_equal(_num5())) // cos(Pi/12) -> sqrt(6)/4*(1+sqrt(3)/3)
- return sign*_ex1_4()*power(_ex6(),_ex1_2())*(_ex1()+_ex1_3()*power(_ex3(),_ex1_2()));
- if (z.is_equal(_num10())) // cos(Pi/6) -> sqrt(3)/2
- return sign*_ex1_2()*power(_ex3(),_ex1_2());
- if (z.is_equal(_num12())) // cos(Pi/5) -> sqrt(5)/4+1/4
- return sign*(_ex1_4()*power(_ex5(),_ex1_2())+_ex1_4());
- if (z.is_equal(_num15())) // cos(Pi/4) -> sqrt(2)/2
- return sign*_ex1_2()*power(_ex2(),_ex1_2());
- if (z.is_equal(_num20())) // cos(Pi/3) -> 1/2
- return sign*_ex1_2();
- if (z.is_equal(_num24())) // cos(2/5*Pi) -> sqrt(5)/4-1/4x
- return sign*(_ex1_4()*power(_ex5(),_ex1_2())+_ex_1_4());
- if (z.is_equal(_num25())) // cos(5/12*Pi) -> sqrt(6)/4*(1-sqrt(3)/3)
- return sign*_ex1_4()*power(_ex6(),_ex1_2())*(_ex1()+_ex_1_3()*power(_ex3(),_ex1_2()));
- if (z.is_equal(_num30())) // cos(Pi/2) -> 0
- return sign*_ex0();
+ if (z.is_equal(_num0)) // cos(0) -> 1
+ return sign;
+ if (z.is_equal(_num5)) // cos(Pi/12) -> sqrt(6)/4*(1+sqrt(3)/3)
+ return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex1_3*sqrt(_ex3));
+ if (z.is_equal(_num10)) // cos(Pi/6) -> sqrt(3)/2
+ return sign*_ex1_2*sqrt(_ex3);
+ if (z.is_equal(_num12)) // cos(Pi/5) -> sqrt(5)/4+1/4
+ return sign*(_ex1_4*sqrt(_ex5)+_ex1_4);
+ if (z.is_equal(_num15)) // cos(Pi/4) -> sqrt(2)/2
+ return sign*_ex1_2*sqrt(_ex2);
+ if (z.is_equal(_num20)) // cos(Pi/3) -> 1/2
+ return sign*_ex1_2;
+ if (z.is_equal(_num24)) // cos(2/5*Pi) -> sqrt(5)/4-1/4x
+ return sign*(_ex1_4*sqrt(_ex5)+_ex_1_4);
+ if (z.is_equal(_num25)) // cos(5/12*Pi) -> sqrt(6)/4*(1-sqrt(3)/3)
+ return sign*_ex1_4*sqrt(_ex6)*(_ex1+_ex_1_3*sqrt(_ex3));
+ if (z.is_equal(_num30)) // cos(Pi/2) -> 0
+ return _ex0;
}
if (is_exactly_a<function>(x)) {
// cos(acos(x)) -> x
if (is_ex_the_function(x, acos))
return t;
- // cos(asin(x)) -> (1-x^2)^(1/2)
+ // cos(asin(x)) -> sqrt(1-x^2)
if (is_ex_the_function(x, asin))
- return power(_ex1()-power(t,_ex2()),_ex1_2());
- // cos(atan(x)) -> (1+x^2)^(-1/2)
+ return sqrt(_ex1-power(t,_ex2));
+ // cos(atan(x)) -> 1/sqrt(1+x^2)
if (is_ex_the_function(x, atan))
- return power(_ex1()+power(t,_ex2()),_ex_1_2());
+ return power(_ex1+power(t,_ex2),_ex_1_2);
}
// cos(float) -> float
GINAC_ASSERT(deriv_param==0);
// d/dx cos(x) -> -sin(x)
- return _ex_1()*sin(x);
+ return -sin(x);
}
REGISTER_FUNCTION(cos, eval_func(cos_eval).
static ex tan_eval(const ex & x)
{
// tan(n/d*Pi) -> { all known non-nested radicals }
- const ex SixtyExOverPi = _ex60()*x/Pi;
- ex sign = _ex1();
+ const ex SixtyExOverPi = _ex60*x/Pi;
+ ex sign = _ex1;
if (SixtyExOverPi.info(info_flags::integer)) {
- numeric z = mod(ex_to<numeric>(SixtyExOverPi),_num60());
- if (z>=_num60()) {
+ numeric z = mod(ex_to<numeric>(SixtyExOverPi),_num60);
+ if (z>=_num60) {
// wrap to interval [0, Pi)
- z -= _num60();
+ z -= _num60;
}
- if (z>=_num30()) {
+ if (z>=_num30) {
// wrap to interval [0, Pi/2)
- z = _num60()-z;
- sign = _ex_1();
+ z = _num60-z;
+ sign = _ex_1;
}
- if (z.is_equal(_num0())) // tan(0) -> 0
- return _ex0();
- if (z.is_equal(_num5())) // tan(Pi/12) -> 2-sqrt(3)
- return sign*(_ex2()-power(_ex3(),_ex1_2()));
- if (z.is_equal(_num10())) // tan(Pi/6) -> sqrt(3)/3
- return sign*_ex1_3()*power(_ex3(),_ex1_2());
- if (z.is_equal(_num15())) // tan(Pi/4) -> 1
- return sign*_ex1();
- if (z.is_equal(_num20())) // tan(Pi/3) -> sqrt(3)
- return sign*power(_ex3(),_ex1_2());
- if (z.is_equal(_num25())) // tan(5/12*Pi) -> 2+sqrt(3)
- return sign*(power(_ex3(),_ex1_2())+_ex2());
- if (z.is_equal(_num30())) // tan(Pi/2) -> infinity
+ if (z.is_equal(_num0)) // tan(0) -> 0
+ return _ex0;
+ if (z.is_equal(_num5)) // tan(Pi/12) -> 2-sqrt(3)
+ return sign*(_ex2-sqrt(_ex3));
+ if (z.is_equal(_num10)) // tan(Pi/6) -> sqrt(3)/3
+ return sign*_ex1_3*sqrt(_ex3);
+ if (z.is_equal(_num15)) // tan(Pi/4) -> 1
+ return sign;
+ if (z.is_equal(_num20)) // tan(Pi/3) -> sqrt(3)
+ return sign*sqrt(_ex3);
+ if (z.is_equal(_num25)) // tan(5/12*Pi) -> 2+sqrt(3)
+ return sign*(sqrt(_ex3)+_ex2);
+ if (z.is_equal(_num30)) // tan(Pi/2) -> infinity
throw (pole_error("tan_eval(): simple pole",1));
}
// tan(atan(x)) -> x
if (is_ex_the_function(x, atan))
return t;
- // tan(asin(x)) -> x*(1+x^2)^(-1/2)
+ // tan(asin(x)) -> x/sqrt(1+x^2)
if (is_ex_the_function(x, asin))
- return t*power(_ex1()-power(t,_ex2()),_ex_1_2());
- // tan(acos(x)) -> (1-x^2)^(1/2)/x
+ return t*power(_ex1-power(t,_ex2),_ex_1_2);
+ // tan(acos(x)) -> sqrt(1-x^2)/x
if (is_ex_the_function(x, acos))
- return power(t,_ex_1())*power(_ex1()-power(t,_ex2()),_ex1_2());
+ return power(t,_ex_1)*sqrt(_ex1-power(t,_ex2));
}
// tan(float) -> float
GINAC_ASSERT(deriv_param==0);
// d/dx tan(x) -> 1+tan(x)^2;
- return (_ex1()+power(tan(x),_ex2()));
+ return (_ex1+power(tan(x),_ex2));
}
static ex tan_series(const ex &x,
if (x.is_zero())
return x;
// asin(1/2) -> Pi/6
- if (x.is_equal(_ex1_2()))
+ if (x.is_equal(_ex1_2))
return numeric(1,6)*Pi;
// asin(1) -> Pi/2
- if (x.is_equal(_ex1()))
- return _num1_2()*Pi;
+ if (x.is_equal(_ex1))
+ return _num1_2*Pi;
// asin(-1/2) -> -Pi/6
- if (x.is_equal(_ex_1_2()))
+ if (x.is_equal(_ex_1_2))
return numeric(-1,6)*Pi;
// asin(-1) -> -Pi/2
- if (x.is_equal(_ex_1()))
- return _num_1_2()*Pi;
+ if (x.is_equal(_ex_1))
+ return _num_1_2*Pi;
// asin(float) -> float
if (!x.info(info_flags::crational))
return asin(ex_to<numeric>(x));
GINAC_ASSERT(deriv_param==0);
// d/dx asin(x) -> 1/sqrt(1-x^2)
- return power(1-power(x,_ex2()),_ex_1_2());
+ return power(1-power(x,_ex2),_ex_1_2);
}
REGISTER_FUNCTION(asin, eval_func(asin_eval).
{
if (x.info(info_flags::numeric)) {
// acos(1) -> 0
- if (x.is_equal(_ex1()))
- return _ex0();
+ if (x.is_equal(_ex1))
+ return _ex0;
// acos(1/2) -> Pi/3
- if (x.is_equal(_ex1_2()))
- return _ex1_3()*Pi;
+ if (x.is_equal(_ex1_2))
+ return _ex1_3*Pi;
// acos(0) -> Pi/2
if (x.is_zero())
- return _ex1_2()*Pi;
+ return _ex1_2*Pi;
// acos(-1/2) -> 2/3*Pi
- if (x.is_equal(_ex_1_2()))
+ if (x.is_equal(_ex_1_2))
return numeric(2,3)*Pi;
// acos(-1) -> Pi
- if (x.is_equal(_ex_1()))
+ if (x.is_equal(_ex_1))
return Pi;
// acos(float) -> float
if (!x.info(info_flags::crational))
GINAC_ASSERT(deriv_param==0);
// d/dx acos(x) -> -1/sqrt(1-x^2)
- return _ex_1()*power(1-power(x,_ex2()),_ex_1_2());
+ return -power(1-power(x,_ex2),_ex_1_2);
}
REGISTER_FUNCTION(acos, eval_func(acos_eval).
if (x.info(info_flags::numeric)) {
// atan(0) -> 0
if (x.is_zero())
- return _ex0();
+ return _ex0;
// atan(1) -> Pi/4
- if (x.is_equal(_ex1()))
- return _ex1_4()*Pi;
+ if (x.is_equal(_ex1))
+ return _ex1_4*Pi;
// atan(-1) -> -Pi/4
- if (x.is_equal(_ex_1()))
- return _ex_1_4()*Pi;
+ if (x.is_equal(_ex_1))
+ return _ex_1_4*Pi;
if (x.is_equal(I) || x.is_equal(-I))
throw (pole_error("atan_eval(): logarithmic pole",0));
// atan(float) -> float
GINAC_ASSERT(deriv_param==0);
// d/dx atan(x) -> 1/(1+x^2)
- return power(_ex1()+power(x,_ex2()), _ex_1());
+ return power(_ex1+power(x,_ex2), _ex_1);
}
static ex atan_series(const ex &arg,
const ex arg_pt = arg.subs(rel);
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())
+ if ((I*arg_pt).info(info_flags::real) && abs(I*arg_pt)<_ex1)
throw do_taylor(); // Re(x) == 0, but abs(x)<1
// care for the poles, using the defining formula for atan()...
if (arg_pt.is_equal(I) || arg_pt.is_equal(-I))
const ex point = rel.rhs();
const symbol foo;
const ex replarg = series(atan(arg), s==foo, order).subs(foo==point);
- 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();
+ 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;
else
- Order0correction += log((I*arg_pt+_ex1())/(I*arg_pt+_ex_1()))*I*_ex1_2();
+ Order0correction += log((I*arg_pt+_ex1)/(I*arg_pt+_ex_1))*I*_ex1_2;
epvector seq;
- seq.push_back(expair(Order0correction, _ex0()));
- seq.push_back(expair(Order(_ex1()), order));
+ seq.push_back(expair(Order0correction, _ex0));
+ seq.push_back(expair(Order(_ex1), order));
return series(replarg - pseries(rel, seq), rel, order);
}
throw do_taylor();
if (deriv_param==0) {
// d/dy atan(y,x)
- return x*power(power(x,_ex2())+power(y,_ex2()),_ex_1());
+ return x*power(power(x,_ex2)+power(y,_ex2),_ex_1);
}
// d/dx atan(y,x)
- return -y*power(power(x,_ex2())+power(y,_ex2()),_ex_1());
+ return -y*power(power(x,_ex2)+power(y,_ex2),_ex_1);
}
REGISTER_FUNCTION(atan2, eval_func(atan2_eval).
{
if (x.info(info_flags::numeric)) {
if (x.is_zero()) // sinh(0) -> 0
- return _ex0();
+ return _ex0;
if (!x.info(info_flags::crational)) // sinh(float) -> float
return sinh(ex_to<numeric>(x));
}
// sinh(asinh(x)) -> x
if (is_ex_the_function(x, asinh))
return t;
- // sinh(acosh(x)) -> (x-1)^(1/2) * (x+1)^(1/2)
+ // sinh(acosh(x)) -> sqrt(x-1) * sqrt(x+1)
if (is_ex_the_function(x, acosh))
- return power(t-_ex1(),_ex1_2())*power(t+_ex1(),_ex1_2());
- // sinh(atanh(x)) -> x*(1-x^2)^(-1/2)
+ return sqrt(t-_ex1)*sqrt(t+_ex1);
+ // sinh(atanh(x)) -> x/sqrt(1-x^2)
if (is_ex_the_function(x, atanh))
- return t*power(_ex1()-power(t,_ex2()),_ex_1_2());
+ return t*power(_ex1-power(t,_ex2),_ex_1_2);
}
return sinh(x).hold();
{
if (x.info(info_flags::numeric)) {
if (x.is_zero()) // cosh(0) -> 1
- return _ex1();
+ return _ex1;
if (!x.info(info_flags::crational)) // cosh(float) -> float
return cosh(ex_to<numeric>(x));
}
// cosh(acosh(x)) -> x
if (is_ex_the_function(x, acosh))
return t;
- // cosh(asinh(x)) -> (1+x^2)^(1/2)
+ // cosh(asinh(x)) -> sqrt(1+x^2)
if (is_ex_the_function(x, asinh))
- return power(_ex1()+power(t,_ex2()),_ex1_2());
- // cosh(atanh(x)) -> (1-x^2)^(-1/2)
+ return sqrt(_ex1+power(t,_ex2));
+ // cosh(atanh(x)) -> 1/sqrt(1-x^2)
if (is_ex_the_function(x, atanh))
- return power(_ex1()-power(t,_ex2()),_ex_1_2());
+ return power(_ex1-power(t,_ex2),_ex_1_2);
}
return cosh(x).hold();
{
if (x.info(info_flags::numeric)) {
if (x.is_zero()) // tanh(0) -> 0
- return _ex0();
+ return _ex0;
if (!x.info(info_flags::crational)) // tanh(float) -> float
return tanh(ex_to<numeric>(x));
}
// tanh(atanh(x)) -> x
if (is_ex_the_function(x, atanh))
return t;
- // tanh(asinh(x)) -> x*(1+x^2)^(-1/2)
+ // tanh(asinh(x)) -> x/sqrt(1+x^2)
if (is_ex_the_function(x, asinh))
- return t*power(_ex1()+power(t,_ex2()),_ex_1_2());
- // tanh(acosh(x)) -> (x-1)^(1/2)*(x+1)^(1/2)/x
+ return t*power(_ex1+power(t,_ex2),_ex_1_2);
+ // tanh(acosh(x)) -> sqrt(x-1)*sqrt(x+1)/x
if (is_ex_the_function(x, acosh))
- return power(t-_ex1(),_ex1_2())*power(t+_ex1(),_ex1_2())*power(t,_ex_1());
+ return sqrt(t-_ex1)*sqrt(t+_ex1)*power(t,_ex_1);
}
return tanh(x).hold();
GINAC_ASSERT(deriv_param==0);
// d/dx tanh(x) -> 1-tanh(x)^2
- return _ex1()-power(tanh(x),_ex2());
+ return _ex1-power(tanh(x),_ex2);
}
static ex tanh_series(const ex &x,
if (x.info(info_flags::numeric)) {
// asinh(0) -> 0
if (x.is_zero())
- return _ex0();
+ return _ex0;
// asinh(float) -> float
if (!x.info(info_flags::crational))
return asinh(ex_to<numeric>(x));
GINAC_ASSERT(deriv_param==0);
// d/dx asinh(x) -> 1/sqrt(1+x^2)
- return power(_ex1()+power(x,_ex2()),_ex_1_2());
+ return power(_ex1+power(x,_ex2),_ex_1_2);
}
REGISTER_FUNCTION(asinh, eval_func(asinh_eval).
if (x.is_zero())
return Pi*I*numeric(1,2);
// acosh(1) -> 0
- if (x.is_equal(_ex1()))
- return _ex0();
+ if (x.is_equal(_ex1))
+ return _ex0;
// acosh(-1) -> Pi*I
- if (x.is_equal(_ex_1()))
+ if (x.is_equal(_ex_1))
return Pi*I;
// acosh(float) -> float
if (!x.info(info_flags::crational))
GINAC_ASSERT(deriv_param==0);
// d/dx acosh(x) -> 1/(sqrt(x-1)*sqrt(x+1))
- return power(x+_ex_1(),_ex_1_2())*power(x+_ex1(),_ex_1_2());
+ return power(x+_ex_1,_ex_1_2)*power(x+_ex1,_ex_1_2);
}
REGISTER_FUNCTION(acosh, eval_func(acosh_eval).
if (x.info(info_flags::numeric)) {
// atanh(0) -> 0
if (x.is_zero())
- return _ex0();
+ return _ex0;
// atanh({+|-}1) -> throw
- if (x.is_equal(_ex1()) || x.is_equal(_ex_1()))
+ if (x.is_equal(_ex1) || x.is_equal(_ex_1))
throw (pole_error("atanh_eval(): logarithmic pole",0));
// atanh(float) -> float
if (!x.info(info_flags::crational))
GINAC_ASSERT(deriv_param==0);
// d/dx atanh(x) -> 1/(1-x^2)
- return power(_ex1()-power(x,_ex2()),_ex_1());
+ return power(_ex1-power(x,_ex2),_ex_1);
}
static ex atanh_series(const ex &arg,
const ex arg_pt = arg.subs(rel);
if (!(arg_pt).info(info_flags::real))
throw do_taylor(); // Im(x) != 0
- if ((arg_pt).info(info_flags::real) && abs(arg_pt)<_ex1())
+ if ((arg_pt).info(info_flags::real) && abs(arg_pt)<_ex1)
throw do_taylor(); // Im(x) == 0, but abs(x)<1
// care for the poles, using the defining formula for atanh()...
- if (arg_pt.is_equal(_ex1()) || arg_pt.is_equal(_ex_1()))
- return ((log(_ex1()+arg)-log(_ex1()-arg))*_ex1_2()).series(rel, order, options);
+ if (arg_pt.is_equal(_ex1) || arg_pt.is_equal(_ex_1))
+ return ((log(_ex1+arg)-log(_ex1-arg))*_ex1_2).series(rel, order, options);
// ...and the branch cuts (the discontinuity at the cut being just I*Pi)
if (!(options & series_options::suppress_branchcut)) {
// method:
const ex point = rel.rhs();
const symbol foo;
const ex replarg = series(atanh(arg), s==foo, order).subs(foo==point);
- 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();
+ 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;
else
- Order0correction += log((arg_pt+_ex1())/(arg_pt+_ex_1()))*_ex_1_2();
+ Order0correction += log((arg_pt+_ex1)/(arg_pt+_ex_1))*_ex_1_2;
epvector seq;
- seq.push_back(expair(Order0correction, _ex0()));
- seq.push_back(expair(Order(_ex1()), order));
+ seq.push_back(expair(Order0correction, _ex0));
+ seq.push_back(expair(Order(_ex1), order));
return series(replarg - pseries(rel, seq), rel, order);
}
throw do_taylor();
// trap integer arguments:
if (y.is_integer()) {
if (y.is_zero())
- return _ex_1_2();
- if (x.is_equal(_ex1()))
+ return _ex_1_2;
+ if (x.is_equal(_ex1))
throw(std::domain_error("zeta(1): infinity"));
if (x.info(info_flags::posint)) {
if (x.info(info_flags::odd))
return zeta(x).hold();
else
- return abs(bernoulli(y))*pow(Pi,x)*pow(_num2(),y-_num1())/factorial(y);
+ return abs(bernoulli(y))*pow(Pi,x)*pow(_num2,y-_num1)/factorial(y);
} else {
if (x.info(info_flags::odd))
- return -bernoulli(_num1()-y)/(_num1()-y);
+ return -bernoulli(_num1-y)/(_num1-y);
else
- return _num0();
+ return _num0;
}
}
// zeta(float)
{
GINAC_ASSERT(deriv_param==0);
- return zeta(_ex1(), x);
+ return zeta(_ex1, x);
}
const unsigned function_index_zeta1 =
matrix::matrix() : inherited(TINFO_matrix), row(1), col(1)
{
debugmsg("matrix default ctor",LOGLEVEL_CONSTRUCT);
- m.push_back(_ex0());
+ m.push_back(_ex0);
}
void matrix::copy(const matrix & other)
: inherited(TINFO_matrix), row(r), col(c)
{
debugmsg("matrix ctor from unsigned,unsigned",LOGLEVEL_CONSTRUCT);
- m.resize(r*c, _ex0());
+ m.resize(r*c, _ex0);
}
// protected
: inherited(TINFO_matrix), row(r), col(c)
{
debugmsg("matrix ctor from unsigned,unsigned,lst",LOGLEVEL_CONSTRUCT);
- m.resize(r*c, _ex0());
+ m.resize(r*c, _ex0);
for (unsigned i=0; i<l.nops(); i++) {
unsigned x = i % c;
*self = self_matrix.mul(other_matrix.transpose())(0, 0);
}
}
- *other = _ex1();
+ *other = _ex1;
return true;
} else { // vector * matrix
*self = indexed(self_matrix.mul(other_matrix), other->op(2));
else
*self = indexed(self_matrix.transpose().mul(other_matrix), other->op(2));
- *other = _ex1();
+ *other = _ex1;
return true;
}
*self = indexed(other_matrix.mul(self_matrix), other->op(1));
else
*self = indexed(other_matrix.mul(self_matrix.transpose()), other->op(1));
- *other = _ex1();
+ *other = _ex1;
return true;
}
}
// A_ij * B_jk = (A*B)_ik
if (is_dummy_pair(self->op(2), other->op(1))) {
*self = indexed(self_matrix.mul(other_matrix), self->op(1), other->op(2));
- *other = _ex1();
+ *other = _ex1;
return true;
}
// A_ij * B_kj = (A*Btrans)_ik
if (is_dummy_pair(self->op(2), other->op(2))) {
*self = indexed(self_matrix.mul(other_matrix.transpose()), self->op(1), other->op(1));
- *other = _ex1();
+ *other = _ex1;
return true;
}
// A_ji * B_jk = (Atrans*B)_ik
if (is_dummy_pair(self->op(1), other->op(1))) {
*self = indexed(self_matrix.transpose().mul(other_matrix), self->op(2), other->op(2));
- *other = _ex1();
+ *other = _ex1;
return true;
}
// A_ji * B_kj = (B*A)_ki
if (is_dummy_pair(self->op(1), other->op(2))) {
*self = indexed(other_matrix.mul(self_matrix), other->op(1), self->op(2));
- *other = _ex1();
+ *other = _ex1;
return true;
}
}
}
matrix C(row,col);
for (unsigned r=0; r<row; ++r)
- C(r,r) = _ex1();
+ C(r,r) = _ex1;
// This loop computes the representation of b in base 2 from right
// to left and multiplies the factors whenever needed. Note
// that this is not entirely optimal but close to optimal and
C = C.mul(A);
b -= 1;
}
- b *= _num1_2(); // b /= 2, still integer.
+ b *= _num1_2; // b /= 2, still integer.
A = A.mul(A);
}
return A.mul(C);
int sign;
sign = tmp.division_free_elimination(true);
if (sign==0)
- return _ex0();
+ return _ex0;
ex det = tmp.m[row*col-1];
// factor out accumulated bogus slag
for (unsigned d=0; d<row-2; ++d)
// First populate the identity matrix supposed to become the right hand side.
matrix identity(row,col);
for (unsigned i=0; i<row; ++i)
- identity(i,i) = _ex1();
+ identity(i,i) = _ex1;
// Populate a dummy matrix of variables, just because of compatibility with
// matrix::solve() which wants this (for compatibility with under-determined
Pkey.push_back(i);
unsigned fc = 0; // controls logic for our strange flipper counter
do {
- det = _ex0();
+ det = _ex0;
for (unsigned r=0; r<n-c; ++r) {
// maybe there is nothing to do?
if (m[Pkey[r]*n+c].is_zero())
}
// fill up left hand side with zeros
for (unsigned c=0; c<=r1; ++c)
- this->m[r2*n+c] = _ex0();
+ this->m[r2*n+c] = _ex0;
}
if (det) {
// save space by deleting no longer needed elements
for (unsigned c=r0+1; c<n; ++c)
- this->m[r0*n+c] = _ex0();
+ this->m[r0*n+c] = _ex0;
}
++r0;
}
this->m[r2*n+c] = (this->m[r0*n+r1]*this->m[r2*n+c] - this->m[r2*n+r1]*this->m[r0*n+c]).expand();
// fill up left hand side with zeros
for (unsigned c=0; c<=r1; ++c)
- this->m[r2*n+c] = _ex0();
+ this->m[r2*n+c] = _ex0;
}
if (det) {
// save space by deleting no longer needed elements
for (unsigned c=r0+1; c<n; ++c)
- this->m[r0*n+c] = _ex0();
+ this->m[r0*n+c] = _ex0;
}
++r0;
}
}
// fill up left hand side with zeros
for (unsigned c=0; c<=r1; ++c)
- tmp_n.m[r2*n+c] = _ex0();
+ tmp_n.m[r2*n+c] = _ex0;
}
if ((r1<n-1)&&(r0<m-1)) {
// compute next iteration's divisor
if (det) {
// save space by deleting no longer needed elements
for (unsigned c=0; c<n; ++c) {
- tmp_n.m[r0*n+c] = _ex0();
- tmp_d.m[r0*n+c] = _ex1();
+ tmp_n.m[r0*n+c] = _ex0;
+ tmp_d.m[r0*n+c] = _ex1;
}
}
}
if (l.op(i).nops() > j)
m(i, j) = l.op(i).op(j);
else
- m(i, j) = _ex0();
+ m(i, j) = _ex0;
return m;
}
{
debugmsg("mul ctor from ex,ex",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_mul;
- overall_coeff = _ex1();
+ overall_coeff = _ex1;
construct_from_2_ex(lh,rh);
GINAC_ASSERT(is_canonical());
}
{
debugmsg("mul ctor from exvector",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_mul;
- overall_coeff = _ex1();
+ overall_coeff = _ex1;
construct_from_exvector(v);
GINAC_ASSERT(is_canonical());
}
{
debugmsg("mul ctor from epvector",LOGLEVEL_CONSTRUCT);
tinfo_key = TINFO_mul;
- overall_coeff = _ex1();
+ overall_coeff = _ex1;
construct_from_epvector(v);
GINAC_ASSERT(is_canonical());
}
factors.push_back(lh);
factors.push_back(mh);
factors.push_back(rh);
- overall_coeff = _ex1();
+ overall_coeff = _ex1;
construct_from_exvector(factors);
GINAC_ASSERT(is_canonical());
}
if (precedence() <= level)
c.s << "(";
- if (!overall_coeff.is_equal(_ex1())) {
+ if (!overall_coeff.is_equal(_ex1)) {
overall_coeff.print(c, precedence());
c.s << "*";
}
while (it != itend) {
// If the first argument is a negative integer power, it gets printed as "1.0/<expr>"
- if (it == seq.begin() && ex_to<numeric>(it->coeff).is_integer() && it->coeff.compare(_num0()) < 0) {
+ if (it == seq.begin() && ex_to<numeric>(it->coeff).is_integer() && it->coeff.compare(_num0) < 0) {
if (is_a<print_csrc_cl_N>(c))
c.s << "recip(";
else
}
// If the exponent is 1 or -1, it is left out
- if (it->coeff.compare(_ex1()) == 0 || it->coeff.compare(_num_1()) == 0)
+ if (it->coeff.compare(_ex1) == 0 || it->coeff.compare(_num_1) == 0)
it->rest.print(c, precedence());
else {
// Outer parens around ex needed for broken gcc-2.95 parser:
// Separator is "/" for negative integer powers, "*" otherwise
++it;
if (it != itend) {
- if (ex_to<numeric>(it->coeff).is_integer() && it->coeff.compare(_num0()) < 0)
+ if (ex_to<numeric>(it->coeff).is_integer() && it->coeff.compare(_num0) < 0)
c.s << "/";
else
c.s << "*";
numeric coeff = ex_to<numeric>(overall_coeff);
if (coeff.csgn() == -1)
c.s << '-';
- if (!coeff.is_equal(_num1()) &&
- !coeff.is_equal(_num_1())) {
+ if (!coeff.is_equal(_num1) &&
+ !coeff.is_equal(_num_1)) {
if (coeff.is_rational()) {
if (coeff.is_negative())
(-coeff).print(c);
return (new mul(coeffseq))->setflag(status_flags::dynallocated);
}
- return _ex0();
+ return _ex0;
}
/** Perform automatic term rewriting rules in this class. In the following
if (flags & status_flags::evaluated) {
GINAC_ASSERT(seq.size()>0);
- GINAC_ASSERT(seq.size()>1 || !overall_coeff.is_equal(_ex1()));
+ GINAC_ASSERT(seq.size()>1 || !overall_coeff.is_equal(_ex1));
return *this;
}
int seq_size = seq.size();
if (overall_coeff.is_zero()) {
// *(...,x;0) -> 0
- return _ex0();
+ return _ex0;
} else if (seq_size==0) {
// *(;c) -> c
return overall_coeff;
- } else if (seq_size==1 && overall_coeff.is_equal(_ex1())) {
+ } else if (seq_size==1 && overall_coeff.is_equal(_ex1)) {
// *(x;1) -> x
return recombine_pair_to_ex(*(seq.begin()));
} else if ((seq_size==1) &&
is_ex_exactly_of_type((*seq.begin()).rest,add) &&
- ex_to<numeric>((*seq.begin()).coeff).is_equal(_num1())) {
+ ex_to<numeric>((*seq.begin()).coeff).is_equal(_num1)) {
// *(+(x,y,...);c) -> +(*(x,c),*(y,c),...) (c numeric(), no powers of +())
const add & addref = ex_to<add>((*seq.begin()).rest);
epvector *distrseq = new epvector();
ex mul::evalm(void) const
{
// numeric*matrix
- if (seq.size() == 1 && seq[0].coeff.is_equal(_ex1())
+ if (seq.size() == 1 && seq[0].coeff.is_equal(_ex1)
&& is_ex_of_type(seq[0].rest, matrix))
return ex_to<matrix>(seq[0].rest).mul(ex_to<numeric>(overall_coeff));
epvector::const_iterator i = seq.begin(), end = seq.end();
epvector::iterator i2 = mulseq.begin();
while (i != end) {
- expair ep = split_ex_to_pair(power(i->rest, i->coeff - _ex1()) *
+ expair ep = split_ex_to_pair(power(i->rest, i->coeff - _ex1) *
i->rest.diff(s));
ep.swap(*i2);
addseq.push_back((new mul(mulseq, overall_coeff * i->coeff))->setflag(status_flags::dynallocated));
if (is_ex_exactly_of_type(powerref.exponent,numeric))
return expair(powerref.basis,powerref.exponent);
}
- return expair(e,_ex1());
+ return expair(e,_ex1);
}
expair mul::combine_ex_with_coeff_to_pair(const ex & e,
// we create a temporary power object
// otherwise it would be hard to correctly simplify
// expression like (4^(1/3))^(3/2)
- if (are_ex_trivially_equal(c,_ex1()))
+ if (are_ex_trivially_equal(c,_ex1))
return split_ex_to_pair(e);
return split_ex_to_pair(power(e,c));
// we create a temporary power object
// otherwise it would be hard to correctly simplify
// expression like (4^(1/3))^(3/2)
- if (are_ex_trivially_equal(c,_ex1()))
+ if (are_ex_trivially_equal(c,_ex1))
return p;
return split_ex_to_pair(power(recombine_pair_to_ex(p),c));
ex mul::recombine_pair_to_ex(const expair & p) const
{
- if (ex_to<numeric>(p.coeff).is_equal(_num1()))
+ if (ex_to<numeric>(p.coeff).is_equal(_num1))
return p.rest;
else
return power(p.rest,p.coeff);
*it = ep;
return true;
}
- if (ex_to<numeric>((*it).coeff).is_equal(_num1())) {
+ if (ex_to<numeric>((*it).coeff).is_equal(_num1)) {
// combined pair has coeff 1 and must be moved to the end
return true;
}
ex mul::default_overall_coeff(void) const
{
- return _ex1();
+ return _ex1;
}
void mul::combine_overall_coeff(const ex & c)
// this assertion will probably fail somewhere
// it would require a more careful make_flat, obeying the power laws
// probably should return true only if p.coeff is integer
- return ex_to<numeric>(p.coeff).is_equal(_num1());
+ return ex_to<numeric>(p.coeff).is_equal(_num1);
}
ex mul::expand(unsigned options) const
// with the next one that is found while collecting the factors which are
// not sums
int number_of_adds = 0;
- ex last_expanded = _ex1();
+ ex last_expanded = _ex1;
epvector non_adds;
non_adds.reserve(expanded_seq.size());
epvector::const_iterator cit = expanded_seq.begin(), last = expanded_seq.end();
while (cit != last) {
if (is_ex_exactly_of_type(cit->rest, add) &&
- (cit->coeff.is_equal(_ex1()))) {
+ (cit->coeff.is_equal(_ex1))) {
++number_of_adds;
if (is_ex_exactly_of_type(last_expanded, add)) {
const add & add1 = ex_to<add>(last_expanded);
if (coeff_found) return (new ncmul(coeffseq,1))->setflag(status_flags::dynallocated);
- return _ex0();
+ return _ex0;
}
unsigned ncmul::count_factors(const ex & e) const
if (assocseq.size()==1) return *(seq.begin());
// ncmul() -> 1
- if (assocseq.empty()) return _ex1();
+ if (assocseq.empty()) return _ex1;
// determine return types
unsignedvector rettypes;
ex simplified_ncmul(const exvector & v)
{
if (v.empty())
- return _ex1();
+ return _ex1;
else if (v.size() == 1)
return v[0];
else
if (e.info(info_flags::rational))
return lcm(ex_to<numeric>(e).denom(), l);
else if (is_ex_exactly_of_type(e, add)) {
- numeric c = _num1();
+ numeric c = _num1;
for (unsigned i=0; i<e.nops(); i++)
c = lcmcoeff(e.op(i), c);
return lcm(c, l);
} else if (is_ex_exactly_of_type(e, mul)) {
- numeric c = _num1();
+ numeric c = _num1;
for (unsigned i=0; i<e.nops(); i++)
- c *= lcmcoeff(e.op(i), _num1());
+ c *= lcmcoeff(e.op(i), _num1);
return lcm(c, l);
} else if (is_ex_exactly_of_type(e, power)) {
if (is_ex_exactly_of_type(e.op(0), symbol))
* @return LCM of denominators of coefficients */
static numeric lcm_of_coefficients_denominators(const ex &e)
{
- return lcmcoeff(e, _num1());
+ return lcmcoeff(e, _num1);
}
/** Bring polynomial from Q[X] to Z[X] by multiplying in the previously
if (is_ex_exactly_of_type(e, mul)) {
unsigned num = e.nops();
exvector v; v.reserve(num + 1);
- numeric lcm_accum = _num1();
+ numeric lcm_accum = _num1;
for (unsigned i=0; i<e.nops(); i++) {
- numeric op_lcm = lcmcoeff(e.op(i), _num1());
+ numeric op_lcm = lcmcoeff(e.op(i), _num1);
v.push_back(multiply_lcm(e.op(i), op_lcm));
lcm_accum *= op_lcm;
}
numeric basic::integer_content(void) const
{
- return _num1();
+ return _num1;
}
numeric numeric::integer_content(void) const
{
epvector::const_iterator it = seq.begin();
epvector::const_iterator itend = seq.end();
- numeric c = _num0();
+ numeric c = _num0;
while (it != itend) {
GINAC_ASSERT(!is_exactly_a<numeric>(it->rest));
GINAC_ASSERT(is_exactly_a<numeric>(it->coeff));
return a / b;
#if FAST_COMPARE
if (a.is_equal(b))
- return _ex1();
+ return _ex1;
#endif
if (check_args && (!a.info(info_flags::rational_polynomial) || !b.info(info_flags::rational_polynomial)))
throw(std::invalid_argument("quo: arguments must be polynomials over the rationals"));
throw(std::overflow_error("rem: division by zero"));
if (is_ex_exactly_of_type(a, numeric)) {
if (is_ex_exactly_of_type(b, numeric))
- return _ex0();
+ return _ex0;
else
return a;
}
#if FAST_COMPARE
if (a.is_equal(b))
- return _ex0();
+ return _ex0;
#endif
if (check_args && (!a.info(info_flags::rational_polynomial) || !b.info(info_flags::rational_polynomial)))
throw(std::invalid_argument("rem: arguments must be polynomials over the rationals"));
throw(std::overflow_error("prem: division by zero"));
if (is_ex_exactly_of_type(a, numeric)) {
if (is_ex_exactly_of_type(b, numeric))
- return _ex0();
+ return _ex0;
else
return b;
}
if (bdeg <= rdeg) {
blcoeff = eb.coeff(x, bdeg);
if (bdeg == 0)
- eb = _ex0();
+ eb = _ex0;
else
eb -= blcoeff * power(x, bdeg);
} else
- blcoeff = _ex1();
+ blcoeff = _ex1;
int delta = rdeg - bdeg + 1, i = 0;
while (rdeg >= bdeg && !r.is_zero()) {
ex rlcoeff = r.coeff(x, rdeg);
ex term = (power(x, rdeg - bdeg) * eb * rlcoeff).expand();
if (rdeg == 0)
- r = _ex0();
+ r = _ex0;
else
r -= rlcoeff * power(x, rdeg);
r = (blcoeff * r).expand() - term;
throw(std::overflow_error("prem: division by zero"));
if (is_ex_exactly_of_type(a, numeric)) {
if (is_ex_exactly_of_type(b, numeric))
- return _ex0();
+ return _ex0;
else
return b;
}
if (bdeg <= rdeg) {
blcoeff = eb.coeff(x, bdeg);
if (bdeg == 0)
- eb = _ex0();
+ eb = _ex0;
else
eb -= blcoeff * power(x, bdeg);
} else
- blcoeff = _ex1();
+ blcoeff = _ex1;
while (rdeg >= bdeg && !r.is_zero()) {
ex rlcoeff = r.coeff(x, rdeg);
ex term = (power(x, rdeg - bdeg) * eb * rlcoeff).expand();
if (rdeg == 0)
- r = _ex0();
+ r = _ex0;
else
r -= rlcoeff * power(x, rdeg);
r = (blcoeff * r).expand() - term;
* "false" otherwise */
bool divide(const ex &a, const ex &b, ex &q, bool check_args)
{
- q = _ex0();
+ q = _ex0;
if (b.is_zero())
throw(std::overflow_error("divide: division by zero"));
if (a.is_zero())
return false;
#if FAST_COMPARE
if (a.is_equal(b)) {
- q = _ex1();
+ q = _ex1;
return true;
}
#endif
* @see get_symbol_stats, heur_gcd */
static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_iterator var)
{
- q = _ex0();
+ q = _ex0;
if (b.is_zero())
throw(std::overflow_error("divide_in_z: division by zero"));
- if (b.is_equal(_ex1())) {
+ if (b.is_equal(_ex1)) {
q = a;
return true;
}
}
#if FAST_COMPARE
if (a.is_equal(b)) {
- q = _ex1();
+ q = _ex1;
return true;
}
#endif
// Compute values at evaluation points 0..adeg
vector<numeric> alpha; alpha.reserve(adeg + 1);
exvector u; u.reserve(adeg + 1);
- numeric point = _num0();
+ numeric point = _num0;
ex c;
for (i=0; i<=adeg; i++) {
ex bs = b.subs(*x == point);
while (bs.is_zero()) {
- point += _num1();
+ point += _num1;
bs = b.subs(*x == point);
}
if (!divide_in_z(a.subs(*x == point), bs, c, var+1))
return false;
alpha.push_back(point);
u.push_back(c);
- point += _num1();
+ point += _num1;
}
// Compute inverses
vector<numeric> rcp; rcp.reserve(adeg + 1);
- rcp.push_back(_num0());
+ rcp.push_back(_num0);
for (k=1; k<=adeg; k++) {
numeric product = alpha[k] - alpha[0];
for (i=1; i<k; i++)
{
ex c = expand().lcoeff(x);
if (is_ex_exactly_of_type(c, numeric))
- return c < _ex0() ? _ex_1() : _ex1();
+ return c < _ex0 ? _ex_1 : _ex1;
else {
const symbol *y;
if (get_first_symbol(c, y))
ex ex::content(const symbol &x) const
{
if (is_zero())
- return _ex0();
+ return _ex0;
if (is_ex_exactly_of_type(*this, numeric))
return info(info_flags::negative) ? -*this : *this;
ex e = expand();
if (e.is_zero())
- return _ex0();
+ return _ex0;
// First, try the integer content
ex c = e.integer_content();
int ldeg = e.ldegree(x);
if (deg == ldeg)
return e.lcoeff(x) / e.unit(x);
- c = _ex0();
+ c = _ex0;
for (int i=ldeg; i<=deg; i++)
c = gcd(e.coeff(x, i), c, NULL, NULL, false);
return c;
ex ex::primpart(const symbol &x) const
{
if (is_zero())
- return _ex0();
+ return _ex0;
if (is_ex_exactly_of_type(*this, numeric))
- return _ex1();
+ return _ex1;
ex c = content(x);
if (c.is_zero())
- return _ex0();
+ return _ex0;
ex u = unit(x);
if (is_ex_exactly_of_type(c, numeric))
return *this / (c * u);
ex ex::primpart(const symbol &x, const ex &c) const
{
if (is_zero())
- return _ex0();
+ return _ex0;
if (c.is_zero())
- return _ex0();
+ return _ex0;
if (is_ex_exactly_of_type(*this, numeric))
- return _ex1();
+ return _ex1;
ex u = unit(x);
if (is_ex_exactly_of_type(c, numeric))
d = d.primpart(*x, cont_d);
// First element of divisor sequence
- ex r, ri = _ex1();
+ ex r, ri = _ex1;
int delta = cdeg - ddeg;
for (;;) {
//std::clog << " content " << gamma << " removed, continuing with sr_gcd(" << c << "," << d << ")\n";
// First element of subresultant sequence
- ex r = _ex0(), ri = _ex1(), psi = _ex1();
+ ex r = _ex0, ri = _ex1, psi = _ex1;
int delta = cdeg - ddeg;
for (;;) {
* @see heur_gcd */
numeric basic::max_coefficient(void) const
{
- return _num1();
+ return _num1;
}
numeric numeric::max_coefficient(void) const
numeric mq = q.max_coefficient();
numeric xi;
if (mp > mq)
- xi = mq * _num2() + _num2();
+ xi = mq * _num2 + _num2;
else
- xi = mp * _num2() + _num2();
+ xi = mp * _num2 + _num2;
// 6 tries maximum
for (int t=0; t<6; t++) {
if (ca || cb) {
if (g.is_zero()) {
if (ca)
- *ca = _ex0();
+ *ca = _ex0;
if (cb)
- *cb = _ex0();
+ *cb = _ex0;
} else {
if (ca)
*ca = ex_to<numeric>(a) / g;
ex exp_a = a.op(1), exp_b = b.op(1);
if (exp_a < exp_b) {
if (ca)
- *ca = _ex1();
+ *ca = _ex1;
if (cb)
*cb = power(p, exp_b - exp_a);
return power(p, exp_a);
if (ca)
*ca = power(p, exp_a - exp_b);
if (cb)
- *cb = _ex1();
+ *cb = _ex1;
return power(p, exp_b);
}
}
if (ca)
*ca = power(p, a.op(1) - 1);
if (cb)
- *cb = _ex1();
+ *cb = _ex1;
return p;
}
}
if (p.is_equal(a)) {
// a = p, b = p^n, gcd = p
if (ca)
- *ca = _ex1();
+ *ca = _ex1;
if (cb)
*cb = power(p, b.op(1) - 1);
return p;
ex aex = a.expand(), bex = b.expand();
if (aex.is_zero()) {
if (ca)
- *ca = _ex0();
+ *ca = _ex0;
if (cb)
- *cb = _ex1();
+ *cb = _ex1;
return b;
}
if (bex.is_zero()) {
if (ca)
- *ca = _ex1();
+ *ca = _ex1;
if (cb)
- *cb = _ex0();
+ *cb = _ex0;
return a;
}
- if (aex.is_equal(_ex1()) || bex.is_equal(_ex1())) {
+ if (aex.is_equal(_ex1) || bex.is_equal(_ex1)) {
if (ca)
*ca = a;
if (cb)
*cb = b;
- return _ex1();
+ return _ex1;
}
#if FAST_COMPARE
if (a.is_equal(b)) {
if (ca)
- *ca = _ex1();
+ *ca = _ex1;
if (cb)
- *cb = _ex1();
+ *cb = _ex1;
return a;
}
#endif
// g = peu_gcd(aex, bex, &x);
// g = red_gcd(aex, bex, &x);
g = sr_gcd(aex, bex, var);
- if (g.is_equal(_ex1())) {
+ if (g.is_equal(_ex1)) {
// Keep cofactors factored if possible
if (ca)
*ca = a;
}
#if 1
} else {
- if (g.is_equal(_ex1())) {
+ if (g.is_equal(_ex1)) {
// Keep cofactors factored if possible
if (ca)
*ca = a;
ex w = a;
ex z = w.diff(x);
ex g = gcd(w, z);
- if (g.is_equal(_ex1())) {
+ if (g.is_equal(_ex1)) {
res.push_back(a);
return res;
}
lst args;
if (l.nops()==0) {
sym_desc_vec sdv;
- get_symbol_stats(a, _ex0(), sdv);
+ get_symbol_stats(a, _ex0, sdv);
sym_desc_vec::const_iterator it = sdv.begin(), itend = sdv.end();
while (it != itend) {
args.append(*it->sym);
}
// Done with recursion, now construct the final result
- ex result = _ex1();
+ ex result = _ex1;
exvector::const_iterator it = factors.begin(), itend = factors.end();
for (int p = 1; it!=itend; ++it, ++p)
result *= power(*it, p);
exvector factor; factor.reserve(num_yun);
exvector cofac; cofac.reserve(num_yun);
for (unsigned i=0; i<num_yun; i++) {
- if (!yun[i].is_equal(_ex1())) {
+ if (!yun[i].is_equal(_ex1)) {
for (unsigned j=0; j<=i; j++) {
factor.push_back(pow(yun[i], j+1));
- ex prod = _ex1();
+ ex prod = _ex1;
for (unsigned k=0; k<num_yun; k++) {
if (k == i)
prod *= pow(yun[k], i-j);
ex basic::normal(lst &sym_lst, lst &repl_lst, int level) const
{
if (nops() == 0)
- return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
else {
if (level == 1)
- return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
else if (level == -max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
else {
normal_map_function map_normal(level - 1);
- return (new lst(replace_with_symbol(map(map_normal), sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(map(map_normal), sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
}
}
}
* @see ex::normal */
ex symbol::normal(lst &sym_lst, lst &repl_lst, int level) const
{
- return (new lst(*this, _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(*this, _ex1))->setflag(status_flags::dynallocated);
}
{
ex num = n;
ex den = d;
- numeric pre_factor = _num1();
+ numeric pre_factor = _num1;
//std::clog << "frac_cancel num = " << num << ", den = " << den << std::endl;
// Handle trivial case where denominator is 1
- if (den.is_equal(_ex1()))
+ if (den.is_equal(_ex1))
return (new lst(num, den))->setflag(status_flags::dynallocated);
// Handle special cases where numerator or denominator is 0
if (num.is_zero())
- return (new lst(num, _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(num, _ex1))->setflag(status_flags::dynallocated);
if (den.expand().is_zero())
throw(std::overflow_error("frac_cancel: division by zero in frac_cancel"));
// Cancel GCD from numerator and denominator
ex cnum, cden;
- if (gcd(num, den, &cnum, &cden, false) != _ex1()) {
+ if (gcd(num, den, &cnum, &cden, false) != _ex1) {
num = cnum;
den = cden;
}
if (get_first_symbol(den, x)) {
GINAC_ASSERT(is_exactly_a<numeric>(den.unit(*x)));
if (ex_to<numeric>(den.unit(*x)).is_negative()) {
- num *= _ex_1();
- den *= _ex_1();
+ num *= _ex_1;
+ den *= _ex_1;
}
}
ex add::normal(lst &sym_lst, lst &repl_lst, int level) const
{
if (level == 1)
- return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
else if (level == -max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
ex mul::normal(lst &sym_lst, lst &repl_lst, int level) const
{
if (level == 1)
- return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
else if (level == -max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
ex power::normal(lst &sym_lst, lst &repl_lst, int level) const
{
if (level == 1)
- return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(*this, sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
else if (level == -max_recursion_level)
throw(std::runtime_error("max recursion level reached"));
if (n_exponent.info(info_flags::positive)) {
// (a/b)^x -> {sym((a/b)^x), 1}
- return (new lst(replace_with_symbol(power(n_basis.op(0) / n_basis.op(1), n_exponent), sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(power(n_basis.op(0) / n_basis.op(1), n_exponent), sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
} else if (n_exponent.info(info_flags::negative)) {
- if (n_basis.op(1).is_equal(_ex1())) {
+ if (n_basis.op(1).is_equal(_ex1)) {
// a^-x -> {1, sym(a^x)}
- return (new lst(_ex1(), replace_with_symbol(power(n_basis.op(0), -n_exponent), sym_lst, repl_lst)))->setflag(status_flags::dynallocated);
+ return (new lst(_ex1, replace_with_symbol(power(n_basis.op(0), -n_exponent), sym_lst, repl_lst)))->setflag(status_flags::dynallocated);
} else {
// (a/b)^-x -> {sym((b/a)^x), 1}
- return (new lst(replace_with_symbol(power(n_basis.op(1) / n_basis.op(0), -n_exponent), sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(power(n_basis.op(1) / n_basis.op(0), -n_exponent), sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
}
} else { // n_exponent not numeric
// (a/b)^x -> {sym((a/b)^x, 1}
- return (new lst(replace_with_symbol(power(n_basis.op(0) / n_basis.op(1), n_exponent), sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(power(n_basis.op(0) / n_basis.op(1), n_exponent), sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
}
}
}
++i;
}
ex n = pseries(relational(var,point), newseq);
- return (new lst(replace_with_symbol(n, sym_lst, repl_lst), _ex1()))->setflag(status_flags::dynallocated);
+ return (new lst(replace_with_symbol(n, sym_lst, repl_lst), _ex1))->setflag(status_flags::dynallocated);
}
if (oc.info(info_flags::numeric))
return thisexpairseq(s, overall_coeff);
else
- s.push_back(combine_ex_with_coeff_to_pair(oc, _ex1()));
+ s.push_back(combine_ex_with_coeff_to_pair(oc, _ex1));
return thisexpairseq(s, default_overall_coeff());
}
std::ios::fmtflags oldflags = c.s.flags();
c.s.setf(std::ios::scientific);
if (this->is_rational() && !this->is_integer()) {
- if (compare(_num0()) > 0) {
+ if (compare(_num0) > 0) {
c.s << "(";
if (is_a<print_csrc_cl_N>(c))
c.s << "cln::cl_F(\"" << numer().evalf() << "\")";
const numeric numeric::add(const numeric &other) const
{
// Efficiency shortcut: trap the neutral element by pointer.
- static const numeric * _num0p = &_num0();
- if (this==_num0p)
+ if (this==_num0_p)
return other;
- else if (&other==_num0p)
+ else if (&other==_num0_p)
return *this;
return numeric(cln::the<cln::cl_N>(value)+cln::the<cln::cl_N>(other.value));
const numeric numeric::mul(const numeric &other) const
{
// Efficiency shortcut: trap the neutral element by pointer.
- static const numeric * _num1p = &_num1();
- if (this==_num1p)
+ if (this==_num1_p)
return other;
- else if (&other==_num1p)
+ else if (&other==_num1_p)
return *this;
return numeric(cln::the<cln::cl_N>(value)*cln::the<cln::cl_N>(other.value));
const numeric numeric::power(const numeric &other) const
{
// Efficiency shortcut: trap the neutral exponent by pointer.
- static const numeric * _num1p = &_num1();
- if (&other==_num1p)
+ if (&other==_num1_p)
return *this;
if (cln::zerop(cln::the<cln::cl_N>(value))) {
else if (cln::minusp(cln::realpart(cln::the<cln::cl_N>(other.value))))
throw std::overflow_error("numeric::eval(): division by zero");
else
- return _num0();
+ return _num0;
}
return numeric(cln::expt(cln::the<cln::cl_N>(value),cln::the<cln::cl_N>(other.value)));
}
const numeric &numeric::add_dyn(const numeric &other) const
{
// Efficiency shortcut: trap the neutral element by pointer.
- static const numeric * _num0p = &_num0();
- if (this==_num0p)
+ if (this==_num0_p)
return other;
- else if (&other==_num0p)
+ else if (&other==_num0_p)
return *this;
return static_cast<const numeric &>((new numeric(cln::the<cln::cl_N>(value)+cln::the<cln::cl_N>(other.value)))->
const numeric &numeric::mul_dyn(const numeric &other) const
{
// Efficiency shortcut: trap the neutral element by pointer.
- static const numeric * _num1p = &_num1();
- if (this==_num1p)
+ if (this==_num1_p)
return other;
- else if (&other==_num1p)
+ else if (&other==_num1_p)
return *this;
return static_cast<const numeric &>((new numeric(cln::the<cln::cl_N>(value)*cln::the<cln::cl_N>(other.value)))->
const numeric &numeric::power_dyn(const numeric &other) const
{
// Efficiency shortcut: trap the neutral exponent by pointer.
- static const numeric * _num1p=&_num1();
- if (&other==_num1p)
+ if (&other==_num1_p)
return *this;
if (cln::zerop(cln::the<cln::cl_N>(value))) {
else if (cln::minusp(cln::realpart(cln::the<cln::cl_N>(other.value))))
throw std::overflow_error("numeric::eval(): division by zero");
else
- return _num0();
+ return _num0;
}
return static_cast<const numeric &>((new numeric(cln::expt(cln::the<cln::cl_N>(value),cln::the<cln::cl_N>(other.value))))->
setflag(status_flags::dynallocated));
const numeric numeric::denom(void) const
{
if (this->is_integer())
- return _num1();
+ return _num1;
if (cln::instanceof(value, cln::cl_RA_ring))
return numeric(cln::denominator(cln::the<cln::cl_RA>(value)));
const cln::cl_RA r = cln::the<cln::cl_RA>(cln::realpart(cln::the<cln::cl_N>(value)));
const cln::cl_RA i = cln::the<cln::cl_RA>(cln::imagpart(cln::the<cln::cl_N>(value)));
if (cln::instanceof(r, cln::cl_I_ring) && cln::instanceof(i, cln::cl_I_ring))
- return _num1();
+ return _num1;
if (cln::instanceof(r, cln::cl_I_ring) && cln::instanceof(i, cln::cl_RA_ring))
return numeric(cln::denominator(i));
if (cln::instanceof(r, cln::cl_RA_ring) && cln::instanceof(i, cln::cl_I_ring))
return numeric(cln::lcm(cln::denominator(r), cln::denominator(i)));
}
// at least one float encountered
- return _num1();
+ return _num1;
}
{
if (!x.is_real() &&
x.real().is_zero() &&
- abs(x.imag()).is_equal(_num1()))
+ abs(x.imag()).is_equal(_num1))
throw pole_error("atan(): logarithmic pole",0);
return cln::atan(x.to_cl_N());
}
const numeric Li2(const numeric &x)
{
if (x.is_zero())
- return _num0();
+ return _num0;
// what is the desired float format?
// first guess: default format
* @exception range_error (argument must be integer >= -1) */
const numeric doublefactorial(const numeric &n)
{
- if (n.is_equal(_num_1()))
- return _num1();
+ if (n.is_equal(_num_1))
+ return _num1;
if (!n.is_nonneg_integer())
throw std::range_error("numeric::doublefactorial(): argument must be integer >= -1");
{
if (n.is_integer() && k.is_integer()) {
if (n.is_nonneg_integer()) {
- if (k.compare(n)!=1 && k.compare(_num0())!=-1)
+ if (k.compare(n)!=1 && k.compare(_num0)!=-1)
return numeric(cln::binomial(n.to_int(),k.to_int()));
else
- return _num0();
+ return _num0;
} else {
- return _num_1().power(k)*binomial(k-n-_num1(),k);
+ return _num_1.power(k)*binomial(k-n-_num1,k);
}
}
// we don't use it.)
// the special cases not covered by the algorithm below
- if (nn.is_equal(_num1()))
- return _num_1_2();
+ if (nn.is_equal(_num1))
+ return _num_1_2;
if (nn.is_odd())
- return _num0();
+ return _num0;
// store nonvanishing Bernoulli numbers here
static std::vector< cln::cl_RA > results;
// hence
// F(2n+2) = F(n+1)*(2*F(n) + F(n+1))
if (n.is_zero())
- return _num0();
+ return _num0;
if (n.is_negative())
if (n.is_even())
return -fibonacci(-n);
return cln::mod(cln::the<cln::cl_I>(a.to_cl_N()),
cln::the<cln::cl_I>(b.to_cl_N()));
else
- return _num0();
+ return _num0;
}
return cln::mod(cln::the<cln::cl_I>(a.to_cl_N()) + b2,
cln::the<cln::cl_I>(b.to_cl_N())) - b2;
} else
- return _num0();
+ return _num0;
}
return cln::rem(cln::the<cln::cl_I>(a.to_cl_N()),
cln::the<cln::cl_I>(b.to_cl_N()));
else
- return _num0();
+ return _num0;
}
q = rem_quo.quotient;
return rem_quo.remainder;
} else {
- q = _num0();
- return _num0();
+ q = _num0;
+ return _num0;
}
}
return cln::truncate1(cln::the<cln::cl_I>(a.to_cl_N()),
cln::the<cln::cl_I>(b.to_cl_N()));
else
- return _num0();
+ return _num0;
}
r = rem_quo.remainder;
return rem_quo.quotient;
} else {
- r = _num0();
- return _num0();
+ r = _num0;
+ return _num0;
}
}
return cln::gcd(cln::the<cln::cl_I>(a.to_cl_N()),
cln::the<cln::cl_I>(b.to_cl_N()));
else
- return _num1();
+ return _num1;
}
cln::isqrt(cln::the<cln::cl_I>(x.to_cl_N()), &root);
return root;
} else
- return _num0();
+ return _num0;
}
protected:
/** Implementation of ex::diff for a numeric always returns 0.
* @see ex::diff */
- ex derivative(const symbol &s) const { return _ex0(); }
+ ex derivative(const symbol &s) const { return 0; }
bool is_equal_same_type(const basic &other) const;
unsigned calchash(void) const;
/** Used internally by operator-() and friends to change the sign of an argument. */
static inline const ex exminus(const ex & lh)
{
- return (new mul(lh,_ex_1()))->setflag(status_flags::dynallocated);
+ return (new mul(lh,_ex_1))->setflag(status_flags::dynallocated);
}
// binary arithmetic operators ex with ex
const ex operator/(const ex & lh, const ex & rh)
{
debugmsg("operator/(ex,ex)",LOGLEVEL_OPERATOR);
- return exmul(lh, power(rh,_ex_1()));
+ return exmul(lh, power(rh,_ex_1));
}
ex & operator/=(ex & lh, const ex & rh)
{
debugmsg("operator/=(ex,ex)",LOGLEVEL_OPERATOR);
- return lh = exmul(lh, power(rh,_ex_1()));
+ return lh = exmul(lh, power(rh,_ex_1));
}
const numeric operator-(const numeric & lh)
{
debugmsg("operator-(numeric)",LOGLEVEL_OPERATOR);
- return _num_1().mul(lh);
+ return _num_1.mul(lh);
}
ex & operator++(ex & rh)
{
debugmsg("operator++(ex)",LOGLEVEL_OPERATOR);
- return rh = exadd(rh, _ex1());
+ return rh = exadd(rh, _ex1);
}
/** Expression prefix decrement. Subtracts 1 and returns decremented ex. */
ex & operator--(ex & rh)
{
debugmsg("operator--(ex)",LOGLEVEL_OPERATOR);
- return rh = exadd(rh, _ex_1());
+ return rh = exadd(rh, _ex_1);
}
/** Expression postfix increment. Returns the ex and leaves the original
{
debugmsg("operator++(ex,int)",LOGLEVEL_OPERATOR);
ex tmp(lh);
- lh = exadd(lh, _ex1());
+ lh = exadd(lh, _ex1);
return tmp;
}
{
debugmsg("operator--(ex,int)",LOGLEVEL_OPERATOR);
ex tmp(lh);
- lh = exadd(lh, _ex_1());
+ lh = exadd(lh, _ex_1);
return tmp;
}
numeric& operator++(numeric & rh)
{
debugmsg("operator++(numeric)",LOGLEVEL_OPERATOR);
- rh = rh.add(_num1());
+ rh = rh.add(_num1);
return rh;
}
numeric& operator--(numeric & rh)
{
debugmsg("operator--(numeric)",LOGLEVEL_OPERATOR);
- rh = rh.add(_num_1());
+ rh = rh.add(_num_1);
return rh;
}
{
debugmsg("operator++(numeric,int)",LOGLEVEL_OPERATOR);
numeric tmp(lh);
- lh = lh.add(_num1());
+ lh = lh.add(_num1);
return tmp;
}
{
debugmsg("operator--(numeric,int)",LOGLEVEL_OPERATOR);
numeric tmp(lh);
- lh = lh.add(_num_1());
+ lh = lh.add(_num_1);
return tmp;
}
c.s << ')';
// <expr>^-1 is printed as "1.0/<expr>" or with the recip() function of CLN
- } else if (exponent.compare(_num_1()) == 0) {
+ } else if (exponent.compare(_num_1) == 0) {
if (is_a<print_csrc_cl_N>(c))
c.s << "recip(";
else
} else {
- if (exponent.is_equal(_ex1_2())) {
+ if (exponent.is_equal(_ex1_2)) {
if (is_a<print_latex>(c))
c.s << "\\sqrt{";
else
if (n == 0)
return *this;
else
- return _ex0();
+ return _ex0;
} else {
// basis equal to s
if (is_ex_exactly_of_type(exponent, numeric) && ex_to<numeric>(exponent).is_integer()) {
// integer exponent
int int_exp = ex_to<numeric>(exponent).to_int();
if (n == int_exp)
- return _ex1();
+ return _ex1;
else
- return _ex0();
+ return _ex0;
} else {
// non-integer exponents are treated as zero
if (n == 0)
return *this;
else
- return _ex0();
+ return _ex0;
}
}
}
if (ebasis.is_zero())
throw (std::domain_error("power::eval(): pow(0,0) is undefined"));
else
- return _ex1();
+ return _ex1;
}
// ^(x,1) -> x
- if (eexponent.is_equal(_ex1()))
+ if (eexponent.is_equal(_ex1))
return ebasis;
// ^(0,c1) -> 0 or exception (depending on real value of c1)
else if ((num_exponent->real()).is_negative())
throw (pole_error("power::eval(): division by zero",1));
else
- return _ex0();
+ return _ex0;
}
// ^(1,x) -> 1
- if (ebasis.is_equal(_ex1()))
- return _ex1();
+ if (ebasis.is_equal(_ex1))
+ return _ex1;
if (exponent_is_numerical) {
if (is_ex_exactly_of_type(sub_exponent,numeric)) {
const numeric & num_sub_exponent = ex_to<numeric>(sub_exponent);
GINAC_ASSERT(num_sub_exponent!=numeric(1));
- if (num_exponent->is_integer() || (abs(num_sub_exponent) - _num1()).is_negative())
+ if (num_exponent->is_integer() || (abs(num_sub_exponent) - _num1).is_negative())
return power(sub_basis,num_sub_exponent.mul(*num_exponent));
}
}
if (is_ex_exactly_of_type(ebasis,mul)) {
GINAC_ASSERT(!num_exponent->is_integer()); // should have been handled above
const mul & mulref = ex_to<mul>(ebasis);
- if (!mulref.overall_coeff.is_equal(_ex1())) {
+ if (!mulref.overall_coeff.is_equal(_ex1)) {
const numeric & num_coeff = ex_to<numeric>(mulref.overall_coeff);
if (num_coeff.is_real()) {
if (num_coeff.is_positive()) {
mul *mulp = new mul(mulref);
- mulp->overall_coeff = _ex1();
+ mulp->overall_coeff = _ex1;
mulp->clearflag(status_flags::evaluated);
mulp->clearflag(status_flags::hash_calculated);
return (new mul(power(*mulp,exponent),
power(num_coeff,*num_exponent)))->setflag(status_flags::dynallocated);
} else {
- GINAC_ASSERT(num_coeff.compare(_num0())<0);
- if (num_coeff.compare(_num_1())!=0) {
+ GINAC_ASSERT(num_coeff.compare(_num0)<0);
+ if (!num_coeff.is_equal(_num_1)) {
mul *mulp = new mul(mulref);
- mulp->overall_coeff = _ex_1();
+ mulp->overall_coeff = _ex_1;
mulp->clearflag(status_flags::evaluated);
mulp->clearflag(status_flags::hash_calculated);
return (new mul(power(*mulp,exponent),
// D(b^r) = r * b^(r-1) * D(b) (faster than the formula below)
epvector newseq;
newseq.reserve(2);
- newseq.push_back(expair(basis, exponent - _ex1()));
- newseq.push_back(expair(basis.diff(s), _ex1()));
+ newseq.push_back(expair(basis, exponent - _ex1));
+ newseq.push_back(expair(basis.diff(s), _ex1));
return mul(newseq, exponent);
} else {
// D(b^e) = b^e * (D(e)*ln(b) + e*D(b)/b)
return mul(*this,
add(mul(exponent.diff(s), log(basis)),
- mul(mul(exponent, basis.diff(s)), power(basis, _ex_1()))));
+ mul(mul(exponent, basis.diff(s)), power(basis, _ex_1))));
}
}
!is_exactly_a<mul>(ex_to<power>(r).basis) ||
!is_exactly_a<power>(ex_to<power>(r).basis));
- if (are_ex_trivially_equal(c,_ex1())) {
+ if (are_ex_trivially_equal(c,_ex1)) {
if (is_ex_exactly_of_type(r,mul)) {
- sum.push_back(expair(expand_mul(ex_to<mul>(r),_num2()),
- _ex1()));
+ sum.push_back(expair(expand_mul(ex_to<mul>(r),_num2),
+ _ex1));
} else {
- sum.push_back(expair((new power(r,_ex2()))->setflag(status_flags::dynallocated),
- _ex1()));
+ sum.push_back(expair((new power(r,_ex2))->setflag(status_flags::dynallocated),
+ _ex1));
}
} else {
if (is_ex_exactly_of_type(r,mul)) {
- sum.push_back(expair(expand_mul(ex_to<mul>(r),_num2()),
- ex_to<numeric>(c).power_dyn(_num2())));
+ sum.push_back(expair(expand_mul(ex_to<mul>(r),_num2),
+ ex_to<numeric>(c).power_dyn(_num2)));
} else {
- sum.push_back(expair((new power(r,_ex2()))->setflag(status_flags::dynallocated),
- ex_to<numeric>(c).power_dyn(_num2())));
+ sum.push_back(expair((new power(r,_ex2))->setflag(status_flags::dynallocated),
+ ex_to<numeric>(c).power_dyn(_num2)));
}
}
const ex & r1 = cit1->rest;
const ex & c1 = cit1->coeff;
sum.push_back(a.combine_ex_with_coeff_to_pair((new mul(r,r1))->setflag(status_flags::dynallocated),
- _num2().mul(ex_to<numeric>(c)).mul_dyn(ex_to<numeric>(c1))));
+ _num2.mul(ex_to<numeric>(c)).mul_dyn(ex_to<numeric>(c1))));
}
}
if (!a.overall_coeff.is_zero()) {
epvector::const_iterator i = a.seq.begin(), end = a.seq.end();
while (i != end) {
- sum.push_back(a.combine_pair_with_coeff_to_pair(*i, ex_to<numeric>(a.overall_coeff).mul_dyn(_num2())));
+ sum.push_back(a.combine_pair_with_coeff_to_pair(*i, ex_to<numeric>(a.overall_coeff).mul_dyn(_num2)));
++i;
}
- sum.push_back(expair(ex_to<numeric>(a.overall_coeff).power_dyn(_num2()),_ex1()));
+ sum.push_back(expair(ex_to<numeric>(a.overall_coeff).power_dyn(_num2),_ex1));
}
GINAC_ASSERT(sum.size()==(a_nops*(a_nops+1))/2);
ex power::expand_mul(const mul & m, const numeric & n) const
{
if (n.is_zero())
- return _ex1();
+ return _ex1;
epvector distrseq;
distrseq.reserve(m.seq.size());
return (new mul(distrseq,ex_to<numeric>(m.overall_coeff).power_dyn(n)))->setflag(status_flags::dynallocated);
}
-// helper function
-
-ex sqrt(const ex & a)
-{
- return power(a,_ex1_2());
-}
-
} // namespace GiNaC
}
/** Square root expression. Returns a power-object with exponent 1/2. */
-ex sqrt(const ex & a);
+inline ex sqrt(const ex & a)
+{
+ extern const ex _ex1_2;
+ return power(a,_ex1_2);
+}
} // namespace GiNaC
/** Construct pseries from a vector of coefficients and powers.
* expair.rest holds the coefficient, expair.coeff holds the power.
* The powers must be integers (positive or negative) and in ascending order;
- * the last coefficient can be Order(_ex1()) to represent a truncated,
+ * the last coefficient can be Order(_ex1) to represent a truncated,
* non-terminating series.
*
* @param rel_ expansion variable and point (must hold a relational)
c.s << par_close;
} else
var.print(c);
- if (i->coeff.compare(_ex1())) {
+ if (i->coeff.compare(_ex1)) {
c.s << '^';
if (i->coeff.info(info_flags::negative)) {
c.s << par_open;
{
if (var.is_equal(s)) {
if (seq.empty())
- return _ex0();
+ return _ex0;
// Binary search in sequence for given power
numeric looking_for = numeric(n);
throw(std::logic_error("pseries::coeff: compare() didn't return -1, 0 or 1"));
}
}
- return _ex0();
+ return _ex0;
} else
return convert_to_poly().coeff(s, n);
}
const symbol &s = ex_to<symbol>(r.lhs());
if (!coeff.is_zero())
- seq.push_back(expair(coeff, _ex0()));
+ seq.push_back(expair(coeff, _ex0));
int n;
for (n=1; n<order; ++n) {
// Higher-order terms, if present
deriv = deriv.diff(s);
if (!deriv.expand().is_zero())
- seq.push_back(expair(Order(_ex1()), n));
+ seq.push_back(expair(Order(_ex1), n));
return pseries(r, seq);
}
if (this->is_equal_same_type(ex_to<symbol>(r.lhs()))) {
if (order > 0 && !point.is_zero())
- seq.push_back(expair(point, _ex0()));
+ seq.push_back(expair(point, _ex0));
if (order > 1)
- seq.push_back(expair(_ex1(), _ex1()));
+ seq.push_back(expair(_ex1, _ex1));
else
- seq.push_back(expair(Order(_ex1()), numeric(order)));
+ seq.push_back(expair(Order(_ex1), numeric(order)));
} else
- seq.push_back(expair(*this, _ex0()));
+ seq.push_back(expair(*this, _ex0));
return pseries(r, seq);
}
// results in an empty (constant) series
if (!is_compatible_to(other)) {
epvector nul;
- nul.push_back(expair(Order(_ex1()), _ex0()));
+ nul.push_back(expair(Order(_ex1), _ex0));
return pseries(relational(var,point), nul);
}
} else {
// Add coefficient of a and b
if (is_order_function((*a).rest) || is_order_function((*b).rest)) {
- new_seq.push_back(expair(Order(_ex1()), (*a).coeff));
+ new_seq.push_back(expair(Order(_ex1), (*a).coeff));
break; // Order term ends the sequence
} else {
ex sum = (*a).rest + (*b).rest;
op = it->rest;
else
op = it->rest.series(r, order, options);
- if (!it->coeff.is_equal(_ex1()))
+ if (!it->coeff.is_equal(_ex1))
op = ex_to<pseries>(op).mul_const(ex_to<numeric>(it->coeff));
// Series addition
// results in an empty (constant) series
if (!is_compatible_to(other)) {
epvector nul;
- nul.push_back(expair(Order(_ex1()), _ex0()));
+ nul.push_back(expair(Order(_ex1), _ex0));
return pseries(relational(var,point), nul);
}
cdeg_max = higher_order_c - 1;
for (int cdeg=cdeg_min; cdeg<=cdeg_max; ++cdeg) {
- ex co = _ex0();
+ ex co = _ex0;
// c(i)=a(0)b(i)+...+a(i)b(0)
for (int i=a_min; cdeg-i>=b_min; ++i) {
ex a_coeff = coeff(var, i);
new_seq.push_back(expair(co, numeric(cdeg)));
}
if (higher_order_c < INT_MAX)
- new_seq.push_back(expair(Order(_ex1()), numeric(higher_order_c)));
+ new_seq.push_back(expair(Order(_ex1), numeric(higher_order_c)));
return pseries(relational(var, point), new_seq);
}
co.push_back(power(coeff(var, ldeg), p));
bool all_sums_zero = true;
for (int i=1; i<deg; ++i) {
- ex sum = _ex0();
+ ex sum = _ex0;
for (int j=1; j<=i; ++j) {
ex c = coeff(var, j + ldeg);
if (is_order_function(c)) {
- co.push_back(Order(_ex1()));
+ co.push_back(Order(_ex1));
break;
} else
sum += (p * j - (i - j)) * co[i - j] * c;
}
}
if (!higher_order && !all_sums_zero)
- new_seq.push_back(expair(Order(_ex1()), p * ldeg + deg));
+ new_seq.push_back(expair(Order(_ex1), p * ldeg + deg));
return pseries(relational(var,point), new_seq);
}
if (basis.is_equal(r.lhs() - r.rhs())) {
epvector new_seq;
if (ex_to<numeric>(exponent).to_int() < order)
- new_seq.push_back(expair(_ex1(), exponent));
+ new_seq.push_back(expair(_ex1, exponent));
else
- new_seq.push_back(expair(Order(_ex1()), exponent));
+ new_seq.push_back(expair(Order(_ex1), exponent));
return pseries(r, new_seq);
}
while (it != itend) {
int o = ex_to<numeric>(it->coeff).to_int();
if (o >= order) {
- new_seq.push_back(expair(Order(_ex1()), o));
+ new_seq.push_back(expair(Order(_ex1), o));
break;
}
new_seq.push_back(*it);
if (is_ex_exactly_of_type(r,relational))
rel_ = ex_to<relational>(r);
else if (is_ex_exactly_of_type(r,symbol))
- rel_ = relational(r,_ex0());
+ rel_ = relational(r,_ex0);
else
throw (std::logic_error("ex::series(): expansion point has unknown type"));
case not_equal:
return !ex_to<numeric>(df).is_zero();
case less:
- return ex_to<numeric>(df)<_num0();
+ return ex_to<numeric>(df)<_num0;
case less_or_equal:
- return ex_to<numeric>(df)<=_num0();
+ return ex_to<numeric>(df)<=_num0;
case greater:
- return ex_to<numeric>(df)>_num0();
+ return ex_to<numeric>(df)>_num0;
case greater_or_equal:
- return ex_to<numeric>(df)>=_num0();
+ return ex_to<numeric>(df)>=_num0;
default:
throw(std::logic_error("invalid relational operator"));
}
ex symbol::coeff(const ex & s, int n) const
{
if (is_equal(ex_to<basic>(s)))
- return n==1 ? _ex1() : _ex0();
+ return n==1 ? _ex1 : _ex0;
else
- return n==0 ? *this : _ex0();
+ return n==0 ? *this : _ex0;
}
ex symbol::eval(int level) const
ex symbol::derivative(const symbol & s) const
{
if (compare_same_type(s))
- return _ex0();
+ return _ex0;
else
- return _ex1();
+ return _ex1;
}
int symbol::compare_same_type(const basic & other) const
{
if (asexinfop->is_assigned) {
asexinfop->is_assigned = 0;
- asexinfop->assigned_expression = _ex0();
+ asexinfop->assigned_expression = _ex0;
}
setflag(status_flags::evaluated | status_flags::expanded);
}
if (static_cast<const indexed &>(i).all_index_values_are(info_flags::integer)) {
int n1 = ex_to<numeric>(i1.get_value()).to_int(), n2 = ex_to<numeric>(i2.get_value()).to_int();
if (n1 == n2)
- return _ex1();
+ return _ex1;
else
- return _ex0();
+ return _ex0;
}
// No further simplifications
if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
int n1 = ex_to<numeric>(i1.get_value()).to_int(), n2 = ex_to<numeric>(i2.get_value()).to_int();
if (n1 != n2)
- return _ex0();
+ return _ex0;
else if (n1 == 0)
- return pos_sig ? _ex_1() : _ex1();
+ return pos_sig ? _ex_1 : _ex1;
else
- return pos_sig ? _ex1() : _ex_1();
+ return pos_sig ? _ex1 : _ex_1;
}
// Perform the usual evaluations of a metric tensor
// Convolutions are zero
if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
- return _ex0();
+ return _ex0;
// Numeric evaluation
if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
int n1 = ex_to<numeric>(i1.get_value()).to_int(), n2 = ex_to<numeric>(i2.get_value()).to_int();
if (n1 == n2)
- return _ex0();
+ return _ex0;
else if (n1 < n2)
- return _ex1();
+ return _ex1;
else
- return _ex_1();
+ return _ex_1;
}
// No further simplifications
// Convolutions are zero
if (!(static_cast<const indexed &>(i).get_dummy_indices().empty()))
- return _ex0();
+ return _ex0;
// Numeric evaluation
if (static_cast<const indexed &>(i).all_index_values_are(info_flags::nonnegint)) {
// Contraction found, remove delta tensor and substitute
// index in second object
- *self = _ex1();
+ *self = _ex1;
*other = other->subs(other_idx == *free_idx);
return true;
}
// Contraction found, remove metric tensor and substitute
// index in second object
- *self = _ex1();
+ *self = _ex1;
*other = other->subs(other_idx == *free_idx);
return true;
}
if (is_dummy_pair(self_i1, other_i1)) {
if (is_dummy_pair(self_i2, other_i2))
- *self = _ex2();
+ *self = _ex2;
else
*self = delta_tensor(self_i2, other_i2);
- *other = _ex1();
+ *other = _ex1;
return true;
} else if (is_dummy_pair(self_i1, other_i2)) {
if (is_dummy_pair(self_i2, other_i1))
- *self = _ex_2();
+ *self = _ex_2;
else
*self = -delta_tensor(self_i2, other_i1);
- *other = _ex1();
+ *other = _ex1;
return true;
} else if (is_dummy_pair(self_i2, other_i1)) {
*self = -delta_tensor(self_i1, other_i2);
- *other = _ex1();
+ *other = _ex1;
return true;
} else if (is_dummy_pair(self_i2, other_i2)) {
*self = delta_tensor(self_i1, other_i1);
- *other = _ex1();
+ *other = _ex1;
return true;
}
}
}
int sign = minkowski ? -1 : 1;
*self = sign * M.determinant().simplify_indexed();
- *other = _ex1();
+ *other = _ex1;
return true;
} else if (other->return_type() == return_types::commutative) {
} else {
// Yes, the contraction is zero
- *self = _ex0();
- *other = _ex0();
+ *self = _ex0;
+ *other = _ex0;
return true;
}
}
ex dim = ex_to<idx>(i1).get_dim();
if (!dim.is_equal(ex_to<idx>(i2).get_dim()))
throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension"));
- if (!ex_to<idx>(i1).get_dim().is_equal(_ex2()))
+ if (!ex_to<idx>(i1).get_dim().is_equal(_ex2))
throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
return indexed(tensepsilon(), sy_anti(), i1, i2);
ex dim = ex_to<idx>(i1).get_dim();
if (!dim.is_equal(ex_to<idx>(i2).get_dim()) || !dim.is_equal(ex_to<idx>(i3).get_dim()))
throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension"));
- if (!ex_to<idx>(i1).get_dim().is_equal(_ex3()))
+ if (!ex_to<idx>(i1).get_dim().is_equal(_ex3))
throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
return indexed(tensepsilon(), sy_anti(), i1, i2, i3);
ex dim = ex_to<idx>(i1).get_dim();
if (!dim.is_equal(ex_to<idx>(i2).get_dim()) || !dim.is_equal(ex_to<idx>(i3).get_dim()) || !dim.is_equal(ex_to<idx>(i4).get_dim()))
throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension"));
- if (!ex_to<idx>(i1).get_dim().is_equal(_ex4()))
+ if (!ex_to<idx>(i1).get_dim().is_equal(_ex4))
throw(std::runtime_error("index dimension of epsilon tensor must match number of indices"));
return indexed(tensepsilon(true, pos_sig), sy_anti(), i1, i2, i3, i4);
}
#endif
+
//////////
-// `construct on first use' chest of numbers
+// flyweight chest of numbers is initialized here:
//////////
-// numeric -120
-const numeric & _num_120(void)
-{
- const static ex e = ex(numeric(-120));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_120(void)
-{
- static ex * e = new ex(_num_120());
- return *e;
-}
-
-// numeric -60
-const numeric & _num_60(void)
-{
- const static ex e = ex(numeric(-60));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_60(void)
-{
- static ex * e = new ex(_num_60());
- return *e;
-}
-
-// numeric -48
-const numeric & _num_48(void)
-{
- const static ex e = ex(numeric(-48));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_48(void)
-{
- static ex * e = new ex(_num_48());
- return *e;
-}
-
-// numeric -30
-const numeric & _num_30(void)
-{
- const static ex e = ex(numeric(-30));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_30(void)
-{
- static ex * e = new ex(_num_30());
- return *e;
-}
-
-// numeric -25
-const numeric & _num_25(void)
-{
- const static ex e = ex(numeric(-25));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_25(void)
-{
- static ex * e = new ex(_num_25());
- return *e;
-}
-
-// numeric -24
-const numeric & _num_24(void)
-{
- const static ex e = ex(numeric(-24));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_24(void)
-{
- static ex * e = new ex(_num_24());
- return *e;
-}
-
-// numeric -20
-const numeric & _num_20(void)
-{
- const static ex e = ex(numeric(-20));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_20(void)
-{
- static ex * e = new ex(_num_20());
- return *e;
-}
-
-// numeric -18
-const numeric & _num_18(void)
-{
- const static ex e = ex(numeric(-18));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_18(void)
-{
- static ex * e = new ex(_num_18());
- return *e;
-}
-
-// numeric -15
-const numeric & _num_15(void)
-{
- const static ex e = ex(numeric(-15));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_15(void)
-{
- static ex * e = new ex(_num_15());
- return *e;
-}
-
-// numeric -12
-const numeric & _num_12(void)
-{
- const static ex e = ex(numeric(-12));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_12(void)
-{
- static ex * e = new ex(_num_12());
- return *e;
-}
-
-// numeric -11
-const numeric & _num_11(void)
-{
- const static ex e = ex(numeric(-11));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_11(void)
-{
- static ex * e = new ex(_num_11());
- return *e;
-}
-
-// numeric -10
-const numeric & _num_10(void)
-{
- const static ex e = ex(numeric(-10));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_10(void)
-{
- static ex * e = new ex(_num_10());
- return *e;
-}
-
-// numeric -9
-const numeric & _num_9(void)
-{
- const static ex e = ex(numeric(-9));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_9(void)
-{
- static ex * e = new ex(_num_9());
- return *e;
-}
-
-// numeric -8
-const numeric & _num_8(void)
-{
- const static ex e = ex(numeric(-8));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_8(void)
-{
- static ex * e = new ex(_num_8());
- return *e;
-}
-
-// numeric -7
-const numeric & _num_7(void)
-{
- const static ex e = ex(numeric(-7));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_7(void)
-{
- static ex * e = new ex(_num_7());
- return *e;
-}
-
-// numeric -6
-const numeric & _num_6(void)
-{
- const static ex e = ex(numeric(-6));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_6(void)
-{
- static ex * e = new ex(_num_6());
- return *e;
-}
-
-// numeric -5
-const numeric & _num_5(void)
-{
- const static ex e = ex(numeric(-5));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_5(void)
-{
- static ex * e = new ex(_num_5());
- return *e;
-}
-
-// numeric -4
-const numeric & _num_4(void)
-{
- const static ex e = ex(numeric(-4));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_4(void)
-{
- static ex * e = new ex(_num_4());
- return *e;
-}
-
-// numeric -3
-const numeric & _num_3(void)
-{
- const static ex e = ex(numeric(-3));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_3(void)
-{
- static ex * e = new ex(_num_3());
- return *e;
-}
-
-// numeric -2
-const numeric & _num_2(void)
-{
- const static ex e = ex(numeric(-2));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_2(void)
-{
- static ex * e = new ex(_num_2());
- return *e;
-}
-
-// numeric -1
-const numeric & _num_1(void)
-{
- const static ex e = ex(numeric(-1));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_1(void)
-{
- static ex * e = new ex(_num_1());
- return *e;
-}
-
-// numeric -1/2
-const numeric & _num_1_2(void)
-{
- const static ex e = ex(numeric(-1,2));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_1_2(void)
-{
- static ex * e = new ex(_num_1_2());
- return *e;
-}
-
-// numeric -1/3
-const numeric & _num_1_3(void)
-{
- const static ex e = ex(numeric(-1,3));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_1_3(void)
-{
- static ex * e = new ex(_num_1_3());
- return *e;
-}
-
-// numeric -1/4
-const numeric & _num_1_4(void)
-{
- const static ex e = ex(numeric(-1,4));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex_1_4(void)
-{
- static ex * e = new ex(_num_1_4());
- return *e;
-}
-
-// numeric 0
-const numeric & _num0(void)
-{
- const static ex e = ex(numeric(0));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex0(void)
-{
- static ex * e = new ex(_num0());
- return *e;
-}
-
-// numeric 1/4
-const numeric & _num1_4(void)
-{
- const static ex e = ex(numeric(1,4));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex1_4(void)
-{
- static ex * e = new ex(_num1_4());
- return *e;
-}
-
-// numeric 1/3
-const numeric & _num1_3(void)
-{
- const static ex e = ex(numeric(1,3));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex1_3(void)
-{
- static ex * e = new ex(_num1_3());
- return *e;
-}
-
-// numeric 1/2
-const numeric & _num1_2(void)
-{
- const static ex e = ex(numeric(1,2));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex1_2(void)
-{
- static ex * e = new ex(_num1_2());
- return *e;
-}
-
-// numeric 1
-const numeric & _num1(void)
-{
- const static ex e = ex(numeric(1));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex1(void)
-{
- static ex * e = new ex(_num1());
- return *e;
-}
-
-// numeric 2
-const numeric & _num2(void)
-{
- const static ex e = ex(numeric(2));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex2(void)
-{
- static ex * e = new ex(_num2());
- return *e;
-}
-
-// numeric 3
-const numeric & _num3(void)
-{
- const static ex e = ex(numeric(3));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex3(void)
-{
- static ex * e = new ex(_num3());
- return *e;
-}
-
-// numeric 4
-const numeric & _num4(void)
-{
- const static ex e = ex(numeric(4));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex4(void)
-{
- static ex * e = new ex(_num4());
- return *e;
-}
-
-// numeric 5
-const numeric & _num5(void)
-{
- const static ex e = ex(numeric(5));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex5(void)
-{
- static ex * e = new ex(_num5());
- return *e;
-}
-
-// numeric 6
-const numeric & _num6(void)
-{
- const static ex e = ex(numeric(6));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex6(void)
-{
- static ex * e = new ex(_num6());
- return *e;
-}
-
-// numeric 7
-const numeric & _num7(void)
-{
- const static ex e = ex(numeric(7));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex7(void)
-{
- static ex * e = new ex(_num7());
- return *e;
-}
-
-// numeric 8
-const numeric & _num8(void)
-{
- const static ex e = ex(numeric(8));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex8(void)
-{
- static ex * e = new ex(_num8());
- return *e;
-}
-
-// numeric 9
-const numeric & _num9(void)
-{
- const static ex e = ex(numeric(9));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex9(void)
-{
- static ex * e = new ex(_num9());
- return *e;
-}
-
-// numeric 10
-const numeric & _num10(void)
-{
- const static ex e = ex(numeric(10));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex10(void)
-{
- static ex * e = new ex(_num10());
- return *e;
-}
-
-// numeric 11
-const numeric & _num11(void)
-{
- const static ex e = ex(numeric(11));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex11(void)
-{
- static ex * e = new ex(_num11());
- return *e;
-}
-
-// numeric 12
-const numeric & _num12(void)
-{
- const static ex e = ex(numeric(12));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex12(void)
-{
- static ex * e = new ex(_num12());
- return *e;
-}
-
-// numeric 15
-const numeric & _num15(void)
-{
- const static ex e = ex(numeric(15));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex15(void)
-{
- static ex * e = new ex(_num15());
- return *e;
-}
-
-// numeric 18
-const numeric & _num18(void)
-{
- const static ex e = ex(numeric(18));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex18(void)
-{
- static ex * e = new ex(_num18());
- return *e;
-}
-
-// numeric 20
-const numeric & _num20(void)
-{
- const static ex e = ex(numeric(20));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex20(void)
-{
- static ex * e = new ex(_num20());
- return *e;
-}
-
-// numeric 24
-const numeric & _num24(void)
-{
- const static ex e = ex(numeric(24));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex24(void)
-{
- static ex * e = new ex(_num24());
- return *e;
-}
-
-// numeric 25
-const numeric & _num25(void)
-{
- const static ex e = ex(numeric(25));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex25(void)
-{
- static ex * e = new ex(_num25());
- return *e;
-}
-
-// numeric 30
-const numeric & _num30(void)
-{
- const static ex e = ex(numeric(30));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex30(void)
-{
- static ex * e = new ex(_num30());
- return *e;
-}
-
-// numeric 48
-const numeric & _num48(void)
-{
- const static ex e = ex(numeric(48));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex48(void)
-{
- static ex * e = new ex(_num48());
- return *e;
-}
-
-// numeric 60
-const numeric & _num60(void)
-{
- const static ex e = ex(numeric(60));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex60(void)
-{
- static ex * e = new ex(_num60());
- return *e;
-}
-
-// numeric 120
-const numeric & _num120(void)
-{
- const static ex e = ex(numeric(120));
- const static numeric &n = ex_to<numeric>(e);
- return n;
-}
-
-const ex & _ex120(void)
-{
- static ex * e = new ex(_num120());
- return *e;
+/** How many static objects were created? Only the first one must create
+ * the static flyweights on the heap. */
+int library_init::count = 0;
+
+// static numeric -120
+const numeric *_num_120_p;
+const numeric &_num_120 = *_num_120_p;
+const ex _ex_120 = _num_120;
+
+// static numeric -60
+const numeric *_num_60_p;
+const numeric &_num_60 = *_num_60_p;
+const ex _ex_60 = _num_60;
+
+// static numeric -48
+const numeric *_num_48_p;
+const numeric &_num_48 = *_num_48_p;
+const ex _ex_48 = _num_48;
+
+// static numeric -30
+const numeric *_num_30_p;
+const numeric &_num_30 = *_num_30_p;
+const ex _ex_30 = _num_30;
+
+// static numeric -25
+const numeric *_num_25_p;
+const numeric &_num_25 = *_num_25_p;
+const ex _ex_25 = _num_25;
+
+// static numeric -24
+const numeric *_num_24_p;
+const numeric &_num_24 = *_num_24_p;
+const ex _ex_24 = _num_24;
+
+// static numeric -20
+const numeric *_num_20_p;
+const numeric &_num_20 = *_num_20_p;
+const ex _ex_20 = _num_20;
+
+// static numeric -18
+const numeric *_num_18_p;
+const numeric &_num_18 = *_num_18_p;
+const ex _ex_18 = _num_18;
+
+// static numeric -15
+const numeric *_num_15_p;
+const numeric &_num_15 = *_num_15_p;
+const ex _ex_15 = _num_15;
+
+// static numeric -12
+const numeric *_num_12_p;
+const numeric &_num_12 = *_num_12_p;
+const ex _ex_12 = _num_12;
+
+// static numeric -11
+const numeric *_num_11_p;
+const numeric &_num_11 = *_num_11_p;
+const ex _ex_11 = _num_11;
+
+// static numeric -10
+const numeric *_num_10_p;
+const numeric &_num_10 = *_num_10_p;
+const ex _ex_10 = _num_10;
+
+// static numeric -9
+const numeric *_num_9_p;
+const numeric &_num_9 = *_num_9_p;
+const ex _ex_9 = _num_9;
+
+// static numeric -8
+const numeric *_num_8_p;
+const numeric &_num_8 = *_num_8_p;
+const ex _ex_8 = _num_8;
+
+// static numeric -7
+const numeric *_num_7_p;
+const numeric &_num_7 = *_num_7_p;
+const ex _ex_7 = _num_7;
+
+// static numeric -6
+const numeric *_num_6_p;
+const numeric &_num_6 = *_num_6_p;
+const ex _ex_6 = _num_6;
+
+// static numeric -5
+const numeric *_num_5_p;
+const numeric &_num_5 = *_num_5_p;
+const ex _ex_5 = _num_5;
+
+// static numeric -4
+const numeric *_num_4_p;
+const numeric &_num_4 = *_num_4_p;
+const ex _ex_4 = _num_4;
+
+// static numeric -3
+const numeric *_num_3_p;
+const numeric &_num_3 = *_num_3_p;
+const ex _ex_3 = _num_3;
+
+// static numeric -2
+const numeric *_num_2_p;
+const numeric &_num_2 = *_num_2_p;
+const ex _ex_2 = _num_2;
+
+// static numeric -1
+const numeric *_num_1_p;
+const numeric &_num_1 = *_num_1_p;
+const ex _ex_1 = _num_1;
+
+// static numeric -1/2
+const numeric *_num_1_2_p;
+const numeric &_num_1_2= *_num_1_2_p;
+const ex _ex_1_2= _num_1_2;
+
+// static numeric -1/3
+const numeric *_num_1_3_p;
+const numeric &_num_1_3= *_num_1_3_p;
+const ex _ex_1_3= _num_1_3;
+
+// static numeric -1/4
+const numeric *_num_1_4_p;
+const numeric &_num_1_4= *_num_1_4_p;
+const ex _ex_1_4= _num_1_4;
+
+// static numeric 0
+const numeric *_num0_p;
+const numeric &_num0 = *_num0_p;
+const ex _ex0 = _num0;
+
+// static numeric 1/4
+const numeric *_num1_4_p;
+const numeric &_num1_4 = *_num1_4_p;
+const ex _ex1_4 = _num1_4;
+
+// static numeric 1/3
+const numeric *_num1_3_p;
+const numeric &_num1_3 = *_num1_3_p;
+const ex _ex1_3 = _num1_3;
+
+// static numeric 1/2
+const numeric *_num1_2_p;
+const numeric &_num1_2 = *_num1_2_p;
+const ex _ex1_2 = _num1_2;
+
+// static numeric 1
+const numeric *_num1_p;
+const numeric &_num1 = *_num1_p;
+const ex _ex1 = _num1;
+
+// static numeric 2
+const numeric *_num2_p;
+const numeric &_num2 = *_num2_p;
+const ex _ex2 = _num2;
+
+// static numeric 3
+const numeric *_num3_p;
+const numeric &_num3 = *_num3_p;
+const ex _ex3 = _num3;
+
+// static numeric 4
+const numeric *_num4_p;
+const numeric &_num4 = *_num4_p;
+const ex _ex4 = _num4;
+
+// static numeric 5
+const numeric *_num5_p;
+const numeric &_num5 = *_num5_p;
+const ex _ex5 = _num5;
+
+// static numeric 6
+const numeric *_num6_p;
+const numeric &_num6 = *_num6_p;
+const ex _ex6 = _num6;
+
+// static numeric 7
+const numeric *_num7_p;
+const numeric &_num7 = *_num7_p;
+const ex _ex7 = _num7;
+
+// static numeric 8
+const numeric *_num8_p;
+const numeric &_num8 = *_num8_p;
+const ex _ex8 = _num8;
+
+// static numeric 9
+const numeric *_num9_p;
+const numeric &_num9 = *_num9_p;
+const ex _ex9 = _num9;
+
+// static numeric 10
+const numeric *_num10_p;
+const numeric &_num10 = *_num10_p;
+const ex _ex10 = _num10;
+
+// static numeric 11
+const numeric *_num11_p;
+const numeric &_num11 = *_num11_p;
+const ex _ex11 = _num11;
+
+// static numeric 12
+const numeric *_num12_p;
+const numeric &_num12 = *_num12_p;
+const ex _ex12 = _num12;
+
+// static numeric 15
+const numeric *_num15_p;
+const numeric &_num15 = *_num15_p;
+const ex _ex15 = _num15;
+
+// static numeric 18
+const numeric *_num18_p;
+const numeric &_num18 = *_num18_p;
+const ex _ex18 = _num18;
+
+// static numeric 20
+const numeric *_num20_p;
+const numeric &_num20 = *_num20_p;
+const ex _ex20 = _num20;
+
+// static numeric 24
+const numeric *_num24_p;
+const numeric &_num24 = *_num24_p;
+const ex _ex24 = _num24;
+
+// static numeric 25
+const numeric *_num25_p;
+const numeric &_num25 = *_num25_p;
+const ex _ex25 = _num25;
+
+// static numeric 30
+const numeric *_num30_p;
+const numeric &_num30 = *_num30_p;
+const ex _ex30 = _num30;
+
+// static numeric 48
+const numeric *_num48_p;
+const numeric &_num48 = *_num48_p;
+const ex _ex48 = _num48;
+
+// static numeric 60
+const numeric *_num60_p;
+const numeric &_num60 = *_num60_p;
+const ex _ex60 = _num60;
+
+// static numeric 120
+const numeric *_num120_p;
+const numeric &_num120 = *_num120_p;
+const ex _ex120 = _num120;
+
+/** Ctor of static initialization helpers. The fist call to this is going
+ * to initialize the library, the others do nothing. */
+library_init::library_init()
+{
+ if (count++==0) {
+ _num_120_p= reinterpret_cast<const numeric*>(&((new numeric(-120))->setflag(status_flags::dynallocated)));
+ _num_60_p = reinterpret_cast<const numeric*>(&((new numeric(-60))->setflag(status_flags::dynallocated)));
+ _num_48_p = reinterpret_cast<const numeric*>(&((new numeric(-48))->setflag(status_flags::dynallocated)));
+ _num_30_p = reinterpret_cast<const numeric*>(&((new numeric(-30))->setflag(status_flags::dynallocated)));
+ _num_25_p = reinterpret_cast<const numeric*>(&((new numeric(-25))->setflag(status_flags::dynallocated)));
+ _num_24_p = reinterpret_cast<const numeric*>(&((new numeric(-24))->setflag(status_flags::dynallocated)));
+ _num_20_p = reinterpret_cast<const numeric*>(&((new numeric(-20))->setflag(status_flags::dynallocated)));
+ _num_18_p = reinterpret_cast<const numeric*>(&((new numeric(-18))->setflag(status_flags::dynallocated)));
+ _num_15_p = reinterpret_cast<const numeric*>(&((new numeric(-15))->setflag(status_flags::dynallocated)));
+ _num_12_p = reinterpret_cast<const numeric*>(&((new numeric(-12))->setflag(status_flags::dynallocated)));
+ _num_11_p = reinterpret_cast<const numeric*>(&((new numeric(-11))->setflag(status_flags::dynallocated)));
+ _num_10_p = reinterpret_cast<const numeric*>(&((new numeric(-10))->setflag(status_flags::dynallocated)));
+ _num_9_p = reinterpret_cast<const numeric*>(&((new numeric(-9))->setflag(status_flags::dynallocated)));
+ _num_8_p = reinterpret_cast<const numeric*>(&((new numeric(-8))->setflag(status_flags::dynallocated)));
+ _num_7_p = reinterpret_cast<const numeric*>(&((new numeric(-7))->setflag(status_flags::dynallocated)));
+ _num_6_p = reinterpret_cast<const numeric*>(&((new numeric(-6))->setflag(status_flags::dynallocated)));
+ _num_5_p = reinterpret_cast<const numeric*>(&((new numeric(-5))->setflag(status_flags::dynallocated)));
+ _num_4_p = reinterpret_cast<const numeric*>(&((new numeric(-4))->setflag(status_flags::dynallocated)));
+ _num_3_p = reinterpret_cast<const numeric*>(&((new numeric(-3))->setflag(status_flags::dynallocated)));
+ _num_2_p = reinterpret_cast<const numeric*>(&((new numeric(-2))->setflag(status_flags::dynallocated)));
+ _num_1_p = reinterpret_cast<const numeric*>(&((new numeric(-1))->setflag(status_flags::dynallocated)));
+ _num_1_2_p= reinterpret_cast<const numeric*>(&((new numeric(-1,2))->setflag(status_flags::dynallocated)));
+ _num_1_3_p= reinterpret_cast<const numeric*>(&((new numeric(-1,3))->setflag(status_flags::dynallocated)));
+ _num_1_4_p= reinterpret_cast<const numeric*>(&((new numeric(-1,4))->setflag(status_flags::dynallocated)));
+ _num0_p = reinterpret_cast<const numeric*>(&((new numeric(0))->setflag(status_flags::dynallocated)));
+ _num1_4_p = reinterpret_cast<const numeric*>(&((new numeric(1,4))->setflag(status_flags::dynallocated)));
+ _num1_3_p = reinterpret_cast<const numeric*>(&((new numeric(1,3))->setflag(status_flags::dynallocated)));
+ _num1_2_p = reinterpret_cast<const numeric*>(&((new numeric(1,2))->setflag(status_flags::dynallocated)));
+ _num1_p = reinterpret_cast<const numeric*>(&((new numeric(1))->setflag(status_flags::dynallocated)));
+ _num2_p = reinterpret_cast<const numeric*>(&((new numeric(2))->setflag(status_flags::dynallocated)));
+ _num3_p = reinterpret_cast<const numeric*>(&((new numeric(3))->setflag(status_flags::dynallocated)));
+ _num4_p = reinterpret_cast<const numeric*>(&((new numeric(4))->setflag(status_flags::dynallocated)));
+ _num5_p = reinterpret_cast<const numeric*>(&((new numeric(5))->setflag(status_flags::dynallocated)));
+ _num6_p = reinterpret_cast<const numeric*>(&((new numeric(6))->setflag(status_flags::dynallocated)));
+ _num7_p = reinterpret_cast<const numeric*>(&((new numeric(7))->setflag(status_flags::dynallocated)));
+ _num8_p = reinterpret_cast<const numeric*>(&((new numeric(8))->setflag(status_flags::dynallocated)));
+ _num9_p = reinterpret_cast<const numeric*>(&((new numeric(9))->setflag(status_flags::dynallocated)));
+ _num10_p = reinterpret_cast<const numeric*>(&((new numeric(10))->setflag(status_flags::dynallocated)));
+ _num11_p = reinterpret_cast<const numeric*>(&((new numeric(11))->setflag(status_flags::dynallocated)));
+ _num12_p = reinterpret_cast<const numeric*>(&((new numeric(12))->setflag(status_flags::dynallocated)));
+ _num15_p = reinterpret_cast<const numeric*>(&((new numeric(15))->setflag(status_flags::dynallocated)));
+ _num18_p = reinterpret_cast<const numeric*>(&((new numeric(18))->setflag(status_flags::dynallocated)));
+ _num20_p = reinterpret_cast<const numeric*>(&((new numeric(20))->setflag(status_flags::dynallocated)));
+ _num24_p = reinterpret_cast<const numeric*>(&((new numeric(24))->setflag(status_flags::dynallocated)));
+ _num25_p = reinterpret_cast<const numeric*>(&((new numeric(25))->setflag(status_flags::dynallocated)));
+ _num30_p = reinterpret_cast<const numeric*>(&((new numeric(30))->setflag(status_flags::dynallocated)));
+ _num48_p = reinterpret_cast<const numeric*>(&((new numeric(48))->setflag(status_flags::dynallocated)));
+ _num60_p = reinterpret_cast<const numeric*>(&((new numeric(60))->setflag(status_flags::dynallocated)));
+ _num120_p = reinterpret_cast<const numeric*>(&((new numeric(120))->setflag(status_flags::dynallocated)));
+ }
+}
+
+
+/** Dtor of static initialization helpers. The last call to this is going
+ * to shut down the library, the others do nothing. */
+library_init::~library_init()
+{
+ if (--count==0) {
+ // In theory, we would have to clean up here. But since we were
+ // only initializing memory in the ctor and that memory is reclaimed
+ // anyways by the OS when the program exits, we skip this.
+ }
}
// comment skeleton for header files
class numeric;
class ex;
-const numeric & _num_120(void); // -120
-const ex & _ex_120(void);
-const numeric & _num_60(void); // -60
-const ex & _ex_60(void);
-const numeric & _num_48(void); // -48
-const ex & _ex_48(void);
-const numeric & _num_30(void); // -30
-const ex & _ex_30(void);
-const numeric & _num_25(void); // -25
-const ex & _ex_25(void);
-const numeric & _num_24(void); // -24
-const ex & _ex_24(void);
-const numeric & _num_20(void); // -20
-const ex & _ex_20(void);
-const numeric & _num_18(void); // -18
-const ex & _ex_18(void);
-const numeric & _num_15(void); // -15
-const ex & _ex_15(void);
-const numeric & _num_12(void); // -12
-const ex & _ex_12(void);
-const numeric & _num_11(void); // -11
-const ex & _ex_11(void);
-const numeric & _num_10(void); // -10
-const ex & _ex_10(void);
-const numeric & _num_9(void); // -9
-const ex & _ex_9(void);
-const numeric & _num_8(void); // -8
-const ex & _ex_8(void);
-const numeric & _num_7(void); // -7
-const ex & _ex_7(void);
-const numeric & _num_6(void); // -6
-const ex & _ex_6(void);
-const numeric & _num_5(void); // -5
-const ex & _ex_5(void);
-const numeric & _num_4(void); // -4
-const ex & _ex_4(void);
-const numeric & _num_3(void); // -3
-const ex & _ex_3(void);
-const numeric & _num_2(void); // -2
-const ex & _ex_2(void);
-const numeric & _num_1(void); // -1
-const ex & _ex_1(void);
-const numeric & _num_1_2(void); // -1/2
-const ex & _ex_1_2(void);
-const numeric & _num_1_3(void); // -1/3
-const ex & _ex_1_3(void);
-const numeric & _num_1_4(void); // -1/4
-const ex & _ex_1_4(void);
-const numeric & _num0(void); // 0
-const ex & _ex0(void);
-const numeric & _num1_4(void); // 1/4
-const ex & _ex1_4(void);
-const numeric & _num1_3(void); // 1/3
-const ex & _ex1_3(void);
-const numeric & _num1_2(void); // 1/2
-const ex & _ex1_2(void);
-const numeric & _num1(void); // 1
-const ex & _ex1(void);
-const numeric & _num2(void); // 2
-const ex & _ex2(void);
-const numeric & _num3(void); // 3
-const ex & _ex3(void);
-const numeric & _num4(void); // 4
-const ex & _ex4(void);
-const numeric & _num5(void); // 5
-const ex & _ex5(void);
-const numeric & _num6(void); // 6
-const ex & _ex6(void);
-const numeric & _num7(void); // 7
-const ex & _ex7(void);
-const numeric & _num8(void); // 8
-const ex & _ex8(void);
-const numeric & _num9(void); // 9
-const ex & _ex9(void);
-const numeric & _num10(void); // 10
-const ex & _ex10(void);
-const numeric & _num11(void); // 11
-const ex & _ex11(void);
-const numeric & _num12(void); // 12
-const ex & _ex12(void);
-const numeric & _num15(void); // 15
-const ex & _ex15(void);
-const numeric & _num18(void); // 18
-const ex & _ex18(void);
-const numeric & _num20(void); // 20
-const ex & _ex20(void);
-const numeric & _num24(void); // 24
-const ex & _ex24(void);
-const numeric & _num25(void); // 25
-const ex & _ex25(void);
-const numeric & _num30(void); // 30
-const ex & _ex30(void);
-const numeric & _num48(void); // 48
-const ex & _ex48(void);
-const numeric & _num60(void); // 60
-const ex & _ex60(void);
-const numeric & _num120(void); // 120
-const ex & _ex120(void);
+extern const numeric *_num_120_p;
+extern const numeric &_num_120;
+extern const ex _ex_120;
+extern const numeric *_num_60_p;
+extern const numeric &_num_60;
+extern const ex _ex_60;
+extern const numeric *_num_48_p;
+extern const numeric &_num_48;
+extern const ex _ex_48;
+extern const numeric *_num_30_p;
+extern const numeric &_num_30;
+extern const ex _ex_30;
+extern const numeric *_num_25_p;
+extern const numeric &_num_25;
+extern const ex _ex_25;
+extern const numeric *_num_24_p;
+extern const numeric &_num_24;
+extern const ex _ex_24;
+extern const numeric *_num_20_p;
+extern const numeric &_num_20;
+extern const ex _ex_20;
+extern const numeric *_num_18_p;
+extern const numeric &_num_18;
+extern const ex _ex_18;
+extern const numeric *_num_15_p;
+extern const numeric &_num_15;
+extern const ex _ex_15;
+extern const numeric *_num_12_p;
+extern const numeric &_num_12;
+extern const ex _ex_12;
+extern const numeric *_num_11_p;
+extern const numeric &_num_11;
+extern const ex _ex_11;
+extern const numeric *_num_10_p;
+extern const numeric &_num_10;
+extern const ex _ex_10;
+extern const numeric *_num_9_p;
+extern const numeric &_num_9;
+extern const ex _ex_9;
+extern const numeric *_num_8_p;
+extern const numeric &_num_8;
+extern const ex _ex_8;
+extern const numeric *_num_7_p;
+extern const numeric &_num_7;
+extern const ex _ex_7;
+extern const numeric *_num_6_p;
+extern const numeric &_num_6;
+extern const ex _ex_6;
+extern const numeric *_num_5_p;
+extern const numeric &_num_5;
+extern const ex _ex_5;
+extern const numeric *_num_4_p;
+extern const numeric &_num_4;
+extern const ex _ex_4;
+extern const numeric *_num_3_p;
+extern const numeric &_num_3;
+extern const ex _ex_3;
+extern const numeric *_num_2_p;
+extern const numeric &_num_2;
+extern const ex _ex_2;
+extern const numeric *_num_1_p;
+extern const numeric &_num_1;
+extern const ex _ex_1;
+extern const numeric *_num_1_2_p;
+extern const numeric &_num_1_2;
+extern const ex _ex_1_2;
+extern const numeric *_num_1_3_p;
+extern const numeric &_num_1_3;
+extern const ex _ex_1_3;
+extern const numeric *_num_1_4_p;
+extern const numeric &_num_1_4;
+extern const ex _ex_1_4;
+extern const numeric *_num0_p;
+extern const numeric &_num0;
+extern const ex _ex0;
+extern const numeric *_num1_4_p;
+extern const numeric &_num1_4;
+extern const ex _ex1_4;
+extern const numeric *_num1_3_p;
+extern const numeric &_num1_3;
+extern const ex _ex1_3;
+extern const numeric *_num1_2_p;
+extern const numeric &_num1_2;
+extern const ex _ex1_2;
+extern const numeric *_num1_p;
+extern const numeric &_num1;
+extern const ex _ex1;
+extern const numeric *_num2_p;
+extern const numeric &_num2;
+extern const ex _ex2;
+extern const numeric *_num3_p;
+extern const numeric &_num3;
+extern const ex _ex3;
+extern const numeric *_num4_p;
+extern const numeric &_num4;
+extern const ex _ex4;
+extern const numeric *_num5_p;
+extern const numeric &_num5;
+extern const ex _ex5;
+extern const numeric *_num6_p;
+extern const numeric &_num6;
+extern const ex _ex6;
+extern const numeric *_num7_p;
+extern const numeric &_num7;
+extern const ex _ex7;
+extern const numeric *_num8_p;
+extern const numeric &_num8;
+extern const ex _ex8;
+extern const numeric *_num9_p;
+extern const numeric &_num9;
+extern const ex _ex9;
+extern const numeric *_num10_p;
+extern const numeric &_num10;
+extern const ex _ex10;
+extern const numeric *_num11_p;
+extern const numeric &_num11;
+extern const ex _ex11;
+extern const numeric *_num12_p;
+extern const numeric &_num12;
+extern const ex _ex12;
+extern const numeric *_num15_p;
+extern const numeric &_num15;
+extern const ex _ex15;
+extern const numeric *_num18_p;
+extern const numeric &_num18;
+extern const ex _ex18;
+extern const numeric *_num20_p;
+extern const numeric &_num20;
+extern const ex _ex20;
+extern const numeric *_num24_p;
+extern const numeric &_num24;
+extern const ex _ex24;
+extern const numeric *_num25_p;
+extern const numeric &_num25;
+extern const ex _ex25;
+extern const numeric *_num30_p;
+extern const numeric &_num30;
+extern const ex _ex30;
+extern const numeric *_num48_p;
+extern const numeric &_num48;
+extern const ex _ex48;
+extern const numeric *_num60_p;
+extern const numeric &_num60;
+extern const ex _ex60;
+extern const numeric *_num120_p;
+extern const numeric &_num120;
+extern const ex _ex120;
// Helper macros for class implementations (mostly useful for trivial classes)