GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
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
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
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"
# 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
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"
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_SUBST(LD)
AC_PROG_LD_GNU
])
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
;;
GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
errorflag = true;
}
}
- if (errorflag) {
+ if (errorflag)
++result;
- }
return result;
}
errorflag = true;
}
}
- if (errorflag) {
+ if (errorflag)
++result;
- }
return result;
}
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;
}
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;
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;
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;
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());
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;
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;
GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
#include <strstream>
template<class T>
-string ToString(const T & t)
+std::string ToString(const T & t)
{
char buf[256];
ostrstream(buf,sizeof(buf)) << t << ends;
#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<char *> 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);
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);
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;");
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)||
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;
}
}
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 <MXJ02154@niftyserve.or.jp>.\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 <MXJ02154@niftyserve.or.jp>.\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;
}
* 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;
{
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);
}
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");
}
/** 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") {
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;
}
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;
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);
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)) {
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));
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;
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;
}
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);
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;
}
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);
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;
}
# 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
| 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)
;;
| 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.
basic_machine=t3e-cray
os=-unicos
;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
tx39)
basic_machine=mipstx39-unknown
;;
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
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
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
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
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"
# 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"
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 <<EOF
-#line 1683 "configure"
+
+ 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
+
+ cat > conftest.$ac_ext <<EOF
+#line 1688 "configure"
#include "confdefs.h"
int main() {
; return 0; }
EOF
-if { (eval echo configure:1690: \"$ac_link\") 1>&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
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
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
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=
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
-#line 1807 "configure"
+#line 1819 "configure"
#include "confdefs.h"
#include <assert.h>
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
:
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
-#line 1824 "configure"
+#line 1836 "configure"
#include "confdefs.h"
#include <assert.h>
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
:
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
-#line 1841 "configure"
+#line 1853 "configure"
#include "confdefs.h"
#include <assert.h>
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
:
# 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
# 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
*) 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
ac_save_LIBS="$LIBS"
LIBS="-l$ac_lib $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 1952 "configure"
+#line 1964 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
yywrap()
; return 0; }
EOF
-if { (eval echo configure:1963: \"$ac_link\") 1>&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
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
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
ac_save_LIBS="$LIBS"
LIBS="$LIBS $LEXLIB"
cat > conftest.$ac_ext <<EOF
-#line 2019 "configure"
+#line 2031 "configure"
#include "confdefs.h"
`cat $LEX_OUTPUT_ROOT.c`
int main() {
; return 0; }
EOF
-if { (eval echo configure:2026: \"$ac_link\") 1>&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
# 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
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
ac_cv_sizeof_long=4
else
cat > conftest.$ac_ext <<EOF
-#line 2117 "configure"
+#line 2129 "configure"
#include "confdefs.h"
#include <stdio.h>
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
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
ac_cv_sizeof_long_long=8
else
cat > conftest.$ac_ext <<EOF
-#line 2156 "configure"
+#line 2168 "configure"
#include "confdefs.h"
#include <stdio.h>
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
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
ac_cv_sizeof_long_double=12
else
cat > conftest.$ac_ext <<EOF
-#line 2195 "configure"
+#line 2207 "configure"
#include "confdefs.h"
#include <stdio.h>
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
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
-#line 2243 "configure"
+#line 2255 "configure"
#include "confdefs.h"
#include <$ac_hdr>
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*
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
-#line 2283 "configure"
+#line 2295 "configure"
#include "confdefs.h"
#include <$ac_hdr>
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*
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 <<EOF
-#line 2330 "configure"
+#line 2342 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
; return 0; }
EOF
-if { (eval echo configure:2356: \"$ac_link\") 1>&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
:
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
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2392 "configure"
+#line 2404 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
tgetent()
; return 0; }
EOF
-if { (eval echo configure:2406: \"$ac_link\") 1>&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
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
ac_save_LIBS="$LIBS"
LIBS="-ltermcap $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2436 "configure"
+#line 2448 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
tgetent()
; return 0; }
EOF
-if { (eval echo configure:2450: \"$ac_link\") 1>&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
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
ac_save_LIBS="$LIBS"
LIBS="-lreadline $LIBS"
cat > conftest.$ac_ext <<EOF
-#line 2485 "configure"
+#line 2497 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
readline()
; return 0; }
EOF
-if { (eval echo configure:2499: \"$ac_link\") 1>&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
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
-#line 2546 "configure"
+#line 2558 "configure"
#include "confdefs.h"
#include <$ac_hdr>
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*
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
-#line 2587 "configure"
+#line 2599 "configure"
#include "confdefs.h"
#include <$ac_hdr>
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*
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
-#line 2629 "configure"
+#line 2641 "configure"
#include "confdefs.h"
#include <$ac_hdr>
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*
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
-#line 2666 "configure"
+#line 2678 "configure"
#include "confdefs.h"
#include <$ac_hdr>
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*
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
case "${ac_cv_header_cln_cln_h}" in
"yes")
cat > conftest.$ac_ext <<EOF
-#line 2715 "configure"
+#line 2727 "configure"
#include "confdefs.h"
#include <cln/cl_integer.h>
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
;;
*)
cat > conftest.$ac_ext <<EOF
-#line 2735 "configure"
+#line 2747 "configure"
#include "confdefs.h"
#include <cl_integer.h>
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
# 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
# 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
# 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
# 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
# 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
# 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
# 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
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
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)
GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
@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
GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
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 << "(";
if (precedence<=upper_precedence) os << ")";
}
-void add::printraw(ostream & os) const
+void add::printraw(std::ostream & os) const
{
debugmsg("add printraw",LOGLEVEL_PRINT);
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)
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);
// 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;
archive_node_id archive::add_node(const archive_node &n)
{
// Search for node in nodes vector
- vector<archive_node>::const_iterator i = nodes.begin(), iend = nodes.end();
+ std::vector<archive_node>::const_iterator i = nodes.begin(), iend = nodes.end();
archive_node_id id = 0;
while (i != iend) {
if (i->has_same_ex_as(n))
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<archived_ex>::const_iterator i = exprs.begin(), iend = exprs.end();
+ std::vector<archived_ex>::const_iterator i = exprs.begin(), iend = exprs.end();
while (i != iend) {
if (i->name == id)
goto found;
/** 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"));
*/
/** 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);
}
/** 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;
}
/** 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();
}
/** 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
}
/** 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);
}
/** 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;
/** 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<string>::const_iterator i = atoms.begin(), iend = atoms.end();
+ std::vector<std::string>::const_iterator i = atoms.begin(), iend = atoms.end();
archive_atom id = 0;
while (i != iend) {
if (*i == s)
}
/** 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"));
/** 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));
/** 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<property>::const_iterator i = props.begin(), iend = props.end();
+ std::vector<property>::const_iterator i = props.begin(), iend = props.end();
while (i != iend) {
if (i->type == PTYPE_BOOL && i->name == name_atom) {
ret = i->value;
/** 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<property>::const_iterator i = props.begin(), iend = props.end();
+ std::vector<property>::const_iterator i = props.begin(), iend = props.end();
while (i != iend) {
if (i->type == PTYPE_UNSIGNED && i->name == name_atom) {
ret = i->value;
/** 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<property>::const_iterator i = props.begin(), iend = props.end();
+ std::vector<property>::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);
/** 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<property>::const_iterator i = props.begin(), iend = props.end();
+ std::vector<property>::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) {
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);
/** Delete cached unarchived expressions in all archive_nodes (mainly for debugging). */
void archive::forget(void)
{
- vector<archive_node>::iterator i = nodes.begin(), iend = nodes.end();
+ std::vector<archive_node>::iterator i = nodes.begin(), iend = nodes.end();
while (i != iend) {
i->forget();
i++;
/** 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<string>::const_iterator i = atoms.begin(), iend = atoms.end();
+ std::vector<std::string>::const_iterator i = atoms.begin(), iend = atoms.end();
archive_atom id = 0;
while (i != iend) {
os << " " << id << " " << *i << endl;
// Dump expressions
os << "Expressions:\n";
{
- vector<archived_ex>::const_iterator i = exprs.begin(), iend = exprs.end();
+ std::vector<archived_ex>::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;
// Dump nodes
os << "Nodes:\n";
{
- vector<archive_node>::const_iterator i = nodes.begin(), iend = nodes.end();
+ std::vector<archive_node>::const_iterator i = nodes.begin(), iend = nodes.end();
archive_node_id id = 0;
while (i != iend) {
os << " " << id << " ";
}
/** 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)
os << "\n";
// Dump properties
- vector<property>::const_iterator i = props.begin(), iend = props.end();
+ std::vector<property>::const_iterator i = props.begin(), iend = props.end();
while (i != iend) {
os << " ";
switch (i->type) {
#include <string>
#include <vector>
-class ostream;
-class istream;
+namespace std {
+ class ostream;
+ class istream;
+}
#ifndef NO_NAMESPACE_GINAC
namespace GiNaC {
* 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
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);
archive &a;
/** Vector of stored properties. */
- vector<property> props;
+ std::vector<property> props;
/** Flag indicating whether a cached unarchived representation of this node exists. */
mutable bool has_expression;
* 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() {}
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<archive_node> nodes;
+ std::vector<archive_node> nodes;
/** Archived expression descriptor. */
struct archived_ex {
};
/** Vector of archived expression descriptors. */
- vector<archived_ex> exprs;
+ std::vector<archived_ex> 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<string> atoms;
+ mutable std::vector<std::string> 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
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
// 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]";
/** 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]";
/** 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; i<nops(); ++i) {
op(i).printtree(os,indent+delta_indent);
}
* @param type variable type (one of the csrc_types)
* @param upper_precedence operator precedence of caller
* @see ex::printcsrc */
-void basic::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
+void basic::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
{
debugmsg("basic print csrc", LOGLEVEL_PRINT);
}
/** Little wrapper arount print to be called within a debugger. */
void basic::dbgprint(void) const
{
- print(cerr);
- cerr << endl;
+ print(std::cerr);
+ std::cerr << std::endl;
}
/** Little wrapper arount printtree to be called within a debugger. */
void basic::dbgprinttree(void) const
{
- printtree(cerr,0);
+ printtree(std::cerr,0);
}
basic * basic::duplicate() const
ex basic::diff(const symbol & s, unsigned nth) const
{
// trivial: zeroth derivative
- if (!nth)
+ if (nth==0)
return ex(*this);
// evaluate unevaluated *this before differentiating
if (!(flags & status_flags::evaluated))
return ex(*this).diff(s, nth);
- ex ndiff = derivative(s);
+ ex ndiff = this->derivative(s);
while (!ndiff.is_zero() && // stop differentiating zeros
nth>1) {
ndiff = ndiff.diff(s);
#include <typeinfo>
#include <vector>
-// CINT needs <algorithm> to work properly with <vector>
+// CINT needs <algorithm> to work properly with <vector>
#include <algorithm>
#include "flags.h"
class relational;
class archive_node;
-//typedef vector<ex> exvector;
-typedef vector<ex,malloc_alloc> exvector; // CINT does not like vector<...,default_alloc>
+// typedef std::vector<ex> exvector;
+typedef std::vector<ex,malloc_alloc> exvector; // CINT does not like vector<...,default_alloc>
#define INLINE_BASIC_CONSTRUCTORS
// 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;
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;
// public
-clifford::clifford(const string & initname)
+clifford::clifford(const std::string & initname)
{
debugmsg("clifford constructor from string",LOGLEVEL_CONSTRUCT);
name=initname;
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
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);
// 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;
}
// 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;
// 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;
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
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) {
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);
}
}
- vector<int> counter;
+ std::vector<int> counter;
counter.resize(iv_double.size());
int l;
for (l=0; unsigned(l)<iv_double.size(); ++l) {
counter[l]=1;
}
- ex sum=_ex0();
+ ex sum;
while (1) {
- ex term=e;
+ ex term = e;
for (l=0; unsigned(l)<iv_double.size(); ++l) {
term=term.subs(iv_double[l]==coloridx((unsigned)(counter[l])));
//iv_double[l].print(cout);
sum += term;
// increment counter[]
- l=iv_double.size()-1;
+ l = iv_double.size()-1;
while ((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;
}
const unsigned COLOR_EIGHT = 8; // N*N-1
const unsigned COLOR_THREE = 3; // N
-typedef vector<exvector,malloc_alloc> exvectorvector;
+// typedef std::vector<exvector> exvectorvector;
+typedef std::vector<exvector,malloc_alloc> exvectorvector; // CINT does not like vector<...,default_alloc>
/** Base class for color object */
class color : public indexed
// 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:
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;
return new coloridx(*this);
}
-void coloridx::printraw(ostream & os) const
+void coloridx::printraw(std::ostream & os) const
{
debugmsg("coloridx printraw",LOGLEVEL_PRINT);
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;
}
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);
// 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
// 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++)
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++)
{
{
// 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;
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;
// 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;
// member variables
private:
- string name;
+ std::string name;
evalffunctype ef;
numeric * number;
// bool fct_assigned;
namespace GiNaC {
#endif // ndef NO_NAMESPACE_GINAC
-// typedef ${STLHEADER}<ex> ${STLT};
-typedef ${STLHEADER}<ex,malloc_alloc> ${STLT}; // CINT does not like ${STLHEADER}<...,default_alloc>
+// typedef std::${STLHEADER}<ex> ${STLT};
+typedef std::${STLHEADER}<ex,malloc_alloc> ${STLT}; // CINT does not like ${STLHEADER}<...,default_alloc>
class ${CONTAINER} : public basic
{
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);
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;
return new ${CONTAINER}(*this);
}
-void ${CONTAINER}::printraw(ostream & os) const
+void ${CONTAINER}::printraw(std::ostream & os) const
{
debugmsg("${CONTAINER} printraw",LOGLEVEL_PRINT);
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";
// 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
{
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;
}
}
// #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
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);
}
/** 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);
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);
* @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);
{
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
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);
* 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);
// 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;
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;
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
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); }
return cmpval;
}
- void printraw(ostream & os) const
+ void printraw(std::ostream & os) const
{
os << "expair(";
rest.printraw(os);
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 << "[[";
os << "]]";
}
-void expairseq::printraw(ostream & os) const
+void expairseq::printraw(std::ostream & os) const
{
debugmsg("expairseq printraw",LOGLEVEL_PRINT);
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; i<seq.size(); ++i) {
seq[i].rest.printtree(os,indent+delta_indent);
seq[i].coeff.printtree(os,indent+delta_indent);
if (i!=seq.size()-1) {
- os << string(indent+delta_indent,' ') << "-----" << endl;
+ os << std::string(indent+delta_indent,' ') << "-----" << std::endl;
}
}
if (!overall_coeff.is_equal(default_overall_coeff())) {
- os << string(indent+delta_indent,' ') << "-----" << endl;
- os << string(indent+delta_indent,' ') << "overall_coeff" << endl;
+ os << std::string(indent+delta_indent,' ') << "-----" << std::endl;
+ os << std::string(indent+delta_indent,' ') << "overall_coeff" << std::endl;
overall_coeff.printtree(os,indent+delta_indent);
}
- os << string(indent+delta_indent,' ') << "=====" << endl;
+ os << std::string(indent+delta_indent,' ') << "=====" << std::endl;
#ifdef EXPAIRSEQ_USE_HASHTAB
- os << string(indent+delta_indent,' ')
- << "hashtab size " << hashtabsize << endl;
+ os << std::string(indent+delta_indent,' ')
+ << "hashtab size " << hashtabsize << std::endl;
if (hashtabsize==0) return;
#define MAXCOUNT 5
unsigned count[MAXCOUNT+1];
for (unsigned i=0; i<hashtabsize; ++i) {
this_bin_fill=0;
if (hashtab[i].size()>0) {
- 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;
}
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
}
#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);
}
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);
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 << "(";
#endif // def EXPAIRSEQ_USE_HASHTAB
}
-#include <iostream>
-
void expairseq::make_flat(const exvector & v)
{
exvector::const_iterator cit, citend = v.end();
}
/*
- 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;
*/
}
*/
/*
- 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();
*/
}
}
/*
- 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();
*/
}
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];
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<seq.size(); ++i) {
- if (touched[i]) cout << i << " is touched" << endl;
+ if (touched[i]) cout << i << " is touched" << std::endl;
}
- cout << "end in combine" << endl;
+ cout << "end in combine" << std::endl;
*/
// there should not be any terms with coeff 0 from the beginning,
if (number_of_zeroes!=0) {
drop_coeff_0_terms(first_numeric,last_non_zero,touched,number_of_zeroes);
/*
- cout << "in combine after drop:" << endl;
+ cout << "in combine after drop:" << 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<seq.size(); ++i) {
- if (touched[i]) cout << i << " is touched" << endl;
+ if (touched[i]) cout << i << " is touched" << std::endl;
}
- cout << "end in combine after drop" << endl;
+ cout << "end in combine after drop" << std::endl;
*/
}
cout << ">";
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;
#include <list>
// CINT needs <algorithm> to work properly with <vector> and <list>
-//#include <algorithm>
+#include <algorithm>
#include "expair.h"
//#define EXPAIRSEQ_USE_HASHTAB
-typedef vector<expair> epvector;
+typedef std::vector<expair> epvector;
typedef epvector::iterator epviter;
inline void iter_swap(epvector::iterator it1, epvector::iterator it2)
}
typedef epvector::iterator epp;
-typedef list<epp> epplist;
-typedef vector<epplist> epplistvector;
+typedef std::list<epp> epplist;
+typedef std::vector<epplist> epplistvector;
/** A sequence of class expair.
* This is used for time-critical classes like sums and products of terms
// 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;
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,
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";
// 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; };
'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",'','');
<<'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;
#include <string>
#include <vector>
-#ifdef __CINT__
// CINT needs <algorithm> to work properly with <vector>
#include <algorithm>
-#endif // def __CINT__
#include "exprseq.h"
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
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;
// 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:
// non-virtual functions in this class
protected:
ex pderivative(unsigned diff_param) const; // partial differentiation
- static vector<function_options> & registered_functions(void);
+ static std::vector<function_options> & 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
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);
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;
// 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;
}
}
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<function_options>::const_iterator i = registered_functions().begin(), iend = registered_functions().end();
+ std::vector<function_options>::const_iterator i = registered_functions().begin(), iend = registered_functions().end();
while (i != iend) {
if (s == i->name) {
serial = ser;
return new function(*this);
}
-void function::printraw(ostream & os) const
+void function::printraw(std::ostream & os) const
{
debugmsg("function printraw",LOGLEVEL_PRINT);
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);
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<registered_functions().size());
- os << string(indent,' ') << "function "
+ os << std::string(indent,' ') << "function "
<< registered_functions()[serial].name
- << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
+ << ", hash=" << hashvalue
+ << " (0x" << std::hex << hashvalue << std::dec << ")"
<< ", flags=" << flags
- << ", nops=" << nops() << endl;
+ << ", nops=" << nops() << std::endl;
for (unsigned i=0; i<nops(); ++i) {
seq[i].printtree(os,indent+delta_indent);
}
- os << string(indent+delta_indent,' ') << "=====" << endl;
+ os << std::string(indent+delta_indent,' ') << "=====" << std::endl;
}
-void function::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) const
+void function::printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence) const
{
debugmsg("function print csrc",LOGLEVEL_PRINT);
GINAC_ASSERT(serial<registered_functions().size());
// Print function name in lowercase
- string lname;
+ std::string lname;
lname=registered_functions()[serial].name;
for (unsigned i=0; i<lname.size(); i++)
lname[i] = tolower(lname[i]);
/** Implementation of ex::series for functions.
* \@see ex::series */
-ex function::series(const relational & r, int order) const
+ex function::series(const relational & r, int order, bool branchcut = true) const
{
GINAC_ASSERT(serial<registered_functions().size());
throw(std::logic_error("function::pderivative(): no diff function defined"));
}
-vector<function_options> & function::registered_functions(void)
+std::vector<function_options> & function::registered_functions(void)
{
- static vector<function_options> * rf=new vector<function_options>;
+ static std::vector<function_options> * rf = new std::vector<function_options>;
return *rf;
}
// 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) {
/** 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<function_options>::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end();
+ std::vector<function_options>::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)
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;
}
//////////
return new idx(*this);
}
-void idx::printraw(ostream & os) const
+void idx::printraw(std::ostream & os) const
{
debugmsg("idx printraw",LOGLEVEL_PRINT);
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;
}
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);
// 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;
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
// global functions
-// typedef vector<ex> 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,
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=";
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);
// 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) {
}
}
-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) {
// 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:
// 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
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);
}
// 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();
}
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<order; ++i)
- ser += pow(s,i)/pow(numeric(i),numeric(2));
- // substitute the argument's series expansion
- ser = ser.subs(s==x.series(rel,order));
- // maybe that was terminanting, so add a proper order term
- epvector nseq;
- nseq.push_back(expair(Order(_ex1()), numeric(order)));
- ser += pseries(rel, nseq);
- // reexpand will collapse the series again
- ser = ser.series(rel,order);
- return ser;
- // NOTE: Of course, this still does not allow us to compute anything
- // like sin(Li2(x)).series(x==0,2), since then this code here is not
- // reached and the derivative of sin(Li2(x)) doesn't allow the
- // substitution x==0. Probably limits *are* needed for the general
- // cases.
+ if (x_pt.info(info_flags::numeric)) {
+ // First special 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;
+ // manually construct the primitive expansion
+ for (int i=1; i<order; ++i)
+ ser += pow(s,i) / pow(numeric(i), _num2());
+ // substitute the argument's series expansion
+ ser = ser.subs(s==x.series(rel, order));
+ // maybe that was terminating, so add a proper order term
+ epvector nseq;
+ nseq.push_back(expair(Order(_ex1()), order));
+ ser += pseries(rel, nseq);
+ // reexpanding it will collapse the series again
+ return ser.series(rel, order);
+ // NB: Of course, this still does not allow us to compute anything
+ // like sin(Li2(x)).series(x==0,2), since then this code here is
+ // not reached and the derivative of sin(Li2(x)) doesn't allow the
+ // substitution x==0. Probably limits *are* needed for the general
+ // cases. In case L'Hospital's rule is implemented for limits and
+ // basic::series() takes care of this, this whole block is probably
+ // obsolete!
+ }
+ // second special case: x==1 (branch point)
+ if (x_pt == _ex1()) {
+ // method:
+ // construct series manually in a dummy symbol s
+ const symbol s;
+ ex ser = zeta(2);
+ // manually construct the primitive expansion
+ for (int i=1; i<order; ++i)
+ ser += pow(1-s,i) * (numeric(1,i)*(I*Pi+log(s-1)) - numeric(1,i*i));
+ // substitute the argument's series expansion
+ ser = ser.subs(s==x.series(rel, order));
+ // maybe that was terminating, so add a proper order term
+ epvector nseq;
+ nseq.push_back(expair(Order(_ex1()), order));
+ ser += pseries(rel, nseq);
+ // reexpanding it will collapse the series again
+ return ser.series(rel, order);
+ }
+ // third special case: x real, >=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<symbol *>(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<replarg.nops()-1; ++i)
+ seq.push_back(expair((replarg.op(i)/power(*s-foo,i)).series(foo==point,1,branchcut).op(0).subs(foo==*s),i));
+ // append an order term:
+ seq.push_back(expair(Order(_ex1()), replarg.nops()-1));
+ return pseries(rel, seq);
+ }
}
- // second problematic case: x real, >=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));
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<symbol *>(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);
}
{
// 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);
* 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)) {
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
}
-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
// 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
}
* 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)) {
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:
}
-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
// 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);
}
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);
}
}
-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<symbol *>(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();
}
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()) {
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
// 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 =
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()) {
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
// 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 =
{
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
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<symbol *>(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<symbol *>(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<symbol *>(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).
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)) {
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.
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.
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);
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
ex sym;
bool predefined; // true = user supplied symbol, false = lexer generated symbol
};
-typedef map<string, sym_def> sym_tab;
+typedef std::map<std::string, sym_def> sym_tab;
static sym_tab syms;
// lex input function
*/
// 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;
#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;
// public
-isospin::isospin(const string & initname)
+isospin::isospin(const std::string & initname)
{
debugmsg("isospin constructor from string",LOGLEVEL_CONSTRUCT);
name=initname;
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
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);
// 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;
}
// 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;
// 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;
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",
return new lorentzidx(*this);
}
-void lorentzidx::printraw(ostream & os) const
+void lorentzidx::printraw(std::ostream & os) const
{
debugmsg("lorentzidx printraw",LOGLEVEL_PRINT);
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;
}
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);
// 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);
// 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
// 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++;
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++;
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++;
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++;
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++;
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());
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
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) {
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);
// 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
// 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;
}
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);
}
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);
// 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:
//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;
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 << "[[ ";
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 <<",";
// 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<unsigned,unsigned> uintpair; // # of zeros, column
- vector<uintpair> c_zeros; // number of zeros in column
+ typedef std::pair<unsigned,unsigned> uintpair; // # of zeros, column
+ std::vector<uintpair> c_zeros; // number of zeros in column
for (unsigned c=0; c<col; ++c) {
unsigned acc = 0;
for (unsigned r=0; r<row; ++r)
c_zeros.push_back(uintpair(acc,c));
}
sort(c_zeros.begin(),c_zeros.end());
- vector<unsigned> pre_sort; // unfortunately vector<uintpair> can't be used
- // for permutation_sign.
- for (vector<uintpair>::iterator i=c_zeros.begin(); i!=c_zeros.end(); ++i)
+ // unfortunately std::vector<uintpair> can't be used for permutation_sign.
+ std::vector<unsigned> pre_sort;
+ for (std::vector<uintpair>::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<unsigned>::iterator i=pre_sort.begin();
+ for (std::vector<unsigned>::iterator i=pre_sort.begin();
i!=pre_sort.end();
++i,++c) {
for (unsigned r=0; r<row; ++r)
// 2*binomial(n,n/2) minors.
// Unique flipper counter for partitioning into minors
- vector<unsigned> Pkey;
+ std::vector<unsigned> Pkey;
Pkey.reserve(this->col);
// key for minor determinant (a subpartition of Pkey)
- vector<unsigned> Mkey;
+ std::vector<unsigned> Mkey;
Mkey.reserve(this->col-1);
// we store our subminors in maps, keys being the rows they arise from
- typedef map<vector<unsigned>,class ex> Rmap;
- typedef map<vector<unsigned>,class ex>::value_type Rmap_value;
+ typedef std::map<std::vector<unsigned>,class ex> Rmap;
+ typedef std::map<std::vector<unsigned>,class ex>::value_type Rmap_value;
Rmap A;
Rmap B;
ex det;
// 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);
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 << "(";
if (precedence<=upper_precedence) os << ")";
}
-void mul::printraw(ostream & os) const
+void mul::printraw(std::ostream & os) const
{
debugmsg("mul printraw",LOGLEVEL_PRINT);
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)
(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 << "/";
return inherited::info(inf);
}
-typedef vector<int> intvector;
+typedef std::vector<int> intvector;
int mul::degree(const symbol & s) 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
// 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));
}
// 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));
}
{
// 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)
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<number_of_adds; l++) {
- k[l]=0;
- }
+ k.resize(number_of_adds, 0);
while (1) {
epvector term;
term = expanded_seq;
- for (l=0; l<number_of_adds; l++) {
- const add & addref=ex_to_add(expanded_seq[positions_of_adds[l]].rest);
+ for (int l=0; l<number_of_adds; ++l) {
+ const add & addref = ex_to_add(expanded_seq[positions_of_adds[l]].rest);
GINAC_ASSERT(term[positions_of_adds[l]].coeff.compare(_ex1())==0);
term[positions_of_adds[l]]=split_ex_to_pair(addref.op(k[l]));
}
status_flags::expanded));
// increment k[]
- l=number_of_adds-1;
+ int l = number_of_adds-1;
while ((l>=0) && ((++k[l])>=number_of_add_operands[l])) {
- k[l]=0;
- l--;
+ k[l] = 0;
+ --l;
}
if (l<0) break;
}
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);
// 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;
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);
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;
throw(std::logic_error("which flags have to be implemented in ncmul::info()?"));
}
-typedef vector<int> intvector;
+typedef std::vector<int> intvector;
ex ncmul::expand(unsigned options) const
{
v.push_back(e);
}
-typedef vector<unsigned> unsignedvector;
-typedef vector<exvector> exvectorvector;
+typedef std::vector<unsigned> unsignedvector;
+typedef std::vector<exvector> exvectorvector;
ex ncmul::eval(int level) const
{
// 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;
};
// Vector of sym_desc structures
-typedef vector<sym_desc> sym_desc_vec;
+typedef std::vector<sym_desc> 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)
}
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
* Remembering
*/
-typedef pair<ex, ex> ex2;
-typedef pair<ex, bool> exbool;
+typedef std::pair<ex, ex> ex2;
+typedef std::pair<ex, bool> exbool;
struct ex2_less {
bool operator() (const ex2 p, const ex2 q) const
}
};
-typedef map<ex2, exbool, ex2_less> ex2_exbool_remember;
+typedef std::map<ex2, exbool, ex2_less> ex2_exbool_remember;
#endif
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;
// 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);
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;
// 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;
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;
// 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;
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;
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);
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
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();
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);
}
// 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;
* @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
// 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();
}
* @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
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)
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
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())
}
// 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);
}
// 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())) {
* 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)) {
* 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()) {
}
-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
}
-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();
/** 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
{
}
+/*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)
// 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);
}
* 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);
}
* 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);
}
* 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);
}
// 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)
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;
}
}
-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;
_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;
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);
// 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;
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;
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);
// 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"));
}
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
GINAC_IMPLEMENT_REGISTERED_CLASS(power, basic)
-typedef vector<int> intvector;
+typedef std::vector<int> intvector;
//////////
// default constructor, destructor, copy constructor assignment operator and helpers
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())) {
}
}
-void power::printraw(ostream & os) const
+void power::printraw(std::ostream & os) const
{
debugmsg("power printraw",LOGLEVEL_PRINT);
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) {
}
}
-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);
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();
}
{
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),
// 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:
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
* 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();
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))
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);
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;
}
}
-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(); ++i) {
seq[i].rest.printtree(os,indent+delta_indent);
seq[i].coeff.printtree(os,indent+delta_indent);
- if (i!=seq.size()-1) {
- os << string(indent+delta_indent,' ') << "-----" << endl;
- }
+ if (i!=seq.size()-1)
+ os << std::string(indent+delta_indent,' ') << "-----" << std::endl;
}
var.printtree(os, indent+delta_indent);
point.printtree(os, indent+delta_indent);
}
+/** Return the number of operands including a possible order term. */
unsigned pseries::nops(void) const
{
return seq.size();
}
+
+/** Return the ith term in the series when represented as a sum. */
ex pseries::op(int i) const
{
if (i < 0 || unsigned(i) >= seq.size())
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)) {
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)) {
int pow = it->rest.ldegree(s);
if (pow < min_pow)
min_pow = pow;
- it++;
+ ++it;
}
return min_pow;
}
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;
return convert_to_poly().coeff(s, n);
}
+
ex pseries::collect(const symbol &s) const
{
return *this;
}
+
/** Evaluate coefficients. */
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
{
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
// 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 */
if (!c.is_zero())
new_seq.push_back(expair(c, it->coeff - 1));
}
- it++;
+ ++it;
}
return pseries(relational(var,point), new_seq);
} else {
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
/** 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);
// 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);
}
/** 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();
if (a == a_end) {
while (b != b_end) {
new_seq.push_back(*b);
- b++;
+ ++b;
}
break;
} else
if (b == b_end) {
while (a != a_end) {
new_seq.push_back(*a);
- a++;
+ ++a;
}
break;
} else
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)) {
ex sum = (*a).rest + (*b).rest;
if (!(sum.is_zero()))
new_seq.push_back(expair(sum, numeric(pow_a)));
- a++;
- b++;
+ ++a;
+ ++b;
}
}
}
/** 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));
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);
}
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))
/** 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)
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);
ex co0;
co.push_back(co0 = power(coeff(*s, ldeg), p));
bool all_sums_zero = true;
- for (i=1; i<deg; i++) {
+ for (i=1; i<deg; ++i) {
ex sum = _ex0();
- for (int j=1; j<=i; j++) {
+ for (int j=1; j<=i; ++j) {
ex c = coeff(*s, j + ldeg);
if (is_order_function(c)) {
co.push_back(Order(_ex1()));
// Construct new series (of non-zero coefficients)
epvector new_seq;
bool higher_order = false;
- for (i=0; i<deg; i++) {
+ for (i=0; i<deg; ++i) {
if (!co[i].is_zero())
new_seq.push_back(expair(co[i], numeric(i) + p * ldeg));
if (is_order_function(co[i])) {
}
+/** Return a new pseries object with the powers shifted by deg. */
+pseries pseries::shift_exponents(int deg) const
+{
+ epvector newseq(seq);
+ for (epvector::iterator i=newseq.begin(); i!=newseq.end(); ++i)
+ i->coeff = 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;
/** 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));
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);
}
*
* @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;
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;
}
// 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;
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 */
return (static_cast<const pseries &>(*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
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) {
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;
/** 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
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 << "(";
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(";
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)
// non-virtual functions in this class
//////////
-#include <iostream>
-
relational::operator bool() const
{
// please note that (a<b) == false does not imply (a>=b) == true
// 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);
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;
}
for (unsigned i=0; i<seq.size(); ++i) {
if (!seq[i].is_equal(f.seq[i])) return false;
}
- last_access=access_counter++;
- successful_hits++;
+ ++last_access=access_counter;
+ ++successful_hits;
return true;
}
}
}
-vector<remember_table> & remember_table::remember_tables(void)
+std::vector<remember_table> & remember_table::remember_tables(void)
{
- static vector<remember_table> * rt=new vector<remember_table>;
+ static std::vector<remember_table> * rt = new std::vector<remember_table>;
return *rt;
}
/** A list of entries in the remember table having some least
significant bits of the hashvalue in common. */
-class remember_table_list : public list<remember_table_entry> {
+class remember_table_list : public std::list<remember_table_entry> {
public:
remember_table_list(unsigned as, unsigned strat);
void add_entry(function const & f, ex const & result);
- 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<remember_table_list> {
+class remember_table : public std::vector<remember_table_list> {
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_table> & remember_tables(void);
+ void show_statistics(std::ostream & os, unsigned level) const;
+ static std::vector<remember_table> & remember_tables(void);
protected:
void init_table(void);
unsigned table_size;
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);
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);
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);
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
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) {
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);
//////////
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
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);
}
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;
}
}
namespace GiNaC {
#endif // ndef NO_NAMESPACE_GINAC
-typedef pair<string,string> strstrpair;
-typedef pair<strstrpair,lorentzidx> spmapkey;
+typedef std::pair<std::string,std::string> strstrpair;
+typedef std::pair<strstrpair,lorentzidx> spmapkey;
class spmapkey_is_less
{
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);
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:
protected:
simp_lor_types type;
- string name;
+ std::string name;
};
// global constants
}
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);
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);
// protected
-vector<registered_structure_info> & structure::registered_structures(void)
+std::vector<registered_structure_info> & structure::registered_structures(void)
{
- static vector<registered_structure_info> * rs=new vector<registered_structure_info>;
+ static std::vector<registered_structure_info> * rs = new std::vector<registered_structure_info>;
return *rs;
}
// 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;
// non-virtual functions in this class
protected:
- static vector<registered_structure_info> & registered_structures(void);
+ static std::vector<registered_structure_info> & registered_structures(void);
public:
static unsigned register_new(const char * nm);
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;
unsigned symbol::next_serial=0;
-// string const symbol::autoname_prefix="symbol";
+// std::string const symbol::autoname_prefix="symbol";
//////////
// global constants
// 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:
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);
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)
{
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 */
#include <strstream>
#include <string>
+#include <stdexcept>
#include "config.h"
#include "assertion.h"
namespace GiNaC {
#endif // ndef NO_NAMESPACE_GINAC
+// This should be obsoleted once <sstream> is widely available.
template<class T>
-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
// Compute the sign of a permutation of a vector of things.
template <typename T>
-int permutation_sign(vector<T> s)
+int permutation_sign(std::vector<T> s)
{
if (s.size() < 2)
return 0;
int sigma = 1;
- for (typename vector<T>::iterator i=s.begin(); i!=s.end()-1; ++i) {
- for (typename vector<T>::iterator j=i+1; j!=s.end(); ++j) {
+ for (typename std::vector<T>::iterator i=s.begin(); i!=s.end()-1; ++i) {
+ for (typename std::vector<T>::iterator j=i+1; j!=s.end(); ++j) {
if (*i == *j)
return 0;
if (*i > *j) {
/* 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__
GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
# 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
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;}
;
| 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) {
GINACLIB_VERSION = @GINACLIB_VERSION@
GINSH_LIBS = @GINSH_LIBS@
LATEX = @LATEX@
+LD = @LD@
LEX = @LEX@
LIBTERMCAP = @LIBTERMCAP@
LIBTOOL = @LIBTOOL@
MAKECINT = @MAKECINT@
MAKEINDEX = @MAKEINDEX@
MAKEINFO = @MAKEINFO@
+NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
/** @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
fprintf(stderr, "Usage: %s [-d] file...\n", argv[0]);
exit(1);
}
- argc--; argv++;
+ --argc; ++argv;
bool dump_mode = false;
try {
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<ar.num_expressions(); i++) {
- string name;
+ for (unsigned int i=0; i<ar.num_expressions(); ++i) {
+ std::string name;
ex e = ar.unarchive_ex(l, name, i);
- cout << name << " = " << e << endl;
+ std::cout << name << " = " << e << std::endl;
}
}
- argc--; argv++;
+ --argc; ++argv;
}
- } catch (exception &e) {
- cerr << *argv << ": " << e.what() << endl;
+ } catch (std::exception &e) {
+ std::cerr << *argv << ": " << e.what() << std::endl;
}
}