]> www.ginac.de Git - ginac.git/blobdiff - ginac/inifcns_trans.cpp
Better output for slashed expressions (C.Dams' patch).
[ginac.git] / ginac / inifcns_trans.cpp
index 7df32121680621edec85c584de21c5c1243e7554..04ce052da4dc88f5a62026a3ef92613526177a1f 100644 (file)
@@ -4,7 +4,7 @@
  *  functions. */
 
 /*
- *  GiNaC Copyright (C) 1999-2004 Johannes Gutenberg University Mainz, Germany
+ *  GiNaC Copyright (C) 1999-2005 Johannes Gutenberg University Mainz, Germany
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -111,7 +111,7 @@ static ex log_eval(const ex & x)
        if (x.info(info_flags::numeric)) {
                if (x.is_zero())         // log(0) -> infinity
                        throw(pole_error("log_eval(): log(0)",0));
-               if (x.info(info_flags::real) && x.info(info_flags::negative))
+               if (x.info(info_flags::rational) && x.info(info_flags::negative))
                        return (log(-x)+I*Pi);
                if (x.is_equal(_ex1))  // log(1) -> 0
                        return _ex0;
@@ -200,6 +200,22 @@ static ex log_series(const ex &arg,
                if (!argser.is_terminating() || argser.nops()!=1) {
                        // 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 = (new pseries(rel, epv))->setflag(status_flags::dynallocated);
+                               epv.reserve(2);
+                               epv.push_back(expair(-1, _ex0));
+                               epv.push_back(expair(Order(_ex1), order));
+                               ex rest = pseries(rel, epv).add_series(argser);
+                               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));
+                                       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)));
                } else  // it was a monomial