]> www.ginac.de Git - ginac.git/commitdiff
Move ctors for classes matrix and pseries.
authorRichard Kreckel <kreckel@ginac.de>
Tue, 3 Nov 2015 15:46:06 +0000 (16:46 +0100)
committerRichard Kreckel <kreckel@ginac.de>
Tue, 3 Nov 2015 15:46:06 +0000 (16:46 +0100)
ginac/inifcns.cpp
ginac/inifcns_nstdsums.cpp
ginac/inifcns_trans.cpp
ginac/matrix.cpp
ginac/matrix.h
ginac/pseries.cpp
ginac/pseries.h

index 9ac5ceba882add64f91025c733c2abd20d7d3450..f9305282901194c1a00e158ee778e695df79bf3d 100644 (file)
@@ -453,9 +453,8 @@ static ex step_series(const ex & arg,
            && !(options & series_options::suppress_branchcut))
                throw (std::domain_error("step_series(): on imaginary axis"));
        
            && !(options & series_options::suppress_branchcut))
                throw (std::domain_error("step_series(): on imaginary axis"));
        
-       epvector seq;
-       seq.push_back(expair(step(arg_pt), _ex0));
-       return pseries(rel,seq);
+       epvector seq { expair(step(arg_pt), _ex0) };
+       return pseries(rel, std::move(seq));
 }
 
 static ex step_conjugate(const ex& arg)
 }
 
 static ex step_conjugate(const ex& arg)
@@ -532,9 +531,8 @@ static ex csgn_series(const ex & arg,
            && !(options & series_options::suppress_branchcut))
                throw (std::domain_error("csgn_series(): on imaginary axis"));
        
            && !(options & series_options::suppress_branchcut))
                throw (std::domain_error("csgn_series(): on imaginary axis"));
        
-       epvector seq;
-       seq.push_back(expair(csgn(arg_pt), _ex0));
-       return pseries(rel,seq);
+       epvector seq { expair(csgn(arg_pt), _ex0) };
+       return pseries(rel, std::move(seq));
 }
 
 static ex csgn_conjugate(const ex& arg)
 }
 
 static ex csgn_conjugate(const ex& arg)
@@ -640,9 +638,8 @@ static ex eta_series(const ex & x, const ex & y,
            (y_pt.info(info_flags::numeric) && y_pt.info(info_flags::negative)) ||
            ((x_pt*y_pt).info(info_flags::numeric) && (x_pt*y_pt).info(info_flags::negative)))
                        throw (std::domain_error("eta_series(): on discontinuity"));
            (y_pt.info(info_flags::numeric) && y_pt.info(info_flags::negative)) ||
            ((x_pt*y_pt).info(info_flags::numeric) && (x_pt*y_pt).info(info_flags::negative)))
                        throw (std::domain_error("eta_series(): on discontinuity"));
-       epvector seq;
-       seq.push_back(expair(eta(x_pt,y_pt), _ex0));
-       return pseries(rel,seq);
+       epvector seq { expair(eta(x_pt,y_pt), _ex0) };
+       return pseries(rel, std::move(seq));
 }
 
 static ex eta_conjugate(const ex & x, const ex & y)
 }
 
 static ex eta_conjugate(const ex & x, const ex & y)
@@ -745,9 +742,8 @@ static ex Li2_series(const ex &x, const relational &rel, int order, unsigned opt
                        // substitute the argument's series expansion
                        ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
                        // substitute the argument's series expansion
                        ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
-                       epvector nseq;
-                       nseq.push_back(expair(Order(_ex1), order));
-                       ser += pseries(rel, nseq);
+                       epvector nseq { expair(Order(_ex1), order) };
+                       ser += pseries(rel, std::move(nseq));
                        // reexpanding it will collapse the series again
                        return ser.series(rel, order);
                        // NB: Of course, this still does not allow us to compute anything
                        // reexpanding it will collapse the series again
                        return ser.series(rel, order);
                        // NB: Of course, this still does not allow us to compute anything
@@ -770,9 +766,8 @@ static ex Li2_series(const ex &x, const relational &rel, int order, unsigned opt
                        // substitute the argument's series expansion
                        ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
                        // substitute the argument's series expansion
                        ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
-                       epvector nseq;
-                       nseq.push_back(expair(Order(_ex1), order));
-                       ser += pseries(rel, nseq);
+                       epvector nseq { expair(Order(_ex1), order) };
+                       ser += pseries(rel, std::move(nseq));
                        // reexpanding it will collapse the series again
                        return ser.series(rel, order);
                }
                        // reexpanding it will collapse the series again
                        return ser.series(rel, order);
                }
@@ -794,7 +789,7 @@ static ex Li2_series(const ex &x, const relational &rel, int order, unsigned opt
                                seq.push_back(expair((replarg.op(i)/power(s-foo,i)).series(foo==point,1,options).op(0).subs(foo==s, subs_options::no_pattern),i));
                        // append an order term:
                        seq.push_back(expair(Order(_ex1), replarg.nops()-1));
                                seq.push_back(expair((replarg.op(i)/power(s-foo,i)).series(foo==point,1,options).op(0).subs(foo==s, subs_options::no_pattern),i));
                        // append an order term:
                        seq.push_back(expair(Order(_ex1), replarg.nops()-1));
-                       return pseries(rel, seq);
+                       return pseries(rel, std::move(seq));
                }
        }
        // all other cases should be safe, by now:
                }
        }
        // all other cases should be safe, by now:
@@ -1004,11 +999,10 @@ static ex Order_eval(const ex & x)
 static ex Order_series(const ex & x, const relational & r, int order, unsigned options)
 {
        // Just wrap the function into a pseries object
 static ex Order_series(const ex & x, const relational & r, int order, unsigned options)
 {
        // Just wrap the function into a pseries object
-       epvector new_seq;
        GINAC_ASSERT(is_a<symbol>(r.lhs()));
        const symbol &s = ex_to<symbol>(r.lhs());
        GINAC_ASSERT(is_a<symbol>(r.lhs()));
        const symbol &s = ex_to<symbol>(r.lhs());
-       new_seq.push_back(expair(Order(_ex1), numeric(std::min(x.ldegree(s), order))));
-       return pseries(r, new_seq);
+       epvector new_seq { expair(Order(_ex1), numeric(std::min(x.ldegree(s), order))) };
+       return pseries(r, std::move(new_seq));
 }
 
 static ex Order_conjugate(const ex & x)
 }
 
 static ex Order_conjugate(const ex & x)
index 24a17a60a872a0ae72c7774f02b7589a26b1f53d..eb98d7a9750e5ba257f6f6f960685f30527353e6 100644 (file)
@@ -1662,9 +1662,8 @@ static ex Li_series(const ex& m, const ex& x, const relational& rel, int order,
 {
        if (is_a<lst>(m) || is_a<lst>(x)) {
                // multiple polylog
 {
        if (is_a<lst>(m) || is_a<lst>(x)) {
                // multiple polylog
-               epvector seq;
-               seq.push_back(expair(Li(m, x), 0));
-               return pseries(rel, seq);
+               epvector seq { expair(Li(m, x), 0) };
+               return pseries(rel, std::move(seq));
        }
        
        // classical polylog
        }
        
        // classical polylog
@@ -1680,9 +1679,8 @@ static ex Li_series(const ex& m, const ex& x, const relational& rel, int order,
                        // substitute the argument's series expansion
                        ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
                        // substitute the argument's series expansion
                        ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
-                       epvector nseq;
-                       nseq.push_back(expair(Order(_ex1), order));
-                       ser += pseries(rel, nseq);
+                       epvector nseq { expair(Order(_ex1), order) };
+                       ser += pseries(rel, std::move(nseq));
                        // reexpanding it will collapse the series again
                        return ser.series(rel, order);
                }
                        // reexpanding it will collapse the series again
                        return ser.series(rel, order);
                }
@@ -2235,9 +2233,8 @@ static ex S_series(const ex& n, const ex& p, const ex& x, const relational& rel,
                        // substitute the argument's series expansion
                        ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
                        // substitute the argument's series expansion
                        ser = ser.subs(s==x.series(rel, order), subs_options::no_pattern);
                        // maybe that was terminating, so add a proper order term
-                       epvector nseq;
-                       nseq.push_back(expair(Order(_ex1), order));
-                       ser += pseries(rel, nseq);
+                       epvector nseq { expair(Order(_ex1), order) };
+                       ser += pseries(rel, std::move(nseq));
                        // reexpanding it will collapse the series again
                        return ser.series(rel, order);
                }
                        // reexpanding it will collapse the series again
                        return ser.series(rel, order);
                }
@@ -3430,9 +3427,8 @@ static ex H_eval(const ex& m_, const ex& x)
 
 static ex H_series(const ex& m, const ex& x, const relational& rel, int order, unsigned options)
 {
 
 static ex H_series(const ex& m, const ex& x, const relational& rel, int order, unsigned options)
 {
-       epvector seq;
-       seq.push_back(expair(H(m, x), 0));
-       return pseries(rel, seq);
+       epvector seq { expair(H(m, x), 0) };
+       return pseries(rel, std::move(seq));
 }
 
 
 }
 
 
index 4f081f171df33bffb961a2fc91d5d94e672bd9f3..d7fa377e269395d6b6b2c0af0591f44242c1a363 100644 (file)
@@ -247,20 +247,18 @@ static ex log_series(const ex &arg,
                                epv.reserve(2);
                                epv.push_back(expair(-1, _ex0));
                                epv.push_back(expair(Order(_ex1), order));
                                epv.reserve(2);
                                epv.push_back(expair(-1, _ex0));
                                epv.push_back(expair(Order(_ex1), order));
-                               ex rest = pseries(rel, epv).add_series(argser);
+                               ex rest = pseries(rel, std::move(epv)).add_series(argser);
                                for (int i = order-1; i>0; --i) {
                                for (int i = order-1; i>0; --i) {
-                                       epvector cterm;
-                                       cterm.reserve(1);
-                                       cterm.push_back(expair(i%2 ? _ex1/i : _ex_1/i, _ex0));
-                                       acc = pseries(rel, cterm).add_series(ex_to<pseries>(acc));
+                                       epvector cterm { expair(i%2 ? _ex1/i : _ex_1/i, _ex0) };
+                                       acc = pseries(rel, std::move(cterm)).add_series(ex_to<pseries>(acc));
                                        acc = (ex_to<pseries>(rest)).mul_series(ex_to<pseries>(acc));
                                }
                                return acc;
                        }
                        const ex newarg = ex_to<pseries>((arg/coeff).series(rel, order+n, options)).shift_exponents(-n).convert_to_poly(true);
                                        acc = (ex_to<pseries>(rest)).mul_series(ex_to<pseries>(acc));
                                }
                                return acc;
                        }
                        const ex newarg = ex_to<pseries>((arg/coeff).series(rel, order+n, options)).shift_exponents(-n).convert_to_poly(true);
-                       return pseries(rel, seq).add_series(ex_to<pseries>(log(newarg).series(rel, order, options)));
+                       return pseries(rel, std::move(seq)).add_series(ex_to<pseries>(log(newarg).series(rel, order, options)));
                } else  // it was a monomial
                } else  // it was a monomial
-                       return pseries(rel, seq);
+                       return pseries(rel, std::move(seq));
        }
        if (!(options & series_options::suppress_branchcut) &&
             arg_pt.info(info_flags::negative)) {
        }
        if (!(options & series_options::suppress_branchcut) &&
             arg_pt.info(info_flags::negative)) {
@@ -271,10 +269,9 @@ static ex log_series(const ex &arg,
                const ex &point = rel.rhs();
                const symbol foo;
                const ex replarg = series(log(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
                const ex &point = rel.rhs();
                const symbol foo;
                const ex replarg = series(log(arg), s==foo, order).subs(foo==point, subs_options::no_pattern);
-               epvector seq;
-               seq.push_back(expair(-I*csgn(arg*I)*Pi, _ex0));
-               seq.push_back(expair(Order(_ex1), order));
-               return series(replarg - I*Pi + pseries(rel, seq), rel, order);
+               epvector seq { expair(-I*csgn(arg*I)*Pi, _ex0),
+                              expair(Order(_ex1), order) };
+               return series(replarg - I*Pi + pseries(rel, std::move(seq)), rel, order);
        }
        throw do_taylor();  // caught by function::series()
 }
        }
        throw do_taylor();  // caught by function::series()
 }
@@ -935,10 +932,9 @@ static ex atan_series(const ex &arg,
                        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+_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;
-               epvector seq;
-               seq.push_back(expair(Order0correction, _ex0));
-               seq.push_back(expair(Order(_ex1), order));
-               return series(replarg - pseries(rel, seq), rel, order);
+               epvector seq { expair(Order0correction, _ex0),
+                              expair(Order(_ex1), order) };
+               return series(replarg - pseries(rel, std::move(seq)), rel, order);
        }
        throw do_taylor();
 }
        }
        throw do_taylor();
 }
@@ -1542,10 +1538,9 @@ static ex atanh_series(const ex &arg,
                        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+_ex_1)/(arg_pt+_ex1))*_ex1_2;
                else
                        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));
-               return series(replarg - pseries(rel, seq), rel, order);
+               epvector seq { expair(Order0correction, _ex0),
+                              expair(Order(_ex1), order) };
+               return series(replarg - pseries(rel, std::move(seq)), rel, order);
        }
        throw do_taylor();
 }
        }
        throw do_taylor();
 }
index 1b5f8edf7f418b4b773c39887c657c335dd0fa9a..871c3f15d1c5f433238b6f5a3b354d1f17ef1ea2 100644 (file)
@@ -81,6 +81,11 @@ matrix::matrix(unsigned r, unsigned c, const exvector & m2)
 {
        setflag(status_flags::not_shareable);
 }
 {
        setflag(status_flags::not_shareable);
 }
+matrix::matrix(unsigned r, unsigned c, exvector && m2)
+  : row(r), col(c), m(std::move(m2))
+{
+       setflag(status_flags::not_shareable);
+}
 
 /** Construct matrix from (flat) list of elements. If the list has fewer
  *  elements than the matrix, the remaining matrix elements are set to zero.
 
 /** Construct matrix from (flat) list of elements. If the list has fewer
  *  elements than the matrix, the remaining matrix elements are set to zero.
index 759e825ab4ca06c7dedf446a25d325b00e32402e..725ea2bb99b0e26a6fe61b6e5865ed823ca1df34 100644 (file)
@@ -98,7 +98,6 @@ class matrix : public basic
        // other constructors
 public:
        matrix(unsigned r, unsigned c);
        // other constructors
 public:
        matrix(unsigned r, unsigned c);
-       matrix(unsigned r, unsigned c, const exvector & m2);
        matrix(unsigned r, unsigned c, const lst & l);
 
        // First step of initialization of matrix with a comma-separated sequence
        matrix(unsigned r, unsigned c, const lst & l);
 
        // First step of initialization of matrix with a comma-separated sequence
@@ -108,7 +107,10 @@ public:
                m[0] = x;
                return matrix_init<ex, exvector::iterator>(++m.begin());
        }
                m[0] = x;
                return matrix_init<ex, exvector::iterator>(++m.begin());
        }
-       
+
+protected:
+       matrix(unsigned r, unsigned c, const exvector & m2);
+       matrix(unsigned r, unsigned c, exvector && m2);
        // functions overriding virtual functions from base classes
 public:
        size_t nops() const;
        // functions overriding virtual functions from base classes
 public:
        size_t nops() const;
index 2ae10f4f73a3150e9f6fcfc5373fd8afecc2fd29..01b26914360a7e15c2f2336b6f0806aa37d865c7 100644 (file)
@@ -68,7 +68,16 @@ pseries::pseries() { }
  *  @param rel_  expansion variable and point (must hold a relational)
  *  @param ops_  vector of {coefficient, power} pairs (coefficient must not be zero)
  *  @return newly constructed pseries */
  *  @param rel_  expansion variable and point (must hold a relational)
  *  @param ops_  vector of {coefficient, power} pairs (coefficient must not be zero)
  *  @return newly constructed pseries */
-pseries::pseries(const ex &rel_, const epvector &ops_) : seq(ops_)
+pseries::pseries(const ex &rel_, const epvector &ops_)
+  : seq(ops_)
+{
+       GINAC_ASSERT(is_a<relational>(rel_));
+       GINAC_ASSERT(is_a<symbol>(rel_.lhs()));
+       point = rel_.rhs();
+       var = rel_.lhs();
+}
+pseries::pseries(const ex &rel_, epvector &&ops_)
+  : seq(std::move(ops_))
 {
        GINAC_ASSERT(is_a<relational>(rel_));
        GINAC_ASSERT(is_a<symbol>(rel_.lhs()));
 {
        GINAC_ASSERT(is_a<relational>(rel_));
        GINAC_ASSERT(is_a<symbol>(rel_.lhs()));
@@ -461,7 +470,7 @@ ex pseries::imag_part() const
 
 ex pseries::eval_integ() const
 {
 
 ex pseries::eval_integ() const
 {
-       epvector *newseq = nullptr;
+       std::unique_ptr<epvector> newseq(nullptr);
        for (auto i=seq.begin(); i!=seq.end(); ++i) {
                if (newseq) {
                        newseq->push_back(expair(i->rest.eval_integ(), i->coeff));
        for (auto i=seq.begin(); i!=seq.end(); ++i) {
                if (newseq) {
                        newseq->push_back(expair(i->rest.eval_integ(), i->coeff));
@@ -469,7 +478,7 @@ ex pseries::eval_integ() const
                }
                ex newterm = i->rest.eval_integ();
                if (!are_ex_trivially_equal(newterm, i->rest)) {
                }
                ex newterm = i->rest.eval_integ();
                if (!are_ex_trivially_equal(newterm, i->rest)) {
-                       newseq = new epvector;
+                       newseq.reset(new epvector);
                        newseq->reserve(seq.size());
                        for (auto j=seq.begin(); j!=i; ++j)
                                newseq->push_back(*j);
                        newseq->reserve(seq.size());
                        for (auto j=seq.begin(); j!=i; ++j)
                                newseq->push_back(*j);
@@ -479,7 +488,7 @@ ex pseries::eval_integ() const
 
        ex newpoint = point.eval_integ();
        if (newseq || !are_ex_trivially_equal(newpoint, point))
 
        ex newpoint = point.eval_integ();
        if (newseq || !are_ex_trivially_equal(newpoint, point))
-               return (new pseries(var==newpoint, *newseq))
+               return (new pseries(var==newpoint, std::move(*newseq)))
                       ->setflag(status_flags::dynallocated);
        return *this;
 }
                       ->setflag(status_flags::dynallocated);
        return *this;
 }
@@ -526,7 +535,7 @@ ex pseries::subs(const exmap & m, unsigned options) const
        newseq.reserve(seq.size());
        for (auto & it : seq)
                newseq.push_back(expair(it.rest.subs(m, options), it.coeff));
        newseq.reserve(seq.size());
        for (auto & it : seq)
                newseq.push_back(expair(it.rest.subs(m, options), it.coeff));
-       return (new pseries(relational(var,point.subs(m, options)), newseq))->setflag(status_flags::dynallocated);
+       return (new pseries(relational(var,point.subs(m, options)), std::move(newseq)))->setflag(status_flags::dynallocated);
 }
 
 /** Implementation of ex::expand() for a power series.  It expands all the
 }
 
 /** Implementation of ex::expand() for a power series.  It expands all the
@@ -625,7 +634,7 @@ ex basic::series(const relational & r, int order, unsigned options) const
        // default for order-values that make no sense for Taylor expansion
        if ((order <= 0) && this->has(s)) {
                seq.push_back(expair(Order(_ex1), order));
        // default for order-values that make no sense for Taylor expansion
        if ((order <= 0) && this->has(s)) {
                seq.push_back(expair(Order(_ex1), order));
-               return pseries(r, seq);
+               return pseries(r, std::move(seq));
        }
 
        // do Taylor expansion
        }
 
        // do Taylor expansion
@@ -645,7 +654,7 @@ ex basic::series(const relational & r, int order, unsigned options) const
                // zero.  Expanding the term occasionally helps a little...
                deriv = deriv.diff(s).expand();
                if (deriv.is_zero())  // Series terminates
                // zero.  Expanding the term occasionally helps a little...
                deriv = deriv.diff(s).expand();
                if (deriv.is_zero())  // Series terminates
-                       return pseries(r, seq);
+                       return pseries(r, std::move(seq));
 
                coeff = deriv.subs(r, subs_options::no_pattern);
                if (!coeff.is_zero())
 
                coeff = deriv.subs(r, subs_options::no_pattern);
                if (!coeff.is_zero())
@@ -656,7 +665,7 @@ ex basic::series(const relational & r, int order, unsigned options) const
        deriv = deriv.diff(s);
        if (!deriv.expand().is_zero())
                seq.push_back(expair(Order(_ex1), n));
        deriv = deriv.diff(s);
        if (!deriv.expand().is_zero())
                seq.push_back(expair(Order(_ex1), n));
-       return pseries(r, seq);
+       return pseries(r, std::move(seq));
 }
 
 
 }
 
 
@@ -677,7 +686,7 @@ ex symbol::series(const relational & r, int order, unsigned options) const
                        seq.push_back(expair(Order(_ex1), numeric(order)));
        } else
                seq.push_back(expair(*this, _ex0));
                        seq.push_back(expair(Order(_ex1), numeric(order)));
        } else
                seq.push_back(expair(*this, _ex0));
-       return pseries(r, seq);
+       return pseries(r, std::move(seq));
 }
 
 
 }
 
 
@@ -691,9 +700,8 @@ ex pseries::add_series(const pseries &other) const
        // Adding two series with different variables or expansion points
        // results in an empty (constant) series 
        if (!is_compatible_to(other)) {
        // Adding two series with different variables or expansion points
        // results in an empty (constant) series 
        if (!is_compatible_to(other)) {
-               epvector nul;
-               nul.push_back(expair(Order(_ex1), _ex0));
-               return pseries(relational(var,point), nul);
+               epvector nul { expair(Order(_ex1), _ex0) };
+               return pseries(relational(var,point), std::move(nul));
        }
        
        // Series addition
        }
        
        // Series addition
@@ -796,7 +804,7 @@ ex pseries::mul_const(const numeric &other) const
                else
                        new_seq.push_back(it);
        }
                else
                        new_seq.push_back(it);
        }
-       return pseries(relational(var,point), new_seq);
+       return pseries(relational(var,point), std::move(new_seq));
 }
 
 
 }
 
 
@@ -810,9 +818,8 @@ ex pseries::mul_series(const pseries &other) const
        // Multiplying two series with different variables or expansion points
        // results in an empty (constant) series 
        if (!is_compatible_to(other)) {
        // Multiplying two series with different variables or expansion points
        // results in an empty (constant) series 
        if (!is_compatible_to(other)) {
-               epvector nul;
-               nul.push_back(expair(Order(_ex1), _ex0));
-               return pseries(relational(var,point), nul);
+               epvector nul { expair(Order(_ex1), _ex0) };
+               return pseries(relational(var,point), std::move(nul));
        }
 
        if (seq.empty() || other.seq.empty()) {
        }
 
        if (seq.empty() || other.seq.empty()) {
@@ -853,7 +860,7 @@ ex pseries::mul_series(const pseries &other) const
        }
        if (higher_order_c < std::numeric_limits<int>::max())
                new_seq.push_back(expair(Order(_ex1), numeric(higher_order_c)));
        }
        if (higher_order_c < std::numeric_limits<int>::max())
                new_seq.push_back(expair(Order(_ex1), numeric(higher_order_c)));
-       return pseries(relational(var, point), new_seq);
+       return pseries(relational(var, point), std::move(new_seq));
 }
 
 
 }
 
 
@@ -947,9 +954,8 @@ ex mul::series(const relational & r, int order, unsigned options) const
        int degsum = std::accumulate(ldegrees.begin(), ldegrees.end(), 0);
 
        if (degsum >= order) {
        int degsum = std::accumulate(ldegrees.begin(), ldegrees.end(), 0);
 
        if (degsum >= order) {
-               epvector epv;
-               epv.push_back(expair(Order(_ex1), order));
-               return (new pseries(r, epv))->setflag(status_flags::dynallocated);
+               epvector epv { expair(Order(_ex1), order) };
+               return (new pseries(r, std::move(epv)))->setflag(status_flags::dynallocated);
        }
 
        // Multiply with remaining terms
        }
 
        // Multiply with remaining terms
@@ -1015,10 +1021,8 @@ ex pseries::power_const(const numeric &p, int deg) const
        // adjust number of coefficients
        int numcoeff = deg - (p*ldeg).to_int();
        if (numcoeff <= 0) {
        // adjust number of coefficients
        int numcoeff = deg - (p*ldeg).to_int();
        if (numcoeff <= 0) {
-               epvector epv;
-               epv.reserve(1);
-               epv.push_back(expair(Order(_ex1), deg));
-               return (new pseries(relational(var,point), epv))
+               epvector epv { expair(Order(_ex1), deg) };
+               return (new pseries(relational(var,point), std::move(epv)))
                       ->setflag(status_flags::dynallocated);
        }
        
                       ->setflag(status_flags::dynallocated);
        }
        
@@ -1057,7 +1061,7 @@ ex pseries::power_const(const numeric &p, int deg) const
        if (!higher_order)
                new_seq.push_back(expair(Order(_ex1), p * ldeg + numcoeff));
 
        if (!higher_order)
                new_seq.push_back(expair(Order(_ex1), p * ldeg + numcoeff));
 
-       return pseries(relational(var,point), new_seq);
+       return pseries(relational(var,point), std::move(new_seq));
 }
 
 
 }
 
 
@@ -1128,7 +1132,7 @@ ex power::series(const relational & r, int order, unsigned options) const
                        new_seq.push_back(expair(_ex1, exponent));
                else
                        new_seq.push_back(expair(Order(_ex1), exponent));
                        new_seq.push_back(expair(_ex1, exponent));
                else
                        new_seq.push_back(expair(Order(_ex1), exponent));
-               return pseries(r, new_seq);
+               return pseries(r, std::move(new_seq));
        }
 
        // No, expand basis into series
        }
 
        // No, expand basis into series
@@ -1161,9 +1165,8 @@ ex power::series(const relational & r, int order, unsigned options) const
        try {
                result = ex_to<pseries>(e).power_const(numexp, order);
        } catch (pole_error) {
        try {
                result = ex_to<pseries>(e).power_const(numexp, order);
        } catch (pole_error) {
-               epvector ser;
-               ser.push_back(expair(Order(_ex1), order));
-               result = pseries(r, ser);
+               epvector ser { expair(Order(_ex1), order) };
+               result = pseries(r, std::move(ser));
        }
 
        return result;
        }
 
        return result;
@@ -1190,7 +1193,7 @@ ex pseries::series(const relational & r, int order, unsigned options) const
                                }
                                new_seq.push_back(it);
                        }
                                }
                                new_seq.push_back(it);
                        }
-                       return pseries(r, new_seq);
+                       return pseries(r, std::move(new_seq));
                }
        } else
                return convert_to_poly().series(r, order, options);
                }
        } else
                return convert_to_poly().series(r, order, options);
index f24e4390e55020dea4fea6ae6747f1ec3e9896f2..cdac31da1395e4e7a11c32fbcf159adde8830d1b 100644 (file)
@@ -39,6 +39,7 @@ class pseries : public basic
        // other constructors
 public:
        pseries(const ex &rel_, const epvector &ops_);
        // other constructors
 public:
        pseries(const ex &rel_, const epvector &ops_);
+       pseries(const ex &rel_, epvector &&ops_);
 
        // functions overriding virtual functions from base classes
 public:
 
        // functions overriding virtual functions from base classes
 public: