From 19c8f943c15dcc0d946fb4d5fef11e487d34857a Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Fri, 11 Aug 2000 19:52:41 +0000 Subject: [PATCH] - fixes to the indentation --- ginac/basic.h | 4 +- ginac/color.h | 39 +- ginac/container.pl | 695 +++++++++++++++++----------------- ginac/ex.h | 190 +++++----- ginac/expair.h | 29 +- ginac/expairseq.h | 44 +-- ginac/flags.h | 172 +++++---- ginac/function.pl | 910 ++++++++++++++++++++++----------------------- ginac/idx.h | 4 +- ginac/lorentzidx.h | 4 +- ginac/lortensor.h | 20 +- ginac/matrix.h | 2 +- ginac/ncmul.h | 6 +- ginac/numeric.h | 4 +- ginac/power.h | 4 +- ginac/registrar.h | 10 +- ginac/relational.h | 13 +- ginac/remember.h | 34 +- ginac/simp_lor.h | 11 +- ginac/structure.pl | 315 ++++++++-------- ginac/utils.h | 15 +- 21 files changed, 1269 insertions(+), 1256 deletions(-) diff --git a/ginac/basic.h b/ginac/basic.h index 4acdb9ef..1a7ffcf0 100644 --- a/ginac/basic.h +++ b/ginac/basic.h @@ -66,7 +66,7 @@ class basic public: basic() #ifdef INLINE_BASIC_CONSTRUCTORS - : tinfo_key(TINFO_basic), flags(0), refcount(0) + : tinfo_key(TINFO_basic), flags(0), refcount(0) { } #else @@ -106,7 +106,7 @@ protected: // other constructors basic(unsigned ti) #ifdef INLINE_BASIC_CONSTRUCTORS - : tinfo_key(ti), flags(0), refcount(0) + : tinfo_key(ti), flags(0), refcount(0) { } #else diff --git a/ginac/color.h b/ginac/color.h index 67218342..299b3be8 100644 --- a/ginac/color.h +++ b/ginac/color.h @@ -54,13 +54,13 @@ class color : public indexed friend color color_delta8(const ex & a, const ex & b); friend unsigned subs_index_in_exvector(exvector & v, const ex & is, const ex & ir); friend void split_color_string_in_parts(const exvector & v, exvector & delta8vec, - exvector & fvec, exvector & dvec, - exvectorvector & Tvecs, - exvectorvector & ONEvecs, - exvector & unknownvec); + exvector & fvec, exvector & dvec, + exvectorvector & Tvecs, + exvectorvector & ONEvecs, + exvector & unknownvec); friend exvector recombine_color_string(exvector & delta8vec, exvector & fvec, - exvector & dvec, exvectorvector & Tvecs, - exvectorvector & ONEvecs, exvector & unknownvec); + exvector & dvec, exvectorvector & Tvecs, + exvectorvector & ONEvecs, exvector & unknownvec); friend ex color_trace_of_one_representation_label(const exvector & v); friend ex color_trace(const exvector & v, unsigned rl); friend ex simplify_pure_color_string(const ex & e); @@ -70,12 +70,13 @@ class color : public indexed // types public: - typedef enum { invalid, // not properly constructed by one of the friend functions - color_T, - color_f, - color_d, - color_delta8, - color_ONE + typedef enum { + invalid, // not properly constructed by one of the friend functions + color_T, + color_f, + color_d, + color_delta8, + color_ONE } color_types; // member functions @@ -96,7 +97,7 @@ protected: color(color_types const t, const ex & i1, unsigned rl=0); color(color_types const t, const ex & i1, const ex & i2, unsigned rl=0); color(color_types const t, const ex & i1, const ex & i2, const ex & i3, - unsigned rl=0); + unsigned rl=0); color(color_types const t, const exvector & iv, unsigned rl=0); color(color_types const t, exvector * ivp, unsigned rl=0); @@ -153,13 +154,13 @@ color color_d(const ex & a, const ex & b, const ex & c); ex color_h(const ex & a, const ex & b, const ex & c); color color_delta8(const ex & a, const ex & b); void split_color_string_in_parts(const exvector & v, exvector & delta8vec, - exvector & fvec, exvector & dvec, - exvectorvector & Tvecs, - exvectorvector & ONEvecs, - exvector & unknownvec); + exvector & fvec, exvector & dvec, + exvectorvector & Tvecs, + exvectorvector & ONEvecs, + exvector & unknownvec); exvector recombine_color_string(exvector & delta8vec, exvector & fvec, - exvector & dvec, exvectorvector & Tvecs, - exvectorvector & ONEvecs, exvector & unknownvec); + exvector & dvec, exvectorvector & Tvecs, + exvectorvector & ONEvecs, exvector & unknownvec); ex color_trace_of_one_representation_label(const exvector & v); ex color_trace(const exvector & v, unsigned rl=0); ex simplify_pure_color_string(const ex & e); diff --git a/ginac/container.pl b/ginac/container.pl index 9dac1847..7f06cfeb 100755 --- a/ginac/container.pl +++ b/ginac/container.pl @@ -1,127 +1,127 @@ if (($#ARGV!=0) and ($#ARGV!=1)) { - die 'usage: container.pl type [maxargs] (type=lst or exprseq)'; + die 'usage: container.pl type [maxargs] (type=lst or exprseq)'; } if ($ARGV[0] eq 'lst') { - $type='lst'; + $type='lst'; } elsif ($ARGV[0] eq 'exprseq') { - $type='exprseq'; + $type='exprseq'; } else { - die 'only lst and exprseq supported'; + die 'only lst and exprseq supported'; } if ($#ARGV==1) { - $maxargs=$ARGV[1]; + $maxargs=$ARGV[1]; } else { - $maxargs=15; # must be greater or equal than the value used in function.pl + $maxargs=15; # must be greater or equal than the value used in function.pl } if ($type eq 'exprseq') { - # settings for exprseq - $CONTAINER="exprseq"; - $STLHEADER="vector"; - $reserve=1; - $prepend=0; - $let_op=0; - $open_bracket='('; - $close_bracket=')'; - + # settings for exprseq + $CONTAINER="exprseq"; + $STLHEADER="vector"; + $reserve=1; + $prepend=0; + $let_op=0; + $open_bracket='('; + $close_bracket=')'; + } elsif ($type eq 'lst') { - # settings for lst - $CONTAINER="lst"; - $STLHEADER="list"; - $reserve=0; - $prepend=1; - $let_op=1; - $open_bracket='['; - $close_bracket=']'; + # settings for lst + $CONTAINER="lst"; + $STLHEADER="list"; + $reserve=0; + $prepend=1; + $let_op=1; + $open_bracket='['; + $close_bracket=']'; } else { - die "invalid type $type"; + die "invalid type $type"; } $CONTAINER_UC=uc(${CONTAINER}); $STLT="ex".$STLHEADER; if ($reserve) { - $RESERVE_IMPLEMENTATION="#define RESERVE(s,size) (s).reserve(size)"; + $RESERVE_IMPLEMENTATION="#define RESERVE(s,size) (s).reserve(size)"; } else { - $RESERVE_IMPLEMENTATION="#define RESERVE(s,size) // no reserve needed for ${STLHEADER}"; + $RESERVE_IMPLEMENTATION="#define RESERVE(s,size) // no reserve needed for ${STLHEADER}"; } if ($prepend) { - $PREPEND_INTERFACE=<=0); - GINAC_ASSERT(i=0); + GINAC_ASSERT(i ${STLT}; // CINT does not like ${STLH class ${CONTAINER} : public basic { - GINAC_DECLARE_REGISTERED_CLASS(${CONTAINER}, basic) + GINAC_DECLARE_REGISTERED_CLASS(${CONTAINER}, basic) public: - ${CONTAINER}(); - ~${CONTAINER}(); - ${CONTAINER}(${CONTAINER} const & other); - ${CONTAINER} const & operator=(${CONTAINER} const & other); + ${CONTAINER}(); + ~${CONTAINER}(); + ${CONTAINER}(${CONTAINER} const & other); + ${CONTAINER} const & operator=(${CONTAINER} const & other); protected: - void copy(${CONTAINER} const & other); - void destroy(bool call_parent); + void copy(${CONTAINER} const & other); + void destroy(bool call_parent); public: - ${CONTAINER}(${STLT} const & s, bool discardable=0); - ${CONTAINER}(${STLT} * vp); // vp will be deleted + ${CONTAINER}(${STLT} const & s, bool discardable=0); + ${CONTAINER}(${STLT} * vp); // vp will be deleted ${constructors_interface} public: - basic * duplicate() const; - void printraw(std::ostream & os) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - void printtree(std::ostream & os, unsigned indent) const; - bool info(unsigned inf) const; - unsigned nops() const; - ex & let_op(int i); - ex expand(unsigned options=0) const; - bool has(const ex & other) const; - ex eval(int level=0) const; - ex evalf(int level=0) const; - ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; - ex derivative(const symbol & s) const; - ex subs(const lst & ls, const lst & lr) const; + basic * duplicate() const; + void printraw(std::ostream & os) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printtree(std::ostream & os, unsigned indent) const; + bool info(unsigned inf) const; + unsigned nops() const; + ex & let_op(int i); + ex expand(unsigned options=0) const; + bool has(const ex & other) const; + ex eval(int level=0) const; + ex evalf(int level=0) const; + ex normal(lst &sym_lst, lst &repl_lst, int level=0) const; + ex derivative(const symbol & s) const; + ex subs(const lst & ls, const lst & lr) const; protected: - int compare_same_type(const basic & other) const; - bool is_equal_same_type(const basic & other) const; - unsigned return_type(void) const; + int compare_same_type(const basic & other) const; + bool is_equal_same_type(const basic & other) const; + unsigned return_type(void) const; - // new virtual functions which can be overridden by derived classes + // new virtual functions which can be overridden by derived classes public: - virtual ${CONTAINER} & append(const ex & b); + virtual ${CONTAINER} & append(const ex & b); ${PREPEND_INTERFACE} protected: - virtual void printseq(std::ostream & os, char openbracket, char delim, - char closebracket, unsigned this_precedence, - unsigned upper_precedence=0) const; - virtual ex this${CONTAINER}(${STLT} const & v) const; - virtual ex this${CONTAINER}(${STLT} * vp) const; + virtual void printseq(std::ostream & os, char openbracket, char delim, + char closebracket, unsigned this_precedence, + unsigned upper_precedence=0) const; + virtual ex this${CONTAINER}(${STLT} const & v) const; + virtual ex this${CONTAINER}(${STLT} * vp) const; protected: - bool is_canonical() const; - ${STLT} evalchildren(int level) const; - ${STLT} evalfchildren(int level) const; - ${STLT} normalchildren(int level) const; - ${STLT} diffchildren(const symbol & s) const; - ${STLT} * subschildren(const lst & ls, const lst & lr) const; + bool is_canonical() const; + ${STLT} evalchildren(int level) const; + ${STLT} evalfchildren(int level) const; + ${STLT} normalchildren(int level) const; + ${STLT} diffchildren(const symbol & s) const; + ${STLT} * subschildren(const lst & ls, const lst & lr) const; protected: - ${STLT} seq; - static unsigned precedence; + ${STLT} seq; + static unsigned precedence; }; // global constants @@ -260,12 +260,12 @@ extern const type_info & typeid_${CONTAINER}; // utility functions inline const ${CONTAINER} &ex_to_${CONTAINER}(const ex &e) { - return static_cast(*e.bp); + return static_cast(*e.bp); } inline ${CONTAINER} &ex_to_nonconst_${CONTAINER}(const ex &e) { - return static_cast<${CONTAINER} &>(*e.bp); + return static_cast<${CONTAINER} &>(*e.bp); } #ifndef NO_NAMESPACE_GINAC @@ -334,43 +334,43 @@ ${RESERVE_IMPLEMENTATION} ${CONTAINER}::${CONTAINER}() : basic(TINFO_${CONTAINER}) { - debugmsg("${CONTAINER} default constructor",LOGLEVEL_CONSTRUCT); + debugmsg("${CONTAINER} default constructor",LOGLEVEL_CONSTRUCT); } ${CONTAINER}::~${CONTAINER}() { - debugmsg("${CONTAINER} destructor",LOGLEVEL_DESTRUCT); - destroy(0); + debugmsg("${CONTAINER} destructor",LOGLEVEL_DESTRUCT); + destroy(0); } ${CONTAINER}::${CONTAINER}(${CONTAINER} const & other) { - debugmsg("${CONTAINER} copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); + debugmsg("${CONTAINER} copy constructor",LOGLEVEL_CONSTRUCT); + copy(other); } ${CONTAINER} const & ${CONTAINER}::operator=(${CONTAINER} const & other) { - debugmsg("${CONTAINER} operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(1); - copy(other); - } - return *this; + debugmsg("${CONTAINER} operator=",LOGLEVEL_ASSIGNMENT); + if (this != &other) { + destroy(1); + copy(other); + } + return *this; } // protected void ${CONTAINER}::copy(${CONTAINER} const & other) { - inherited::copy(other); - seq=other.seq; + inherited::copy(other); + seq=other.seq; } void ${CONTAINER}::destroy(bool call_parent) { - seq.clear(); - if (call_parent) inherited::destroy(call_parent); + seq.clear(); + if (call_parent) inherited::destroy(call_parent); } ////////// @@ -381,21 +381,20 @@ void ${CONTAINER}::destroy(bool call_parent) ${CONTAINER}::${CONTAINER}(${STLT} const & s, bool discardable) : basic(TINFO_${CONTAINER}) { - debugmsg("${CONTAINER} constructor from ${STLT}", - LOGLEVEL_CONSTRUCT); - if (discardable) { - seq.swap(const_cast<${STLT} &>(s)); - } else { - seq=s; - } + debugmsg("${CONTAINER} constructor from ${STLT}", LOGLEVEL_CONSTRUCT); + if (discardable) { + seq.swap(const_cast<${STLT} &>(s)); + } else { + seq=s; + } } ${CONTAINER}::${CONTAINER}(${STLT} * vp) : basic(TINFO_${CONTAINER}) { - debugmsg("${CONTAINER} constructor from ${STLT} *",LOGLEVEL_CONSTRUCT); - GINAC_ASSERT(vp!=0); - seq.swap(*vp); - delete vp; + debugmsg("${CONTAINER} constructor from ${STLT} *",LOGLEVEL_CONSTRUCT); + GINAC_ASSERT(vp!=0); + seq.swap(*vp); + delete vp; } ${constructors_implementation} @@ -407,31 +406,31 @@ ${constructors_implementation} /** Construct object from archive_node. */ ${CONTAINER}::${CONTAINER}(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) { - debugmsg("${CONTAINER} constructor from archive_node", LOGLEVEL_CONSTRUCT); - for (unsigned int i=0; true; i++) { - ex e; - if (n.find_ex("seq", e, sym_lst, i)) - seq.push_back(e); - else - break; - } + debugmsg("${CONTAINER} constructor from archive_node", LOGLEVEL_CONSTRUCT); + for (unsigned int i=0; true; i++) { + ex e; + if (n.find_ex("seq", e, sym_lst, i)) + seq.push_back(e); + else + break; + } } /** Unarchive the object. */ ex ${CONTAINER}::unarchive(const archive_node &n, const lst &sym_lst) { - return (new ${CONTAINER}(n, sym_lst))->setflag(status_flags::dynallocated); + return (new ${CONTAINER}(n, sym_lst))->setflag(status_flags::dynallocated); } /** Archive the object. */ void ${CONTAINER}::archive(archive_node &n) const { - inherited::archive(n); - ${STLT}::const_iterator i = seq.begin(), iend = seq.end(); - while (i != iend) { - n.add_ex("seq", *i); - i++; - } + inherited::archive(n); + ${STLT}::const_iterator i = seq.begin(), iend = seq.end(); + while (i != iend) { + n.add_ex("seq", *i); + i++; + } } ////////// @@ -442,87 +441,87 @@ void ${CONTAINER}::archive(archive_node &n) const basic * ${CONTAINER}::duplicate() const { - debugmsg("${CONTAINER} duplicate",LOGLEVEL_DUPLICATE); - return new ${CONTAINER}(*this); + debugmsg("${CONTAINER} duplicate",LOGLEVEL_DUPLICATE); + return new ${CONTAINER}(*this); } void ${CONTAINER}::printraw(std::ostream & os) const { - debugmsg("${CONTAINER} printraw",LOGLEVEL_PRINT); + debugmsg("${CONTAINER} printraw",LOGLEVEL_PRINT); - os << "${CONTAINER}("; - for (${STLT}::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { - (*cit).bp->printraw(os); - os << ","; - } - os << ")"; + os << "${CONTAINER}("; + for (${STLT}::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { + (*cit).bp->printraw(os); + os << ","; + } + os << ")"; } void ${CONTAINER}::print(std::ostream & os, unsigned upper_precedence) const { - debugmsg("${CONTAINER} print",LOGLEVEL_PRINT); - // always print brackets around seq, ignore upper_precedence - printseq(os,'${open_bracket}',',','${close_bracket}',precedence,precedence+1); + debugmsg("${CONTAINER} print",LOGLEVEL_PRINT); + // always print brackets around seq, ignore upper_precedence + printseq(os,'${open_bracket}',',','${close_bracket}',precedence,precedence+1); } void ${CONTAINER}::printtree(std::ostream & os, unsigned indent) const { - debugmsg("${CONTAINER} printtree",LOGLEVEL_PRINT); + debugmsg("${CONTAINER} printtree",LOGLEVEL_PRINT); - os << std::string(indent,' ') << "type=" << typeid(*this).name() - << ", hash=" << hashvalue - << " (0x" << std::hex << hashvalue << std::dec << ")" - << ", flags=" << flags - << ", nops=" << nops() << std::endl; - for (${STLT}::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { - (*cit).printtree(os,indent+delta_indent); - } - os << std::string(indent+delta_indent,' ') << "=====" << std::endl; + os << std::string(indent,' ') << "type=" << class_name() + << ", hash=" << hashvalue + << " (0x" << std::hex << hashvalue << std::dec << ")" + << ", flags=" << flags + << ", nops=" << nops() << std::endl; + for (${STLT}::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) { + (*cit).printtree(os,indent+delta_indent); + } + os << std::string(indent+delta_indent,' ') << "=====" << std::endl; } // ${CONTAINER}::info() will be implemented by user elsewhere"; unsigned ${CONTAINER}::nops() const { - return seq.size(); + return seq.size(); } ${LET_OP_IMPLEMENTATION} ex ${CONTAINER}::expand(unsigned options) const { - ${STLT} s; - RESERVE(s,seq.size()); - for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { - s.push_back((*it).expand(options)); - } + ${STLT} s; + RESERVE(s,seq.size()); + for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { + s.push_back((*it).expand(options)); + } - return this${CONTAINER}(s); + return this${CONTAINER}(s); } // a ${CONTAINER} 'has' an expression if it is this expression itself or a child 'has' it bool ${CONTAINER}::has(const ex & other) const { - GINAC_ASSERT(other.bp!=0); - if (is_equal(*other.bp)) return true; - for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { - if ((*it).has(other)) return true; - } - return false; + GINAC_ASSERT(other.bp!=0); + if (is_equal(*other.bp)) return true; + for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { + if ((*it).has(other)) return true; + } + return false; } ex ${CONTAINER}::eval(int level) const { - if (level==1) { - return this->hold(); - } - return this${CONTAINER}(evalchildren(level)); + if (level==1) { + return this->hold(); + } + return this${CONTAINER}(evalchildren(level)); } ex ${CONTAINER}::evalf(int level) const { - return this${CONTAINER}(evalfchildren(level)); + return this${CONTAINER}(evalfchildren(level)); } /** Implementation of ex::normal() for ${CONTAINER}s. It normalizes the arguments @@ -530,67 +529,67 @@ ex ${CONTAINER}::evalf(int level) const * \@see ex::normal */ ex ${CONTAINER}::normal(lst &sym_lst, lst &repl_lst, int level) const { - ex n=this${CONTAINER}(normalchildren(level)); - return n.bp->basic::normal(sym_lst,repl_lst,level); + ex n=this${CONTAINER}(normalchildren(level)); + return n.bp->basic::normal(sym_lst,repl_lst,level); } ex ${CONTAINER}::derivative(const symbol & s) const { - return this${CONTAINER}(diffchildren(s)); + return this${CONTAINER}(diffchildren(s)); } ex ${CONTAINER}::subs(const lst & ls, const lst & lr) const { - ${STLT} * vp=subschildren(ls,lr); - if (vp==0) { - return *this; - } - return this${CONTAINER}(vp); + ${STLT} * vp=subschildren(ls,lr); + if (vp==0) { + return *this; + } + return this${CONTAINER}(vp); } // protected int ${CONTAINER}::compare_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other,${CONTAINER})); - ${CONTAINER} const & o=static_cast<${CONTAINER} const &> - (const_cast(other)); - int cmpval; - ${STLT}::const_iterator it1=seq.begin(); - ${STLT}::const_iterator it2=o.seq.begin(); + GINAC_ASSERT(is_of_type(other,${CONTAINER})); + ${CONTAINER} const & o=static_cast<${CONTAINER} const &> + (const_cast(other)); + int cmpval; + ${STLT}::const_iterator it1=seq.begin(); + ${STLT}::const_iterator it2=o.seq.begin(); - for (; (it1!=seq.end())&&(it2!=o.seq.end()); ++it1, ++it2) { - cmpval=(*it1).compare(*it2); - if (cmpval!=0) return cmpval; - } + for (; (it1!=seq.end())&&(it2!=o.seq.end()); ++it1, ++it2) { + cmpval=(*it1).compare(*it2); + if (cmpval!=0) return cmpval; + } - if (it1==seq.end()) { - return (it2==o.seq.end() ? 0 : -1); - } + if (it1==seq.end()) { + return (it2==o.seq.end() ? 0 : -1); + } - return 1; + return 1; } bool ${CONTAINER}::is_equal_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other,${CONTAINER})); - ${CONTAINER} const & o=static_cast<${CONTAINER} const &> - (const_cast(other)); - if (seq.size()!=o.seq.size()) return false; + GINAC_ASSERT(is_of_type(other,${CONTAINER})); + ${CONTAINER} const & o=static_cast<${CONTAINER} const &> + (const_cast(other)); + if (seq.size()!=o.seq.size()) return false; - ${STLT}::const_iterator it1=seq.begin(); - ${STLT}::const_iterator it2=o.seq.begin(); + ${STLT}::const_iterator it1=seq.begin(); + ${STLT}::const_iterator it2=o.seq.begin(); - for (; it1!=seq.end(); ++it1, ++it2) { - if (!(*it1).is_equal(*it2)) return false; - } + for (; it1!=seq.end(); ++it1, ++it2) { + if (!(*it1).is_equal(*it2)) return false; + } - return true; + return true; } unsigned ${CONTAINER}::return_type(void) const { - return return_types::noncommutative_composite; + return return_types::noncommutative_composite; } ////////// @@ -601,9 +600,9 @@ unsigned ${CONTAINER}::return_type(void) const ${CONTAINER} & ${CONTAINER}::append(const ex & b) { - ensure_if_modifiable(); - seq.push_back(b); - return *this; + ensure_if_modifiable(); + seq.push_back(b); + return *this; } ${PREPEND_IMPLEMENTATION} @@ -611,32 +610,32 @@ ${PREPEND_IMPLEMENTATION} // protected void ${CONTAINER}::printseq(std::ostream & os, char openbracket, char delim, - char closebracket, unsigned this_precedence, - unsigned upper_precedence) const -{ - if (this_precedence<=upper_precedence) os << openbracket; - if (seq.size()!=0) { - ${STLT}::const_iterator it,it_last; - it=seq.begin(); - it_last=seq.end(); - --it_last; - for (; it!=it_last; ++it) { - (*it).bp->print(os,this_precedence); - os << delim; - } - (*it).bp->print(os,this_precedence); - } - if (this_precedence<=upper_precedence) os << closebracket; + char closebracket, unsigned this_precedence, + unsigned upper_precedence) const +{ + if (this_precedence<=upper_precedence) os << openbracket; + if (seq.size()!=0) { + ${STLT}::const_iterator it,it_last; + it=seq.begin(); + it_last=seq.end(); + --it_last; + for (; it!=it_last; ++it) { + (*it).bp->print(os,this_precedence); + os << delim; + } + (*it).bp->print(os,this_precedence); + } + if (this_precedence<=upper_precedence) os << closebracket; } ex ${CONTAINER}::this${CONTAINER}(${STLT} const & v) const { - return ${CONTAINER}(v); + return ${CONTAINER}(v); } ex ${CONTAINER}::this${CONTAINER}(${STLT} * vp) const { - return ${CONTAINER}(vp); + return ${CONTAINER}(vp); } ////////// @@ -651,134 +650,134 @@ ex ${CONTAINER}::this${CONTAINER}(${STLT} * vp) const bool ${CONTAINER}::is_canonical() const { - if (seq.size()<=1) { return 1; } + if (seq.size()<=1) { return 1; } - ${STLT}::const_iterator it=seq.begin(); - ${STLT}::const_iterator it_last=it; - for (++it; it!=seq.end(); it_last=it, ++it) { - if ((*it_last).compare(*it)>0) { - if ((*it_last).compare(*it)>0) { - std::cout << *it_last << ">" << *it << "\\n"; - return 0; - } - } - } - return 1; + ${STLT}::const_iterator it=seq.begin(); + ${STLT}::const_iterator it_last=it; + for (++it; it!=seq.end(); it_last=it, ++it) { + if ((*it_last).compare(*it)>0) { + if ((*it_last).compare(*it)>0) { + std::cout << *it_last << ">" << *it << "\\n"; + return 0; + } + } + } + return 1; } ${STLT} ${CONTAINER}::evalchildren(int level) const { - ${STLT} s; - RESERVE(s,seq.size()); + ${STLT} s; + RESERVE(s,seq.size()); - if (level==1) { - return seq; - } - if (level == -max_recursion_level) { - throw(std::runtime_error("max recursion level reached")); - } - --level; - for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { - s.push_back((*it).eval(level)); - } - return s; + if (level==1) { + return seq; + } + if (level == -max_recursion_level) { + throw(std::runtime_error("max recursion level reached")); + } + --level; + for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { + s.push_back((*it).eval(level)); + } + return s; } ${STLT} ${CONTAINER}::evalfchildren(int level) const { - ${STLT} s; - RESERVE(s,seq.size()); + ${STLT} s; + RESERVE(s,seq.size()); - if (level==1) { - return seq; - } - if (level == -max_recursion_level) { - throw(std::runtime_error("max recursion level reached")); - } - --level; - for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { - s.push_back((*it).evalf(level)); - } - return s; + if (level==1) { + return seq; + } + if (level == -max_recursion_level) { + throw(std::runtime_error("max recursion level reached")); + } + --level; + for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { + s.push_back((*it).evalf(level)); + } + return s; } ${STLT} ${CONTAINER}::normalchildren(int level) const { - ${STLT} s; - RESERVE(s,seq.size()); + ${STLT} s; + RESERVE(s,seq.size()); - if (level==1) { - return seq; - } - if (level == -max_recursion_level) { - throw(std::runtime_error("max recursion level reached")); - } - --level; - for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { - s.push_back((*it).normal(level)); - } - return s; + if (level==1) { + return seq; + } + if (level == -max_recursion_level) { + throw(std::runtime_error("max recursion level reached")); + } + --level; + for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { + s.push_back((*it).normal(level)); + } + return s; } ${STLT} ${CONTAINER}::diffchildren(const symbol & y) const { - ${STLT} s; - RESERVE(s,seq.size()); - for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { - s.push_back((*it).diff(y)); - } - return s; + ${STLT} s; + RESERVE(s,seq.size()); + for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { + s.push_back((*it).diff(y)); + } + return s; } /* obsolete subschildren ${STLT} ${CONTAINER}::subschildren(const lst & ls, const lst & lr) const { - ${STLT} s; - RESERVE(s,seq.size()); - for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { - s.push_back((*it).subs(ls,lr)); - } - return s; + ${STLT} s; + RESERVE(s,seq.size()); + for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) { + s.push_back((*it).subs(ls,lr)); + } + return s; } */ ${STLT} * ${CONTAINER}::subschildren(const lst & ls, const lst & lr) const { - // returns a NULL pointer if nothing had to be substituted - // returns a pointer to a newly created epvector otherwise - // (which has to be deleted somewhere else) - - ${STLT}::const_iterator last=seq.end(); - ${STLT}::const_iterator cit=seq.begin(); - while (cit!=last) { - const ex & subsed_ex=(*cit).subs(ls,lr); - if (!are_ex_trivially_equal(*cit,subsed_ex)) { - - // something changed, copy seq, subs and return it - ${STLT} *s=new ${STLT}; - RESERVE(*s,seq.size()); - - // copy parts of seq which are known not to have changed - ${STLT}::const_iterator cit2=seq.begin(); - while (cit2!=cit) { - s->push_back(*cit2); - ++cit2; - } - // copy first changed element - s->push_back(subsed_ex); - ++cit2; - // copy rest - while (cit2!=last) { - s->push_back((*cit2).subs(ls,lr)); - ++cit2; - } - return s; - } - ++cit; - } - - return 0; // nothing has changed + // returns a NULL pointer if nothing had to be substituted + // returns a pointer to a newly created epvector otherwise + // (which has to be deleted somewhere else) + + ${STLT}::const_iterator last=seq.end(); + ${STLT}::const_iterator cit=seq.begin(); + while (cit!=last) { + const ex & subsed_ex=(*cit).subs(ls,lr); + if (!are_ex_trivially_equal(*cit,subsed_ex)) { + + // something changed, copy seq, subs and return it + ${STLT} *s=new ${STLT}; + RESERVE(*s,seq.size()); + + // copy parts of seq which are known not to have changed + ${STLT}::const_iterator cit2=seq.begin(); + while (cit2!=cit) { + s->push_back(*cit2); + ++cit2; + } + // copy first changed element + s->push_back(subsed_ex); + ++cit2; + // copy rest + while (cit2!=last) { + s->push_back((*cit2).subs(ls,lr)); + ++cit2; + } + return s; + } + ++cit; + } + + return 0; // nothing has changed } ////////// diff --git a/ginac/ex.h b/ginac/ex.h index 87105a12..b34dcb96 100644 --- a/ginac/ex.h +++ b/ginac/ex.h @@ -57,66 +57,66 @@ class ex public: ex() #ifdef INLINE_EX_CONSTRUCTORS - : bp(_ex0().bp) - { - GINAC_ASSERT(_ex0().bp!=0); - GINAC_ASSERT(_ex0().bp->flags & status_flags::dynallocated); - GINAC_ASSERT(bp!=0); - ++bp->refcount; + : bp(_ex0().bp) + { + GINAC_ASSERT(_ex0().bp!=0); + GINAC_ASSERT(_ex0().bp->flags & status_flags::dynallocated); + GINAC_ASSERT(bp!=0); + ++bp->refcount; #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS ~ex() #ifdef INLINE_EX_CONSTRUCTORS - { - GINAC_ASSERT(bp!=0); - GINAC_ASSERT(bp->flags & status_flags::dynallocated); - if (--bp->refcount == 0) { - delete bp; - } + { + GINAC_ASSERT(bp!=0); + GINAC_ASSERT(bp->flags & status_flags::dynallocated); + if (--bp->refcount == 0) { + delete bp; } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS ex(const ex & other) #ifdef INLINE_EX_CONSTRUCTORS - : bp(other.bp) - { - GINAC_ASSERT(bp!=0); - GINAC_ASSERT((bp->flags) & status_flags::dynallocated); - ++bp->refcount; + : bp(other.bp) + { + GINAC_ASSERT(bp!=0); + GINAC_ASSERT((bp->flags) & status_flags::dynallocated); + ++bp->refcount; #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS const ex & operator=(const ex & other) #ifdef INLINE_EX_CONSTRUCTORS - { - GINAC_ASSERT(bp!=0); - GINAC_ASSERT(bp->flags & status_flags::dynallocated); - GINAC_ASSERT(other.bp!=0); - GINAC_ASSERT(other.bp->flags & status_flags::dynallocated); - ++other.bp->refcount; - basic * tmpbp=other.bp; - if (--bp->refcount==0) { - delete bp; - } - bp=tmpbp; + { + GINAC_ASSERT(bp!=0); + GINAC_ASSERT(bp->flags & status_flags::dynallocated); + GINAC_ASSERT(other.bp!=0); + GINAC_ASSERT(other.bp->flags & status_flags::dynallocated); + ++other.bp->refcount; + basic * tmpbp=other.bp; + if (--bp->refcount==0) { + delete bp; + } + bp=tmpbp; #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - return *this; - } + return *this; + } #else ; #endif // def INLINE_EX_CONSTRUCTORS @@ -126,72 +126,72 @@ public: public: ex(const basic & other) #ifdef INLINE_EX_CONSTRUCTORS - { - construct_from_basic(other); + { + construct_from_basic(other); #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS ex(int i) #ifdef INLINE_EX_CONSTRUCTORS - { - construct_from_int(i); + { + construct_from_int(i); #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS ex(unsigned int i) #ifdef INLINE_EX_CONSTRUCTORS - { - construct_from_uint(i); + { + construct_from_uint(i); #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS ex(long i) #ifdef INLINE_EX_CONSTRUCTORS - { - construct_from_long(i); + { + construct_from_long(i); #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS ex(unsigned long i) #ifdef INLINE_EX_CONSTRUCTORS - { - construct_from_ulong(i); + { + construct_from_ulong(i); #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS ex(double const d) #ifdef INLINE_EX_CONSTRUCTORS - { - construct_from_double(d); + { + construct_from_double(d); #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS @@ -202,12 +202,12 @@ public: * symbols and other parser errors will throw an exception. */ ex(const std::string &s, const ex &l) #ifdef INLINE_EX_CONSTRUCTORS - { - construct_from_string_and_lst(s, l); + { + construct_from_string_and_lst(s, l); #ifdef OBSCURE_CINT_HACK - update_last_created_or_assigned_bp(); + update_last_created_or_assigned_bp(); #endif // def OBSCURE_CINT_HACK - } + } #else ; #endif // def INLINE_EX_CONSTRUCTORS @@ -265,29 +265,29 @@ public: ex rhs(void) const; int compare(const ex & other) const #ifdef INLINE_EX_CONSTRUCTORS - { - GINAC_ASSERT(bp!=0); - GINAC_ASSERT(other.bp!=0); - if (bp==other.bp) { - // special case: both expression point to same basic, trivially equal - return 0; - } - return bp->compare(*other.bp); + { + GINAC_ASSERT(bp!=0); + GINAC_ASSERT(other.bp!=0); + if (bp==other.bp) { + // special case: both expression point to same basic, trivially equal + return 0; } + return bp->compare(*other.bp); + } #else ; #endif // def INLINE_EX_CONSTRUCTORS bool is_equal(const ex & other) const #ifdef INLINE_EX_CONSTRUCTORS - { - GINAC_ASSERT(bp!=0); - GINAC_ASSERT(other.bp!=0); - if (bp==other.bp) { - // special case: both expression point to same basic, trivially equal - return true; - } - return bp->is_equal(*other.bp); + { + GINAC_ASSERT(bp!=0); + GINAC_ASSERT(other.bp!=0); + if (bp==other.bp) { + // special case: both expression point to same basic, trivially equal + return true; } + return bp->is_equal(*other.bp); + } #else ; #endif // def INLINE_EX_CONSTRUCTORS @@ -313,26 +313,26 @@ private: #ifdef OBSCURE_CINT_HACK public: static bool last_created_or_assigned_bp_can_be_converted_to_ex(void) - { - if (last_created_or_assigned_bp==0) return false; - if ((last_created_or_assigned_bp->flags & - status_flags::dynallocated)==0) return false; - if ((last_created_or_assigned_bp->flags & - status_flags::evaluated)==0) return false; - return true; - } + { + if (last_created_or_assigned_bp==0) return false; + if ((last_created_or_assigned_bp->flags & + status_flags::dynallocated)==0) return false; + if ((last_created_or_assigned_bp->flags & + status_flags::evaluated)==0) return false; + return true; + } protected: void update_last_created_or_assigned_bp(void) - { - if (last_created_or_assigned_bp!=0) { - if (--last_created_or_assigned_bp->refcount == 0) { - delete last_created_or_assigned_bp; - } + { + if (last_created_or_assigned_bp!=0) { + if (--last_created_or_assigned_bp->refcount == 0) { + delete last_created_or_assigned_bp; } - last_created_or_assigned_bp=bp; - ++last_created_or_assigned_bp->refcount; - last_created_or_assigned_exp=(long)(void *)(this); } + last_created_or_assigned_bp=bp; + ++last_created_or_assigned_bp->refcount; + last_created_or_assigned_exp=(long)(void *)(this); + } #endif // def OBSCURE_CINT_HACK // member variables diff --git a/ginac/expair.h b/ginac/expair.h index 2ec2848d..15dffe71 100644 --- a/ginac/expair.h +++ b/ginac/expair.h @@ -38,10 +38,12 @@ class expair public: expair() {} ~expair() {} + expair(const expair & other) : rest(other.rest), coeff(other.coeff) { GINAC_ASSERT(is_ex_exactly_of_type(coeff,numeric)); } + const expair & operator=(const expair & other) { if (this != &other) { @@ -50,6 +52,7 @@ public: } return *this; } + expair(const ex & r, const ex & c) : rest(r), coeff(c) { GINAC_ASSERT(is_ex_exactly_of_type(coeff,numeric)); @@ -58,19 +61,21 @@ public: bool is_numeric_with_coeff_1(void) const { GINAC_ASSERT(is_ex_exactly_of_type(coeff,numeric)); - return is_ex_exactly_of_type(rest,numeric) && - (coeff.is_equal(ex(1))); + return is_ex_exactly_of_type(rest,numeric) + && (coeff.is_equal(ex(1))); } bool is_equal(const expair & other) const { return (rest.is_equal(other.rest) && coeff.is_equal(other.coeff)); } + bool is_less(const expair & other) const { - return (rest.compare(other.rest)<0) || - (!(other.rest.compare(rest)<0) && (coeff.compare(other.coeff)<0)); + return (rest.compare(other.rest)<0) + || (!(other.rest.compare(rest)<0) && (coeff.compare(other.coeff)<0)); } + int compare(const expair & other) const { int cmpval=rest.compare(other.rest); @@ -95,9 +100,8 @@ public: // only other has coeff 1: < return true; } - return (rest.compare(other.rest)<0) || - (!(other.rest.compare(rest)<0) && - (coeff.compare(other.coeff)<0)); + return (rest.compare(other.rest)<0) + || (!(other.rest.compare(rest)<0) && (coeff.compare(other.coeff)<0)); */ if (is_ex_exactly_of_type(rest,numeric) && is_ex_exactly_of_type(other.rest,numeric)) { @@ -114,10 +118,10 @@ public: } // neither has coeff 1: usual compare } - return (rest.compare(other.rest)<0) || - (!(other.rest.compare(rest)<0) && - (coeff.compare(other.coeff)<0)); + return (rest.compare(other.rest)<0) + || (!(other.rest.compare(rest)<0) && (coeff.compare(other.coeff)<0)); } + int compare_old2(const expair & other) const { if (is_ex_exactly_of_type(rest,numeric) && @@ -155,10 +159,11 @@ public: if (cmpval!=0) return cmpval; return coeff.compare(other.coeff); } + bool is_less_old(const expair & other) const { - return (rest.compare(other.rest)<0) || - (!(other.rest.compare(rest)<0) && (coeff.compare(other.coeff)<0)); + return (rest.compare(other.rest)<0) + || (!(other.rest.compare(rest)<0) && (coeff.compare(other.coeff)<0)); } int compare_old(const expair & other) const { diff --git a/ginac/expairseq.h b/ginac/expairseq.h index e4263d51..ee7ddbd3 100644 --- a/ginac/expairseq.h +++ b/ginac/expairseq.h @@ -65,22 +65,22 @@ class expairseq : public basic public: expairseq() : basic(TINFO_expairseq) #ifdef EXPAIRSEQ_USE_HASHTAB - , hashtabsize(0) + , hashtabsize(0) #endif // def EXPAIRSEQ_USE_HASHTAB - { - } + { + } ~expairseq() - { - destroy(0); - } + { + destroy(0); + } expairseq(const expairseq & other); const expairseq & operator=(const expairseq & other); protected: void copy(const expairseq & other); void destroy(bool call_parent) - { - if (call_parent) basic::destroy(call_parent); - }; + { + if (call_parent) basic::destroy(call_parent); + }; // other constructors public: @@ -117,10 +117,10 @@ protected: virtual ex thisexpairseq(const epvector & v, const ex & oc) const; virtual ex thisexpairseq(epvector * vp, const ex & oc) const; virtual void printseq(std::ostream & os, char delim, - unsigned this_precedence, - unsigned upper_precedence) const; + unsigned this_precedence, + unsigned upper_precedence) const; virtual void printpair(std::ostream & os, const expair & p, - unsigned upper_precedence) const; + unsigned upper_precedence) const; virtual expair split_ex_to_pair(const ex & e) const; virtual expair combine_ex_with_coeff_to_pair(const ex & e, const ex & c) const; @@ -138,9 +138,9 @@ protected: void construct_from_2_ex_via_exvector(const ex & lh, const ex & rh); void construct_from_2_ex(const ex & lh, const ex & rh); void construct_from_2_expairseq(const expairseq & s1, - const expairseq & s2); + const expairseq & s2); void construct_from_expairseq_ex(const expairseq & s, - const ex & e); + const ex & e); void construct_from_exvector(const exvector & v); void construct_from_epvector(const epvector & v); void make_flat(const exvector & v); @@ -156,19 +156,19 @@ protected: void shrink_hashtab(void); void remove_hashtab_entry(epvector::const_iterator element); void move_hashtab_entry(epvector::const_iterator oldpos, - epvector::iterator newpos); + epvector::iterator newpos); void sorted_insert(epplist & eppl, epp elem); void build_hashtab_and_combine(epvector::iterator & first_numeric, - epvector::iterator & last_non_zero, - vector & touched, - unsigned & number_of_zeroes); + epvector::iterator & last_non_zero, + vector & touched, + unsigned & number_of_zeroes); void drop_coeff_0_terms(epvector::iterator & first_numeric, - epvector::iterator & last_non_zero, - vector & touched, - unsigned & number_of_zeroes); + epvector::iterator & last_non_zero, + vector & touched, + unsigned & number_of_zeroes); bool has_coeff_0(void) const; void add_numerics_to_hashtab(epvector::iterator first_numeric, - epvector::const_iterator last_non_zero); + epvector::const_iterator last_non_zero); #endif // def EXPAIRSEQ_USE_HASHTAB bool is_canonical() const; epvector * expandchildren(unsigned options) const; diff --git a/ginac/flags.h b/ginac/flags.h index 2ff39e67..1c9cf084 100644 --- a/ginac/flags.h +++ b/ginac/flags.h @@ -29,110 +29,119 @@ namespace GiNaC { class expand_options { public: - enum { expand_trigonometric = 0x0001 - }; + enum { + expand_trigonometric = 0x0001 + }; }; class series_options { public: - enum { suppress_branchcut = 0x0001 - }; + enum { + suppress_branchcut = 0x0001 + }; }; class determinant_algo { public: - enum { automatic, - gauss, - divfree, - laplace, - bareiss - }; + enum { + automatic, + gauss, + divfree, + laplace, + bareiss + }; }; class solve_algo { public: - enum { automatic, - gauss, - divfree, - bareiss - }; + enum { + automatic, + gauss, + divfree, + bareiss + }; }; class status_flags { public: - enum { dynallocated = 0x0001, - evaluated = 0x0002, - expanded = 0x0004, - hash_calculated = 0x0008 - }; + enum { + dynallocated = 0x0001, + evaluated = 0x0002, + expanded = 0x0004, + hash_calculated = 0x0008 + }; }; /** Possible attributes an object can have. */ class info_flags { public: enum { - // answered by class numeric - numeric, - real, - rational, - integer, - crational, - cinteger, - positive, - negative, - nonnegative, - posint, - negint, - nonnegint, - even, - odd, - prime, - - // answered by class relation - relation, - relation_equal, - relation_not_equal, - relation_less, - relation_less_or_equal, - relation_greater, - relation_greater_or_equal, - - // answered by class symbol - symbol, - - // answered by class lst - list, - - // answered by class exprseq - exprseq, - - // answered by classes numeric, symbol, add, mul, power - polynomial, - integer_polynomial, - cinteger_polynomial, - rational_polynomial, - crational_polynomial, - rational_function, - algebraic, - - // answered by class indexed - indexed, // class can carry indices - has_indices, // object has at least one index - - // answered by class idx - idx, - - // answered by class coloridx - coloridx, - - // answered by class lorentzidx - lorentzidx + // answered by class numeric + numeric, + real, + rational, + integer, + crational, + cinteger, + positive, + negative, + nonnegative, + posint, + negint, + nonnegint, + even, + odd, + prime, + + // answered by class relation + relation, + relation_equal, + relation_not_equal, + relation_less, + relation_less_or_equal, + relation_greater, + relation_greater_or_equal, + + // answered by class symbol + symbol, + + // answered by class lst + list, + + // answered by class exprseq + exprseq, + + // answered by classes numeric, symbol, add, mul, power + polynomial, + integer_polynomial, + cinteger_polynomial, + rational_polynomial, + crational_polynomial, + rational_function, + algebraic, + + // answered by class indexed + indexed, // class can carry indices + has_indices, // object has at least one index + + // answered by class idx + idx, + + // answered by class coloridx + coloridx, + + // answered by class lorentzidx + lorentzidx }; }; class return_types { public: - enum { commutative, noncommutative, noncommutative_composite}; + enum { + commutative, + noncommutative, + noncommutative_composite + }; }; class csrc_types { @@ -146,10 +155,11 @@ public: class remember_strategies { public: - enum { delete_never, // let table grow undefinitely, not recommmended, but currently default - delete_lru, // least recently used - delete_lfu, // least frequently used - delete_cyclic // first (oldest) one in list + enum { + delete_never, // let table grow undefinitely, not recommmended, but currently default + delete_lru, // least recently used + delete_lfu, // least frequently used + delete_cyclic // first (oldest) one in list }; }; diff --git a/ginac/function.pl b/ginac/function.pl index f67c4b96..ac2dc877 100755 --- a/ginac/function.pl +++ b/ginac/function.pl @@ -1,59 +1,59 @@ $maxargs=13; sub generate_seq { - my ($seq_template,$n)=@_; - my ($res,$N); - - $res=''; - for ($N=1; $N<=$n; $N++) { - $res .= eval('"' . $seq_template . '"'); - if ($N!=$n) { - $res .= ', '; - } - } - return $res; + my ($seq_template,$n)=@_; + my ($res,$N); + + $res=''; + for ($N=1; $N<=$n; $N++) { + $res .= eval('"' . $seq_template . '"'); + if ($N!=$n) { + $res .= ', '; + } + } + return $res; } sub generate_from_to { - my ($template,$seq_template1,$seq_template2,$from,$to)=@_; - my ($res,$N,$SEQ); - - $res=''; - for ($N=$from; $N<=$to; $N++) { - $SEQ1=generate_seq($seq_template1,$N); - $SEQ2=generate_seq($seq_template2,$N); - $res .= eval('"' . $template . '"'); - $SEQ1=''; # to avoid main::SEQ1 used only once warning - $SEQ2=''; # same as above - } - return $res; + my ($template,$seq_template1,$seq_template2,$from,$to)=@_; + my ($res,$N,$SEQ); + + $res=''; + for ($N=$from; $N<=$to; $N++) { + $SEQ1=generate_seq($seq_template1,$N); + $SEQ2=generate_seq($seq_template2,$N); + $res .= eval('"' . $template . '"'); + $SEQ1=''; # to avoid main::SEQ1 used only once warning + $SEQ2=''; # same as above + } + return $res; } sub generate { - my ($template,$seq_template1,$seq_template2)=@_; - return generate_from_to($template,$seq_template1,$seq_template2,1,$maxargs); + my ($template,$seq_template1,$seq_template2)=@_; + return generate_from_to($template,$seq_template1,$seq_template2,1,$maxargs); } $declare_function_macro_namespace = <<'END_OF_DECLARE_FUNCTION_1_AND_2P_MACRO_NAMESPACE'; #define DECLARE_FUNCTION_1P(NAME) \ extern const unsigned function_index_##NAME; \ inline GiNaC::function NAME(const GiNaC::ex & p1) { \ - return GiNaC::function(function_index_##NAME, p1); \ + return GiNaC::function(function_index_##NAME, p1); \ } #define DECLARE_FUNCTION_2P(NAME) \ extern const unsigned function_index_##NAME; \ inline GiNaC::function NAME(const GiNaC::ex & p1, const GiNaC::ex & p2) { \ - return GiNaC::function(function_index_##NAME, p1, p2); \ + return GiNaC::function(function_index_##NAME, p1, p2); \ } END_OF_DECLARE_FUNCTION_1_AND_2P_MACRO_NAMESPACE $declare_function_macro_namespace .= generate_from_to( - <<'END_OF_DECLARE_FUNCTION_MACRO_NAMESPACE','const GiNaC::ex & p${N}','p${N}',3,$maxargs); + <<'END_OF_DECLARE_FUNCTION_MACRO_NAMESPACE','const GiNaC::ex & p${N}','p${N}',3,$maxargs); #define DECLARE_FUNCTION_${N}P(NAME) \\ extern const unsigned function_index_##NAME; \\ inline GiNaC::function NAME(${SEQ1}) { \\ - return GiNaC::function(function_index_##NAME, ${SEQ2}); \\ + return GiNaC::function(function_index_##NAME, ${SEQ2}); \\ } END_OF_DECLARE_FUNCTION_MACRO_NAMESPACE @@ -62,22 +62,22 @@ $declare_function_macro_no_namespace = <<'END_OF_DECLARE_FUNCTION_1_AND_2P_MACRO #define DECLARE_FUNCTION_1P(NAME) \ extern const unsigned function_index_##NAME; \ inline function NAME(const ex & p1) { \ - return function(function_index_##NAME, p1); \ + return function(function_index_##NAME, p1); \ } #define DECLARE_FUNCTION_2P(NAME) \ extern const unsigned function_index_##NAME; \ inline function NAME(const ex & p1, const ex & p2) { \ - return function(function_index_##NAME, p1, p2); \ + return function(function_index_##NAME, p1, p2); \ } END_OF_DECLARE_FUNCTION_1_AND_2P_MACRO_NO_NAMESPACE $declare_function_macro_no_namespace .= generate_from_to( - <<'END_OF_DECLARE_FUNCTION_MACRO_NO_NAMESPACE','const ex & p${N}','p${N}',3,$maxargs); + <<'END_OF_DECLARE_FUNCTION_MACRO_NO_NAMESPACE','const ex & p${N}','p${N}',3,$maxargs); #define DECLARE_FUNCTION_${N}P(NAME) \\ extern const unsigned function_index_##NAME; \\ inline function NAME(${SEQ1}) { \\ - return function(function_index_##NAME, ${SEQ2}); \\ + return function(function_index_##NAME, ${SEQ2}); \\ } END_OF_DECLARE_FUNCTION_MACRO_NO_NAMESPACE @@ -111,85 +111,85 @@ $constructors_interface=generate( 'const ex & param${N}',''); $constructors_implementation=generate( - <<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}','param${N}'); + <<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}','param${N}'); function::function(unsigned ser, ${SEQ1}) - : exprseq(${SEQ2}), serial(ser) + : exprseq(${SEQ2}), serial(ser) { - debugmsg(\"function constructor from unsigned,${N}*ex\",LOGLEVEL_CONSTRUCT); - tinfo_key = TINFO_function; + debugmsg(\"function constructor from unsigned,${N}*ex\",LOGLEVEL_CONSTRUCT); + tinfo_key = TINFO_function; } END_OF_CONSTRUCTORS_IMPLEMENTATION $eval_switch_statement=generate( - <<'END_OF_EVAL_SWITCH_STATEMENT','seq[${N}-1]',''); - case ${N}: - eval_result=((eval_funcp_${N})(registered_functions()[serial].eval_f))(${SEQ1}); - break; + <<'END_OF_EVAL_SWITCH_STATEMENT','seq[${N}-1]',''); + case ${N}: + eval_result=((eval_funcp_${N})(registered_functions()[serial].eval_f))(${SEQ1}); + break; END_OF_EVAL_SWITCH_STATEMENT $evalf_switch_statement=generate( - <<'END_OF_EVALF_SWITCH_STATEMENT','eseq[${N}-1]',''); - case ${N}: - return ((evalf_funcp_${N})(registered_functions()[serial].evalf_f))(${SEQ1}); - break; + <<'END_OF_EVALF_SWITCH_STATEMENT','eseq[${N}-1]',''); + case ${N}: + return ((evalf_funcp_${N})(registered_functions()[serial].evalf_f))(${SEQ1}); + break; END_OF_EVALF_SWITCH_STATEMENT $diff_switch_statement=generate( - <<'END_OF_DIFF_SWITCH_STATEMENT','seq[${N}-1]',''); - case ${N}: - return ((derivative_funcp_${N})(registered_functions()[serial].derivative_f))(${SEQ1},diff_param); - break; + <<'END_OF_DIFF_SWITCH_STATEMENT','seq[${N}-1]',''); + case ${N}: + return ((derivative_funcp_${N})(registered_functions()[serial].derivative_f))(${SEQ1},diff_param); + break; END_OF_DIFF_SWITCH_STATEMENT $series_switch_statement=generate( - <<'END_OF_SERIES_SWITCH_STATEMENT','seq[${N}-1]',''); - case ${N}: - try { - res = ((series_funcp_${N})(registered_functions()[serial].series_f))(${SEQ1},r,order,options); - } catch (do_taylor) { - res = basic::series(r, order, options); - } - return res; - break; + <<'END_OF_SERIES_SWITCH_STATEMENT','seq[${N}-1]',''); + case ${N}: + try { + res = ((series_funcp_${N})(registered_functions()[serial].series_f))(${SEQ1},r,order,options); + } catch (do_taylor) { + res = basic::series(r, order, options); + } + return res; + break; END_OF_SERIES_SWITCH_STATEMENT $eval_func_implementation=generate( - <<'END_OF_EVAL_FUNC_IMPLEMENTATION','',''); + <<'END_OF_EVAL_FUNC_IMPLEMENTATION','',''); function_options & function_options::eval_func(eval_funcp_${N} e) { - test_and_set_nparams(${N}); - eval_f=eval_funcp(e); - return *this; + test_and_set_nparams(${N}); + eval_f=eval_funcp(e); + return *this; } END_OF_EVAL_FUNC_IMPLEMENTATION $evalf_func_implementation=generate( - <<'END_OF_EVALF_FUNC_IMPLEMENTATION','',''); + <<'END_OF_EVALF_FUNC_IMPLEMENTATION','',''); function_options & function_options::evalf_func(evalf_funcp_${N} ef) { - test_and_set_nparams(${N}); - evalf_f=evalf_funcp(ef); - return *this; + test_and_set_nparams(${N}); + evalf_f=evalf_funcp(ef); + return *this; } END_OF_EVALF_FUNC_IMPLEMENTATION $derivative_func_implementation=generate( - <<'END_OF_DERIVATIVE_FUNC_IMPLEMENTATION','',''); + <<'END_OF_DERIVATIVE_FUNC_IMPLEMENTATION','',''); function_options & function_options::derivative_func(derivative_funcp_${N} d) { - test_and_set_nparams(${N}); - derivative_f=derivative_funcp(d); - return *this; + test_and_set_nparams(${N}); + derivative_f=derivative_funcp(d); + return *this; } END_OF_DERIVATIVE_FUNC_IMPLEMENTATION $series_func_implementation=generate( - <<'END_OF_SERIES_FUNC_IMPLEMENTATION','',''); + <<'END_OF_SERIES_FUNC_IMPLEMENTATION','',''); function_options & function_options::series_func(series_funcp_${N} s) { - test_and_set_nparams(${N}); - series_f=series_funcp(s); - return *this; + test_and_set_nparams(${N}); + series_f=series_funcp(s); + return *this; } END_OF_SERIES_FUNC_IMPLEMENTATION @@ -249,29 +249,29 @@ $declare_function_macro_no_namespace #define REGISTER_FUNCTION(NAME,OPT) \\ const unsigned function_index_##NAME= \\ - GiNaC::function::register_new(GiNaC::function_options(#NAME).OPT); + GiNaC::function::register_new(GiNaC::function_options(#NAME).OPT); #define REGISTER_FUNCTION_OLD(NAME,E,EF,D,S) \\ const unsigned function_index_##NAME= \\ - GiNaC::function::register_new(GiNaC::function_options(#NAME). \\ - eval_func(E). \\ - evalf_func(EF). \\ - derivative_func(D). \\ - series_func(S)); + GiNaC::function::register_new(GiNaC::function_options(#NAME). \\ + eval_func(E). \\ + evalf_func(EF). \\ + derivative_func(D). \\ + series_func(S)); #else // ndef NO_NAMESPACE_GINAC #define REGISTER_FUNCTION(NAME,OPT) \\ const unsigned function_index_##NAME= \\ - function::register_new(function_options(#NAME).OPT); + function::register_new(function_options(#NAME).OPT); #define REGISTER_FUNCTION_OLD(NAME,E,EF,D,S) \\ const unsigned function_index_##NAME= \\ - function::register_new(function_options(#NAME). \\ - eval_func(E). \\ - evalf_func(EF). \\ - derivative_func(D). \\ - series_func(S)); + function::register_new(function_options(#NAME). \\ + eval_func(E). \\ + evalf_func(EF). \\ + derivative_func(D). \\ + series_func(S)); #endif // ndef NO_NAMESPACE_GINAC @@ -280,21 +280,21 @@ bool automatic_typecheck=true; #define TYPECHECK(VAR,TYPE) \\ if (!is_ex_exactly_of_type(VAR,TYPE)) { \\ - automatic_typecheck=false; \\ + automatic_typecheck=false; \\ } else #ifndef NO_NAMESPACE_GINAC #define TYPECHECK_INTEGER(VAR) \\ if (!(VAR).info(GiNaC::info_flags::integer)) { \\ - automatic_typecheck=false; \\ + automatic_typecheck=false; \\ } else #else // ndef NO_NAMESPACE_GINAC #define TYPECHECK_INTEGER(VAR) \\ if (!(VAR).info(info_flags::integer)) { \\ - automatic_typecheck=false; \\ + automatic_typecheck=false; \\ } else #endif // ndef NO_NAMESPACE_GINAC @@ -302,7 +302,7 @@ if (!(VAR).info(info_flags::integer)) { \\ #define END_TYPECHECK(RV) \\ {} \\ if (!automatic_typecheck) { \\ - return RV.hold(); \\ + return RV.hold(); \\ } #ifndef NO_NAMESPACE_GINAC @@ -325,145 +325,145 @@ $typedef_series_funcp class function_options { - friend class function; + friend class function; public: - function_options(); - function_options(std::string const & n, std::string const & tn=std::string()); - ~function_options(); - void initialize(void); - function_options & set_name(std::string const & n, std::string const & tn=std::string()); + function_options(); + function_options(std::string const & n, std::string const & tn=std::string()); + ~function_options(); + void initialize(void); + function_options & set_name(std::string const & n, std::string const & tn=std::string()); // the following lines have been generated for max. ${maxargs} parameters $eval_func_interface $evalf_func_interface $derivative_func_interface $series_func_interface // end of generated lines - function_options & set_return_type(unsigned rt, unsigned rtt=0); - function_options & do_not_evalf_params(void); - function_options & remember(unsigned size, unsigned assoc_size=0, - unsigned strategy=remember_strategies::delete_never); - function_options & overloaded(unsigned o); - void test_and_set_nparams(unsigned n); - std::string get_name(void) const { return name; } - unsigned get_nparams(void) const { return nparams; } + function_options & set_return_type(unsigned rt, unsigned rtt=0); + function_options & do_not_evalf_params(void); + function_options & remember(unsigned size, unsigned assoc_size=0, + unsigned strategy=remember_strategies::delete_never); + function_options & overloaded(unsigned o); + void test_and_set_nparams(unsigned n); + std::string get_name(void) const { return name; } + unsigned get_nparams(void) const { return nparams; } protected: - std::string name; - std::string TeX_name; + std::string name; + std::string TeX_name; - unsigned nparams; + unsigned nparams; - eval_funcp eval_f; - evalf_funcp evalf_f; - derivative_funcp derivative_f; - series_funcp series_f; + eval_funcp eval_f; + evalf_funcp evalf_f; + derivative_funcp derivative_f; + series_funcp series_f; - bool evalf_params_first; + bool evalf_params_first; - bool use_return_type; - unsigned return_type; - unsigned return_type_tinfo; + bool use_return_type; + unsigned return_type; + unsigned return_type_tinfo; - bool use_remember; - unsigned remember_size; - unsigned remember_assoc_size; - unsigned remember_strategy; + bool use_remember; + unsigned remember_size; + unsigned remember_assoc_size; + unsigned remember_strategy; - unsigned functions_with_same_name; + unsigned functions_with_same_name; }; /** The class function is used to implement builtin functions like sin, cos... - and user defined functions */ + and user defined functions */ class function : public exprseq { - GINAC_DECLARE_REGISTERED_CLASS(function, exprseq) + GINAC_DECLARE_REGISTERED_CLASS(function, exprseq) - // CINT has a linking problem + // CINT has a linking problem #ifndef __MAKECINT__ - friend void ginsh_get_ginac_functions(void); + friend void ginsh_get_ginac_functions(void); #endif // def __MAKECINT__ - friend class remember_table_entry; - // friend class remember_table_list; - // friend class remember_table; + friend class remember_table_entry; + // friend class remember_table_list; + // friend class remember_table; // member functions - // default constructor, destructor, copy constructor assignment operator and helpers + // default constructor, destructor, copy constructor assignment operator and helpers public: - function(); - ~function(); - function(const function & other); - const function & operator=(const function & other); + function(); + ~function(); + function(const function & other); + const function & operator=(const function & other); protected: - void copy(const function & other); - void destroy(bool call_parent); + void copy(const function & other); + void destroy(bool call_parent); - // other constructors + // other constructors public: - function(unsigned ser); - // the following lines have been generated for max. ${maxargs} parameters + function(unsigned ser); + // the following lines have been generated for max. ${maxargs} parameters $constructors_interface - // end of generated lines - function(unsigned ser, const exprseq & es); - function(unsigned ser, const exvector & v, bool discardable=0); - function(unsigned ser, exvector * vp); // vp will be deleted + // end of generated lines + function(unsigned ser, const exprseq & es); + function(unsigned ser, const exvector & v, bool discardable=0); + function(unsigned ser, exvector * vp); // vp will be deleted - // functions overriding virtual functions from bases classes + // functions overriding virtual functions from bases classes public: - basic * duplicate() const; - void printraw(std::ostream & os) const; - void print(std::ostream & os, unsigned upper_precedence=0) const; - void printtree(std::ostream & os, unsigned indent) const; - void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; - ex expand(unsigned options=0) const; - ex eval(int level=0) const; - ex evalf(int level=0) const; - ex series(const relational & r, int order, unsigned options = 0) const; - ex thisexprseq(const exvector & v) const; - ex thisexprseq(exvector * vp) const; + basic * duplicate() const; + void printraw(std::ostream & os) const; + void print(std::ostream & os, unsigned upper_precedence=0) const; + void printtree(std::ostream & os, unsigned indent) const; + void printcsrc(std::ostream & os, unsigned type, unsigned upper_precedence=0) const; + ex expand(unsigned options=0) const; + ex eval(int level=0) const; + ex evalf(int level=0) const; + ex series(const relational & r, int order, unsigned options = 0) const; + ex thisexprseq(const exvector & v) const; + ex thisexprseq(exvector * vp) const; protected: - ex derivative(const symbol & s) const; - int compare_same_type(const basic & other) const; - bool is_equal_same_type(const basic & other) const; - unsigned return_type(void) const; - unsigned return_type_tinfo(void) const; - - // new virtual functions which can be overridden by derived classes - // none - - // non-virtual functions in this class + ex derivative(const symbol & s) const; + int compare_same_type(const basic & other) const; + bool is_equal_same_type(const basic & other) const; + unsigned return_type(void) const; + unsigned return_type_tinfo(void) const; + + // new virtual functions which can be overridden by derived classes + // none + + // non-virtual functions in this class protected: - ex pderivative(unsigned diff_param) const; // partial differentiation - static std::vector & registered_functions(void); - bool lookup_remember_table(ex & result) const; - void store_remember_table(ex const & result) const; + ex pderivative(unsigned diff_param) const; // partial differentiation + static std::vector & registered_functions(void); + bool lookup_remember_table(ex & result) const; + void store_remember_table(ex const & result) const; public: - static unsigned register_new(function_options const & opt); - static unsigned find_function(const std::string &name, unsigned nparams); - unsigned getserial(void) const {return serial;} - + static unsigned register_new(function_options const & opt); + static unsigned find_function(const std::string &name, unsigned nparams); + unsigned getserial(void) const {return serial;} + // member variables protected: - unsigned serial; + unsigned serial; }; // utility functions/macros inline const function &ex_to_function(const ex &e) { - return static_cast(*e.bp); + return static_cast(*e.bp); } #ifndef NO_NAMESPACE_GINAC #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) #else // ndef NO_NAMESPACE_GINAC #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) #endif // ndef NO_NAMESPACE_GINAC @@ -530,41 +530,41 @@ namespace GiNaC { function_options::function_options() { - initialize(); + initialize(); } function_options::function_options(std::string const & n, std::string const & tn) { - initialize(); - set_name(n,tn); + initialize(); + set_name(n,tn); } function_options::~function_options() { - // nothing to clean up at the moment + // nothing to clean up at the moment } void function_options::initialize(void) { - set_name("unnamed_function","\\\\operatorname{unnamed}"); - nparams=0; - eval_f=evalf_f=derivative_f=series_f=0; - evalf_params_first=true; - use_return_type=false; - use_remember=false; - functions_with_same_name=1; + set_name("unnamed_function","\\\\operatorname{unnamed}"); + nparams=0; + eval_f=evalf_f=derivative_f=series_f=0; + evalf_params_first=true; + use_return_type=false; + use_remember=false; + functions_with_same_name=1; } function_options & function_options::set_name(std::string const & n, std::string const & tn) { - name=n; - if (tn==std::string()) { - TeX_name="\\\\operatorname{"+name+"}"; - } else { - TeX_name=tn; - } - return *this; + name=n; + if (tn==std::string()) { + TeX_name="\\\\operatorname{"+name+"}"; + } else { + TeX_name=tn; + } + return *this; } // the following lines have been generated for max. ${maxargs} parameters @@ -576,47 +576,47 @@ $series_func_implementation function_options & function_options::set_return_type(unsigned rt, unsigned rtt) { - use_return_type=true; - return_type=rt; - return_type_tinfo=rtt; - return *this; + use_return_type=true; + return_type=rt; + return_type_tinfo=rtt; + return *this; } function_options & function_options::do_not_evalf_params(void) { - evalf_params_first=false; - return *this; + evalf_params_first=false; + return *this; } function_options & function_options::remember(unsigned size, unsigned assoc_size, unsigned strategy) { - use_remember=true; - remember_size=size; - remember_assoc_size=assoc_size; - remember_strategy=strategy; - return *this; + use_remember=true; + remember_size=size; + remember_assoc_size=assoc_size; + remember_strategy=strategy; + return *this; } function_options & function_options::overloaded(unsigned o) { - functions_with_same_name=o; - return *this; + functions_with_same_name=o; + return *this; } - + void function_options::test_and_set_nparams(unsigned n) { - if (nparams==0) { - nparams=n; - } else if (nparams!=n) { - // we do not throw an exception here because this code is - // usually executed before main(), so the exception could not - // caught anyhow - std::cerr << "WARNING: number of parameters (" - << n << ") differs from number set before (" - << nparams << ")" << std::endl; - } + if (nparams==0) { + nparams=n; + } else if (nparams!=n) { + // we do not throw an exception here because this code is + // usually executed before main(), so the exception could not + // caught anyhow + std::cerr << "WARNING: number of parameters (" + << n << ") differs from number set before (" + << nparams << ")" << std::endl; + } } GINAC_IMPLEMENT_REGISTERED_CLASS(function, exprseq) @@ -629,43 +629,43 @@ GINAC_IMPLEMENT_REGISTERED_CLASS(function, exprseq) function::function() : serial(0) { - debugmsg("function default constructor",LOGLEVEL_CONSTRUCT); - tinfo_key = TINFO_function; + debugmsg("function default constructor",LOGLEVEL_CONSTRUCT); + tinfo_key = TINFO_function; } function::~function() { - debugmsg("function destructor",LOGLEVEL_DESTRUCT); - destroy(0); + debugmsg("function destructor",LOGLEVEL_DESTRUCT); + destroy(0); } function::function(const function & other) { - debugmsg("function copy constructor",LOGLEVEL_CONSTRUCT); - copy(other); + debugmsg("function copy constructor",LOGLEVEL_CONSTRUCT); + copy(other); } const function & function::operator=(const function & other) { - debugmsg("function operator=",LOGLEVEL_ASSIGNMENT); - if (this != &other) { - destroy(1); - copy(other); - } - return *this; + debugmsg("function operator=",LOGLEVEL_ASSIGNMENT); + if (this != &other) { + destroy(1); + copy(other); + } + return *this; } // protected void function::copy(const function & other) { - exprseq::copy(other); - serial=other.serial; + exprseq::copy(other); + serial=other.serial; } void function::destroy(bool call_parent) { - if (call_parent) exprseq::destroy(call_parent); + if (call_parent) exprseq::destroy(call_parent); } ////////// @@ -676,8 +676,8 @@ void function::destroy(bool call_parent) function::function(unsigned ser) : serial(ser) { - debugmsg("function constructor from unsigned",LOGLEVEL_CONSTRUCT); - tinfo_key = TINFO_function; + debugmsg("function constructor from unsigned",LOGLEVEL_CONSTRUCT); + tinfo_key = TINFO_function; } // the following lines have been generated for max. ${maxargs} parameters @@ -686,22 +686,22 @@ $constructors_implementation function::function(unsigned ser, const exprseq & es) : exprseq(es), serial(ser) { - debugmsg("function constructor from unsigned,exprseq",LOGLEVEL_CONSTRUCT); - tinfo_key = TINFO_function; + debugmsg("function constructor from unsigned,exprseq",LOGLEVEL_CONSTRUCT); + tinfo_key = TINFO_function; } function::function(unsigned ser, const exvector & v, bool discardable) - : exprseq(v,discardable), serial(ser) + : exprseq(v,discardable), serial(ser) { - debugmsg("function constructor from string,exvector,bool",LOGLEVEL_CONSTRUCT); - tinfo_key = TINFO_function; + debugmsg("function constructor from string,exvector,bool",LOGLEVEL_CONSTRUCT); + tinfo_key = TINFO_function; } function::function(unsigned ser, exvector * vp) - : exprseq(vp), serial(ser) + : exprseq(vp), serial(ser) { - debugmsg("function constructor from unsigned,exvector *",LOGLEVEL_CONSTRUCT); - tinfo_key = TINFO_function; + debugmsg("function constructor from unsigned,exvector *",LOGLEVEL_CONSTRUCT); + tinfo_key = TINFO_function; } ////////// @@ -711,37 +711,37 @@ function::function(unsigned ser, exvector * vp) /** Construct object from archive_node. */ function::function(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst) { - debugmsg("function constructor from archive_node", LOGLEVEL_CONSTRUCT); - - // Find serial number by function name - std::string s; - if (n.find_string("name", s)) { - unsigned int ser = 0; - std::vector::const_iterator i = registered_functions().begin(), iend = registered_functions().end(); - while (i != iend) { - if (s == i->name) { - serial = ser; - return; - } - i++; ser++; - } - throw (std::runtime_error("unknown function '" + s + "' in archive")); - } else - throw (std::runtime_error("unnamed function in archive")); + debugmsg("function constructor from archive_node", LOGLEVEL_CONSTRUCT); + + // Find serial number by function name + std::string s; + if (n.find_string("name", s)) { + unsigned int ser = 0; + std::vector::const_iterator i = registered_functions().begin(), iend = registered_functions().end(); + while (i != iend) { + if (s == i->name) { + serial = ser; + return; + } + i++; ser++; + } + throw (std::runtime_error("unknown function '" + s + "' in archive")); + } else + throw (std::runtime_error("unnamed function in archive")); } /** Unarchive the object. */ ex function::unarchive(const archive_node &n, const lst &sym_lst) { - return (new function(n, sym_lst))->setflag(status_flags::dynallocated); + return (new function(n, sym_lst))->setflag(status_flags::dynallocated); } /** Archive the object. */ void function::archive(archive_node &n) const { - inherited::archive(n); - GINAC_ASSERT(serial < registered_functions().size()); - n.add_string("name", registered_functions()[serial].name); + inherited::archive(n); + GINAC_ASSERT(serial < registered_functions().size()); + n.add_string("name", registered_functions()[serial].name); } ////////// @@ -752,157 +752,157 @@ void function::archive(archive_node &n) const basic * function::duplicate() const { - debugmsg("function duplicate",LOGLEVEL_DUPLICATE); - return new function(*this); + debugmsg("function duplicate",LOGLEVEL_DUPLICATE); + return new function(*this); } void function::printraw(std::ostream & os) const { - debugmsg("function printraw",LOGLEVEL_PRINT); + debugmsg("function printraw",LOGLEVEL_PRINT); - GINAC_ASSERT(serialprint(os); - } - os << ")"; + os << "function(name=" << registered_functions()[serial].name; + for (exvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) { + os << ","; + (*it).bp->print(os); + } + os << ")"; } void function::print(std::ostream & os, unsigned upper_precedence) const { - debugmsg("function print",LOGLEVEL_PRINT); + debugmsg("function print",LOGLEVEL_PRINT); - GINAC_ASSERT(serialbp->printcsrc(os, type, 0); - it++; - if (it != itend) - os << ","; - } - os << ")"; + exvector::const_iterator it = seq.begin(); + exvector::const_iterator itend = seq.end(); + while (it != itend) { + it->bp->printcsrc(os, type, 0); + it++; + if (it != itend) + os << ","; + } + os << ")"; } ex function::expand(unsigned options) const { - return this->setflag(status_flags::expanded); + return this->setflag(status_flags::expanded); } ex function::eval(int level) const { - GINAC_ASSERT(serial1) { - // first evaluate children, then we will end up here again - return function(serial,evalchildren(level)); - } + if (level>1) { + // first evaluate children, then we will end up here again + return function(serial,evalchildren(level)); + } - if (registered_functions()[serial].eval_f==0) { - return this->hold(); - } + if (registered_functions()[serial].eval_f==0) { + return this->hold(); + } - bool use_remember=registered_functions()[serial].use_remember; - ex eval_result; - if (use_remember && lookup_remember_table(eval_result)) { - return eval_result; - } + bool use_remember=registered_functions()[serial].use_remember; + ex eval_result; + if (use_remember && lookup_remember_table(eval_result)) { + return eval_result; + } - switch (registered_functions()[serial].nparams) { - // the following lines have been generated for max. ${maxargs} parameters + switch (registered_functions()[serial].nparams) { + // the following lines have been generated for max. ${maxargs} parameters ${eval_switch_statement} - // end of generated lines - default: - throw(std::logic_error("function::eval(): invalid nparams")); - } - if (use_remember) { - store_remember_table(eval_result); - } - return eval_result; + // end of generated lines + default: + throw(std::logic_error("function::eval(): invalid nparams")); + } + if (use_remember) { + store_remember_table(eval_result); + } + return eval_result; } ex function::evalf(int level) const { - GINAC_ASSERT(serial(const_cast(other)); + GINAC_ASSERT(is_of_type(other, function)); + const function & o=static_cast(const_cast(other)); - if (serial!=o.serial) { - return serial < o.serial ? -1 : 1; - } - return exprseq::compare_same_type(o); + if (serial!=o.serial) { + return serial < o.serial ? -1 : 1; + } + return exprseq::compare_same_type(o); } bool function::is_equal_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other, function)); - const function & o=static_cast(const_cast(other)); + GINAC_ASSERT(is_of_type(other, function)); + const function & o=static_cast(const_cast(other)); - if (serial!=o.serial) return false; - return exprseq::is_equal_same_type(o); + if (serial!=o.serial) return false; + return exprseq::is_equal_same_type(o); } unsigned function::return_type(void) const { - if (seq.size()==0) { - return return_types::commutative; - } - return (*seq.begin()).return_type(); + if (seq.size()==0) { + return return_types::commutative; + } + return (*seq.begin()).return_type(); } unsigned function::return_type_tinfo(void) const { - if (seq.size()==0) { - return tinfo_key; - } - return (*seq.begin()).return_type_tinfo(); + if (seq.size()==0) { + return tinfo_key; + } + return (*seq.begin()).return_type_tinfo(); } ////////// @@ -1000,77 +1000,77 @@ unsigned function::return_type_tinfo(void) const ex function::pderivative(unsigned diff_param) const // partial differentiation { - GINAC_ASSERT(serial & function::registered_functions(void) { - static std::vector * rf = new std::vector; - return *rf; + static std::vector * rf = new std::vector; + return *rf; } bool function::lookup_remember_table(ex & result) const { - return remember_table::remember_tables()[serial].lookup_entry(*this,result); + return remember_table::remember_tables()[serial].lookup_entry(*this,result); } void function::store_remember_table(ex const & result) const { - remember_table::remember_tables()[serial].add_entry(*this,result); + remember_table::remember_tables()[serial].add_entry(*this,result); } // public unsigned function::register_new(function_options const & opt) { - unsigned same_name=0; - for (unsigned i=0; i=opt.functions_with_same_name) { - // we do not throw an exception here because this code is - // usually executed before main(), so the exception could not - // caught anyhow - std::cerr << "WARNING: function name " << opt.name - << " already in use!" << std::endl; - } - registered_functions().push_back(opt); - if (opt.use_remember) { - remember_table::remember_tables(). - push_back(remember_table(opt.remember_size, - opt.remember_assoc_size, - opt.remember_strategy)); - } else { - remember_table::remember_tables().push_back(remember_table()); - } - return registered_functions().size()-1; + unsigned same_name=0; + for (unsigned i=0; i=opt.functions_with_same_name) { + // we do not throw an exception here because this code is + // usually executed before main(), so the exception could not + // caught anyhow + std::cerr << "WARNING: function name " << opt.name + << " already in use!" << std::endl; + } + registered_functions().push_back(opt); + if (opt.use_remember) { + remember_table::remember_tables(). + push_back(remember_table(opt.remember_size, + opt.remember_assoc_size, + opt.remember_strategy)); + } else { + remember_table::remember_tables().push_back(remember_table()); + } + return registered_functions().size()-1; } /** Find serial number of function by name and number of parameters. * Throws exception if function was not found. */ unsigned function::find_function(const std::string &name, unsigned nparams) { - std::vector::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end(); - unsigned serial = 0; - while (i != end) { - if (i->get_name() == name && i->get_nparams() == nparams) - return serial; - i++; - serial++; - } - throw (std::runtime_error("no function '" + name + "' with " + ToString(nparams) + " parameters defined")); + std::vector::const_iterator i = function::registered_functions().begin(), end = function::registered_functions().end(); + unsigned serial = 0; + while (i != end) { + if (i->get_name() == name && i->get_nparams() == nparams) + return serial; + i++; + serial++; + } + throw (std::runtime_error("no function '" + name + "' with " + ToString(nparams) + " parameters defined")); } ////////// diff --git a/ginac/idx.h b/ginac/idx.h index 13fb3e89..3ab440e9 100644 --- a/ginac/idx.h +++ b/ginac/idx.h @@ -107,10 +107,10 @@ inline const idx &ex_to_idx(const ex &e) int canonicalize_indices(exvector & iv, bool antisymmetric=false); exvector idx_intersect(const exvector & iv1, const exvector & iv2); ex permute_free_index_to_front(const exvector & iv3, const exvector & iv2, - bool antisymmetric, int * sig); + bool antisymmetric, int * sig); unsigned subs_index_in_exvector(exvector & v, const ex & is, const ex & ir); ex subs_indices(const ex & e, const exvector & idxv_contra, - const exvector & idxv_co); + const exvector & idxv_co); unsigned count_index(const ex & e, const ex & i); #ifndef NO_NAMESPACE_GINAC diff --git a/ginac/lorentzidx.h b/ginac/lorentzidx.h index 3534a66e..f7aa397b 100644 --- a/ginac/lorentzidx.h +++ b/ginac/lorentzidx.h @@ -54,9 +54,9 @@ protected: public: explicit lorentzidx(bool cov, bool oonly=false, unsigned dimp=0); explicit lorentzidx(const std::string & n, bool cov=false, - bool oonly=false, unsigned dimp=0); + bool oonly=false, unsigned dimp=0); explicit lorentzidx(const char * n, bool cov=false, - bool oonly=false, unsigned dimp=0); + bool oonly=false, unsigned dimp=0); explicit lorentzidx(unsigned v, bool cov=false); // functions overriding virtual functions from bases classes diff --git a/ginac/lortensor.h b/ginac/lortensor.h index c259a434..8d85df81 100644 --- a/ginac/lortensor.h +++ b/ginac/lortensor.h @@ -36,7 +36,6 @@ namespace GiNaC { /** Base class for lortensor object */ class lortensor : public indexed { - // friends friend lortensor lortensor_g(const ex & mu, const ex & nu); // friend lortensor lortensor_delta(const ex & mu, const ex & nu); friend lortensor lortensor_epsilon(const ex & mu, const ex & nu, @@ -48,15 +47,15 @@ class lortensor : public indexed friend ex simplify_lortensor(const ex & e); // types - public: - typedef enum { invalid, - lortensor_g, - lortensor_rankn, - lortensor_rank1, - lortensor_rank2, - // lortensor_delta, - lortensor_epsilon + typedef enum { + invalid, + lortensor_g, + lortensor_rankn, + lortensor_rank1, + lortensor_rank2, + // lortensor_delta, + lortensor_epsilon } lortensor_types; // member functions @@ -76,8 +75,7 @@ protected: lortensor(lortensor_types const lt, const std::string & n); lortensor(lortensor_types const lt, const std::string & n, const ex & mu); lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu); - lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, - const ex & rho); + lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho); lortensor(lortensor_types const lt, const std::string & n, const ex & mu, const ex & nu, const ex & rho, const ex & sigma); lortensor(lortensor_types const lt, const std::string & n, const exvector & iv); lortensor(lortensor_types const lt, const std::string & n, unsigned s, const exvector & iv); diff --git a/ginac/matrix.h b/ginac/matrix.h index 164d1762..37dffa42 100644 --- a/ginac/matrix.h +++ b/ginac/matrix.h @@ -92,7 +92,7 @@ public: ex charpoly(const symbol & lambda) const; matrix inverse(void) const; matrix solve(const matrix & vars, const matrix & rhs, - unsigned algo = solve_algo::automatic) const; + unsigned algo = solve_algo::automatic) const; protected: ex determinant_minor(void) const; int gauss_elimination(const bool det = false); diff --git a/ginac/ncmul.h b/ginac/ncmul.h index acb4edee..0f943395 100644 --- a/ginac/ncmul.h +++ b/ginac/ncmul.h @@ -55,11 +55,11 @@ public: ncmul(const ex & lh, const ex & rh); ncmul(const ex & f1, const ex & f2, const ex & f3); ncmul(const ex & f1, const ex & f2, const ex & f3, - const ex & f4); + const ex & f4); ncmul(const ex & f1, const ex & f2, const ex & f3, - const ex & f4, const ex & f5); + const ex & f4, const ex & f5); ncmul(const ex & f1, const ex & f2, const ex & f3, - const ex & f4, const ex & f5, const ex & f6); + const ex & f4, const ex & f5, const ex & f6); ncmul(const exvector & v, bool discardable=false); ncmul(exvector * vp); // vp will be deleted diff --git a/ginac/numeric.h b/ginac/numeric.h index b579a3be..25cf91e6 100644 --- a/ginac/numeric.h +++ b/ginac/numeric.h @@ -27,8 +27,8 @@ #include "basic.h" #include "ex.h" -class cl_N; // We want to include cln.h only in numeric.cpp in order to - // avoid namespace pollution and keep compile-time low. +class cl_N; // We want to include cln.h only in numeric.cpp in order to + // avoid namespace pollution and keep compile-time low. #ifndef NO_NAMESPACE_GINAC namespace GiNaC { diff --git a/ginac/power.h b/ginac/power.h index d765d382..08c8a75a 100644 --- a/ginac/power.h +++ b/ginac/power.h @@ -94,8 +94,8 @@ protected: ex expand_add_2(const add & a) const; ex expand_mul(const mul & m, const numeric & n) const; //ex expand_commutative_3(const ex & basis, const numeric & exponent, - // unsigned options) const; - // ex expand_noncommutative(const ex & basis, const numeric & exponent, unsigned options) const; + // unsigned options) const; + //ex expand_noncommutative(const ex & basis, const numeric & exponent, unsigned options) const; // member variables diff --git a/ginac/registrar.h b/ginac/registrar.h index 8eb4d31d..ca0d4a39 100644 --- a/ginac/registrar.h +++ b/ginac/registrar.h @@ -53,11 +53,11 @@ struct registered_class_info { first_registered_class = this; } - registered_class_info *next; /**< Pointer to next registered_class_info in list. */ - const char *name; /**< Class name. */ - const char *super; /**< Name of superclass. */ - unsigned int tinfo_key; /**< TINFO_* key. */ - unarch_func unarchive; /**< Pointer to unarchiving function. */ + registered_class_info *next; /**< Pointer to next registered_class_info in list. */ + const char *name; /**< Class name. */ + const char *super; /**< Name of superclass. */ + unsigned int tinfo_key; /**< TINFO_* key. */ + unarch_func unarchive; /**< Pointer to unarchiving function. */ }; diff --git a/ginac/relational.h b/ginac/relational.h index 118e494c..c9c0eb68 100644 --- a/ginac/relational.h +++ b/ginac/relational.h @@ -38,12 +38,13 @@ class relational : public basic // types public: - enum operators { equal, - not_equal, - less, - less_or_equal, - greater, - greater_or_equal + enum operators { + equal, + not_equal, + less, + less_or_equal, + greater, + greater_or_equal }; // member functions diff --git a/ginac/remember.h b/ginac/remember.h index 0d9bb687..deee9411 100644 --- a/ginac/remember.h +++ b/ginac/remember.h @@ -35,9 +35,9 @@ class function; class ex; /** A single entry in the remember table of a function. - Needs to be a friend of class function to access 'seq'. - 'last_access' and 'successful_hits' are updated at each successful - 'is_equal'. */ + * Needs to be a friend of class function to access 'seq'. + * 'last_access' and 'successful_hits' are updated at each successful + * 'is_equal'. */ class remember_table_entry { public: remember_table_entry(function const & f, ex const & r); @@ -56,7 +56,7 @@ protected: }; /** A list of entries in the remember table having some least - significant bits of the hashvalue in common. */ + * significant bits of the hashvalue in common. */ class remember_table_list : public std::list { public: remember_table_list(unsigned as, unsigned strat); @@ -68,19 +68,19 @@ protected: }; /** The remember table is organized like an n-fold associative cache - in a microprocessor. The table has a width of 's' (which is rounded - to table_size, some power of 2 near 's', internally) and a depth of 'as' - (unless you choose that entries are never discarded). The place where - an entry is stored depends on the hashvalue of the parameters of the - function (this corresponds to the address of byte to be cached). - The 'log_2(table_size)' least significant bits of this hashvalue - give the slot in which the entry will be stored or looked up. - Each slot can take up to 'as' entries. If a slot is full, an older - entry is removed by one of the following strategies: - - oldest entry (the first one in the list) - - least recently used (the one with the lowest 'last_access') - - least frequently used (the one with the lowest 'successful_hits') - or all entries are kept which means that the table grows indefinitely. */ + * in a microprocessor. The table has a width of 's' (which is rounded + * to table_size, some power of 2 near 's', internally) and a depth of 'as' + * (unless you choose that entries are never discarded). The place where + * an entry is stored depends on the hashvalue of the parameters of the + * function (this corresponds to the address of byte to be cached). + * The 'log_2(table_size)' least significant bits of this hashvalue + * give the slot in which the entry will be stored or looked up. + * Each slot can take up to 'as' entries. If a slot is full, an older + * entry is removed by one of the following strategies: + * - oldest entry (the first one in the list) + * - least recently used (the one with the lowest 'last_access') + * - least frequently used (the one with the lowest 'successful_hits') + * or all entries are kept which means that the table grows indefinitely. */ class remember_table : public std::vector { public: remember_table(); diff --git a/ginac/simp_lor.h b/ginac/simp_lor.h index 940e110e..4f5c49f5 100644 --- a/ginac/simp_lor.h +++ b/ginac/simp_lor.h @@ -55,8 +55,8 @@ public: rh.second.printraw(cerr); cerr << ")" << endl; */ - bool res=lh.first=0); - GINAC_ASSERT(i=0); + GINAC_ASSERT(ihold(); - } - bool all_are_trivially_equal=true; + if (level==1) { + return this->hold(); + } + bool all_are_trivially_equal=true; ${eval_statements} - if (all_are_trivially_equal) { - return this->hold(); - } - return ${STRUCTURE}(${temporary_arglist}); + if (all_are_trivially_equal) { + return this->hold(); + } + return ${STRUCTURE}(${temporary_arglist}); } ex ${STRUCTURE}::evalf(int level) const { - if (level==1) { - return *this; - } - bool all_are_trivially_equal=true; + if (level==1) { + return *this; + } + bool all_are_trivially_equal=true; ${evalf_statements} - if (all_are_trivially_equal) { - return *this; - } - return ${STRUCTURE}(${temporary_arglist}); + if (all_are_trivially_equal) { + return *this; + } + return ${STRUCTURE}(${temporary_arglist}); } /** Implementation of ex::normal() for ${STRUCTURE}s. It normalizes the arguments @@ -421,61 +420,61 @@ ${evalf_statements} * \@see ex::normal */ ex ${STRUCTURE}::normal(lst &sym_lst, lst &repl_lst, int level) const { - if (level==1) { - return basic::normal(sym_lst,repl_lst,level); - } - bool all_are_trivially_equal=true; + if (level==1) { + return basic::normal(sym_lst,repl_lst,level); + } + bool all_are_trivially_equal=true; ${normal_statements} - if (all_are_trivially_equal) { - return basic::normal(sym_lst,repl_lst,level); - } - ex n=${STRUCTURE}(${temporary_arglist}); - return n.bp->basic::normal(sym_lst,repl_lst,level); + if (all_are_trivially_equal) { + return basic::normal(sym_lst,repl_lst,level); + } + ex n=${STRUCTURE}(${temporary_arglist}); + return n.bp->basic::normal(sym_lst,repl_lst,level); } /** ${STRUCTURE}::diff() differentiates the children. - there is no need to check for triavially equal, since diff usually - does not return itself unevaluated. */ + there is no need to check for triavially equal, since diff usually + does not return itself unevaluated. */ ex ${STRUCTURE}::diff(const symbol & s) const { ${diff_statements} - return ${STRUCTURE}(${temporary_arglist}); + return ${STRUCTURE}(${temporary_arglist}); } ex ${STRUCTURE}::subs(const lst & ls, const lst & lr) const { - bool all_are_trivially_equal=true; + bool all_are_trivially_equal=true; ${subs_statements} - if (all_are_trivially_equal) { - return *this; - } - return ${STRUCTURE}(${temporary_arglist}); + if (all_are_trivially_equal) { + return *this; + } + return ${STRUCTURE}(${temporary_arglist}); } // protected int ${STRUCTURE}::compare_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other,${STRUCTURE})); - ${STRUCTURE} const & o=static_cast<${STRUCTURE} const &> - (const_cast(other)); - int cmpval; + GINAC_ASSERT(is_of_type(other,${STRUCTURE})); + ${STRUCTURE} const & o=static_cast<${STRUCTURE} const &> + (const_cast(other)); + int cmpval; ${compare_statements} - return 0; + return 0; } bool ${STRUCTURE}::is_equal_same_type(const basic & other) const { - GINAC_ASSERT(is_of_type(other,${STRUCTURE})); - ${STRUCTURE} const & o=static_cast<${STRUCTURE} const &> - (const_cast(other)); + GINAC_ASSERT(is_of_type(other,${STRUCTURE})); + ${STRUCTURE} const & o=static_cast<${STRUCTURE} const &> + (const_cast(other)); ${is_equal_statements} - return true; + return true; } unsigned ${STRUCTURE}::return_type(void) const { - return return_types::noncommutative_composite; + return return_types::noncommutative_composite; } ////////// @@ -497,7 +496,7 @@ unsigned ${STRUCTURE}::return_type(void) const bool ${STRUCTURE}::types_ok(void) const { ${types_ok_statements} - return true; + return true; } ////////// diff --git a/ginac/utils.h b/ginac/utils.h index b7d47c49..3af14c7b 100644 --- a/ginac/utils.h +++ b/ginac/utils.h @@ -105,11 +105,10 @@ inline unsigned golden_ratio_hash(unsigned n) } // modified from stl_algo.h: always do com(*first1,*first2) instead of comp(*first2,*first1) -template +template OutputIterator mymerge(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, - OutputIterator result, Compare comp) { + InputIterator2 first2, InputIterator2 last2, + OutputIterator result, Compare comp) { while (first1 != last1 && first2 != last2) { if (comp(*first1, *first2)) { *result = *first1; @@ -126,11 +125,11 @@ OutputIterator mymerge(InputIterator1 first1, InputIterator1 last1, // like merge(), but three lists with *last2<*first3 template + class OutputIterator, class Compare> OutputIterator mymerge3(InputIterator1 first1, InputIterator1 last1, - InputIterator2 first2, InputIterator2 last2, - InputIterator3 first3, InputIterator3 last3, - OutputIterator result, Compare comp) { + InputIterator2 first2, InputIterator2 last2, + InputIterator3 first3, InputIterator3 last3, + OutputIterator result, Compare comp) { while (first1 != last1 && first2 != last2) { if (comp(*first1, *first2)) { *result = *first1; -- 2.44.0