]> www.ginac.de Git - ginac.git/commitdiff
Merge some cosmetic patches.
authorRichard Kreckel <kreckel@ginac.de>
Wed, 16 Dec 2015 21:02:25 +0000 (22:02 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Wed, 16 Dec 2015 21:15:52 +0000 (22:15 +0100)
This is a collection of some minor optimizations and indentation fixes.

15 files changed:
INSTALL
doc/CodingStyle
ginac/color.cpp
ginac/expairseq.cpp
ginac/expairseq.h
ginac/factor.cpp
ginac/function.cppy
ginac/inifcns.cpp
ginac/inifcns_trans.cpp
ginac/mul.cpp
ginac/normal.cpp
ginac/operators.cpp
ginac/polynomial/collect_vargs.cpp
ginac/power.cpp
ginac/pseries.cpp

diff --git a/INSTALL b/INSTALL
index 635ec4b67b9a2ed74fd0a01401cc7d925299439c..08509aabbe196818908cff9378fe404d2b482b5a 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -5,7 +5,7 @@ GiNaC requires the CLN library by Bruno Haible installed on your system.
 It is available from <ftp://ftpthep.physik.uni-mainz.de/pub/gnu/>.
 
 You will also need a decent ISO C++-11 compiler. We recommend the C++
-compiler from the GNU compiler collection, GCC >= 4.9. If you have a
+compiler from the GNU compiler collection, GCC >= 4.8. If you have a
 different or older compiler you are on your own. Note that you may have to
 use the same compiler you compiled CLN with because of differing
 name-mangling schemes.
@@ -20,7 +20,7 @@ TeX are necessary.
 
 Known to work with:
  - Linux on x86 and x86_64 using 
-   - GCC 4.8, 4.9, 5.1, and 5.2
+   - GCC 4.8, 4.9, 5.1, 5.2, and 5.3
    - Clang 3.5.0
 
 Known not to work with:
index e387bf294eb5a02e7ef95714bb11af96feea53e8..b537f19b3bab5182612860666d571527f9217112 100644 (file)
@@ -27,7 +27,7 @@ please try to follow these rules. It will make our (and your) lives easier. :-)
 ----------------------
 
 Any code in GiNaC should comply to the C++ standard, as defined by ISO/IEC
-14882:1998(E). Don't use compiler-specific language extensions unless they
+14882:2011(E). Don't use compiler-specific language extensions unless they
 are surrounded by appropriate "#ifdef"s, and you also provide a compliant
 version of the code in question for other compilers.
 
index 0f7723e359d92f5dad7af8d14bf7f2f0406b7185..89377e24b2f836a4c286043049e65d6511388ae7 100644 (file)
@@ -400,9 +400,7 @@ bool su3d::contract_with(exvector::iterator self, exvector::iterator other, exve
                 && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
 
                        exvector self_indices = ex_to<indexed>(*self).get_indices();
-                       exvector dummy_indices;
-                       dummy_indices.push_back(other[0].op(1));
-                       dummy_indices.push_back(other[1].op(1));
+                       exvector dummy_indices = {other[0].op(1), other[1].op(1)};
                        int sig;
                        ex a = permute_free_index_to_front(self_indices, dummy_indices, sig);
                        *self = numeric(5, 6);
@@ -453,9 +451,7 @@ bool su3f::contract_with(exvector::iterator self, exvector::iterator other, exve
                 && ex_to<indexed>(*self).has_dummy_index_for(other[1].op(1))) {
 
                        exvector self_indices = ex_to<indexed>(*self).get_indices();
-                       exvector dummy_indices;
-                       dummy_indices.push_back(other[0].op(1));
-                       dummy_indices.push_back(other[1].op(1));
+                       exvector dummy_indices = {other[0].op(1), other[1].op(1)};
                        int sig;
                        ex a = permute_free_index_to_front(self_indices, dummy_indices, sig);
                        *self = numeric(3, 2) * sig * I;
index e99d21fe0061d64d2102c9dd1df966decc27bb2b..55fa311bea087344eff0bb78ca24e1d78ab54107 100644 (file)
@@ -601,11 +601,8 @@ bool expairseq::can_make_flat(const expair &p) const
 
 void expairseq::construct_from_2_ex_via_exvector(const ex &lh, const ex &rh)
 {
-       exvector v;
-       v.reserve(2);
-       v.push_back(lh);
-       v.push_back(rh);
-       construct_from_exvector(v);
+       const exvector v = {lh, rh};
+       construct_from_exvector(std::move(v));
 }
 
 void expairseq::construct_from_2_ex(const ex &lh, const ex &rh)
index 41b077d5097f11d968aaec72cc83974631ecec50..f0a0b4e65b71f415aa1b3075c5b1b682153a1960 100644 (file)
@@ -166,7 +166,7 @@ class make_flat_inserter
                                return x;
                        sort(dummies_of_factor.begin(), dummies_of_factor.end(), ex_is_less());
                        ex new_factor = rename_dummy_indices_uniquely(used_indices,
-                               dummies_of_factor, x);
+                                                                     dummies_of_factor, x);
                        combine_indices(dummies_of_factor);
                        return new_factor;
                }
@@ -175,8 +175,8 @@ class make_flat_inserter
                {
                        exvector new_dummy_indices;
                        set_union(used_indices.begin(), used_indices.end(),
-                               dummies_of_factor.begin(), dummies_of_factor.end(),
-                               std::back_insert_iterator<exvector>(new_dummy_indices), ex_is_less());
+                                 dummies_of_factor.begin(), dummies_of_factor.end(),
+                                 std::back_insert_iterator<exvector>(new_dummy_indices), ex_is_less());
                        used_indices.swap(new_dummy_indices);
                }
                bool do_renaming;
index 30d7953be90c830baced6c4e92410cdab5e3f416..21f024265afc89bae171c90aa96a73506c338a65 100644 (file)
@@ -916,8 +916,7 @@ static void berlekamp(const umodpoly& a, upvec& upv)
                return;
        }
 
-       list<umodpoly> factors;
-       factors.push_back(a);
+       list<umodpoly> factors = {a};
        unsigned int size = 1;
        unsigned int r = 1;
        unsigned int q = cl_I_to_uint(R->modulus);
@@ -937,8 +936,7 @@ static void berlekamp(const umodpoly& a, upvec& upv)
                                div(*u, g, uo);
                                if ( equal_one(uo) ) {
                                        throw logic_error("berlekamp: unexpected divisor.");
-                               }
-                               else {
+                               } else {
                                        *u = uo;
                                }
                                factors.push_back(g);
@@ -1021,8 +1019,7 @@ static void modsqrfree(const umodpoly& a, upvec& factors, vector<int>& mult)
                                mult[i] *= prime;
                        }
                }
-       }
-       else {
+       } else {
                umodpoly ap;
                expt_1_over_p(a, prime, ap);
                size_t previ = mult.size();
@@ -1107,8 +1104,7 @@ static void same_degree_factor(const umodpoly& a, upvec& upv)
        for ( size_t i=0; i<degrees.size(); ++i ) {
                if ( degrees[i] == degree(ddfactors[i]) ) {
                        upv.push_back(ddfactors[i]);
-               }
-               else {
+               } else {
                        berlekamp(ddfactors[i], upv);
                }
        }
@@ -1314,8 +1310,7 @@ static void hensel_univar(const upoly& a_, unsigned int p, const umodpoly& u1_,
                if ( alpha != 1 ) {
                        w = w / alpha;
                }
-       }
-       else {
+       } else {
                u.clear();
        }
 }
@@ -1328,20 +1323,22 @@ static void hensel_univar(const upoly& a_, unsigned int p, const umodpoly& u1_,
 static unsigned int next_prime(unsigned int p)
 {
        static vector<unsigned int> primes;
-       if ( primes.size() == 0 ) {
-               primes.push_back(3); primes.push_back(5); primes.push_back(7);
+       if (primes.empty()) {
+               primes = {3, 5, 7};
        }
        if ( p >= primes.back() ) {
                unsigned int candidate = primes.back() + 2;
                while ( true ) {
                        size_t n = primes.size()/2;
                        for ( size_t i=0; i<n; ++i ) {
-                               if ( candidate % primes[i] ) continue;
+                               if (candidate % primes[i])
+                                       continue;
                                candidate += 2;
                                i=-1;
                        }
                        primes.push_back(candidate);
-                       if ( candidate > p ) break;
+                       if (candidate > p)
+                               break;
                }
                return candidate;
        }
@@ -1405,8 +1402,7 @@ public:
                        if ( len > n/2 ) return false;
                        fill(k.begin(), k.begin()+len, 1);
                        fill(k.begin()+len+1, k.end(), 0);
-               }
-               else {
+               } else {
                        k[last++] = 0;
                        k[last] = 1;
                }
@@ -1429,8 +1425,7 @@ private:
                        if ( d ) {
                                if ( cache[pos].size() >= d ) {
                                        lr[group] = lr[group] * cache[pos][d-1];
-                               }
-                               else {
+                               } else {
                                        if ( cache[pos].size() == 0 ) {
                                                cache[pos].push_back(factors[pos] * factors[pos+1]);
                                        }
@@ -1444,8 +1439,7 @@ private:
                                        }
                                        lr[group] = lr[group] * cache[pos].back();
                                }
-                       }
-                       else {
+                       } else {
                                lr[group] = lr[group] * factors[pos];
                        }
                } while ( i < n );
@@ -1456,8 +1450,7 @@ private:
                lr[1] = one;
                if ( n > 6 ) {
                        split_cached();
-               }
-               else {
+               } else {
                        for ( size_t i=0; i<n; ++i ) {
                                lr[k[i]] = lr[k[i]] * factors[i];
                        }
@@ -1542,8 +1535,7 @@ static ex factor_univariate(const ex& poly, const ex& x, unsigned int& prime)
                        minfactors = trialfactors.size();
                        lastp = prime;
                        trials = 1;
-               }
-               else {
+               } else {
                        ++trials;
                }
        }
@@ -1597,15 +1589,13 @@ static ex factor_univariate(const ex& poly, const ex& x, unsigned int& prime)
                                                }
                                        }
                                        break;
-                               }
-                               else {
+                               } else {
                                        upvec newfactors1(part.size_left()), newfactors2(part.size_right());
                                        auto i1 = newfactors1.begin(), i2 = newfactors2.begin();
                                        for ( size_t i=0; i<n; ++i ) {
                                                if ( part[i] ) {
                                                        *i2++ = tocheck.top().factors[i];
-                                               }
-                                               else {
+                                               } else {
                                                        *i1++ = tocheck.top().factors[i];
                                                }
                                        }
@@ -1617,8 +1607,7 @@ static ex factor_univariate(const ex& poly, const ex& x, unsigned int& prime)
                                        tocheck.push(mf);
                                        break;
                                }
-                       }
-                       else {
+                       } else {
                                // not successful
                                if ( !part.next() ) {
                                        // if no more combinations left, return polynomial as
@@ -1808,8 +1797,7 @@ static upvec univar_diophant(const upvec& a, const ex& x, unsigned int m, unsign
                        rem(bmod, a[j], buf);
                        result.push_back(buf);
                }
-       }
-       else {
+       } else {
                umodpoly s, t;
                eea_lift(a[1], a[0], x, p, k, s, t);
                umodpoly bmod = umodpoly_to_umodpoly(s, R, m);
@@ -1843,8 +1831,7 @@ struct make_modular_map : public map_function {
                        numeric n(R->retract(emod));
                        if ( n > halfmod ) {
                                return n-mod;
-                       }
-                       else {
+                       } else {
                                return n;
                        }
                }
@@ -1937,8 +1924,7 @@ static vector<ex> multivar_diophant(const vector<ex>& a_, const ex& x, const ex&
                                e = make_modular(buf, R);
                        }
                }
-       }
-       else {
+       } else {
                upvec amod;
                for ( size_t i=0; i<a.size(); ++i ) {
                        umodpoly up;
@@ -1952,8 +1938,7 @@ static vector<ex> multivar_diophant(const vector<ex>& a_, const ex& x, const ex&
                if ( is_a<add>(c) ) {
                        nterms = c.nops();
                        z = c.op(0);
-               }
-               else {
+               } else {
                        nterms = 1;
                        z = c;
                }
@@ -2090,8 +2075,7 @@ static ex hensel_multivar(const ex& a, const ex& x, const vector<EvalPoint>& I,
                        res.append(U[i]);
                }
                return res;
-       }
-       else {
+       } else {
                lst res;
                return lst{};
        }
@@ -2325,8 +2309,7 @@ static ex factor_multivariate(const ex& poly, const exset& syms)
                        for ( size_t i=1; i<ufaclst.nops(); ++i ) {
                                C[i-1] = ufaclst.op(i).lcoeff(x);
                        }
-               }
-               else {
+               } else {
                        // difficult case.
                        // we use the property of the ftilde having a unique prime factor.
                        // details can be found in [Wan].
@@ -2361,8 +2344,7 @@ static ex factor_multivariate(const ex& poly, const exset& syms)
                                        }
                                        C[i] = D[i] * prefac;
                                }
-                       }
-                       else {
+                       } else {
                                for ( int i=0; i<factor_count; ++i ) {
                                        numeric prefac = ex_to<numeric>(ufaclst.op(i+1).lcoeff(x));
                                        for ( int j=ftilde.size()-1; j>=0; --j ) {
@@ -2486,8 +2468,7 @@ static ex factor_sqrfree(const ex& poly)
                        int ld = poly.ldegree(x);
                        ex res = factor_univariate(expand(poly/pow(x, ld)), x);
                        return res * pow(x,ld);
-               }
-               else {
+               } else {
                        ex res = factor_univariate(poly, x);
                        return res;
                }
@@ -2514,8 +2495,7 @@ struct apply_factor_map : public map_function {
                        for ( size_t i=0; i<e.nops(); ++i ) {
                                if ( e.op(i).info(info_flags::polynomial) ) {
                                        s1 += e.op(i);
-                               }
-                               else {
+                               } else {
                                        s2 += e.op(i);
                                }
                        }
@@ -2577,17 +2557,14 @@ ex factor(const ex& poly, unsigned options)
                                const ex& base = t.op(0);
                                if ( !is_a<add>(base) ) {
                                        res *= t;
-                               }
-                               else {
+                               } else {
                                        ex f = factor_sqrfree(base);
                                        res *= pow(f, t.op(1));
                                }
-                       }
-                       else if ( is_a<add>(t) ) {
+                       } else if ( is_a<add>(t) ) {
                                ex f = factor_sqrfree(t);
                                res *= f;
-                       }
-                       else {
+                       } else {
                                res *= t;
                        }
                }
index 686a76e6386d610d4d2aa07493471b42054e2951..0c551908678d57718feb0f227ddc6174170a4874 100644 (file)
@@ -142,7 +142,7 @@ function_options & function_options::set_return_type(unsigned rt, const return_t
 {
        use_return_type = true;
        return_type = rt;
-       if (rtt != 0)
+       if (rtt != nullptr)
                return_type_tinfo = *rtt;
        else
                return_type_tinfo = make_return_type_t<function>();
@@ -380,7 +380,7 @@ ex function::eval() const
                        // Something has changed while sorting arguments, more evaluations later
                        if (sig == 0)
                                return _ex0;
-                       return ex(sig) * thiscontainer(v);
+                       return ex(sig) * thiscontainer(std::move(v));
                }
        }
 
index 850ed04a5515e666f18ca3e42aa25a7957196bf7..89a3bcbffc61f7f50023efc8df885d79acdf79d5 100644 (file)
@@ -354,9 +354,9 @@ static ex abs_power(const ex & arg, const ex & exp)
 {
        if ((is_a<numeric>(exp) && ex_to<numeric>(exp).is_even()) || exp.info(info_flags::even)) {
                if (arg.info(info_flags::real) || arg.is_equal(arg.conjugate()))
-                       return power(arg, exp);
+                       return pow(arg, exp);
                else
-                       return power(arg, exp/2)*power(arg.conjugate(), exp/2);
+                       return pow(arg, exp/2) * pow(arg.conjugate(), exp/2);
        } else
                return power(abs(arg), exp).hold();
 }
index dd84418974b1c34c377894ced74a6906b258d519..12a082a4b2d2b0ae15440a2474a64ffb30dc1002 100644 (file)
@@ -242,12 +242,8 @@ static ex log_series(const ex &arg,
                        // in this case n more (or less) terms are needed
                        // (sadly, to generate them, we have to start from the beginning)
                        if (n == 0 && coeff == 1) {
-                               epvector epv;
-                               ex acc = dynallocate<pseries>(rel, epv);
-                               epv.reserve(2);
-                               epv.push_back(expair(-1, _ex0));
-                               epv.push_back(expair(Order(_ex1), order));
-                               ex rest = pseries(rel, std::move(epv)).add_series(argser);
+                               ex rest = pseries(rel, epvector{expair(-1, _ex0), expair(Order(_ex1), order)}).add_series(argser);
+                               ex acc = dynallocate<pseries>(rel, epvector());
                                for (int i = order-1; i>0; --i) {
                                        epvector cterm { expair(i%2 ? _ex1/i : _ex_1/i, _ex0) };
                                        acc = pseries(rel, std::move(cterm)).add_series(ex_to<pseries>(acc));
index 0a6fca40b7a06cb25749f80cae700c9bf5fb1b63..36960c0a8b63d5300f61ee842e5dd1280605d2d6 100644 (file)
@@ -500,7 +500,7 @@ ex mul::eval() const
                        distrseq.push_back(addref.combine_pair_with_coeff_to_pair(it, overall_coeff));
                }
                return dynallocate<add>(std::move(distrseq),
-                                        ex_to<numeric>(addref.overall_coeff).mul_dyn(ex_to<numeric>(overall_coeff)))
+                                       ex_to<numeric>(addref.overall_coeff).mul_dyn(ex_to<numeric>(overall_coeff)))
                        .setflag(status_flags::evaluated);
        } else if ((seq_size >= 2) && (! (flags & status_flags::expanded))) {
                // Strip the content and the unit part from each term. Thus
@@ -554,9 +554,9 @@ ex mul::eval() const
                        add & primitive = dynallocate<add>(addref);
                        primitive.clearflag(status_flags::hash_calculated);
                        primitive.overall_coeff = ex_to<numeric>(primitive.overall_coeff).div_dyn(c);
-                       for (epvector::iterator ai = primitive.seq.begin(); ai != primitive.seq.end(); ++ai)
-                               ai->coeff = ex_to<numeric>(ai->coeff).div_dyn(c);
-                       
+                       for (auto & ai : primitive.seq)
+                               ai.coeff = ex_to<numeric>(ai.coeff).div_dyn(c);
+
                        s.push_back(expair(primitive, _ex1));
 
                        ++i;
@@ -577,7 +577,7 @@ ex mul::eval() const
 ex mul::evalf(int level) const
 {
        if (level==1)
-               return mul(seq,overall_coeff);
+               return mul(seq, overall_coeff);
        
        if (level==-max_recursion_level)
                throw(std::runtime_error("max recursion level reached"));
@@ -797,10 +797,10 @@ retry1:
                                        subsed[j] = true;
                        ex subsed_pattern
                                = it.first.subs(repls, subs_options::no_pattern);
-                       divide_by *= power(subsed_pattern, nummatches);
+                       divide_by *= pow(subsed_pattern, nummatches);
                        ex subsed_result
                                = it.second.subs(repls, subs_options::no_pattern);
-                       multiply_by *= power(subsed_result, nummatches);
+                       multiply_by *= pow(subsed_result, nummatches);
                        goto retry1;
 
                } else {
@@ -812,10 +812,10 @@ retry1:
                                        subsed[j] = true;
                                        ex subsed_pattern
                                                = it.first.subs(repls, subs_options::no_pattern);
-                                       divide_by *= power(subsed_pattern, nummatches);
+                                       divide_by *= pow(subsed_pattern, nummatches);
                                        ex subsed_result
                                                = it.second.subs(repls, subs_options::no_pattern);
-                                       multiply_by *= power(subsed_result, nummatches);
+                                       multiply_by *= pow(subsed_result, nummatches);
                                }
                        }
                }
@@ -879,7 +879,7 @@ ex mul::derivative(const symbol & s) const
        auto i = seq.begin(), end = seq.end();
        auto i2 = mulseq.begin();
        while (i != end) {
-               expair ep = split_ex_to_pair(power(i->rest, i->coeff - _ex1) *
+               expair ep = split_ex_to_pair(pow(i->rest, i->coeff - _ex1) *
                                             i->rest.diff(s));
                ep.swap(*i2);
                addseq.push_back(dynallocate<mul>(mulseq, overall_coeff * i->coeff));
@@ -977,7 +977,7 @@ expair mul::combine_ex_with_coeff_to_pair(const ex & e,
        if (c.is_equal(_ex1))
                return split_ex_to_pair(e);
 
-       return split_ex_to_pair(power(e,c));
+       return split_ex_to_pair(pow(e,c));
 }
 
 expair mul::combine_pair_with_coeff_to_pair(const expair & p,
@@ -993,7 +993,7 @@ expair mul::combine_pair_with_coeff_to_pair(const expair & p,
        if (c.is_equal(_ex1))
                return p;
 
-       return split_ex_to_pair(power(recombine_pair_to_ex(p),c));
+       return split_ex_to_pair(pow(recombine_pair_to_ex(p),c));
 }
 
 ex mul::recombine_pair_to_ex(const expair & p) const
@@ -1071,20 +1071,22 @@ bool mul::can_be_further_expanded(const ex & e)
 
 ex mul::expand(unsigned options) const
 {
-       {
-       // trivial case: expanding the monomial (~ 30% of all calls)
-               epvector::const_iterator i = seq.begin(), seq_end = seq.end();
-               while ((i != seq.end()) &&  is_a<symbol>(i->rest) && i->coeff.info(info_flags::integer))
-                       ++i;
-               if (i == seq_end) {
-                       setflag(status_flags::expanded);
-                       return *this;
+       // Check for trivial case: expanding the monomial (~ 30% of all calls)
+       bool monomial_case = true;
+       for (const auto & i : seq) {
+               if (!is_a<symbol>(i.rest) || !i.coeff.info(info_flags::integer)) {
+                       monomial_case = false;
+                       break;
                }
        }
+       if (monomial_case) {
+               setflag(status_flags::expanded);
+               return *this;
+       }
 
        // do not rename indices if the object has no indices at all
        if ((!(options & expand_options::expand_rename_idx)) && 
-                       this->info(info_flags::has_indices))
+           this->info(info_flags::has_indices))
                options |= expand_options::expand_rename_idx;
 
        const bool skip_idx_rename = !(options & expand_options::expand_rename_idx);
index 7968b9083b0b37fab38ff5da3f88b6350c16199c..b4b5b694225f0b557c0cb96d3edb43966ff8b94a 100644 (file)
@@ -388,7 +388,7 @@ ex quo(const ex &a, const ex &b, const ex &x, bool check_args)
                        if (!divide(rcoeff, blcoeff, term, false))
                                return dynallocate<fail>();
                }
-               term *= power(x, rdeg - bdeg);
+               term *= pow(x, rdeg - bdeg);
                v.push_back(term);
                r -= (term * b).expand();
                if (r.is_zero())
@@ -441,7 +441,7 @@ ex rem(const ex &a, const ex &b, const ex &x, bool check_args)
                        if (!divide(rcoeff, blcoeff, term, false))
                                return dynallocate<fail>();
                }
-               term *= power(x, rdeg - bdeg);
+               term *= pow(x, rdeg - bdeg);
                r -= (term * b).expand();
                if (r.is_zero())
                        break;
@@ -501,23 +501,23 @@ ex prem(const ex &a, const ex &b, const ex &x, bool check_args)
                if (bdeg == 0)
                        eb = _ex0;
                else
-                       eb -= blcoeff * power(x, bdeg);
+                       eb -= blcoeff * pow(x, bdeg);
        } else
                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();
+               ex term = (pow(x, rdeg - bdeg) * eb * rlcoeff).expand();
                if (rdeg == 0)
                        r = _ex0;
                else
-                       r -= rlcoeff * power(x, rdeg);
+                       r -= rlcoeff * pow(x, rdeg);
                r = (blcoeff * r).expand() - term;
                rdeg = r.degree(x);
                i++;
        }
-       return power(blcoeff, delta - i) * r;
+       return pow(blcoeff, delta - i) * r;
 }
 
 
@@ -553,17 +553,17 @@ ex sprem(const ex &a, const ex &b, const ex &x, bool check_args)
                if (bdeg == 0)
                        eb = _ex0;
                else
-                       eb -= blcoeff * power(x, bdeg);
+                       eb -= blcoeff * pow(x, bdeg);
        } else
                blcoeff = _ex1;
 
        while (rdeg >= bdeg && !r.is_zero()) {
                ex rlcoeff = r.coeff(x, rdeg);
-               ex term = (power(x, rdeg - bdeg) * eb * rlcoeff).expand();
+               ex term = (pow(x, rdeg - bdeg) * eb * rlcoeff).expand();
                if (rdeg == 0)
                        r = _ex0;
                else
-                       r -= rlcoeff * power(x, rdeg);
+                       r -= rlcoeff * pow(x, rdeg);
                r = (blcoeff * r).expand() - term;
                rdeg = r.degree(x);
        }
@@ -663,7 +663,7 @@ bool divide(const ex &a, const ex &b, ex &q, bool check_args)
                int a_exp = ex_to<numeric>(a.op(1)).to_int();
                ex rem_i;
                if (divide(ab, b, rem_i, false)) {
-                       q = rem_i*power(ab, a_exp - 1);
+                       q = rem_i * pow(ab, a_exp - 1);
                        return true;
                }
 // code below is commented-out because it leads to a significant slowdown
@@ -693,7 +693,7 @@ bool divide(const ex &a, const ex &b, ex &q, bool check_args)
                else
                        if (!divide(rcoeff, blcoeff, term, false))
                                return false;
-               term *= power(x, rdeg - bdeg);
+               term *= pow(x, rdeg - bdeg);
                v.push_back(term);
                r -= (term * b).expand();
                if (r.is_zero()) {
@@ -876,7 +876,7 @@ static bool divide_in_z(const ex &a, const ex &b, ex &q, sym_desc_vec::const_ite
                ex term, rcoeff = r.coeff(x, rdeg);
                if (!divide_in_z(rcoeff, blcoeff, term, var+1))
                        break;
-               term = (term * power(x, rdeg - bdeg)).expand();
+               term = (term * pow(x, rdeg - bdeg)).expand();
                v.push_back(term);
                r -= (term * eb).expand();
                if (r.is_zero()) {
@@ -1237,7 +1237,7 @@ static ex interpolate(const ex &gamma, const numeric &xi, const ex &x, int degre
        numeric rxi = xi.inverse();
        for (int i=0; !e.is_zero(); i++) {
                ex gi = e.smod(xi);
-               g.push_back(gi * power(x, i));
+               g.push_back(gi * pow(x, i));
                e = (e - gi) * rxi;
        }
        return dynallocate<add>(g);
@@ -1563,7 +1563,7 @@ ex gcd(const ex &a, const ex &b, ex *ca, ex *cb, bool check_args, unsigned optio
        int ldeg_b = var->ldeg_b;
        int min_ldeg = std::min(ldeg_a,ldeg_b);
        if (min_ldeg > 0) {
-               ex common = power(x, min_ldeg);
+               ex common = pow(x, min_ldeg);
                return gcd((aex / common).expand(), (bex / common).expand(), ca, cb, false) * common;
        }
 
@@ -1644,14 +1644,14 @@ static ex gcd_pf_pow_pow(const ex& a, const ex& b, ex* ca, ex* cb)
                        if (ca)
                                *ca = _ex1;
                        if (cb)
-                               *cb = power(p, exp_b - exp_a);
-                       return power(p, exp_a);
+                               *cb = pow(p, exp_b - exp_a);
+                       return pow(p, exp_a);
                } else {
                        if (ca)
-                               *ca = power(p, exp_a - exp_b);
+                               *ca = pow(p, exp_a - exp_b);
                        if (cb)
                                *cb = _ex1;
-                       return power(p, exp_b);
+                       return pow(p, exp_b);
                }
        }
 
@@ -1671,11 +1671,11 @@ static ex gcd_pf_pow_pow(const ex& a, const ex& b, ex* ca, ex* cb)
        // a(x) = g(x)^n A(x)^n, b(x) = g(x)^m B(x)^m ==>
        // gcd(a, b) = g(x)^n gcd(A(x)^n, g(x)^(n-m) B(x)^m
        if (exp_a < exp_b) {
-               ex pg =  gcd(power(p_co, exp_a), power(p_gcd, exp_b-exp_a)*power(pb_co, exp_b), ca, cb, false);
-               return power(p_gcd, exp_a)*pg;
+               ex pg =  gcd(pow(p_co, exp_a), pow(p_gcd, exp_b-exp_a)*pow(pb_co, exp_b), ca, cb, false);
+               return pow(p_gcd, exp_a)*pg;
        } else {
-               ex pg = gcd(power(p_gcd, exp_a - exp_b)*power(p_co, exp_a), power(pb_co, exp_b), ca, cb, false);
-               return power(p_gcd, exp_b)*pg;
+               ex pg = gcd(pow(p_gcd, exp_a - exp_b)*pow(p_co, exp_a), pow(pb_co, exp_b), ca, cb, false);
+               return pow(p_gcd, exp_b)*pg;
        }
 }
 
@@ -1694,7 +1694,7 @@ static ex gcd_pf_pow(const ex& a, const ex& b, ex* ca, ex* cb)
        if (p.is_equal(b)) {
                // a = p^n, b = p, gcd = p
                if (ca)
-                       *ca = power(p, a.op(1) - 1);
+                       *ca = pow(p, a.op(1) - 1);
                if (cb)
                        *cb = _ex1;
                return p;
@@ -1712,7 +1712,7 @@ static ex gcd_pf_pow(const ex& a, const ex& b, ex* ca, ex* cb)
                return _ex1;
        }
        // a(x) = g(x)^n A(x)^n, b(x) = g(x) B(x) ==> gcd(a, b) = g(x) gcd(g(x)^(n-1) A(x)^n, B(x))
-       ex rg = gcd(power(p_gcd, exp_a-1)*power(p_co, exp_a), bpart_co, ca, cb, false);
+       ex rg = gcd(pow(p_gcd, exp_a-1)*pow(p_co, exp_a), bpart_co, ca, cb, false);
        return p_gcd*rg;
 }
 
@@ -1876,7 +1876,7 @@ ex sqrfree(const ex &a, const lst &l)
        ex result = _ex1;
        int p = 1;
        for (auto & it : factors)
-               result *= power(it, p++);
+               result *= pow(it, p++);
 
        // Yun's algorithm does not account for constant factors.  (For univariate
        // polynomials it works only in the monic case.)  We can correct this by
@@ -2248,12 +2248,12 @@ ex power::normal(exmap & repl, exmap & rev_lookup, int level) const
                if (n_exponent.info(info_flags::positive)) {
 
                        // (a/b)^n -> {a^n, b^n}
-                       return dynallocate<lst>({power(n_basis.op(0), n_exponent), power(n_basis.op(1), n_exponent)});
+                       return dynallocate<lst>({pow(n_basis.op(0), n_exponent), pow(n_basis.op(1), n_exponent)});
 
                } else if (n_exponent.info(info_flags::negative)) {
 
                        // (a/b)^-n -> {b^n, a^n}
-                       return dynallocate<lst>({power(n_basis.op(1), -n_exponent), power(n_basis.op(0), -n_exponent)});
+                       return dynallocate<lst>({pow(n_basis.op(1), -n_exponent), pow(n_basis.op(0), -n_exponent)});
                }
 
        } else {
@@ -2261,25 +2261,25 @@ ex power::normal(exmap & repl, exmap & rev_lookup, int level) const
                if (n_exponent.info(info_flags::positive)) {
 
                        // (a/b)^x -> {sym((a/b)^x), 1}
-                       return dynallocate<lst>({replace_with_symbol(power(n_basis.op(0) / n_basis.op(1), n_exponent), repl, rev_lookup), _ex1});
+                       return dynallocate<lst>({replace_with_symbol(pow(n_basis.op(0) / n_basis.op(1), n_exponent), repl, rev_lookup), _ex1});
 
                } else if (n_exponent.info(info_flags::negative)) {
 
                        if (n_basis.op(1).is_equal(_ex1)) {
 
                                // a^-x -> {1, sym(a^x)}
-                               return dynallocate<lst>({_ex1, replace_with_symbol(power(n_basis.op(0), -n_exponent), repl, rev_lookup)});
+                               return dynallocate<lst>({_ex1, replace_with_symbol(pow(n_basis.op(0), -n_exponent), repl, rev_lookup)});
 
                        } else {
 
                                // (a/b)^-x -> {sym((b/a)^x), 1}
-                               return dynallocate<lst>({replace_with_symbol(power(n_basis.op(1) / n_basis.op(0), -n_exponent), repl, rev_lookup), _ex1});
+                               return dynallocate<lst>({replace_with_symbol(pow(n_basis.op(1) / n_basis.op(0), -n_exponent), repl, rev_lookup), _ex1});
                        }
                }
        }
 
        // (a/b)^x -> {sym((a/b)^x, 1}
-       return dynallocate<lst>({replace_with_symbol(power(n_basis.op(0) / n_basis.op(1), n_exponent), repl, rev_lookup), _ex1});
+       return dynallocate<lst>({replace_with_symbol(pow(n_basis.op(0) / n_basis.op(1), n_exponent), repl, rev_lookup), _ex1});
 }
 
 
@@ -2516,7 +2516,7 @@ ex numeric::to_polynomial(exmap & repl) const
 ex power::to_rational(exmap & repl) const
 {
        if (exponent.info(info_flags::integer))
-               return power(basis.to_rational(repl), exponent);
+               return pow(basis.to_rational(repl), exponent);
        else
                return replace_with_symbol(*this, repl);
 }
@@ -2526,17 +2526,17 @@ ex power::to_rational(exmap & repl) const
 ex power::to_polynomial(exmap & repl) const
 {
        if (exponent.info(info_flags::posint))
-               return power(basis.to_rational(repl), exponent);
+               return pow(basis.to_rational(repl), exponent);
        else if (exponent.info(info_flags::negint))
        {
                ex basis_pref = collect_common_factors(basis);
                if (is_exactly_a<mul>(basis_pref) || is_exactly_a<power>(basis_pref)) {
                        // (A*B)^n will be automagically transformed to A^n*B^n
-                       ex t = power(basis_pref, exponent);
+                       ex t = pow(basis_pref, exponent);
                        return t.to_polynomial(repl);
                }
                else
-                       return power(replace_with_symbol(power(basis, _ex_1), repl), -exponent);
+                       return pow(replace_with_symbol(pow(basis, _ex_1), repl), -exponent);
        } 
        else
                return replace_with_symbol(*this, repl);
@@ -2655,8 +2655,8 @@ term_done:        ;
                        ex eb = e.op(0).to_polynomial(repl);
                        ex factor_local(_ex1);
                        ex pre_res = find_common_factor(eb, factor_local, repl);
-                       factor *= power(factor_local, e_exp);
-                       return power(pre_res, e_exp);
+                       factor *= pow(factor_local, e_exp);
+                       return pow(pre_res, e_exp);
                        
                } else
                        return e.to_polynomial(repl);
index 4cb57ec7d510586b04c3f84b9021afc09b5ff570..9ab73b0a67147b40de68134d316620887c75c8fd 100644 (file)
 
 namespace GiNaC {
 
-/** Used internally by operator+() to add two ex objects together. */
+/** Used internally by operator+() to add two ex objects. */
 static inline const ex exadd(const ex & lh, const ex & rh)
 {
        return dynallocate<add>(lh, rh);
 }
 
-/** Used internally by operator*() to multiply two ex objects together. */
+/** Used internally by operator*() to multiply two ex objects. */
 static inline const ex exmul(const ex & lh, const ex & rh)
 {
        // Check if we are constructing a mul object or a ncmul object.  Due to
@@ -247,32 +247,32 @@ const numeric operator--(numeric & lh, int)
 
 const relational operator==(const ex & lh, const ex & rh)
 {
-       return relational(lh,rh,relational::equal);
+       return dynallocate<relational>(lh, rh, relational::equal);
 }
 
 const relational operator!=(const ex & lh, const ex & rh)
 {
-       return relational(lh,rh,relational::not_equal);
+       return dynallocate<relational>(lh, rh, relational::not_equal);
 }
 
 const relational operator<(const ex & lh, const ex & rh)
 {
-       return relational(lh,rh,relational::less);
+       return dynallocate<relational>(lh, rh, relational::less);
 }
 
 const relational operator<=(const ex & lh, const ex & rh)
 {
-       return relational(lh,rh,relational::less_or_equal);
+       return dynallocate<relational>(lh, rh, relational::less_or_equal);
 }
 
 const relational operator>(const ex & lh, const ex & rh)
 {
-       return relational(lh,rh,relational::greater);
+       return dynallocate<relational>(lh, rh, relational::greater);
 }
 
 const relational operator>=(const ex & lh, const ex & rh)
 {
-       return relational(lh,rh,relational::greater_or_equal);
+       return dynallocate<relational>(lh, rh, relational::greater_or_equal);
 }
 
 // input/output stream operators and manipulators
index 9ff206ef04e696e53acad880f40066ed2d3d387d..661372d1d43ed580cfb2a9f691a8e510a2672146 100644 (file)
@@ -155,7 +155,7 @@ ex_collect_to_ex(const ex_collect_t& ec, const exvector& vars)
                                "expression has " << exp_vector.size() << " instead");
 
                        if (exp_vector[j] != 0)
-                               tv.push_back(power(vars[j], exp_vector[j]));
+                               tv.push_back(pow(vars[j], exp_vector[j]));
                }
                tv.push_back(ec[i].second);
                ex tmp = dynallocate<mul>(tv);
index c376009b5c416f5c2ec3d68e35e6c869b440602e..3baa3c6f9125f8e65a26d460d15cb46b6f7d1ac0 100644 (file)
@@ -421,7 +421,7 @@ ex power::eval() const
 
        // Turn (x^c)^d into x^(c*d) in the case that x is positive and c is real.
        if (is_exactly_a<power>(basis) && basis.op(0).info(info_flags::positive) && basis.op(1).info(info_flags::real))
-               return power(basis.op(0), basis.op(1) * exponent);
+               return dynallocate<power>(basis.op(0), basis.op(1) * exponent);
 
        if ( num_exponent ) {
 
@@ -472,8 +472,7 @@ ex power::eval() const
                                        // because otherwise we'll end up with something like
                                        //    (7/8)^(4/3)  ->  7/8*(1/2*7^(1/3))
                                        // instead of 7/16*7^(1/3).
-                                       ex prod = power(*num_basis,r.div(m));
-                                       return prod*power(*num_basis,q);
+                                       return pow(basis, r.div(m)) * pow(basis, q);
                                }
                        }
                }
@@ -490,14 +489,14 @@ ex power::eval() const
                                GINAC_ASSERT(num_sub_exponent!=numeric(1));
                                if (num_exponent->is_integer() || (abs(num_sub_exponent) - (*_num1_p)).is_negative() ||
                                    (num_sub_exponent == *_num_1_p && num_exponent->is_positive())) {
-                                       return power(sub_basis,num_sub_exponent.mul(*num_exponent));
+                                       return dynallocate<power>(sub_basis, num_sub_exponent.mul(*num_exponent));
                                }
                        }
                }
        
                // ^(*(x,y,z),c1) -> *(x^c1,y^c1,z^c1) (c1 integer)
                if (num_exponent->is_integer() && is_exactly_a<mul>(basis)) {
-                       return expand_mul(ex_to<mul>(basis), *num_exponent, 0);
+                       return expand_mul(ex_to<mul>(basis), *num_exponent, false);
                }
 
                // (2*x + 6*y)^(-4) -> 1/16*(x + 3*y)^(-4)
@@ -584,7 +583,7 @@ ex power::evalf(int level) const
                        eexponent = exponent;
        }
 
-       return power(ebasis,eexponent);
+       return dynallocate<power>(ebasis, eexponent);
 }
 
 ex power::evalm() const
@@ -642,7 +641,7 @@ ex power::subs(const exmap & m, unsigned options) const
                if (tryfactsubs(*this, it.first, nummatches, repls)) {
                        ex anum = it.second.subs(repls, subs_options::no_pattern);
                        ex aden = it.first.subs(repls, subs_options::no_pattern);
-                       ex result = (*this)*power(anum/aden, nummatches);
+                       ex result = (*this) * pow(anum/aden, nummatches);
                        return (ex_to<basic>(result)).subs_one_level(m, options);
                }
        }
@@ -691,12 +690,12 @@ ex power::real_part() const
                // Re((a+I*b)^c)  w/  c ∈ ℤ
                long N = ex_to<numeric>(c).to_long();
                // Use real terms in Binomial expansion to construct
-               // Re(expand(power(a+I*b, N))).
+               // Re(expand(pow(a+I*b, N))).
                long NN = N > 0 ? N : -N;
-               ex numer = N > 0 ? _ex1 : power(power(a,2) + power(b,2), NN);
+               ex numer = N > 0 ? _ex1 : pow(pow(a,2) + pow(b,2), NN);
                ex result = 0;
                for (long n = 0; n <= NN; n += 2) {
-                       ex term = binomial(NN, n) * power(a, NN-n) * power(b, n) / numer;
+                       ex term = binomial(NN, n) * pow(a, NN-n) * pow(b, n) / numer;
                        if (n % 4 == 0) {
                                result += term;  // sign: I^n w/ n == 4*m
                        } else {
@@ -708,11 +707,12 @@ ex power::real_part() const
 
        // Re((a+I*b)^(c+I*d))
        const ex d = exponent.imag_part();
-       return power(abs(basis),c)*exp(-d*atan2(b,a))*cos(c*atan2(b,a)+d*log(abs(basis)));
+       return pow(abs(basis),c) * exp(-d*atan2(b,a)) * cos(c*atan2(b,a)+d*log(abs(basis)));
 }
 
 ex power::imag_part() const
 {
+       // basis == a+I*b, exponent == c+I*d
        const ex a = basis.real_part();
        const ex c = exponent.real_part();
        if (basis.is_equal(a) && exponent.is_equal(c)) {
@@ -725,13 +725,13 @@ ex power::imag_part() const
                // Im((a+I*b)^c)  w/  c ∈ ℤ
                long N = ex_to<numeric>(c).to_long();
                // Use imaginary terms in Binomial expansion to construct
-               // Im(expand(power(a+I*b, N))).
+               // Im(expand(pow(a+I*b, N))).
                long p = N > 0 ? 1 : 3;  // modulus for positive sign
                long NN = N > 0 ? N : -N;
-               ex numer = N > 0 ? _ex1 : power(power(a,2) + power(b,2), NN);
+               ex numer = N > 0 ? _ex1 : pow(pow(a,2) + pow(b,2), NN);
                ex result = 0;
                for (long n = 1; n <= NN; n += 2) {
-                       ex term = binomial(NN, n) * power(a, NN-n) * power(b, n) / numer;
+                       ex term = binomial(NN, n) * pow(a, NN-n) * pow(b, n) / numer;
                        if (n % 4 == p) {
                                result += term;  // sign: I^n w/ n == 4*m+p
                        } else {
@@ -743,7 +743,7 @@ ex power::imag_part() const
 
        // Im((a+I*b)^(c+I*d))
        const ex d = exponent.imag_part();
-       return power(abs(basis),c)*exp(-d*atan2(b,a))*sin(c*atan2(b,a)+d*log(abs(basis)));
+       return pow(abs(basis),c) * exp(-d*atan2(b,a)) * sin(c*atan2(b,a)+d*log(abs(basis)));
 }
 
 // protected
@@ -754,16 +754,11 @@ ex power::derivative(const symbol & s) const
 {
        if (is_a<numeric>(exponent)) {
                // D(b^r) = r * b^(r-1) * D(b) (faster than the formula below)
-               epvector newseq;
-               newseq.reserve(2);
-               newseq.push_back(expair(basis, exponent - _ex1));
-               newseq.push_back(expair(basis.diff(s), _ex1));
-               return mul(std::move(newseq), exponent);
+               const epvector newseq = {expair(basis, exponent - _ex1), expair(basis.diff(s), _ex1)};
+               return dynallocate<mul>(std::move(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))));
+               return *this * (exponent.diff(s)*log(basis) + exponent*basis.diff(s)*pow(basis, _ex_1));
        }
 }
 
@@ -822,9 +817,9 @@ ex power::expand(unsigned options) const
                // take care on the numeric coefficient
                ex coeff=(possign? _ex1 : _ex_1);
                if (m.overall_coeff.info(info_flags::positive) && m.overall_coeff != _ex1)
-                       prodseq.push_back(power(m.overall_coeff, exponent));
+                       prodseq.push_back(pow(m.overall_coeff, exponent));
                else if (m.overall_coeff.info(info_flags::negative) && m.overall_coeff != _ex_1)
-                       prodseq.push_back(power(-m.overall_coeff, exponent));
+                       prodseq.push_back(pow(-m.overall_coeff, exponent));
                else
                        coeff *= m.overall_coeff;
 
@@ -832,7 +827,7 @@ ex power::expand(unsigned options) const
                // In either case we set a flag to avoid the second run on a part
                // which does not have positive/negative terms.
                if (prodseq.size() > 0) {
-                       ex newbasis = coeff*mul(std::move(powseq));
+                       ex newbasis = dynallocate<mul>(std::move(powseq), coeff);
                        ex_to<basic>(newbasis).setflag(status_flags::purely_indefinite);
                        return dynallocate<mul>(std::move(prodseq)) * pow(newbasis, exponent);
                } else
@@ -848,7 +843,7 @@ ex power::expand(unsigned options) const
                exvector distrseq;
                distrseq.reserve(a.seq.size() + 1);
                for (auto & cit : a.seq) {
-                       distrseq.push_back(power(expanded_basis, a.recombine_pair_to_ex(cit)));
+                       distrseq.push_back(pow(expanded_basis, a.recombine_pair_to_ex(cit)));
                }
                
                // Make sure that e.g. (x+y)^(2+a) expands the (x+y)^2 factor
@@ -858,9 +853,9 @@ ex power::expand(unsigned options) const
                        if (int_exponent > 0 && is_exactly_a<add>(expanded_basis))
                                distrseq.push_back(expand_add(ex_to<add>(expanded_basis), int_exponent, options));
                        else
-                               distrseq.push_back(power(expanded_basis, a.overall_coeff));
+                               distrseq.push_back(pow(expanded_basis, a.overall_coeff));
                } else
-                       distrseq.push_back(power(expanded_basis, a.overall_coeff));
+                       distrseq.push_back(pow(expanded_basis, a.overall_coeff));
                
                // Make sure that e.g. (x+y)^(1+a) -> x*(x+y)^a + y*(x+y)^a
                ex r = dynallocate<mul>(distrseq);
index 31a92002958399818659b65e83094b498a66dbc4..cc756ac43e9c70b0cb3bfec01af080aa8a63ed90 100644 (file)
@@ -177,7 +177,7 @@ void pseries::print_series(const print_context & c, const char *openbrace, const
                                }
                        }
                } else
-                       Order(power(var-point,i->coeff)).print(c);
+                       Order(pow(var - point, i->coeff)).print(c);
                ++i;
        }
 
@@ -281,8 +281,8 @@ ex pseries::op(size_t i) const
                throw (std::out_of_range("op() out of range"));
 
        if (is_order_function(seq[i].rest))
-               return Order(power(var-point, seq[i].coeff));
-       return seq[i].rest * power(var - point, seq[i].coeff);
+               return Order(pow(var-point, seq[i].coeff));
+       return seq[i].rest * pow(var - point, seq[i].coeff);
 }
 
 /** Return degree of highest power of the series.  This is usually the exponent
@@ -500,8 +500,7 @@ ex pseries::evalm() const
                        ex newcoeff = i->rest.evalm();
                        if (!newcoeff.is_zero())
                                newseq.push_back(expair(newcoeff, i->coeff));
-               }
-               else {
+               } else {
                        ex newcoeff = i->rest.evalm();
                        if (!are_ex_trivially_equal(newcoeff, i->rest)) {
                                something_changed = true;
@@ -589,9 +588,9 @@ ex pseries::convert_to_poly(bool no_order) const
        for (auto & it : seq) {
                if (is_order_function(it.rest)) {
                        if (!no_order)
-                               e += Order(power(var - point, it.coeff));
+                               e += Order(pow(var - point, it.coeff));
                } else
-                       e += it.rest * power(var - point, it.coeff);
+                       e += it.rest * pow(var - point, it.coeff);
        }
        return e;
 }
@@ -644,7 +643,7 @@ ex basic::series(const relational & r, int order, unsigned options) const
 
        int n;
        for (n=1; n<order; ++n) {
-               fac = fac.mul(n);
+               fac = fac.div(n);
                // We need to test for zero in order to see if the series terminates.
                // The problem is that there is no such thing as a perfect test for
                // zero.  Expanding the term occasionally helps a little...
@@ -654,7 +653,7 @@ ex basic::series(const relational & r, int order, unsigned options) const
 
                coeff = deriv.subs(r, subs_options::no_pattern);
                if (!coeff.is_zero())
-                       seq.push_back(expair(fac.inverse() * coeff, n));
+                       seq.push_back(expair(fac * coeff, n));
        }
        
        // Higher-order terms, if present
@@ -1027,7 +1026,7 @@ ex pseries::power_const(const numeric &p, int deg) const
        // Compute coefficients of the powered series
        exvector co;
        co.reserve(numcoeff);
-       co.push_back(power(coeff(var, ldeg), p));
+       co.push_back(pow(coeff(var, ldeg), p));
        for (int i=1; i<numcoeff; ++i) {
                ex sum = _ex0;
                for (int j=1; j<=i; ++j) {