#include "expairseq.h"
#include "lst.h"
+#include "archive.h"
#include "debugmsg.h"
#include "utils.h"
#error "FIXME: expair_needs_further_processing not yet implemented for hashtabs, sorry. A.F."
#endif // def EXPAIRSEQ_USE_HASHTAB
+GINAC_IMPLEMENT_REGISTERED_CLASS(expairseq, basic)
+
//////////
// helper classes
//////////
void expairseq::copy(expairseq const & other)
{
- basic::copy(other);
+ inherited::copy(other);
seq=other.seq;
overall_coeff=other.overall_coeff;
#ifdef EXPAIRSEQ_USE_HASHTAB
// other constructors
//////////
-expairseq::expairseq(ex const & lh, ex const & rh) : basic(TINFO_expairseq)
+expairseq::expairseq(ex const & lh, ex const & rh) : inherited(TINFO_expairseq)
{
debugmsg("expairseq constructor from ex,ex",LOGLEVEL_CONSTRUCT);
construct_from_2_ex(lh,rh);
GINAC_ASSERT(is_canonical());
}
-expairseq::expairseq(exvector const & v) : basic(TINFO_expairseq)
+expairseq::expairseq(exvector const & v) : inherited(TINFO_expairseq)
{
debugmsg("expairseq constructor from exvector",LOGLEVEL_CONSTRUCT);
construct_from_exvector(v);
/*
expairseq::expairseq(epvector const & v, bool do_not_canonicalize) :
- basic(TINFO_expairseq)
+ inherited(TINFO_expairseq)
{
debugmsg("expairseq constructor from epvector",LOGLEVEL_CONSTRUCT);
if (do_not_canonicalize) {
*/
expairseq::expairseq(epvector const & v, ex const & oc) :
- basic(TINFO_expairseq), overall_coeff(oc)
+ inherited(TINFO_expairseq), overall_coeff(oc)
{
debugmsg("expairseq constructor from epvector,ex",LOGLEVEL_CONSTRUCT);
construct_from_epvector(v);
}
expairseq::expairseq(epvector * vp, ex const & oc) :
- basic(TINFO_expairseq), overall_coeff(oc)
+ inherited(TINFO_expairseq), overall_coeff(oc)
{
debugmsg("expairseq constructor from epvector *,ex",LOGLEVEL_CONSTRUCT);
GINAC_ASSERT(vp!=0);
GINAC_ASSERT(is_canonical());
}
+//////////
+// archiving
+//////////
+
+/** Construct object from archive_node. */
+expairseq::expairseq(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
+#ifdef EXPAIRSEQ_USE_HASHTAB
+ , hashtabsize(0)
+#endif
+{
+ debugmsg("expairseq constructor from archive_node", LOGLEVEL_CONSTRUCT);
+ for (unsigned int i=0; true; i++) {
+ ex rest;
+ ex coeff;
+ if (n.find_ex("rest", rest, sym_lst, i) && n.find_ex("coeff", coeff, sym_lst, i))
+ seq.push_back(expair(rest, coeff));
+ else
+ break;
+ }
+ n.find_ex("overall_coeff", overall_coeff, sym_lst);
+}
+
+/** Unarchive the object. */
+ex expairseq::unarchive(const archive_node &n, const lst &sym_lst)
+{
+ return (new expairseq(n, sym_lst))->setflag(status_flags::dynallocated);
+}
+
+/** Archive the object. */
+void expairseq::archive(archive_node &n) const
+{
+ inherited::archive(n);
+ epvector::const_iterator i = seq.begin(), iend = seq.end();
+ while (i != iend) {
+ n.add_ex("rest", i->rest);
+ n.add_ex("coeff", i->coeff);
+ i++;
+ }
+ n.add_ex("overall_coeff", overall_coeff);
+}
+
//////////
// functions overriding virtual functions from bases classes
//////////
bool expairseq::info(unsigned inf) const
{
- return basic::info(inf);
+ return inherited::info(inf);
}
unsigned expairseq::nops() const