From 27d6204effdef95a00af461fff98024e290dbaa7 Mon Sep 17 00:00:00 2001 From: Richard Kreckel Date: Mon, 22 Oct 2001 17:59:49 +0000 Subject: [PATCH] * Some internal reorganization WRT flyweight handling and initialization, resulting in a general speed-up. Wherever thou hast written _ex7() thou shalt write _ex7 from now on. --- NEWS | 3 + ginac/add.cpp | 46 +- ginac/basic.cpp | 6 +- ginac/clifford.cpp | 40 +- ginac/color.cpp | 52 +- ginac/constant.cpp | 6 +- ginac/ex.cpp | 282 ++++++++++- ginac/ex.h | 39 +- ginac/expairseq.cpp | 4 +- ginac/function.pl | 6 +- ginac/idx.cpp | 2 +- ginac/indexed.cpp | 24 +- ginac/inifcns.cpp | 48 +- ginac/inifcns_gamma.cpp | 82 ++-- ginac/inifcns_trans.cpp | 336 ++++++------- ginac/inifcns_zeta.cpp | 12 +- ginac/matrix.cpp | 46 +- ginac/mul.cpp | 52 +- ginac/ncmul.cpp | 6 +- ginac/normal.cpp | 168 +++---- ginac/numeric.cpp | 80 ++-- ginac/numeric.h | 2 +- ginac/operators.cpp | 24 +- ginac/power.cpp | 73 ++- ginac/power.h | 6 +- ginac/pseries.cpp | 46 +- ginac/relational.cpp | 8 +- ginac/symbol.cpp | 10 +- ginac/tensor.cpp | 48 +- ginac/utils.cpp | 1003 +++++++++++++-------------------------- ginac/utils.h | 245 ++++++---- 31 files changed, 1371 insertions(+), 1434 deletions(-) diff --git a/NEWS b/NEWS index 47fb59a2..52f9a4c6 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ This file records noteworthy changes. +0.9.5 () +* 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. diff --git a/ginac/add.cpp b/ginac/add.cpp index 4cb11825..bdcd4999 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -57,7 +57,7 @@ add::add(const ex & lh, const ex & rh) { 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()); } @@ -66,7 +66,7 @@ add::add(const exvector & v) { 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()); } @@ -75,7 +75,7 @@ add::add(const epvector & v) { 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()); } @@ -130,16 +130,16 @@ void add::print(const print_context & c, unsigned level) const 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(it->coeff).numer().compare(_num1()) == 0) { + } else if (ex_to(it->coeff).numer().compare(_num1) == 0) { it->rest.print(c, precedence()); c.s << "/"; ex_to(it->coeff).denom().print(c, precedence()); - } else if (ex_to(it->coeff).numer().compare(_num_1()) == 0) { + } else if (ex_to(it->coeff).numer().compare(_num_1) == 0) { c.s << "-"; it->rest.print(c, precedence()); c.s << "/"; @@ -152,7 +152,7 @@ void add::print(const print_context & c, unsigned level) const // 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(it->rest) && it->rest.compare(_num0()) < 0))) + if (it != itend && !(it->coeff.compare(_num0) < 0 || (it->coeff.compare(_num1) == 0 && is_exactly_a(it->rest) && it->rest.compare(_num0) < 0))) c.s << "+"; } @@ -196,8 +196,8 @@ void add::print(const print_context & c, unsigned level) const 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); @@ -304,7 +304,7 @@ ex add::coeff(const ex & s, int n) const ++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 @@ -413,7 +413,7 @@ ex add::derivative(const symbol & y) const 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 @@ -458,13 +458,13 @@ expair add::split_ex_to_pair(const ex & e) const const mul &mulref(ex_to(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, @@ -475,20 +475,20 @@ expair add::combine_ex_with_coeff_to_pair(const ex & e, const mul &mulref(ex_to(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(numfactor).mul_dyn(ex_to(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(e).mul_dyn(ex_to(c)), _ex1()); + if (are_ex_trivially_equal(c, _ex1)) + return expair(e, _ex1); + return expair(ex_to(e).mul_dyn(ex_to(c)), _ex1); } return expair(e, c); } @@ -500,8 +500,8 @@ expair add::combine_pair_with_coeff_to_pair(const expair & p, GINAC_ASSERT(is_exactly_a(c)); if (is_ex_exactly_of_type(p.rest,numeric)) { - GINAC_ASSERT(ex_to(p.coeff).is_equal(_num1())); // should be normalized - return expair(ex_to(p.rest).mul_dyn(ex_to(c)),_ex1()); + GINAC_ASSERT(ex_to(p.coeff).is_equal(_num1)); // should be normalized + return expair(ex_to(p.rest).mul_dyn(ex_to(c)),_ex1); } return expair(p.rest,ex_to(p.coeff).mul_dyn(ex_to(c))); @@ -509,7 +509,7 @@ expair add::combine_pair_with_coeff_to_pair(const expair & p, ex add::recombine_pair_to_ex(const expair & p) const { - if (ex_to(p.coeff).is_equal(_num1())) + if (ex_to(p.coeff).is_equal(_num1)) return p.rest; else return p.rest*p.coeff; diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 2065eac8..f0fdee78 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -256,7 +256,7 @@ int basic::ldegree(const ex & s) const /** 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). @@ -295,7 +295,7 @@ ex basic::collect(const ex & s, bool distributed) const while (true) { // Calculate coeff*x1^c1*...*xn^cn - ex y = _ex1(); + ex y = _ex1; for (int i=0; i(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(c.op(1)).get_dim()); b = indexed(c.op(0), ix.toggle_variance()); @@ -214,7 +214,7 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other } else if (other - self == 2 && is_a(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 @@ -225,9 +225,9 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other 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 @@ -236,10 +236,10 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other && is_a(self[2]) && is_a(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 @@ -254,15 +254,15 @@ bool diracgamma::contract_with(exvector::iterator self, exvector::iterator other } 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; } } @@ -462,12 +462,12 @@ ex dirac_trace(const ex & e, unsigned char rl, const ex & trONE) && is_a(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(i).get_dummy_indices().empty())) - return _ex0(); + return _ex0; // Numeric evaluation if (static_cast(i).all_index_values_are(info_flags::nonnegint)) { @@ -248,18 +248,18 @@ ex su3d::eval_indexed(const basic & i) const // 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 @@ -290,13 +290,13 @@ ex su3f::eval_indexed(const basic & i) const 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 @@ -325,7 +325,7 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve } 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 @@ -339,14 +339,14 @@ bool su3t::contract_with(exvector::iterator self, exvector::iterator other, exve } 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; } } @@ -375,7 +375,7 @@ bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exve // 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 @@ -386,7 +386,7 @@ bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exve 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; } @@ -405,7 +405,7 @@ bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exve ex a = permute_free_index_to_front(self_indices, dummy_indices, sig); *self = numeric(5, 6); other[0] = color_T(a, ex_to(other[0]).get_representation_label()); - other[1] = _ex1(); + other[1] = _ex1; return true; } } @@ -430,7 +430,7 @@ bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exve // 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 @@ -439,7 +439,7 @@ bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exve ex a = permute_free_index_to_front(ex_to(*self).get_indices(), dummy_indices, sign1); ex b = permute_free_index_to_front(ex_to(*other).get_indices(), dummy_indices, sign2); *self = sign1 * sign2 * 3 * delta_tensor(a, b); - *other = _ex1(); + *other = _ex1; return true; } @@ -458,7 +458,7 @@ bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exve 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(other[0]).get_representation_label()); - other[1] = _ex1(); + other[1] = _ex1; return true; } } @@ -523,14 +523,14 @@ ex color_trace(const ex & e, unsigned char rl) if (ex_to(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(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 @@ -185,7 +185,7 @@ 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 diff --git a/ginac/ex.cpp b/ginac/ex.cpp index 0d0657a5..b35cd8c8 100644 --- a/ginac/ex.cpp +++ b/ginac/ex.cpp @@ -48,7 +48,7 @@ namespace GiNaC { ////////// // public - + /** Efficiently swap the contents of two expressions. */ void ex::swap(ex & other) { @@ -239,25 +239,105 @@ void ex::construct_from_basic(const basic & 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: @@ -271,17 +351,57 @@ void ex::construct_from_int(int i) 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: @@ -295,25 +415,105 @@ void ex::construct_from_uint(unsigned int i) 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: @@ -327,17 +527,57 @@ void ex::construct_from_long(long i) 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: diff --git a/ginac/ex.h b/ginac/ex.h index e9f72bbe..f119c85b 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -30,10 +30,30 @@ 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; @@ -133,7 +153,7 @@ public: 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(); } @@ -188,12 +208,13 @@ public: // 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(); diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index c2dfc6a5..a2673e58 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -651,7 +651,7 @@ void expairseq::printseq(const print_context & c, char delim, * @see expairseq::recombine_pair_to_ex() */ expair expairseq::split_ex_to_pair(const ex &e) const { - return expair(e,_ex1()); + return expair(e,_ex1); } @@ -691,7 +691,7 @@ bool expairseq::expair_needs_further_processing(epp it) ex expairseq::default_overall_coeff(void) const { - return _ex0(); + return _ex0; } void expairseq::combine_overall_coeff(const ex &c) diff --git a/ginac/function.pl b/ginac/function.pl index 68673ddc..0b92e193 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -764,9 +764,9 @@ int function::ldegree(const ex & s) const ex function::coeff(const ex & s, int n) const { if (is_equal(ex_to(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 @@ -788,7 +788,7 @@ 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); } } diff --git a/ginac/idx.cpp b/ginac/idx.cpp index 9017a9ca..d0388d23 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -387,7 +387,7 @@ ex idx::subs(const lst & ls, const lst & lr, bool no_pattern) const * @see ex::diff */ ex idx::derivative(const symbol & s) const { - return _ex0(); + return _ex0; } ////////// diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index 5759b24d..29380c56 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -264,7 +264,7 @@ ex indexed::eval(int level) const // 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)) { @@ -282,7 +282,7 @@ ex indexed::eval(int level) const 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); } } @@ -304,9 +304,9 @@ int indexed::ldegree(const ex & s) const ex indexed::coeff(const ex & s, int n) const { if (is_equal(ex_to(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 @@ -327,7 +327,7 @@ ex indexed::expand(unsigned options) 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 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(x); @@ -159,7 +159,7 @@ static ex eta_eval(const ex &x, const ex &y) { // 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()! @@ -192,7 +192,7 @@ static ex eta_series(const ex & x, const ex & y, ((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); } @@ -220,22 +220,22 @@ static ex Li2_eval(const ex & x) 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(x)); @@ -249,7 +249,7 @@ static ex Li2_deriv(const ex & x, unsigned deriv_param) 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) @@ -274,12 +274,12 @@ static ex Li2_series(const ex &x, const relational &rel, int order, unsigned opt ex ser; // manually construct the primitive expansion for (int i=1; i 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(x); // O(c*expr) -> O(expr) @@ -421,7 +421,7 @@ static ex Order_series(const ex & x, const relational & r, int order, unsigned o epvector new_seq; GINAC_ASSERT(is_exactly_a(r.lhs())); const symbol &s = ex_to(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); } diff --git a/ginac/inifcns_gamma.cpp b/ginac/inifcns_gamma.cpp index 928a6b52..497c37a6 100644 --- a/ginac/inifcns_gamma.cpp +++ b/ginac/inifcns_gamma.cpp @@ -64,7 +64,7 @@ static ex lgamma_eval(const ex & x) 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)); } @@ -105,7 +105,7 @@ static ex lgamma_series(const ex & arg, 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); } @@ -141,11 +141,11 @@ static ex tgamma_eval(const ex & x) { if (x.info(info_flags::numeric)) { // trap integer arguments: - const numeric two_x = _num2()*ex_to(x); + const numeric two_x = _num2*ex_to(x); if (two_x.is_even()) { // tgamma(n) -> (n-1)! for postitive n if (two_x.is_positive()) { - return factorial(ex_to(x).sub(_num1())); + return factorial(ex_to(x).sub(_num1)); } else { throw (pole_error("tgamma_eval(): simple pole",1)); } @@ -155,13 +155,13 @@ static ex tgamma_eval(const ex & x) // 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(x).sub(_num1_2()); - return (doublefactorial(n.mul(_num2()).sub(_num1())).div(pow(_num2(),n))) * pow(Pi,_ex1_2()); + const numeric n = ex_to(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(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(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 @@ -198,10 +198,10 @@ static ex tgamma_series(const ex & arg, 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(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); } @@ -240,13 +240,13 @@ static ex beta_eval(const ex & x, const ex & y) 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)); } @@ -256,7 +256,7 @@ static ex beta_eval(const ex & x, const ex & y) 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 } @@ -351,7 +351,7 @@ static ex psi1_eval(const ex & x) 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 { @@ -359,14 +359,14 @@ static ex psi1_eval(const ex & x) 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) @@ -375,8 +375,8 @@ static ex psi1_eval(const ex & x) // 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 @@ -390,7 +390,7 @@ static ex psi1_deriv(const ex & x, unsigned deriv_param) 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, @@ -413,8 +413,8 @@ static ex psi1_series(const ex & arg, const numeric m = -ex_to(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 = @@ -449,7 +449,7 @@ static ex psi2_eval(const ex & n, const ex & x) 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)) { @@ -457,9 +457,9 @@ static ex psi2_eval(const ex & n, const ex & x) const numeric nx = ex_to(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) @@ -468,25 +468,25 @@ static ex psi2_eval(const ex & n, const ex & x) // where r == (-)^n * n! * (1^(-n-1) + ... + (m-1)^(-n-1)) numeric recur = 0; for (numeric p = 1; p psi(n+1,x) - return psi(n+_ex1(), x); + return psi(n+_ex1, x); } static ex psi2_series(const ex & n, @@ -540,9 +540,9 @@ static ex psi2_series(const ex & n, const numeric m = -ex_to(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 = diff --git a/ginac/inifcns_trans.cpp b/ginac/inifcns_trans.cpp index 507e18f5..00fc2efd 100644 --- a/ginac/inifcns_trans.cpp +++ b/ginac/inifcns_trans.cpp @@ -52,19 +52,19 @@ static ex exp_eval(const ex & x) { // 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(TwoExOverPiI),_num4()); - if (z.is_equal(_num0())) - return _ex1(); - if (z.is_equal(_num1())) + numeric z = mod(ex_to(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 @@ -110,12 +110,12 @@ static ex log_eval(const ex & 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(x)); @@ -138,7 +138,7 @@ static ex log_deriv(const ex & x, unsigned deriv_param) 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, @@ -185,9 +185,9 @@ 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 @@ -207,8 +207,8 @@ static ex log_series(const ex &arg, 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() @@ -235,37 +235,37 @@ static ex sin_evalf(const ex & x) 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(SixtyExOverPi),_num120()); - if (z>=_num60()) { + numeric z = mod(ex_to(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(x)) { @@ -275,10 +275,10 @@ static ex sin_eval(const ex & 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 @@ -316,37 +316,37 @@ static ex cos_evalf(const ex & x) 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(SixtyExOverPi),_num120()); - if (z>=_num60()) { + numeric z = mod(ex_to(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(x)) { @@ -354,12 +354,12 @@ static ex cos_eval(const ex & 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 @@ -374,7 +374,7 @@ static ex cos_deriv(const ex & x, unsigned deriv_param) 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). @@ -397,32 +397,32 @@ static ex tan_evalf(const ex & x) 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(SixtyExOverPi),_num60()); - if (z>=_num60()) { + numeric z = mod(ex_to(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)); } @@ -431,12 +431,12 @@ static ex tan_eval(const ex & x) // 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 @@ -452,7 +452,7 @@ static ex tan_deriv(const ex & x, unsigned deriv_param) 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, @@ -496,17 +496,17 @@ static ex asin_eval(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(x)); @@ -520,7 +520,7 @@ static ex asin_deriv(const ex & x, unsigned deriv_param) 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). @@ -544,19 +544,19 @@ static ex acos_eval(const ex & x) { 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)) @@ -571,7 +571,7 @@ static ex acos_deriv(const ex & x, unsigned deriv_param) 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). @@ -596,13 +596,13 @@ static ex atan_eval(const ex & x) 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 @@ -618,7 +618,7 @@ static ex atan_deriv(const ex & x, unsigned deriv_param) 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, @@ -638,7 +638,7 @@ 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)) @@ -651,14 +651,14 @@ static ex atan_series(const ex &arg, 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(); @@ -698,10 +698,10 @@ static ex atan2_deriv(const ex & y, const ex & x, unsigned deriv_param) 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). @@ -724,7 +724,7 @@ static ex sinh_eval(const ex & x) { 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(x)); } @@ -738,12 +738,12 @@ static ex sinh_eval(const ex & 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(); @@ -778,7 +778,7 @@ static ex cosh_eval(const ex & x) { 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(x)); } @@ -792,12 +792,12 @@ static ex cosh_eval(const ex & 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(); @@ -832,7 +832,7 @@ static ex tanh_eval(const ex & x) { 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(x)); } @@ -846,12 +846,12 @@ static ex tanh_eval(const ex & 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(); @@ -862,7 +862,7 @@ static ex tanh_deriv(const ex & x, unsigned deriv_param) 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, @@ -904,7 +904,7 @@ static ex asinh_eval(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(x)); @@ -918,7 +918,7 @@ static ex asinh_deriv(const ex & x, unsigned deriv_param) 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). @@ -944,10 +944,10 @@ static ex acosh_eval(const ex & x) 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)) @@ -962,7 +962,7 @@ static ex acosh_deriv(const ex & x, unsigned deriv_param) 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). @@ -986,9 +986,9 @@ static ex atanh_eval(const ex & x) 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)) @@ -1003,7 +1003,7 @@ static ex atanh_deriv(const ex & x, unsigned deriv_param) 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, @@ -1022,11 +1022,11 @@ 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: @@ -1036,14 +1036,14 @@ static ex atanh_series(const ex &arg, 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(); diff --git a/ginac/inifcns_zeta.cpp b/ginac/inifcns_zeta.cpp index 53eba05b..28705983 100644 --- a/ginac/inifcns_zeta.cpp +++ b/ginac/inifcns_zeta.cpp @@ -54,19 +54,19 @@ static ex zeta1_eval(const ex & x) // 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) @@ -80,7 +80,7 @@ static ex zeta1_deriv(const ex & x, unsigned deriv_param) { GINAC_ASSERT(deriv_param==0); - return zeta(_ex1(), x); + return zeta(_ex1, x); } const unsigned function_index_zeta1 = diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index e544210f..df262238 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -49,7 +49,7 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(matrix, basic) 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) @@ -76,7 +76,7 @@ matrix::matrix(unsigned r, unsigned c) : 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 @@ -96,7 +96,7 @@ matrix::matrix(unsigned r, unsigned c, const lst & l) : 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; iop(2)); else *self = indexed(self_matrix.transpose().mul(other_matrix), other->op(2)); - *other = _ex1(); + *other = _ex1; return true; } @@ -456,7 +456,7 @@ bool matrix::contract_with(exvector::iterator self, exvector::iterator other, ex *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; } } @@ -466,28 +466,28 @@ bool matrix::contract_with(exvector::iterator self, exvector::iterator other, ex // 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; } } @@ -609,7 +609,7 @@ matrix matrix::pow(const ex & expn) const } matrix C(row,col); for (unsigned r=0; rm[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; cm[r0*n+c] = _ex0(); + this->m[r0*n+c] = _ex0; } ++r0; } @@ -1241,12 +1241,12 @@ int matrix::division_free_elimination(const bool det) 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; cm[r0*n+c] = _ex0(); + this->m[r0*n+c] = _ex0; } ++r0; } @@ -1354,7 +1354,7 @@ int matrix::fraction_free_elimination(const bool det) } // 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 j) m(i, j) = l.op(i).op(j); else - m(i, j) = _ex0(); + m(i, j) = _ex0; return m; } diff --git a/ginac/mul.cpp b/ginac/mul.cpp index da23307e..d4117944 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -58,7 +58,7 @@ mul::mul(const ex & lh, const ex & rh) { 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()); } @@ -67,7 +67,7 @@ mul::mul(const exvector & v) { 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()); } @@ -76,7 +76,7 @@ mul::mul(const epvector & v) { 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()); } @@ -110,7 +110,7 @@ mul::mul(const ex & lh, const ex & mh, const ex & rh) 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()); } @@ -140,7 +140,7 @@ void mul::print(const print_context & c, unsigned level) const if (precedence() <= level) c.s << "("; - if (!overall_coeff.is_equal(_ex1())) { + if (!overall_coeff.is_equal(_ex1)) { overall_coeff.print(c, precedence()); c.s << "*"; } @@ -150,7 +150,7 @@ void mul::print(const print_context & c, unsigned level) const while (it != itend) { // If the first argument is a negative integer power, it gets printed as "1.0/" - if (it == seq.begin() && ex_to(it->coeff).is_integer() && it->coeff.compare(_num0()) < 0) { + if (it == seq.begin() && ex_to(it->coeff).is_integer() && it->coeff.compare(_num0) < 0) { if (is_a(c)) c.s << "recip("; else @@ -158,7 +158,7 @@ void mul::print(const print_context & c, unsigned level) const } // 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: @@ -168,7 +168,7 @@ void mul::print(const print_context & c, unsigned level) const // Separator is "/" for negative integer powers, "*" otherwise ++it; if (it != itend) { - if (ex_to(it->coeff).is_integer() && it->coeff.compare(_num0()) < 0) + if (ex_to(it->coeff).is_integer() && it->coeff.compare(_num0) < 0) c.s << "/"; else c.s << "*"; @@ -193,8 +193,8 @@ void mul::print(const print_context & c, unsigned level) const numeric coeff = ex_to(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); @@ -327,7 +327,7 @@ ex mul::coeff(const ex & s, int n) const return (new mul(coeffseq))->setflag(status_flags::dynallocated); } - return _ex0(); + return _ex0; } /** Perform automatic term rewriting rules in this class. In the following @@ -370,23 +370,23 @@ ex mul::eval(int level) const 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((*seq.begin()).coeff).is_equal(_num1())) { + ex_to((*seq.begin()).coeff).is_equal(_num1)) { // *(+(x,y,...);c) -> +(*(x,c),*(y,c),...) (c numeric(), no powers of +()) const add & addref = ex_to((*seq.begin()).rest); epvector *distrseq = new epvector(); @@ -428,7 +428,7 @@ ex mul::evalf(int level) const 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(seq[0].rest).mul(ex_to(overall_coeff)); @@ -495,7 +495,7 @@ ex mul::derivative(const symbol & s) const 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)); @@ -581,7 +581,7 @@ expair mul::split_ex_to_pair(const ex & e) const 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, @@ -591,7 +591,7 @@ 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)); @@ -604,7 +604,7 @@ expair mul::combine_pair_with_coeff_to_pair(const expair & p, // 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)); @@ -612,7 +612,7 @@ expair mul::combine_pair_with_coeff_to_pair(const expair & p, ex mul::recombine_pair_to_ex(const expair & p) const { - if (ex_to(p.coeff).is_equal(_num1())) + if (ex_to(p.coeff).is_equal(_num1)) return p.rest; else return power(p.rest,p.coeff); @@ -633,7 +633,7 @@ bool mul::expair_needs_further_processing(epp it) *it = ep; return true; } - if (ex_to((*it).coeff).is_equal(_num1())) { + if (ex_to((*it).coeff).is_equal(_num1)) { // combined pair has coeff 1 and must be moved to the end return true; } @@ -643,7 +643,7 @@ bool mul::expair_needs_further_processing(epp it) ex mul::default_overall_coeff(void) const { - return _ex1(); + return _ex1; } void mul::combine_overall_coeff(const ex & c) @@ -667,7 +667,7 @@ bool mul::can_make_flat(const expair & p) const // 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(p.coeff).is_equal(_num1()); + return ex_to(p.coeff).is_equal(_num1); } ex mul::expand(unsigned options) const @@ -680,13 +680,13 @@ 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(last_expanded); diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index 473a1c9e..21cdefda 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -259,7 +259,7 @@ ex ncmul::coeff(const ex & s, int n) const if (coeff_found) return (new ncmul(coeffseq,1))->setflag(status_flags::dynallocated); - return _ex0(); + return _ex0; } unsigned ncmul::count_factors(const ex & e) const @@ -331,7 +331,7 @@ ex ncmul::eval(int level) 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; @@ -593,7 +593,7 @@ ex nonsimplified_ncmul(const exvector & v) ex simplified_ncmul(const exvector & v) { if (v.empty()) - return _ex1(); + return _ex1; else if (v.size() == 1) return v[0]; else diff --git a/ginac/normal.cpp b/ginac/normal.cpp index e9117c4d..f123be20 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -231,14 +231,14 @@ static numeric lcmcoeff(const ex &e, const numeric &l) if (e.info(info_flags::rational)) return lcm(ex_to(e).denom(), l); else if (is_ex_exactly_of_type(e, add)) { - numeric c = _num1(); + numeric c = _num1; for (unsigned i=0; i(it->rest)); GINAC_ASSERT(is_exactly_a(it->coeff)); @@ -368,7 +368,7 @@ ex quo(const ex &a, const ex &b, const symbol &x, bool check_args) 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")); @@ -416,13 +416,13 @@ ex rem(const ex &a, const ex &b, const symbol &x, bool check_args) 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")); @@ -485,7 +485,7 @@ ex prem(const ex &a, const ex &b, const symbol &x, bool check_args) 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; } @@ -501,18 +501,18 @@ ex prem(const ex &a, const ex &b, const symbol &x, bool check_args) 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; @@ -537,7 +537,7 @@ ex sprem(const ex &a, const ex &b, const symbol &x, bool check_args) 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; } @@ -553,17 +553,17 @@ ex sprem(const ex &a, const ex &b, const symbol &x, bool check_args) 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; @@ -584,7 +584,7 @@ ex sprem(const ex &a, const ex &b, const symbol &x, bool check_args) * "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()) @@ -596,7 +596,7 @@ bool divide(const ex &a, const ex &b, ex &q, bool check_args) return false; #if FAST_COMPARE if (a.is_equal(b)) { - q = _ex1(); + q = _ex1; return true; } #endif @@ -676,10 +676,10 @@ typedef std::map ex2_exbool_remember; * @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; } @@ -692,7 +692,7 @@ static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_ite } #if FAST_COMPARE if (a.is_equal(b)) { - q = _ex1(); + q = _ex1; return true; } #endif @@ -723,24 +723,24 @@ static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_ite // Compute values at evaluation points 0..adeg vector 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 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 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++) { @@ -1467,9 +1467,9 @@ ex gcd(const ex &a, const ex &b, ex *ca, ex *cb, bool check_args) 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(a) / g; @@ -1536,7 +1536,7 @@ factored_b: 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); @@ -1544,7 +1544,7 @@ factored_b: if (ca) *ca = power(p, exp_a - exp_b); if (cb) - *cb = _ex1(); + *cb = _ex1; return power(p, exp_b); } } @@ -1554,7 +1554,7 @@ factored_b: if (ca) *ca = power(p, a.op(1) - 1); if (cb) - *cb = _ex1(); + *cb = _ex1; return p; } } @@ -1563,7 +1563,7 @@ factored_b: 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; @@ -1575,31 +1575,31 @@ factored_b: 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 @@ -1659,7 +1659,7 @@ factored_b: // 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; @@ -1673,7 +1673,7 @@ factored_b: } #if 1 } else { - if (g.is_equal(_ex1())) { + if (g.is_equal(_ex1)) { // Keep cofactors factored if possible if (ca) *ca = a; @@ -1723,7 +1723,7 @@ static exvector sqrfree_yun(const ex &a, const symbol &x) 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; } @@ -1755,7 +1755,7 @@ ex sqrfree(const ex &a, const lst &l) 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); @@ -1791,7 +1791,7 @@ ex sqrfree(const ex &a, const lst &l) } // 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); @@ -1828,10 +1828,10 @@ ex sqrfree_parfrac(const ex & a, const symbol & x) exvector factor; factor.reserve(num_yun); exvector cofac; cofac.reserve(num_yun); for (unsigned i=0; isetflag(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); } } } @@ -1961,7 +1961,7 @@ ex basic::normal(lst &sym_lst, lst &repl_lst, int level) const * @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); } @@ -1997,17 +1997,17 @@ static ex frac_cancel(const ex &n, const ex &d) { 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")); @@ -2021,7 +2021,7 @@ static ex frac_cancel(const ex &n, const ex &d) // 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; } @@ -2032,8 +2032,8 @@ static ex frac_cancel(const ex &n, const ex &d) if (get_first_symbol(den, x)) { GINAC_ASSERT(is_exactly_a(den.unit(*x))); if (ex_to(den.unit(*x)).is_negative()) { - num *= _ex_1(); - den *= _ex_1(); + num *= _ex_1; + den *= _ex_1; } } @@ -2049,7 +2049,7 @@ static ex frac_cancel(const ex &n, const ex &d) 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")); @@ -2108,7 +2108,7 @@ ex add::normal(lst &sym_lst, lst &repl_lst, int level) const 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")); @@ -2140,7 +2140,7 @@ ex mul::normal(lst &sym_lst, lst &repl_lst, int level) const 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")); @@ -2167,25 +2167,25 @@ ex power::normal(lst &sym_lst, lst &repl_lst, int level) const 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); } } } @@ -2205,7 +2205,7 @@ ex pseries::normal(lst &sym_lst, lst &repl_lst, int level) const ++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); } @@ -2369,7 +2369,7 @@ ex expairseq::to_rational(lst &repl_lst) const 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()); } diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 9d5f7f01..b1a4033c 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -390,7 +390,7 @@ void numeric::print(const print_context & c, unsigned level) const 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(c)) c.s << "cln::cl_F(\"" << numer().evalf() << "\")"; @@ -626,10 +626,9 @@ unsigned numeric::calchash(void) const 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(value)+cln::the(other.value)); @@ -649,10 +648,9 @@ const numeric numeric::sub(const numeric &other) const 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(value)*cln::the(other.value)); @@ -676,8 +674,7 @@ const numeric numeric::div(const numeric &other) const 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(value))) { @@ -688,7 +685,7 @@ const numeric numeric::power(const numeric &other) const else if (cln::minusp(cln::realpart(cln::the(other.value)))) throw std::overflow_error("numeric::eval(): division by zero"); else - return _num0(); + return _num0; } return numeric(cln::expt(cln::the(value),cln::the(other.value))); } @@ -697,10 +694,9 @@ const numeric numeric::power(const numeric &other) const 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((new numeric(cln::the(value)+cln::the(other.value)))-> @@ -718,10 +714,9 @@ const numeric &numeric::sub_dyn(const numeric &other) const 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((new numeric(cln::the(value)*cln::the(other.value)))-> @@ -741,8 +736,7 @@ const numeric &numeric::div_dyn(const numeric &other) const 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(value))) { @@ -753,7 +747,7 @@ const numeric &numeric::power_dyn(const numeric &other) const else if (cln::minusp(cln::realpart(cln::the(other.value)))) throw std::overflow_error("numeric::eval(): division by zero"); else - return _num0(); + return _num0; } return static_cast((new numeric(cln::expt(cln::the(value),cln::the(other.value))))-> setflag(status_flags::dynallocated)); @@ -1120,7 +1114,7 @@ const numeric numeric::numer(void) const 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(value))); @@ -1129,7 +1123,7 @@ const numeric numeric::denom(void) const const cln::cl_RA r = cln::the(cln::realpart(cln::the(value))); const cln::cl_RA i = cln::the(cln::imagpart(cln::the(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)) @@ -1138,7 +1132,7 @@ const numeric numeric::denom(void) const return numeric(cln::lcm(cln::denominator(r), cln::denominator(i))); } // at least one float encountered - return _num1(); + return _num1; } @@ -1242,7 +1236,7 @@ const numeric atan(const numeric &x) { 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()); } @@ -1393,7 +1387,7 @@ static cln::cl_N Li2_projection(const cln::cl_N &x, const numeric Li2(const numeric &x) { if (x.is_zero()) - return _num0(); + return _num0; // what is the desired float format? // first guess: default format @@ -1484,8 +1478,8 @@ const numeric factorial(const numeric &n) * @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"); @@ -1502,12 +1496,12 @@ const numeric binomial(const numeric &n, const numeric &k) { 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); } } @@ -1558,10 +1552,10 @@ const numeric bernoulli(const numeric &nn) // 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; @@ -1619,7 +1613,7 @@ const numeric fibonacci(const numeric &n) // 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); @@ -1671,7 +1665,7 @@ const numeric mod(const numeric &a, const numeric &b) return cln::mod(cln::the(a.to_cl_N()), cln::the(b.to_cl_N())); else - return _num0(); + return _num0; } @@ -1686,7 +1680,7 @@ const numeric smod(const numeric &a, const numeric &b) return cln::mod(cln::the(a.to_cl_N()) + b2, cln::the(b.to_cl_N())) - b2; } else - return _num0(); + return _num0; } @@ -1702,7 +1696,7 @@ const numeric irem(const numeric &a, const numeric &b) return cln::rem(cln::the(a.to_cl_N()), cln::the(b.to_cl_N())); else - return _num0(); + return _num0; } @@ -1721,8 +1715,8 @@ const numeric irem(const numeric &a, const numeric &b, numeric &q) q = rem_quo.quotient; return rem_quo.remainder; } else { - q = _num0(); - return _num0(); + q = _num0; + return _num0; } } @@ -1737,7 +1731,7 @@ const numeric iquo(const numeric &a, const numeric &b) return cln::truncate1(cln::the(a.to_cl_N()), cln::the(b.to_cl_N())); else - return _num0(); + return _num0; } @@ -1755,8 +1749,8 @@ const numeric iquo(const numeric &a, const numeric &b, numeric &r) r = rem_quo.remainder; return rem_quo.quotient; } else { - r = _num0(); - return _num0(); + r = _num0; + return _num0; } } @@ -1771,7 +1765,7 @@ const numeric gcd(const numeric &a, const numeric &b) return cln::gcd(cln::the(a.to_cl_N()), cln::the(b.to_cl_N())); else - return _num1(); + return _num1; } @@ -1811,7 +1805,7 @@ const numeric isqrt(const numeric &x) cln::isqrt(cln::the(x.to_cl_N()), &root); return root; } else - return _num0(); + return _num0; } diff --git a/ginac/numeric.h b/ginac/numeric.h index 6599ffbc..eec54fff 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -96,7 +96,7 @@ public: 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; diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 31c4cf03..c638e3d7 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -55,7 +55,7 @@ static inline const ex exmul(const ex & lh, const ex & rh) /** 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 @@ -81,7 +81,7 @@ const ex operator*(const ex & lh, const ex & rh) 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)); } @@ -135,7 +135,7 @@ ex & operator*=(ex & lh, const ex & rh) 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)); } @@ -193,7 +193,7 @@ const numeric operator+(const numeric & lh) const numeric operator-(const numeric & lh) { debugmsg("operator-(numeric)",LOGLEVEL_OPERATOR); - return _num_1().mul(lh); + return _num_1.mul(lh); } @@ -203,14 +203,14 @@ const numeric operator-(const numeric & 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 @@ -219,7 +219,7 @@ const ex operator++(ex & lh, int) { debugmsg("operator++(ex,int)",LOGLEVEL_OPERATOR); ex tmp(lh); - lh = exadd(lh, _ex1()); + lh = exadd(lh, _ex1); return tmp; } @@ -229,7 +229,7 @@ const ex operator--(ex & lh, int) { debugmsg("operator--(ex,int)",LOGLEVEL_OPERATOR); ex tmp(lh); - lh = exadd(lh, _ex_1()); + lh = exadd(lh, _ex_1); return tmp; } @@ -237,7 +237,7 @@ const ex operator--(ex & lh, int) numeric& operator++(numeric & rh) { debugmsg("operator++(numeric)",LOGLEVEL_OPERATOR); - rh = rh.add(_num1()); + rh = rh.add(_num1); return rh; } @@ -245,7 +245,7 @@ numeric& operator++(numeric & rh) numeric& operator--(numeric & rh) { debugmsg("operator--(numeric)",LOGLEVEL_OPERATOR); - rh = rh.add(_num_1()); + rh = rh.add(_num_1); return rh; } @@ -255,7 +255,7 @@ const numeric operator++(numeric & lh, int) { debugmsg("operator++(numeric,int)",LOGLEVEL_OPERATOR); numeric tmp(lh); - lh = lh.add(_num1()); + lh = lh.add(_num1); return tmp; } @@ -265,7 +265,7 @@ const numeric operator--(numeric & lh, int) { debugmsg("operator--(numeric,int)",LOGLEVEL_OPERATOR); numeric tmp(lh); - lh = lh.add(_num_1()); + lh = lh.add(_num_1); return tmp; } diff --git a/ginac/power.cpp b/ginac/power.cpp index 33f572f9..a5db62b7 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -146,7 +146,7 @@ void power::print(const print_context & c, unsigned level) const c.s << ')'; // ^-1 is printed as "1.0/" or with the recip() function of CLN - } else if (exponent.compare(_num_1()) == 0) { + } else if (exponent.compare(_num_1) == 0) { if (is_a(c)) c.s << "recip("; else @@ -168,7 +168,7 @@ void power::print(const print_context & c, unsigned level) const } else { - if (exponent.is_equal(_ex1_2())) { + if (exponent.is_equal(_ex1_2)) { if (is_a(c)) c.s << "\\sqrt{"; else @@ -267,22 +267,22 @@ ex power::coeff(const ex & s, int n) const 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(exponent).is_integer()) { // integer exponent int int_exp = ex_to(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; } } } @@ -332,11 +332,11 @@ ex power::eval(int level) const 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) @@ -346,12 +346,12 @@ ex power::eval(int level) const 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) { @@ -420,7 +420,7 @@ ex power::eval(int level) const if (is_ex_exactly_of_type(sub_exponent,numeric)) { const numeric & num_sub_exponent = ex_to(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)); } } @@ -435,21 +435,21 @@ ex power::eval(int level) const if (is_ex_exactly_of_type(ebasis,mul)) { GINAC_ASSERT(!num_exponent->is_integer()); // should have been handled above const mul & mulref = ex_to(ebasis); - if (!mulref.overall_coeff.is_equal(_ex1())) { + if (!mulref.overall_coeff.is_equal(_ex1)) { const numeric & num_coeff = ex_to(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), @@ -538,14 +538,14 @@ ex power::derivative(const symbol & s) const // 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)))); } } @@ -754,21 +754,21 @@ ex power::expand_add_2(const add & a) const !is_exactly_a(ex_to(r).basis) || !is_exactly_a(ex_to(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(r),_num2()), - _ex1())); + sum.push_back(expair(expand_mul(ex_to(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(r),_num2()), - ex_to(c).power_dyn(_num2()))); + sum.push_back(expair(expand_mul(ex_to(r),_num2), + ex_to(c).power_dyn(_num2))); } else { - sum.push_back(expair((new power(r,_ex2()))->setflag(status_flags::dynallocated), - ex_to(c).power_dyn(_num2()))); + sum.push_back(expair((new power(r,_ex2))->setflag(status_flags::dynallocated), + ex_to(c).power_dyn(_num2))); } } @@ -776,7 +776,7 @@ ex power::expand_add_2(const add & a) const 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(c)).mul_dyn(ex_to(c1)))); + _num2.mul(ex_to(c)).mul_dyn(ex_to(c1)))); } } @@ -786,10 +786,10 @@ ex power::expand_add_2(const add & a) const 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(a.overall_coeff).mul_dyn(_num2()))); + sum.push_back(a.combine_pair_with_coeff_to_pair(*i, ex_to(a.overall_coeff).mul_dyn(_num2))); ++i; } - sum.push_back(expair(ex_to(a.overall_coeff).power_dyn(_num2()),_ex1())); + sum.push_back(expair(ex_to(a.overall_coeff).power_dyn(_num2),_ex1)); } GINAC_ASSERT(sum.size()==(a_nops*(a_nops+1))/2); @@ -802,7 +802,7 @@ ex power::expand_add_2(const add & a) const 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()); @@ -821,11 +821,4 @@ ex power::expand_mul(const mul & m, const numeric & n) const return (new mul(distrseq,ex_to(m.overall_coeff).power_dyn(n)))->setflag(status_flags::dynallocated); } -// helper function - -ex sqrt(const ex & a) -{ - return power(a,_ex1_2()); -} - } // namespace GiNaC diff --git a/ginac/power.h b/ginac/power.h index 06f9681e..97072e2a 100644 --- a/ginac/power.h +++ b/ginac/power.h @@ -113,7 +113,11 @@ inline ex pow(const T1 & b, const T2 & e) } /** 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 diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index b348fd31..4cccdd29 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -68,7 +68,7 @@ DEFAULT_DESTROY(pseries) /** 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) @@ -180,7 +180,7 @@ void pseries::print(const print_context & c, unsigned level) const 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; @@ -323,7 +323,7 @@ ex pseries::coeff(const ex &s, int n) const { if (var.is_equal(s)) { if (seq.empty()) - return _ex0(); + return _ex0; // Binary search in sequence for given power numeric looking_for = numeric(n); @@ -345,7 +345,7 @@ ex pseries::coeff(const ex &s, int n) const 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); } @@ -495,7 +495,7 @@ ex basic::series(const relational & r, int order, unsigned options) const const symbol &s = ex_to(r.lhs()); if (!coeff.is_zero()) - seq.push_back(expair(coeff, _ex0())); + seq.push_back(expair(coeff, _ex0)); int n; for (n=1; nis_equal_same_type(ex_to(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); } @@ -552,7 +552,7 @@ ex pseries::add_series(const pseries &other) const // 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); } @@ -600,7 +600,7 @@ ex pseries::add_series(const pseries &other) const } 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; @@ -634,7 +634,7 @@ ex add::series(const relational & r, int order, unsigned options) const 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(op).mul_const(ex_to(it->coeff)); // Series addition @@ -677,7 +677,7 @@ ex pseries::mul_series(const pseries &other) const // 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); } @@ -701,7 +701,7 @@ ex pseries::mul_series(const pseries &other) const 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); @@ -713,7 +713,7 @@ ex pseries::mul_series(const pseries &other) const 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); } @@ -793,11 +793,11 @@ ex pseries::power_const(const numeric &p, int deg) const co.push_back(power(coeff(var, ldeg), p)); bool all_sums_zero = true; for (int i=1; i(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); } @@ -894,7 +894,7 @@ ex pseries::series(const relational & r, int order, unsigned options) const while (it != itend) { int o = ex_to(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); @@ -925,7 +925,7 @@ ex ex::series(const ex & r, int order, unsigned options) const if (is_ex_exactly_of_type(r,relational)) rel_ = ex_to(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")); diff --git a/ginac/relational.cpp b/ginac/relational.cpp index 6d51a563..9d50fee2 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -263,13 +263,13 @@ relational::operator bool() const case not_equal: return !ex_to(df).is_zero(); case less: - return ex_to(df)<_num0(); + return ex_to(df)<_num0; case less_or_equal: - return ex_to(df)<=_num0(); + return ex_to(df)<=_num0; case greater: - return ex_to(df)>_num0(); + return ex_to(df)>_num0; case greater_or_equal: - return ex_to(df)>=_num0(); + return ex_to(df)>=_num0; default: throw(std::logic_error("invalid relational operator")); } diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 9d291686..65386f3a 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -193,9 +193,9 @@ int symbol::ldegree(const ex & s) const ex symbol::coeff(const ex & s, int n) const { if (is_equal(ex_to(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 @@ -223,9 +223,9 @@ 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 @@ -276,7 +276,7 @@ void symbol::unassign(void) { if (asexinfop->is_assigned) { asexinfop->is_assigned = 0; - asexinfop->assigned_expression = _ex0(); + asexinfop->assigned_expression = _ex0; } setflag(status_flags::evaluated | status_flags::expanded); } diff --git a/ginac/tensor.cpp b/ginac/tensor.cpp index 8881425f..f6379bd0 100644 --- a/ginac/tensor.cpp +++ b/ginac/tensor.cpp @@ -199,9 +199,9 @@ ex tensdelta::eval_indexed(const basic & i) const if (static_cast(i).all_index_values_are(info_flags::integer)) { int n1 = ex_to(i1.get_value()).to_int(), n2 = ex_to(i2.get_value()).to_int(); if (n1 == n2) - return _ex1(); + return _ex1; else - return _ex0(); + return _ex0; } // No further simplifications @@ -245,11 +245,11 @@ ex minkmetric::eval_indexed(const basic & i) const if (static_cast(i).all_index_values_are(info_flags::nonnegint)) { int n1 = ex_to(i1.get_value()).to_int(), n2 = ex_to(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 @@ -270,17 +270,17 @@ ex spinmetric::eval_indexed(const basic & i) const // Convolutions are zero if (!(static_cast(i).get_dummy_indices().empty())) - return _ex0(); + return _ex0; // Numeric evaluation if (static_cast(i).all_index_values_are(info_flags::nonnegint)) { int n1 = ex_to(i1.get_value()).to_int(), n2 = ex_to(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 @@ -296,7 +296,7 @@ ex tensepsilon::eval_indexed(const basic & i) const // Convolutions are zero if (!(static_cast(i).get_dummy_indices().empty())) - return _ex0(); + return _ex0; // Numeric evaluation if (static_cast(i).all_index_values_are(info_flags::nonnegint)) { @@ -351,7 +351,7 @@ again: // Contraction found, remove delta tensor and substitute // index in second object - *self = _ex1(); + *self = _ex1; *other = other->subs(other_idx == *free_idx); return true; } @@ -396,7 +396,7 @@ again: // Contraction found, remove metric tensor and substitute // index in second object - *self = _ex1(); + *self = _ex1; *other = other->subs(other_idx == *free_idx); return true; } @@ -432,25 +432,25 @@ bool spinmetric::contract_with(exvector::iterator self, exvector::iterator other 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; } } @@ -517,7 +517,7 @@ bool tensepsilon::contract_with(exvector::iterator self, exvector::iterator othe } 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) { @@ -549,8 +549,8 @@ bool tensepsilon::contract_with(exvector::iterator self, exvector::iterator othe } else { // Yes, the contraction is zero - *self = _ex0(); - *other = _ex0(); + *self = _ex0; + *other = _ex0; return true; } } @@ -608,7 +608,7 @@ ex epsilon_tensor(const ex & i1, const ex & i2) ex dim = ex_to(i1).get_dim(); if (!dim.is_equal(ex_to(i2).get_dim())) throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension")); - if (!ex_to(i1).get_dim().is_equal(_ex2())) + if (!ex_to(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); @@ -622,7 +622,7 @@ ex epsilon_tensor(const ex & i1, const ex & i2, const ex & i3) ex dim = ex_to(i1).get_dim(); if (!dim.is_equal(ex_to(i2).get_dim()) || !dim.is_equal(ex_to(i3).get_dim())) throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension")); - if (!ex_to(i1).get_dim().is_equal(_ex3())) + if (!ex_to(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); @@ -636,7 +636,7 @@ ex lorentz_eps(const ex & i1, const ex & i2, const ex & i3, const ex & i4, bool ex dim = ex_to(i1).get_dim(); if (!dim.is_equal(ex_to(i2).get_dim()) || !dim.is_equal(ex_to(i3).get_dim()) || !dim.is_equal(ex_to(i4).get_dim())) throw(std::invalid_argument("all indices of epsilon tensor must have the same dimension")); - if (!ex_to(i1).get_dim().is_equal(_ex4())) + if (!ex_to(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); diff --git a/ginac/utils.cpp b/ginac/utils.cpp index d5d7ab62..31aaa5a7 100644 --- a/ginac/utils.cpp +++ b/ginac/utils.cpp @@ -56,694 +56,327 @@ unsigned log2(unsigned n) } #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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(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(&((new numeric(-120))->setflag(status_flags::dynallocated))); + _num_60_p = reinterpret_cast(&((new numeric(-60))->setflag(status_flags::dynallocated))); + _num_48_p = reinterpret_cast(&((new numeric(-48))->setflag(status_flags::dynallocated))); + _num_30_p = reinterpret_cast(&((new numeric(-30))->setflag(status_flags::dynallocated))); + _num_25_p = reinterpret_cast(&((new numeric(-25))->setflag(status_flags::dynallocated))); + _num_24_p = reinterpret_cast(&((new numeric(-24))->setflag(status_flags::dynallocated))); + _num_20_p = reinterpret_cast(&((new numeric(-20))->setflag(status_flags::dynallocated))); + _num_18_p = reinterpret_cast(&((new numeric(-18))->setflag(status_flags::dynallocated))); + _num_15_p = reinterpret_cast(&((new numeric(-15))->setflag(status_flags::dynallocated))); + _num_12_p = reinterpret_cast(&((new numeric(-12))->setflag(status_flags::dynallocated))); + _num_11_p = reinterpret_cast(&((new numeric(-11))->setflag(status_flags::dynallocated))); + _num_10_p = reinterpret_cast(&((new numeric(-10))->setflag(status_flags::dynallocated))); + _num_9_p = reinterpret_cast(&((new numeric(-9))->setflag(status_flags::dynallocated))); + _num_8_p = reinterpret_cast(&((new numeric(-8))->setflag(status_flags::dynallocated))); + _num_7_p = reinterpret_cast(&((new numeric(-7))->setflag(status_flags::dynallocated))); + _num_6_p = reinterpret_cast(&((new numeric(-6))->setflag(status_flags::dynallocated))); + _num_5_p = reinterpret_cast(&((new numeric(-5))->setflag(status_flags::dynallocated))); + _num_4_p = reinterpret_cast(&((new numeric(-4))->setflag(status_flags::dynallocated))); + _num_3_p = reinterpret_cast(&((new numeric(-3))->setflag(status_flags::dynallocated))); + _num_2_p = reinterpret_cast(&((new numeric(-2))->setflag(status_flags::dynallocated))); + _num_1_p = reinterpret_cast(&((new numeric(-1))->setflag(status_flags::dynallocated))); + _num_1_2_p= reinterpret_cast(&((new numeric(-1,2))->setflag(status_flags::dynallocated))); + _num_1_3_p= reinterpret_cast(&((new numeric(-1,3))->setflag(status_flags::dynallocated))); + _num_1_4_p= reinterpret_cast(&((new numeric(-1,4))->setflag(status_flags::dynallocated))); + _num0_p = reinterpret_cast(&((new numeric(0))->setflag(status_flags::dynallocated))); + _num1_4_p = reinterpret_cast(&((new numeric(1,4))->setflag(status_flags::dynallocated))); + _num1_3_p = reinterpret_cast(&((new numeric(1,3))->setflag(status_flags::dynallocated))); + _num1_2_p = reinterpret_cast(&((new numeric(1,2))->setflag(status_flags::dynallocated))); + _num1_p = reinterpret_cast(&((new numeric(1))->setflag(status_flags::dynallocated))); + _num2_p = reinterpret_cast(&((new numeric(2))->setflag(status_flags::dynallocated))); + _num3_p = reinterpret_cast(&((new numeric(3))->setflag(status_flags::dynallocated))); + _num4_p = reinterpret_cast(&((new numeric(4))->setflag(status_flags::dynallocated))); + _num5_p = reinterpret_cast(&((new numeric(5))->setflag(status_flags::dynallocated))); + _num6_p = reinterpret_cast(&((new numeric(6))->setflag(status_flags::dynallocated))); + _num7_p = reinterpret_cast(&((new numeric(7))->setflag(status_flags::dynallocated))); + _num8_p = reinterpret_cast(&((new numeric(8))->setflag(status_flags::dynallocated))); + _num9_p = reinterpret_cast(&((new numeric(9))->setflag(status_flags::dynallocated))); + _num10_p = reinterpret_cast(&((new numeric(10))->setflag(status_flags::dynallocated))); + _num11_p = reinterpret_cast(&((new numeric(11))->setflag(status_flags::dynallocated))); + _num12_p = reinterpret_cast(&((new numeric(12))->setflag(status_flags::dynallocated))); + _num15_p = reinterpret_cast(&((new numeric(15))->setflag(status_flags::dynallocated))); + _num18_p = reinterpret_cast(&((new numeric(18))->setflag(status_flags::dynallocated))); + _num20_p = reinterpret_cast(&((new numeric(20))->setflag(status_flags::dynallocated))); + _num24_p = reinterpret_cast(&((new numeric(24))->setflag(status_flags::dynallocated))); + _num25_p = reinterpret_cast(&((new numeric(25))->setflag(status_flags::dynallocated))); + _num30_p = reinterpret_cast(&((new numeric(30))->setflag(status_flags::dynallocated))); + _num48_p = reinterpret_cast(&((new numeric(48))->setflag(status_flags::dynallocated))); + _num60_p = reinterpret_cast(&((new numeric(60))->setflag(status_flags::dynallocated))); + _num120_p = reinterpret_cast(&((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 diff --git a/ginac/utils.h b/ginac/utils.h index 78334b17..bfd21c53 100644 --- a/ginac/utils.h +++ b/ginac/utils.h @@ -307,104 +307,153 @@ again: 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) -- 2.44.0