* Minor cleanups to avoid copying of symbols and stuff like that.
authorRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Thu, 22 Nov 2001 19:31:34 +0000 (19:31 +0000)
committerRichard Kreckel <Richard.Kreckel@uni-mainz.de>
Thu, 22 Nov 2001 19:31:34 +0000 (19:31 +0000)
ginac/inifcns_gamma.cpp
ginac/inifcns_trans.cpp

index 497c37a6adf62beccb007f46406c628337e98d33..ca16b18b22cfdf45639efc2b3c541f126f8ea9ae 100644 (file)
@@ -234,8 +234,8 @@ static ex beta_eval(const ex & x, const ex & y)
                // treat all problematic x and y that may not be passed into tgamma,
                // because they would throw there although beta(x,y) is well-defined
                // using the formula beta(x,y) == (-1)^y * beta(1-x-y, y)
-               const numeric nx = ex_to<numeric>(x);
-               const numeric ny = ex_to<numeric>(y);
+               const numeric &nx = ex_to<numeric>(x);
+               const numeric &ny = ex_to<numeric>(y);
                if (nx.is_real() && nx.is_integer() &&
                        ny.is_real() && ny.is_integer()) {
                        if (nx.is_negative()) {
@@ -345,7 +345,7 @@ static ex psi1_evalf(const ex & x)
 static ex psi1_eval(const ex & x)
 {
        if (x.info(info_flags::numeric)) {
-               const numeric nx = ex_to<numeric>(x);
+               const numeric &nx = ex_to<numeric>(x);
                if (nx.is_integer()) {
                        // integer case 
                        if (nx.is_positive()) {
@@ -453,8 +453,8 @@ static ex psi2_eval(const ex & n, const ex & x)
                return log(tgamma(x));
        if (n.info(info_flags::numeric) && n.info(info_flags::posint) &&
                x.info(info_flags::numeric)) {
-               const numeric nn = ex_to<numeric>(n);
-               const numeric nx = ex_to<numeric>(x);
+               const numeric &nn = ex_to<numeric>(n);
+               const numeric &nx = ex_to<numeric>(x);
                if (nx.is_integer()) {
                        // integer case 
                        if (nx.is_equal(_num1))
index 00fc2efd19e70477fce747c43d311db9b7e7b6d2..cbf370dbb16542f1be19e16566a547a998e90f01 100644 (file)
@@ -57,7 +57,7 @@ static ex exp_eval(const ex & x)
        // exp(n*Pi*I/2) -> {+1|+I|-1|-I}
        const ex TwoExOverPiI=(_ex2*x)/(Pi*I);
        if (TwoExOverPiI.info(info_flags::integer)) {
-               numeric z = mod(ex_to<numeric>(TwoExOverPiI),_num4);
+               const numeric z = mod(ex_to<numeric>(TwoExOverPiI),_num4);
                if (z.is_equal(_num0))
                        return _ex1;
                if (z.is_equal(_num1))
@@ -122,9 +122,9 @@ static ex log_eval(const ex & x)
        }
        // log(exp(t)) -> t (if -Pi < t.imag() <= Pi):
        if (is_ex_the_function(x, exp)) {
-               ex t = x.op(0);
+               const ex &t = x.op(0);
                if (t.info(info_flags::numeric)) {
-                       numeric nt = ex_to<numeric>(t);
+                       const numeric &nt = ex_to<numeric>(t);
                        if (nt.is_real())
                                return t;
                }
@@ -177,7 +177,7 @@ static ex log_series(const ex &arg,
                } while (!argser.is_terminating() && argser.nops()==1);
 
                const symbol &s = ex_to<symbol>(rel.lhs());
-               const ex point = rel.rhs();
+               const ex &point = rel.rhs();
                const int n = argser.ldegree(s);
                epvector seq;
                // construct what we carelessly called the n*log(x) term above
@@ -203,7 +203,7 @@ static ex log_series(const ex &arg,
                // This is the branch cut: assemble the primitive series manually and
                // then add the corresponding complex step function.
                const symbol &s = ex_to<symbol>(rel.lhs());
-               const ex point = rel.rhs();
+               const ex &point = rel.rhs();
                const symbol foo;
                const ex replarg = series(log(arg), s==foo, order).subs(foo==point);
                epvector seq;
@@ -269,7 +269,7 @@ static ex sin_eval(const ex & x)
        }
        
        if (is_exactly_a<function>(x)) {
-               ex t = x.op(0);
+               const ex &t = x.op(0);
                // sin(asin(x)) -> x
                if (is_ex_the_function(x, asin))
                        return t;
@@ -350,7 +350,7 @@ static ex cos_eval(const ex & x)
        }
        
        if (is_exactly_a<function>(x)) {
-               ex t = x.op(0);
+               const ex &t = x.op(0);
                // cos(acos(x)) -> x
                if (is_ex_the_function(x, acos))
                        return t;
@@ -427,7 +427,7 @@ static ex tan_eval(const ex & x)
        }
        
        if (is_exactly_a<function>(x)) {
-               ex t = x.op(0);
+               const ex &t = x.op(0);
                // tan(atan(x)) -> x
                if (is_ex_the_function(x, atan))
                        return t;
@@ -648,7 +648,7 @@ static ex atan_series(const ex &arg,
                // This is the branch cut: assemble the primitive series manually and
                // then add the corresponding complex step function.
                const symbol &s = ex_to<symbol>(rel.lhs());
-               const ex point = rel.rhs();
+               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;
@@ -734,7 +734,7 @@ static ex sinh_eval(const ex & x)
                return I*sin(x/I);
        
        if (is_exactly_a<function>(x)) {
-               ex t = x.op(0);
+               const ex &t = x.op(0);
                // sinh(asinh(x)) -> x
                if (is_ex_the_function(x, asinh))
                        return t;
@@ -788,7 +788,7 @@ static ex cosh_eval(const ex & x)
                return cos(x/I);
        
        if (is_exactly_a<function>(x)) {
-               ex t = x.op(0);
+               const ex &t = x.op(0);
                // cosh(acosh(x)) -> x
                if (is_ex_the_function(x, acosh))
                        return t;
@@ -842,7 +842,7 @@ static ex tanh_eval(const ex & x)
                return I*tan(x/I);
        
        if (is_exactly_a<function>(x)) {
-               ex t = x.op(0);
+               const ex &t = x.op(0);
                // tanh(atanh(x)) -> x
                if (is_ex_the_function(x, atanh))
                        return t;
@@ -1033,7 +1033,7 @@ static ex atanh_series(const ex &arg,
                // This is the branch cut: assemble the primitive series manually and
                // then add the corresponding complex step function.
                const symbol &s = ex_to<symbol>(rel.lhs());
-               const ex point = rel.rhs();
+               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;