@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 \
@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 \
/* 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
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
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
-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
-#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"
-{ (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*
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
-#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"
-{ (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*
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
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
-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
;;
*)
cat > conftest.$ac_ext <<EOF
-#line 2573 "configure"
+#line 2613 "configure"
#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
# 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
# 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
# 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
# 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
# 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
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_CHECK_HEADERS(sstream strstream)
dnl We need to have Bruno Haible's CLN installed (macros are in acinclude.m4):
GINAC_CHECK_CLN_H
@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 \
@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 \
@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 \
@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 \
}
-/** 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";
archive_node_id id = 0;
while (i != iend) {
os << " " << id << " ";
- i->dump(os);
+ i->printraw(os);
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)
ex unarchive(const lst &sym_lst) const;
void forget(void);
- void dump(ostream &os) const;
+ void printraw(ostream &os) const;
private:
/** Property data types */
void clear(void);
void forget(void);
- void dump(ostream &os) const;
+ void printraw(ostream &os) const;
private:
/** Vector of archived nodes. */
#include "ncmul.h"
#include "numeric.h"
#include "relational.h"
+#include "archive.h"
#include "debugmsg.h"
#include "utils.h"
namespace GiNaC {
#endif // ndef NO_GINAC_NAMESPACE
+GINAC_IMPLEMENT_REGISTERED_CLASS(color, indexed)
+
//////////
// default constructor, destructor, copy constructor assignment operator and helpers
//////////
void color::copy(const color & other)
{
- indexed::copy(other);
+ inherited::copy(other);
type=other.type;
representation_label=other.representation_label;
}
void color::destroy(bool call_parent)
{
if (call_parent) {
- indexed::destroy(call_parent);
+ inherited::destroy(call_parent);
}
}
}
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);
}
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);
}
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);
}
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);
}
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);
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
//////////
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)))
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;
}
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>
/** Base class for color object */
class color : public indexed
{
+ GINAC_DECLARE_REGISTERED_CLASS(color, indexed)
+
// friends
friend color color_ONE(unsigned rl);
#include <stdexcept>
#include "coloridx.h"
+#include "archive.h"
#include "utils.h"
#include "debugmsg.h"
namespace GiNaC {
#endif // ndef NO_GINAC_NAMESPACE
+GINAC_IMPLEMENT_REGISTERED_CLASS(coloridx, idx)
+
//////////
// default constructor, destructor, copy constructor assignment operator and helpers
//////////
void coloridx::copy(const coloridx & other)
{
- idx::copy(other);
+ inherited::copy(other);
}
void coloridx::destroy(bool call_parent)
{
- if (call_parent) idx::destroy(call_parent);
+ if (call_parent) inherited::destroy(call_parent);
}
//////////
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
//////////
class coloridx : public idx
{
+ GINAC_DECLARE_REGISTERED_CLASS(coloridx, idx)
+
friend class color;
// member functions
#include "ex.h"
#include "lst.h"
#include "relational.h"
+#include "archive.h"
#include "utils.h"
#include "debugmsg.h"
namespace GiNaC {
#endif // ndef NO_GINAC_NAMESPACE
+GINAC_IMPLEMENT_REGISTERED_CLASS(idx, basic)
+
//////////
// 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++;
void idx::copy(const idx & other)
{
- basic::copy(other);
+ inherited::copy(other);
serial=other.serial;
symbolic=other.symbolic;
name=other.name;
void idx::destroy(bool call_parent)
{
- if (call_parent) basic::destroy(call_parent);
+ if (call_parent) inherited::destroy(call_parent);
}
//////////
// 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);
}
-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++;
}
-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++;
}
-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;
}
+//////////
+// 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
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
class idx : public basic
{
+ GINAC_DECLARE_REGISTERED_CLASS(idx, basic)
+
// member functions
// default constructor, destructor, copy constructor assignment operator and helpers
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. */
#include "isospin.h"
#include "ex.h"
#include "ncmul.h"
+#include "lst.h"
+#include "archive.h"
#include "utils.h"
#include "debugmsg.h"
namespace GiNaC {
#endif // ndef NO_GINAC_NAMESPACE
+GINAC_IMPLEMENT_REGISTERED_CLASS(isospin, indexed)
+
//////////
// default constructor, destructor, copy constructor assignment operator and helpers
//////////
void isospin::copy(const isospin & other)
{
- indexed::copy(other);
+ inherited::copy(other);
name=other.name;
serial=other.serial;
}
void isospin::destroy(bool call_parent)
{
if (call_parent) {
- indexed::destroy(call_parent);
+ inherited::destroy(call_parent);
}
}
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
//////////
bool isospin::info(unsigned inf) const
{
- return indexed::info(inf);
+ return inherited::info(inf);
}
// protected
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;
}
/** 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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "config.h"
+
#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 "config.h"
#include "archive.h"
#include "debugmsg.h"
#include "utils.h"
{
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);
- 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
- // 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);
- 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();
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;
- 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
- // Workaround for the above: write to strstream
+ // Write number as string
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
@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 \
@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 \
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++) {