]> www.ginac.de Git - ginac.git/commitdiff
- renamed archive::dump() to archive::printraw() for consistency with the
authorChristian Bauer <Christian.Bauer@uni-mainz.de>
Mon, 24 Jan 2000 20:53:56 +0000 (20:53 +0000)
committerChristian Bauer <Christian.Bauer@uni-mainz.de>
Mon, 24 Jan 2000 20:53:56 +0000 (20:53 +0000)
  other classes
- implemented archiving for the following classes: color, idx, coloridx,
  isospin
- non-crational numbers are now stored in an integer-decoded format in archives

24 files changed:
Makefile.in
check/Makefile.in
config.h.in
configure
configure.in
doc/Makefile.in
doc/reference/Makefile.in
doc/tutorial/Makefile.in
ginac/Makefile.in
ginac/archive.cpp
ginac/archive.h
ginac/color.cpp
ginac/color.h
ginac/coloridx.cpp
ginac/coloridx.h
ginac/idx.cpp
ginac/idx.h
ginac/indexed.cpp
ginac/isospin.cpp
ginac/isospin.h
ginac/numeric.cpp
ginsh/Makefile.in
tools/Makefile.in
tools/viewgar.cpp

index 4f1c9d611f760c8ba4632fb2e2cf9c0e0d507812..0bef60060eb1243bb1d7af2082e510ead7eec9f1 100644 (file)
@@ -354,7 +354,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index 1d2a006919da608970fa028c83da71d0c7af906b..bcb32424ba673a7a6ef5f2bcc10e49dc18ebc99b 100644 (file)
@@ -248,7 +248,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index c229c73a80acb00aaadb9f9e11e356abc7d4d201..f4d7fb17e2aea485294d01eea54bdc018a4b308e 100644 (file)
@@ -42,6 +42,9 @@
 /* Define if you have the <readline/readline.h> header file.  */
 #undef HAVE_READLINE_READLINE_H
 
 /* Define if you have the <readline/readline.h> header file.  */
 #undef HAVE_READLINE_READLINE_H
 
+/* Define if you have the <sstream> header file.  */
+#undef HAVE_SSTREAM
+
 /* Define if you have the <stdexcept> header file.  */
 #undef HAVE_STDEXCEPT
 
 /* Define if you have the <stdexcept> header file.  */
 #undef HAVE_STDEXCEPT
 
index d7eb43904f8fb7fbdc38278a1fc0cadaa85468a3..f0c1bb8017d33cd2eb2f44c40fd83695ae9f7f9c 100755 (executable)
--- a/configure
+++ b/configure
@@ -2411,7 +2411,7 @@ else
 fi
 
 
 fi
 
 
-for ac_hdr in iostream vector map string list typeinfo iterator strstream stdexcept algorithm
+for ac_hdr in iostream vector map string list typeinfo iterator stdexcept algorithm
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
@@ -2452,23 +2452,63 @@ else
 fi
 done
 
 fi
 done
 
+for ac_hdr in sstream strstream
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:2460: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2465 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2470: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  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 <<EOF
+#define $ac_tr_hdr 1
+EOF
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
 
 
     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
 
 
     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:2462: checking for $ac_hdr" >&5
+echo "configure:2502: 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
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2467 "configure"
+#line 2507 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2472: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2512: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2495,17 +2535,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
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:2499: checking for $ac_hdr" >&5
+echo "configure:2539: 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
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 2504 "configure"
+#line 2544 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:2509: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:2549: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -2540,7 +2580,7 @@ done
 
 
     echo $ac_n "checking for doublefactorial in -lcln""... $ac_c" 1>&6
 
 
     echo $ac_n "checking for doublefactorial in -lcln""... $ac_c" 1>&6
-echo "configure:2544: checking for doublefactorial in -lcln" >&5
+echo "configure:2584: checking for doublefactorial in -lcln" >&5
     saved_LIBS="${LIBS}"
     if eval "test \"`echo '$''{'ginac_cv_lib_cln_link'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
     saved_LIBS="${LIBS}"
     if eval "test \"`echo '$''{'ginac_cv_lib_cln_link'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -2549,14 +2589,14 @@ else
         case "${ac_cv_header_CLN_cln_h}" in
         "yes")
             cat > conftest.$ac_ext <<EOF
         case "${ac_cv_header_CLN_cln_h}" in
         "yes")
             cat > conftest.$ac_ext <<EOF
-#line 2553 "configure"
+#line 2593 "configure"
 #include "confdefs.h"
 #include <cln/cln.h>
 int main() {
 doublefactorial(2);
 ; return 0; }
 EOF
 #include "confdefs.h"
 #include <cln/cln.h>
 int main() {
 doublefactorial(2);
 ; return 0; }
 EOF
-if { (eval echo configure:2560: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2600: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ginac_cv_lib_cln_link="-lcln"
 else
   rm -rf conftest*
   ginac_cv_lib_cln_link="-lcln"
 else
@@ -2569,14 +2609,14 @@ rm -f conftest*
             ;;
         *)
             cat > conftest.$ac_ext <<EOF
             ;;
         *)
             cat > conftest.$ac_ext <<EOF
-#line 2573 "configure"
+#line 2613 "configure"
 #include "confdefs.h"
 #include <cln.h>
 int main() {
 doublefactorial(2);
 ; return 0; }
 EOF
 #include "confdefs.h"
 #include <cln.h>
 int main() {
 doublefactorial(2);
 ; return 0; }
 EOF
-if { (eval echo configure:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:2620: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   ginac_cv_lib_cln_link="-lcln"
 else
   rm -rf conftest*
   ginac_cv_lib_cln_link="-lcln"
 else
@@ -2616,7 +2656,7 @@ GINACLIB_LIBS=$LIBS
 # Extract the first word of "doxygen", so it can be a program name with args.
 set dummy doxygen; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
 # Extract the first word of "doxygen", so it can be a program name with args.
 set dummy doxygen; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2620: checking for $ac_word" >&5
+echo "configure:2660: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_DOXYGEN'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
 if eval "test \"`echo '$''{'ac_cv_path_DOXYGEN'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2652,7 +2692,7 @@ fi
 # Extract the first word of "latex", so it can be a program name with args.
 set dummy latex; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
 # Extract the first word of "latex", so it can be a program name with args.
 set dummy latex; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2656: checking for $ac_word" >&5
+echo "configure:2696: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_LATEX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
 if eval "test \"`echo '$''{'ac_cv_path_LATEX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2688,7 +2728,7 @@ fi
 # Extract the first word of "makeindex", so it can be a program name with args.
 set dummy makeindex; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
 # Extract the first word of "makeindex", so it can be a program name with args.
 set dummy makeindex; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2692: checking for $ac_word" >&5
+echo "configure:2732: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_MAKEINDEX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
 if eval "test \"`echo '$''{'ac_cv_path_MAKEINDEX'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2724,7 +2764,7 @@ fi
 # Extract the first word of "dvips", so it can be a program name with args.
 set dummy dvips; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
 # Extract the first word of "dvips", so it can be a program name with args.
 set dummy dvips; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2728: checking for $ac_word" >&5
+echo "configure:2768: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_DVIPS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
 if eval "test \"`echo '$''{'ac_cv_path_DVIPS'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -2760,7 +2800,7 @@ fi
 # Extract the first word of "fig2dev", so it can be a program name with args.
 set dummy fig2dev; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
 # Extract the first word of "fig2dev", so it can be a program name with args.
 set dummy fig2dev; ac_word=$2
 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
-echo "configure:2764: checking for $ac_word" >&5
+echo "configure:2804: checking for $ac_word" >&5
 if eval "test \"`echo '$''{'ac_cv_path_FIG2DEV'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
 if eval "test \"`echo '$''{'ac_cv_path_FIG2DEV'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
index af2b0a8e434d6d21d9565413b02632614172e72e..a42eba2c135f87f99126228e43bc41d7b0b3552f 100644 (file)
@@ -104,8 +104,9 @@ AC_CHECK_LIB(stdc++, cout)
 dnl Make sure all the necessary new-style headers are installed on the system.
 dnl If one of them cannot be found the system is probably not ANSI-conform
 dnl enough so trying the .h-style headers is a waste of time.
 dnl Make sure all the necessary new-style headers are installed on the system.
 dnl If one of them cannot be found the system is probably not ANSI-conform
 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_CHECK_HEADERS(iostream vector map string list typeinfo iterator stdexcept algorithm, ,
     AC_MSG_ERROR(need to have ANSI compliant headers))
     AC_MSG_ERROR(need to have ANSI compliant headers))
+AC_CHECK_HEADERS(sstream strstream)
 
 dnl We need to have Bruno Haible's CLN installed (macros are in acinclude.m4):
 GINAC_CHECK_CLN_H
 
 dnl We need to have Bruno Haible's CLN installed (macros are in acinclude.m4):
 GINAC_CHECK_CLN_H
index 480df48e487d6daa9f1c37067adab7f77f3f87b1..b6902514b620ee3e08c0d32ec8c2fb481c4a126e 100644 (file)
@@ -269,7 +269,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index 2edc3256c1367ee8320032dfdf94b52743253627..94f8b73231c929dcbd23aae535fa014a56b6e0f0 100644 (file)
@@ -165,7 +165,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index ca92d6b9a500c2c056a2b7c2a658512e9f6c1858..820db8e54f670d531d9374d45ece518cd041d55b 100644 (file)
@@ -317,7 +317,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index 0fbd01bec125118b16845e37c53a77d21d44a7bf..12b11d080d69adf2a28d93d9c8f3cd0138f61a62 100644 (file)
@@ -290,7 +290,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index dfc00cee9f6cc7d923ff3ad343cb3089dd51a350..0fdb30ad4ae97296a96513d8b04ce4e814324f20 100644 (file)
@@ -511,8 +511,8 @@ void archive_node::forget(void)
 }
 
 
 }
 
 
-/** Dump archive to stream (for debugging). */
-void archive::dump(ostream &os) const
+/** Print archive to stream in ugly raw format (for debugging). */
+void archive::printraw(ostream &os) const
 {
        // Dump atoms
        os << "Atoms:\n";
 {
        // Dump atoms
        os << "Atoms:\n";
@@ -545,14 +545,14 @@ void archive::dump(ostream &os) const
                archive_node_id id = 0;
                while (i != iend) {
                        os << " " << id << " ";
                archive_node_id id = 0;
                while (i != iend) {
                        os << " " << id << " ";
-                       i->dump(os);
+                       i->printraw(os);
                        i++; id++;
                }
        }
 }
 
                        i++; id++;
                }
        }
 }
 
-/** Dump archive_node to stream (for debugging). */
-void archive_node::dump(ostream &os) const
+/** Output archive_node to stream in ugly raw format (for debugging). */
+void archive_node::printraw(ostream &os) const
 {
        // Dump cached unarchived expression
        if (has_expression)
 {
        // Dump cached unarchived expression
        if (has_expression)
index a2db1666417070fad8a738cc6e3b988ef5b3ca0b..7b464a22ec2394225eed6378a9e128ed2d9eff3c 100644 (file)
@@ -77,7 +77,7 @@ public:
        ex unarchive(const lst &sym_lst) const;
 
        void forget(void);
        ex unarchive(const lst &sym_lst) const;
 
        void forget(void);
-       void dump(ostream &os) const;
+       void printraw(ostream &os) const;
 
 private:
        /** Property data types */
 
 private:
        /** Property data types */
@@ -150,7 +150,7 @@ public:
        void clear(void);
 
        void forget(void);
        void clear(void);
 
        void forget(void);
-       void dump(ostream &os) const;
+       void printraw(ostream &os) const;
 
 private:
        /** Vector of archived nodes. */
 
 private:
        /** Vector of archived nodes. */
index f9220582676a1e7ddae10b6e1b1fe6d1208cc0d8..8a793844ed289d7871aa1e1db453aa4a80f81762 100644 (file)
@@ -33,6 +33,7 @@
 #include "ncmul.h"
 #include "numeric.h"
 #include "relational.h"
 #include "ncmul.h"
 #include "numeric.h"
 #include "relational.h"
+#include "archive.h"
 #include "debugmsg.h"
 #include "utils.h"
 
 #include "debugmsg.h"
 #include "utils.h"
 
@@ -40,6 +41,8 @@
 namespace GiNaC {
 #endif // ndef NO_GINAC_NAMESPACE
 
 namespace GiNaC {
 #endif // ndef NO_GINAC_NAMESPACE
 
+GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed)
+
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
@@ -78,7 +81,7 @@ const color & color::operator=(const color & other)
 
 void color::copy(const color & other)
 {
 
 void color::copy(const color & other)
 {
-    indexed::copy(other);
+    inherited::copy(other);
     type=other.type;
     representation_label=other.representation_label;
 }
     type=other.type;
     representation_label=other.representation_label;
 }
@@ -86,7 +89,7 @@ void color::copy(const color & other)
 void color::destroy(bool call_parent)
 {
     if (call_parent) {
 void color::destroy(bool call_parent)
 {
     if (call_parent) {
-        indexed::destroy(call_parent);
+        inherited::destroy(call_parent);
     }
 }
 
     }
 }
 
@@ -105,7 +108,7 @@ color::color(color_types const t, unsigned rl) : type(t), representation_label(r
 }
 
 color::color(color_types const t, const ex & i1, unsigned rl)
 }
 
 color::color(color_types const t, const ex & i1, unsigned rl)
-    : indexed(i1), type(t), representation_label(rl)
+    : inherited(i1), type(t), representation_label(rl)
 {
     debugmsg("color constructor from color_types,ex,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
 {
     debugmsg("color constructor from color_types,ex,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
@@ -114,7 +117,7 @@ color::color(color_types const t, const ex & i1, unsigned rl)
 }
 
 color::color(color_types const t, const ex & i1, const ex & i2, unsigned rl)
 }
 
 color::color(color_types const t, const ex & i1, const ex & i2, unsigned rl)
-    : indexed(i1,i2), type(t), representation_label(rl)
+    : inherited(i1,i2), type(t), representation_label(rl)
 {
     debugmsg("color constructor from color_types,ex,ex,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
 {
     debugmsg("color constructor from color_types,ex,ex,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
@@ -123,7 +126,7 @@ color::color(color_types const t, const ex & i1, const ex & i2, unsigned rl)
 }
 
 color::color(color_types const t, const ex & i1, const ex & i2, const ex & i3,
 }
 
 color::color(color_types const t, const ex & i1, const ex & i2, const ex & i3,
-             unsigned rl) : indexed(i1,i2,i3), type(t), representation_label(rl)
+             unsigned rl) : inherited(i1,i2,i3), type(t), representation_label(rl)
 {
     debugmsg("color constructor from color_types,ex,ex,ex,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
 {
     debugmsg("color constructor from color_types,ex,ex,ex,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
@@ -132,7 +135,7 @@ color::color(color_types const t, const ex & i1, const ex & i2, const ex & i3,
 }
 
 color::color(color_types const t, const exvector & iv, unsigned rl)
 }
 
 color::color(color_types const t, const exvector & iv, unsigned rl)
-    : indexed(iv), type(t), representation_label(rl)
+    : inherited(iv), type(t), representation_label(rl)
 {
     debugmsg("color constructor from color_types,exvector,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
 {
     debugmsg("color constructor from color_types,exvector,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
@@ -141,7 +144,7 @@ color::color(color_types const t, const exvector & iv, unsigned rl)
 }
 
 color::color(color_types const t, exvector * ivp, unsigned rl)
 }
 
 color::color(color_types const t, exvector * ivp, unsigned rl)
-    : indexed(ivp), type(t), representation_label(rl)
+    : inherited(ivp), type(t), representation_label(rl)
 {
     debugmsg("color constructor from color_types,exvector *,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
 {
     debugmsg("color constructor from color_types,exvector *,unsigned",LOGLEVEL_CONSTRUCT);
     GINAC_ASSERT(representation_label<MAX_REPRESENTATION_LABELS);
@@ -149,6 +152,36 @@ color::color(color_types const t, exvector * ivp, unsigned rl)
     GINAC_ASSERT(all_of_type_coloridx());
 }
 
     GINAC_ASSERT(all_of_type_coloridx());
 }
 
+//////////
+// archiving
+//////////
+
+/** Construct object from archive_node. */
+color::color(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+{
+    debugmsg("color constructor from archive_node", LOGLEVEL_CONSTRUCT);
+    unsigned int ty;
+    if (!(n.find_unsigned("type", ty)))
+        throw (std::runtime_error("unknown color type in archive"));
+    type = (color_types)ty;
+    if (!(n.find_unsigned("representation", representation_label)))
+        throw (std::runtime_error("unknown color representation label in archive"));
+}
+
+/** Unarchive the object. */
+ex color::unarchive(const archive_node &n, const lst &sym_lst)
+{
+    return (new color(n, sym_lst))->setflag(status_flags::dynallocated);
+}
+
+/** Archive the object. */
+void color::archive(archive_node &n) const
+{
+    inherited::archive(n);
+    n.add_unsigned("type", type);
+    n.add_unsigned("representation", representation_label);
+}
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
@@ -222,7 +255,7 @@ void color::printcsrc(ostream & os, unsigned type, unsigned upper_precedence) co
 
 bool color::info(unsigned inf) const
 {
 
 bool color::info(unsigned inf) const
 {
-    return indexed::info(inf);
+    return inherited::info(inf);
 }
 
 #define CMPINDICES(A,B,C) ((idx1.get_value()==(A))&&(idx2.get_value()==(B))&&(idx3.get_value()==(C)))
 }
 
 #define CMPINDICES(A,B,C) ((idx1.get_value()==(A))&&(idx2.get_value()==(B))&&(idx3.get_value()==(C)))
@@ -354,7 +387,7 @@ int color::compare_same_type(const basic & other) const
     const color *o = static_cast<const color *>(&other);
     if (type==o->type) {
         if (representation_label==o->representation_label) {
     const color *o = static_cast<const color *>(&other);
     if (type==o->type) {
         if (representation_label==o->representation_label) {
-            return indexed::compare_same_type(other);
+            return inherited::compare_same_type(other);
         }
         return representation_label < o->representation_label ? -1 : 1;
     }
         }
         return representation_label < o->representation_label ? -1 : 1;
     }
@@ -367,7 +400,7 @@ bool color::is_equal_same_type(const basic & other) const
     const color *o = static_cast<const color *>(&other);
     if (type!=o->type) return false;
     if (representation_label!=o->representation_label) return false;
     const color *o = static_cast<const color *>(&other);
     if (type!=o->type) return false;
     if (representation_label!=o->representation_label) return false;
-    return indexed::is_equal_same_type(other);
+    return inherited::is_equal_same_type(other);
 }
 
 #include <iostream>
 }
 
 #include <iostream>
index 6a464edc62911298aeebcec886767ae67ae6d9b9..c6c4ca04a5e1dd64d5789f91d247f1b0380e3567 100644 (file)
@@ -41,6 +41,8 @@ typedef vector<exvector,malloc_alloc> exvectorvector;
 /** Base class for color object */
 class color : public indexed
 {
 /** Base class for color object */
 class color : public indexed
 {
+    GINAC_DECLARE_REGISTERED_CLASS(color, indexed)
+
 // friends
 
     friend color color_ONE(unsigned rl);
 // friends
 
     friend color color_ONE(unsigned rl);
index 60e4596815de4a7544645c8a811816510975514a..e7c35c551afc8508a318b64f6ce6b0f25bdab567 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdexcept>
 
 #include "coloridx.h"
 #include <stdexcept>
 
 #include "coloridx.h"
+#include "archive.h"
 #include "utils.h"
 #include "debugmsg.h"
 
 #include "utils.h"
 #include "debugmsg.h"
 
@@ -30,6 +31,8 @@
 namespace GiNaC {
 #endif // ndef NO_GINAC_NAMESPACE
 
 namespace GiNaC {
 #endif // ndef NO_GINAC_NAMESPACE
 
+GINAC_IMPLEMENT_REGISTERED_CLASS(coloridx, idx)
+
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
@@ -70,12 +73,12 @@ const coloridx & coloridx::operator=(const coloridx & other)
 
 void coloridx::copy(const coloridx & other)
 {
 
 void coloridx::copy(const coloridx & other)
 {
-    idx::copy(other);
+    inherited::copy(other);
 }
 
 void coloridx::destroy(bool call_parent)
 {
 }
 
 void coloridx::destroy(bool call_parent)
 {
-    if (call_parent) idx::destroy(call_parent);
+    if (call_parent) inherited::destroy(call_parent);
 }
 
 //////////
 }
 
 //////////
@@ -110,6 +113,28 @@ coloridx::coloridx(unsigned v, bool cov) : idx(v,cov)
     tinfo_key=TINFO_coloridx;
 }
 
     tinfo_key=TINFO_coloridx;
 }
 
+//////////
+// archiving
+//////////
+
+/** Construct object from archive_node. */
+coloridx::coloridx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+{
+    debugmsg("coloridx constructor from archive_node", LOGLEVEL_CONSTRUCT);
+}
+
+/** Unarchive the object. */
+ex coloridx::unarchive(const archive_node &n, const lst &sym_lst)
+{
+    return (new coloridx(n, sym_lst))->setflag(status_flags::dynallocated);
+}
+
+/** Archive the object. */
+void coloridx::archive(archive_node &n) const
+{
+    inherited::archive(n);
+}
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
index 52ed82a0d6ad7809f97efdc643fe8111bc989903..266dcf9276be0c25852b91b71462b0d7ed1d526b 100644 (file)
@@ -34,6 +34,8 @@ namespace GiNaC {
 
 class coloridx : public idx
 {
 
 class coloridx : public idx
 {
+    GINAC_DECLARE_REGISTERED_CLASS(coloridx, idx)
+
     friend class color;
 
 // member functions
     friend class color;
 
 // member functions
index 67d23c5b1b9592af8da3b10bba9cccb0c10e0dc7..5b93905af144d3e65c0e2dbbfba2c37f5469fe5a 100644 (file)
@@ -26,6 +26,7 @@
 #include "ex.h"
 #include "lst.h"
 #include "relational.h"
 #include "ex.h"
 #include "lst.h"
 #include "relational.h"
+#include "archive.h"
 #include "utils.h"
 #include "debugmsg.h"
 
 #include "utils.h"
 #include "debugmsg.h"
 
 namespace GiNaC {
 #endif // ndef NO_GINAC_NAMESPACE
 
 namespace GiNaC {
 #endif // ndef NO_GINAC_NAMESPACE
 
+GINAC_IMPLEMENT_REGISTERED_CLASS(idx, basic)
+
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 
 // public
 
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 
 // public
 
-idx::idx() : basic(TINFO_idx), symbolic(true), covariant(false)
+idx::idx() : inherited(TINFO_idx), symbolic(true), covariant(false)
 {
     debugmsg("idx default constructor",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
 {
     debugmsg("idx default constructor",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
@@ -72,7 +75,7 @@ const idx & idx::operator=(const idx & other)
 
 void idx::copy(const idx & other)
 {
 
 void idx::copy(const idx & other)
 {
-    basic::copy(other);
+    inherited::copy(other);
     serial=other.serial;
     symbolic=other.symbolic;
     name=other.name;
     serial=other.serial;
     symbolic=other.symbolic;
     name=other.name;
@@ -82,7 +85,7 @@ void idx::copy(const idx & other)
 
 void idx::destroy(bool call_parent)
 {
 
 void idx::destroy(bool call_parent)
 {
-    if (call_parent) basic::destroy(call_parent);
+    if (call_parent) inherited::destroy(call_parent);
 }
 
 //////////
 }
 
 //////////
@@ -91,34 +94,80 @@ void idx::destroy(bool call_parent)
 
 // public
 
 
 // public
 
-idx::idx(bool cov) : basic(TINFO_idx), symbolic(true), covariant(cov)
+idx::idx(bool cov) : inherited(TINFO_idx), symbolic(true), covariant(cov)
 {
     debugmsg("idx constructor from bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
     name="index"+ToString(serial);
 }
 
 {
     debugmsg("idx constructor from bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
     name="index"+ToString(serial);
 }
 
-idx::idx(const string & n, bool cov) : basic(TINFO_idx),  
+idx::idx(const string & n, bool cov) : inherited(TINFO_idx),  
     symbolic(true), name(n), covariant(cov)
 {
     debugmsg("idx constructor from string,bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
 }
 
     symbolic(true), name(n), covariant(cov)
 {
     debugmsg("idx constructor from string,bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
 }
 
-idx::idx(const char * n, bool cov) : basic(TINFO_idx),  
+idx::idx(const char * n, bool cov) : inherited(TINFO_idx),  
     symbolic(true), name(n), covariant(cov)
 {
     debugmsg("idx constructor from char*,bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
 }
 
     symbolic(true), name(n), covariant(cov)
 {
     debugmsg("idx constructor from char*,bool",LOGLEVEL_CONSTRUCT);
     serial=next_serial++;
 }
 
-idx::idx(unsigned v, bool cov) : basic(TINFO_idx),
+idx::idx(unsigned v, bool cov) : inherited(TINFO_idx),
     symbolic(false), value(v), covariant(cov)
 {
     debugmsg("idx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
     serial=0;
 }
 
     symbolic(false), value(v), covariant(cov)
 {
     debugmsg("idx constructor from unsigned,bool",LOGLEVEL_CONSTRUCT);
     serial=0;
 }
 
+//////////
+// archiving
+//////////
+
+/** Construct object from archive_node. */
+idx::idx(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+{
+    debugmsg("idx constructor from archive_node", LOGLEVEL_CONSTRUCT);
+    n.find_bool("symbolic", symbolic);
+    n.find_bool("covariant", covariant);
+    if (symbolic) {
+        serial = next_serial++;
+        if (!(n.find_string("name", name)))
+            name = "index" + ToString(serial);
+    } else {
+        serial = 0;
+        n.find_unsigned("value", value);
+    }
+}
+
+/** Unarchive the object. */
+ex idx::unarchive(const archive_node &n, const lst &sym_lst)
+{
+    ex s = (new idx(n, sym_lst))->setflag(status_flags::dynallocated);
+
+    if (ex_to_idx(s).symbolic) {
+        // If idx is in sym_lst, return the existing idx
+        for (int i=0; i<sym_lst.nops(); i++) {
+            if (is_ex_of_type(sym_lst.op(i), idx) && (ex_to_idx(sym_lst.op(i)).name == ex_to_idx(s).name))
+                return sym_lst.op(i);
+        }
+    }
+    return s;
+}
+
+/** Archive the object. */
+void idx::archive(archive_node &n) const
+{
+    inherited::archive(n);
+    n.add_bool("symbolic", symbolic);
+    n.add_bool("covariant", covariant);
+    if (symbolic)
+        n.add_string("name", name);
+    else
+        n.add_unsigned("value", value);
+}
 
 //////////
 // functions overriding virtual functions from bases classes
 
 //////////
 // functions overriding virtual functions from bases classes
@@ -197,7 +246,7 @@ void idx::print(ostream & os, unsigned upper_precedence) const
 bool idx::info(unsigned inf) const
 {
     if (inf==info_flags::idx) return true;
 bool idx::info(unsigned inf) const
 {
     if (inf==info_flags::idx) return true;
-    return basic::info(inf);
+    return inherited::info(inf);
 }
 
 ex idx::subs(const lst & ls, const lst & lr) const
 }
 
 ex idx::subs(const lst & ls, const lst & lr) const
index 67c9344e6b9a580b09014e7e12b01e3f82406c81..c8a27a96e93fa657cd81555208535e7e8948bfa4 100644 (file)
@@ -34,6 +34,8 @@ namespace GiNaC {
 
 class idx : public basic
 {
 
 class idx : public basic
 {
+    GINAC_DECLARE_REGISTERED_CLASS(idx, basic)
+
 // member functions
 
     // default constructor, destructor, copy constructor assignment operator and helpers
 // member functions
 
     // default constructor, destructor, copy constructor assignment operator and helpers
index 7fe0a7e9752495a77efec25edca751b5d454f829..41c2b1f0681c729edb666e9a5922ede279fb6ce4 100644 (file)
@@ -139,6 +139,7 @@ indexed::indexed(exvector * ivp) : inherited(ivp)
 indexed::indexed(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
     debugmsg("indexed constructor from archive_node", LOGLEVEL_CONSTRUCT);
 indexed::indexed(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
 {
     debugmsg("indexed constructor from archive_node", LOGLEVEL_CONSTRUCT);
+    tinfo_key = TINFO_indexed;
 }
 
 /** Unarchive the object. */
 }
 
 /** Unarchive the object. */
index a5b5912ea2a91ef0d569b182014273ac7705abcc..6fad095daba2fca6669efe3d13eb00ce1c6d9119 100644 (file)
@@ -26,6 +26,8 @@
 #include "isospin.h"
 #include "ex.h"
 #include "ncmul.h"
 #include "isospin.h"
 #include "ex.h"
 #include "ncmul.h"
+#include "lst.h"
+#include "archive.h"
 #include "utils.h"
 #include "debugmsg.h"
 
 #include "utils.h"
 #include "debugmsg.h"
 
@@ -33,6 +35,8 @@
 namespace GiNaC {
 #endif // ndef NO_GINAC_NAMESPACE
 
 namespace GiNaC {
 #endif // ndef NO_GINAC_NAMESPACE
 
+GINAC_IMPLEMENT_REGISTERED_CLASS(isospin, indexed)
+
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
 //////////
 // default constructor, destructor, copy constructor assignment operator and helpers
 //////////
@@ -73,7 +77,7 @@ const isospin & isospin::operator=(const isospin & other)
 
 void isospin::copy(const isospin & other)
 {
 
 void isospin::copy(const isospin & other)
 {
-    indexed::copy(other);
+    inherited::copy(other);
     name=other.name;
     serial=other.serial;
 }
     name=other.name;
     serial=other.serial;
 }
@@ -81,7 +85,7 @@ void isospin::copy(const isospin & other)
 void isospin::destroy(bool call_parent)
 {
     if (call_parent) {
 void isospin::destroy(bool call_parent)
 {
     if (call_parent) {
-        indexed::destroy(call_parent);
+        inherited::destroy(call_parent);
     }
 }
 
     }
 }
 
@@ -99,6 +103,40 @@ isospin::isospin(const string & initname)
     tinfo_key=TINFO_isospin;
 }
 
     tinfo_key=TINFO_isospin;
 }
 
+//////////
+// archiving
+//////////
+
+/** Construct object from archive_node. */
+isospin::isospin(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+{
+    debugmsg("isospin constructor from archive_node", LOGLEVEL_CONSTRUCT);
+    serial = next_serial++;
+    if (!(n.find_string("name", name)))
+        name = autoname_prefix() + ToString(serial);
+    tinfo_key = TINFO_isospin;
+}
+
+/** Unarchive the object. */
+ex isospin::unarchive(const archive_node &n, const lst &sym_lst)
+{
+    ex s = (new isospin(n, sym_lst))->setflag(status_flags::dynallocated);
+
+    // If isospin is in sym_lst, return the existing isospin
+    for (int i=0; i<sym_lst.nops(); i++) {
+        if (is_ex_of_type(sym_lst.op(i), isospin) && (ex_to_isospin(sym_lst.op(i)).name == ex_to_isospin(s).name))
+            return sym_lst.op(i);
+    }
+    return s;
+}
+
+/** Archive the object. */
+void isospin::archive(archive_node &n) const
+{
+    inherited::archive(n);
+    n.add_string("name", name);
+}
+
 //////////
 // functions overriding virtual functions from bases classes
 //////////
 //////////
 // functions overriding virtual functions from bases classes
 //////////
@@ -146,7 +184,7 @@ void isospin::printcsrc(ostream & os, unsigned type, unsigned upper_precedence)
 
 bool isospin::info(unsigned inf) const
 {
 
 bool isospin::info(unsigned inf) const
 {
-    return indexed::info(inf);
+    return inherited::info(inf);
 }
 
 // protected
 }
 
 // protected
@@ -156,7 +194,7 @@ int isospin::compare_same_type(const basic & other) const
     GINAC_ASSERT(other.tinfo() == TINFO_isospin);
     const isospin *o = static_cast<const isospin *>(&other);
     if (serial==o->serial) {
     GINAC_ASSERT(other.tinfo() == TINFO_isospin);
     const isospin *o = static_cast<const isospin *>(&other);
     if (serial==o->serial) {
-        return indexed::compare_same_type(other);
+        return inherited::compare_same_type(other);
     }
     return serial < o->serial ? -1 : 1;
 }
     }
     return serial < o->serial ? -1 : 1;
 }
index 0318360f30a8e60aa8dfbb8fa504cb3d451b1bfd..8988fef11cbeca0eaa67d16984e67de37862c67e 100644 (file)
@@ -33,6 +33,8 @@ namespace GiNaC {
 /** Base class for isospin object */
 class isospin : public indexed
 {
 /** Base class for isospin object */
 class isospin : public indexed
 {
+    GINAC_DECLARE_REGISTERED_CLASS(isospin, indexed)
+
 // member functions
 
     // default constructor, destructor, copy constructor assignment operator and helpers
 // member functions
 
     // default constructor, destructor, copy constructor assignment operator and helpers
index 99dcc8e4486fda82b1f0101daa38c2b56ec048b9..77620c320a3f710f7160551b54cf271109bb20bd 100644 (file)
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "config.h"
+
 #include <vector>
 #include <stdexcept>
 #include <string>
 #include <vector>
 #include <stdexcept>
 #include <string>
-#include <strstream>   //!!
+
+#if defined(HAVE_SSTREAM)
+#include <sstream>
+#elif defined(HAVE_STRSTREAM)
+#include <strstream>
+#else
+#error Need either sstream or strstream
+#endif
 
 #include "numeric.h"
 #include "ex.h"
 
 #include "numeric.h"
 #include "ex.h"
-#include "config.h"
 #include "archive.h"
 #include "debugmsg.h"
 #include "utils.h"
 #include "archive.h"
 #include "debugmsg.h"
 #include "utils.h"
@@ -236,19 +244,56 @@ numeric::numeric(const archive_node &n, const lst &sym_lst) : inherited(n, sym_l
 {
     debugmsg("numeric constructor from archive_node", LOGLEVEL_CONSTRUCT);
     value = new cl_N;
 {
     debugmsg("numeric constructor from archive_node", LOGLEVEL_CONSTRUCT);
     value = new cl_N;
-#if 0  //!!
-    // This is how it should be implemented but we have no istringstream here...
+#ifdef HAVE_SSTREAM
+    // Read number as string
     string str;
     if (n.find_string("number", str)) {
         istringstream s(str);
     string str;
     if (n.find_string("number", str)) {
         istringstream s(str);
-        s >> *value;
+        cl_idecoded_float re, im;
+        char c;
+        s.get(c);
+        switch (c) {
+            case 'N':    // Ordinary number
+            case 'R':    // Integer-decoded real number
+                s >> re.sign >> re.mantissa >> re.exponent;
+                *value = re.sign * re.mantissa * expt(cl_float(2.0, cl_default_float_format), re.exponent);
+                break;
+            case 'C':    // Integer-decoded complex number
+                s >> re.sign >> re.mantissa >> re.exponent;
+                s >> im.sign >> im.mantissa >> im.exponent;
+                *value = complex(re.sign * re.mantissa * expt(cl_float(2.0, cl_default_float_format), re.exponent),
+                                 im.sign * im.mantissa * expt(cl_float(2.0, cl_default_float_format), im.exponent));
+                break;
+            default:   // Ordinary number
+                               s.putback(c);
+                s >> *value;
+                break;
+        }
     }
 #else
     }
 #else
-    // Workaround for the above: read from strstream
+    // Read number as string
     string str;
     if (n.find_string("number", str)) {
         istrstream f(str.c_str(), str.size() + 1);
     string str;
     if (n.find_string("number", str)) {
         istrstream f(str.c_str(), str.size() + 1);
-        f >> *value;
+        cl_idecoded_float re, im;
+        char c;
+        f.get(c);
+        switch (c) {
+            case 'R':    // Integer-decoded real number
+                f >> re.sign >> re.mantissa >> re.exponent;
+                *value = re.sign * re.mantissa * expt(cl_float(2.0, cl_default_float_format), re.exponent);
+                break;
+            case 'C':    // Integer-decoded complex number
+                f >> re.sign >> re.mantissa >> re.exponent;
+                f >> im.sign >> im.mantissa >> im.exponent;
+                *value = complex(re.sign * re.mantissa * expt(cl_float(2.0, cl_default_float_format), re.exponent),
+                                 im.sign * im.mantissa * expt(cl_float(2.0, cl_default_float_format), im.exponent));
+                break;
+            default:   // Ordinary number
+                               f.putback(c);
+                f >> *value;
+                               break;
+        }
     }
 #endif
     calchash();
     }
 #endif
     calchash();
@@ -266,16 +311,48 @@ ex numeric::unarchive(const archive_node &n, const lst &sym_lst)
 void numeric::archive(archive_node &n) const
 {
     inherited::archive(n);
 void numeric::archive(archive_node &n) const
 {
     inherited::archive(n);
-#if 0  //!!
-    // This is how it should be implemented but we have no ostringstream here...
+#ifdef HAVE_SSTREAM
+    // Write number as string
     ostringstream s;
     ostringstream s;
-    s << *value;
+    if (is_crational())
+        s << *value;
+    else {
+        // Non-rational numbers are written in an integer-decoded format
+        // to preserve the precision
+        if (is_real()) {
+            cl_idecoded_float re = integer_decode_float(The(cl_F)(*value));
+            s << "R";
+            s << re.sign << " " << re.mantissa << " " << re.exponent;
+        } else {
+            cl_idecoded_float re = integer_decode_float(The(cl_F)(realpart(*value)));
+            cl_idecoded_float im = integer_decode_float(The(cl_F)(imagpart(*value)));
+            s << "C";
+            s << re.sign << " " << re.mantissa << " " << re.exponent << " ";
+            s << im.sign << " " << im.mantissa << " " << im.exponent;
+        }
+    }
     n.add_string("number", s.str());
 #else
     n.add_string("number", s.str());
 #else
-    // Workaround for the above: write to strstream
+    // Write number as string
     char buf[1024];
     ostrstream f(buf, 1024);
     char buf[1024];
     ostrstream f(buf, 1024);
-    f << *value << ends;
+    if (is_crational())
+        f << *value << ends;
+    else {
+        // Non-rational numbers are written in an integer-decoded format
+        // to preserve the precision
+        if (is_real()) {
+            cl_idecoded_float re = integer_decode_float(The(cl_F)(*value));
+            f << "R";
+            f << re.sign << " " << re.mantissa << " " << re.exponent << ends;
+        } else {
+            cl_idecoded_float re = integer_decode_float(The(cl_F)(realpart(*value)));
+            cl_idecoded_float im = integer_decode_float(The(cl_F)(imagpart(*value)));
+            f << "C";
+            f << re.sign << " " << re.mantissa << " " << re.exponent << " ";
+            f << im.sign << " " << im.mantissa << " " << im.exponent << ends;
+        }
+    }
     string str(buf);
     n.add_string("number", str);
 #endif
     string str(buf);
     n.add_string("number", str);
 #endif
index 52e10808c528dad956d370163306204123e6aaac..977284b47d43bc0901920b4beb795be954c6114a 100644 (file)
@@ -311,7 +311,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index eb3d17221dc4987189f08ed5cf49257b9c523e64..901c1860871b903d8aab620efa7a4b291ab2bfeb 100644 (file)
@@ -293,7 +293,7 @@ distdir: $(DISTFILES)
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
        @for file in $(DISTFILES); do \
          d=$(srcdir); \
          if test -d $$d/$$file; then \
-           cp -pr $$d/$$file $(distdir)/$$file; \
+           cp -pr $$/$$file $(distdir)/$$file; \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          else \
            test -f $(distdir)/$$file \
            || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
index 1f333f0e136be341c09e28a2c8a5fafc093c90a1..79f992913470a53311af93dca350742f45174a7f 100644 (file)
@@ -47,7 +47,7 @@ int main(int argc, char **argv)
                        archive ar;
                        f >> ar;
                        if (dump_mode) {
                        archive ar;
                        f >> ar;
                        if (dump_mode) {
-                               ar.dump(cout);
+                               ar.printraw(cout);
                                cout << endl;
                        } else {
                                for (unsigned int i=0; i<ar.num_expressions(); i++) {
                                cout << endl;
                        } else {
                                for (unsigned int i=0; i<ar.num_expressions(); i++) {