From 9eab44408b9213d8909b7a9e525f404ad06064dd Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Wed, 17 Nov 1999 19:57:49 +0000 Subject: [PATCH] - put everything in "GiNaC" namespace - converted some macros into inline functions - split debugmsg.h into assertion.h (public) and debugmsg.h (private) --- NEWS | 1 + check/check.h | 5 +- check/differentiation.cpp | 6 +- check/expand_subs.cpp | 6 +- check/fcntimer.cpp | 5 +- check/inifcns_consist.cpp | 6 +- check/lsolve_onedim.cpp | 6 +- check/main.cpp | 5 +- check/matrix_checks.cpp | 6 +- check/normalization.cpp | 6 +- check/numeric_consist.cpp | 6 +- check/numeric_output.cpp | 6 +- check/paranoia_check.cpp | 6 +- check/poly_gcd.cpp | 6 +- check/powerlaws.cpp | 6 +- check/series_expansion.cpp | 6 +- configure | 294 ++++++++++++++++++------------------- configure.in | 8 +- ginac/Makefile.am | 20 ++- ginac/Makefile.in | 20 ++- ginac/add.cpp | 12 +- ginac/add.h | 10 +- ginac/assertion.h | 34 +++++ ginac/basic.cpp | 5 + ginac/basic.h | 23 ++- ginac/clifford.cpp | 4 + ginac/clifford.h | 13 +- ginac/color.cpp | 20 +-- ginac/color.h | 25 +++- ginac/coloridx.cpp | 6 +- ginac/coloridx.h | 11 +- ginac/constant.cpp | 5 + ginac/constant.h | 4 + ginac/container.pl | 24 ++- ginac/debugmsg.h | 13 +- ginac/diff.cpp | 6 +- ginac/ex.cpp | 4 + ginac/ex.h | 16 +- ginac/expair.h | 4 + ginac/expairseq.cpp | 6 +- ginac/expairseq.h | 13 +- ginac/exprseq.cpp | 14 +- ginac/exprseq.h | 20 ++- ginac/exprseq_suppl.cpp | 3 + ginac/fail.cpp | 4 + ginac/fail.h | 6 +- ginac/flags.h | 4 + ginac/function.cpp | 15 +- ginac/function.h | 65 ++++---- ginac/function.pl | 35 +++-- ginac/ginac.h | 4 +- ginac/idx.cpp | 7 +- ginac/idx.h | 15 +- ginac/indexed.cpp | 4 + ginac/indexed.h | 12 +- ginac/inifcns.cpp | 4 + ginac/inifcns.h | 4 + ginac/inifcns_gamma.cpp | 8 +- ginac/inifcns_trans.cpp | 4 + ginac/isospin.cpp | 4 + ginac/isospin.h | 12 +- ginac/lorentzidx.cpp | 6 +- ginac/lorentzidx.h | 10 +- ginac/lst.cpp | 14 +- ginac/lst.h | 20 ++- ginac/lst_suppl.cpp | 4 +- ginac/matrix.cpp | 5 + ginac/matrix.h | 10 +- ginac/mul.cpp | 5 +- ginac/mul.h | 10 +- ginac/ncmul.cpp | 5 +- ginac/ncmul.h | 11 +- ginac/normal.cpp | 18 ++- ginac/normal.h | 10 +- ginac/numeric.cpp | 57 +++---- ginac/numeric.h | 14 +- ginac/operators.cpp | 4 + ginac/operators.h | 4 + ginac/power.cpp | 7 +- ginac/power.h | 11 +- ginac/print.cpp | 5 + ginac/printcsrc.cpp | 5 + ginac/printraw.cpp | 5 + ginac/printtree.cpp | 4 + ginac/relational.cpp | 4 + ginac/relational.h | 12 +- ginac/series.cpp | 5 + ginac/series.h | 16 +- ginac/simp_lor.cpp | 6 +- ginac/simp_lor.h | 18 ++- ginac/structure.cpp | 4 + ginac/structure.h | 5 +- ginac/structure.pl | 20 ++- ginac/symbol.cpp | 5 + ginac/symbol.h | 12 +- ginac/tinfos.h | 58 ++++---- ginac/utils.cpp | 6 +- ginac/utils.h | 7 +- 98 files changed, 891 insertions(+), 463 deletions(-) create mode 100644 ginac/assertion.h diff --git a/NEWS b/NEWS index e69de29b..7315d324 100644 --- a/NEWS +++ b/NEWS @@ -0,0 +1 @@ +First release diff --git a/check/check.h b/check/check.h index 89a093e7..0474594e 100644 --- a/check/check.h +++ b/check/check.h @@ -1,7 +1,8 @@ /** @file check.h * - * Prototypes for all individual checks. - * + * Prototypes for all individual checks. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify diff --git a/check/differentiation.cpp b/check/differentiation.cpp index 8a160180..d1051ea9 100644 --- a/check/differentiation.cpp +++ b/check/differentiation.cpp @@ -1,7 +1,8 @@ /** @file differentiation.cpp * - * Tests for symbolic differentiation, including various functions. - * + * Tests for symbolic differentiation, including various functions. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -20,6 +21,7 @@ */ #include +using namespace GiNaC; static unsigned check_diff(const ex &e, const symbol &x, const ex &d, unsigned nth=1) diff --git a/check/expand_subs.cpp b/check/expand_subs.cpp index abaea8f1..b6ff16f0 100644 --- a/check/expand_subs.cpp +++ b/check/expand_subs.cpp @@ -10,8 +10,9 @@ * e = (a0 + a1)^200 * expand e * substitute a0 by -a1 in e - * after which e should return 0 (without expanding). - * + * after which e should return 0 (without expanding). */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -31,6 +32,7 @@ #include +using namespace GiNaC; #define VECSIZE 100 diff --git a/check/fcntimer.cpp b/check/fcntimer.cpp index 152ec67d..3ccb31d4 100644 --- a/check/fcntimer.cpp +++ b/check/fcntimer.cpp @@ -1,7 +1,8 @@ /** @file fcntimer.cpp * - * Function execution timer. - * + * Function execution timer. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify diff --git a/check/inifcns_consist.cpp b/check/inifcns_consist.cpp index 5d91a145..e51625b2 100644 --- a/check/inifcns_consist.cpp +++ b/check/inifcns_consist.cpp @@ -1,8 +1,9 @@ /** @file inifcns_consist.cpp * * This test routine applies assorted tests on initially known higher level - * functions. - * + * functions. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -21,6 +22,7 @@ */ #include +using namespace GiNaC; /* Simple tests on the sine trigonometric function. */ static unsigned inifcns_consist_sin(void) diff --git a/check/lsolve_onedim.cpp b/check/lsolve_onedim.cpp index 5cd3421d..448a1637 100644 --- a/check/lsolve_onedim.cpp +++ b/check/lsolve_onedim.cpp @@ -1,8 +1,9 @@ /** @file lsolve_onedim.cpp * * This test routine does some simple checks on solving a polynomial for a - * variable. - * + * variable. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -21,6 +22,7 @@ */ #include +using namespace GiNaC; unsigned lsolve_onedim(void) { diff --git a/check/main.cpp b/check/main.cpp index 200c96d6..0171e9c5 100644 --- a/check/main.cpp +++ b/check/main.cpp @@ -1,7 +1,8 @@ /** @file main.cpp * - * Main program that calls all individual tests. - * + * Main program that calls all individual tests. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify diff --git a/check/matrix_checks.cpp b/check/matrix_checks.cpp index 4b973ef3..80d8bf95 100644 --- a/check/matrix_checks.cpp +++ b/check/matrix_checks.cpp @@ -1,7 +1,8 @@ /** @file matrix_checks.cpp * - * Here we test manipulations on GiNaC's symbolic matrices. - * + * Here we test manipulations on GiNaC's symbolic matrices. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -21,6 +22,7 @@ #include #include +using namespace GiNaC; static unsigned matrix_determinants(void) { diff --git a/check/normalization.cpp b/check/normalization.cpp index 0b79a64c..3f814fde 100644 --- a/check/normalization.cpp +++ b/check/normalization.cpp @@ -1,7 +1,8 @@ /** @file normalization.cpp * - * Rational function normalization test suite. - * + * Rational function normalization test suite. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -20,6 +21,7 @@ */ #include +using namespace GiNaC; static symbol x("x"), y("y"), z("z"); diff --git a/check/numeric_consist.cpp b/check/numeric_consist.cpp index cd6f81ce..6c5fd6be 100644 --- a/check/numeric_consist.cpp +++ b/check/numeric_consist.cpp @@ -1,8 +1,9 @@ /** @file numeric_consist.cpp * * This test routine creates some numbers and check the result of several - * boolean tests on these numbers like is_integer() etc... - * + * boolean tests on these numbers like is_integer() etc... */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -22,6 +23,7 @@ #include #include +using namespace GiNaC; /* Simple and maybe somewhat pointless consistency tests of assorted tests and * conversions. */ diff --git a/check/numeric_output.cpp b/check/numeric_output.cpp index d138a74f..99f3afdc 100644 --- a/check/numeric_output.cpp +++ b/check/numeric_output.cpp @@ -1,7 +1,8 @@ /** @file numeric_output.cpp * - * Test output of numeric types. - * + * Test output of numeric types. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -20,6 +21,7 @@ */ #include +using namespace GiNaC; unsigned numeric_output(void) { diff --git a/check/paranoia_check.cpp b/check/paranoia_check.cpp index 228d8465..d84946f2 100644 --- a/check/paranoia_check.cpp +++ b/check/paranoia_check.cpp @@ -3,8 +3,9 @@ * This set of tests checks for some of GiNaC's oopses which showed up during * development. Things were evaluated wrongly and so. It should not find such * a sick behaviour again. But since we are paranoic and we want to exclude - * that behaviour for good... - * + * that behaviour for good... */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -23,6 +24,7 @@ */ #include +using namespace GiNaC; // The very first pair of historic problems had its roots in power.cpp and was // finally resolved on April 27th. (Fixing the first on April 23rd actually diff --git a/check/poly_gcd.cpp b/check/poly_gcd.cpp index 542bc80c..484eb2d2 100644 --- a/check/poly_gcd.cpp +++ b/check/poly_gcd.cpp @@ -1,8 +1,9 @@ /** @file poly_gcd.cpp * * Some test with polynomial GCD calculations. See also the checks for - * rational function normalization in normalization.cpp. - * + * rational function normalization in normalization.cpp. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -21,6 +22,7 @@ */ #include +using namespace GiNaC; const int MAX_VARIABLES = 5; diff --git a/check/powerlaws.cpp b/check/powerlaws.cpp index 2a6382a8..c51bff8e 100644 --- a/check/powerlaws.cpp +++ b/check/powerlaws.cpp @@ -1,8 +1,9 @@ /** @file powerlaws.cpp * * Tests for power laws. You shouldn't try to draw much inspiration from - * this code, it is a sanity check rather deeply rooted in GiNaC's classes. - * + * this code, it is a sanity check rather deeply rooted in GiNaC's classes. */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -21,6 +22,7 @@ */ #include +using namespace GiNaC; static unsigned powerlaws1(void) { diff --git a/check/series_expansion.cpp b/check/series_expansion.cpp index 0f8437b2..292f5b92 100644 --- a/check/series_expansion.cpp +++ b/check/series_expansion.cpp @@ -1,7 +1,8 @@ /** @file series_expansion.cpp * - * Series expansion test (Laurent and Taylor series). - * + * Series expansion test (Laurent and Taylor series). */ + +/* * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -20,6 +21,7 @@ */ #include +using namespace GiNaC; static symbol x("x"); diff --git a/configure b/configure index e7726193..4e2863d6 100755 --- a/configure +++ b/configure @@ -1862,22 +1862,153 @@ fi done +for ac_hdr in unistd.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1870: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1880: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +for ac_hdr in readline/readline.h readline/history.h +do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "configure:1910: checking for $ac_hdr" >&5 +if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1920: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` + cat >> confdefs.h <&6 +fi +done + +echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6 +echo "configure:1947: 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 +else + ac_save_LIBS="$LIBS" +LIBS="-lreadline $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_lib_$ac_lib_var=no" +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then + echo "$ac_t""yes" 1>&6 + ac_tr_lib=HAVE_LIB`echo readline | sed -e 's/[^a-zA-Z0-9_]/_/g' \ + -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` + cat >> confdefs.h <&6 +fi + + for ac_hdr in CLN/cln.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1871: checking for $ac_hdr" >&5 +echo "configure:2002: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1881: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2012: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1904,17 +2035,17 @@ for ac_hdr in cln.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:1908: checking for $ac_hdr" >&5 +echo "configure:2039: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:1918: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +{ (eval echo configure:2049: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out` if test -z "$ac_err"; then rm -rf conftest* @@ -1949,7 +2080,7 @@ done echo $ac_n "checking how to link with libcln""... $ac_c" 1>&6 -echo "configure:1953: checking how to link with libcln" >&5 +echo "configure:2084: checking how to link with libcln" >&5 saved_LIBS="${LIBS}" if eval "test \"`echo '$''{'ginac_cv_lib_cln_link'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1958,14 +2089,14 @@ else case "${ac_cv_header_CLN_cln_h}" in "yes") cat > conftest.$ac_ext < int main() { factorial(1); ; return 0; } EOF -if { (eval echo configure:1969: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2100: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ginac_cv_lib_cln_link="-lcln" else @@ -1978,14 +2109,14 @@ rm -f conftest* ;; *) cat > conftest.$ac_ext < int main() { factorial(1); ; return 0; } EOF -if { (eval echo configure:1989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then +if { (eval echo configure:2120: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then rm -rf conftest* ginac_cv_lib_cln_link="-lcln" else @@ -2006,7 +2137,7 @@ fi echo "$ac_t""-lcln" 1>&6 echo $ac_n "checking whether libcln behaves sane""... $ac_c" 1>&6 -echo "configure:2010: checking whether libcln behaves sane" >&5 +echo "configure:2141: checking whether libcln behaves sane" >&5 if eval "test \"`echo '$''{'ginac_cv_lib_cln_integrity'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2017,7 +2148,7 @@ else ginac_cv_lib_cln_integrity="guessing sane" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2163: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ginac_cv_lib_cln_integrity="sane" else @@ -2046,7 +2177,7 @@ fi ginac_cv_lib_cln_integrity="guessing sane" else cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +if { (eval echo configure:2192: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null then ginac_cv_lib_cln_integrity="sane" else @@ -2102,137 +2233,6 @@ fi esac -for ac_hdr in unistd.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2110: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2120: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done - -for ac_hdr in readline/readline.h readline/history.h -do -ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` -echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 -echo "configure:2150: checking for $ac_hdr" >&5 -if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then - echo $ac_n "(cached) $ac_c" 1>&6 -else - cat > conftest.$ac_ext < -EOF -ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" -{ (eval echo configure:2160: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } -ac_err=`grep -v '^ *+' conftest.out` -if test -z "$ac_err"; then - rm -rf conftest* - eval "ac_cv_header_$ac_safe=yes" -else - echo "$ac_err" >&5 - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_header_$ac_safe=no" -fi -rm -f conftest* -fi -if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` - cat >> confdefs.h <&6 -fi -done - -echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6 -echo "configure:2187: 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 -else - ac_save_LIBS="$LIBS" -LIBS="-lreadline $LIBS" -cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=yes" -else - echo "configure: failed program was:" >&5 - cat conftest.$ac_ext >&5 - rm -rf conftest* - eval "ac_cv_lib_$ac_lib_var=no" -fi -rm -f conftest* -LIBS="$ac_save_LIBS" - -fi -if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then - echo "$ac_t""yes" 1>&6 - ac_tr_lib=HAVE_LIB`echo readline | sed -e 's/[^a-zA-Z0-9_]/_/g' \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` - cat >> confdefs.h <&6 -fi - - # 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 diff --git a/configure.in b/configure.in index 74227d16..066d4f2e 100644 --- a/configure.in +++ b/configure.in @@ -75,15 +75,15 @@ dnl enough so trying the .h-style headers is a waste of time. AC_CHECK_HEADERS(iostream vector map string list typeinfo iterator strstream stdexcept algorithm, , AC_MSG_ERROR(need to have ANSI compliant headers)) -dnl We need to have Bruno Haible's CLN installed (macros are in aclocal.m4): -GINAC_CHECK_CLN_H -GINAC_CHECK_LIBCLN - dnl Check for stuff needed for building the GiNaC interactive shell (ginsh): AC_CHECK_HEADERS(unistd.h) AC_CHECK_HEADERS(readline/readline.h readline/history.h) AC_CHECK_LIB(readline, readline) +dnl We need to have Bruno Haible's CLN installed (macros are in acinclude.m4): +GINAC_CHECK_CLN_H +GINAC_CHECK_LIBCLN + dnl Check for utilities needed by the different kinds of documentation. dnl Documantation needs only be built when extending it, so never mind if it dnl cannot find those helpers: diff --git a/ginac/Makefile.am b/ginac/Makefile.am index e56226c8..9d8ed38e 100644 --- a/ginac/Makefile.am +++ b/ginac/Makefile.am @@ -7,12 +7,22 @@ libginac_la_SOURCES = add.cpp basic.cpp constant.cpp diff.cpp ex.cpp \ printcsrc.cpp relational.cpp symbol.cpp utils.cpp series.cpp ncmul.cpp \ clifford.cpp structure.cpp color.cpp indexed.cpp idx.cpp isospin.cpp \ exprseq_suppl.cpp lst.cpp lst_suppl.cpp simp_lor.cpp coloridx.cpp \ - lorentzidx.cpp utils.h + lorentzidx.cpp debugmsg.h utils.h libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) ginacincludedir = $(includedir)/ginac ginacinclude_HEADERS = ginac.h add.h basic.h clifford.h color.h coloridx.h \ - constant.h debugmsg.h ex.h expair.h expairseq.h exprseq.h fail.h flags.h \ - function.h idx.h indexed.h inifcns.h isospin.h lorentzidx.h lst.h matrix.h \ - mul.h ncmul.h normal.h numeric.h operators.h power.h relational.h series.h \ - simp_lor.h structure.h symbol.h tinfos.h + constant.h ex.h expair.h expairseq.h exprseq.h fail.h flags.h function.h \ + idx.h indexed.h inifcns.h isospin.h lorentzidx.h lst.h matrix.h mul.h \ + ncmul.h normal.h numeric.h operators.h power.h relational.h series.h \ + simp_lor.h structure.h symbol.h tinfos.h assertion.h + +# Files which are generated by perl scripts +function.h function.cpp: function.pl + perl function.pl + +lst.h lst.cpp: container.pl + perl container.pl lst + +exprseq.h exprseq.cpp: container.pl + perl container.pl exprseq diff --git a/ginac/Makefile.in b/ginac/Makefile.in index 7144b928..c697f07a 100644 --- a/ginac/Makefile.in +++ b/ginac/Makefile.in @@ -101,15 +101,15 @@ libginac_la_SOURCES = add.cpp basic.cpp constant.cpp diff.cpp ex.cpp \ printcsrc.cpp relational.cpp symbol.cpp utils.cpp series.cpp ncmul.cpp \ clifford.cpp structure.cpp color.cpp indexed.cpp idx.cpp isospin.cpp \ exprseq_suppl.cpp lst.cpp lst_suppl.cpp simp_lor.cpp coloridx.cpp \ - lorentzidx.cpp utils.h + lorentzidx.cpp debugmsg.h utils.h libginac_la_LDFLAGS = -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ -release $(LT_RELEASE) ginacincludedir = $(includedir)/ginac ginacinclude_HEADERS = ginac.h add.h basic.h clifford.h color.h coloridx.h \ - constant.h debugmsg.h ex.h expair.h expairseq.h exprseq.h fail.h flags.h \ - function.h idx.h indexed.h inifcns.h isospin.h lorentzidx.h lst.h matrix.h \ - mul.h ncmul.h normal.h numeric.h operators.h power.h relational.h series.h \ - simp_lor.h structure.h symbol.h tinfos.h + constant.h ex.h expair.h expairseq.h exprseq.h fail.h flags.h function.h \ + idx.h indexed.h inifcns.h isospin.h lorentzidx.h lst.h matrix.h mul.h \ + ncmul.h normal.h numeric.h operators.h power.h relational.h series.h \ + simp_lor.h structure.h symbol.h tinfos.h assertion.h mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = @@ -391,6 +391,16 @@ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean +# Files which are generated by perl scripts +function.h function.cpp: function.pl + perl function.pl + +lst.h lst.cpp: container.pl + perl container.pl lst + +exprseq.h exprseq.cpp: container.pl + perl container.pl exprseq + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff --git a/ginac/add.cpp b/ginac/add.cpp index 2f3beb13..0f25d2dc 100644 --- a/ginac/add.cpp +++ b/ginac/add.cpp @@ -25,6 +25,9 @@ #include "add.h" #include "mul.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -420,9 +423,9 @@ ex add::eval(int level) const exvector add::get_indices(void) const { - // all terms in the sum should have the same indices (compatible tensors) - // however this is not checked, since there is no function yet which - // compares indices (idxvector can be unsorted) !!!!!!!!!!! + // FIXME: all terms in the sum should have the same indices (compatible + // tensors) however this is not checked, since there is no function yet + // which compares indices (idxvector can be unsorted) if (seq.size()==0) { return exvector(); } @@ -650,5 +653,4 @@ unsigned add::precedence=40; const add some_add; type_info const & typeid_add=typeid(some_add); - - +} // namespace GiNaC diff --git a/ginac/add.h b/ginac/add.h index 0545bcd2..f471741b 100644 --- a/ginac/add.h +++ b/ginac/add.h @@ -25,6 +25,8 @@ #include +namespace GiNaC { + /** Sum of expressions. */ class add : public expairseq { @@ -106,6 +108,12 @@ protected: extern const add some_add; extern type_info const & typeid_add; -#define ex_to_add(X) static_cast(*(X).bp) +// utility functions +inline const add &ex_to_add(const ex &e) +{ + return static_cast(*e.bp); +} + +} // namespace GiNaC #endif // ndef __GINAC_ADD_H__ diff --git a/ginac/assertion.h b/ginac/assertion.h new file mode 100644 index 00000000..39bb4f4e --- /dev/null +++ b/ginac/assertion.h @@ -0,0 +1,34 @@ +/** @file assertion.h + * + * Assertion macro definition. */ + +/* + * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __GINAC_ASSERTION_H__ +#define __GINAC_ASSERTION_H__ + +#include + +#if defined(DO_GINAC_ASSERT) && !defined(ASSERT) +#define ASSERT(X) assert(X) +#else +#define ASSERT(X) ((void)0) +#endif + +#endif // ndef __GINAC_ASSERTION_H__ diff --git a/ginac/basic.cpp b/ginac/basic.cpp index 097ec574..1c8814d4 100644 --- a/ginac/basic.cpp +++ b/ginac/basic.cpp @@ -32,6 +32,9 @@ #include "lst.h" #include "ncmul.h" #include "utils.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -413,3 +416,5 @@ type_info const & typeid_basic=typeid(some_basic); ////////// int max_recursion_level=1024; + +} // namespace GiNaC diff --git a/ginac/basic.h b/ginac/basic.h index a376855d..f397b778 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -29,7 +29,9 @@ #include #include -#include +#include + +namespace GiNaC { class basic; class ex; @@ -55,8 +57,6 @@ public: #ifdef INLINE_BASIC_CONSTRUCTORS : tinfo_key(TINFO_basic), flags(0), refcount(0) { - debugmsg("basic default constructor",LOGLEVEL_CONSTRUCT); - // nothing to do } #else ; @@ -65,7 +65,6 @@ public: virtual ~basic() #ifdef INLINE_BASIC_CONSTRUCTORS { - debugmsg("basic destructor",LOGLEVEL_DESTRUCT); destroy(0); ASSERT((!(flags & status_flags::dynallocated))||(refcount==0)); } @@ -76,7 +75,6 @@ public: basic(basic const & other) #ifdef INLINE_BASIC_CONSTRUCTORS { - debugmsg("basic copy constructor",LOGLEVEL_CONSTRUCT); copy(other); } #else @@ -99,8 +97,6 @@ protected: #ifdef INLINE_BASIC_CONSTRUCTORS : tinfo_key(ti), flags(0), refcount(0) { - debugmsg("basic constructor with tinfo_key",LOGLEVEL_CONSTRUCT); - // nothing to do } #else ; @@ -183,21 +179,18 @@ extern type_info const & typeid_basic; extern int max_recursion_level; // convenience macros - #define is_of_type(OBJ,TYPE) \ - (dynamic_cast(const_cast(&OBJ))!=0) + (dynamic_cast(const_cast(&OBJ))!=0) #define is_exactly_of_type(OBJ,TYPE) \ - ((OBJ).tinfo()==TINFO_##TYPE) + ((OBJ).tinfo()==GiNaC::TINFO_##TYPE) #define is_ex_of_type(OBJ,TYPE) \ - (dynamic_cast(const_cast((OBJ).bp))!=0) + (dynamic_cast(const_cast((OBJ).bp))!=0) #define is_ex_exactly_of_type(OBJ,TYPE) \ - ((*(OBJ).bp).tinfo()==TINFO_##TYPE) + ((*(OBJ).bp).tinfo()==GiNaC::TINFO_##TYPE) -#define are_ex_trivially_equal(EX1,EX2) \ - ((EX1).bp==(EX2).bp) // global functions @@ -232,4 +225,6 @@ inline unsigned golden_ratio_hash(unsigned n) #endif } +} // namespace GiNaC + #endif // ndef __GINAC_BASIC_H__ diff --git a/ginac/clifford.cpp b/ginac/clifford.cpp index d16f1fe5..e60ced04 100644 --- a/ginac/clifford.cpp +++ b/ginac/clifford.cpp @@ -27,6 +27,9 @@ #include "ex.h" #include "ncmul.h" #include "utils.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -208,3 +211,4 @@ unsigned clifford::next_serial=0; const clifford some_clifford; type_info const & typeid_clifford=typeid(some_clifford); +} // namespace GiNaC diff --git a/ginac/clifford.h b/ginac/clifford.h index 36a1ff9b..49a3613b 100644 --- a/ginac/clifford.h +++ b/ginac/clifford.h @@ -25,6 +25,9 @@ #include #include +#include + +namespace GiNaC { /** Base class for clifford object */ class clifford : public indexed @@ -81,10 +84,12 @@ private: extern const clifford some_clifford; extern type_info const & typeid_clifford; -// macros +// utility functions +inline const clifford &ex_to_clifford(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_clifford(X) static_cast(*(X).bp) +} // namespace GiNaC #endif // ndef __GINAC_CLIFFORD_H__ - - diff --git a/ginac/color.cpp b/ginac/color.cpp index 33dc647c..3ac2d1f2 100644 --- a/ginac/color.cpp +++ b/ginac/color.cpp @@ -33,6 +33,9 @@ #include "ncmul.h" #include "numeric.h" #include "relational.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -746,7 +749,7 @@ ex color_trace_of_one_representation_label(exvector const & v) v2.push_back(color_T(summation_index)); // don't care about the representation_label - // check this formula for SU(N) with N!=3 !!!!!!!!! + // FIXME: check this formula for SU(N) with N!=3 return numeric(1)/numeric(2*COLOR_THREE)*color_delta8(next_to_last_index,last_index) % color_trace_of_one_representation_label(v1) +numeric(1)/numeric(2)*color_h(next_to_last_index,last_index,summation_index) @@ -858,7 +861,7 @@ ex simplify_pure_color_string(ex const & e) } } - // TODO: higher contractions!!!!!!!!!!!!! + // FIXME: higher contractions return e; } @@ -962,15 +965,4 @@ void append_exvector_to_exvector(exvector & dest, exvector const & source) } } - - - - - - - - - - - - +} // namespace GiNaC diff --git a/ginac/color.h b/ginac/color.h index 877e7de5..a6f8ea59 100644 --- a/ginac/color.h +++ b/ginac/color.h @@ -26,10 +26,13 @@ #include #include #include +#include -#define MAX_REPRESENTATION_LABELS 4 -#define COLOR_EIGHT 8 // N*N-1 -#define COLOR_THREE 3 // N +namespace GiNaC { + +const int MAX_REPRESENTATION_LABELS = 4; +const int COLOR_EIGHT = 8; // N*N-1 +const int COLOR_THREE = 3; // N /** Base class for color object */ class color : public indexed @@ -125,10 +128,16 @@ protected: extern const color some_color; extern type_info const & typeid_color; -// macros +// global functions +inline const color &ex_to_color(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_color(X) static_cast(*(X).bp) -#define ex_to_nonconst_color(X) static_cast(*(X).bp) +inline color &ex_to_nonconst_color(const ex &e) +{ + return static_cast(*e.bp); +} color color_ONE(unsigned const rl=0); color color_T(ex const & a, unsigned const rl=0); @@ -153,6 +162,6 @@ ex brute_force_sum_color_indices(ex const & e); void append_exvector_to_exvector(exvector & dest, exvector const & source); -#endif // ndef __GINAC_COLOR_H__ - +} // namespace GiNaC +#endif // ndef __GINAC_COLOR_H__ diff --git a/ginac/coloridx.cpp b/ginac/coloridx.cpp index 523c0d2a..dc8eed7d 100644 --- a/ginac/coloridx.cpp +++ b/ginac/coloridx.cpp @@ -24,6 +24,9 @@ #include "coloridx.h" #include "utils.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -210,5 +213,4 @@ bool coloridx::info(unsigned inf) const const coloridx some_coloridx; type_info const & typeid_coloridx=typeid(some_coloridx); - - +} // namespace GiNaC diff --git a/ginac/coloridx.h b/ginac/coloridx.h index 1753b429..7861c899 100644 --- a/ginac/coloridx.h +++ b/ginac/coloridx.h @@ -26,6 +26,9 @@ #include #include #include +#include + +namespace GiNaC { class coloridx : public idx { @@ -73,8 +76,12 @@ public: extern const coloridx some_coloridx; extern type_info const & typeid_coloridx; -// macros +// utility functions +inline const coloridx &ex_to_coloridx(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_coloridx(X) (static_cast(*(X).bp)) +} // namespace GiNaC #endif // ndef __GINAC_COLORIDX_H__ diff --git a/ginac/constant.cpp b/ginac/constant.cpp index 4e866eaf..30ccb887 100644 --- a/ginac/constant.cpp +++ b/ginac/constant.cpp @@ -26,6 +26,9 @@ #include "constant.h" #include "numeric.h" #include "ex.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -161,3 +164,5 @@ const constant EulerGamma("EulerGamma", EulerGammaEvalf); /** Euler's constant. (0.57721...) Sometimes called Euler-Mascheroni constant. * Diverts straight into CLN for evalf(). */ const constant Catalan("Catalan", CatalanEvalf); + +} // namespace GiNaC diff --git a/ginac/constant.h b/ginac/constant.h index c5c90c03..89cb7eba 100644 --- a/ginac/constant.h +++ b/ginac/constant.h @@ -26,6 +26,8 @@ #include #include +namespace GiNaC { + /** This class holds constants, symbols with specific numerical value. Each * object of this class must either provide their own function to evaluate it * to class numeric or provide the constant as a numeric (if it's an exact @@ -88,4 +90,6 @@ extern const constant Pi; extern const constant Catalan; extern const constant EulerGamma; +} // namespace GiNaC + #endif // ndef __GINAC_CONSTANT_H__ diff --git a/ginac/container.pl b/ginac/container.pl index 4f838e68..7a7b3e9d 100755 --- a/ginac/container.pl +++ b/ginac/container.pl @@ -89,7 +89,9 @@ END_OF_LET_OP_IMPLEMENTATION $interface=< #include +#include + +namespace GiNaC { typedef ${STLHEADER} ${STLT}; @@ -212,9 +217,13 @@ protected: extern const ${CONTAINER} some_${CONTAINER}; extern type_info const & typeid_${CONTAINER}; -// macros +// utility functions +inline const ${CONTAINER} &ex_to_${CONTAINER}(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_${CONTAINER}(X) (static_cast<${CONTAINER} const &>(*(X).bp)) +} // namespace GiNaC #endif // ndef __GINAC_${CONTAINER_UC}_H__ @@ -223,7 +232,9 @@ END_OF_INTERFACE $implementation=< + #ifdef _DEBUG #define VERBOSE #define DOASSERT (VERBOSE||DEBUG) @@ -39,10 +41,7 @@ #define LOGLEVEL_ALL 0xffff #define LOGMASK (LOGLEVEL_PRINT) -// #define LOGMASK (LOGLEVEL_PRINT | LOGLEVEL_ASSIGNMENT | LOGLEVEL_OPERATOR | LOGLEVEL_DUPLICATE | LOGLEVEL_OPERATOR | LOGLEVEL_MEMBER_FUNCTION | LOGLEVEL_NONMEMBER_FUNCTION ) - -#include -#include +// #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; @@ -50,10 +49,4 @@ #define debugmsg(msg, loglevel) #endif // def VERBOSE -#ifdef DOASSERT -#define ASSERT(X) assert(X) -#else -#define ASSERT(X) ((void)0) -#endif - #endif // ndef __GINAC_DEBUGMSG_H__ diff --git a/ginac/diff.cpp b/ginac/diff.cpp index dec8dc7d..167d4939 100644 --- a/ginac/diff.cpp +++ b/ginac/diff.cpp @@ -37,6 +37,8 @@ #include "series.h" #include "symbol.h" +namespace GiNaC { + /** Default implementation of ex::diff(). It prints and error message and returns a fail object. * @see ex::diff */ ex basic::diff(symbol const & s) const @@ -198,7 +200,7 @@ ex series::diff(symbol const & s) const epvector new_seq; epvector::const_iterator it = seq.begin(), itend = seq.end(); - //!! coeff might depend on var + // FIXME: coeff might depend on var while (it != itend) { if (is_order_function(it->rest)) { new_seq.push_back(expair(it->rest, it->coeff - 1)); @@ -237,3 +239,5 @@ ex ex::diff(symbol const & s, unsigned nth) const } return ndiff; } + +} // namespace GiNaC diff --git a/ginac/ex.cpp b/ginac/ex.cpp index 147cd97f..e036af53 100644 --- a/ginac/ex.cpp +++ b/ginac/ex.cpp @@ -28,6 +28,9 @@ #include "ncmul.h" #include "numeric.h" #include "power.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -511,3 +514,4 @@ ex const & exMINUSHALF(void) return *eMINUSHALF; } +} // namespace GiNaC diff --git a/ginac/ex.h b/ginac/ex.h index de54e7c9..0de91a17 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -27,6 +27,8 @@ #include #include +namespace GiNaC { + class ex; class expand_options; class status_flags; @@ -63,7 +65,6 @@ public: #ifdef INLINE_EX_CONSTRUCTORS : bp(exZERO().bp) { - debugmsg("ex default constructor",LOGLEVEL_CONSTRUCT); ASSERT(exZERO().bp!=0); ASSERT(exZERO().bp->flags & status_flags::dynallocated); ASSERT(bp!=0); @@ -76,7 +77,6 @@ public: ~ex() #ifdef INLINE_EX_CONSTRUCTORS { - debugmsg("ex destructor",LOGLEVEL_DESTRUCT); ASSERT(bp!=0); ASSERT(bp->flags & status_flags::dynallocated); if (--bp->refcount == 0) { @@ -91,7 +91,6 @@ public: #ifdef INLINE_EX_CONSTRUCTORS : bp(other.bp) { - debugmsg("ex copy constructor",LOGLEVEL_CONSTRUCT); ASSERT(bp!=0); ASSERT((bp->flags) & status_flags::dynallocated); ++bp->refcount; @@ -103,7 +102,6 @@ public: ex const & operator=(ex const & other) #ifdef INLINE_EX_CONSTRUCTORS { - debugmsg("ex operator=",LOGLEVEL_ASSIGNMENT); ASSERT(bp!=0); ASSERT(bp->flags & status_flags::dynallocated); ASSERT(other.bp!=0); @@ -125,7 +123,6 @@ public: ex(basic const & other) #ifdef INLINE_EX_CONSTRUCTORS { - debugmsg("ex constructor from basic",LOGLEVEL_CONSTRUCT); construct_from_basic(other); } #else @@ -230,9 +227,14 @@ private: public: basic *bp; - }; +// utility functions +inline bool are_ex_trivially_equal(const ex &e1, const ex &e2) +{ + return e1.bp == e2.bp; +} + // wrapper functions around member functions inline int nops(ex const & thisex) { return thisex.nops(); } @@ -282,4 +284,6 @@ inline ex subs(ex const & thisex, lst const & ls, lst const & lr) inline void swap(ex & e1, ex & e2) { e1.swap(e2); } +} // namespace GiNaC + #endif // ndef __GINAC_EX_H__ diff --git a/ginac/expair.h b/ginac/expair.h index a066382a..0a986775 100644 --- a/ginac/expair.h +++ b/ginac/expair.h @@ -26,6 +26,8 @@ #include #include +namespace GiNaC { + /** A pair of expressions. * This similar to, but slightly extended STL's pair<> but we need to account * for methods like .compare() */ @@ -195,4 +197,6 @@ public: } }; +} // namespace GiNaC + #endif // ndef __GINAC_EXPAIR_H__ diff --git a/ginac/expairseq.cpp b/ginac/expairseq.cpp index f9347e0b..f74be45e 100644 --- a/ginac/expairseq.cpp +++ b/ginac/expairseq.cpp @@ -26,9 +26,12 @@ #include "expairseq.h" #include "lst.h" +#include "debugmsg.h" + +namespace GiNaC { #ifdef EXPAIRSEQ_USE_HASHTAB -#error "!!!!!!!!TODO: expair_needs_further_processing not yet implemented for hashtabs, sorry. A.F." +#error "FIXME: expair_needs_further_processing not yet implemented for hashtabs, sorry. A.F." #endif // def EXPAIRSEQ_USE_HASHTAB ////////// @@ -1623,3 +1626,4 @@ unsigned expairseq::hashtabfactor=1; const expairseq some_expairseq; type_info const & typeid_expairseq=typeid(some_expairseq); +} // namespace GiNaC diff --git a/ginac/expairseq.h b/ginac/expairseq.h index 55be7cfd..a14cecaa 100644 --- a/ginac/expairseq.h +++ b/ginac/expairseq.h @@ -27,6 +27,8 @@ #include #include +namespace GiNaC { + //#define EXPAIRSEQ_USE_HASHTAB typedef vector epvector; @@ -34,7 +36,6 @@ typedef epvector::iterator epviter; inline void iter_swap(epvector::iterator it1, epvector::iterator it2) { - debugmsg("iter_swap epvector",LOGLEVEL_NONMEMBER_FUNCTION); (*it1).rest.swap((*it2).rest); (*it1).coeff.swap((*it2).coeff); } @@ -59,11 +60,9 @@ public: , hashtabsize(0) #endif // def EXPAIRSEQ_USE_HASHTAB { - debugmsg("expairseq default constructor",LOGLEVEL_CONSTRUCT); } ~expairseq() { - debugmsg("expairseq destructor",LOGLEVEL_DESTRUCT); destroy(0); } expairseq(expairseq const & other); @@ -189,6 +188,12 @@ protected: extern const expairseq some_expairseq; extern type_info const & typeid_expairseq; -#define ex_to_expairseq(X) static_cast(*(X).bp) +// utility functions +inline const expairseq &ex_to_expairseq(const ex &e) +{ + return static_cast(*e.bp); +} + +} // namespace GiNaC #endif // ndef __GINAC_EXPAIRSEQ_H__ diff --git a/ginac/exprseq.cpp b/ginac/exprseq.cpp index 32970155..e8d6406b 100644 --- a/ginac/exprseq.cpp +++ b/ginac/exprseq.cpp @@ -1,6 +1,8 @@ /** @file exprseq.cpp * - * Implementation of GiNaC's exprseq. + * Implementation of GiNaC's exprseq. */ + +/* * This file was generated automatically by container.pl. * Please do not modify it directly, edit the perl script instead! * container.pl options: $CONTAINER=exprseq @@ -9,9 +11,8 @@ * $prepend=0 * $let_op=0 * $open_bracket=( - * $close_bracket=) */ - -/* + * $close_bracket=) + * * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -34,6 +35,9 @@ #include "exprseq.h" #include "ex.h" +#include "debugmsg.h" + +namespace GiNaC { #define RESERVE(s,size) (s).reserve(size) @@ -611,3 +615,5 @@ unsigned exprseq::precedence=10; const exprseq some_exprseq; type_info const & typeid_exprseq=typeid(some_exprseq); +} // namespace GiNaC + diff --git a/ginac/exprseq.h b/ginac/exprseq.h index 179cfbde..59f6821f 100644 --- a/ginac/exprseq.h +++ b/ginac/exprseq.h @@ -1,6 +1,8 @@ /** @file exprseq.h * - * Definition of GiNaC's exprseq. + * Definition of GiNaC's exprseq. */ + +/* * This file was generated automatically by container.pl. * Please do not modify it directly, edit the perl script instead! * container.pl options: $CONTAINER=exprseq @@ -9,9 +11,8 @@ * $prepend=0 * $let_op=0 * $open_bracket=( - * $close_bracket=) */ - -/* + * $close_bracket=) + * * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -34,6 +35,9 @@ #include #include +#include + +namespace GiNaC { typedef vector exvector; @@ -124,9 +128,13 @@ protected: extern const exprseq some_exprseq; extern type_info const & typeid_exprseq; -// macros +// utility functions +inline const exprseq &ex_to_exprseq(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_exprseq(X) (static_cast(*(X).bp)) +} // namespace GiNaC #endif // ndef __GINAC_EXPRSEQ_H__ diff --git a/ginac/exprseq_suppl.cpp b/ginac/exprseq_suppl.cpp index f4355d79..5e96830d 100644 --- a/ginac/exprseq_suppl.cpp +++ b/ginac/exprseq_suppl.cpp @@ -24,6 +24,8 @@ #include "exprseq.h" #include "ex.h" +namespace GiNaC { + bool exprseq::info(unsigned inf) const { if (inf==info_flags::exprseq) return 1; @@ -38,3 +40,4 @@ ex & exprseq::let_op(int const i) return seq[i]; } +} // namespace GiNaC diff --git a/ginac/fail.cpp b/ginac/fail.cpp index 3dc847b9..e5800a38 100644 --- a/ginac/fail.cpp +++ b/ginac/fail.cpp @@ -22,6 +22,9 @@ */ #include "fail.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -120,3 +123,4 @@ int fail::compare_same_type(basic const & other) const const fail some_fail; type_info const & typeid_fail=typeid(some_fail); +} // namespace GiNaC diff --git a/ginac/fail.h b/ginac/fail.h index 2fc383ef..7edc7b1b 100644 --- a/ginac/fail.h +++ b/ginac/fail.h @@ -26,6 +26,8 @@ #include +namespace GiNaC { + class fail : public basic { // member functions @@ -67,6 +69,6 @@ protected: extern const fail some_fail; extern type_info const & typeid_fail; -#endif // ndef __GINAC_FAIL_H__ - +} // namespace GiNaC +#endif // ndef __GINAC_FAIL_H__ diff --git a/ginac/flags.h b/ginac/flags.h index 2057baa2..90f4e38d 100644 --- a/ginac/flags.h +++ b/ginac/flags.h @@ -23,6 +23,8 @@ #ifndef __GINAC_FLAGS_H__ #define __GINAC_FLAGS_H__ +namespace GiNaC { + class expand_options { public: enum { expand_trigonometric = 0x0001 @@ -112,4 +114,6 @@ public: }; }; +} // namespace GiNaC + #endif // ndef __GINAC_FLAGS_H__ diff --git a/ginac/function.cpp b/ginac/function.cpp index 1870dedd..d8532066 100644 --- a/ginac/function.cpp +++ b/ginac/function.cpp @@ -1,12 +1,12 @@ /** @file function.cpp * - * Implementation of class function. - * - * This file was generated automatically by function.pl. - * Please do not modify it directly, edit the perl script instead! - * function.pl options: $maxargs=10 */ + * Implementation of class function. */ /* + * This file was generated automatically by function.pl. + * Please do not modify it directly, edit the perl script instead! + * function.pl options: $maxargs=10 + * * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -29,6 +29,9 @@ #include "function.h" #include "ex.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -607,3 +610,5 @@ unsigned function::register_new(char const * nm, eval_funcp_10 e, const function some_function; type_info const & typeid_function=typeid(some_function); +} // namespace GiNaC + diff --git a/ginac/function.h b/ginac/function.h index 4666e177..f4350a11 100644 --- a/ginac/function.h +++ b/ginac/function.h @@ -1,12 +1,12 @@ /** @file function.h * - * Interface to abstract class function (new function concept). - * - * This file was generated automatically by function.pl. - * Please do not modify it directly, edit the perl script instead! - * function.pl options: $maxargs=10 */ + * Interface to abstract class function (new function concept). */ /* + * This file was generated automatically by function.pl. + * Please do not modify it directly, edit the perl script instead! + * function.pl options: $maxargs=10 + * * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -31,74 +31,72 @@ #include #include -class function; - // the following lines have been generated for max. 10 parameters #define DECLARE_FUNCTION_1P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1) { \ - return function(function_index_##NAME, p1); \ +inline GiNaC::function NAME(GiNaC::ex const & p1) { \ + return GiNaC::function(function_index_##NAME, p1); \ } #define DECLARE_FUNCTION_2P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2) { \ - return function(function_index_##NAME, p1, p2); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2) { \ + return GiNaC::function(function_index_##NAME, p1, p2); \ } #define DECLARE_FUNCTION_3P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2, ex const & p3) { \ - return function(function_index_##NAME, p1, p2, p3); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2, GiNaC::ex const & p3) { \ + return GiNaC::function(function_index_##NAME, p1, p2, p3); \ } #define DECLARE_FUNCTION_4P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4) { \ - return function(function_index_##NAME, p1, p2, p3, p4); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2, GiNaC::ex const & p3, GiNaC::ex const & p4) { \ + return GiNaC::function(function_index_##NAME, p1, p2, p3, p4); \ } #define DECLARE_FUNCTION_5P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5) { \ - return function(function_index_##NAME, p1, p2, p3, p4, p5); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2, GiNaC::ex const & p3, GiNaC::ex const & p4, GiNaC::ex const & p5) { \ + return GiNaC::function(function_index_##NAME, p1, p2, p3, p4, p5); \ } #define DECLARE_FUNCTION_6P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6) { \ - return function(function_index_##NAME, p1, p2, p3, p4, p5, p6); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2, GiNaC::ex const & p3, GiNaC::ex const & p4, GiNaC::ex const & p5, GiNaC::ex const & p6) { \ + return GiNaC::function(function_index_##NAME, p1, p2, p3, p4, p5, p6); \ } #define DECLARE_FUNCTION_7P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6, ex const & p7) { \ - return function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2, GiNaC::ex const & p3, GiNaC::ex const & p4, GiNaC::ex const & p5, GiNaC::ex const & p6, GiNaC::ex const & p7) { \ + return GiNaC::function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7); \ } #define DECLARE_FUNCTION_8P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6, ex const & p7, ex const & p8) { \ - return function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2, GiNaC::ex const & p3, GiNaC::ex const & p4, GiNaC::ex const & p5, GiNaC::ex const & p6, GiNaC::ex const & p7, GiNaC::ex const & p8) { \ + return GiNaC::function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8); \ } #define DECLARE_FUNCTION_9P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6, ex const & p7, ex const & p8, ex const & p9) { \ - return function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2, GiNaC::ex const & p3, GiNaC::ex const & p4, GiNaC::ex const & p5, GiNaC::ex const & p6, GiNaC::ex const & p7, GiNaC::ex const & p8, GiNaC::ex const & p9) { \ + return GiNaC::function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8, p9); \ } #define DECLARE_FUNCTION_10P(NAME) \ extern unsigned function_index_##NAME; \ -inline function NAME(ex const & p1, ex const & p2, ex const & p3, ex const & p4, ex const & p5, ex const & p6, ex const & p7, ex const & p8, ex const & p9, ex const & p10) { \ - return function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ +inline GiNaC::function NAME(GiNaC::ex const & p1, GiNaC::ex const & p2, GiNaC::ex const & p3, GiNaC::ex const & p4, GiNaC::ex const & p5, GiNaC::ex const & p6, GiNaC::ex const & p7, GiNaC::ex const & p8, GiNaC::ex const & p9, GiNaC::ex const & p10) { \ + return GiNaC::function(function_index_##NAME, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ } // end of generated lines #define REGISTER_FUNCTION(NAME,E,EF,D,S) \ -unsigned function_index_##NAME=function::register_new(#NAME,E,EF,D,S); +unsigned function_index_##NAME=GiNaC::function::register_new(#NAME,E,EF,D,S); #define BEGIN_TYPECHECK \ bool automatic_typecheck=true; @@ -109,7 +107,7 @@ if (!is_ex_exactly_of_type(VAR,TYPE)) { \ } else #define TYPECHECK_INTEGER(VAR) \ -if (!(VAR).info(info_flags::integer)) { \ +if (!(VAR).info(GiNaC::info_flags::integer)) { \ automatic_typecheck=false; \ } else @@ -119,6 +117,10 @@ if (!automatic_typecheck) { \ return RV.hold(); \ } +namespace GiNaC { + +class function; + typedef ex (* eval_funcp)(); typedef ex (* evalf_funcp)(); typedef ex (* diff_funcp)(); @@ -281,11 +283,14 @@ protected: // utility macros #define is_ex_the_function(OBJ, FUNCNAME) \ - (is_ex_exactly_of_type(OBJ, function) && static_cast(OBJ.bp)->getserial() == function_index_##FUNCNAME) + (is_ex_exactly_of_type(OBJ, function) && static_cast(OBJ.bp)->getserial() == function_index_##FUNCNAME) // global constants extern const function some_function; extern type_info const & typeid_function; +} // namespace GiNaC + #endif // ndef __GINAC_FUNCTION_H__ + diff --git a/ginac/function.pl b/ginac/function.pl index 1a1fcbaa..7167d984 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -32,11 +32,11 @@ sub generate { } $declare_function_macro=generate( - <<'END_OF_DECLARE_FUNCTION_MACRO','ex const & p${N}','p${N}'); + <<'END_OF_DECLARE_FUNCTION_MACRO','GiNaC::ex const & p${N}','p${N}'); #define DECLARE_FUNCTION_${N}P(NAME) \\ extern unsigned function_index_##NAME; \\ -inline function NAME(${SEQ1}) { \\ - return function(function_index_##NAME, ${SEQ2}); \\ +inline GiNaC::function NAME(${SEQ1}) { \\ + return GiNaC::function(function_index_##NAME, ${SEQ2}); \\ } END_OF_DECLARE_FUNCTION_MACRO @@ -119,8 +119,9 @@ END_OF_REGISTER_NEW_IMPLEMENTATION $interface=< #include -class function; - // the following lines have been generated for max. ${maxargs} parameters $declare_function_macro // end of generated lines #define REGISTER_FUNCTION(NAME,E,EF,D,S) \\ -unsigned function_index_##NAME=function::register_new(#NAME,E,EF,D,S); +unsigned function_index_##NAME=GiNaC::function::register_new(#NAME,E,EF,D,S); #define BEGIN_TYPECHECK \\ bool automatic_typecheck=true; @@ -167,7 +166,7 @@ if (!is_ex_exactly_of_type(VAR,TYPE)) { \\ } else #define TYPECHECK_INTEGER(VAR) \\ -if (!(VAR).info(info_flags::integer)) { \\ +if (!(VAR).info(GiNaC::info_flags::integer)) { \\ automatic_typecheck=false; \\ } else @@ -177,6 +176,10 @@ if (!automatic_typecheck) { \\ return RV.hold(); \\ } +namespace GiNaC { + +class function; + typedef ex (* eval_funcp)(); typedef ex (* evalf_funcp)(); typedef ex (* diff_funcp)(); @@ -269,13 +272,15 @@ protected: // utility macros #define is_ex_the_function(OBJ, FUNCNAME) \\ - (is_ex_exactly_of_type(OBJ, function) && static_cast(OBJ.bp)->getserial() == function_index_##FUNCNAME) + (is_ex_exactly_of_type(OBJ, function) && static_cast(OBJ.bp)->getserial() == function_index_##FUNCNAME) // global constants extern const function some_function; extern type_info const & typeid_function; +} // namespace GiNaC + #endif // ndef __GINAC_FUNCTION_H__ END_OF_INTERFACE @@ -283,8 +288,9 @@ END_OF_INTERFACE $implementation=< #include #include -#endif /* ndef GINAC_BASE_ONLY */ +#endif // ndef GINAC_BASE_ONLY -#endif /* ndef __GINAC_H__ */ +#endif // ndef __GINAC_H__ diff --git a/ginac/idx.cpp b/ginac/idx.cpp index 8de753c1..26e91ff8 100644 --- a/ginac/idx.cpp +++ b/ginac/idx.cpp @@ -27,6 +27,9 @@ #include "lst.h" #include "relational.h" #include "utils.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -443,6 +446,4 @@ ex subs_indices(ex const & e, exvector const & idxv_subs, return res; } - - - +} // namespace GiNaC diff --git a/ginac/idx.h b/ginac/idx.h index 2faced84..fa0b8ce3 100644 --- a/ginac/idx.h +++ b/ginac/idx.h @@ -26,6 +26,9 @@ #include #include #include +#include + +namespace GiNaC { class idx : public basic { @@ -89,11 +92,13 @@ protected: extern const idx some_idx; extern type_info const & typeid_idx; -// macros - -#define ex_to_idx(X) (static_cast(*(X).bp)) +// utility functions +inline const idx &ex_to_idx(const ex &e) +{ + return static_cast(*e.bp); +} -// other functions +// global functions typedef vector exvector; @@ -106,4 +111,6 @@ ex subs_indices(ex const & e, exvector const & idxv_contra, exvector const & idxv_co); unsigned count_index(ex const & e, ex const & i); +} // namespace GiNaC + #endif // ndef __GINAC_IDX_H__ diff --git a/ginac/indexed.cpp b/ginac/indexed.cpp index 0804330b..48a8c948 100644 --- a/ginac/indexed.cpp +++ b/ginac/indexed.cpp @@ -25,6 +25,9 @@ #include "indexed.h" #include "ex.h" #include "idx.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -289,3 +292,4 @@ bool indexed::all_of_type_idx(void) const const indexed some_indexed; type_info const & typeid_indexed=typeid(some_indexed); +} // namespace GiNaC diff --git a/ginac/indexed.h b/ginac/indexed.h index 7f13af51..3707e629 100644 --- a/ginac/indexed.h +++ b/ginac/indexed.h @@ -26,6 +26,8 @@ #include #include +namespace GiNaC { + /** Base class for non-commutative indexed objects */ class indexed : public exprseq { @@ -86,10 +88,12 @@ protected: extern const indexed some_indexed; extern type_info const & typeid_indexed; -// macros +// utility functions +inline const indexed &ex_to_indexed(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_indexed(X) static_cast(*(X).bp) +} // namespace GiNaC #endif // ndef __GINAC_INDEXED_H__ - - diff --git a/ginac/inifcns.cpp b/ginac/inifcns.cpp index f9b797ee..5eb4466c 100644 --- a/ginac/inifcns.cpp +++ b/ginac/inifcns.cpp @@ -36,6 +36,8 @@ #include "series.h" #include "symbol.h" +namespace GiNaC { + ////////// // dilogarithm ////////// @@ -244,3 +246,5 @@ ex ncpower(ex const &basis, unsigned exponent) return ncmul(v,1); } + +} // namespace GiNaC diff --git a/ginac/inifcns.h b/ginac/inifcns.h index f4af0cb8..42f38389 100644 --- a/ginac/inifcns.h +++ b/ginac/inifcns.h @@ -26,6 +26,8 @@ #include #include +namespace GiNaC { + /** Sine. */ DECLARE_FUNCTION_1P(sin) @@ -98,4 +100,6 @@ inline bool is_order_function(ex const & e) return is_ex_the_function(e, Order); } +} // namespace GiNaC + #endif // ndef __GINAC_INIFCNS_H__ diff --git a/ginac/inifcns_gamma.cpp b/ginac/inifcns_gamma.cpp index 34a390ed..5683fd21 100644 --- a/ginac/inifcns_gamma.cpp +++ b/ginac/inifcns_gamma.cpp @@ -30,6 +30,8 @@ #include "power.h" #include "symbol.h" +namespace GiNaC { + ////////// // gamma function ////////// @@ -87,12 +89,12 @@ ex gamma_diff(ex const & x, unsigned diff_param) { ASSERT(diff_param==0); - return power(x, -1); //!! + return power(x, -1); // FIXME } ex gamma_series(ex const & x, symbol const & s, ex const & point, int order) { - //!! Only handle one special case for now... + // FIXME: Only handle one special case for now... if (x.is_equal(s) && point.is_zero()) { ex e = 1 / s - EulerGamma + s * (power(Pi, 2) / 12 + power(EulerGamma, 2) / 2) + Order(power(s, 2)); return e.series(s, point, order); @@ -101,3 +103,5 @@ ex gamma_series(ex const & x, symbol const & s, ex const & point, int order) } REGISTER_FUNCTION(gamma, gamma_eval, gamma_evalf, gamma_diff, gamma_series); + +} // namespace GiNaC diff --git a/ginac/inifcns_trans.cpp b/ginac/inifcns_trans.cpp index 41065733..e26050a6 100644 --- a/ginac/inifcns_trans.cpp +++ b/ginac/inifcns_trans.cpp @@ -30,6 +30,8 @@ #include "numeric.h" #include "power.h" +namespace GiNaC { + ////////// // exponential function ////////// @@ -737,3 +739,5 @@ ex atanh_diff(ex const & x, unsigned diff_param) } REGISTER_FUNCTION(atanh, atanh_eval, atanh_evalf, atanh_diff, NULL); + +} // namespace GiNaC diff --git a/ginac/isospin.cpp b/ginac/isospin.cpp index 3cc6b5e1..672ea924 100644 --- a/ginac/isospin.cpp +++ b/ginac/isospin.cpp @@ -27,6 +27,9 @@ #include "ex.h" #include "ncmul.h" #include "utils.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -208,3 +211,4 @@ unsigned isospin::next_serial=0; const isospin some_isospin; type_info const & typeid_isospin=typeid(some_isospin); +} // namespace GiNaC diff --git a/ginac/isospin.h b/ginac/isospin.h index 81c96dc3..c4d23864 100644 --- a/ginac/isospin.h +++ b/ginac/isospin.h @@ -26,6 +26,8 @@ #include #include +namespace GiNaC { + /** Base class for isospin object */ class isospin : public indexed { @@ -81,10 +83,12 @@ private: extern const isospin some_isospin; extern type_info const & typeid_isospin; -// macros +// utility functions +inline const isospin &ex_to_isospin(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_isospin(X) static_cast(*(X).bp) +} // namespace GiNaC #endif // ndef __GINAC_ISOSPIN_H__ - - diff --git a/ginac/lorentzidx.cpp b/ginac/lorentzidx.cpp index 3719f15b..3e69d30d 100644 --- a/ginac/lorentzidx.cpp +++ b/ginac/lorentzidx.cpp @@ -24,6 +24,9 @@ #include "lorentzidx.h" #include "utils.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -248,5 +251,4 @@ lorentzidx lorentzidx::create_anonymous_representative(void) const const lorentzidx some_lorentzidx; type_info const & typeid_lorentzidx=typeid(some_lorentzidx); - - +} // namespace GiNaC diff --git a/ginac/lorentzidx.h b/ginac/lorentzidx.h index 7fc2a05d..1a429021 100644 --- a/ginac/lorentzidx.h +++ b/ginac/lorentzidx.h @@ -27,6 +27,8 @@ #include #include +namespace GiNaC { + class lorentzidx : public idx { friend class simp_lor; @@ -81,8 +83,12 @@ protected: extern const lorentzidx some_lorentzidx; extern type_info const & typeid_lorentzidx; -// macros +// utility functions +inline const lorentzidx &ex_to_lorentzidx(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_lorentzidx(X) (static_cast(*(X).bp)) +} // namespace GiNaC #endif // ndef __GINAC_LORENTZIDX_H__ diff --git a/ginac/lst.cpp b/ginac/lst.cpp index b05c48aa..a71f5dda 100644 --- a/ginac/lst.cpp +++ b/ginac/lst.cpp @@ -1,6 +1,8 @@ /** @file lst.cpp * - * Implementation of GiNaC's lst. + * Implementation of GiNaC's lst. */ + +/* * This file was generated automatically by container.pl. * Please do not modify it directly, edit the perl script instead! * container.pl options: $CONTAINER=lst @@ -9,9 +11,8 @@ * $prepend=1 * $let_op=1 * $open_bracket=[ - * $close_bracket=] */ - -/* + * $close_bracket=] + * * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -34,6 +35,9 @@ #include "lst.h" #include "ex.h" +#include "debugmsg.h" + +namespace GiNaC { #define RESERVE(s,size) // no reserve needed for list @@ -628,3 +632,5 @@ unsigned lst::precedence=10; const lst some_lst; type_info const & typeid_lst=typeid(some_lst); +} // namespace GiNaC + diff --git a/ginac/lst.h b/ginac/lst.h index beeb9a3d..901638e5 100644 --- a/ginac/lst.h +++ b/ginac/lst.h @@ -1,6 +1,8 @@ /** @file lst.h * - * Definition of GiNaC's lst. + * Definition of GiNaC's lst. */ + +/* * This file was generated automatically by container.pl. * Please do not modify it directly, edit the perl script instead! * container.pl options: $CONTAINER=lst @@ -9,9 +11,8 @@ * $prepend=1 * $let_op=1 * $open_bracket=[ - * $close_bracket=] */ - -/* + * $close_bracket=] + * * GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany * * This program is free software; you can redistribute it and/or modify @@ -34,6 +35,9 @@ #include #include +#include + +namespace GiNaC { typedef list exlist; @@ -125,9 +129,13 @@ protected: extern const lst some_lst; extern type_info const & typeid_lst; -// macros +// utility functions +inline const lst &ex_to_lst(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_lst(X) (static_cast(*(X).bp)) +} // namespace GiNaC #endif // ndef __GINAC_LST_H__ diff --git a/ginac/lst_suppl.cpp b/ginac/lst_suppl.cpp index 71463df7..927a503c 100644 --- a/ginac/lst_suppl.cpp +++ b/ginac/lst_suppl.cpp @@ -23,10 +23,12 @@ #include "lst.h" +namespace GiNaC { + bool lst::info(unsigned inf) const { if (inf==info_flags::list) return 1; return basic::info(inf); } - +} // namespace GiNaC diff --git a/ginac/matrix.cpp b/ginac/matrix.cpp index 34d5f2f9..3fd31fcb 100644 --- a/ginac/matrix.cpp +++ b/ginac/matrix.cpp @@ -24,6 +24,9 @@ #include #include "matrix.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor, assignment operator @@ -868,3 +871,5 @@ int matrix::pivot(int ro) const matrix some_matrix; type_info const & typeid_matrix=typeid(some_matrix); + +} // namespace GiNaC diff --git a/ginac/matrix.h b/ginac/matrix.h index 235fbda4..769647ca 100644 --- a/ginac/matrix.h +++ b/ginac/matrix.h @@ -27,6 +27,8 @@ #include #include +namespace GiNaC { + /** Symbolic matrices. */ class matrix : public basic { @@ -144,8 +146,12 @@ inline ex charpoly(matrix const & m, ex const & lambda) inline matrix inverse(matrix const & m) { return m.inverse(); } -// macros +// utility functions +inline const matrix &ex_to_matrix(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_matrix(X) (static_cast(*(X).bp)) +} // namespace GiNaC #endif // ndef __GINAC_MATRIX_H__ diff --git a/ginac/mul.cpp b/ginac/mul.cpp index e3cbd78a..5054fb06 100644 --- a/ginac/mul.cpp +++ b/ginac/mul.cpp @@ -26,6 +26,9 @@ #include "mul.h" #include "add.h" #include "power.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -1011,4 +1014,4 @@ unsigned mul::precedence=50; const mul some_mul; type_info const & typeid_mul=typeid(some_mul); - +} // namespace GiNaC diff --git a/ginac/mul.h b/ginac/mul.h index 46b3791e..4e5a6e63 100644 --- a/ginac/mul.h +++ b/ginac/mul.h @@ -25,6 +25,8 @@ #include +namespace GiNaC { + /** Product of expressions. */ class mul : public expairseq { @@ -113,6 +115,12 @@ protected: extern const mul some_mul; extern type_info const & typeid_mul; -#define ex_to_mul(X) static_cast(*(X).bp) +// utility functions +inline const mul &ex_to_mul(const ex &e) +{ + return static_cast(*e.bp); +} + +} // namespace GiNaC #endif // ndef __GINAC_MUL_H__ diff --git a/ginac/ncmul.cpp b/ginac/ncmul.cpp index 74c39546..7d2364e2 100644 --- a/ginac/ncmul.cpp +++ b/ginac/ncmul.cpp @@ -28,6 +28,9 @@ #include "ex.h" #include "add.h" #include "mul.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -588,4 +591,4 @@ ex simplified_ncmul(exvector const & v) status_flags::evaluated); } - +} // namespace GiNaC diff --git a/ginac/ncmul.h b/ginac/ncmul.h index 458c5ecc..03b47ca7 100644 --- a/ginac/ncmul.h +++ b/ginac/ncmul.h @@ -25,6 +25,8 @@ #include +namespace GiNaC { + /** Non-commutative product of expressions. */ class ncmul : public exprseq { @@ -106,7 +108,12 @@ extern type_info const & typeid_ncmul; ex nonsimplified_ncmul(exvector const & v); ex simplified_ncmul(exvector const & v); -#define ex_to_ncmul(X) static_cast(*(X).bp) +// utility functions +inline const ncmul &ex_to_ncmul(const ex &e) +{ + return static_cast (*e.bp); +} + +} // namespace GiNaC #endif // ndef __GINAC_NCMUL_H__ - diff --git a/ginac/normal.cpp b/ginac/normal.cpp index 65c81098..82fcaf84 100644 --- a/ginac/normal.cpp +++ b/ginac/normal.cpp @@ -25,6 +25,8 @@ */ #include +#include +#include #include "normal.h" #include "basic.h" @@ -44,6 +46,8 @@ #include "series.h" #include "symbol.h" +namespace GiNaC { + // If comparing expressions (ex::compare()) is fast, you can set this to 1. // Some routines like quo(), rem() and gcd() will then return a quick answer // when they are called with two identical arguments. @@ -82,8 +86,6 @@ static bool get_first_symbol(const ex &e, const symbol *&x) * Statistical information about symbols in polynomials */ -#include - /** This structure holds information about the highest and lowest degrees * in which a symbol appears in two multivariate polynomials "a" and "b". * A vector of these structures with information about all symbols in @@ -489,8 +491,6 @@ bool divide(const ex &a, const ex &b, ex &q, bool check_args) * Remembering */ -#include - typedef pair ex2; typedef pair exbool; @@ -908,7 +908,7 @@ ex basic::smod(const numeric &xi) const ex numeric::smod(const numeric &xi) const { - return ::smod(*this, xi); + return GiNaC::smod(*this, xi); } ex add::smod(const numeric &xi) const @@ -919,13 +919,13 @@ ex add::smod(const numeric &xi) const epvector::const_iterator itend = seq.end(); while (it != itend) { ASSERT(!is_ex_exactly_of_type(it->rest,numeric)); - numeric coeff = ::smod(ex_to_numeric(it->coeff), xi); + numeric coeff = GiNaC::smod(ex_to_numeric(it->coeff), xi); if (!coeff.is_zero()) newseq.push_back(expair(it->rest, coeff)); it++; } ASSERT(is_ex_exactly_of_type(overall_coeff,numeric)); - numeric coeff = ::smod(ex_to_numeric(overall_coeff), xi); + numeric coeff = GiNaC::smod(ex_to_numeric(overall_coeff), xi); return (new add(newseq,coeff))->setflag(status_flags::dynallocated); } @@ -941,7 +941,7 @@ ex mul::smod(const numeric &xi) const #endif // def DOASSERT mul * mulcopyp=new mul(*this); ASSERT(is_ex_exactly_of_type(overall_coeff,numeric)); - mulcopyp->overall_coeff=::smod(ex_to_numeric(overall_coeff),xi); + mulcopyp->overall_coeff = GiNaC::smod(ex_to_numeric(overall_coeff),xi); mulcopyp->clearflag(status_flags::evaluated); mulcopyp->clearflag(status_flags::hash_calculated); return mulcopyp->setflag(status_flags::dynallocated); @@ -1484,3 +1484,5 @@ ex ex::normal(int level) const else return e; } + +} // namespace GiNaC diff --git a/ginac/normal.h b/ginac/normal.h index 879e0d4d..0fa3a441 100644 --- a/ginac/normal.h +++ b/ginac/normal.h @@ -21,8 +21,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef NORMAL_H -#define NORMAL_H +#ifndef __GINAC_NORMAL_H__ +#define __GINAC_NORMAL_H__ + +namespace GiNaC { class ex; class symbol; @@ -48,4 +50,6 @@ extern ex lcm(const ex &a, const ex &b, bool check_args = true); // Square-free factorization of a polynomial a(x) extern ex sqrfree(const ex &a, const symbol &x); -#endif +} // namespace GiNaC + +#endif // ndef __GINAC_NORMAL_H__ diff --git a/ginac/numeric.cpp b/ginac/numeric.cpp index 126a4b25..8609740e 100644 --- a/ginac/numeric.cpp +++ b/ginac/numeric.cpp @@ -30,6 +30,7 @@ #include "numeric.h" #include "ex.h" #include "config.h" +#include "debugmsg.h" // CLN should not pollute the global namespace, hence we include it here // instead of in some header file where it would propagate to other parts: @@ -39,6 +40,8 @@ #include #endif +namespace GiNaC { + // linker has no problems finding text symbols for numerator or denominator //#define SANE_LINKER @@ -851,7 +854,7 @@ const numeric some_numeric; type_info const & typeid_numeric=typeid(some_numeric); /** Imaginary unit. This is not a constant but a numeric since we are * natively handing complex numbers anyways. */ -const numeric I = (complex(cl_I(0),cl_I(1))); +const numeric I = numeric(complex(cl_I(0),cl_I(1))); ////////// // global functions @@ -904,7 +907,7 @@ numeric const & numHALF(void) * @return arbitrary precision numerical exp(x). */ numeric exp(numeric const & x) { - return exp(*x.value); // -> CLN + return ::exp(*x.value); // -> CLN } /** Natural logarithm. @@ -916,7 +919,7 @@ numeric log(numeric const & z) { if (z.is_zero()) throw (std::overflow_error("log(): logarithmic singularity")); - return log(*z.value); // -> CLN + return ::log(*z.value); // -> CLN } /** Numeric sine (trigonometric function). @@ -924,7 +927,7 @@ numeric log(numeric const & z) * @return arbitrary precision numerical sin(x). */ numeric sin(numeric const & x) { - return sin(*x.value); // -> CLN + return ::sin(*x.value); // -> CLN } /** Numeric cosine (trigonometric function). @@ -932,7 +935,7 @@ numeric sin(numeric const & x) * @return arbitrary precision numerical cos(x). */ numeric cos(numeric const & x) { - return cos(*x.value); // -> CLN + return ::cos(*x.value); // -> CLN } /** Numeric tangent (trigonometric function). @@ -940,7 +943,7 @@ numeric cos(numeric const & x) * @return arbitrary precision numerical tan(x). */ numeric tan(numeric const & x) { - return tan(*x.value); // -> CLN + return ::tan(*x.value); // -> CLN } /** Numeric inverse sine (trigonometric function). @@ -948,7 +951,7 @@ numeric tan(numeric const & x) * @return arbitrary precision numerical asin(x). */ numeric asin(numeric const & x) { - return asin(*x.value); // -> CLN + return ::asin(*x.value); // -> CLN } /** Numeric inverse cosine (trigonometric function). @@ -956,7 +959,7 @@ numeric asin(numeric const & x) * @return arbitrary precision numerical acos(x). */ numeric acos(numeric const & x) { - return acos(*x.value); // -> CLN + return ::acos(*x.value); // -> CLN } /** Arcustangents. @@ -970,7 +973,7 @@ numeric atan(numeric const & x) x.real().is_zero() && !abs(x.imag()).is_equal(numONE())) throw (std::overflow_error("atan(): logarithmic singularity")); - return atan(*x.value); // -> CLN + return ::atan(*x.value); // -> CLN } /** Arcustangents. @@ -981,7 +984,7 @@ numeric atan(numeric const & x) numeric atan(numeric const & y, numeric const & x) { if (x.is_real() && y.is_real()) - return atan(realpart(*x.value), realpart(*y.value)); // -> CLN + return ::atan(realpart(*x.value), realpart(*y.value)); // -> CLN else throw (std::invalid_argument("numeric::atan(): complex argument")); } @@ -991,7 +994,7 @@ numeric atan(numeric const & y, numeric const & x) * @return arbitrary precision numerical sinh(x). */ numeric sinh(numeric const & x) { - return sinh(*x.value); // -> CLN + return ::sinh(*x.value); // -> CLN } /** Numeric hyperbolic cosine (trigonometric function). @@ -999,7 +1002,7 @@ numeric sinh(numeric const & x) * @return arbitrary precision numerical cosh(x). */ numeric cosh(numeric const & x) { - return cosh(*x.value); // -> CLN + return ::cosh(*x.value); // -> CLN } /** Numeric hyperbolic tangent (trigonometric function). @@ -1007,7 +1010,7 @@ numeric cosh(numeric const & x) * @return arbitrary precision numerical tanh(x). */ numeric tanh(numeric const & x) { - return tanh(*x.value); // -> CLN + return ::tanh(*x.value); // -> CLN } /** Numeric inverse hyperbolic sine (trigonometric function). @@ -1015,7 +1018,7 @@ numeric tanh(numeric const & x) * @return arbitrary precision numerical asinh(x). */ numeric asinh(numeric const & x) { - return asinh(*x.value); // -> CLN + return ::asinh(*x.value); // -> CLN } /** Numeric inverse hyperbolic cosine (trigonometric function). @@ -1023,7 +1026,7 @@ numeric asinh(numeric const & x) * @return arbitrary precision numerical acosh(x). */ numeric acosh(numeric const & x) { - return acosh(*x.value); // -> CLN + return ::acosh(*x.value); // -> CLN } /** Numeric inverse hyperbolic tangent (trigonometric function). @@ -1031,7 +1034,7 @@ numeric acosh(numeric const & x) * @return arbitrary precision numerical atanh(x). */ numeric atanh(numeric const & x) { - return atanh(*x.value); // -> CLN + return ::atanh(*x.value); // -> CLN } /** The gamma function. @@ -1051,7 +1054,7 @@ numeric factorial(numeric const & nn) throw (std::range_error("numeric::factorial(): argument must be integer >= 0")); } - return numeric(factorial(nn.to_int())); // -> CLN + return numeric(::factorial(nn.to_int())); // -> CLN } /** The double factorial combinatorial function. (Scarcely used, but still @@ -1123,7 +1126,7 @@ numeric doublefactorial(numeric const & nn) numeric binomial(numeric const & n, numeric const & k) { if (n.is_nonneg_integer() && k.is_nonneg_integer()) { - return numeric(binomial(n.to_int(),k.to_int())); // -> CLN + return numeric(::binomial(n.to_int(),k.to_int())); // -> CLN } else { // should really be gamma(n+1)/(gamma(r+1)/gamma(n-r+1) return numeric(0); @@ -1134,7 +1137,7 @@ numeric binomial(numeric const & n, numeric const & k) /** Absolute value. */ numeric abs(numeric const & x) { - return abs(*x.value); // -> CLN + return ::abs(*x.value); // -> CLN } /** Modulus (in positive representation). @@ -1147,7 +1150,7 @@ numeric abs(numeric const & x) numeric mod(numeric const & a, numeric const & b) { if (a.is_integer() && b.is_integer()) { - return mod(The(cl_I)(*a.value), The(cl_I)(*b.value)); // -> CLN + return ::mod(The(cl_I)(*a.value), The(cl_I)(*b.value)); // -> CLN } else { return numZERO(); // Throw? @@ -1162,7 +1165,7 @@ numeric smod(numeric const & a, numeric const & b) { if (a.is_integer() && b.is_integer()) { cl_I b2 = The(cl_I)(ceiling1(The(cl_I)(*b.value) / 2)) - 1; - return mod(The(cl_I)(*a.value) + b2, The(cl_I)(*b.value)) - b2; + return ::mod(The(cl_I)(*a.value) + b2, The(cl_I)(*b.value)) - b2; } else { return numZERO(); // Throw? } @@ -1177,7 +1180,7 @@ numeric smod(numeric const & a, numeric const & b) numeric irem(numeric const & a, numeric const & b) { if (a.is_integer() && b.is_integer()) { - return rem(The(cl_I)(*a.value), The(cl_I)(*b.value)); // -> CLN + return ::rem(The(cl_I)(*a.value), The(cl_I)(*b.value)); // -> CLN } else { return numZERO(); // Throw? @@ -1245,7 +1248,7 @@ numeric iquo(numeric const & a, numeric const & b, numeric & r) * where imag(z)>0. */ numeric sqrt(numeric const & z) { - return sqrt(*z.value); // -> CLN + return ::sqrt(*z.value); // -> CLN } /** Integer numeric square root. */ @@ -1253,7 +1256,7 @@ numeric isqrt(numeric const & x) { if (x.is_integer()) { cl_I root; - isqrt(The(cl_I)(*x.value), &root); // -> CLN + ::isqrt(The(cl_I)(*x.value), &root); // -> CLN return root; } else return numZERO(); // Throw? @@ -1266,7 +1269,7 @@ numeric isqrt(numeric const & x) numeric gcd(numeric const & a, numeric const & b) { if (a.is_integer() && b.is_integer()) - return gcd(The(cl_I)(*a.value), The(cl_I)(*b.value)); // -> CLN + return ::gcd(The(cl_I)(*a.value), The(cl_I)(*b.value)); // -> CLN else return numONE(); } @@ -1278,7 +1281,7 @@ numeric gcd(numeric const & a, numeric const & b) numeric lcm(numeric const & a, numeric const & b) { if (a.is_integer() && b.is_integer()) - return lcm(The(cl_I)(*a.value), The(cl_I)(*b.value)); // -> CLN + return ::lcm(The(cl_I)(*a.value), The(cl_I)(*b.value)); // -> CLN else return *a.value * *b.value; } @@ -1344,3 +1347,5 @@ bool _numeric_digits::too_late = false; /** Accuracy in decimal digits. Only object of this type! Can be set using * assignment from C++ unsigned ints and evaluated like any built-in type. */ _numeric_digits Digits; + +} // namespace GiNaC diff --git a/ginac/numeric.h b/ginac/numeric.h index 01e2ad60..a460d099 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -25,12 +25,15 @@ #include #include - -#define HASHVALUE_NUMERIC 0x80000001U +#include class cl_N; // We want to include cln.h only in numeric.cpp in order to // avoid namespace pollution and keep compile-time low. +namespace GiNaC { + +#define HASHVALUE_NUMERIC 0x80000001U + /** This class is used to instantiate a global object Digits which * behaves just like Maple's Digits. We need an object rather than a * dumber basic type since as a side-effect we let it change @@ -318,7 +321,12 @@ ex PiEvalf(void); ex EulerGammaEvalf(void); ex CatalanEvalf(void); -#define ex_to_numeric(X) static_cast(*(X).bp) +// utility functions +inline const numeric &ex_to_numeric(const ex &e) +{ + return static_cast(*e.bp); +} +} // namespace GiNaC #endif // ndef __GINAC_NUMERIC_H__ diff --git a/ginac/operators.cpp b/ginac/operators.cpp index 6ccc7a81..d9882c0e 100644 --- a/ginac/operators.cpp +++ b/ginac/operators.cpp @@ -29,6 +29,9 @@ #include "numeric.h" #include "power.h" #include "relational.h" +#include "debugmsg.h" + +namespace GiNaC { // binary arithmetic operators ex with ex @@ -403,3 +406,4 @@ istream & operator>>(istream & is, ex & e) throw(std::logic_error("input from streams not yet implemented")); } +} // namespace GiNaC diff --git a/ginac/operators.h b/ginac/operators.h index cc354d86..4c95a551 100644 --- a/ginac/operators.h +++ b/ginac/operators.h @@ -25,6 +25,8 @@ #include +namespace GiNaC { + class ex; class numeric; class relational; @@ -123,4 +125,6 @@ relational operator>=(numeric const & lh, ex const & rh); ostream & operator<<(ostream & os, ex const & e); istream & operator>>(istream & is, ex & e); +} // namespace GiNaC + #endif // ndef __GINAC_OPERATORS_H__ diff --git a/ginac/power.cpp b/ginac/power.cpp index a459150d..36b5c8b4 100644 --- a/ginac/power.cpp +++ b/ginac/power.cpp @@ -31,6 +31,9 @@ #include "numeric.h" #include "relational.h" #include "symbol.h" +#include "debugmsg.h" + +namespace GiNaC { typedef vector intvector; @@ -510,7 +513,7 @@ ex power::expand_add(add const & a, int const n) const cout << "end term" << endl; */ - // TODO: optimize!!!!!!!! + // TODO: optimize this sum.push_back((new mul(term))->setflag(status_flags::dynallocated)); // increment k[] @@ -717,3 +720,5 @@ unsigned power::precedence=60; const power some_power; type_info const & typeid_power=typeid(some_power); + +} // namespace GiNaC diff --git a/ginac/power.h b/ginac/power.h index 37ce8022..3d9ae574 100644 --- a/ginac/power.h +++ b/ginac/power.h @@ -26,6 +26,8 @@ #include #include +namespace GiNaC { + class numeric; class add; @@ -103,7 +105,11 @@ protected: extern const power some_power; extern type_info const & typeid_power; -#define ex_to_power(X) static_cast(*(X).bp) +// utility functions +inline const power &ex_to_power(const ex &e) +{ + return static_cast(*e.bp); +} // wrapper functions @@ -119,5 +125,6 @@ inline ex pow(ex const & b, ex const & e) inline ex sqrt(ex const & a) { return power(a,exHALF()); } -#endif // ndef __GINAC_POWER_H__ +} // namespace GiNaC +#endif // ndef __GINAC_POWER_H__ diff --git a/ginac/print.cpp b/ginac/print.cpp index f75ad933..899c21b0 100644 --- a/ginac/print.cpp +++ b/ginac/print.cpp @@ -39,6 +39,9 @@ #include "relational.h" #include "series.h" #include "symbol.h" +#include "debugmsg.h" + +namespace GiNaC { void ex::print(ostream & os, unsigned upper_precedence) const { @@ -318,3 +321,5 @@ void matrix::print(ostream & os, unsigned upper_precedence) const } os << m[row*col-1] << "]] ]]"; } + +} // namespace GiNaC diff --git a/ginac/printcsrc.cpp b/ginac/printcsrc.cpp index 543035eb..a162ad8a 100644 --- a/ginac/printcsrc.cpp +++ b/ginac/printcsrc.cpp @@ -37,6 +37,9 @@ #include "relational.h" #include "series.h" #include "symbol.h" +#include "debugmsg.h" + +namespace GiNaC { /** Print expression as a C++ statement. The output looks like * " = ;". The "type" parameter has an effect @@ -326,3 +329,5 @@ void relational::printcsrc(ostream & os, unsigned type, unsigned upper_precedenc if (precedence <= upper_precedence) os << ")"; } + +} // namespace GiNaC diff --git a/ginac/printraw.cpp b/ginac/printraw.cpp index d1aac63e..7c66c1bb 100644 --- a/ginac/printraw.cpp +++ b/ginac/printraw.cpp @@ -43,6 +43,9 @@ #include "relational.h" #include "series.h" #include "symbol.h" +#include "debugmsg.h" + +namespace GiNaC { void ex::printraw(ostream & os) const { @@ -221,3 +224,5 @@ void matrix::printraw(ostream & os) const } os << m[row*col-1] << "))"; } + +} // namespace GiNaC diff --git a/ginac/printtree.cpp b/ginac/printtree.cpp index 38706f69..a7b09723 100644 --- a/ginac/printtree.cpp +++ b/ginac/printtree.cpp @@ -38,6 +38,9 @@ #include "relational.h" #include "series.h" #include "symbol.h" +#include "debugmsg.h" + +namespace GiNaC { void ex::printtree(ostream & os, unsigned indent) const { @@ -178,3 +181,4 @@ void expairseq::printtree(ostream & os, unsigned indent) const #endif // def EXPAIRSEQ_USE_HASHTAB } +} // namespace GiNaC diff --git a/ginac/relational.cpp b/ginac/relational.cpp index 1cce02d9..f63a297f 100644 --- a/ginac/relational.cpp +++ b/ginac/relational.cpp @@ -24,6 +24,9 @@ #include "relational.h" #include "numeric.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -261,3 +264,4 @@ unsigned relational::precedence=20; const relational some_relational; type_info const & typeid_relational=typeid(some_relational); +} // namespace GiNaC diff --git a/ginac/relational.h b/ginac/relational.h index 317b1d23..7426e19e 100644 --- a/ginac/relational.h +++ b/ginac/relational.h @@ -26,6 +26,8 @@ #include #include +namespace GiNaC { + /** This class holds a relation consisting of two expressions and a logical * relation between them. */ class relational : public basic @@ -95,8 +97,12 @@ protected: extern const relational some_relational; extern type_info const & typeid_relational; -#define ex_to_relational(X) static_cast(*(X).bp) - -#endif // ndef __GINAC_RELATIONAL_H__ +// utility functions +inline const relational &ex_to_relational(const ex &e) +{ + return static_cast(*e.bp); +} +} // namespace GiNaC +#endif // ndef __GINAC_RELATIONAL_H__ diff --git a/ginac/series.cpp b/ginac/series.cpp index 6002d95b..5822825f 100644 --- a/ginac/series.cpp +++ b/ginac/series.cpp @@ -28,6 +28,9 @@ #include "power.h" #include "relational.h" #include "symbol.h" +#include "debugmsg.h" + +namespace GiNaC { /* @@ -632,3 +635,5 @@ ex ex::series(symbol const &s, ex const &point, int order) const // Global constants const series some_series; type_info const & typeid_series = typeid(some_series); + +} // namespace GiNaC diff --git a/ginac/series.h b/ginac/series.h index 4a757b0a..7b4e095f 100644 --- a/ginac/series.h +++ b/ginac/series.h @@ -26,6 +26,8 @@ #include #include +namespace GiNaC { + /** This class holds a extended truncated power series (positive and negative * integer powers). It consists of expression coefficients (only non-zero * coefficients are stored), an expansion variable and an expansion point. @@ -86,7 +88,17 @@ protected: extern const series some_series; extern type_info const & typeid_series; -#define ex_to_series(X) (static_cast(*(X).bp)) -#define series_to_poly(X) (static_cast(*(X).bp).convert_to_poly(true)) +// utility functions +inline const series &ex_to_series(const ex &e) +{ + return static_cast(*e.bp); +} + +inline ex series_to_poly(const ex &e) +{ + return (static_cast(*e.bp).convert_to_poly(true)); +} + +} // namespace GiNaC #endif // ndef __GINAC_SERIES_H__ diff --git a/ginac/simp_lor.cpp b/ginac/simp_lor.cpp index ea488dc6..d488e6dd 100644 --- a/ginac/simp_lor.cpp +++ b/ginac/simp_lor.cpp @@ -32,6 +32,9 @@ #include "ex.h" #include "mul.h" #include "symbol.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -510,5 +513,4 @@ spmapkey scalar_products::make_key(simp_lor const & v1, simp_lor const & v2) return spmapkey(strstrpair(v1.name,v2.name),anon); } - - +} // namespace GiNaC diff --git a/ginac/simp_lor.h b/ginac/simp_lor.h index a3971bf4..643a6d91 100644 --- a/ginac/simp_lor.h +++ b/ginac/simp_lor.h @@ -31,6 +31,8 @@ #include #include +namespace GiNaC { + typedef pair strstrpair; typedef pair spmapkey; @@ -151,10 +153,16 @@ protected: extern const simp_lor some_simp_lor; extern type_info const & typeid_simp_lor; -// macros +// utility functions +inline const simp_lor &ex_to_simp_lor(const ex &e) +{ + return static_cast(*e.bp); +} -#define ex_to_simp_lor(X) static_cast(*(X).bp) -#define ex_to_nonconst_simp_lor(X) static_cast(*(X).bp) +inline simp_lor &ex_to_nonconst_simp_lor(const ex &e) +{ + return static_cast(*e.bp); +} simp_lor lor_g(ex const & mu, ex const & nu); simp_lor lor_vec(string const & n, ex const & mu); @@ -162,6 +170,6 @@ ex simplify_simp_lor_mul(ex const & m, scalar_products const & sp); ex simplify_simp_lor(ex const & e, scalar_products const & sp); ex Dim(void); -#endif // ndef _SIMP__GINAC_LOR_H__ - +} // namespace GiNaC +#endif // ndef _SIMP__GINAC_LOR_H__ diff --git a/ginac/structure.cpp b/ginac/structure.cpp index dd939c90..55ec5828 100644 --- a/ginac/structure.cpp +++ b/ginac/structure.cpp @@ -23,6 +23,9 @@ #include #include "structure.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -172,3 +175,4 @@ unsigned structure::register_new(char const * nm) const structure some_structure; type_info const & typeid_structure=typeid(some_structure); +} // namespace GiNaC diff --git a/ginac/structure.h b/ginac/structure.h index c14a17c8..34788875 100644 --- a/ginac/structure.h +++ b/ginac/structure.h @@ -25,6 +25,8 @@ #include +namespace GiNaC { + struct registered_structure_info { char const * name; }; @@ -82,5 +84,6 @@ public: extern const structure some_structure; extern type_info const & typeid_structure; -#endif // ndef __GINAC_STRUCTURE_H__ +} // namespace GiNaC +#endif // ndef __GINAC_STRUCTURE_H__ diff --git a/ginac/structure.pl b/ginac/structure.pl index de365ede..b6137d0b 100755 --- a/ginac/structure.pl +++ b/ginac/structure.pl @@ -119,7 +119,9 @@ $types_ok_statements=generate( $interface=< +#include + +namespace GiNaC { class ${STRUCTURE} : public structure { @@ -211,6 +215,8 @@ extern const unsigned tinfo_${STRUCTURE}; #define ex_to_${STRUCTURE}(X) (static_cast<${STRUCTURE} const &>(*(X).bp)) +} // namespace GiNaC + #endif // ndef _${STRUCTURE_UC}_H_ END_OF_INTERFACE @@ -218,7 +224,9 @@ END_OF_INTERFACE $implementation=< -#include "ginac.h" +#include "${STRUCTURE}.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -498,6 +508,8 @@ const ${STRUCTURE} some_${STRUCTURE}; type_info const & typeid_${STRUCTURE}=typeid(some_${STRUCTURE}); const unsigned tinfo_${STRUCTURE}=structure::register_new("${STRUCTURE}"); +} // namespace GiNaC + END_OF_IMPLEMENTATION print "Creating interface file ${STRUCTURE}.h..."; diff --git a/ginac/symbol.cpp b/ginac/symbol.cpp index f84d98cb..2d42b5af 100644 --- a/ginac/symbol.cpp +++ b/ginac/symbol.cpp @@ -27,6 +27,9 @@ #include "lst.h" #include "utils.h" #include "idx.h" +#include "debugmsg.h" + +namespace GiNaC { ////////// // default constructor, destructor, copy constructor assignment operator and helpers @@ -277,3 +280,5 @@ type_info const & typeid_symbol=typeid(some_symbol); symbol::assigned_ex_info::assigned_ex_info(void) : is_assigned(0), refcount(1) { } + +} // namespace GiNaC diff --git a/ginac/symbol.h b/ginac/symbol.h index ade8d776..9905f3c8 100644 --- a/ginac/symbol.h +++ b/ginac/symbol.h @@ -27,6 +27,8 @@ #include #include +namespace GiNaC { + /** Basic CAS symbol. It has a name because it must know how to output itself. * It may be assigned an expression, but this feature is only intended for * programs like 'ginsh' that want to associate symbols with expressions. @@ -109,9 +111,11 @@ private: extern const symbol some_symbol; extern type_info const & typeid_symbol; -// macros - -#define ex_to_symbol(X) static_cast(*(X).bp) +// utility functions +inline const symbol &ex_to_symbol(const ex &e) +{ + return static_cast(*e.bp); +} // wrapper functions around member functions inline void unassign(symbol & symarg) @@ -123,4 +127,6 @@ inline int degree(symbol const & a, symbol const & s) inline int ldegree(symbol const & a, symbol const & s) { return a.ldegree(s); } +} // namespace GiNaC + #endif // ndef __GINAC_SYMBOL_H__ diff --git a/ginac/tinfos.h b/ginac/tinfos.h index 5a70aeed..2c807b12 100644 --- a/ginac/tinfos.h +++ b/ginac/tinfos.h @@ -23,46 +23,50 @@ #ifndef __GINAC_TINFOS_H__ #define __GINAC_TINFOS_H__ -#define TINFO_basic 0x00000001U +namespace GiNaC { -#define TINFO_expairseq 0x00010001U -#define TINFO_add 0x00011001U -#define TINFO_mul 0x00011002U +const unsigned TINFO_basic = 0x00000001U; -#define TINFO_symbol 0x00020001U -#define TINFO_constant 0x00021001U +const unsigned TINFO_expairseq = 0x00010001U; +const unsigned TINFO_add = 0x00011001U; +const unsigned TINFO_mul = 0x00011002U; -#define TINFO_exprseq 0x00030001U -#define TINFO_function 0x00031001U -#define TINFO_ncmul 0x00031002U +const unsigned TINFO_symbol = 0x00020001U; +const unsigned TINFO_constant = 0x00021001U; -#define TINFO_lst 0x00040001U +const unsigned TINFO_exprseq = 0x00030001U; +const unsigned TINFO_function = 0x00031001U; +const unsigned TINFO_ncmul = 0x00031002U; -#define TINFO_matrix 0x00050001U +const unsigned TINFO_lst = 0x00040001U; -#define TINFO_power 0x00060001U +const unsigned TINFO_matrix = 0x00050001U; -#define TINFO_relational 0x00070001U +const unsigned TINFO_power = 0x00060001U; -#define TINFO_fail 0x00080001U +const unsigned TINFO_relational = 0x00070001U; -#define TINFO_numeric 0x00090001U +const unsigned TINFO_fail = 0x00080001U; -#define TINFO_series 0x000a0001U +const unsigned TINFO_numeric = 0x00090001U; -#define TINFO_indexed 0x000b0001U -#define TINFO_algebra 0x000b1001U -#define TINFO_clifford 0x000b1101U -#define TINFO_color 0x000b1201U -#define TINFO_isospin 0x000b1301U -#define TINFO_simp_lor 0x000b1401U +const unsigned TINFO_series = 0x000a0001U; -#define TINFO_structure 0x000c0001U -// reserved up to 0x000cffffU +const unsigned TINFO_indexed = 0x000b0001U; +const unsigned TINFO_algebra = 0x000b1001U; +const unsigned TINFO_clifford = 0x000b1101U; +const unsigned TINFO_color = 0x000b1201U; +const unsigned TINFO_isospin = 0x000b1301U; +const unsigned TINFO_simp_lor = 0x000b1401U; + +const unsigned TINFO_structure = 0x000c0001U; +// reserved up to 0x000cffffU // for user defined structures -#define TINFO_idx 0x000d0001U -#define TINFO_coloridx 0x000d1001U -#define TINFO_lorentzidx 0x000d1002U +const unsigned TINFO_idx = 0x000d0001U; +const unsigned TINFO_coloridx = 0x000d1001U; +const unsigned TINFO_lorentzidx = 0x000d1002U; + +} // namespace GiNaC #endif // ndef __GINAC_TINFOS_H__ diff --git a/ginac/utils.cpp b/ginac/utils.cpp index 0689d3e7..446377b2 100644 --- a/ginac/utils.cpp +++ b/ginac/utils.cpp @@ -22,6 +22,8 @@ #include "utils.h" +namespace GiNaC { + unsigned log2(unsigned n) { unsigned k; @@ -113,6 +115,4 @@ int compare_pointers(void const * a, void const * b) // private // none - - - +} // namespace GiNaC diff --git a/ginac/utils.h b/ginac/utils.h index b78d46a3..edde75fc 100644 --- a/ginac/utils.h +++ b/ginac/utils.h @@ -27,6 +27,8 @@ #include #include "config.h" +namespace GiNaC { + template string ToString(T const & t) { @@ -39,9 +41,6 @@ unsigned log2(unsigned n); int compare_pointers(void const * a, void const * b); -#define DYNCONSTCAST(FINALTYPE,BASICTYPE,EXPRESSION) \ - dynamic_cast(const_cast(EXPRESSION)) - // modified from stl_algo.h: always do com(*first1,*first2) instead of comp(*first2,*first1) template @@ -90,4 +89,6 @@ OutputIterator mymerge3(InputIterator1 first1, InputIterator1 last1, } } +} // namespace GiNaC + #endif // ndef __GINAC_UTILS_H__ -- 2.44.0