From: Richard Kreckel Date: Fri, 21 Jul 2000 01:12:25 +0000 (+0000) Subject: - Derivatives are now assembled in a slightly different manner (i.e. they X-Git-Tag: release_0-6-3~4 X-Git-Url: https://www.ginac.de/ginac.git//ginac.git?p=ginac.git;a=commitdiff_plain;h=bd2d7351b89743eb68ce7d3bfa7ab62c331f9522 - Derivatives are now assembled in a slightly different manner (i.e. they 'look' different on first sight). Under certain circumstances this can result in a dramatic speedup because it gives hashing a better chance, especially when computing higher derivatives. - Series expansion accepts an additional bool argument now, telling it whether branch cuts are to be honored (as Maple does it) or not (as Mathematica does it). It defaults to true (i.e. the Maple way). - Many series expansions of built-in functions have been reengineered. - The Dilogarithm (Li2) now has floating point evaluation, derivative and a proper series expansion. - Namespace 'std' cleanly disentangled, as demanded by ISO/EIC 14882-1998(E). - Some helpers updated from upstream. --- diff --git a/Makefile.in b/Makefile.in index 605257fc..2cbb87ae 100644 --- a/Makefile.in +++ b/Makefile.in @@ -82,6 +82,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -94,6 +95,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ diff --git a/NEWS b/NEWS index d40d12b8..406a6e81 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,15 @@ This file records noteworthy changes. +0.6.3 (xx July 2000) +* Derivatives are now assembled in a slightly different manner (i.e. they + 'look' different on first sight). Under certain circumstances this can + result in a dramatic speedup because it gives hashing a better chance, + especially when computing higher derivatives. +* Many series expansions of built-in functions have been reengineered. +* The Dilogarithm (Li2) now has floating point evaluation, derivative and a + proper series expansion. +* Namespace 'std' cleanly disentangled, as demanded by ISO/EIC 14882-1998(E). + 0.6.2 (21 June 2000) * ginaccint.bin is now launched by a binary program instead of by a scripts. This allows us to write #!-scripts. A small test suite for GiNaC-cint was diff --git a/aclocal.m4 b/aclocal.m4 index 12c39ff7..fe627fdb 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -297,7 +297,7 @@ LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ || AC_MSG_ERROR([libtool configure failed]) # Reload cache, that may have been modified by ltconfig @@ -329,11 +329,6 @@ AC_REQUIRE([AC_PROG_NM])dnl AC_REQUIRE([AC_PROG_LN_S])dnl dnl -case "$target" in -NONE) lt_target="$host" ;; -*) lt_target="$target" ;; -esac - # Check for any special flags to pass to ltconfig. libtool_flags="--cache-file=$cache_file" test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" @@ -352,7 +347,7 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$lt_target" in +case "$host" in *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext @@ -377,7 +372,10 @@ case "$lt_target" in SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, - [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + [AC_LANG_SAVE + AC_LANG_C + AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_RESTORE]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" @@ -568,6 +566,7 @@ else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_SUBST(LD) AC_PROG_LD_GNU ]) @@ -613,13 +612,14 @@ else fi]) NM="$ac_cv_path_NM" AC_MSG_RESULT([$NM]) +AC_SUBST(NM) ]) # AC_CHECK_LIBM - check for math library AC_DEFUN(AC_CHECK_LIBM, [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= -case "$lt_target" in +case "$host" in *-*-beos* | *-*-cygwin*) # These system don't have libm ;; diff --git a/check/Makefile.in b/check/Makefile.in index a834eef2..b984a80c 100644 --- a/check/Makefile.in +++ b/check/Makefile.in @@ -82,6 +82,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -94,6 +95,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ diff --git a/check/check_inifcns.cpp b/check/check_inifcns.cpp index b9e1f9f8..9cebceeb 100644 --- a/check/check_inifcns.cpp +++ b/check/check_inifcns.cpp @@ -72,9 +72,8 @@ static unsigned inifcns_check_sin(void) errorflag = true; } } - if (errorflag) { + if (errorflag) ++result; - } return result; } @@ -127,9 +126,8 @@ static unsigned inifcns_check_cos(void) errorflag = true; } } - if (errorflag) { + if (errorflag) ++result; - } return result; } @@ -157,10 +155,38 @@ static unsigned inifcns_check_tan(void) errorflag = true; } } - if (errorflag) { + if (errorflag) ++result; + + return result; +} + +/* Simple tests on the dilogarithm function. */ +static unsigned inifcns_check_Li2(void) +{ + // NOTE: this can safely be removed once CLN supports dilogarithms and + // checks them itself. + unsigned result = 0; + bool errorflag; + + // check the relation Li2(z^2) == 2 * (Li2(z) + Li2(-z)) numerically, which + // should hold in the entire complex plane: + errorflag = false; + ex argument; + numeric epsilon(double(1e-16)); + for (int n=0; n<200; ++n) { + argument = numeric(20.0*rand()/(RAND_MAX+1.0)-10.0) + + numeric(20.0*rand()/(RAND_MAX+1.0)-10.0)*I; + if (abs(Li2(pow(argument,2))-2*Li2(argument)-2*Li2(-argument)) > epsilon) { + cout << "Li2(z) at z==" << argument + << " failed to satisfy Li2(z^2)==2*(Li2(z)+Li2(-z))" << endl; + errorflag = true; + } } + if (errorflag) + ++result; + return result; } @@ -174,6 +200,7 @@ unsigned check_inifcns(void) result += inifcns_check_sin(); cout << '.' << flush; result += inifcns_check_cos(); cout << '.' << flush; result += inifcns_check_tan(); cout << '.' << flush; + result += inifcns_check_Li2(); cout << '.' << flush; if (!result) { cout << " passed " << endl; diff --git a/check/exam_differentiation.cpp b/check/exam_differentiation.cpp index 49eddd66..085ff451 100644 --- a/check/exam_differentiation.cpp +++ b/check/exam_differentiation.cpp @@ -268,6 +268,30 @@ static unsigned exam_differentiation6(void) return 0; } +// Hashing can help a lot, if differentiation is done cleverly +static unsigned exam_differentiation7(void) +{ + symbol x("x"); + ex P = x + pow(x,3); + ex e = (P.diff(x) / P).diff(x, 2); + ex d = 6/P - 18*x/pow(P,2) - 54*pow(x,3)/pow(P,2) + 2/pow(P,3) + +18*pow(x,2)/pow(P,3) + 54*pow(x,4)/pow(P,3) + 54*pow(x,6)/pow(P,3); + + if (!(e-d).expand().is_zero()) { + clog << "expanded second derivative of " << (P.diff(x) / P) << " by " << x + << " returned " << e.expand() << " instead of " << d << endl; + return 1; + } + if (e.nops() > 3) { + clog << "second derivative of " << (P.diff(x) / P) << " by " << x + << " has " << e.nops() << " operands. " + << "The result is still correct but not optimal: 3 are enough! " + << "(Hint: maybe the product rule for objects of class mul should be more careful about assembling the result?)" << endl; + return 1; + } + return 0; +} + unsigned exam_differentiation(void) { unsigned result = 0; @@ -281,6 +305,7 @@ unsigned exam_differentiation(void) result += exam_differentiation4(); cout << '.' << flush; result += exam_differentiation5(); cout << '.' << flush; result += exam_differentiation6(); cout << '.' << flush; + result += exam_differentiation7(); cout << '.' << flush; if (!result) { cout << " passed " << endl; diff --git a/check/exam_pseries.cpp b/check/exam_pseries.cpp index da860108..a6ff7047 100644 --- a/check/exam_pseries.cpp +++ b/check/exam_pseries.cpp @@ -89,7 +89,7 @@ static unsigned exam_series1(void) result += check_series(e, 0, d); e = pow(numeric(2), x); - ex t = log(ex(2)) * x; + ex t = log(2) * x; d = 1 + t + pow(t, 2) / 2 + pow(t, 3) / 6 + pow(t, 4) / 24 + pow(t, 5) / 120 + pow(t, 6) / 720 + pow(t, 7) / 5040 + Order(pow(x, 8)); result += check_series(e, 0, d.expand()); @@ -179,30 +179,47 @@ static unsigned exam_series5(void) return check_series(e, -1, d, 4); } -// Series expansion of tan(Pi/2) +// Series expansion of tan(x==Pi/2) static unsigned exam_series6(void) { ex e = tan(x*Pi/2); - ex d = pow(x-1,-1)/Pi*(-2) + - pow(x-1,1)*Pi/6 + - pow(x-1,3)*pow(Pi,3)/360 + - pow(x-1,5)*pow(Pi,5)/15120 + - pow(x-1,7)*pow(Pi,7)/604800 + - Order(pow(x-1,8)); + ex d = pow(x-1,-1)/Pi*(-2) + pow(x-1,1)*Pi/6 + pow(x-1,3)*pow(Pi,3)/360 + +pow(x-1,5)*pow(Pi,5)/15120 + pow(x-1,7)*pow(Pi,7)/604800 + +Order(pow(x-1,8)); return check_series(e,1,d,8); } -// Series expansion of Li2(sin(0)) +// Series expansion of log(sin(x==0)) static unsigned exam_series7(void) +{ + ex e = log(sin(x)); + ex d = log(x) - pow(x,2)/6 - pow(x,4)/180 - pow(x,6)/2835 + +Order(pow(x,8)); + return check_series(e,0,d,8); +} + +// Series expansion of Li2(sin(x==0)) +static unsigned exam_series8(void) { ex e = Li2(sin(x)); - ex d = x + numeric(1,4)*pow(x,2) - numeric(1,18)*pow(x,3) - - numeric(1,48)*pow(x,4) - numeric(13,1800)*pow(x,5) - - numeric(1,360)*pow(x,6) - numeric(23,21168)*pow(x,7) + ex d = x + pow(x,2)/4 - pow(x,3)/18 - pow(x,4)/48 + - 13*pow(x,5)/1800 - pow(x,6)/360 - 23*pow(x,7)/21168 + Order(pow(x,8)); return check_series(e,0,d,8); } +// Series expansion of Li2((x==2)^2), caring about branch-cut +static unsigned exam_series9(void) +{ + ex e = Li2(pow(x,2)); + ex d = Li2(4) + (-log(3) + I*Pi*csgn(I-I*pow(x,2))) * (x-2) + + (numeric(-2,3) + log(3)/4 - I*Pi/4*csgn(I-I*pow(x,2))) * pow(x-2,2) + + (numeric(11,27) - log(3)/12 + I*Pi/12*csgn(I-I*pow(x,2))) * pow(x-2,3) + + (numeric(-155,648) + log(3)/32 - I*Pi/32*csgn(I-I*pow(x,2))) * pow(x-2,4) + + Order(pow(x-2,5)); + return check_series(e,2,d,5); +} + unsigned exam_pseries(void) { unsigned result = 0; @@ -217,6 +234,8 @@ unsigned exam_pseries(void) result += exam_series5(); cout << '.' << flush; result += exam_series6(); cout << '.' << flush; result += exam_series7(); cout << '.' << flush; + result += exam_series8(); cout << '.' << flush; + result += exam_series9(); cout << '.' << flush; if (!result) { cout << " passed " << endl; diff --git a/cint/Makefile.in b/cint/Makefile.in index 89fcfce9..42d1ce27 100644 --- a/cint/Makefile.in +++ b/cint/Makefile.in @@ -82,6 +82,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -94,6 +95,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ diff --git a/cint/ginaccint.bin.cpp b/cint/ginaccint.bin.cpp index de396e60..dca000f3 100644 --- a/cint/ginaccint.bin.cpp +++ b/cint/ginaccint.bin.cpp @@ -31,7 +31,7 @@ extern "C" void G__store_undo_position(void); #include template -string ToString(const T & t) +std::string ToString(const T & t) { char buf[256]; ostrstream(buf,sizeof(buf)) << t << ends; @@ -44,36 +44,36 @@ long ex::last_created_or_assigned_exp = 0; #endif // def OBSCURE_CINT_HACK -G__value exec_tempfile(string const & command); -char * process_permanentfile(string const & command); -void process_tempfile(string const & command); +G__value exec_tempfile(std::string const & command); +char * process_permanentfile(std::string const & command); +void process_tempfile(std::string const & command); void greeting(void); void helpmessage(void); -string preprocess(char const * const line, bool & comment, bool & single_quote, - bool & double_quote, unsigned & open_braces); +std::string preprocess(char const * const line, bool & comment, bool & single_quote, + bool & double_quote, unsigned & open_braces); void cleanup(void); void sigterm_handler(int n); void initialize(void); void initialize_cint(void); void restart(void); -bool is_command(string const & command, string & preprocessed, - string const & comparevalue, bool substr=false); -bool readlines(istream * is, string & allcommands); -bool readfile(string const & filename, string & allcommands, bool shutup=false); -void savefile(string const & filename, string const & allcommands); +bool is_command(std::string const & command, std::string & preprocessed, + std::string const & comparevalue, bool substr=false); +bool readlines(istream * is, std::string & allcommands); +bool readfile(std::string const & filename, std::string & allcommands, bool shutup=false); +void savefile(std::string const & filename, std::string const & allcommands); typedef list cplist; cplist filenames; bool redirect_output = false; bool silent = false; -G__value exec_tempfile(string const & command) +G__value exec_tempfile(std::string const & command) { G__value retval; char *tmpfilename = tempnam(NULL,"ginac"); - ofstream fout; + std::ofstream fout; fout.open(tmpfilename); - fout << "{" << endl << command << endl << "}" << endl; + fout << "{" << std::endl << command << std::endl << "}" << std::endl; fout.close(); G__store_undo_position(); retval = G__exec_tempfile(tmpfilename); @@ -83,14 +83,14 @@ G__value exec_tempfile(string const & command) return retval; } -char * process_permanentfile(string const & command) +char * process_permanentfile(std::string const & command) { char *tmpfilename = tempnam(NULL,"ginac"); if (!silent) - cout << "creating file " << tmpfilename << endl; - ofstream fout; + std::cout << "creating file " << tmpfilename << std::endl; + std::ofstream fout; fout.open(tmpfilename); - fout << command << endl; + fout << command << std::endl; fout.close(); G__store_undo_position(); G__loadfile(tmpfilename); @@ -98,7 +98,7 @@ char * process_permanentfile(string const & command) return tmpfilename; } -void process_tempfile(string const & command) +void process_tempfile(std::string const & command) { #ifdef OBSCURE_CINT_HACK static G__value ref_symbol = exec_tempfile("symbol ginac_cint_internal_symbol; ginac_cint_internal_symbol;"); @@ -118,27 +118,27 @@ void process_tempfile(string const & command) static unsigned out_count = 0; if (TYPES_EQUAL(retval,ref_ex)) { - string varname = "Out"+ToString(++out_count); + std::string varname = "Out"+ToString(++out_count); if (retval.obj.i!=ex::last_created_or_assigned_exp) { // an ex was returned, but this is not the ex which was created last // => this is not a temporary ex, but one that resides safely in memory - // cout << "warning: using ex from retval (experimental)" << endl; + // std::cout << "warning: using ex from retval (experimental)" << std::endl; ex::dummy_bp = ((ex *)(void *)(retval.obj.i))->bp; exec_tempfile("ex "+varname+"(*ex::dummy_bp);"); } else if (ex::last_created_or_assigned_bp_can_be_converted_to_ex()) { exec_tempfile("ex "+varname+"(*ex::last_created_or_assigned_bp);"); } else { - cout << "warning: last_created_or_assigned_bp modified 0 or not evaluated or not dynallocated" << endl; + std::cout << "warning: last_created_or_assigned_bp modified 0 or not evaluated or not dynallocated" << std::endl; } - exec_tempfile(string()+"LLLAST=LLAST;\n" + exec_tempfile(std::string()+"LLLAST=LLAST;\n" +"LLAST=LAST;\n" +"LAST="+varname+";\n" +"if (ginac_cint_internal_redirect_output&&" +" ginac_cint_internal_fout.good()) {" +" ginac_cint_internal_fout << \""+varname+" = \" << "+varname+" << endl << endl;" +"} else {" - +" cout << \""+varname+" = \" << "+varname+" << endl << endl;" + +" std::cout << \""+varname+" = \" << "+varname+" << endl << endl;" +"}"); } else if (TYPES_EQUAL(retval,ref_symbol)|| TYPES_EQUAL(retval,ref_constant)|| @@ -146,16 +146,16 @@ void process_tempfile(string const & command) TYPES_EQUAL(retval,ref_power)|| TYPES_EQUAL(retval,ref_numeric)) { if (!basic_type_warning_already_displayed) { - cout << endl - <<"WARNING: The return value of the last expression you entered was a symbol," << endl - << "constant, function, power or numeric, which cannot be safely displayed." << endl - << "To force the output, cast it explicitly to type 'ex' or use 'cout'," << endl - << "for example (assume 'x' is a symbol):" << endl - << PROMPT1 "ex(x);" << endl - << "OutX = x" << endl << endl - << PROMPT1 "cout << x << endl;" << endl - << "x" << endl << endl - << "This warning will not be shown again." << endl; + std::cout << std::endl + <<"WARNING: The return value of the last expression you entered was a symbol," << std::endl + << "constant, function, power or numeric, which cannot be safely displayed." << std::endl + << "To force the output, cast it explicitly to type 'ex' or use 'cout'," << std::endl + << "for example (assume 'x' is a symbol):" << std::endl + << PROMPT1 "ex(x);" << std::endl + << "OutX = x" << std::endl << std::endl + << PROMPT1 "cout << x << endl;" << std::endl + << "x" << std::endl << std::endl + << "This warning will not be shown again." << std::endl; basic_type_warning_already_displayed = true; } } @@ -165,64 +165,64 @@ void process_tempfile(string const & command) void greeting(void) { - cout << "Welcome to GiNaC-cint (" << PACKAGE << " V" << VERSION - << ", Cint V" << G__CINTVERSION << ")\n"; - cout << " __, _______ GiNaC: (C) 1999-2000 Johannes Gutenberg University Mainz,\n" - << " (__) * | Germany. Cint C/C++ interpreter: (C) 1995-2000 Masaharu\n" - << " ._) i N a C | Goto and Agilent Technologies, Japan. This is free software\n" - << "<-------------' with ABSOLUTELY NO WARRANTY. For details, type `.warranty'\n" - << "Type `.help' for help.\n\n"; + std::cout << "Welcome to GiNaC-cint (" << PACKAGE << " V" << VERSION + << ", Cint V" << G__CINTVERSION << ")\n"; + std::cout << " __, _______ GiNaC: (C) 1999-2000 Johannes Gutenberg University Mainz,\n" + << " (__) * | Germany. Cint C/C++ interpreter: (C) 1995-2000 Masaharu\n" + << " ._) i N a C | Goto and Agilent Technologies, Japan. This is free software\n" + << "<-------------' with ABSOLUTELY NO WARRANTY. For details, type `.warranty'\n" + << "Type `.help' for help.\n\n"; return; } void helpmessage(void) { - cout << "GiNaC-cint recognizes some special commands which start with a dot:\n\n" - << " .cint switch to cint interactive mode (see cint\n" - << " documentation for further details)\n" - << " .function define the body of a function (necessary due to a\n" - << " cint limitation)\n" - << " .help the text you are currently reading\n" - << " .q, .quit, .exit, .bye quit GiNaC-cint\n" - << " .read filename read a file from disk and execute it in GiNaC-cint\n" - << " (recursive call is possible)\n" - << " .redirect [filename] redirect 'OutXY = ...' output to a file\n" - << " (.redirect alone redirects output back to console)\n" - << " .restart restart GiNaC-cint (does not re-read command line\n" - << " files)\n" - << " .save filename save the commands you have entered so far in a file\n" - << " .silent suppress 'OutXY = ...' output (variables are still\n" - << " accessible)\n" - << " .warranty information on redistribution and warranty\n" - << " .> [filename] same as .redirect [filename]\n\n" - << "Instead of '.cmd' you can also write '//GiNaC-cint.cmd' to be compatible with\n" - << "programs that will be compiled later.\n" - << "Additionally you can exit GiNaC-cint with quit; exit; or bye;\n\n"; + std::cout << "GiNaC-cint recognizes some special commands which start with a dot:\n\n" + << " .cint switch to cint interactive mode (see cint\n" + << " documentation for further details)\n" + << " .function define the body of a function (necessary due to a\n" + << " cint limitation)\n" + << " .help the text you are currently reading\n" + << " .q, .quit, .exit, .bye quit GiNaC-cint\n" + << " .read filename read a file from disk and execute it in GiNaC-cint\n" + << " (recursive call is possible)\n" + << " .redirect [filename] redirect 'OutXY = ...' output to a file\n" + << " (.redirect alone redirects output back to console)\n" + << " .restart restart GiNaC-cint (does not re-read command line\n" + << " files)\n" + << " .save filename save the commands you have entered so far in a file\n" + << " .silent suppress 'OutXY = ...' output (variables are still\n" + << " accessible)\n" + << " .warranty information on redistribution and warranty\n" + << " .> [filename] same as .redirect [filename]\n\n" + << "Instead of '.cmd' you can also write '//GiNaC-cint.cmd' to be compatible with\n" + << "programs that will be compiled later.\n" + << "Additionally you can exit GiNaC-cint with quit; exit; or bye;\n\n"; return; } void warrantymessage(void) { - cout << "GiNaC is free software; you can redistribute it and/or modify it under the\n" - << "the terms of the GNU General Public License as published by the Free Software\n" - << "Foundation; either version 2 of the License, or (at your option) any later\n" - << "version.\n" - << "This program is distributed in the hope that it will be useful, but WITHOUT\n" - << "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n" - << "FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n" - << "details.\n" - << "You should have received a copy of the GNU General Public License along with\n" - << "this program. If not, write to the Free Software Foundation, 675 Mass Ave,\n" - << "Cambridge, MA 02139, USA.\n\n"; - cout << "Cint and associated tools are copyright by Agilent Technologies Japan Company\n" - << "and Masaharu Goto .\n" - << "Source code, binary executable or library of Cint and associated tools can be\n" - << "used, modified and distributed with no royalty for any purpose provided that\n" - << "the copyright notice appear in all copies and that both that copyright notice\n" - << "and this permission notice appear in supporting documentation.\n" - << "Agilent Technologies Japan and the author make no representations about the\n" - << "suitability of this software for any purpose. It is provided \"AS IS\"\n" - << "without express or implied warranty.\n"; + std::cout << "GiNaC is free software; you can redistribute it and/or modify it under the\n" + << "the terms of the GNU General Public License as published by the Free Software\n" + << "Foundation; either version 2 of the License, or (at your option) any later\n" + << "version.\n" + << "This program is distributed in the hope that it will be useful, but WITHOUT\n" + << "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n" + << "FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n" + << "details.\n" + << "You should have received a copy of the GNU General Public License along with\n" + << "this program. If not, write to the Free Software Foundation, 675 Mass Ave,\n" + << "Cambridge, MA 02139, USA.\n\n"; + std::cout << "Cint and associated tools are copyright by Agilent Technologies Japan Company\n" + << "and Masaharu Goto .\n" + << "Source code, binary executable or library of Cint and associated tools can be\n" + << "used, modified and distributed with no royalty for any purpose provided that\n" + << "the copyright notice appear in all copies and that both that copyright notice\n" + << "and this permission notice appear in supporting documentation.\n" + << "Agilent Technologies Japan and the author make no representations about the\n" + << "suitability of this software for any purpose. It is provided \"AS IS\"\n" + << "without express or implied warranty.\n"; return; } @@ -230,10 +230,10 @@ void warrantymessage(void) * executed directly or more input is needed or this is a special command. * All whitespace will be removed. All comments will be removed. Open and * close braces ( { and } ) outside strings will be counted. */ -string preprocess(char const * const line, bool & comment, bool & single_quote, - bool & double_quote, unsigned & open_braces) +std::string preprocess(char const * const line, bool & comment, bool & single_quote, + bool & double_quote, unsigned & open_braces) { - string preprocessed; + std::string preprocessed; int pos = 0; bool end = false; bool escape = false; @@ -315,7 +315,7 @@ void cleanup(void) { for (cplist::iterator it=filenames.begin(); it!=filenames.end(); ++it) { if (!silent) - cout << "removing file " << *it << endl; + std::cout << "removing file " << *it << std::endl; remove(*it); free(*it); } @@ -348,24 +348,24 @@ void initialize_cint(void) void restart(void) { - cout << "Restarting GiNaC-cint." << endl; + std::cout << "Restarting GiNaC-cint." << std::endl; G__scratch_all(); initialize_cint(); } -void redirect(string const & filename, +void redirect(std::string const & filename, bool shutup=false) { if (filename=="") { if (!shutup) - cout << "Redirecting output back to console..." << endl; - exec_tempfile( string() + std::cout << "Redirecting output back to console..." << std::endl; + exec_tempfile( std::string() +"ginac_cint_internal_redirect_output=false;\n" +"ginac_cint_internal_fout.close();"); } else { if (!shutup) - cout << "Redirecting output to " << filename << "..." << endl; - exec_tempfile( string() + std::cout << "Redirecting output to " << filename << "..." << std::endl; + exec_tempfile( std::string() +"ginac_cint_internal_redirect_output=true;\n" +"ginac_cint_internal_fout.open(\""+filename+"\");\n"); } @@ -373,20 +373,20 @@ void redirect(string const & filename, /** Sort out command line options and evaluate them. Returns true if it * succeeds and false otherwise. */ -bool evaloption(const string & option) +bool evaloption(const std::string & option) { if (option=="--version") { - cout << "GiNaC-cint (" << PACKAGE << " V" << VERSION + std::cout << "GiNaC-cint (" << PACKAGE << " V" << VERSION << ", Cint V" << G__CINTVERSION << ")\n"; exit(0); } if (option=="--help") { - cout << "GiNaC-cint (" << PACKAGE << " V" << VERSION - << ", Cint V" << G__CINTVERSION << ")\n"; - cout << "usage: ginaccint [option] [file ...]\n"; - cout << " --help print this help message and exit\n" - << " --silent invoke ginaccint in silent mode\n" - << " --version print GiNaC version and Cint version and exit\n"; + std::cout << "GiNaC-cint (" << PACKAGE << " V" << VERSION + << ", Cint V" << G__CINTVERSION << ")\n"; + std::cout << "usage: ginaccint [option] [file ...]\n"; + std::cout << " --help print this help message and exit\n" + << " --silent invoke ginaccint in silent mode\n" + << " --version print GiNaC version and Cint version and exit\n"; exit(0); } if (option=="--silent") { @@ -397,9 +397,9 @@ bool evaloption(const string & option) return false; } -bool is_command(string const & command, - string & preprocessed, - string const & comparevalue, +bool is_command(std::string const & command, + std::string & preprocessed, + std::string const & comparevalue, bool substr) { bool single_quote = false; @@ -422,11 +422,11 @@ bool is_command(string const & command, } bool readlines(istream * is, - string & allcommands) + std::string & allcommands) { char const * line; char prompt[G__ONELINE]; - string linebuffer; + std::string linebuffer; bool quit = false; bool eof = false; @@ -439,8 +439,8 @@ bool readlines(istream * is, while ((!quit)&&(!eof)) { strcpy(prompt,PROMPT1); bool end_of_command = false; - string command; - string preprocessed; + std::string command; + std::string preprocessed; while (!end_of_command) { if (is==NULL) { line = G__input(prompt); @@ -473,13 +473,13 @@ bool readlines(istream * is, quit = true; } else if (is_command(command,preprocessed,"function")) { if (!silent) - cout << "next expression can be a function definition" << endl; + std::cout << "next expression can be a function definition" << std::endl; next_command_is_function = true; } else if (is_command(command,preprocessed,"cint")) { - cout << endl << "switching to cint interactive mode" << endl; - cout << "'h' for help, 'q' to quit, '{ statements }' or 'p [expression]' to evaluate" << endl; + std::cout << std::endl << "switching to cint interactive mode" << std::endl; + std::cout << "'h' for help, 'q' to quit, '{ statements }' or 'p [expression]' to evaluate" << std::endl; G__pause(); - cout << "back from cint" << endl; + std::cout << "back from cint" << std::endl; } else if (is_command(command,preprocessed,"help")) { helpmessage(); } else if (is_command(command,preprocessed,"read",true)) { @@ -505,12 +505,12 @@ bool readlines(istream * is, warrantymessage(); /* test for more special commands } else if (preprocessed==".xyz") { - cout << "special command (TBD): " << command << endl; + std::cout << "special command (TBD): " << command << std::endl; */ } else if (command.substr(0,2)=="#!") { // ignore lines which indicate that this file is executed as a script } else { - // cout << "now processing: " << command << endl; + // std::cout << "now processing: " << command << std::endl; if (next_command_is_function) { next_command_is_function = false; filenames.push_back(process_permanentfile(command)); @@ -530,42 +530,42 @@ bool readlines(istream * is, return quit; } -bool readfile(string const & filename, - string & allcommands, - bool shutup=false) +bool readfile(std::string const & filename, + std::string & allcommands, + bool shutup = false) { if (!shutup) - cout << "Reading commands from file " << filename << "." << endl; + std::cout << "Reading commands from file " << filename << "." << std::endl; bool quit = false; - ifstream fin; + std::ifstream fin; fin.open(filename.c_str()); if (fin.good()) quit = readlines(&fin,allcommands); else - cout << "Cannot open " << filename << " for reading." << endl; + std::cout << "Cannot open " << filename << " for reading." << std::endl; fin.close(); return quit; } -void savefile(string const & filename, string const & allcommands) +void savefile(std::string const & filename, std::string const & allcommands) { - cout << "Saving commands to file " << filename << "." << endl; - ofstream fout; + std::cout << "Saving commands to file " << filename << "." << std::endl; + std::ofstream fout; fout.open(filename.c_str()); if (fout.good()) { fout << allcommands; if (!fout.good()) { - cout << "Cannot save commands to " << filename << "." << endl; + std::cout << "Cannot save commands to " << filename << "." << std::endl; } } else { - cout << "Cannot open " << filename << " for writing." << endl; + std::cout << "Cannot open " << filename << " for writing." << std::endl; } fout.close(); } int main(int argc, char * *argv) { - string allcommands; + std::string allcommands; initialize(); bool quit = false; @@ -587,7 +587,7 @@ int main(int argc, char * *argv) allcommands = "/* Files given as command line arguments:\n"; --argc; while (argc && !quit) { - allcommands += string(argv[argc])+'\n'; + allcommands += std::string(argv[argc])+'\n'; quit = readfile(argv[argc], allcommands, silent); --argc; } diff --git a/cint/ginaccint.cpp b/cint/ginaccint.cpp index 4d25c445..0c6e1c1e 100644 --- a/cint/ginaccint.cpp +++ b/cint/ginaccint.cpp @@ -22,14 +22,14 @@ int main(int argc, char * *argv) if (libdir=="${exec_prefix}/lib") libdir = exec_prefix + "/lib"; // now we can guess what to start - string binprog = bindir + "/ginaccint.bin"; + std::string binprog = bindir + "/ginaccint.bin"; // extend LD_LIBRARY_PATH by libdir, so ginaccint.bin really finds libginac const char * LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH"); if (LD_LIBRARY_PATH == NULL) setenv("LD_LIBRARY_PATH", libdir.c_str(), 1); else - setenv("LD_LIBRARY_PATH", (string(LD_LIBRARY_PATH)+':'+libdir).c_str(), 1); + setenv("LD_LIBRARY_PATH", (std::string(LD_LIBRARY_PATH)+':'+libdir).c_str(), 1); // hard-wire CINTSYSDIR, inherited from configure, if it is not set setenv("CINTSYSDIR", CINTSYSDIR.c_str(), 0); @@ -38,6 +38,6 @@ int main(int argc, char * *argv) int error = execve(binprog.c_str(), argv, environ); // only gets here on error - cerr << argv[0] << ": cannot exec " << binprog << endl; + std::cerr << argv[0] << ": cannot exec " << binprog << std::endl; return error; } diff --git a/cint/run_exams.cpp b/cint/run_exams.cpp index dabf467b..6225d73b 100644 --- a/cint/run_exams.cpp +++ b/cint/run_exams.cpp @@ -15,14 +15,14 @@ extern char **environ; int main(int argc, char * *argv) { // what to start - string binprog = "./ginaccint.bin"; + std::string binprog = "./ginaccint.bin"; // extend LD_LIBRARY_PATH by ../ginac/.libs, so ginaccint.bin really finds libginac const char * LD_LIBRARY_PATH = getenv("LD_LIBRARY_PATH"); if (LD_LIBRARY_PATH == NULL) setenv("LD_LIBRARY_PATH", "../ginac/.libs", 1); else - setenv("LD_LIBRARY_PATH", (string(LD_LIBRARY_PATH)+':'+"../ginac/.libs").c_str(), 1); + setenv("LD_LIBRARY_PATH", (std::string(LD_LIBRARY_PATH)+':'+"../ginac/.libs").c_str(), 1); // hard-wire CINTSYSDIR, inherited from configure setenv("CINTSYSDIR", CINTSYSDIR.c_str(), 1); @@ -31,6 +31,6 @@ int main(int argc, char * *argv) int error = execve(binprog.c_str(), argv, environ); // only gets here on error - cerr << argv[0] << ": cannot exec " << binprog << endl; + std::cerr << argv[0] << ": cannot exec " << binprog << std::endl; return error; } diff --git a/config.sub b/config.sub index 8fa14be2..2b4fad13 100755 --- a/config.sub +++ b/config.sub @@ -3,7 +3,7 @@ # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000 # Free Software Foundation, Inc. -version='2000-06-13' +version='2000-07-06' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -218,9 +218,14 @@ case $basic_machine in | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \ | mips64vr5000 | miprs64vr5000el | mcore \ | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \ - | thumb | d10v | fr30 | avr) + | thumb | d10v | d30v | fr30 | avr) basic_machine=$basic_machine-unknown ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl) ;; @@ -257,7 +262,7 @@ case $basic_machine in | f301-* | armv*-* | s390-* | sv1-* | t3e-* \ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \ | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \ - | bs2000-*) + | bs2000-* | tic54x-* | c54x-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. @@ -793,6 +798,10 @@ case $basic_machine in basic_machine=t3e-cray os=-unicos ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; tx39) basic_machine=mipstx39-unknown ;; diff --git a/configure b/configure index efc04bd6..1b903beb 100755 --- a/configure +++ b/configure @@ -545,9 +545,9 @@ fi GINACLIB_MAJOR_VERSION=0 GINACLIB_MINOR_VERSION=6 -GINACLIB_MICRO_VERSION=2 -GINACLIB_INTERFACE_AGE=2 -GINACLIB_BINARY_AGE=2 +GINACLIB_MICRO_VERSION=3 +GINACLIB_INTERFACE_AGE=0 +GINACLIB_BINARY_AGE=0 GINACLIB_VERSION=$GINACLIB_MAJOR_VERSION.$GINACLIB_MINOR_VERSION.$GINACLIB_MICRO_VERSION @@ -1550,8 +1550,9 @@ else echo "$ac_t""no" 1>&6 fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } + echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:1555: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:1556: checking if the linker ($LD) is GNU ld" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1567,7 +1568,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1571: checking for BSD-compatible nm" >&5 +echo "configure:1572: checking for BSD-compatible nm" >&5 if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1602,8 +1603,9 @@ fi NM="$ac_cv_path_NM" echo "$ac_t""$NM" 1>&6 + echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1607: checking whether ln -s works" >&5 +echo "configure:1609: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1624,11 +1626,6 @@ else fi -case "$target" in -NONE) lt_target="$host" ;; -*) lt_target="$target" ;; -esac - # Check for any special flags to pass to ltconfig. libtool_flags="--cache-file=$cache_file" test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" @@ -1649,11 +1646,11 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" # Some flags need to be propagated to the compiler or linker for good # libtool support. -case "$lt_target" in +case "$host" in *-*-irix6*) # Find out which ABI we are using. - echo '#line 1656 "configure"' > conftest.$ac_ext - if { (eval echo configure:1657: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 1653 "configure"' > conftest.$ac_ext + if { (eval echo configure:1654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *32-bit*) LD="${LD-ld} -32" @@ -1674,19 +1671,27 @@ case "$lt_target" in SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:1678: checking whether the C compiler needs -belf" >&5 +echo "configure:1675: checking whether the C compiler needs -belf" >&5 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else - cat > conftest.$ac_ext < conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1695: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_needs_belf=yes else @@ -1696,6 +1701,13 @@ else lt_cv_cc_needs_belf=no fi rm -f conftest* + ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + fi echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 @@ -1764,7 +1776,7 @@ LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ ${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ -$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $host \ || { echo "configure: error: libtool configure failed" 1>&2; exit 1; } # Reload cache, that may have been modified by ltconfig @@ -1788,7 +1800,7 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool' exec 5>>./config.log echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 -echo "configure:1792: checking how to run the C preprocessor" >&5 +echo "configure:1804: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= @@ -1803,13 +1815,13 @@ else # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1813: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1825: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1820,13 +1832,13 @@ else rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1830: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1842: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1837,13 +1849,13 @@ else rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1847: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:1859: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : @@ -1873,7 +1885,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1877: checking for $ac_word" >&5 +echo "configure:1889: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1906,7 +1918,7 @@ test -n "$LEX" || LEX=""$missing_dir/missing flex"" # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1910: checking for $ac_word" >&5 +echo "configure:1922: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1940,7 +1952,7 @@ then *) ac_lib=l ;; esac echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 -echo "configure:1944: checking for yywrap in -l$ac_lib" >&5 +echo "configure:1956: checking for yywrap in -l$ac_lib" >&5 ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1948,7 +1960,7 @@ else ac_save_LIBS="$LIBS" LIBS="-l$ac_lib $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1975: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -1982,7 +1994,7 @@ fi fi echo $ac_n "checking lex output file root""... $ac_c" 1>&6 -echo "configure:1986: checking lex output file root" >&5 +echo "configure:1998: checking lex output file root" >&5 if eval "test \"`echo '$''{'ac_cv_prog_lex_root'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2003,7 +2015,7 @@ echo "$ac_t""$ac_cv_prog_lex_root" 1>&6 LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root echo $ac_n "checking whether yytext is a pointer""... $ac_c" 1>&6 -echo "configure:2007: checking whether yytext is a pointer" >&5 +echo "configure:2019: checking whether yytext is a pointer" >&5 if eval "test \"`echo '$''{'ac_cv_prog_lex_yytext_pointer'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2015,14 +2027,14 @@ echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c ac_save_LIBS="$LIBS" LIBS="$LIBS $LEXLIB" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2038: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_prog_lex_yytext_pointer=yes else @@ -2048,7 +2060,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2052: checking for $ac_word" >&5 +echo "configure:2064: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_YACC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2105,7 +2117,7 @@ fi echo $ac_n "checking size of long""... $ac_c" 1>&6 -echo "configure:2109: checking size of long" >&5 +echo "configure:2121: checking size of long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2113,7 +2125,7 @@ else ac_cv_sizeof_long=4 else cat > conftest.$ac_ext < main() @@ -2124,7 +2136,7 @@ main() exit(0); } EOF -if { (eval echo configure:2128: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2140: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else @@ -2144,7 +2156,7 @@ EOF echo $ac_n "checking size of long long""... $ac_c" 1>&6 -echo "configure:2148: checking size of long long" >&5 +echo "configure:2160: checking size of long long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2152,7 +2164,7 @@ else ac_cv_sizeof_long_long=8 else cat > conftest.$ac_ext < main() @@ -2163,7 +2175,7 @@ main() exit(0); } EOF -if { (eval echo configure:2167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2179: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long_long=`cat conftestval` else @@ -2183,7 +2195,7 @@ EOF echo $ac_n "checking size of long double""... $ac_c" 1>&6 -echo "configure:2187: checking size of long double" >&5 +echo "configure:2199: checking size of long double" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long_double'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2191,7 +2203,7 @@ else ac_cv_sizeof_long_double=12 else cat > conftest.$ac_ext < main() @@ -2202,7 +2214,7 @@ main() exit(0); } EOF -if { (eval echo configure:2206: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2218: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long_double=`cat conftestval` else @@ -2234,17 +2246,17 @@ for ac_hdr in unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2238: checking for $ac_hdr" >&5 +echo "configure:2250: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2248: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2260: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2274,17 +2286,17 @@ for ac_hdr in readline/readline.h readline/history.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2278: checking for $ac_hdr" >&5 +echo "configure:2290: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2288: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2300: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2321,12 +2333,12 @@ LIBTERMCAP= for ac_func in tgetent do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 -echo "configure:2325: checking for $ac_func" >&5 +echo "configure:2337: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2368: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else @@ -2380,7 +2392,7 @@ if test "x$ac_cv_func_tgetent" = "xyes"; then : else echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6 -echo "configure:2384: checking for tgetent in -lncurses" >&5 +echo "configure:2396: checking for tgetent in -lncurses" >&5 ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2388,7 +2400,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lncurses $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2424,7 +2436,7 @@ fi if test -z "$LIBTERMCAP"; then echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6 -echo "configure:2428: checking for tgetent in -ltermcap" >&5 +echo "configure:2440: checking for tgetent in -ltermcap" >&5 ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2432,7 +2444,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ltermcap $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2462: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2473,7 +2485,7 @@ fi save_LIBS=$LIBS LIBS="$LIBTERMCAP $LIBS" echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6 -echo "configure:2477: checking for readline in -lreadline" >&5 +echo "configure:2489: checking for readline in -lreadline" >&5 ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2481,7 +2493,7 @@ else ac_save_LIBS="$LIBS" LIBS="-lreadline $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2511: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2537,17 +2549,17 @@ for ac_hdr in iostream vector map string list typeinfo iterator stdexcept algori do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2541: checking for $ac_hdr" >&5 +echo "configure:2553: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2551: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2563: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2578,17 +2590,17 @@ for ac_hdr in sstream strstream do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2582: checking for $ac_hdr" >&5 +echo "configure:2594: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2592: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2604: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2620,17 +2632,17 @@ done do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2624: checking for $ac_hdr" >&5 +echo "configure:2636: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2634: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2646: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2657,17 +2669,17 @@ for ac_hdr in cln.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2661: checking for $ac_hdr" >&5 +echo "configure:2673: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2671: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2683: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* @@ -2702,7 +2714,7 @@ done echo $ac_n "checking for doublefactorial in -lcln""... $ac_c" 1>&6 -echo "configure:2706: checking for doublefactorial in -lcln" >&5 +echo "configure:2718: checking for doublefactorial in -lcln" >&5 saved_LIBS="${LIBS}" if eval "test \"`echo '$''{'ginac_cv_lib_cln_link'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2711,14 +2723,14 @@ else case "${ac_cv_header_cln_cln_h}" in "yes") cat > conftest.$ac_ext < int main() { doublefactorial(2); ; return 0; } EOF -if { (eval echo configure:2722: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2734: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ginac_cv_lib_cln_link="-lcln" else @@ -2731,14 +2743,14 @@ rm -f conftest* ;; *) cat > conftest.$ac_ext < int main() { doublefactorial(2); ; return 0; } EOF -if { (eval echo configure:2742: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2754: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ginac_cv_lib_cln_link="-lcln" else @@ -2779,7 +2791,7 @@ GINACLIB_LIBS=$LIBS # Extract the first word of "doxygen", so it can be a program name with args. set dummy doxygen; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2783: checking for $ac_word" >&5 +echo "configure:2795: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_DOXYGEN'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2815,7 +2827,7 @@ fi # Extract the first word of "latex", so it can be a program name with args. set dummy latex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2819: checking for $ac_word" >&5 +echo "configure:2831: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_LATEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2851,7 +2863,7 @@ fi # Extract the first word of "makeindex", so it can be a program name with args. set dummy makeindex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2855: checking for $ac_word" >&5 +echo "configure:2867: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MAKEINDEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2887,7 +2899,7 @@ fi # Extract the first word of "dvips", so it can be a program name with args. set dummy dvips; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2891: checking for $ac_word" >&5 +echo "configure:2903: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_DVIPS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2923,7 +2935,7 @@ fi # Extract the first word of "fig2dev", so it can be a program name with args. set dummy fig2dev; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2927: checking for $ac_word" >&5 +echo "configure:2939: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_FIG2DEV'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2987,7 +2999,7 @@ if test "x$with_cint" != "xno"; then # Extract the first word of "cint", so it can be a program name with args. set dummy cint; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:2991: checking for $ac_word" >&5 +echo "configure:3003: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_CINT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3023,7 +3035,7 @@ fi # Extract the first word of "makecint", so it can be a program name with args. set dummy makecint; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:3027: checking for $ac_word" >&5 +echo "configure:3039: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_path_MAKECINT'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -3261,6 +3273,8 @@ s%@build_vendor@%$build_vendor%g s%@build_os@%$build_os%g s%@RANLIB@%$RANLIB%g s%@CC@%$CC%g +s%@LD@%$LD%g +s%@NM@%$NM%g s%@LN_S@%$LN_S%g s%@LIBTOOL@%$LIBTOOL%g s%@LEX@%$LEX%g diff --git a/configure.in b/configure.in index f10abf96..1f17c6a9 100644 --- a/configure.in +++ b/configure.in @@ -19,9 +19,9 @@ dnl (don't we all *love* M4?)... GINACLIB_MAJOR_VERSION=0 GINACLIB_MINOR_VERSION=6 -GINACLIB_MICRO_VERSION=2 -GINACLIB_INTERFACE_AGE=2 -GINACLIB_BINARY_AGE=2 +GINACLIB_MICRO_VERSION=3 +GINACLIB_INTERFACE_AGE=0 +GINACLIB_BINARY_AGE=0 GINACLIB_VERSION=$GINACLIB_MAJOR_VERSION.$GINACLIB_MINOR_VERSION.$GINACLIB_MICRO_VERSION AC_SUBST(GINACLIB_MAJOR_VERSION) diff --git a/doc/Makefile.in b/doc/Makefile.in index 5e9d536f..79c771fd 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -82,6 +82,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -94,6 +95,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ diff --git a/doc/reference/Makefile.in b/doc/reference/Makefile.in index 7d610ec7..bb186000 100644 --- a/doc/reference/Makefile.in +++ b/doc/reference/Makefile.in @@ -85,6 +85,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -97,6 +98,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ diff --git a/doc/tutorial/Makefile.in b/doc/tutorial/Makefile.in index 2bad576a..027e555a 100644 --- a/doc/tutorial/Makefile.in +++ b/doc/tutorial/Makefile.in @@ -84,6 +84,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -96,6 +97,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ diff --git a/doc/tutorial/ginac.texi b/doc/tutorial/ginac.texi index ad044074..536bf897 100644 --- a/doc/tutorial/ginac.texi +++ b/doc/tutorial/ginac.texi @@ -2068,10 +2068,17 @@ GiNaC contains the following predefined mathematical functions: @cindex branch cut For functions that have a branch cut in the complex plane GiNaC follows -the conventions for C++ as defined in the ANSI standard. In particular: -the natural logarithm (@code{log}) and the square root (@code{sqrt}) -both have their branch cuts running along the negative real axis where -the points on the axis itself belong to the upper part. +the conventions for C++ as defined in the ANSI standard as far as +possible. In particular: the natural logarithm (@code{log}) and the +square root (@code{sqrt}) both have their branch cuts running along the +negative real axis where the points on the axis itself belong to the +upper part (i.e. continuous with quadrant II). The inverse +trigonometric and hyperbolic functions are not defined for complex +arguments by the C++ standard, however. Here, we follow the conventions +used by CLN, which in turn follow the carefully structured definitions +in the Common Lisp standard. Hopefully, future revisions of the C++ +standard incorporate these functions in the complex domain in a manner +compatible with Common Lisp. @node Input/Output, Extending GiNaC, Built-in Functions, Methods and Functions diff --git a/ginac/Makefile.in b/ginac/Makefile.in index 4677e726..da902e49 100644 --- a/ginac/Makefile.in +++ b/ginac/Makefile.in @@ -82,6 +82,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -94,6 +95,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ diff --git a/ginac/add.cpp b/ginac/add.cpp index 8a7e9041..f85617c6 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -185,7 +185,7 @@ basic * add::duplicate() const return new add(*this); } -void add::print(ostream & os, unsigned upper_precedence) const +void add::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("add print",LOGLEVEL_PRINT); if (precedence<=upper_precedence) os << "("; @@ -225,7 +225,7 @@ void add::print(ostream & os, unsigned upper_precedence) const if (precedence<=upper_precedence) os << ")"; } -void add::printraw(ostream & os) const +void add::printraw(std::ostream & os) const { debugmsg("add printraw",LOGLEVEL_PRINT); @@ -241,7 +241,7 @@ void add::printraw(ostream & os) const os << ")"; } -void add::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void add::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("add print csrc", LOGLEVEL_PRINT); if (precedence <= upper_precedence) @@ -539,9 +539,9 @@ ex add::expand(unsigned options) const return *this; epvector * vp = expandchildren(options); - if (vp==0) { + if (vp==0) return *this; - } + return (new add(vp,overall_coeff))-> setflag(status_flags::expanded | status_flags::dynallocated); diff --git a/ginac/add.h b/ginac/add.h index a3c34e9c..7db48695 100644 --- a/ginac/add.h +++ b/ginac/add.h @@ -62,15 +62,15 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printraw(ostream & os) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; bool info(unsigned inf) const; int degree(const symbol & s) const; int ldegree(const symbol & s) const; ex coeff(const symbol & s, int n=1) const; ex eval(int level=0) const; - ex series(const relational & r, int order) const; + ex series(const relational & r, int order, bool branchcut = true) const; ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; numeric integer_content(void) const; ex smod(const numeric &xi) const; diff --git a/ginac/archive.cpp b/ginac/archive.cpp index 058264d9..73df064a 100644 --- a/ginac/archive.cpp +++ b/ginac/archive.cpp @@ -55,7 +55,7 @@ void archive::archive_ex(const ex &e, const char *name) archive_node_id archive::add_node(const archive_node &n) { // Search for node in nodes vector - vector::const_iterator i = nodes.begin(), iend = nodes.end(); + std::vector::const_iterator i = nodes.begin(), iend = nodes.end(); archive_node_id id = 0; while (i != iend) { if (i->has_same_ex_as(n)) @@ -84,9 +84,9 @@ archive_node &archive::get_node(archive_node_id id) ex archive::unarchive_ex(const lst &sym_lst, const char *name) const { // Find root node - string name_string = name; + std::string name_string = name; archive_atom id = atomize(name_string); - vector::const_iterator i = exprs.begin(), iend = exprs.end(); + std::vector::const_iterator i = exprs.begin(), iend = exprs.end(); while (i != iend) { if (i->name == id) goto found; @@ -112,7 +112,7 @@ ex archive::unarchive_ex(const lst &sym_lst, unsigned int index) const /** Retrieve expression and its name from archive by index. * @param sym_lst list of pre-defined symbols */ -ex archive::unarchive_ex(const lst &sym_lst, string &name, unsigned int index) const +ex archive::unarchive_ex(const lst &sym_lst, std::string &name, unsigned int index) const { if (index >= exprs.size()) throw (std::range_error("index of archived expression out of range")); @@ -172,7 +172,7 @@ unsigned int archive::num_expressions(void) const */ /** Write unsigned integer quantity to stream. */ -static void write_unsigned(ostream &os, unsigned int val) +static void write_unsigned(std::ostream &os, unsigned int val) { while (val > 0x80) { os.put((val & 0x7f) | 0x80); @@ -182,7 +182,7 @@ static void write_unsigned(ostream &os, unsigned int val) } /** Read unsigned integer quantity from stream. */ -static unsigned int read_unsigned(istream &is) +static unsigned int read_unsigned(std::istream &is) { unsigned char b; unsigned int ret = 0; @@ -196,7 +196,7 @@ static unsigned int read_unsigned(istream &is) } /** Write archive_node to binary data stream. */ -ostream &operator<<(ostream &os, const archive_node &n) +std::ostream &operator<<(std::ostream &os, const archive_node &n) { // Write properties unsigned int num_props = n.props.size(); @@ -209,7 +209,7 @@ ostream &operator<<(ostream &os, const archive_node &n) } /** Write archive to binary data stream. */ -ostream &operator<<(ostream &os, const archive &ar) +std::ostream &operator<<(std::ostream &os, const archive &ar) { // Write header os.put('G'); // Signature @@ -241,7 +241,7 @@ ostream &operator<<(ostream &os, const archive &ar) } /** Read archive_node from binary data stream. */ -istream &operator>>(istream &is, archive_node &n) +std::istream &operator>>(std::istream &is, archive_node &n) { // Read properties unsigned int num_props = read_unsigned(is); @@ -256,7 +256,7 @@ istream &operator>>(istream &is, archive_node &n) } /** Read archive from binary data stream. */ -istream &operator>>(istream &is, archive &ar) +std::istream &operator>>(std::istream &is, archive &ar) { // Read header char c1, c2, c3, c4; @@ -293,10 +293,10 @@ istream &operator>>(istream &is, archive &ar) /** Atomize a string (i.e. convert it into an ID number that uniquely * represents the string). */ -archive_atom archive::atomize(const string &s) const +archive_atom archive::atomize(const std::string &s) const { // Search for string in atoms vector - vector::const_iterator i = atoms.begin(), iend = atoms.end(); + std::vector::const_iterator i = atoms.begin(), iend = atoms.end(); archive_atom id = 0; while (i != iend) { if (*i == s) @@ -310,7 +310,7 @@ archive_atom archive::atomize(const string &s) const } /** Unatomize a string (i.e. convert the ID number back to the string). */ -const string &archive::unatomize(archive_atom id) const +const std::string &archive::unatomize(archive_atom id) const { if (id >= atoms.size()) throw (std::range_error("archive::unatomizee(): atom ID out of range")); @@ -359,25 +359,25 @@ bool archive_node::has_same_ex_as(const archive_node &other) const /** Add property of type "bool" to node. */ -void archive_node::add_bool(const string &name, bool value) +void archive_node::add_bool(const std::string &name, bool value) { props.push_back(property(a.atomize(name), PTYPE_BOOL, value)); } /** Add property of type "unsigned int" to node. */ -void archive_node::add_unsigned(const string &name, unsigned int value) +void archive_node::add_unsigned(const std::string &name, unsigned int value) { props.push_back(property(a.atomize(name), PTYPE_UNSIGNED, value)); } /** Add property of type "string" to node. */ -void archive_node::add_string(const string &name, const string &value) +void archive_node::add_string(const std::string &name, const std::string &value) { props.push_back(property(a.atomize(name), PTYPE_STRING, a.atomize(value))); } /** Add property of type "ex" to node. */ -void archive_node::add_ex(const string &name, const ex &value) +void archive_node::add_ex(const std::string &name, const ex &value) { // Recursively create an archive_node and add its ID to the properties of this node archive_node_id id = a.add_node(archive_node(a, value)); @@ -387,10 +387,10 @@ void archive_node::add_ex(const string &name, const ex &value) /** Retrieve property of type "bool" from node. * @return "true" if property was found, "false" otherwise */ -bool archive_node::find_bool(const string &name, bool &ret) const +bool archive_node::find_bool(const std::string &name, bool &ret) const { archive_atom name_atom = a.atomize(name); - vector::const_iterator i = props.begin(), iend = props.end(); + std::vector::const_iterator i = props.begin(), iend = props.end(); while (i != iend) { if (i->type == PTYPE_BOOL && i->name == name_atom) { ret = i->value; @@ -403,10 +403,10 @@ bool archive_node::find_bool(const string &name, bool &ret) const /** Retrieve property of type "unsigned" from node. * @return "true" if property was found, "false" otherwise */ -bool archive_node::find_unsigned(const string &name, unsigned int &ret) const +bool archive_node::find_unsigned(const std::string &name, unsigned int &ret) const { archive_atom name_atom = a.atomize(name); - vector::const_iterator i = props.begin(), iend = props.end(); + std::vector::const_iterator i = props.begin(), iend = props.end(); while (i != iend) { if (i->type == PTYPE_UNSIGNED && i->name == name_atom) { ret = i->value; @@ -419,10 +419,10 @@ bool archive_node::find_unsigned(const string &name, unsigned int &ret) const /** Retrieve property of type "string" from node. * @return "true" if property was found, "false" otherwise */ -bool archive_node::find_string(const string &name, string &ret) const +bool archive_node::find_string(const std::string &name, std::string &ret) const { archive_atom name_atom = a.atomize(name); - vector::const_iterator i = props.begin(), iend = props.end(); + std::vector::const_iterator i = props.begin(), iend = props.end(); while (i != iend) { if (i->type == PTYPE_STRING && i->name == name_atom) { ret = a.unatomize(i->value); @@ -435,10 +435,10 @@ bool archive_node::find_string(const string &name, string &ret) const /** Retrieve property of type "ex" from node. * @return "true" if property was found, "false" otherwise */ -bool archive_node::find_ex(const string &name, ex &ret, const lst &sym_lst, unsigned int index) const +bool archive_node::find_ex(const std::string &name, ex &ret, const lst &sym_lst, unsigned int index) const { archive_atom name_atom = a.atomize(name); - vector::const_iterator i = props.begin(), iend = props.end(); + std::vector::const_iterator i = props.begin(), iend = props.end(); unsigned int found_index = 0; while (i != iend) { if (i->type == PTYPE_NODE && i->name == name_atom) { @@ -464,7 +464,7 @@ ex archive_node::unarchive(const lst &sym_lst) const return e; // Find instantiation function for class specified in node - string class_name; + std::string class_name; if (!find_string("class", class_name)) throw (std::runtime_error("archive node contains no class name")); unarch_func f = find_unarch_func(class_name); @@ -500,7 +500,7 @@ void archive::clear(void) /** Delete cached unarchived expressions in all archive_nodes (mainly for debugging). */ void archive::forget(void) { - vector::iterator i = nodes.begin(), iend = nodes.end(); + std::vector::iterator i = nodes.begin(), iend = nodes.end(); while (i != iend) { i->forget(); i++; @@ -516,12 +516,12 @@ void archive_node::forget(void) /** Print archive to stream in ugly raw format (for debugging). */ -void archive::printraw(ostream &os) const +void archive::printraw(std::ostream &os) const { // Dump atoms os << "Atoms:\n"; { - vector::const_iterator i = atoms.begin(), iend = atoms.end(); + std::vector::const_iterator i = atoms.begin(), iend = atoms.end(); archive_atom id = 0; while (i != iend) { os << " " << id << " " << *i << endl; @@ -533,7 +533,7 @@ void archive::printraw(ostream &os) const // Dump expressions os << "Expressions:\n"; { - vector::const_iterator i = exprs.begin(), iend = exprs.end(); + std::vector::const_iterator i = exprs.begin(), iend = exprs.end(); unsigned int index = 0; while (i != iend) { os << " " << index << " \"" << unatomize(i->name) << "\" root node " << i->root << endl; @@ -545,7 +545,7 @@ void archive::printraw(ostream &os) const // Dump nodes os << "Nodes:\n"; { - vector::const_iterator i = nodes.begin(), iend = nodes.end(); + std::vector::const_iterator i = nodes.begin(), iend = nodes.end(); archive_node_id id = 0; while (i != iend) { os << " " << id << " "; @@ -556,7 +556,7 @@ void archive::printraw(ostream &os) const } /** Output archive_node to stream in ugly raw format (for debugging). */ -void archive_node::printraw(ostream &os) const +void archive_node::printraw(std::ostream &os) const { // Dump cached unarchived expression if (has_expression) @@ -565,7 +565,7 @@ void archive_node::printraw(ostream &os) const os << "\n"; // Dump properties - vector::const_iterator i = props.begin(), iend = props.end(); + std::vector::const_iterator i = props.begin(), iend = props.end(); while (i != iend) { os << " "; switch (i->type) { diff --git a/ginac/archive.h b/ginac/archive.h index 396820b3..082a3268 100644 --- a/ginac/archive.h +++ b/ginac/archive.h @@ -28,8 +28,10 @@ #include #include -class ostream; -class istream; +namespace std { + class ostream; + class istream; +} #ifndef NO_NAMESPACE_GINAC namespace GiNaC { @@ -51,8 +53,8 @@ typedef unsigned int archive_atom; * addressed by its name and data type. */ class archive_node { - friend ostream &operator<<(ostream &os, const archive_node &ar); - friend istream &operator>>(istream &is, archive_node &ar); + friend std::ostream &operator<<(std::ostream &os, const archive_node &ar); + friend std::istream &operator>>(std::istream &is, archive_node &ar); public: archive_node() : a(*dummy_ar_creator()), has_expression(false) {} // hack for cint which always requires a default constructor @@ -65,20 +67,20 @@ public: bool has_same_ex_as(const archive_node &other) const; - void add_bool(const string &name, bool value); - void add_unsigned(const string &name, unsigned int value); - void add_string(const string &name, const string &value); - void add_ex(const string &name, const ex &value); + void add_bool(const std::string &name, bool value); + void add_unsigned(const std::string &name, unsigned int value); + void add_string(const std::string &name, const std::string &value); + void add_ex(const std::string &name, const ex &value); - bool find_bool(const string &name, bool &ret) const; - bool find_unsigned(const string &name, unsigned int &ret) const; - bool find_string(const string &name, string &ret) const; - bool find_ex(const string &name, ex &ret, const lst &sym_lst, unsigned int index = 0) const; + bool find_bool(const std::string &name, bool &ret) const; + bool find_unsigned(const std::string &name, unsigned int &ret) const; + bool find_string(const std::string &name, std::string &ret) const; + bool find_ex(const std::string &name, ex &ret, const lst &sym_lst, unsigned int index = 0) const; ex unarchive(const lst &sym_lst) const; void forget(void); - void printraw(ostream &os) const; + void printraw(std::ostream &os) const; private: static archive* dummy_ar_creator(void); @@ -109,7 +111,7 @@ private: archive &a; /** Vector of stored properties. */ - vector props; + std::vector props; /** Flag indicating whether a cached unarchived representation of this node exists. */ mutable bool has_expression; @@ -128,8 +130,8 @@ private: * of class basic (or a derived class). */ class archive { - friend ostream &operator<<(ostream &os, const archive &ar); - friend istream &operator>>(istream &is, archive &ar); + friend std::ostream &operator<<(std::ostream &os, const archive &ar); + friend std::istream &operator>>(std::istream &is, archive &ar); public: archive() {} @@ -147,17 +149,17 @@ public: void archive_ex(const ex &e, const char *name); ex unarchive_ex(const lst &sym_lst, const char *name) const; ex unarchive_ex(const lst &sym_lst, unsigned int index = 0) const; - ex unarchive_ex(const lst &sym_lst, string &name, unsigned int index = 0) const; + ex unarchive_ex(const lst &sym_lst, std::string &name, unsigned int index = 0) const; unsigned int num_expressions(void) const; void clear(void); void forget(void); - void printraw(ostream &os) const; + void printraw(std::ostream &os) const; private: /** Vector of archived nodes. */ - vector nodes; + std::vector nodes; /** Archived expression descriptor. */ struct archived_ex { @@ -169,20 +171,20 @@ private: }; /** Vector of archived expression descriptors. */ - vector exprs; + std::vector exprs; public: - archive_atom atomize(const string &s) const; - const string &unatomize(archive_atom id) const; + archive_atom atomize(const std::string &s) const; + const std::string &unatomize(archive_atom id) const; private: /** Vector of atomized strings (using a vector allows faster unarchiving). */ - mutable vector atoms; + mutable std::vector atoms; }; -ostream &operator<<(ostream &os, const archive &ar); -istream &operator>>(istream &is, archive &ar); +std::ostream &operator<<(std::ostream &os, const archive &ar); +std::istream &operator>>(std::istream &is, archive &ar); #ifndef NO_NAMESPACE_GINAC diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 83b777bb..5e3ff581 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -104,7 +104,7 @@ basic::basic(const archive_node &n, const lst &sym_lst) : flags(0), refcount(0) debugmsg("basic constructor from archive_node", LOGLEVEL_CONSTRUCT); // Reconstruct tinfo_key from class name - string class_name; + std::string class_name; if (n.find_string("class", class_name)) tinfo_key = find_tinfo_key(class_name); else @@ -136,7 +136,7 @@ void basic::archive(archive_node &n) const // public /** Output to stream formatted to be useful as ginsh input. */ -void basic::print(ostream & os, unsigned upper_precedence) const +void basic::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("basic print",LOGLEVEL_PRINT); os << "[basic object]"; @@ -144,7 +144,7 @@ void basic::print(ostream & os, unsigned upper_precedence) const /** Output to stream in ugly raw format, so brave developers can have a look * at the underlying structure. */ -void basic::printraw(ostream & os) const +void basic::printraw(std::ostream & os) const { debugmsg("basic printraw",LOGLEVEL_PRINT); os << "[basic object]"; @@ -152,13 +152,14 @@ void basic::printraw(ostream & os) const /** Output to stream formatted in tree- (indented-) form, so developers can * have a look at the underlying structure. */ -void basic::printtree(ostream & os, unsigned indent) const +void basic::printtree(std::ostream & os, unsigned indent) const { debugmsg("basic printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "type=" << typeid(*this).name() - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" + os << std::string(indent,' ') << "type=" << typeid(*this).name() + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" << ", flags=" << flags - << ", nops=" << nops() << endl; + << ", nops=" << nops() << std::endl; for (unsigned i=0; iderivative(s); while (!ndiff.is_zero() && // stop differentiating zeros nth>1) { ndiff = ndiff.diff(s); diff --git a/ginac/basic.h b/ginac/basic.h index ed049eaf..2263081c 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -27,7 +27,7 @@ #include #include -// CINT needs to work properly with +// CINT needs to work properly with #include #include "flags.h" @@ -47,8 +47,8 @@ class numeric; class relational; class archive_node; -//typedef vector exvector; -typedef vector exvector; // CINT does not like vector<...,default_alloc> +// typedef std::vector exvector; +typedef std::vector exvector; // CINT does not like vector<...,default_alloc> #define INLINE_BASIC_CONSTRUCTORS @@ -119,10 +119,10 @@ protected: // new virtual functions which can be overridden by derived classes public: // only const functions please (may break reference counting) virtual basic * duplicate() const; - virtual void print(ostream & os,unsigned upper_precedence=0) const; - virtual void printraw(ostream & os) const; - virtual void printtree(ostream & os, unsigned indent) const; - virtual void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + virtual void print(std::ostream & os,unsigned upper_precedence = 0) const; + virtual void printraw(std::ostream & os) const; + virtual void printtree(std::ostream & os, unsigned indent) const; + virtual void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence = 0) const; virtual void dbgprint(void) const; virtual void dbgprinttree(void) const; virtual bool info(unsigned inf) const; @@ -134,13 +134,13 @@ public: // only const functions please (may break reference counting) virtual bool has(const ex & other) const; virtual int degree(const symbol & s) const; virtual int ldegree(const symbol & s) const; - virtual ex coeff(const symbol & s, int n=1) const; + virtual ex coeff(const symbol & s, int n = 1) const; virtual ex collect(const symbol & s) const; - virtual ex eval(int level=0) const; - virtual ex evalf(int level=0) const; - virtual ex series(const relational & r, int order) const; + virtual ex eval(int level = 0) const; + virtual ex evalf(int level = 0) const; + virtual ex series(const relational & r, int order, bool branchcut = true) const; virtual ex subs(const lst & ls, const lst & lr) const; - virtual ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; + virtual ex normal(lst &sym_lst, lst &repl_lst, int level = 0) const; virtual ex to_rational(lst &repl_lst) const; virtual numeric integer_content(void) const; virtual ex smod(const numeric &xi) const; diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index 65d3584c..2bf3fbb7 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -91,7 +91,7 @@ void clifford::destroy(bool call_parent) // public -clifford::clifford(const string & initname) +clifford::clifford(const std::string & initname) { debugmsg("clifford constructor from string",LOGLEVEL_CONSTRUCT); name=initname; @@ -111,7 +111,7 @@ basic * clifford::duplicate() const return new clifford(*this); } -void clifford::printraw(ostream & os) const +void clifford::printraw(std::ostream & os) const { debugmsg("clifford printraw",LOGLEVEL_PRINT); os << "clifford(" << "name=" << name << ",serial=" << serial @@ -120,25 +120,26 @@ void clifford::printraw(ostream & os) const os << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void clifford::printtree(ostream & os, unsigned indent) const +void clifford::printtree(std::ostream & os, unsigned indent) const { debugmsg("clifford printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << name << " (clifford): " + os << std::string(indent,' ') << name << " (clifford): " << "serial=" << serial << "," << seq.size() << "indices="; - printtreeindices(os,indent); - os << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + printtreeindices(os, indent); + os << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void clifford::print(ostream & os, unsigned upper_precedence) const +void clifford::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("clifford print",LOGLEVEL_PRINT); os << name; printindices(os); } -void clifford::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void clifford::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("clifford print csrc",LOGLEVEL_PRINT); print(os,upper_precedence); @@ -185,16 +186,16 @@ unsigned clifford::calchash(void) const // non-virtual functions in this class ////////// -void clifford::setname(const string & n) +void clifford::setname(const std::string & n) { - name=n; + name = n; } // private -string & clifford::autoname_prefix(void) +std::string & clifford::autoname_prefix(void) { - static string * s=new string("clifford"); + static std::string * s = new std::string("clifford"); return *s; } diff --git a/ginac/clifford.h b/ginac/clifford.h index 44757c3e..18d8f0a7 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -48,15 +48,15 @@ protected: // other constructors public: - explicit clifford(const string & initname); + explicit clifford(const std::string & initname); // functions overriding virtual functions from base classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; bool info(unsigned inf) const; protected: int compare_same_type(const basic & other) const; @@ -68,14 +68,14 @@ protected: // non-virtual functions in this class public: - void setname(const string & n); + void setname(const std::string & n); private: - string & autoname_prefix(void); + std::string & autoname_prefix(void); // member variables protected: - string name; + std::string name; unsigned serial; // unique serial number for comparision private: static unsigned next_serial; diff --git a/ginac/color.cpp b/ginac/color.cpp index c35e03e5..b0cbabf5 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -194,7 +194,7 @@ basic * color::duplicate() const return new color(*this); } -void color::printraw(ostream & os) const +void color::printraw(std::ostream & os) const { debugmsg("color printraw",LOGLEVEL_PRINT); os << "color(type=" << (unsigned)type @@ -204,20 +204,20 @@ void color::printraw(ostream & os) const os << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void color::printtree(ostream & os, unsigned indent) const +void color::printtree(std::ostream & os, unsigned indent) const { debugmsg("color printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "color object: " + os << std::string(indent,' ') << "color object: " << "type=" << (unsigned)type << ",representation_label=" << representation_label << ", "; - os << seq.size() << " indices" << endl; + os << seq.size() << " indices" << std::endl; printtreeindices(os,indent); - os << string(indent,' ') << "hash=" << hashvalue - << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + os << std::string(indent,' ') << "hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void color::print(ostream & os, unsigned upper_precedence) const +void color::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("color print",LOGLEVEL_PRINT); switch (type) { @@ -247,7 +247,7 @@ void color::print(ostream & os, unsigned upper_precedence) const printindices(os); } -void color::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void color::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("color print csrc",LOGLEVEL_PRINT); print(os,upper_precedence); @@ -962,17 +962,17 @@ ex brute_force_sum_color_indices(const ex & e) } } - vector counter; + std::vector counter; counter.resize(iv_double.size()); int l; for (l=0; unsigned(l)=0)&&((++counter[l])>(int)COLOR_EIGHT)) { counter[l]=1; l--; } - if (l<2) { cout << counter[0] << counter[1] << endl; } + if (l<2) { std::cout << counter[0] << counter[1] << std::endl; } if (l<0) break; } diff --git a/ginac/color.h b/ginac/color.h index 6e852575..4899fda2 100644 --- a/ginac/color.h +++ b/ginac/color.h @@ -36,7 +36,8 @@ const unsigned MAX_REPRESENTATION_LABELS = 4; const unsigned COLOR_EIGHT = 8; // N*N-1 const unsigned COLOR_THREE = 3; // N -typedef vector exvectorvector; +// typedef std::vector exvectorvector; +typedef std::vector exvectorvector; // CINT does not like vector<...,default_alloc> /** Base class for color object */ class color : public indexed @@ -102,10 +103,10 @@ protected: // functions overriding virtual functions from base classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; bool info(unsigned inf) const; ex eval(int level=0) const; protected: diff --git a/ginac/coloridx.cpp b/ginac/coloridx.cpp index 3e871fbe..aec4c671 100644 --- a/ginac/coloridx.cpp +++ b/ginac/coloridx.cpp @@ -95,7 +95,7 @@ coloridx::coloridx(bool cov) : idx(cov) tinfo_key=TINFO_coloridx; } -coloridx::coloridx(const string & n, bool cov) : idx(n,cov) +coloridx::coloridx(const std::string & n, bool cov) : idx(n,cov) { debugmsg("coloridx constructor from string,bool",LOGLEVEL_CONSTRUCT); tinfo_key=TINFO_coloridx; @@ -147,7 +147,7 @@ basic * coloridx::duplicate() const return new coloridx(*this); } -void coloridx::printraw(ostream & os) const +void coloridx::printraw(std::ostream & os) const { debugmsg("coloridx printraw",LOGLEVEL_PRINT); @@ -170,11 +170,11 @@ void coloridx::printraw(ostream & os) const os << ")"; } -void coloridx::printtree(ostream & os, unsigned indent) const +void coloridx::printtree(std::ostream & os, unsigned indent) const { debugmsg("coloridx printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "coloridx: "; + os << std::string(indent,' ') << "coloridx: "; if (symbolic) { os << "symbolic,name=" << name; @@ -189,11 +189,12 @@ void coloridx::printtree(ostream & os, unsigned indent) const } os << ", serial=" << serial - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void coloridx::print(ostream & os, unsigned upper_precedence) const +void coloridx::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("coloridx print",LOGLEVEL_PRINT); diff --git a/ginac/coloridx.h b/ginac/coloridx.h index a8f368bb..5031e323 100644 --- a/ginac/coloridx.h +++ b/ginac/coloridx.h @@ -53,16 +53,16 @@ protected: // other constructors public: explicit coloridx(bool cov); - explicit coloridx(const string & n, bool cov=false); + explicit coloridx(const std::string & n, bool cov=false); explicit coloridx(const char * n, bool cov=false); explicit coloridx(unsigned v, bool cov=false); // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; bool info(unsigned inf) const; // new virtual functions which can be overridden by derived classes diff --git a/ginac/constant.cpp b/ginac/constant.cpp index 56d096da..826f5153 100644 --- a/ginac/constant.cpp +++ b/ginac/constant.cpp @@ -89,7 +89,7 @@ void constant::destroy(bool call_parent) // public -constant::constant(const string & initname, evalffunctype efun) : +constant::constant(const std::string & initname, evalffunctype efun) : basic(TINFO_constant), name(initname), ef(efun), // number(0), fct_assigned(true), serial(next_serial++) number(0), serial(next_serial++) @@ -97,7 +97,7 @@ constant::constant(const string & initname, evalffunctype efun) : debugmsg("constant constructor from string, function",LOGLEVEL_CONSTRUCT); } -constant::constant(const string & initname, const numeric & initnumber) : +constant::constant(const std::string & initname, const numeric & initnumber) : basic(TINFO_constant), name(initname), ef(0), number(new numeric(initnumber)), /* fct_assigned(false),*/ serial(next_serial++) { @@ -119,7 +119,7 @@ ex constant::unarchive(const archive_node &n, const lst &sym_lst) { // Find constant by name (!! this is bad: 'twould be better if there // was a list of all global constants that we could search) - string s; + std::string s; if (n.find_string("name", s)) { if (s == Pi.name) return Pi; @@ -152,28 +152,29 @@ basic * constant::duplicate() const return new constant(*this); } -void constant::print(ostream & os, unsigned upper_precedence) const +void constant::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("constant print",LOGLEVEL_PRINT); os << name; } -void constant::printraw(ostream & os) const +void constant::printraw(std::ostream & os) const { debugmsg("constant printraw",LOGLEVEL_PRINT); os << "constant(" << name << ")"; } -void constant::printtree(ostream & os, unsigned indent) const +void constant::printtree(std::ostream & os, unsigned indent) const { debugmsg("constant printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << name + os << std::string(indent,' ') << name << ", type=" << typeid(*this).name() - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void constant::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void constant::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("constant print csrc",LOGLEVEL_PRINT); os << name; diff --git a/ginac/constant.h b/ginac/constant.h index 4d456bd3..d099378f 100644 --- a/ginac/constant.h +++ b/ginac/constant.h @@ -54,16 +54,16 @@ protected: // other constructors public: - constant(const string & initname, evalffunctype efun=0); - constant(const string & initname, const numeric & initnumber); + constant(const std::string & initname, evalffunctype efun=0); + constant(const std::string & initname, const numeric & initnumber); // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; ex evalf(int level=0) const; protected: ex derivative(const symbol & s) const; @@ -79,7 +79,7 @@ protected: // member variables private: - string name; + std::string name; evalffunctype ef; numeric * number; // bool fct_assigned; diff --git a/ginac/container.pl b/ginac/container.pl index 86fda5b4..9dac1847 100755 --- a/ginac/container.pl +++ b/ginac/container.pl @@ -187,8 +187,8 @@ $interface=< ${STLT}; -typedef ${STLHEADER} ${STLT}; // CINT does not like ${STLHEADER}<...,default_alloc> +// typedef std::${STLHEADER} ${STLT}; +typedef std::${STLHEADER} ${STLT}; // CINT does not like ${STLHEADER}<...,default_alloc> class ${CONTAINER} : public basic { @@ -210,9 +210,9 @@ ${constructors_interface} public: basic * duplicate() const; - void printraw(ostream & os) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printtree(ostream & os, unsigned indent) const; + void printraw(std::ostream & os) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printtree(std::ostream & os, unsigned indent) const; bool info(unsigned inf) const; unsigned nops() const; ex & let_op(int i); @@ -233,7 +233,7 @@ public: virtual ${CONTAINER} & append(const ex & b); ${PREPEND_INTERFACE} protected: - virtual void printseq(ostream & os, char openbracket, char delim, + virtual void printseq(std::ostream & os, char openbracket, char delim, char closebracket, unsigned this_precedence, unsigned upper_precedence=0) const; virtual ex this${CONTAINER}(${STLT} const & v) const; @@ -446,7 +446,7 @@ basic * ${CONTAINER}::duplicate() const return new ${CONTAINER}(*this); } -void ${CONTAINER}::printraw(ostream & os) const +void ${CONTAINER}::printraw(std::ostream & os) const { debugmsg("${CONTAINER} printraw",LOGLEVEL_PRINT); @@ -458,25 +458,26 @@ void ${CONTAINER}::printraw(ostream & os) const os << ")"; } -void ${CONTAINER}::print(ostream & os, unsigned upper_precedence) const +void ${CONTAINER}::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("${CONTAINER} print",LOGLEVEL_PRINT); // always print brackets around seq, ignore upper_precedence printseq(os,'${open_bracket}',',','${close_bracket}',precedence,precedence+1); } -void ${CONTAINER}::printtree(ostream & os, unsigned indent) const +void ${CONTAINER}::printtree(std::ostream & os, unsigned indent) const { debugmsg("${CONTAINER} printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "type=" << typeid(*this).name() - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" + os << std::string(indent,' ') << "type=" << typeid(*this).name() + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" << ", flags=" << flags - << ", nops=" << nops() << endl; + << ", nops=" << nops() << std::endl; for (${STLT}::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { (*cit).printtree(os,indent+delta_indent); } - os << string(indent+delta_indent,' ') << "=====" << endl; + os << std::string(indent+delta_indent,' ') << "=====" << std::endl; } // ${CONTAINER}::info() will be implemented by user elsewhere"; @@ -609,7 +610,7 @@ ${PREPEND_IMPLEMENTATION} // protected -void ${CONTAINER}::printseq(ostream & os, char openbracket, char delim, +void ${CONTAINER}::printseq(std::ostream & os, char openbracket, char delim, char closebracket, unsigned this_precedence, unsigned upper_precedence) const { @@ -657,7 +658,7 @@ bool ${CONTAINER}::is_canonical() const for (++it; it!=seq.end(); it_last=it, ++it) { if ((*it_last).compare(*it)>0) { if ((*it_last).compare(*it)>0) { - cout << *it_last << ">" << *it << "\\n"; + std::cout << *it_last << ">" << *it << "\\n"; return 0; } } diff --git a/ginac/debugmsg.h b/ginac/debugmsg.h index 8f9aafaf..bd888add 100644 --- a/ginac/debugmsg.h +++ b/ginac/debugmsg.h @@ -44,7 +44,7 @@ // #define LOGMASK (LOGLEVEL_PRINT | LOGLEVEL_ASSIGNMENT | LOGLEVEL_OPERATOR | LOGLEVEL_DUPLICATE | LOGLEVEL_OPERATOR | LOGLEVEL_MEMBER_FUNCTION | LOGLEVEL_NONMEMBER_FUNCTION) #ifdef VERBOSE -#define debugmsg(msg, loglevel) if ((loglevel) & ~LOGMASK) clog << (msg) << endl; +#define debugmsg(msg, loglevel) if ((loglevel) & ~LOGMASK) std::clog << (msg) << endl; #else #define debugmsg(msg, loglevel) #endif // def VERBOSE diff --git a/ginac/ex.cpp b/ginac/ex.cpp index 474b9fd3..2857cdc8 100644 --- a/ginac/ex.cpp +++ b/ginac/ex.cpp @@ -135,7 +135,7 @@ ex::ex(double const d) construct_from_double(d); } -ex::ex(const string &s, const ex &l) +ex::ex(const std::string &s, const ex &l) { debugmsg("ex constructor from string,lst",LOGLEVEL_CONSTRUCT); construct_from_string_and_lst(s, l); @@ -177,14 +177,14 @@ void ex::swap(ex & other) } /** Output formatted to be useful as ginsh input. */ -void ex::print(ostream & os, unsigned upper_precedence) const +void ex::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("ex print",LOGLEVEL_PRINT); GINAC_ASSERT(bp!=0); bp->print(os,upper_precedence); } -void ex::printraw(ostream & os) const +void ex::printraw(std::ostream & os) const { debugmsg("ex printraw",LOGLEVEL_PRINT); GINAC_ASSERT(bp!=0); @@ -193,7 +193,7 @@ void ex::printraw(ostream & os) const os << ")"; } -void ex::printtree(ostream & os, unsigned indent) const +void ex::printtree(std::ostream & os, unsigned indent) const { debugmsg("ex printtree",LOGLEVEL_PRINT); GINAC_ASSERT(bp!=0); @@ -208,7 +208,7 @@ void ex::printtree(ostream & os, unsigned indent) const * @param os output stream * @param type variable type (one of the csrc_types) * @param var_name variable name to be printed */ -void ex::printcsrc(ostream & os, unsigned type, const char *var_name) const +void ex::printcsrc(std::ostream & os, unsigned type, const char *var_name) const { debugmsg("ex print csrc", LOGLEVEL_PRINT); GINAC_ASSERT(bp!=0); @@ -410,10 +410,10 @@ bool ex::is_equal(const ex & other) const { GINAC_ASSERT(bp!=0); GINAC_ASSERT(other.bp!=0); - if (bp==other.bp) { - // special case: both expression point to same basic, trivially equal - return true; - } + // if both expression point to same basic they are trivially equal + if (bp==other.bp) + return true; + return bp->is_equal(*other.bp); } #endif // ndef INLINE_EX_CONSTRUCTORS @@ -634,7 +634,7 @@ void ex::construct_from_double(double d) GINAC_ASSERT(bp->refcount=1); } -void ex::construct_from_string_and_lst(const string &s, const ex &l) +void ex::construct_from_string_and_lst(const std::string &s, const ex &l) { set_lexer_string(s); set_lexer_symbols(l); diff --git a/ginac/ex.h b/ginac/ex.h index c7e1da8c..05f31573 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -200,7 +200,7 @@ public: * similar to the GiNaC output format. All symbols to be used in the * expression must be specified in a lst in the second argument. Undefined * symbols and other parser errors will throw an exception. */ - ex(const string &s, const ex &l) + ex(const std::string &s, const ex &l) #ifdef INLINE_EX_CONSTRUCTORS { construct_from_string_and_lst(s, l); @@ -222,10 +222,10 @@ public: // non-virtual functions in this class public: void swap(ex & other); - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent=0) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printcsrc(ostream & os, unsigned type, const char *var_name) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent=0) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printcsrc(std::ostream & os, unsigned type, const char *var_name) const; void dbgprint(void) const; void dbgprinttree(void) const; bool info(unsigned inf) const; @@ -252,7 +252,7 @@ public: ex eval(int level = 0) const; ex evalf(int level = 0) const; ex diff(const symbol & s, unsigned nth = 1) const; - ex series(const ex & r, int order) const; + ex series(const ex & r, int order, bool branchcut = true) const; ex subs(const lst & ls, const lst & lr) const; ex subs(const ex & e) const; exvector get_indices(void) const; @@ -307,7 +307,7 @@ private: void construct_from_long(long i); void construct_from_ulong(unsigned long i); void construct_from_double(double d); - void construct_from_string_and_lst(const string &s, const ex &l); + void construct_from_string_and_lst(const std::string &s, const ex &l); void makewriteable(); #ifdef OBSCURE_CINT_HACK @@ -395,8 +395,8 @@ inline ex evalf(const ex & thisex, int level = 0) inline ex diff(const ex & thisex, const symbol & s, unsigned nth = 1) { return thisex.diff(s, nth); } -inline ex series(const ex & thisex, const ex & r, int order) -{ return thisex.series(r, order); } +inline ex series(const ex & thisex, const ex & r, int order, bool branchcut = true) +{ return thisex.series(r, order, branchcut); } inline ex subs(const ex & thisex, const ex & e) { return thisex.subs(e); } diff --git a/ginac/expair.h b/ginac/expair.h index 68f062be..448e635b 100644 --- a/ginac/expair.h +++ b/ginac/expair.h @@ -168,7 +168,7 @@ public: return cmpval; } - void printraw(ostream & os) const + void printraw(std::ostream & os) const { os << "expair("; rest.printraw(os); diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index bdfc2ff7..4be6cdd6 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -209,7 +209,7 @@ basic * expairseq::duplicate() const return new expairseq(*this); } -void expairseq::print(ostream & os, unsigned upper_precedence) const +void expairseq::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("expairseq print",LOGLEVEL_PRINT); os << "[["; @@ -217,7 +217,7 @@ void expairseq::print(ostream & os, unsigned upper_precedence) const os << "]]"; } -void expairseq::printraw(ostream & os) const +void expairseq::printraw(std::ostream & os) const { debugmsg("expairseq printraw",LOGLEVEL_PRINT); @@ -232,30 +232,31 @@ void expairseq::printraw(ostream & os) const os << ")"; } -void expairseq::printtree(ostream & os, unsigned indent) const +void expairseq::printtree(std::ostream & os, unsigned indent) const { debugmsg("expairseq printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "type=" << typeid(*this).name() - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" + os << std::string(indent,' ') << "type=" << typeid(*this).name() + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" << ", flags=" << flags - << ", nops=" << nops() << endl; + << ", nops=" << nops() << std::endl; for (unsigned i=0; i0) { - os << string(indent+delta_indent,' ') + os << std::string(indent+delta_indent,' ') << "bin " << i << " with entries "; for (epplist::const_iterator it=hashtab[i].begin(); it!=hashtab[i].end(); ++it) { os << *it-seq.begin() << " "; this_bin_fill++; } - os << endl; + os << std::endl; cum_fill += this_bin_fill; cum_fill_sq += this_bin_fill*this_bin_fill; } @@ -290,20 +291,20 @@ void expairseq::printtree(ostream & os, unsigned indent) const if (k>0) fact *= k; double prob = pow(lambda,k)/fact*exp(-lambda); cum_prob += prob; - os << string(indent+delta_indent,' ') << "bins with " << k << " entries: " + os << std::string(indent+delta_indent,' ') << "bins with " << k << " entries: " << int(1000.0*count[k]/hashtabsize)/10.0 << "% (expected: " - << int(prob*1000)/10.0 << ")" << endl; + << int(prob*1000)/10.0 << ")" << std::endl; } - os << string(indent+delta_indent,' ') << "bins with more entries: " + os << std::string(indent+delta_indent,' ') << "bins with more entries: " << int(1000.0*count[MAXCOUNT]/hashtabsize)/10.0 << "% (expected: " - << int((1-cum_prob)*1000)/10.0 << ")" << endl; + << int((1-cum_prob)*1000)/10.0 << ")" << std::endl; - os << string(indent+delta_indent,' ') << "variance: " + os << std::string(indent+delta_indent,' ') << "variance: " << 1.0/hashtabsize*cum_fill_sq-(1.0/hashtabsize*cum_fill)*(1.0/hashtabsize*cum_fill) - << endl; - os << string(indent+delta_indent,' ') << "average fill: " + << std::endl; + os << std::string(indent+delta_indent,' ') << "average fill: " << (1.0*cum_fill)/hashtabsize - << " (should be equal to " << (1.0*seq.size())/hashtabsize << ")" << endl; + << " (should be equal to " << (1.0*seq.size())/hashtabsize << ")" << std::endl; #endif // def EXPAIRSEQ_USE_HASHTAB } @@ -461,9 +462,9 @@ bool expairseq::is_equal_same_type(const basic & other) const #ifdef EXPAIRSEQ_USE_HASHTAB // compare number of elements in each hashtab entry if (hashtabsize!=o.hashtabsize) { - cout << "this:" << endl; + cout << "this:" << std::endl; printtree(cout,0); - cout << "other:" << endl; + cout << "other:" << std::endl; other.printtree(cout,0); } @@ -562,7 +563,7 @@ ex expairseq::thisexpairseq(epvector * vp, const ex & oc) const return expairseq(vp,oc); } -void expairseq::printpair(ostream & os, const expair & p, unsigned upper_precedence) const +void expairseq::printpair(std::ostream & os, const expair & p, unsigned upper_precedence) const { os << "[["; p.rest.bp->print(os,precedence); @@ -571,7 +572,8 @@ void expairseq::printpair(ostream & os, const expair & p, unsigned upper_precede os << "]]"; } -void expairseq::printseq(ostream & os, char delim, unsigned this_precedence, +void expairseq::printseq(std::ostream & os, char delim, + unsigned this_precedence, unsigned upper_precedence) const { if (this_precedence<=upper_precedence) os << "("; @@ -904,8 +906,6 @@ void expairseq::construct_from_epvector(const epvector & v) #endif // def EXPAIRSEQ_USE_HASHTAB } -#include - void expairseq::make_flat(const exvector & v) { exvector::const_iterator cit, citend = v.end(); @@ -948,11 +948,11 @@ void expairseq::make_flat(const exvector & v) } /* - cout << "after make flat" << endl; + cout << "after make flat" << std::endl; for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { (*cit).printraw(cout); } - cout << endl; + cout << std::endl; */ } @@ -1110,11 +1110,11 @@ void expairseq::canonicalize(void) */ /* - cout << "after canonicalize" << endl; + cout << "after canonicalize" << std::endl; for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { (*cit).printraw(cout); } - cout << endl; + cout << std::endl; cout.flush(); */ } @@ -1163,11 +1163,11 @@ void expairseq::combine_same_terms_sorted_seq(void) } /* - cout << "after combine" << endl; + cout << "after combine" << std::endl; for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { (*cit).printraw(cout); } - cout << endl; + cout << std::endl; cout.flush(); */ @@ -1258,8 +1258,8 @@ void expairseq::remove_hashtab_entry(epvector::const_iterator element) } if (!erased) { printtree(cout,0); - cout << "tried to erase " << element-seq.begin() << endl; - cout << "size " << seq.end()-seq.begin() << endl; + cout << "tried to erase " << element-seq.begin() << std::endl; + cout << "size " << seq.end()-seq.begin() << std::endl; unsigned hashindex=calc_hashindex((*element).rest); epplist & eppl=hashtab[hashindex]; @@ -1463,15 +1463,15 @@ void expairseq::combine_same_terms(void) GINAC_ASSERT(!has_coeff_0()); build_hashtab_and_combine(first_numeric,last_non_zero,touched,number_of_zeroes); /* - cout << "in combine:" << endl; + cout << "in combine:" << std::endl; printtree(cout,0); - cout << "size=" << seq.end() - seq.begin() << endl; - cout << "first_numeric=" << first_numeric - seq.begin() << endl; - cout << "last_non_zero=" << last_non_zero - seq.begin() << endl; + cout << "size=" << seq.end() - seq.begin() << std::endl; + cout << "first_numeric=" << first_numeric - seq.begin() << std::endl; + cout << "last_non_zero=" << last_non_zero - seq.begin() << std::endl; for (unsigned i=0; i"; printpair(cout,*it,0); cout << "\n"; - cout << "pair1:" << endl; + cout << "pair1:" << std::endl; (*it_last).rest.printtree(cout); (*it_last).coeff.printtree(cout); - cout << "pair2:" << endl; + cout << "pair2:" << std::endl; (*it).rest.printtree(cout); (*it).coeff.printtree(cout); return 0; diff --git a/ginac/expairseq.h b/ginac/expairseq.h index 6284ce28..7f467dc2 100644 --- a/ginac/expairseq.h +++ b/ginac/expairseq.h @@ -27,7 +27,7 @@ #include // CINT needs to work properly with and -//#include +#include #include "expair.h" @@ -37,7 +37,7 @@ namespace GiNaC { //#define EXPAIRSEQ_USE_HASHTAB -typedef vector epvector; +typedef std::vector epvector; typedef epvector::iterator epviter; inline void iter_swap(epvector::iterator it1, epvector::iterator it2) @@ -47,8 +47,8 @@ inline void iter_swap(epvector::iterator it1, epvector::iterator it2) } typedef epvector::iterator epp; -typedef list epplist; -typedef vector epplistvector; +typedef std::list epplist; +typedef std::vector epplistvector; /** A sequence of class expair. * This is used for time-critical classes like sums and products of terms @@ -92,9 +92,9 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; bool info(unsigned inf) const; unsigned nops() const; ex op(int i) const; @@ -116,9 +116,10 @@ protected: protected: virtual ex thisexpairseq(const epvector & v, const ex & oc) const; virtual ex thisexpairseq(epvector * vp, const ex & oc) const; - virtual void printseq(ostream & os, char delim, unsigned this_precedence, + virtual void printseq(std::ostream & os, char delim, + unsigned this_precedence, unsigned upper_precedence) const; - virtual void printpair(ostream & os, const expair & p, + virtual void printpair(std::ostream & os, const expair & p, unsigned upper_precedence) const; virtual expair split_ex_to_pair(const ex & e) const; virtual expair combine_ex_with_coeff_to_pair(const ex & e, diff --git a/ginac/fail.cpp b/ginac/fail.cpp index d35c2f43..c41ea41d 100644 --- a/ginac/fail.cpp +++ b/ginac/fail.cpp @@ -117,13 +117,13 @@ basic * fail::duplicate() const return new fail(*this); } -void fail::print(ostream & os, unsigned upper_precedence) const +void fail::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("fail print",LOGLEVEL_PRINT); os << "FAIL"; } -void fail::printraw(ostream & os) const +void fail::printraw(std::ostream & os) const { debugmsg("fail printraw",LOGLEVEL_PRINT); os << "FAIL"; diff --git a/ginac/fail.h b/ginac/fail.h index 9d87d1bc..41c546d8 100644 --- a/ginac/fail.h +++ b/ginac/fail.h @@ -50,8 +50,8 @@ protected: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printraw(ostream & os) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; protected: int compare_same_type(const basic & other) const; unsigned return_type(void) const { return return_types::noncommutative_composite; }; diff --git a/ginac/function.pl b/ginac/function.pl index 36b7c7b7..a69f58fe 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -95,7 +95,7 @@ $typedef_derivative_funcp=generate( 'const ex &',''); $typedef_series_funcp=generate( -'typedef ex (* series_funcp_${N})(${SEQ1}, const relational &, int);'."\n", +'typedef ex (* series_funcp_${N})(${SEQ1}, const relational &, int, bool);'."\n", 'const ex &',''); $eval_func_interface=generate(' function_options & eval_func(eval_funcp_${N} e);'."\n",'',''); @@ -145,9 +145,9 @@ $series_switch_statement=generate( <<'END_OF_SERIES_SWITCH_STATEMENT','seq[${N}-1]',''); case ${N}: try { - res = ((series_funcp_${N})(registered_functions()[serial].series_f))(${SEQ1},r,order); + res = ((series_funcp_${N})(registered_functions()[serial].series_f))(${SEQ1},r,order,branchcut); } catch (do_taylor) { - res = basic::series(r, order); + res = basic::series(r, order, branchcut); } return res; break; @@ -226,10 +226,8 @@ $interface=< #include -#ifdef __CINT__ // CINT needs to work properly with #include -#endif // def __CINT__ #include "exprseq.h" @@ -330,10 +328,10 @@ class function_options friend class function; public: function_options(); - function_options(string const & n, string const & tn=string()); + function_options(std::string const & n, std::string const & tn=std::string()); ~function_options(); void initialize(void); - function_options & set_name(string const & n, string const & tn=string()); + function_options & set_name(std::string const & n, std::string const & tn=std::string()); // the following lines have been generated for max. ${maxargs} parameters $eval_func_interface $evalf_func_interface @@ -346,12 +344,12 @@ $series_func_interface unsigned strategy=remember_strategies::delete_never); function_options & overloaded(unsigned o); void test_and_set_nparams(unsigned n); - string get_name(void) const { return name; } + std::string get_name(void) const { return name; } unsigned get_nparams(void) const { return nparams; } protected: - string name; - string TeX_name; + std::string name; + std::string TeX_name; unsigned nparams; @@ -414,14 +412,14 @@ $constructors_interface // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printtree(ostream & os, unsigned indent) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printtree(std::ostream & os, unsigned indent) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; ex expand(unsigned options=0) const; ex eval(int level=0) const; ex evalf(int level=0) const; - ex series(const relational & r, int order) const; + ex series(const relational & r, int order, bool branchcut = true) const; ex thisexprseq(const exvector & v) const; ex thisexprseq(exvector * vp) const; protected: @@ -437,12 +435,12 @@ protected: // non-virtual functions in this class protected: ex pderivative(unsigned diff_param) const; // partial differentiation - static vector & registered_functions(void); + static std::vector & registered_functions(void); bool lookup_remember_table(ex & result) const; void store_remember_table(ex const & result) const; public: static unsigned register_new(function_options const & opt); - static unsigned find_function(const string &name, unsigned nparams); + static unsigned find_function(const std::string &name, unsigned nparams); unsigned getserial(void) const {return serial;} // member variables @@ -535,7 +533,7 @@ function_options::function_options() initialize(); } -function_options::function_options(string const & n, string const & tn) +function_options::function_options(std::string const & n, std::string const & tn) { initialize(); set_name(n,tn); @@ -557,11 +555,11 @@ void function_options::initialize(void) functions_with_same_name=1; } -function_options & function_options::set_name(string const & n, - string const & tn) +function_options & function_options::set_name(std::string const & n, + std::string const & tn) { name=n; - if (tn==string()) { + if (tn==std::string()) { TeX_name="\\\\operatorname{"+name+"}"; } else { TeX_name=tn; @@ -615,9 +613,9 @@ void function_options::test_and_set_nparams(unsigned n) // we do not throw an exception here because this code is // usually executed before main(), so the exception could not // caught anyhow - cerr << "WARNING: number of parameters (" - << n << ") differs from number set before (" - << nparams << ")" << endl; + std::cerr << "WARNING: number of parameters (" + << n << ") differs from number set before (" + << nparams << ")" << std::endl; } } @@ -716,10 +714,10 @@ function::function(const archive_node &n, const lst &sym_lst) : inherited(n, sym debugmsg("function constructor from archive_node", LOGLEVEL_CONSTRUCT); // Find serial number by function name - string s; + std::string s; if (n.find_string("name", s)) { unsigned int ser = 0; - vector::const_iterator i = registered_functions().begin(), iend = registered_functions().end(); + std::vector::const_iterator i = registered_functions().begin(), iend = registered_functions().end(); while (i != iend) { if (s == i->name) { serial = ser; @@ -758,7 +756,7 @@ basic * function::duplicate() const return new function(*this); } -void function::printraw(ostream & os) const +void function::printraw(std::ostream & os) const { debugmsg("function printraw",LOGLEVEL_PRINT); @@ -772,7 +770,7 @@ void function::printraw(ostream & os) const os << ")"; } -void function::print(ostream & os, unsigned upper_precedence) const +void function::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("function print",LOGLEVEL_PRINT); @@ -782,31 +780,32 @@ void function::print(ostream & os, unsigned upper_precedence) const printseq(os,'(',',',')',exprseq::precedence,function::precedence); } -void function::printtree(ostream & os, unsigned indent) const +void function::printtree(std::ostream & os, unsigned indent) const { debugmsg("function printtree",LOGLEVEL_PRINT); GINAC_ASSERT(serial & function::registered_functions(void) +std::vector & function::registered_functions(void) { - static vector * rf=new vector; + static std::vector * rf = new std::vector; return *rf; } @@ -1044,8 +1043,8 @@ unsigned function::register_new(function_options const & opt) // we do not throw an exception here because this code is // usually executed before main(), so the exception could not // caught anyhow - cerr << "WARNING: function name " << opt.name - << " already in use!" << endl; + std::cerr << "WARNING: function name " << opt.name + << " already in use!" << std::endl; } registered_functions().push_back(opt); if (opt.use_remember) { @@ -1061,9 +1060,9 @@ unsigned function::register_new(function_options const & opt) /** Find serial number of function by name and number of parameters. * Throws exception if function was not found. */ -unsigned function::find_function(const string &name, unsigned nparams) +unsigned function::find_function(const std::string &name, unsigned nparams) { - vector::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end(); + std::vector::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end(); unsigned serial = 0; while (i != end) { if (i->get_name() == name && i->get_nparams() == nparams) diff --git a/ginac/idx.cpp b/ginac/idx.cpp index e0b5ad05..ff493c6e 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -97,29 +97,29 @@ void idx::destroy(bool call_parent) idx::idx(bool cov) : inherited(TINFO_idx), symbolic(true), covariant(cov) { debugmsg("idx constructor from bool",LOGLEVEL_CONSTRUCT); - serial=next_serial++; - name="index"+ToString(serial); + serial = next_serial++; + name = "index"+ToString(serial); } -idx::idx(const string & n, bool cov) : inherited(TINFO_idx), +idx::idx(const std::string & n, bool cov) : inherited(TINFO_idx), symbolic(true), name(n), covariant(cov) { debugmsg("idx constructor from string,bool",LOGLEVEL_CONSTRUCT); - serial=next_serial++; + serial = next_serial++; } idx::idx(const char * n, bool cov) : inherited(TINFO_idx), symbolic(true), name(n), covariant(cov) { debugmsg("idx constructor from char*,bool",LOGLEVEL_CONSTRUCT); - serial=next_serial++; + serial = next_serial++; } idx::idx(unsigned v, bool cov) : inherited(TINFO_idx), symbolic(false), value(v), covariant(cov) { debugmsg("idx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT); - serial=0; + serial = 0; } ////////// @@ -181,7 +181,7 @@ basic * idx::duplicate() const return new idx(*this); } -void idx::printraw(ostream & os) const +void idx::printraw(std::ostream & os) const { debugmsg("idx printraw",LOGLEVEL_PRINT); @@ -204,11 +204,11 @@ void idx::printraw(ostream & os) const os << ")"; } -void idx::printtree(ostream & os, unsigned indent) const +void idx::printtree(std::ostream & os, unsigned indent) const { debugmsg("idx printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "idx: "; + os << std::string(indent,' ') << "idx: "; if (symbolic) { os << "symbolic,name=" << name; @@ -223,11 +223,12 @@ void idx::printtree(ostream & os, unsigned indent) const } os << ", serial=" << serial - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void idx::print(ostream & os, unsigned upper_precedence) const +void idx::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("idx print",LOGLEVEL_PRINT); diff --git a/ginac/idx.h b/ginac/idx.h index 334b58ca..f332f574 100644 --- a/ginac/idx.h +++ b/ginac/idx.h @@ -51,16 +51,16 @@ protected: // other constructors public: explicit idx(bool cov); - explicit idx(const string & n, bool cov=false); + explicit idx(const std::string & n, bool cov=false); explicit idx(const char * n, bool cov=false); explicit idx(unsigned v, bool cov=false); // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; bool info(unsigned inf) const; protected: int compare_same_type(const basic & other) const; @@ -78,14 +78,14 @@ public: bool is_symbolic(void) const; unsigned get_value(void) const; bool is_covariant(void) const; - void setname(const string & n) {name=n;} - string getname(void) const {return name;} + void setname(const std::string & n) {name=n;} + std::string getname(void) const {return name;} // member variables protected: unsigned serial; bool symbolic; - string name; + std::string name; unsigned value; static unsigned next_serial; bool covariant; // x_mu, default is contravariant: x^mu @@ -104,8 +104,6 @@ inline const idx &ex_to_idx(const ex &e) // global functions -// typedef vector exvector; - int canonicalize_indices(exvector & iv, bool antisymmetric=false); exvector idx_intersect(const exvector & iv1, const exvector & iv2); ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2, diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index 0f6726e5..fb35d8c1 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -166,7 +166,7 @@ basic * indexed::duplicate() const return new indexed(*this); } -void indexed::printraw(ostream & os) const +void indexed::printraw(std::ostream & os) const { debugmsg("indexed printraw",LOGLEVEL_PRINT); os << "indexed(indices="; @@ -174,22 +174,22 @@ void indexed::printraw(ostream & os) const os << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void indexed::printtree(ostream & os, unsigned indent) const +void indexed::printtree(std::ostream & os, unsigned indent) const { debugmsg("indexed printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "indexed: " << seq.size() << " indices"; - os << ",hash=" << hashvalue << ",flags=" << flags << endl; + os << std::string(indent,' ') << "indexed: " << seq.size() << " indices"; + os << ",hash=" << hashvalue << ",flags=" << flags << std::endl; printtreeindices(os,indent); } -void indexed::print(ostream & os, unsigned upper_precedence) const +void indexed::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("indexed print",LOGLEVEL_PRINT); os << "UNNAMEDINDEX"; printindices(os); } -void indexed::printcsrc(ostream & os, unsigned type, +void indexed::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("indexed print csrc",LOGLEVEL_PRINT); @@ -272,7 +272,7 @@ ex indexed::thisexprseq(exvector * vp) const // protected -void indexed::printrawindices(ostream & os) const +void indexed::printrawindices(std::ostream & os) const { if (seq.size()!=0) { for (exvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { @@ -282,18 +282,18 @@ void indexed::printrawindices(ostream & os) const } } -void indexed::printtreeindices(ostream & os, unsigned indent) const +void indexed::printtreeindices(std::ostream & os, unsigned indent) const { if (seq.size()!=0) { for (exvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { - os << string(indent+delta_indent,' '); + os << std::string(indent+delta_indent,' '); (*cit).printraw(os); - os << endl; + os << std::endl; } } } -void indexed::printindices(ostream & os) const +void indexed::printindices(std::ostream & os) const { if (seq.size()!=0) { if (seq.size()>1) { diff --git a/ginac/indexed.h b/ginac/indexed.h index 919fc18e..aa0042b4 100644 --- a/ginac/indexed.h +++ b/ginac/indexed.h @@ -59,10 +59,10 @@ public: // functions overriding virtual functions from base classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const; bool info(unsigned inf) const; exvector get_indices(void) const; protected: @@ -79,9 +79,9 @@ protected: // non-virtual functions in this class protected: - void printrawindices(ostream & os) const; - void printtreeindices(ostream & os, unsigned indent) const; - void printindices(ostream & os) const; + void printrawindices(std::ostream & os) const; + void printtreeindices(std::ostream & os, unsigned indent) const; + void printindices(std::ostream & os) const; bool all_of_type_idx(void) const; // member variables diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index 5802325f..14e53b5e 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -107,18 +107,21 @@ static ex csgn_eval(const ex & x) return csgn(x).hold(); } -static ex csgn_series(const ex & x, const relational & rel, int order) +static ex csgn_series(const ex & arg, + const relational & rel, + int order, + bool branchcut) { - const ex x_pt = x.subs(rel); - if (x_pt.info(info_flags::numeric)) { - if (ex_to_numeric(x_pt).real().is_zero()) + const ex arg_pt = arg.subs(rel); + if (arg_pt.info(info_flags::numeric)) { + if (ex_to_numeric(arg_pt).real().is_zero()) throw (std::domain_error("csgn_series(): on imaginary axis")); epvector seq; - seq.push_back(expair(csgn(x_pt), _ex0())); + seq.push_back(expair(csgn(arg_pt), _ex0())); return pseries(rel,seq); } epvector seq; - seq.push_back(expair(csgn(x_pt), _ex0())); + seq.push_back(expair(csgn(arg_pt), _ex0())); return pseries(rel,seq); } @@ -130,26 +133,41 @@ REGISTER_FUNCTION(csgn, eval_func(csgn_eval). // dilogarithm ////////// +static ex Li2_evalf(const ex & x) +{ + BEGIN_TYPECHECK + TYPECHECK(x,numeric) + END_TYPECHECK(Li2(x)) + + return Li2(ex_to_numeric(x)); // -> numeric Li2(numeric) +} + static ex Li2_eval(const ex & x) { - // Li2(0) -> 0 - if (x.is_zero()) - return x; - // Li2(1) -> Pi^2/6 - if (x.is_equal(_ex1())) - return power(Pi,_ex2())/_ex6(); - // Li2(1/2) -> Pi^2/12 - log(2)^2/2 - if (x.is_equal(_ex1_2())) - return power(Pi,_ex2())/_ex12() + power(log(_ex2()),_ex2())*_ex_1_2(); - // Li2(-1) -> -Pi^2/12 - if (x.is_equal(_ex_1())) - return -power(Pi,_ex2())/_ex12(); - // Li2(I) -> -Pi^2/48+Catalan*I - if (x.is_equal(I)) - return power(Pi,_ex2())/_ex_48() + Catalan*I; - // Li2(-I) -> -Pi^2/48-Catalan*I - if (x.is_equal(-I)) - return power(Pi,_ex2())/_ex_48() - Catalan*I; + if (x.info(info_flags::numeric)) { + // Li2(0) -> 0 + if (x.is_zero()) + return _ex0(); + // Li2(1) -> Pi^2/6 + if (x.is_equal(_ex1())) + return power(Pi,_ex2())/_ex6(); + // Li2(1/2) -> Pi^2/12 - log(2)^2/2 + if (x.is_equal(_ex1_2())) + return power(Pi,_ex2())/_ex12() + power(log(_ex2()),_ex2())*_ex_1_2(); + // Li2(-1) -> -Pi^2/12 + if (x.is_equal(_ex_1())) + return -power(Pi,_ex2())/_ex12(); + // Li2(I) -> -Pi^2/48+Catalan*I + if (x.is_equal(I)) + return power(Pi,_ex2())/_ex_48() + Catalan*I; + // Li2(-I) -> -Pi^2/48-Catalan*I + if (x.is_equal(-I)) + return power(Pi,_ex2())/_ex_48() - Catalan*I; + // Li2(float) + if (!x.info(info_flags::crational)) + return Li2_evalf(x); + } + return Li2(x).hold(); } @@ -161,49 +179,89 @@ static ex Li2_deriv(const ex & x, unsigned deriv_param) return -log(1-x)/x; } -static ex Li2_series(const ex &x, const relational &rel, int order) +static ex Li2_series(const ex &x, const relational &rel, int order, bool branchcut) { const ex x_pt = x.subs(rel); - if (!x_pt.is_zero() && !x_pt.is_equal(_ex1())) - throw do_taylor(); // caught by function::series() - // First case: x==0 (derivatives have poles) - if (x_pt.is_zero()) { - // method: - // The problem is that in d/dx Li2(x==0) == -log(1-x)/x we cannot - // simply substitute x==0. The limit, however, exists: it is 1. We - // also know all higher derivatives' limits: (d/dx)^n Li2(x) == n!/n^2. - // So the primitive series expansion is Li2(x==0) == x + x^2/4 + x^3/9 - // and so on. - // We first construct such a primitive series expansion manually in - // a dummy symbol s and then insert the argument's series expansion - // for s. Reexpanding the resulting series returns the desired result. - const symbol s; - ex ser; - // construct manually the primitive expansion - for (int i=1; i=1 (branch cut) + if (ex_to_numeric(x_pt).is_real() && ex_to_numeric(x_pt)>1) { + // method: + // This is the branch cut: assemble the primitive series manually + // and then add the corresponding complex step function. + const symbol *s = static_cast(rel.lhs().bp); + const ex point = rel.rhs(); + const symbol foo; + epvector seq; + // zeroth order term: + seq.push_back(expair(Li2(x_pt), _ex0())); + // compute the intermediate terms: + ex replarg = series(Li2(x), *s==foo, order); + for (unsigned i=1; i=1 (branch cut) - return pseries(); - // TODO: Li2_series should do something around branch point? - // Careful: may involve logs! + // all other cases should be safe, by now: + throw do_taylor(); // caught by function::series() } REGISTER_FUNCTION(Li2, eval_func(Li2_eval). + evalf_func(Li2_evalf). derivative_func(Li2_deriv). series_func(Li2_series)); @@ -283,13 +341,13 @@ static ex Order_eval(const ex & x) return Order(x).hold(); } -static ex Order_series(const ex & x, const relational & r, int order) +static ex Order_series(const ex & x, const relational & r, int order, bool branchcut) { // Just wrap the function into a pseries object epvector new_seq; GINAC_ASSERT(is_ex_exactly_of_type(r.lhs(),symbol)); const symbol *s = static_cast(r.lhs().bp); - new_seq.push_back(expair(Order(_ex1()), numeric(min(x.ldegree(*s), order)))); + new_seq.push_back(expair(Order(_ex1()), numeric(std::min(x.ldegree(*s), order)))); return pseries(r, new_seq); } @@ -323,9 +381,8 @@ ex lsolve(const ex &eqns, const ex &symbols) { // solve a system of linear equations if (eqns.info(info_flags::relation_equal)) { - if (!symbols.info(info_flags::symbol)) { + if (!symbols.info(info_flags::symbol)) throw(std::invalid_argument("lsolve: 2nd argument must be a symbol")); - } ex sol=lsolve(lst(eqns),lst(symbols)); GINAC_ASSERT(sol.nops()==1); diff --git a/ginac/inifcns_gamma.cpp b/ginac/inifcns_gamma.cpp index 213d9d7f..26b5bd78 100644 --- a/ginac/inifcns_gamma.cpp +++ b/ginac/inifcns_gamma.cpp @@ -56,7 +56,7 @@ static ex lgamma_evalf(const ex & x) * Knows about integer arguments and that's it. Somebody ought to provide * some good numerical evaluation some day... * - * @exception std::domain_error("lgamma_eval(): logarithmic pole") */ + * @exception GiNaC::pole_error("lgamma_eval(): logarithmic pole",0) */ static ex lgamma_eval(const ex & x) { if (x.info(info_flags::numeric)) { @@ -66,7 +66,7 @@ static ex lgamma_eval(const ex & x) if (x.info(info_flags::posint)) { return log(factorial(x.exadd(_ex_1()))); } else { - throw (std::domain_error("lgamma_eval(): logarithmic pole")); + throw (pole_error("lgamma_eval(): logarithmic pole",0)); } } // lgamma_evalf should be called here once it becomes available @@ -85,7 +85,10 @@ static ex lgamma_deriv(const ex & x, unsigned deriv_param) } -static ex lgamma_series(const ex & x, const relational & rel, int order) +static ex lgamma_series(const ex & arg, + const relational & rel, + int order, + bool branchcut) { // method: // Taylor series where there is no pole falls back to psi function @@ -98,11 +101,11 @@ static ex lgamma_series(const ex & x, const relational & rel, int order) // This, however, seems to fail utterly because you run into branch-cut // problems. Somebody ought to implement it some day using an asymptotic // series for tgamma: - const ex x_pt = x.subs(rel); - if (!x_pt.info(info_flags::integer) || x_pt.info(info_flags::positive)) + const ex arg_pt = arg.subs(rel); + if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole of tgamma(-m): - throw (std::domain_error("lgamma_series: please implemnt my at the poles")); + throw (std::overflow_error("lgamma_series: please implement my at the poles")); return _ex0(); // not reached } @@ -131,7 +134,7 @@ static ex tgamma_evalf(const ex & x) * arguments, half-integer arguments and that's it. Somebody ought to provide * some good numerical evaluation some day... * - * @exception std::domain_error("tgamma_eval(): simple pole") */ + * @exception pole_error("tgamma_eval(): simple pole",0) */ static ex tgamma_eval(const ex & x) { if (x.info(info_flags::numeric)) { @@ -141,7 +144,7 @@ static ex tgamma_eval(const ex & x) if (x.info(info_flags::posint)) { return factorial(ex_to_numeric(x).sub(_num1())); } else { - throw (std::domain_error("tgamma_eval(): simple pole")); + throw (pole_error("tgamma_eval(): simple pole",1)); } } // trap half integer arguments: @@ -178,7 +181,10 @@ static ex tgamma_deriv(const ex & x, unsigned deriv_param) } -static ex tgamma_series(const ex & x, const relational & rel, int order) +static ex tgamma_series(const ex & arg, + const relational & rel, + int order, + bool branchcut) { // method: // Taylor series where there is no pole falls back to psi function @@ -188,15 +194,15 @@ static ex tgamma_series(const ex & x, const relational & rel, int order) // from which follows // series(tgamma(x),x==-m,order) == // series(tgamma(x+m+1)/(x*(x+1)*...*(x+m)),x==-m,order+1); - const ex x_pt = x.subs(rel); - if (!x_pt.info(info_flags::integer) || x_pt.info(info_flags::positive)) + const ex arg_pt = arg.subs(rel); + if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole at -m: - numeric m = -ex_to_numeric(x_pt); + numeric m = -ex_to_numeric(arg_pt); ex ser_denom = _ex1(); for (numeric p; p<=m; ++p) - ser_denom *= x+p; - return (tgamma(x+m+_ex1())/ser_denom).series(rel, order+1); + ser_denom *= arg+p; + return (tgamma(arg+m+_ex1())/ser_denom).series(rel, order+1); } @@ -235,13 +241,13 @@ static ex beta_eval(const ex & x, const ex & y) if (nx<=-ny) return pow(_num_1(), ny)*beta(1-x-y, y); else - throw (std::domain_error("beta_eval(): simple pole")); + throw (pole_error("beta_eval(): simple pole",1)); } if (ny.is_negative()) { if (ny<=-nx) return pow(_num_1(), nx)*beta(1-y-x, x); else - throw (std::domain_error("beta_eval(): simple pole")); + throw (pole_error("beta_eval(): simple pole",1)); } return tgamma(x)*tgamma(y)/tgamma(x+y); } @@ -273,37 +279,41 @@ static ex beta_deriv(const ex & x, const ex & y, unsigned deriv_param) } -static ex beta_series(const ex & x, const ex & y, const relational & rel, int order) +static ex beta_series(const ex & arg1, + const ex & arg2, + const relational & rel, + int order, + bool branchcut) { // method: // Taylor series where there is no pole of one of the tgamma functions // falls back to beta function evaluation. Otherwise, fall back to // tgamma series directly. - const ex x_pt = x.subs(rel); - const ex y_pt = y.subs(rel); + const ex arg1_pt = arg1.subs(rel); + const ex arg2_pt = arg2.subs(rel); GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol)); const symbol *s = static_cast(rel.lhs().bp); - ex x_ser, y_ser, xy_ser; - if ((!x_pt.info(info_flags::integer) || x_pt.info(info_flags::positive)) && - (!y_pt.info(info_flags::integer) || y_pt.info(info_flags::positive))) + ex arg1_ser, arg2_ser, arg1arg2_ser; + if ((!arg1_pt.info(info_flags::integer) || arg1_pt.info(info_flags::positive)) && + (!arg2_pt.info(info_flags::integer) || arg2_pt.info(info_flags::positive))) throw do_taylor(); // caught by function::series() - // trap the case where x is on a pole directly: - if (x.info(info_flags::integer) && !x.info(info_flags::positive)) - x_ser = tgamma(x+*s).series(rel,order); + // trap the case where arg1 is on a pole: + if (arg1.info(info_flags::integer) && !arg1.info(info_flags::positive)) + arg1_ser = tgamma(arg1+*s).series(rel,order); else - x_ser = tgamma(x).series(rel,order); - // trap the case where y is on a pole directly: - if (y.info(info_flags::integer) && !y.info(info_flags::positive)) - y_ser = tgamma(y+*s).series(rel,order); + arg1_ser = tgamma(arg1).series(rel,order); + // trap the case where arg2 is on a pole: + if (arg2.info(info_flags::integer) && !arg2.info(info_flags::positive)) + arg2_ser = tgamma(arg2+*s).series(rel,order); else - y_ser = tgamma(y).series(rel,order); - // trap the case where y is on a pole directly: - if ((x+y).info(info_flags::integer) && !(x+y).info(info_flags::positive)) - xy_ser = tgamma(y+x+*s).series(rel,order); + arg2_ser = tgamma(arg2).series(rel,order); + // trap the case where arg1+arg2 is on a pole: + if ((arg1+arg2).info(info_flags::integer) && !(arg1+arg2).info(info_flags::positive)) + arg1arg2_ser = tgamma(arg2+arg1+*s).series(rel,order); else - xy_ser = tgamma(y+x).series(rel,order); - // compose the result: - return (x_ser*y_ser/xy_ser).series(rel,order); + arg1arg2_ser = tgamma(arg2+arg1).series(rel,order); + // compose the result (expanding all the terms): + return (arg1_ser*arg2_ser/arg1arg2_ser).series(rel,order).expand(); } @@ -342,7 +352,7 @@ static ex psi1_eval(const ex & x) return rat-Euler; } else { // for non-positive integers there is a pole: - throw (std::domain_error("psi_eval(): simple pole")); + throw (pole_error("psi_eval(): simple pole",1)); } } if ((_num2()*nx).is_integer()) { @@ -379,7 +389,10 @@ static ex psi1_deriv(const ex & x, unsigned deriv_param) return psi(_ex1(), x); } -static ex psi1_series(const ex & x, const relational & rel, int order) +static ex psi1_series(const ex & arg, + const relational & rel, + int order, + bool branchcut) { // method: // Taylor series where there is no pole falls back to polygamma function @@ -389,15 +402,15 @@ static ex psi1_series(const ex & x, const relational & rel, int order) // from which follows // series(psi(x),x==-m,order) == // series(psi(x+m+1) - 1/x - 1/(x+1) - 1/(x+m)),x==-m,order); - const ex x_pt = x.subs(rel); - if (!x_pt.info(info_flags::integer) || x_pt.info(info_flags::positive)) + const ex arg_pt = arg.subs(rel); + if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a simple pole at -m: - numeric m = -ex_to_numeric(x_pt); + numeric m = -ex_to_numeric(arg_pt); ex recur; for (numeric p; p<=m; ++p) - recur += power(x+p,_ex_1()); - return (psi(x+m+_ex1())-recur).series(rel, order); + recur += power(arg+p,_ex_1()); + return (psi(arg+m+_ex1())-recur).series(rel, order); } const unsigned function_index_psi1 = @@ -454,7 +467,7 @@ static ex psi2_eval(const ex & n, const ex & x) return recur+psi(n,_ex1()); } else { // for non-positive integers there is a pole: - throw (std::domain_error("psi2_eval(): pole")); + throw (pole_error("psi2_eval(): pole",1)); } } if ((_num2()*nx).is_integer()) { @@ -499,7 +512,11 @@ static ex psi2_deriv(const ex & n, const ex & x, unsigned deriv_param) return psi(n+_ex1(), x); } -static ex psi2_series(const ex & n, const ex & x, const relational & rel, int order) +static ex psi2_series(const ex & n, + const ex & arg, + const relational & rel, + int order, + bool branchcut) { // method: // Taylor series where there is no pole falls back to polygamma function @@ -510,16 +527,16 @@ static ex psi2_series(const ex & n, const ex & x, const relational & rel, int or // series(psi(x),x==-m,order) == // series(psi(x+m+1) - (-1)^n * n! * ((x)^(-n-1) + (x+1)^(-n-1) + ... // ... + (x+m)^(-n-1))),x==-m,order); - const ex x_pt = x.subs(rel); - if (!x_pt.info(info_flags::integer) || x_pt.info(info_flags::positive)) + const ex arg_pt = arg.subs(rel); + if (!arg_pt.info(info_flags::integer) || arg_pt.info(info_flags::positive)) throw do_taylor(); // caught by function::series() // if we got here we have to care for a pole of order n+1 at -m: - numeric m = -ex_to_numeric(x_pt); + numeric m = -ex_to_numeric(arg_pt); ex recur; for (numeric p; p<=m; ++p) - recur += power(x+p,-n+_ex_1()); + recur += power(arg+p,-n+_ex_1()); recur *= factorial(n)*power(_ex_1(),n); - return (psi(n, x+m+_ex1())-recur).series(rel, order); + return (psi(n, arg+m+_ex1())-recur).series(rel, order); } const unsigned function_index_psi2 = diff --git a/ginac/inifcns_trans.cpp b/ginac/inifcns_trans.cpp index 81f92a93..75c92b76 100644 --- a/ginac/inifcns_trans.cpp +++ b/ginac/inifcns_trans.cpp @@ -110,7 +110,7 @@ static ex log_eval(const ex & x) { if (x.info(info_flags::numeric)) { if (x.is_equal(_ex0())) // log(0) -> infinity - throw(std::domain_error("log_eval(): log(0)")); + throw(pole_error("log_eval(): log(0)",0)); if (x.info(info_flags::real) && x.info(info_flags::negative)) return (log(-x)+I*Pi); if (x.is_equal(_ex1())) // log(1) -> 0 @@ -144,26 +144,60 @@ static ex log_deriv(const ex & x, unsigned deriv_param) return power(x, _ex_1()); } -static ex log_series(const ex &x, const relational &rel, int order) +static ex log_series(const ex &arg, + const relational &rel, + int order, + bool branchcut) { - const ex x_pt = x.subs(rel); - if (!x_pt.info(info_flags::negative) && !x_pt.is_zero()) - throw do_taylor(); // caught by function::series() - // now we either have to care for the branch cut or the branch point: - if (x_pt.is_zero()) { // branch point: return a plain log(x). + GINAC_ASSERT(is_ex_exactly_of_type(rel.lhs(),symbol)); + ex arg_pt; + bool must_expand_arg = false; + // maybe substitution of rel into arg fails because of a pole + try { + arg_pt = arg.subs(rel); + } catch (pole_error) { + must_expand_arg = true; + } + // or we are at the branch cut anyways + if (arg_pt.is_zero()) + must_expand_arg = true; + + if (must_expand_arg) { + // method: + // This is the branch point: Series expand the argument first, then + // trivially factorize it to isolate that part which has constant + // leading coefficient in this fashion: + // x^n + Order(x^(n+m)) -> x^n * (1 + Order(x^m)). + // Return a plain n*log(x) for the x^n part and series expand the + // other part. Add them together and reexpand again in order to have + // one unnested pseries object. All this also works for negative n. + const pseries argser = ex_to_pseries(arg.series(rel, order, branchcut)); + const symbol *s = static_cast(rel.lhs().bp); + const ex point = rel.rhs(); + const int n = argser.ldegree(*s); epvector seq; - seq.push_back(expair(log(x), _ex0())); - return pseries(rel, seq); - } // on the branch cut: - const ex point = rel.rhs(); - const symbol *s = static_cast(rel.lhs().bp); - const symbol foo; - // compute the formal series: - ex replx = series(log(x),*s==foo,order).subs(foo==point); - epvector seq; - seq.push_back(expair(-I*csgn(x*I)*Pi,_ex0())); - seq.push_back(expair(Order(_ex1()),order)); - return series(replx - I*Pi + pseries(rel, seq),rel,order); + seq.push_back(expair(n*log(*s-point), _ex0())); + if (!argser.is_terminating() || argser.nops()!=1) { + // in this case n more terms are needed + ex newarg = ex_to_pseries(arg.series(rel, order+n, branchcut)).shift_exponents(-n).convert_to_poly(true); + return pseries(rel, seq).add_series(ex_to_pseries(log(newarg).series(rel, order, branchcut))); + } else // it was a monomial + return pseries(rel, seq); + } + if (branchcut && arg_pt.info(info_flags::negative)) { + // method: + // This is the branch cut: assemble the primitive series manually and + // then add the corresponding complex step function. + const symbol *s = static_cast(rel.lhs().bp); + const ex point = rel.rhs(); + const symbol foo; + ex replarg = series(log(arg), *s==foo, order, false).subs(foo==point); + 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); + } + throw do_taylor(); // caught by function::series() } REGISTER_FUNCTION(log, eval_func(log_eval). @@ -375,7 +409,7 @@ static ex tan_eval(const ex & x) if (z.is_equal(_num25())) // tan(5/12*Pi) -> 2+sqrt(3) return sign*(power(_ex3(),_ex1_2())+_ex2()); if (z.is_equal(_num30())) // tan(Pi/2) -> infinity - throw (std::domain_error("tan_eval(): simple pole")); + throw (pole_error("tan_eval(): simple pole",1)); } if (is_ex_exactly_of_type(x, function)) { @@ -407,7 +441,10 @@ static ex tan_deriv(const ex & x, unsigned deriv_param) return (_ex1()+power(tan(x),_ex2())); } -static ex tan_series(const ex &x, const relational &rel, int order) +static ex tan_series(const ex &x, + const relational &rel, + int order, + bool branchcut) { // method: // Taylor series where there is no pole falls back to tan_deriv. @@ -764,7 +801,10 @@ static ex tanh_deriv(const ex & x, unsigned deriv_param) return _ex1()-power(tanh(x),_ex2()); } -static ex tanh_series(const ex &x, const relational &rel, int order) +static ex tanh_series(const ex &x, + const relational &rel, + int order, + bool branchcut) { // method: // Taylor series where there is no pole falls back to tanh_deriv. @@ -886,7 +926,7 @@ static ex atanh_eval(const ex & x) return _ex0(); // atanh({+|-}1) -> throw if (x.is_equal(_ex1()) || x.is_equal(_ex_1())) - throw (std::domain_error("atanh_eval(): logarithmic pole")); + throw (pole_error("atanh_eval(): logarithmic pole",0)); // atanh(float) -> float if (!x.info(info_flags::crational)) return atanh_evalf(x); diff --git a/ginac/input_lexer.h b/ginac/input_lexer.h index 0ba72d1a..a7c8c06f 100644 --- a/ginac/input_lexer.h +++ b/ginac/input_lexer.h @@ -65,7 +65,7 @@ extern int ginac_yyparse(); extern ex parsed_ex; /** Get error message from the parser. */ -extern string get_parser_error(void); +extern std::string get_parser_error(void); #ifndef NO_NAMESPACE_GINAC } // namespace GiNaC diff --git a/ginac/input_lexer.ll b/ginac/input_lexer.ll index 5a3bfbdb..9795803e 100644 --- a/ginac/input_lexer.ll +++ b/ginac/input_lexer.ll @@ -69,7 +69,7 @@ struct sym_def { ex sym; bool predefined; // true = user supplied symbol, false = lexer generated symbol }; -typedef map sym_tab; +typedef std::map sym_tab; static sym_tab syms; // lex input function @@ -140,7 +140,7 @@ Digits ginac_yylval = (long)Digits; return T_DIGITS; */ // The string from which we will read -static string lexer_string; +static std::string lexer_string; // The current position within the string static int curr_pos = 0; @@ -169,7 +169,7 @@ namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC // Set the input string -void set_lexer_string(const string &s) +void set_lexer_string(const std::string &s) { lexer_string = s; curr_pos = 0; diff --git a/ginac/isospin.cpp b/ginac/isospin.cpp index 8ff6b916..1afa969f 100644 --- a/ginac/isospin.cpp +++ b/ginac/isospin.cpp @@ -95,7 +95,7 @@ void isospin::destroy(bool call_parent) // public -isospin::isospin(const string & initname) +isospin::isospin(const std::string & initname) { debugmsg("isospin constructor from string",LOGLEVEL_CONSTRUCT); name=initname; @@ -149,7 +149,7 @@ basic * isospin::duplicate() const return new isospin(*this); } -void isospin::printraw(ostream & os) const +void isospin::printraw(std::ostream & os) const { debugmsg("isospin printraw",LOGLEVEL_PRINT); os << "isospin(" << "name=" << name << ",serial=" << serial @@ -158,25 +158,26 @@ void isospin::printraw(ostream & os) const os << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void isospin::printtree(ostream & os, unsigned indent) const +void isospin::printtree(std::ostream & os, unsigned indent) const { debugmsg("isospin printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << name << " (isospin): " + os << std::string(indent,' ') << name << " (isospin): " << "serial=" << serial << "," << seq.size() << "indices="; printtreeindices(os,indent); - os << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + os << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void isospin::print(ostream & os, unsigned upper_precedence) const +void isospin::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("isospin print",LOGLEVEL_PRINT); os << name; printindices(os); } -void isospin::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void isospin::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("isospin print csrc",LOGLEVEL_PRINT); print(os,upper_precedence); @@ -223,16 +224,16 @@ unsigned isospin::calchash(void) const // non-virtual functions in this class ////////// -void isospin::setname(const string & n) +void isospin::setname(const std::string & n) { - name=n; + name = n; } // private -string & isospin::autoname_prefix(void) +std::string & isospin::autoname_prefix(void) { - static string * s=new string("isospin"); + static std::string * s = new std::string("isospin"); return *s; } diff --git a/ginac/isospin.h b/ginac/isospin.h index 0cc29bc7..8103fc1a 100644 --- a/ginac/isospin.h +++ b/ginac/isospin.h @@ -49,15 +49,15 @@ protected: // other constructors public: - explicit isospin(const string & initname); + explicit isospin(const std::string & initname); // functions overriding virtual functions from base classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; bool info(unsigned inf) const; protected: int compare_same_type(const basic & other) const; @@ -69,14 +69,14 @@ protected: // non-virtual functions in this class public: - void setname(const string & n); + void setname(const std::string & n); private: - string & autoname_prefix(void); + std::string & autoname_prefix(void); // member variables protected: - string name; + std::string name; unsigned serial; // unique serial number for comparision private: static unsigned next_serial; diff --git a/ginac/lorentzidx.cpp b/ginac/lorentzidx.cpp index 5835050e..9a0aa7bd 100644 --- a/ginac/lorentzidx.cpp +++ b/ginac/lorentzidx.cpp @@ -103,7 +103,7 @@ lorentzidx::lorentzidx(bool cov, bool oonly, unsigned dimp) : tinfo_key=TINFO_lorentzidx; } -lorentzidx::lorentzidx(const string & n, bool cov, bool oonly, unsigned dimp) +lorentzidx::lorentzidx(const std::string & n, bool cov, bool oonly, unsigned dimp) : idx(n,cov), orthogonal_only(oonly), dim_parallel_space(dimp) { debugmsg("lorentzidx constructor from string,bool,bool,unsigned", @@ -175,7 +175,7 @@ basic * lorentzidx::duplicate() const return new lorentzidx(*this); } -void lorentzidx::printraw(ostream & os) const +void lorentzidx::printraw(std::ostream & os) const { debugmsg("lorentzidx printraw",LOGLEVEL_PRINT); @@ -205,11 +205,11 @@ void lorentzidx::printraw(ostream & os) const os << ")"; } -void lorentzidx::printtree(ostream & os, unsigned indent) const +void lorentzidx::printtree(std::ostream & os, unsigned indent) const { debugmsg("lorentzidx printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "lorentzidx: "; + os << std::string(indent,' ') << "lorentzidx: "; if (symbolic) { os << "symbolic,name=" << name; @@ -231,11 +231,12 @@ void lorentzidx::printtree(ostream & os, unsigned indent) const } os << ", serial=" << serial - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void lorentzidx::print(ostream & os, unsigned upper_precedence) const +void lorentzidx::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("lorentzidx print",LOGLEVEL_PRINT); diff --git a/ginac/lorentzidx.h b/ginac/lorentzidx.h index 6cd5fc2a..8ff27764 100644 --- a/ginac/lorentzidx.h +++ b/ginac/lorentzidx.h @@ -53,7 +53,7 @@ protected: // other constructors public: explicit lorentzidx(bool cov, bool oonly=false, unsigned dimp=0); - explicit lorentzidx(const string & n, bool cov=false, + explicit lorentzidx(const std::string & n, bool cov=false, bool oonly=false, unsigned dimp=0); explicit lorentzidx(const char * n, bool cov=false, bool oonly=false, unsigned dimp=0); @@ -62,9 +62,9 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; bool info(unsigned inf) const; // new virtual functions which can be overridden by derived classes diff --git a/ginac/lortensor.cpp b/ginac/lortensor.cpp index 8a30034e..2b2215fd 100644 --- a/ginac/lortensor.cpp +++ b/ginac/lortensor.cpp @@ -105,14 +105,14 @@ void lortensor::destroy(bool call_parent) // protected -lortensor::lortensor(lortensor_types const lt, const string & n) : type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n) : type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string",LOGLEVEL_CONSTRUCT); serial=next_serial++; tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, const string & n, const ex & mu) : indexed(mu), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu) : indexed(mu), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,ex",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -120,7 +120,7 @@ lortensor::lortensor(lortensor_types const lt, const string & n, const ex & mu) tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu) : indexed(mu,nu), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu) : indexed(mu,nu), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,ex,ex",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -128,7 +128,7 @@ lortensor::lortensor(lortensor_types const lt, const string & n, const ex & mu, tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu, const ex & rho) : indexed(mu,nu,rho), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho) : indexed(mu,nu,rho), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,ex,ex,ex",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -136,7 +136,7 @@ lortensor::lortensor(lortensor_types const lt, const string & n, const ex & mu, tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma) : indexed(mu,nu,rho,sigma), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma) : indexed(mu,nu,rho,sigma), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,ex,ex,ex,ex",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -144,7 +144,7 @@ lortensor::lortensor(lortensor_types const lt, const string & n, const ex & mu, tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, const string & n, const exvector & iv) : indexed(iv), type(lt), name(n) +lortensor::lortensor(lortensor_types const lt, const std::string & n, const exvector & iv) : indexed(iv), type(lt), name(n) { debugmsg("lortensor constructor from lortensor_types,string,exvector",LOGLEVEL_CONSTRUCT); serial=next_serial++; @@ -152,14 +152,14 @@ lortensor::lortensor(lortensor_types const lt, const string & n, const exvector tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, const string & n, unsigned s, const exvector & iv) : indexed(iv), type(lt), name(n), serial(s) +lortensor::lortensor(lortensor_types const lt, const std::string & n, unsigned s, const exvector & iv) : indexed(iv), type(lt), name(n), serial(s) { debugmsg("lortensor constructor from lortensor_types,string,unsigned,exvector",LOGLEVEL_CONSTRUCT); GINAC_ASSERT(all_of_type_lorentzidx()); tinfo_key=TINFO_lortensor; } -lortensor::lortensor(lortensor_types const lt, const string & n, unsigned s, exvector *ivp) : indexed(ivp), type(lt), name(n), serial(s) +lortensor::lortensor(lortensor_types const lt, const std::string & n, unsigned s, exvector *ivp) : indexed(ivp), type(lt), name(n), serial(s) { debugmsg("lortensor constructor from lortensor_types,string,unsigned,exvector",LOGLEVEL_CONSTRUCT); GINAC_ASSERT(all_of_type_lorentzidx()); @@ -178,7 +178,7 @@ basic * lortensor::duplicate() const return new lortensor(*this); } -void lortensor::printraw(ostream & os) const +void lortensor::printraw(std::ostream & os) const { debugmsg("lortensor printraw",LOGLEVEL_PRINT); os << "lortensor(type=" << (unsigned)type @@ -187,19 +187,19 @@ void lortensor::printraw(ostream & os) const os << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void lortensor::printtree(ostream & os, unsigned indent) const +void lortensor::printtree(std::ostream & os, unsigned indent) const { debugmsg("lortensor printtree",LOGLEVEL_PRINT); - os << string(indent,' ') <<"lortensor object: " + os << std::string(indent,' ') <<"lortensor object: " << "type=" << (unsigned)type << "," - << seq.size() << " indices" << endl; + << seq.size() << " indices" << std::endl; printtreeindices(os,indent); - os << string(indent,' ') << "hash=" << hashvalue - << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + os << std::string(indent,' ') << "hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void lortensor::print(ostream & os, unsigned upper_precedence) const +void lortensor::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("lortensor print",LOGLEVEL_PRINT); switch (type) { @@ -226,7 +226,7 @@ void lortensor::print(ostream & os, unsigned upper_precedence) const printindices(os); } -void lortensor::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void lortensor::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("lortensor print csrc",LOGLEVEL_PRINT); print(os,upper_precedence); @@ -327,9 +327,9 @@ ex lortensor::thisexprseq(exvector *vp) const // protected -void lortensor::setname(const string & n) +void lortensor::setname(const std::string & n) { - name=n; + name = n; } bool lortensor::all_of_type_lorentzidx(void) const @@ -344,9 +344,9 @@ bool lortensor::all_of_type_lorentzidx(void) const // private -string & lortensor::autoname_prefix(void) +std::string & lortensor::autoname_prefix(void) { - static string * s=new string("lortensor"); + static std::string * s = new std::string("lortensor"); return *s; } @@ -372,12 +372,12 @@ lortensor lortensor_epsilon(const ex & mu, const ex & nu, const ex & rho, const return lortensor(lortensor::lortensor_epsilon,"",mu,nu,rho,sigma); } -lortensor lortensor_rank1(const string & n, const ex & mu) +lortensor lortensor_rank1(const std::string & n, const ex & mu) { return lortensor(lortensor::lortensor_rank1,n,mu); } -lortensor lortensor_rank2(const string & n, const ex & mu, const ex & nu) +lortensor lortensor_rank2(const std::string & n, const ex & mu, const ex & nu) { return lortensor(lortensor::lortensor_rank2,n,mu,nu); } diff --git a/ginac/lortensor.h b/ginac/lortensor.h index 86bf70a0..4d360589 100644 --- a/ginac/lortensor.h +++ b/ginac/lortensor.h @@ -42,8 +42,8 @@ class lortensor : public indexed friend lortensor lortensor_epsilon(const ex & mu, const ex & nu, const ex & rho, const ex & sigma); // friend lortensor lortensor_rankn(const string & n, const exvector & iv); - friend lortensor lortensor_rank1(const string & n, const ex & mu); - friend lortensor lortensor_rank2(const string & n, const ex & mu, const ex & nu); + friend lortensor lortensor_rank1(const std::string & n, const ex & mu); + friend lortensor lortensor_rank2(const std::string & n, const ex & mu, const ex & nu); friend ex simplify_lortensor_mul(const ex & m); friend ex simplify_lortensor(const ex & e); @@ -73,23 +73,23 @@ protected: // other constructors protected: - lortensor(lortensor_types const lt, const string & n); - lortensor(lortensor_types const lt, const string & n, const ex & mu); - lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu); - lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu, + lortensor(lortensor_types const lt, const std::string & n); + lortensor(lortensor_types const lt, const std::string & n, const ex & mu); + lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu); + lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho); - lortensor(lortensor_types const lt, const string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma); - lortensor(lortensor_types const lt, const string & n, const exvector & iv); - lortensor(lortensor_types const lt, const string & n, unsigned s, const exvector & iv); - lortensor(lortensor_types const lt, const string & n, unsigned s, exvector * ivp); + lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma); + lortensor(lortensor_types const lt, const std::string & n, const exvector & iv); + lortensor(lortensor_types const lt, const std::string & n, unsigned s, const exvector & iv); + lortensor(lortensor_types const lt, const std::string & n, unsigned s, exvector * ivp); //functions overriding virtual functions from base classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; bool info(unsigned inf) const; ex eval(int level=0) const; protected: @@ -105,18 +105,18 @@ protected: //non virtual functions in this class public: - void setname(const string & n); - string getname(void) const {return name;} + void setname(const std::string & n); + std::string getname(void) const {return name;} protected: bool all_of_type_lorentzidx(void) const; private: - string & autoname_prefix(void); + std::string & autoname_prefix(void); //member variables protected: lortensor_types type; - string name; + std::string name; unsigned serial; private: static unsigned next_serial; diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index 1c4b6dd5..fc9d7e26 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -168,7 +168,7 @@ basic * matrix::duplicate() const return new matrix(*this); } -void matrix::print(ostream & os, unsigned upper_precedence) const +void matrix::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("matrix print",LOGLEVEL_PRINT); os << "[[ "; @@ -186,7 +186,7 @@ void matrix::print(ostream & os, unsigned upper_precedence) const os << m[row*col-1] << "]] ]]"; } -void matrix::printraw(ostream & os) const +void matrix::printraw(std::ostream & os) const { debugmsg("matrix printraw",LOGLEVEL_PRINT); os << "matrix(" << row << "," << col <<","; @@ -498,8 +498,8 @@ ex matrix::determinant(void) const // For this to be efficient it turns out that the emptiest columns (i.e. // the ones with most zeros) should be the ones on the right hand side. // Therefore we presort the columns of the matrix: - typedef pair uintpair; // # of zeros, column - vector c_zeros; // number of zeros in column + typedef std::pair uintpair; // # of zeros, column + std::vector c_zeros; // number of zeros in column for (unsigned c=0; c pre_sort; // unfortunately vector can't be used - // for permutation_sign. - for (vector::iterator i=c_zeros.begin(); i!=c_zeros.end(); ++i) + // unfortunately std::vector can't be used for permutation_sign. + std::vector pre_sort; + for (std::vector::iterator i=c_zeros.begin(); i!=c_zeros.end(); ++i) pre_sort.push_back(i->second); int sign = permutation_sign(pre_sort); exvector result(row*col); // represents sorted matrix unsigned c = 0; - for (vector::iterator i=pre_sort.begin(); + for (std::vector::iterator i=pre_sort.begin(); i!=pre_sort.end(); ++i,++c) { for (unsigned r=0; r Pkey; + std::vector Pkey; Pkey.reserve(this->col); // key for minor determinant (a subpartition of Pkey) - vector Mkey; + std::vector Mkey; Mkey.reserve(this->col-1); // we store our subminors in maps, keys being the rows they arise from - typedef map,class ex> Rmap; - typedef map,class ex>::value_type Rmap_value; + typedef std::map,class ex> Rmap; + typedef std::map,class ex>::value_type Rmap_value; Rmap A; Rmap B; ex det; diff --git a/ginac/matrix.h b/ginac/matrix.h index dc8eb482..f4665278 100644 --- a/ginac/matrix.h +++ b/ginac/matrix.h @@ -59,8 +59,8 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printraw(ostream & os) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; unsigned nops() const; ex op(int i) const; ex & let_op(int i); diff --git a/ginac/mul.cpp b/ginac/mul.cpp index e6d4a617..1cc7abf6 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -183,7 +183,7 @@ basic * mul::duplicate() const return new mul(*this); } -void mul::print(ostream & os, unsigned upper_precedence) const +void mul::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("mul print",LOGLEVEL_PRINT); if (precedence<=upper_precedence) os << "("; @@ -218,7 +218,7 @@ void mul::print(ostream & os, unsigned upper_precedence) const if (precedence<=upper_precedence) os << ")"; } -void mul::printraw(ostream & os) const +void mul::printraw(std::ostream & os) const { debugmsg("mul printraw",LOGLEVEL_PRINT); @@ -234,7 +234,7 @@ void mul::printraw(ostream & os) const os << ")"; } -void mul::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void mul::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("mul print csrc", LOGLEVEL_PRINT); if (precedence <= upper_precedence) @@ -266,7 +266,7 @@ void mul::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) cons (ex(power(it->rest, abs(ex_to_numeric(it->coeff))))).bp->printcsrc(os, type, upper_precedence); // Separator is "/" for negative integer powers, "*" otherwise - it++; + ++it; if (it != itend) { if (ex_to_numeric(it->coeff).is_integer() && it->coeff.compare(_num0()) < 0) os << "/"; @@ -304,7 +304,7 @@ bool mul::info(unsigned inf) const return inherited::info(inf); } -typedef vector intvector; +typedef std::vector intvector; int mul::degree(const symbol & s) const { @@ -471,22 +471,21 @@ ex mul::simplify_ncmul(const exvector & v) const // protected -/** Implementation of ex::diff() for a product. It applies the product rule. +/** Implementation of ex::diff() for a product. It applies the product rule. * @see ex::diff */ ex mul::derivative(const symbol & s) const { - exvector new_seq; - new_seq.reserve(seq.size()); - - // D(a*b*c)=D(a)*b*c+a*D(b)*c+a*b*D(c) - for (unsigned i=0; i!=seq.size(); i++) { - epvector sub_seq = seq; - sub_seq[i] = split_ex_to_pair(sub_seq[i].coeff* - power(sub_seq[i].rest,sub_seq[i].coeff-1)* - sub_seq[i].rest.diff(s)); - new_seq.push_back((new mul(sub_seq,overall_coeff))->setflag(status_flags::dynallocated)); + exvector addseq; + addseq.reserve(seq.size()); + + // D(a*b*c) = D(a)*b*c + a*D(b)*c + a*b*D(c) + for (unsigned i=0; i!=seq.size(); ++i) { + epvector mulseq = seq; + mulseq[i] = split_ex_to_pair(power(seq[i].rest,seq[i].coeff - _ex1())* + seq[i].rest.diff(s)); + addseq.push_back((new mul(mulseq,overall_coeff*seq[i].coeff))->setflag(status_flags::dynallocated)); } - return (new add(new_seq))->setflag(status_flags::dynallocated); + return (new add(addseq))->setflag(status_flags::dynallocated); } int mul::compare_same_type(const basic & other) const @@ -574,9 +573,9 @@ expair mul::combine_ex_with_coeff_to_pair(const ex & e, // we create a temporary power object // otherwise it would be hard to correctly simplify // expression like (4^(1/3))^(3/2) - if (are_ex_trivially_equal(c,_ex1())) { + if (are_ex_trivially_equal(c,_ex1())) return split_ex_to_pair(e); - } + return split_ex_to_pair(power(e,c)); } @@ -587,9 +586,9 @@ expair mul::combine_pair_with_coeff_to_pair(const expair & p, // we create a temporary power object // otherwise it would be hard to correctly simplify // expression like (4^(1/3))^(3/2) - if (are_ex_trivially_equal(c,_ex1())) { + if (are_ex_trivially_equal(c,_ex1())) return p; - } + return split_ex_to_pair(power(recombine_pair_to_ex(p),c)); } @@ -597,11 +596,10 @@ ex mul::recombine_pair_to_ex(const expair & p) const { // if (p.coeff.compare(_ex1())==0) { // if (are_ex_trivially_equal(p.coeff,_ex1())) { - if (ex_to_numeric(p.coeff).is_equal(_num1())) { + if (ex_to_numeric(p.coeff).is_equal(_num1())) return p.rest; - } else { + else return power(p.rest,p.coeff); - } } bool mul::expair_needs_further_processing(epp it) @@ -678,44 +676,39 @@ ex mul::expand(unsigned options) const unsigned current_position = 0; epvector::const_iterator last = expanded_seq.end(); - for (epvector::const_iterator cit=expanded_seq.begin(); cit!=last; ++cit) { - if (is_ex_exactly_of_type((*cit).rest,add)&& - (ex_to_numeric((*cit).coeff).is_equal(_num1()))) { + for (epvector::const_iterator cit = expanded_seq.begin(); cit!=last; ++cit) { + if (is_ex_exactly_of_type((*cit).rest,add) && + ((*cit).coeff.is_equal(_ex1()))) { positions_of_adds[number_of_adds] = current_position; const add & expanded_addref = ex_to_add((*cit).rest); unsigned addref_nops = expanded_addref.nops(); number_of_add_operands[number_of_adds] = addref_nops; number_of_expanded_terms *= addref_nops; - number_of_adds++; + ++number_of_adds; } - current_position++; + ++current_position; } if (number_of_adds==0) { - if (expanded_seqp==0) { + if (expanded_seqp==0) return this->setflag(status_flags::expanded); - } - return (new mul(expanded_seqp,overall_coeff))-> - setflag(status_flags::dynallocated | - status_flags::expanded); + else + return ((new mul(expanded_seqp,overall_coeff))-> + setflag(status_flags::dynallocated | + status_flags::expanded)); } exvector distrseq; distrseq.reserve(number_of_expanded_terms); intvector k; - k.resize(number_of_adds); - - int l; - for (l=0; l=0) && ((++k[l])>=number_of_add_operands[l])) { - k[l]=0; - l--; + k[l] = 0; + --l; } if (l<0) break; } diff --git a/ginac/mul.h b/ginac/mul.h index a0a46002..b8409f4d 100644 --- a/ginac/mul.h +++ b/ginac/mul.h @@ -55,7 +55,6 @@ public: mul(const ex & lh, const ex & rh); mul(const exvector & v); mul(const epvector & v); - //mul(const epvector & v, bool do_not_canonicalize=0); mul(const epvector & v, const ex & oc); mul(epvector * vp, const ex & oc); mul(const ex & lh, const ex & mh, const ex & rh); @@ -63,17 +62,17 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence) const; - void printraw(ostream & os) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const; + void print(std::ostream & os, unsigned upper_precedence) const; + void printraw(std::ostream & os) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const; bool info(unsigned inf) const; int degree(const symbol & s) const; int ldegree(const symbol & s) const; - ex coeff(const symbol & s, int n=1) const; + ex coeff(const symbol & s, int n = 1) const; ex eval(int level=0) const; ex evalf(int level=0) const; - ex series(const relational & s, int order) const; - ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; + ex series(const relational & s, int order, bool branchcut = true) const; + ex normal(lst &sym_lst, lst &repl_lst, int level = 0) const; numeric integer_content(void) const; ex smod(const numeric &xi) const; numeric max_coefficient(void) const; diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index 7cd80149..9d13a43d 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -173,13 +173,13 @@ basic * ncmul::duplicate() const return new ncmul(*this); } -void ncmul::print(ostream & os, unsigned upper_precedence) const +void ncmul::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("ncmul print",LOGLEVEL_PRINT); printseq(os,'(','%',')',precedence,upper_precedence); } -void ncmul::printraw(ostream & os) const +void ncmul::printraw(std::ostream & os) const { debugmsg("ncmul printraw",LOGLEVEL_PRINT); @@ -192,7 +192,7 @@ void ncmul::printraw(ostream & os) const os << ")"; } -void ncmul::printcsrc(ostream & os, unsigned upper_precedence) const +void ncmul::printcsrc(std::ostream & os, unsigned upper_precedence) const { debugmsg("ncmul print csrc",LOGLEVEL_PRINT); exvector::const_iterator it; @@ -211,7 +211,7 @@ bool ncmul::info(unsigned inf) const throw(std::logic_error("which flags have to be implemented in ncmul::info()?")); } -typedef vector intvector; +typedef std::vector intvector; ex ncmul::expand(unsigned options) const { @@ -357,8 +357,8 @@ void ncmul::append_factors(exvector & v, const ex & e) const v.push_back(e); } -typedef vector unsignedvector; -typedef vector exvectorvector; +typedef std::vector unsignedvector; +typedef std::vector exvectorvector; ex ncmul::eval(int level) const { diff --git a/ginac/ncmul.h b/ginac/ncmul.h index b5cc1669..7476e290 100644 --- a/ginac/ncmul.h +++ b/ginac/ncmul.h @@ -66,9 +66,9 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence) const; - void printraw(ostream & os) const; - void printcsrc(ostream & os, unsigned upper_precedence) const; + void print(std::ostream & os, unsigned upper_precedence) const; + void printraw(std::ostream & os) const; + void printcsrc(std::ostream & os, unsigned upper_precedence) const; bool info(unsigned inf) const; int degree(const symbol & s) const; int ldegree(const symbol & s) const; diff --git a/ginac/normal.cpp b/ginac/normal.cpp index 79d16461..a15ec62d 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -145,7 +145,7 @@ struct sym_desc { }; // Vector of sym_desc structures -typedef vector sym_desc_vec; +typedef std::vector sym_desc_vec; // Add symbol the sym_desc_vec (used internally by get_symbol_stats()) static void add_symbol(const symbol *s, sym_desc_vec &v) @@ -203,11 +203,11 @@ static void get_symbol_stats(const ex &a, const ex &b, sym_desc_vec &v) } sort(v.begin(), v.end()); #if 0 - clog << "Symbols:\n"; + std::clog << "Symbols:\n"; it = v.begin(); itend = v.end(); while (it != itend) { - clog << " " << *it->sym << ": deg_a=" << it->deg_a << ", deg_b=" << it->deg_b << ", ldeg_a=" << it->ldeg_a << ", ldeg_b=" << it->ldeg_b << ", max_deg=" << it->max_deg << endl; - clog << " lcoeff_a=" << a.lcoeff(*(it->sym)) << ", lcoeff_b=" << b.lcoeff(*(it->sym)) << endl; + std::clog << " " << *it->sym << ": deg_a=" << it->deg_a << ", deg_b=" << it->deg_b << ", ldeg_a=" << it->ldeg_a << ", ldeg_b=" << it->ldeg_b << ", max_deg=" << it->max_deg << endl; + std::clog << " lcoeff_a=" << a.lcoeff(*(it->sym)) << ", lcoeff_b=" << b.lcoeff(*(it->sym)) << endl; it++; } #endif @@ -608,8 +608,8 @@ bool divide(const ex &a, const ex &b, ex &q, bool check_args) * Remembering */ -typedef pair ex2; -typedef pair exbool; +typedef std::pair ex2; +typedef std::pair exbool; struct ex2_less { bool operator() (const ex2 p, const ex2 q) const @@ -618,7 +618,7 @@ struct ex2_less { } }; -typedef map ex2_exbool_remember; +typedef std::map ex2_exbool_remember; #endif @@ -893,7 +893,7 @@ ex ex::primpart(const symbol &x, const ex &c) const static ex eu_gcd(const ex &a, const ex &b, const symbol *x) { -//clog << "eu_gcd(" << a << "," << b << ")\n"; +//std::clog << "eu_gcd(" << a << "," << b << ")\n"; // Sort c and d so that c has higher degree ex c, d; @@ -913,7 +913,7 @@ static ex eu_gcd(const ex &a, const ex &b, const symbol *x) // Euclidean algorithm ex r; for (;;) { -//clog << " d = " << d << endl; +//std::clog << " d = " << d << endl; r = rem(c, d, *x, false); if (r.is_zero()) return d / d.lcoeff(*x); @@ -935,7 +935,7 @@ static ex eu_gcd(const ex &a, const ex &b, const symbol *x) static ex euprem_gcd(const ex &a, const ex &b, const symbol *x) { -//clog << "euprem_gcd(" << a << "," << b << ")\n"; +//std::clog << "euprem_gcd(" << a << "," << b << ")\n"; // Sort c and d so that c has higher degree ex c, d; @@ -954,7 +954,7 @@ static ex euprem_gcd(const ex &a, const ex &b, const symbol *x) // Euclidean algorithm with pseudo-remainders ex r; for (;;) { -//clog << " d = " << d << endl; +//std::clog << " d = " << d << endl; r = prem(c, d, *x, false); if (r.is_zero()) return d.primpart(*x) * gamma; @@ -976,7 +976,7 @@ static ex euprem_gcd(const ex &a, const ex &b, const symbol *x) static ex peu_gcd(const ex &a, const ex &b, const symbol *x) { -//clog << "peu_gcd(" << a << "," << b << ")\n"; +//std::clog << "peu_gcd(" << a << "," << b << ")\n"; // Sort c and d so that c has higher degree ex c, d; @@ -1004,7 +1004,7 @@ static ex peu_gcd(const ex &a, const ex &b, const symbol *x) // Euclidean algorithm with content removal ex r; for (;;) { -//clog << " d = " << d << endl; +//std::clog << " d = " << d << endl; r = prem(c, d, *x, false); if (r.is_zero()) return gamma * d; @@ -1025,7 +1025,7 @@ static ex peu_gcd(const ex &a, const ex &b, const symbol *x) static ex red_gcd(const ex &a, const ex &b, const symbol *x) { -//clog << "red_gcd(" << a << "," << b << ")\n"; +//std::clog << "red_gcd(" << a << "," << b << ")\n"; // Sort c and d so that c has higher degree ex c, d; @@ -1058,7 +1058,7 @@ static ex red_gcd(const ex &a, const ex &b, const symbol *x) for (;;) { // Calculate polynomial pseudo-remainder -//clog << " d = " << d << endl; +//std::clog << " d = " << d << endl; r = prem(c, d, *x, false); if (r.is_zero()) return gamma * d.primpart(*x); @@ -1092,7 +1092,7 @@ static ex red_gcd(const ex &a, const ex &b, const symbol *x) static ex sr_gcd(const ex &a, const ex &b, sym_desc_vec::const_iterator var) { -//clog << "sr_gcd(" << a << "," << b << ")\n"; +//std::clog << "sr_gcd(" << a << "," << b << ")\n"; #if STATISTICS sr_gcd_called++; #endif @@ -1124,7 +1124,7 @@ static ex sr_gcd(const ex &a, const ex &b, sym_desc_vec::const_iterator var) return gamma; c = c.primpart(x, cont_c); d = d.primpart(x, cont_d); -//clog << " content " << gamma << " removed, continuing with sr_gcd(" << c << "," << d << ")\n"; +//std::clog << " content " << gamma << " removed, continuing with sr_gcd(" << c << "," << d << ")\n"; // First element of subresultant sequence ex r = _ex0(), ri = _ex1(), psi = _ex1(); @@ -1132,14 +1132,14 @@ static ex sr_gcd(const ex &a, const ex &b, sym_desc_vec::const_iterator var) for (;;) { // Calculate polynomial pseudo-remainder -//clog << " start of loop, psi = " << psi << ", calculating pseudo-remainder...\n"; -//clog << " d = " << d << endl; +//std::clog << " start of loop, psi = " << psi << ", calculating pseudo-remainder...\n"; +//std::clog << " d = " << d << endl; r = prem(c, d, x, false); if (r.is_zero()) return gamma * d.primpart(x); c = d; cdeg = ddeg; -//clog << " dividing...\n"; +//std::clog << " dividing...\n"; if (!divide_in_z(r, ri * pow(psi, delta), d, var+1)) throw(std::runtime_error("invalid expression in sr_gcd(), division failed")); ddeg = d.degree(x); @@ -1151,7 +1151,7 @@ static ex sr_gcd(const ex &a, const ex &b, sym_desc_vec::const_iterator var) } // Next element of subresultant sequence -//clog << " calculating next subresultant...\n"; +//std::clog << " calculating next subresultant...\n"; ri = c.expand().lcoeff(x); if (delta == 1) psi = ri; @@ -1326,7 +1326,7 @@ class gcdheu_failed {}; * @exception gcdheu_failed() */ static ex heur_gcd(const ex &a, const ex &b, ex *ca, ex *cb, sym_desc_vec::const_iterator var) { -//clog << "heur_gcd(" << a << "," << b << ")\n"; +//std::clog << "heur_gcd(" << a << "," << b << ")\n"; #if STATISTICS heur_gcd_called++; #endif @@ -1365,7 +1365,7 @@ static ex heur_gcd(const ex &a, const ex &b, ex *ca, ex *cb, sym_desc_vec::const // 6 tries maximum for (int t=0; t<6; t++) { if (xi.int_length() * maxdeg > 100000) { -//clog << "giving up heur_gcd, xi.int_length = " << xi.int_length() << ", maxdeg = " << maxdeg << endl; +//std::clog << "giving up heur_gcd, xi.int_length = " << xi.int_length() << ", maxdeg = " << maxdeg << endl; throw gcdheu_failed(); } @@ -1437,7 +1437,7 @@ static ex heur_gcd(const ex &a, const ex &b, ex *ca, ex *cb, sym_desc_vec::const * @return the GCD as a new expression */ ex gcd(const ex &a, const ex &b, ex *ca, ex *cb, bool check_args) { -//clog << "gcd(" << a << "," << b << ")\n"; +//std::clog << "gcd(" << a << "," << b << ")\n"; #if STATISTICS gcd_called++; #endif @@ -1588,20 +1588,20 @@ factored_b: int min_ldeg = min(ldeg_a, ldeg_b); if (min_ldeg > 0) { ex common = power(x, min_ldeg); -//clog << "trivial common factor " << common << endl; +//std::clog << "trivial common factor " << common << endl; return gcd((aex / common).expand(), (bex / common).expand(), ca, cb, false) * common; } // Try to eliminate variables if (var->deg_a == 0) { -//clog << "eliminating variable " << x << " from b" << endl; +//std::clog << "eliminating variable " << x << " from b" << endl; ex c = bex.content(x); ex g = gcd(aex, c, ca, cb, false); if (cb) *cb *= bex.unit(x) * bex.primpart(x, c); return g; } else if (var->deg_b == 0) { -//clog << "eliminating variable " << x << " from a" << endl; +//std::clog << "eliminating variable " << x << " from a" << endl; ex c = aex.content(x); ex g = gcd(c, bex, ca, cb, false); if (ca) @@ -1618,7 +1618,7 @@ factored_b: g = *new ex(fail()); } if (is_ex_exactly_of_type(g, fail)) { -//clog << "heuristics failed" << endl; +//std::clog << "heuristics failed" << endl; #if STATISTICS heur_gcd_failed++; #endif @@ -1853,7 +1853,7 @@ static ex frac_cancel(const ex &n, const ex &d) ex den = d; numeric pre_factor = _num1(); -//clog << "frac_cancel num = " << num << ", den = " << den << endl; +//std::clog << "frac_cancel num = " << num << ", den = " << den << endl; // Handle special cases where numerator or denominator is 0 if (num.is_zero()) @@ -1888,7 +1888,7 @@ static ex frac_cancel(const ex &n, const ex &d) } // Return result as list -//clog << " returns num = " << num << ", den = " << den << ", pre_factor = " << pre_factor << endl; +//std::clog << " returns num = " << num << ", den = " << den << ", pre_factor = " << pre_factor << endl; return (new lst(num * pre_factor.numer(), den * pre_factor.denom()))->setflag(status_flags::dynallocated); } @@ -1936,13 +1936,13 @@ ex add::normal(lst &sym_lst, lst &repl_lst, int level) const // Determine common denominator ex den = _ex1(); exvector::const_iterator ait = o.begin(), aitend = o.end(); -//clog << "add::normal uses the following summands:\n"; +//std::clog << "add::normal uses the following summands:\n"; while (ait != aitend) { -//clog << " num = " << ait->op(0) << ", den = " << ait->op(1) << endl; +//std::clog << " num = " << ait->op(0) << ", den = " << ait->op(1) << endl; den = lcm(ait->op(1), den, false); ait++; } -//clog << " common denominator = " << den << endl; +//std::clog << " common denominator = " << den << endl; // Add fractions if (den.is_equal(_ex1())) { diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index f4dd7380..36b3551c 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -396,7 +396,7 @@ basic * numeric::duplicate() const * long as it only uses cl_LF and no other floating point types. * * @see numeric::print() */ -static void print_real_number(ostream & os, const cl_R & num) +static void print_real_number(std::ostream & os, const cl_R & num) { cl_print_flags ourflags; if (::instanceof(num, ::cl_RA_ring)) { @@ -416,7 +416,7 @@ static void print_real_number(ostream & os, const cl_R & num) * with the other routines and produces something compatible to ginsh input. * * @see print_real_number() */ -void numeric::print(ostream & os, unsigned upper_precedence) const +void numeric::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("numeric print", LOGLEVEL_PRINT); if (this->is_real()) { @@ -479,7 +479,7 @@ void numeric::print(ostream & os, unsigned upper_precedence) const } -void numeric::printraw(ostream & os) const +void numeric::printraw(std::ostream & os) const { // The method printraw doesn't do much, it simply uses CLN's operator<<() // for output, which is ugly but reliable. e.g: 2+2i @@ -488,17 +488,18 @@ void numeric::printraw(ostream & os) const } -void numeric::printtree(ostream & os, unsigned indent) const +void numeric::printtree(std::ostream & os, unsigned indent) const { debugmsg("numeric printtree", LOGLEVEL_PRINT); os << std::string(indent,' ') << *value << " (numeric): " - << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + << "hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void numeric::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void numeric::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("numeric print csrc", LOGLEVEL_PRINT); ios::fmtflags oldflags = os.flags(); @@ -616,9 +617,10 @@ ex numeric::eval(int level) const /** Cast numeric into a floating-point object. For example exact numeric(1) is * returned as a 1.0000000000000000000000 and so on according to how Digits is - * currently set. + * currently set. In case the object already was a floating point number the + * precision is trimmed to match the currently set default. * - * @param level ignored, but needed for overriding basic::evalf. + * @param level ignored, only needed for overriding basic::evalf. * @return an ex-handle to a numeric. */ ex numeric::evalf(int level) const { @@ -1360,6 +1362,106 @@ const numeric atanh(const numeric & x) } +/*static ::cl_N Li2_series(const ::cl_N & x, + const ::cl_float_format_t & prec) +{ + // Note: argument must be in the unit circle + // This is very inefficient unless we have fast floating point Bernoulli + // numbers implemented! + ::cl_N c1 = -::log(1-x); + ::cl_N c2 = c1; + // hard-wire the first two Bernoulli numbers + ::cl_N acc = c1 - ::square(c1)/4; + ::cl_N aug; + ::cl_F pisq = ::square(::cl_pi(prec)); // pi^2 + ::cl_F piac = ::cl_float(1, prec); // accumulator: pi^(2*i) + unsigned i = 1; + c1 = ::square(c1); + do { + c2 = c1 * c2; + piac = piac * pisq; + aug = c2 * (*(bernoulli(numeric(2*i)).clnptr())) / ::factorial(2*i+1); + // aug = c2 * ::cl_I(i%2 ? 1 : -1) / ::cl_I(2*i+1) * ::cl_zeta(2*i, prec) / piac / (::cl_I(1)<<(2*i-1)); + acc = acc + aug; + ++i; + } while (acc != acc+aug); + return acc; +}*/ + +/** Numeric evaluation of Dilogarithm within circle of convergence (unit + * circle) using a power series. */ +static ::cl_N Li2_series(const ::cl_N & x, + const ::cl_float_format_t & prec) +{ + // Note: argument must be in the unit circle + ::cl_N aug, acc; + ::cl_N num = ::complex(::cl_float(1, prec), 0); + ::cl_I den = 0; + unsigned i = 1; + do { + num = num * x; + den = den + i; // 1, 4, 9, 16, ... + i += 2; + aug = num / den; + acc = acc + aug; + } while (acc != acc+aug); + return acc; +} + +/** Folds Li2's argument inside a small rectangle to enhance convergence. */ +static ::cl_N Li2_projection(const ::cl_N & x, + const ::cl_float_format_t & prec) +{ + const ::cl_R re = ::realpart(x); + const ::cl_R im = ::imagpart(x); + if (re > ::cl_F(".5")) + // zeta(2) - Li2(1-x) - log(x)*log(1-x) + return(::cl_zeta(2) + - Li2_series(1-x, prec) + - ::log(x)*::log(1-x)); + if ((re <= 0 && ::abs(im) > ::cl_F(".75")) || (re < ::cl_F("-.5"))) + // -log(1-x)^2 / 2 - Li2(x/(x-1)) + return(-::square(::log(1-x))/2 + - Li2_series(x/(x-1), prec)); + if (re > 0 && ::abs(im) > ::cl_LF(".75")) + // Li2(x^2)/2 - Li2(-x) + return(Li2_projection(::square(x), prec)/2 + - Li2_projection(-x, prec)); + return Li2_series(x, prec); +} + +/** Numeric evaluation of Dilogarithm. The domain is the entire complex plane, + * the branch cut lies along the positive real axis, starting at 1 and + * continuous with quadrant IV. + * + * @return arbitrary precision numerical Li2(x). */ +const numeric Li2(const numeric & x) +{ + if (::zerop(*x.value)) + return x; + + // what is the desired float format? + // first guess: default format + ::cl_float_format_t prec = ::cl_default_float_format; + // second guess: the argument's format + if (!::instanceof(::realpart(*x.value),cl_RA_ring)) + prec = ::cl_float_format(The(::cl_F)(::realpart(*x.value))); + else if (!::instanceof(::imagpart(*x.value),cl_RA_ring)) + prec = ::cl_float_format(The(::cl_F)(::imagpart(*x.value))); + + if (*x.value==1) // may cause trouble with log(1-x) + return ::cl_zeta(2, prec); + + if (::abs(*x.value) > 1) + // -log(-x)^2 / 2 - zeta(2) - Li2(1/x) + return(-::square(::log(-*x.value))/2 + - ::cl_zeta(2, prec) + - Li2_projection(::recip(*x.value), prec)); + else + return Li2_projection(*x.value, prec); +} + + /** Numeric evaluation of Riemann's Zeta function. Currently works only for * integer arguments. */ const numeric zeta(const numeric & x) @@ -1371,12 +1473,12 @@ const numeric zeta(const numeric & x) // pass the number casted to an int: if (x.is_real()) { int aux = (int)(::cl_double_approx(::realpart(*x.value))); - if (zerop(*x.value-aux)) + if (::zerop(*x.value-aux)) return ::cl_zeta(aux); // -> CLN } - clog << "zeta(" << x - << "): Does anybody know good way to calculate this numerically?" - << endl; + std::clog << "zeta(" << x + << "): Does anybody know good way to calculate this numerically?" + << std::endl; return numeric(0); } @@ -1385,16 +1487,16 @@ const numeric zeta(const numeric & x) * This is only a stub! */ const numeric lgamma(const numeric & x) { - clog << "lgamma(" << x - << "): Does anybody know good way to calculate this numerically?" - << endl; + std::clog << "lgamma(" << x + << "): Does anybody know good way to calculate this numerically?" + << std::endl; return numeric(0); } const numeric tgamma(const numeric & x) { - clog << "tgamma(" << x - << "): Does anybody know good way to calculate this numerically?" - << endl; + std::clog << "tgamma(" << x + << "): Does anybody know good way to calculate this numerically?" + << std::endl; return numeric(0); } @@ -1403,9 +1505,9 @@ const numeric tgamma(const numeric & x) * This is only a stub! */ const numeric psi(const numeric & x) { - clog << "psi(" << x - << "): Does anybody know good way to calculate this numerically?" - << endl; + std::clog << "psi(" << x + << "): Does anybody know good way to calculate this numerically?" + << std::endl; return numeric(0); } @@ -1414,9 +1516,9 @@ const numeric psi(const numeric & x) * This is only a stub! */ const numeric psi(const numeric & n, const numeric & x) { - clog << "psi(" << n << "," << x - << "): Does anybody know good way to calculate this numerically?" - << endl; + std::clog << "psi(" << n << "," << x + << "): Does anybody know good way to calculate this numerically?" + << std::endl; return numeric(0); } @@ -1515,13 +1617,13 @@ const numeric bernoulli(const numeric & nn) // we don't use it.) // the special cases not covered by the algorithm below - if (!nn.compare(_num1())) - return numeric(-1,2); + if (nn.is_equal(_num1())) + return _num_1_2(); if (nn.is_odd()) return _num0(); // store nonvanishing Bernoulli numbers here - static vector< ::cl_RA > results; + static std::vector< ::cl_RA > results; static int highest_result = 0; // algorithm not applicable to B(0), so just store it if (results.size()==0) @@ -1535,13 +1637,13 @@ const numeric bernoulli(const numeric & nn) long d1 = i; long d2 = 2*i-1; for (int j=i; j>0; --j) { - B = cl_I(n*m) * (B+results[j]) / (d1*d2); + B = ::cl_I(n*m) * (B+results[j]) / (d1*d2); n += 4; m += 2; d1 -= 1; d2 -= 2; } - B = (1 - ((B+1)/(2*i+3))) / (cl_I(1)<<(2*i+2)); + B = (1 - ((B+1)/(2*i+3))) / (::cl_I(1)<<(2*i+2)); results.push_back(B); ++highest_result; } @@ -1816,14 +1918,14 @@ _numeric_digits::operator long() } -void _numeric_digits::print(ostream & os) const +void _numeric_digits::print(std::ostream & os) const { debugmsg("_numeric_digits print", LOGLEVEL_PRINT); os << digits; } -ostream& operator<<(ostream& os, const _numeric_digits & e) +std::ostream& operator<<(std::ostream& os, const _numeric_digits & e) { e.print(os); return os; diff --git a/ginac/numeric.h b/ginac/numeric.h index 7fb9d9d7..d55e1d13 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -52,7 +52,7 @@ public: _numeric_digits(); _numeric_digits& operator=(long prec); operator long(); - void print(ostream & os) const; + void print(std::ostream & os) const; // member variables private: long digits; @@ -81,8 +81,9 @@ class numeric : public basic friend const numeric asinh(const numeric & x); friend const numeric acosh(const numeric & x); friend const numeric atanh(const numeric & x); + friend const numeric Li2(const numeric & x); friend const numeric zeta(const numeric & x); - friend const numeric bernoulli(const numeric & n); + // friend const numeric bernoulli(const numeric & n); friend const numeric fibonacci(const numeric & n); friend numeric abs(const numeric & x); friend numeric mod(const numeric & a, const numeric & b); @@ -123,10 +124,10 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned precedence=0) const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void printcsrc(ostream & os, unsigned type, unsigned precedence=0) const; + void print(std::ostream & os, unsigned precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void printcsrc(std::ostream & os, unsigned type, unsigned precedence=0) const; bool info(unsigned inf) const; bool has(const ex & other) const; ex eval(int level=0) const; @@ -165,6 +166,7 @@ public: const numeric & operator=(const char * s); numeric inverse(void) const; int csgn(void) const; + ::cl_N* clnptr(void) const { return value; } /**< ptr to representation. */ int compare(const numeric & other) const; bool is_equal(const numeric & other) const; bool is_zero(void) const; @@ -232,6 +234,7 @@ const numeric tanh(const numeric & x); const numeric asinh(const numeric & x); const numeric acosh(const numeric & x); const numeric atanh(const numeric & x); +const numeric Li2(const numeric & x); const numeric zeta(const numeric & x); const numeric lgamma(const numeric & x); const numeric tgamma(const numeric & x); diff --git a/ginac/operators.cpp b/ginac/operators.cpp index f901760e..f0d2eb8d 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -257,13 +257,13 @@ relational operator>=(const ex & lh, const ex & rh) // input/output stream operators -ostream & operator<<(ostream & os, const ex & e) +std::ostream & operator<<(std::ostream & os, const ex & e) { e.print(os); return os; } -istream & operator>>(istream & is, ex & e) +std::istream & operator>>(std::istream & is, ex & e) { throw (std::logic_error("expression input from streams not implemented")); } diff --git a/ginac/operators.h b/ginac/operators.h index a7d84b0a..30702ff1 100644 --- a/ginac/operators.h +++ b/ginac/operators.h @@ -79,8 +79,8 @@ relational operator>(const ex & lh, const ex & rh); relational operator>=(const ex & lh, const ex & rh); // input/output stream operators -ostream & operator<<(ostream & os, const ex & e); -istream & operator>>(istream & is, ex & e); +std::ostream & operator<<(std::ostream & os, const ex & e); +std::istream & operator>>(std::istream & is, ex & e); #ifndef NO_NAMESPACE_GINAC } // namespace GiNaC diff --git a/ginac/power.cpp b/ginac/power.cpp index 8ec1945f..fc52a5f8 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -42,7 +42,7 @@ namespace GiNaC { GINAC_IMPLEMENT_REGISTERED_CLASS(power, basic) -typedef vector intvector; +typedef std::vector intvector; ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -147,7 +147,7 @@ basic * power::duplicate() const return new power(*this); } -void power::print(ostream & os, unsigned upper_precedence) const +void power::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("power print",LOGLEVEL_PRINT); if (exponent.is_equal(_ex1_2())) { @@ -161,7 +161,7 @@ void power::print(ostream & os, unsigned upper_precedence) const } } -void power::printraw(ostream & os) const +void power::printraw(std::ostream & os) const { debugmsg("power printraw",LOGLEVEL_PRINT); @@ -172,18 +172,19 @@ void power::printraw(ostream & os) const os << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void power::printtree(ostream & os, unsigned indent) const +void power::printtree(std::ostream & os, unsigned indent) const { debugmsg("power printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "power: " - << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; - basis.printtree(os,indent+delta_indent); - exponent.printtree(os,indent+delta_indent); + os << std::string(indent,' ') << "power: " + << "hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; + basis.printtree(os, indent+delta_indent); + exponent.printtree(os, indent+delta_indent); } -static void print_sym_pow(ostream & os, unsigned type, const symbol &x, int exp) +static void print_sym_pow(std::ostream & os, unsigned type, const symbol &x, int exp) { // Optimal output of integer powers of symbols to aid compiler CSE if (exp == 1) { @@ -205,7 +206,7 @@ static void print_sym_pow(ostream & os, unsigned type, const symbol &x, int exp) } } -void power::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void power::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("power print csrc", LOGLEVEL_PRINT); @@ -370,7 +371,7 @@ ex power::eval(int level) const if ((num_exponent->real()).is_zero()) throw (std::domain_error("power::eval(): pow(0,I) is undefined")); else if ((num_exponent->real()).is_negative()) - throw (std::overflow_error("power::eval(): division by zero")); + throw (pole_error("power::eval(): division by zero",1)); else return _ex0(); } @@ -524,7 +525,12 @@ ex power::derivative(const symbol & s) const { if (exponent.info(info_flags::real)) { // D(b^r) = r * b^(r-1) * D(b) (faster than the formula below) - return mul(mul(exponent, power(basis, exponent - _ex1())), basis.diff(s)); + //return mul(mul(exponent, power(basis, exponent - _ex1())), basis.diff(s)); + epvector newseq; + newseq.reserve(2); + newseq.push_back(expair(basis, exponent - _ex1())); + newseq.push_back(expair(basis.diff(s),_ex1())); + return mul(newseq, exponent); } else { // D(b^e) = b^e * (D(e)*ln(b) + e*D(b)/b) return mul(power(basis, exponent), diff --git a/ginac/power.h b/ginac/power.h index b4faa178..3d8be419 100644 --- a/ginac/power.h +++ b/ginac/power.h @@ -61,21 +61,21 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void print(std::ostream & os, unsigned upper_precedence = 0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence = 0) const; bool info(unsigned inf) const; unsigned nops() const; ex & let_op(int i); int degree(const symbol & s) const; int ldegree(const symbol & s) const; - ex coeff(const symbol & s, int n=1) const; + ex coeff(const symbol & s, int n = 1) const; ex eval(int level=0) const; ex evalf(int level=0) const; - ex series(const relational & s, int order) const; + ex series(const relational & s, int order, bool branchcut = true) const; ex subs(const lst & ls, const lst & lr) const; - ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; + ex normal(lst &sym_lst, lst &repl_lst, int level = 0) const; ex to_rational(lst &repl_lst) const; ex simplify_ncmul(const exvector & v) const; protected: @@ -83,7 +83,7 @@ protected: int compare_same_type(const basic & other) const; unsigned return_type(void) const; unsigned return_type_tinfo(void) const; - ex expand(unsigned options=0) const; + ex expand(unsigned options = 0) const; // new virtual functions which can be overridden by derived classes // none diff --git a/ginac/pseries.cpp b/ginac/pseries.cpp index d12907a2..38499480 100644 --- a/ginac/pseries.cpp +++ b/ginac/pseries.cpp @@ -97,13 +97,13 @@ void pseries::destroy(bool call_parent) * the last coefficient can be Order(_ex1()) to represent a truncated, * non-terminating series. * - * @param rel__ expansion variable and point (must hold a relational) + * @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_) : basic(TINFO_pseries), seq(ops_) { - debugmsg("pseries constructor from rel,epvector", LOGLEVEL_CONSTRUCT); + debugmsg("pseries constructor from ex,epvector", LOGLEVEL_CONSTRUCT); GINAC_ASSERT(is_ex_exactly_of_type(rel_, relational)); GINAC_ASSERT(is_ex_exactly_of_type(rel_.lhs(),symbol)); point = rel_.rhs(); @@ -119,7 +119,7 @@ pseries::pseries(const ex &rel_, const epvector &ops_) pseries::pseries(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) { debugmsg("pseries constructor from archive_node", LOGLEVEL_CONSTRUCT); - for (unsigned int i=0; true; i++) { + for (unsigned int i=0; true; ++i) { ex rest; ex coeff; if (n.find_ex("coeff", rest, sym_lst, i) && n.find_ex("power", coeff, sym_lst, i)) @@ -145,7 +145,7 @@ void pseries::archive(archive_node &n) const while (i != iend) { n.add_ex("coeff", i->rest); n.add_ex("power", i->coeff); - i++; + ++i; } n.add_ex("var", var); n.add_ex("point", point); @@ -161,10 +161,10 @@ basic *pseries::duplicate() const return new pseries(*this); } -void pseries::print(ostream &os, unsigned upper_precedence) const +void pseries::print(std::ostream &os, unsigned upper_precedence) const { debugmsg("pseries print", LOGLEVEL_PRINT); - for (epvector::const_iterator i=seq.begin(); i!=seq.end(); i++) { + for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) { // omit zero terms if (i->rest.is_zero()) continue; @@ -199,38 +199,43 @@ void pseries::print(ostream &os, unsigned upper_precedence) const } } -void pseries::printraw(ostream &os) const + +void pseries::printraw(std::ostream &os) const { debugmsg("pseries printraw", LOGLEVEL_PRINT); os << "pseries(" << var << ";" << point << ";"; - for (epvector::const_iterator i=seq.begin(); i!=seq.end(); i++) { + for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) { os << "(" << (*i).rest << "," << (*i).coeff << "),"; } os << ")"; } -void pseries::printtree(ostream & os, unsigned indent) const + +void pseries::printtree(std::ostream & os, unsigned indent) const { debugmsg("pseries printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "pseries " - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + os << std::string(indent,' ') << "pseries " + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; for (unsigned i=0; i= seq.size()) @@ -238,11 +243,16 @@ ex pseries::op(int i) const return seq[i].rest * power(var - point, seq[i].coeff); } + ex &pseries::let_op(int i) { throw (std::logic_error("let_op not defined for pseries")); } + +/** Return degree of highest power of the series. This is usually the exponent + * of the Order term. If s is not the expansion variable of the series, the + * series is examined termwise. */ int pseries::degree(const symbol &s) const { if (var.is_equal(s)) { @@ -260,12 +270,17 @@ int pseries::degree(const symbol &s) const int pow = it->rest.degree(s); if (pow > max_pow) max_pow = pow; - it++; + ++it; } return max_pow; } } +/** Return degree of lowest power of the series. This is usually the exponent + * of the leading term. If s is not the expansion variable of the series, the + * series is examined termwise. If s is the expansion variable but the + * expansion point is not zero the series is not expanded to find the degree. + * I.e.: (1-x) + (1-x)^2 + Order((1-x)^3) has ldegree(x) 1, not 0. */ int pseries::ldegree(const symbol &s) const { if (var.is_equal(s)) { @@ -283,7 +298,7 @@ int pseries::ldegree(const symbol &s) const int pow = it->rest.ldegree(s); if (pow < min_pow) min_pow = pow; - it++; + ++it; } return min_pow; } @@ -294,7 +309,7 @@ ex pseries::coeff(const symbol &s, int n) const if (var.is_equal(s)) { if (seq.size() == 0) return _ex0(); - + // Binary search in sequence for given power numeric looking_for = numeric(n); int lo = 0, hi = seq.size() - 1; @@ -320,11 +335,13 @@ ex pseries::coeff(const symbol &s, int n) const return convert_to_poly().coeff(s, n); } + ex pseries::collect(const symbol &s) const { return *this; } + /** Evaluate coefficients. */ ex pseries::eval(int level) const { @@ -340,11 +357,12 @@ ex pseries::eval(int level) const epvector::const_iterator it = seq.begin(), itend = seq.end(); while (it != itend) { new_seq.push_back(expair(it->rest.eval(level-1), it->coeff)); - it++; + ++it; } return (new pseries(relational(var,point), new_seq))->setflag(status_flags::dynallocated | status_flags::evaluated); } + /** Evaluate coefficients numerically. */ ex pseries::evalf(int level) const { @@ -360,11 +378,12 @@ ex pseries::evalf(int level) const epvector::const_iterator it = seq.begin(), itend = seq.end(); while (it != itend) { new_seq.push_back(expair(it->rest.evalf(level-1), it->coeff)); - it++; + ++it; } return (new pseries(relational(var,point), new_seq))->setflag(status_flags::dynallocated | status_flags::evaluated); } + ex pseries::subs(const lst & ls, const lst & lr) const { // If expansion variable is being substituted, convert the series to a @@ -375,16 +394,32 @@ ex pseries::subs(const lst & ls, const lst & lr) const // Otherwise construct a new series with substituted coefficients and // expansion point - epvector new_seq; - new_seq.reserve(seq.size()); + epvector newseq; + newseq.reserve(seq.size()); epvector::const_iterator it = seq.begin(), itend = seq.end(); while (it != itend) { - new_seq.push_back(expair(it->rest.subs(ls, lr), it->coeff)); - it++; + newseq.push_back(expair(it->rest.subs(ls, lr), it->coeff)); + ++it; } - return (new pseries(relational(var,point.subs(ls, lr)), new_seq))->setflag(status_flags::dynallocated); + return (new pseries(relational(var,point.subs(ls, lr)), newseq))->setflag(status_flags::dynallocated); } + +/** Implementation of ex::expand() for a power series. It expands all the + * terms individually and returns the resulting series as a new pseries. + * @see ex::diff */ +ex pseries::expand(unsigned options) const +{ + epvector newseq; + newseq.reserve(seq.size()); + for (epvector::const_iterator i=seq.begin(); i!=seq.end(); ++i) + newseq.push_back(expair(i->rest.expand(), i->coeff)); + return (new pseries(relational(var,point), newseq)) + ->setflag(status_flags::dynallocated | + status_flags::expanded); +} + + /** Implementation of ex::diff() for a power series. It treats the series as a * polynomial. * @see ex::diff */ @@ -403,7 +438,7 @@ ex pseries::derivative(const symbol & s) const if (!c.is_zero()) new_seq.push_back(expair(c, it->coeff - 1)); } - it++; + ++it; } return pseries(relational(var,point), new_seq); } else { @@ -430,11 +465,18 @@ ex pseries::convert_to_poly(bool no_order) const e += Order(power(var - point, it->coeff)); } else e += it->rest * power(var - point, it->coeff); - it++; + ++it; } return e; } +/** Returns true if there is no order term, i.e. the series terminates and + * false otherwise. */ +bool pseries::is_terminating(void) const +{ + return !is_order_function((seq.end()-1)->rest); +} + /* * Implementation of series expansion @@ -442,7 +484,7 @@ ex pseries::convert_to_poly(bool no_order) const /** Default implementation of ex::series(). This performs Taylor expansion. * @see ex::series */ -ex basic::series(const relational & r, int order) const +ex basic::series(const relational & r, int order, bool branchcut) const { epvector seq; numeric fac(1); @@ -461,14 +503,14 @@ ex basic::series(const relational & r, int order) const // Series terminates return pseries(r, seq); } - coeff = fac.inverse() * deriv.subs(r); + coeff = deriv.subs(r); if (!coeff.is_zero()) - seq.push_back(expair(coeff, numeric(n))); + seq.push_back(expair(fac.inverse() * coeff, numeric(n))); } // Higher-order terms, if present deriv = deriv.diff(*s); - if (!deriv.is_zero()) + if (!deriv.expand().is_zero()) seq.push_back(expair(Order(_ex1()), numeric(n))); return pseries(r, seq); } @@ -476,7 +518,7 @@ ex basic::series(const relational & r, int order) const /** Implementation of ex::series() for symbols. * @see ex::series */ -ex symbol::series(const relational & r, int order) const +ex symbol::series(const relational & r, int order, bool branchcut) const { epvector seq; const ex point = r.rhs(); @@ -523,7 +565,7 @@ ex pseries::add_series(const pseries &other) const if (a == a_end) { while (b != b_end) { new_seq.push_back(*b); - b++; + ++b; } break; } else @@ -533,7 +575,7 @@ ex pseries::add_series(const pseries &other) const if (b == b_end) { while (a != a_end) { new_seq.push_back(*a); - a++; + ++a; } break; } else @@ -545,13 +587,13 @@ ex pseries::add_series(const pseries &other) const new_seq.push_back(*a); if (is_order_function((*a).rest)) break; - a++; + ++a; } else if (pow_b < pow_a) { // b has lesser power, get coefficient from b new_seq.push_back(*b); if (is_order_function((*b).rest)) break; - b++; + ++b; } else { // Add coefficient of a and b if (is_order_function((*a).rest) || is_order_function((*b).rest)) { @@ -561,8 +603,8 @@ ex pseries::add_series(const pseries &other) const ex sum = (*a).rest + (*b).rest; if (!(sum.is_zero())) new_seq.push_back(expair(sum, numeric(pow_a))); - a++; - b++; + ++a; + ++b; } } } @@ -573,22 +615,22 @@ ex pseries::add_series(const pseries &other) const /** Implementation of ex::series() for sums. This performs series addition when * adding pseries objects. * @see ex::series */ -ex add::series(const relational & r, int order) const +ex add::series(const relational & r, int order, bool branchcut) const { ex acc; // Series accumulator // Get first term from overall_coeff - acc = overall_coeff.series(r, order); + acc = overall_coeff.series(r, order, branchcut); // Add remaining terms epvector::const_iterator it = seq.begin(); epvector::const_iterator itend = seq.end(); - for (; it!=itend; it++) { + for (; it!=itend; ++it) { ex op; if (is_ex_exactly_of_type(it->rest, pseries)) op = it->rest; else - op = it->rest.series(r, order); + op = it->rest.series(r, order, branchcut); if (!it->coeff.is_equal(_ex1())) op = ex_to_pseries(op).mul_const(ex_to_numeric(it->coeff)); @@ -615,7 +657,7 @@ ex pseries::mul_const(const numeric &other) const new_seq.push_back(expair(it->rest * other, it->coeff)); else new_seq.push_back(*it); - it++; + ++it; } return pseries(relational(var,point), new_seq); } @@ -653,14 +695,14 @@ ex pseries::mul_series(const pseries &other) const higher_order_a = a_max + b_min; if (is_order_function(other.coeff(*s, b_max))) higher_order_b = b_max + a_min; - int higher_order_c = min(higher_order_a, higher_order_b); + int higher_order_c = std::min(higher_order_a, higher_order_b); if (cdeg_max >= higher_order_c) cdeg_max = higher_order_c - 1; - for (int cdeg=cdeg_min; cdeg<=cdeg_max; cdeg++) { + for (int cdeg=cdeg_min; cdeg<=cdeg_max; ++cdeg) { ex co = _ex0(); // c(i)=a(0)b(i)+...+a(i)b(0) - for (int i=a_min; cdeg-i>=b_min; i++) { + for (int i=a_min; cdeg-i>=b_min; ++i) { ex a_coeff = coeff(*s, i); ex b_coeff = other.coeff(*s, cdeg-i); if (!is_order_function(a_coeff) && !is_order_function(b_coeff)) @@ -678,17 +720,17 @@ ex pseries::mul_series(const pseries &other) const /** Implementation of ex::series() for product. This performs series * multiplication when multiplying series. * @see ex::series */ -ex mul::series(const relational & r, int order) const +ex mul::series(const relational & r, int order, bool branchcut) const { ex acc; // Series accumulator // Get first term from overall_coeff - acc = overall_coeff.series(r, order); + acc = overall_coeff.series(r, order, branchcut); // Multiply with remaining terms epvector::const_iterator it = seq.begin(); epvector::const_iterator itend = seq.end(); - for (; it!=itend; it++) { + for (; it!=itend; ++it) { ex op = it->rest; if (op.info(info_flags::numeric)) { // series * const (special case, faster) @@ -696,7 +738,7 @@ ex mul::series(const relational & r, int order) const acc = ex_to_pseries(acc).mul_const(ex_to_numeric(f)); continue; } else if (!is_ex_exactly_of_type(op, pseries)) - op = op.series(r, order); + op = op.series(r, order, branchcut); if (!it->coeff.is_equal(_ex1())) op = ex_to_pseries(op).power_const(ex_to_numeric(it->coeff), order); @@ -723,9 +765,9 @@ ex pseries::power_const(const numeric &p, int deg) const ex co0; co.push_back(co0 = power(coeff(*s, ldeg), p)); bool all_sums_zero = true; - for (i=1; icoeff = i->coeff + deg; + return pseries(relational(var, point), newseq); +} + + /** Implementation of ex::series() for powers. This performs Laurent expansion * of reciprocals of series at singularities. * @see ex::series */ -ex power::series(const relational & r, int order) const +ex power::series(const relational & r, int order, bool branchcut) const { ex e; if (!is_ex_exactly_of_type(basis, pseries)) { // Basis is not a series, may there be a singulary? if (!exponent.info(info_flags::negint)) - return basic::series(r, order); + return basic::series(r, order, branchcut); // Expression is of type something^(-int), check for singularity if (!basis.subs(r).is_zero()) - return basic::series(r, order); + return basic::series(r, order, branchcut); // Singularity encountered, expand basis into series - e = basis.series(r, order); + e = basis.series(r, order, branchcut); } else { // Basis is a series e = basis; @@ -783,7 +835,7 @@ ex power::series(const relational & r, int order) const /** Re-expansion of a pseries object. */ -ex pseries::series(const relational & r, int order) const +ex pseries::series(const relational & r, int order, bool branchcut) const { const ex p = r.rhs(); GINAC_ASSERT(is_ex_exactly_of_type(r.lhs(),symbol)); @@ -802,12 +854,12 @@ ex pseries::series(const relational & r, int order) const break; } new_seq.push_back(*it); - it++; + ++it; } return pseries(r, new_seq); } } else - return convert_to_poly().series(r, order); + return convert_to_poly().series(r, order, branchcut); } @@ -818,8 +870,9 @@ ex pseries::series(const relational & r, int order) const * * @param r expansion relation, lhs holds variable and rhs holds point * @param order truncation order of series calculations + * @param branchcut when set to false, branch cuts are not honored * @return an expression holding a pseries object */ -ex ex::series(const ex & r, int order) const +ex ex::series(const ex & r, int order, bool branchcut) const { GINAC_ASSERT(bp!=0); ex e; @@ -833,9 +886,9 @@ ex ex::series(const ex & r, int order) const throw (std::logic_error("ex::series(): expansion point has unknown type")); try { - e = bp->series(rel_, order); - } catch (exception &x) { - throw (std::logic_error(string("unable to compute series (") + x.what() + ")")); + e = bp->series(rel_, order, branchcut); + } catch (std::exception &x) { + throw (std::logic_error(std::string("unable to compute series (") + x.what() + ")")); } return e; } diff --git a/ginac/pseries.h b/ginac/pseries.h index a0a494ee..f7c32aa5 100644 --- a/ginac/pseries.h +++ b/ginac/pseries.h @@ -55,21 +55,22 @@ public: // functions overriding virtual functions from base classes public: basic *duplicate() const; - void print(ostream &os, unsigned upper_precedence=0) const; - void printraw(ostream &os) const; - void printtree(ostream & os, unsigned indent) const; + void print(std::ostream &os, unsigned upper_precedence = 0) const; + void printraw(std::ostream &os) const; + void printtree(std::ostream & os, unsigned indent) const; unsigned nops(void) const; ex op(int i) const; ex &let_op(int i); int degree(const symbol &s) const; int ldegree(const symbol &s) const; - ex coeff(const symbol &s, int n=1) const; + ex coeff(const symbol &s, int n = 1) const; ex collect(const symbol &s) const; ex eval(int level=0) const; ex evalf(int level=0) const; - ex series(const relational & r, int order) const; - ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; + ex series(const relational & r, int order, bool branchcut = true) const; ex subs(const lst & ls, const lst & lr) const; + ex normal(lst &sym_lst, lst &repl_lst, int level = 0) const; + ex expand(unsigned options = 0) const; protected: ex derivative(const symbol & s) const; @@ -78,10 +79,12 @@ public: ex convert_to_poly(bool no_order = false) const; bool is_compatible_to(const pseries &other) const {return var.compare(other.var) == 0 && point.compare(other.point) == 0;} bool is_zero(void) const {return seq.size() == 0;} + bool is_terminating(void) const; ex add_series(const pseries &other) const; ex mul_const(const numeric &other) const; ex mul_series(const pseries &other) const; ex power_const(const numeric &p, int deg) const; + pseries shift_exponents(int deg) const; protected: /** Vector of {coefficient, power} pairs */ @@ -123,6 +126,11 @@ inline ex series_to_poly(const ex &e) return (static_cast(*e.bp).convert_to_poly(true)); } +inline bool is_terminating(const pseries & s) +{ + return s.is_terminating(); +} + #ifndef NO_NAMESPACE_GINAC } // namespace GiNaC #endif // ndef NO_NAMESPACE_GINAC diff --git a/ginac/registrar.cpp b/ginac/registrar.cpp index f95b2013..2488be55 100644 --- a/ginac/registrar.cpp +++ b/ginac/registrar.cpp @@ -32,7 +32,7 @@ namespace GiNaC { registered_class_info *first_registered_class = NULL; /** Find registered_class_info strucure by class name. */ -static inline registered_class_info *find_registered_class_info(const string &class_name) +static inline registered_class_info *find_registered_class_info(const std::string &class_name) { registered_class_info *p = first_registered_class; while (p) { @@ -43,13 +43,13 @@ static inline registered_class_info *find_registered_class_info(const string &cl throw (std::runtime_error("class '" + class_name + "' not registered")); } -unsigned int find_tinfo_key(const string &class_name) +unsigned int find_tinfo_key(const std::string &class_name) { registered_class_info *p = find_registered_class_info(class_name); return p->tinfo_key; } -unarch_func find_unarch_func(const string &class_name) +unarch_func find_unarch_func(const std::string &class_name) { registered_class_info *p = find_registered_class_info(class_name); return p->unarchive; diff --git a/ginac/registrar.h b/ginac/registrar.h index 1473bbb8..8c2e6d68 100644 --- a/ginac/registrar.h +++ b/ginac/registrar.h @@ -79,10 +79,10 @@ private: /** Find TINFO_* key by class name. */ -extern unsigned int find_tinfo_key(const string &class_name); +extern unsigned int find_tinfo_key(const std::string &class_name); /** Find unarchiving function by class name. */ -extern unarch_func find_unarch_func(const string &class_name); +extern unarch_func find_unarch_func(const std::string &class_name); #ifndef NO_NAMESPACE_GINAC diff --git a/ginac/relational.cpp b/ginac/relational.cpp index 55b70544..b2726acd 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -139,7 +139,7 @@ basic * relational::duplicate() const return new relational(*this); } -void relational::print(ostream & os, unsigned upper_precedence) const +void relational::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("relational print",LOGLEVEL_PRINT); if (precedence<=upper_precedence) os << "("; @@ -170,7 +170,7 @@ void relational::print(ostream & os, unsigned upper_precedence) const if (precedence<=upper_precedence) os << ")"; } -void relational::printraw(ostream & os) const +void relational::printraw(std::ostream & os) const { debugmsg("relational printraw",LOGLEVEL_PRINT); os << "RELATIONAL("; @@ -203,7 +203,7 @@ void relational::printraw(ostream & os) const os << ")"; } -void relational::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void relational::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("relational print csrc", LOGLEVEL_PRINT); if (precedence<=upper_precedence) @@ -364,8 +364,6 @@ ex relational::rhs(void) const // non-virtual functions in this class ////////// -#include - relational::operator bool() const { // please note that (a=b) == true diff --git a/ginac/relational.h b/ginac/relational.h index ae78c239..48b59719 100644 --- a/ginac/relational.h +++ b/ginac/relational.h @@ -65,9 +65,9 @@ public: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printraw(ostream & os) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; bool info(unsigned inf) const; unsigned nops() const; ex & let_op(int i); diff --git a/ginac/remember.cpp b/ginac/remember.cpp index b3307d3c..21e19716 100644 --- a/ginac/remember.cpp +++ b/ginac/remember.cpp @@ -38,7 +38,7 @@ namespace GiNaC { remember_table_entry::remember_table_entry(function const & f, ex const & r) : hashvalue(f.gethash()), seq(f.seq), result(r) { - last_access=access_counter++; + ++last_access=access_counter; successful_hits=0; } @@ -49,8 +49,8 @@ bool remember_table_entry::is_equal(function const & f) const for (unsigned i=0; i & remember_table::remember_tables(void) +std::vector & remember_table::remember_tables(void) { - static vector * rt=new vector; + static std::vector * rt = new std::vector; return *rt; } diff --git a/ginac/remember.h b/ginac/remember.h index 403e3edb..78ce547e 100644 --- a/ginac/remember.h +++ b/ginac/remember.h @@ -57,7 +57,7 @@ protected: /** A list of entries in the remember table having some least significant bits of the hashvalue in common. */ -class remember_table_list : public list { +class remember_table_list : public std::list { public: remember_table_list(unsigned as, unsigned strat); void add_entry(function const & f, ex const & result); @@ -81,15 +81,15 @@ protected: - least recently used (the one with the lowest 'last_access') - least frequently used (the one with the lowest 'successful_hits') or all entries are kept which means that the table grows indefinitely. */ -class remember_table : public vector { +class remember_table : public std::vector { public: remember_table(); remember_table(unsigned s, unsigned as, unsigned strat); bool lookup_entry(function const & f, ex & result) const; void add_entry(function const & f, ex const & result); void clear_all_entries(void); - void show_statistics(ostream & os, unsigned level) const; - static vector & remember_tables(void); + void show_statistics(std::ostream & os, unsigned level) const; + static std::vector & remember_tables(void); protected: void init_table(void); unsigned table_size; diff --git a/ginac/simp_lor.cpp b/ginac/simp_lor.cpp index c5d5f9eb..4865561a 100644 --- a/ginac/simp_lor.cpp +++ b/ginac/simp_lor.cpp @@ -109,7 +109,7 @@ simp_lor::simp_lor(simp_lor_types const t, const ex & i1, const ex & i2) : GINAC_ASSERT(all_of_type_lorentzidx()); } -simp_lor::simp_lor(simp_lor_types const t, const string & n, const ex & i1) : +simp_lor::simp_lor(simp_lor_types const t, const std::string & n, const ex & i1) : indexed(i1), type(t), name(n) { debugmsg("simp_lor constructor from simp_lor_types,string,ex",LOGLEVEL_CONSTRUCT); @@ -117,7 +117,7 @@ simp_lor::simp_lor(simp_lor_types const t, const string & n, const ex & i1) : GINAC_ASSERT(all_of_type_lorentzidx()); } -simp_lor::simp_lor(simp_lor_types const t, const string & n, const exvector & iv) : +simp_lor::simp_lor(simp_lor_types const t, const std::string & n, const exvector & iv) : indexed(iv), type(t), name(n) { debugmsg("simp_lor constructor from simp_lor_types,string,exvector",LOGLEVEL_CONSTRUCT); @@ -125,7 +125,7 @@ simp_lor::simp_lor(simp_lor_types const t, const string & n, const exvector & iv GINAC_ASSERT(all_of_type_lorentzidx()); } -simp_lor::simp_lor(simp_lor_types const t, const string & n, exvector * ivp) : +simp_lor::simp_lor(simp_lor_types const t, const std::string & n, exvector * ivp) : indexed(ivp), type(t), name(n) { debugmsg("simp_lor constructor from simp_lor_types,string,exvector*",LOGLEVEL_CONSTRUCT); @@ -145,7 +145,7 @@ basic * simp_lor::duplicate() const return new simp_lor(*this); } -void simp_lor::printraw(ostream & os) const +void simp_lor::printraw(std::ostream & os) const { debugmsg("simp_lor printraw",LOGLEVEL_PRINT); os << "simp_lor(type=" << (unsigned)type @@ -154,20 +154,20 @@ void simp_lor::printraw(ostream & os) const os << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void simp_lor::printtree(ostream & os, unsigned indent) const +void simp_lor::printtree(std::ostream & os, unsigned indent) const { debugmsg("simp_lor printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "simp_lor object: " + os << std::string(indent,' ') << "simp_lor object: " << "type=" << (unsigned)type << ", name=" << name << ", "; - os << seq.size() << " indices" << endl; + os << seq.size() << " indices" << std::endl; printtreeindices(os,indent); - os << string(indent,' ') << "hash=" << hashvalue - << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + os << std::string(indent,' ') << "hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void simp_lor::print(ostream & os, unsigned upper_precedence) const +void simp_lor::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("simp_lor print",LOGLEVEL_PRINT); switch (type) { @@ -185,7 +185,7 @@ void simp_lor::print(ostream & os, unsigned upper_precedence) const printindices(os); } -void simp_lor::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void simp_lor::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("simp_lor print csrc",LOGLEVEL_PRINT); print(os,upper_precedence); @@ -314,7 +314,7 @@ bool simp_lor::all_of_type_lorentzidx(void) const ////////// const simp_lor some_simp_lor; -const type_info & typeid_simp_lor=typeid(some_simp_lor); +const type_info & typeid_simp_lor = typeid(some_simp_lor); ////////// // friend functions @@ -325,7 +325,7 @@ simp_lor lor_g(const ex & mu, const ex & nu) return simp_lor(simp_lor::simp_lor_g,mu,nu); } -simp_lor lor_vec(const string & n, const ex & mu) +simp_lor lor_vec(const std::string & n, const ex & mu) { return simp_lor(simp_lor::simp_lor_vec,n,mu); } @@ -497,13 +497,13 @@ ex scalar_products::evaluate(const simp_lor & v1, const simp_lor & v2) const void scalar_products::debugprint(void) const { - cerr << "map size=" << spm.size() << endl; + std::cerr << "map size=" << spm.size() << std::endl; for (spmap::const_iterator cit=spm.begin(); cit!=spm.end(); ++cit) { const spmapkey & k=(*cit).first; - cerr << "item key=((" << k.first.first - << "," << k.first.second << "),"; + std::cerr << "item key=((" << k.first.first + << "," << k.first.second << "),"; k.second.printraw(cerr); - cerr << ") value=" << (*cit).second << endl; + cerr << ") value=" << (*cit).second << std::endl; } } diff --git a/ginac/simp_lor.h b/ginac/simp_lor.h index 77e7c4d9..677a4c25 100644 --- a/ginac/simp_lor.h +++ b/ginac/simp_lor.h @@ -35,8 +35,8 @@ namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC -typedef pair strstrpair; -typedef pair spmapkey; +typedef std::pair strstrpair; +typedef std::pair spmapkey; class spmapkey_is_less { @@ -87,7 +87,7 @@ class simp_lor : public indexed friend class scalar_products; friend simp_lor lor_g(const ex & mu, const ex & nu); - friend simp_lor lor_vec(const string & n, const ex & mu); + friend simp_lor lor_vec(const std::string & n, const ex & mu); friend ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp); friend ex simplify_simp_lor(const ex & e, const scalar_products & sp); @@ -115,17 +115,17 @@ protected: protected: simp_lor(simp_lor_types const t); simp_lor(simp_lor_types const t, const ex & i1, const ex & i2); - simp_lor(simp_lor_types const t, const string & n, const ex & i1); - simp_lor(simp_lor_types const t, const string & n, const exvector & iv); - simp_lor(simp_lor_types const t, const string & n, exvector * ivp); + simp_lor(simp_lor_types const t, const std::string & n, const ex & i1); + simp_lor(simp_lor_types const t, const std::string & n, const exvector & iv); + simp_lor(simp_lor_types const t, const std::string & n, exvector * ivp); // functions overriding virtual functions from base classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; bool info(unsigned inf) const; ex eval(int level=0) const; protected: @@ -147,7 +147,7 @@ protected: protected: simp_lor_types type; - string name; + std::string name; }; // global constants @@ -167,7 +167,7 @@ inline simp_lor &ex_to_nonconst_simp_lor(const ex &e) } simp_lor lor_g(const ex & mu, const ex & nu); -simp_lor lor_vec(const string & n, const ex & mu); +simp_lor lor_vec(const std::string & n, const ex & mu); ex simplify_simp_lor_mul(const ex & m, const scalar_products & sp); ex simplify_simp_lor(const ex & e, const scalar_products & sp=scalar_products()); ex Dim(void); diff --git a/ginac/structure.cpp b/ginac/structure.cpp index 4e27c49e..50e93a4d 100644 --- a/ginac/structure.cpp +++ b/ginac/structure.cpp @@ -93,30 +93,31 @@ basic * structure::duplicate() const return new structure(*this); } -void structure::printraw(ostream & os) const +void structure::printraw(std::ostream & os) const { debugmsg("structure printraw",LOGLEVEL_PRINT); os << "structure(hash=" << hashvalue << ",flags=" << flags << ")"; } -void structure::print(ostream & os, unsigned upper_precedence) const +void structure::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("structure print",LOGLEVEL_PRINT); os << "structure()"; } -void structure::printtree(ostream & os, unsigned indent) const +void structure::printtree(std::ostream & os, unsigned indent) const { debugmsg("structure printtree",LOGLEVEL_PRINT); - os << string(indent,' ') << "structure " - << "hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + os << std::string(indent,' ') << "structure " + << "hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void structure::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void structure::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("structure print csrc",LOGLEVEL_PRINT); @@ -149,9 +150,9 @@ bool structure::is_equal_same_type(const basic & other) const // protected -vector & structure::registered_structures(void) +std::vector & structure::registered_structures(void) { - static vector * rs=new vector; + static std::vector * rs = new std::vector; return *rs; } diff --git a/ginac/structure.h b/ginac/structure.h index 5bd74685..358e6ce6 100644 --- a/ginac/structure.h +++ b/ginac/structure.h @@ -59,10 +59,10 @@ protected: // functions overriding virtual functions from bases classes public: basic * duplicate() const; - void printraw(ostream & os) const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printtree(ostream & os, unsigned indent) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void printraw(std::ostream & os) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printtree(std::ostream & os, unsigned indent) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; protected: int compare_same_type(const basic & other) const; bool is_equal_same_type(const basic & other) const; @@ -72,7 +72,7 @@ protected: // non-virtual functions in this class protected: - static vector & registered_structures(void); + static std::vector & registered_structures(void); public: static unsigned register_new(const char * nm); diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index 4f05c6e6..b7408fa6 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -148,29 +148,30 @@ basic *symbol::duplicate() const return new symbol(*this); } -void symbol::print(ostream & os, unsigned upper_precedence) const +void symbol::print(std::ostream & os, unsigned upper_precedence) const { debugmsg("symbol print",LOGLEVEL_PRINT); os << name; } -void symbol::printraw(ostream & os) const +void symbol::printraw(std::ostream & os) const { debugmsg("symbol printraw",LOGLEVEL_PRINT); os << "symbol(" << "name=" << name << ",serial=" << serial << ",hash=" << hashvalue << ",flags=" << flags << ")"; } -void symbol::printtree(ostream & os, unsigned indent) const +void symbol::printtree(std::ostream & os, unsigned indent) const { debugmsg("symbol printtree",LOGLEVEL_PRINT); os << std::string(indent,' ') << name << " (symbol): " << "serial=" << serial - << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")" - << ", flags=" << flags << endl; + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags << std::endl; } -void symbol::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const +void symbol::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const { debugmsg("symbol print csrc", LOGLEVEL_PRINT); os << name; @@ -349,7 +350,7 @@ std::string & symbol::autoname_prefix(void) unsigned symbol::next_serial=0; -// string const symbol::autoname_prefix="symbol"; +// std::string const symbol::autoname_prefix="symbol"; ////////// // global constants diff --git a/ginac/symbol.h b/ginac/symbol.h index 55f20449..1a51ffb4 100644 --- a/ginac/symbol.h +++ b/ginac/symbol.h @@ -70,19 +70,19 @@ public: // functions overriding virtual functions from base classes public: basic * duplicate() const; - void print(ostream & os, unsigned upper_precedence=0) const; - void printraw(ostream & os) const; - void printtree(ostream & os, unsigned indent) const; - void printcsrc(ostream & os, unsigned type, unsigned upper_precedence=0) const; + void print(std::ostream & os, unsigned upper_precedence = 0) const; + void printraw(std::ostream & os) const; + void printtree(std::ostream & os, unsigned indent) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence = 0) const; bool info(unsigned inf) const; - ex expand(unsigned options=0) const; + ex expand(unsigned options = 0) const; bool has(const ex & other) const; int degree(const symbol & s) const; int ldegree(const symbol & s) const; ex coeff(const symbol & s, int n = 1) const; ex eval(int level = 0) const; - ex series(const relational & s, int order) const; - ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; + ex series(const relational & s, int order, bool branchcut = true) const; + ex normal(lst &sym_lst, lst &repl_lst, int level = 0) const; ex to_rational(lst &repl_lst) const; ex subs(const lst & ls, const lst & lr) const; protected: @@ -97,8 +97,8 @@ protected: public: void assign(const ex & value); void unassign(void); - void setname(const std::string & n) {name=n;} - std::string getname(void) const {return name;} + void setname(const std::string & n) { name = n; } + std::string getname(void) const { return name; } private: std::string & autoname_prefix(void); diff --git a/ginac/utils.cpp b/ginac/utils.cpp index 5a92a31c..513b5796 100644 --- a/ginac/utils.cpp +++ b/ginac/utils.cpp @@ -29,6 +29,21 @@ namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC +/** ctor for pole_error exception class. */ +pole_error::pole_error(const std::string& what_arg, int degree) + : domain_error(what_arg) +{ + deg = degree; +} + +/** Return the degree of the pole_error exception class. */ +int pole_error::degree(void) const +{ + return deg; +} + +// some compilers (e.g. cygwin) define a macro log2, causing confusion +#ifndef log2 /** Integer binary logarithm */ unsigned log2(unsigned n) { @@ -36,6 +51,7 @@ unsigned log2(unsigned n) for (k = 0; n > 1; n >>= 1) ++k; return k; } +#endif /** Compare two pointers (just to establish some sort of canonical order). * @return -1, 0, or 1 */ diff --git a/ginac/utils.h b/ginac/utils.h index 107a6f52..2aff369f 100644 --- a/ginac/utils.h +++ b/ginac/utils.h @@ -26,6 +26,7 @@ #include #include +#include #include "config.h" #include "assertion.h" @@ -33,19 +34,29 @@ namespace GiNaC { #endif // ndef NO_NAMESPACE_GINAC +// This should be obsoleted once is widely available. template -string ToString(const T & t) +std::string ToString(const T & t) { char buf[256]; - ostrstream(buf,sizeof(buf)) << t << ends; + std::ostrstream(buf,sizeof(buf)) << t << std::ends; return buf; } -/** Exception thrown by classes which provide their own series expansion to - * signal that ordinary Taylor expansion is safe. */ +/** Exception class thrown by classes which provide their own series expansion + * to signal that ordinary Taylor expansion is safe. */ class do_taylor {}; -// cygwin defines a macro log2, causing confusion +/** Exception class thrown when a singularity is encountered. */ +class pole_error : public std::domain_error { +public: + explicit pole_error(const std::string& what_arg, int degree); + int degree(void) const; +private: + int deg; +}; + +// some compilers (e.g. cygwin) define a macro log2, causing confusion #ifndef log2 unsigned log2(unsigned n); #endif @@ -143,13 +154,13 @@ OutputIterator mymerge3(InputIterator1 first1, InputIterator1 last1, // Compute the sign of a permutation of a vector of things. template -int permutation_sign(vector s) +int permutation_sign(std::vector s) { if (s.size() < 2) return 0; int sigma = 1; - for (typename vector::iterator i=s.begin(); i!=s.end()-1; ++i) { - for (typename vector::iterator j=i+1; j!=s.end(); ++j) { + for (typename std::vector::iterator i=s.begin(); i!=s.end()-1; ++i) { + for (typename std::vector::iterator j=i+1; j!=s.end(); ++j) { if (*i == *j) return 0; if (*i > *j) { diff --git a/ginac/version.h b/ginac/version.h index 385b35de..35801017 100644 --- a/ginac/version.h +++ b/ginac/version.h @@ -26,6 +26,6 @@ /* Major, minor, and micro version number of the GiNaC library. */ #define GINACLIB_MAJOR_VERSION 0 #define GINACLIB_MINOR_VERSION 6 -#define GINACLIB_MICRO_VERSION 2 +#define GINACLIB_MICRO_VERSION 3 #endif // ndef __GINAC_VERSION_H__ diff --git a/ginsh/Makefile.in b/ginsh/Makefile.in index 2ab86bd0..c1f82be4 100644 --- a/ginsh/Makefile.in +++ b/ginsh/Makefile.in @@ -82,6 +82,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -94,6 +95,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ @@ -453,11 +455,11 @@ maintainer-clean-generic clean mostlyclean distclean maintainer-clean # files created by sed scripts -ginsh_fcn_help.c: ginsh.1 ginsh_fcn_help.sed - sed -n -f ginsh_fcn_help.sed <$< >$@ +ginsh_fcn_help.c: ginsh.1 $(srcdir)/ginsh_fcn_help.sed + sed -n -f $(srcdir)/ginsh_fcn_help.sed <$< >$@ -ginsh_op_help.c: ginsh.1 ginsh_op_help.sed - sed -n -f ginsh_op_help.sed <$< >$@ +ginsh_op_help.c: ginsh.1 $(srcdir)/ginsh_op_help.sed + sed -n -f $(srcdir)/ginsh_op_help.sed <$< >$@ ginsh_parser.o: ginsh_fcn_help.c ginsh_op_help.c diff --git a/ginsh/ginsh_parser.yy b/ginsh/ginsh_parser.yy index 646cb020..d792a242 100644 --- a/ginsh/ginsh_parser.yy +++ b/ginsh/ginsh_parser.yy @@ -176,6 +176,13 @@ line : ';' cout << (syms.size() > 350 ? 350 : syms.size()); cout << " out of a possible 350.\n"; } + | T_TIME {getrusage(RUSAGE_SELF, &start_time);} '(' exp ')' { + getrusage(RUSAGE_SELF, &end_time); + cout << (end_time.ru_utime.tv_sec - start_time.ru_utime.tv_sec) + + (end_time.ru_stime.tv_sec - start_time.ru_stime.tv_sec) + + double(end_time.ru_utime.tv_usec - start_time.ru_utime.tv_usec) / 1e6 + + double(end_time.ru_stime.tv_usec - start_time.ru_stime.tv_usec) / 1e6 << 's' << endl; + } | error ';' {yyclearin; yyerrok;} | error ':' {yyclearin; yyerrok;} ; @@ -188,13 +195,6 @@ exp : T_NUMBER {$$ = $1;} | T_QUOTE {$$ = exstack[0];} | T_QUOTE2 {$$ = exstack[1];} | T_QUOTE3 {$$ = exstack[2];} - | T_TIME {getrusage(RUSAGE_SELF, &start_time);} '(' exp ')' { - getrusage(RUSAGE_SELF, &end_time); - $$ = (end_time.ru_utime.tv_sec - start_time.ru_utime.tv_sec) + - (end_time.ru_stime.tv_sec - start_time.ru_stime.tv_sec) + - double(end_time.ru_utime.tv_usec - start_time.ru_utime.tv_usec) / 1e6 + - double(end_time.ru_stime.tv_usec - start_time.ru_stime.tv_usec) / 1e6; - } | T_SYMBOL '(' exprseq ')' { fcn_tab::const_iterator i = find_function($1, $3.nops()); if (i->second.is_ginac) { diff --git a/tools/Makefile.in b/tools/Makefile.in index e12b3036..f6c3caf0 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -82,6 +82,7 @@ GINACLIB_MINOR_VERSION = @GINACLIB_MINOR_VERSION@ GINACLIB_VERSION = @GINACLIB_VERSION@ GINSH_LIBS = @GINSH_LIBS@ LATEX = @LATEX@ +LD = @LD@ LEX = @LEX@ LIBTERMCAP = @LIBTERMCAP@ LIBTOOL = @LIBTOOL@ @@ -94,6 +95,7 @@ MAINT = @MAINT@ MAKECINT = @MAKECINT@ MAKEINDEX = @MAKEINDEX@ MAKEINFO = @MAKEINFO@ +NM = @NM@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ diff --git a/tools/viewgar.cpp b/tools/viewgar.cpp index 5568c51e..cd8921fd 100644 --- a/tools/viewgar.cpp +++ b/tools/viewgar.cpp @@ -1,7 +1,8 @@ /** @file viewgar.cpp * - * GiNaC archive file viewer - * + * GiNaC archive file viewer. */ + +/* * GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -36,7 +37,7 @@ int main(int argc, char **argv) fprintf(stderr, "Usage: %s [-d] file...\n", argv[0]); exit(1); } - argc--; argv++; + --argc; ++argv; bool dump_mode = false; try { @@ -44,24 +45,24 @@ int main(int argc, char **argv) while (argc) { if (strcmp(*argv, "-d") == 0) { dump_mode = true; - argc--; argv++; + --argc; ++argv; } - ifstream f(*argv); + std::ifstream f(*argv); archive ar; f >> ar; if (dump_mode) { - ar.printraw(cout); - cout << endl; + ar.printraw(std::cout); + std::cout << std::endl; } else { - for (unsigned int i=0; i