-#!/usr/bin/perl -w
-
-if ($#ARGV!=0) {
- die 'usage: container.pl type (type=lst or exprseq)';
+if (($#ARGV!=0) and ($#ARGV!=1)) {
+ die 'usage: container.pl type [maxargs] (type=lst or exprseq)';
}
if ($ARGV[0] eq 'lst') {
die 'only lst and exprseq supported';
}
-#$type='lst';
-#$type='exprseq';
+if ($#ARGV==1) {
+ $maxargs=$ARGV[1];
+} else {
+ $maxargs=15; # must be greater or equal than the value used in function.pl
+}
if ($type eq 'exprseq') {
$LET_OP_IMPLEMENTATION="// ${CONTAINER}::let_op() will be implemented by user elsewhere";
}
+sub generate_seq {
+ my ($seq_template,$n,$separator)=@_;
+ my ($res,$N);
+
+ $res='';
+ for ($N=1; $N<=$n; $N++) {
+ $res .= eval('"' . $seq_template . '"');
+ if ($N!=$n) {
+ $res .= $separator;
+ }
+ }
+ return $res;
+}
+
+sub generate_from_to {
+ my ($template,$seq_template1,$seq_separator1,$seq_template2,
+ $seq_separator2,$from,$to)=@_;
+ my ($res,$N,$SEQ);
+
+ $res='';
+ for ($N=$from; $N<=$to; $N++) {
+ $SEQ1=generate_seq($seq_template1,$N,$seq_separator1);
+ $SEQ2=generate_seq($seq_template2,$N,$seq_separator2);
+ $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_separator1,$seq_template2,
+ $seq_separator2)=@_;
+ return generate_from_to($template,$seq_template1,$seq_separator1,
+ $seq_template2,$seq_separator2,1,$maxargs);
+}
+
+$constructors_interface=generate(
+' explicit ${CONTAINER}(${SEQ1});'."\n",
+'const ex & param${N}',', ','','');
+
+$constructors_implementation=generate(
+ <<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}',', ',' seq.push_back(param${N});',"\n");
+${CONTAINER}::${CONTAINER}(${SEQ1}) : basic(TINFO_${CONTAINER})
+{
+ debugmsg(\"${CONTAINER} constructor from ${N}*ex\",LOGLEVEL_CONSTRUCT);
+ RESERVE(seq,${N});
+${SEQ2}
+}
+END_OF_CONSTRUCTORS_IMPLEMENTATION
+
$interface=<<END_OF_INTERFACE;
/** \@file ${CONTAINER}.h
*
* \$let_op=${let_op}
* \$open_bracket=${open_bracket}
* \$close_bracket=${close_bracket}
+ * \$maxargs=${maxargs}
*
* GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
*
// CINT needs <algorithm> to work properly with <vector> and <list>
#include <algorithm>
-#include <ginac/basic.h>
-#include <ginac/ex.h>
+#include "basic.h"
+#include "ex.h"
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
namespace GiNaC {
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
-// typedef ${STLHEADER}<ex> ${STLT};
-typedef ${STLHEADER}<ex,malloc_alloc> ${STLT}; // CINT does not like ${STLHEADER}<...,default_alloc>
+// typedef std::${STLHEADER}<ex> ${STLT};
+typedef std::${STLHEADER}<ex,malloc_alloc> ${STLT}; // CINT does not like ${STLHEADER}<...,default_alloc>
class ${CONTAINER} : public basic
{
public:
${CONTAINER}(${STLT} const & s, bool discardable=0);
${CONTAINER}(${STLT} * vp); // vp will be deleted
- explicit ${CONTAINER}(const ex & e1);
- explicit ${CONTAINER}(const ex & e1, const ex & e2);
- explicit ${CONTAINER}(const ex & e1, const ex & e2, const ex & e3);
- explicit ${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4);
- explicit ${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5);
- explicit ${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6);
- explicit ${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6,
- const ex & e7);
- explicit ${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6,
- const ex & e7, const ex & e8);
- explicit ${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6,
- const ex & e7, const ex & e8, const ex & e9);
- explicit ${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6,
- const ex & e7, const ex & e8, const ex & e9,
- const ex &e10);
+${constructors_interface}
public:
basic * duplicate() const;
- void printraw(ostream & os) const;
- void print(ostream & os, unsigned upper_precedence=0) const;
- void printtree(ostream & os, unsigned indent) 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 eval(int level=0) const;
ex evalf(int level=0) const;
ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
- ex diff(const symbol & s) 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;
virtual ${CONTAINER} & append(const ex & b);
${PREPEND_INTERFACE}
protected:
- virtual void printseq(ostream & os, char openbracket, char delim,
+ 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;
return static_cast<const ${CONTAINER} &>(*e.bp);
}
-#ifndef NO_GINAC_NAMESPACE
+inline ${CONTAINER} &ex_to_nonconst_${CONTAINER}(const ex &e)
+{
+ return static_cast<${CONTAINER} &>(*e.bp);
+}
+
+#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
#endif // ndef __GINAC_${CONTAINER_UC}_H__
* \$let_op=${let_op}
* \$open_bracket=${open_bracket}
* \$close_bracket=${close_bracket}
+ * \$maxargs=${maxargs}
*
* GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
*
#include "archive.h"
#include "debugmsg.h"
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
namespace GiNaC {
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
GINAC_IMPLEMENT_REGISTERED_CLASS(${CONTAINER}, basic)
delete vp;
}
-${CONTAINER}::${CONTAINER}(const ex & e1) : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 1 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,1);
- seq.push_back(e1);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2) : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 2 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,2);
- seq.push_back(e1);
- seq.push_back(e2);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2, const ex & e3)
- : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 3 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,3);
- seq.push_back(e1);
- seq.push_back(e2);
- seq.push_back(e3);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4) : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 4 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,4);
- seq.push_back(e1);
- seq.push_back(e2);
- seq.push_back(e3);
- seq.push_back(e4);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5) : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 5 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,5);
- seq.push_back(e1);
- seq.push_back(e2);
- seq.push_back(e3);
- seq.push_back(e4);
- seq.push_back(e5);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6)
- : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 6 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,6);
- seq.push_back(e1);
- seq.push_back(e2);
- seq.push_back(e3);
- seq.push_back(e4);
- seq.push_back(e5);
- seq.push_back(e6);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6,
- const ex & e7) : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 7 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,7);
- seq.push_back(e1);
- seq.push_back(e2);
- seq.push_back(e3);
- seq.push_back(e4);
- seq.push_back(e5);
- seq.push_back(e6);
- seq.push_back(e7);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6,
- const ex & e7, const ex & e8) : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 8 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,8);
- seq.push_back(e1);
- seq.push_back(e2);
- seq.push_back(e3);
- seq.push_back(e4);
- seq.push_back(e5);
- seq.push_back(e6);
- seq.push_back(e7);
- seq.push_back(e8);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6,
- const ex & e7, const ex & e8, const ex & e9)
- : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 9 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,9);
- seq.push_back(e1);
- seq.push_back(e2);
- seq.push_back(e3);
- seq.push_back(e4);
- seq.push_back(e5);
- seq.push_back(e6);
- seq.push_back(e7);
- seq.push_back(e8);
- seq.push_back(e9);
-}
-
-${CONTAINER}::${CONTAINER}(const ex & e1, const ex & e2, const ex & e3,
- const ex & e4, const ex & e5, const ex & e6,
- const ex & e7, const ex & e8, const ex & e9,
- const ex &e10)
- : basic(TINFO_${CONTAINER})
-{
- debugmsg("${CONTAINER} constructor from 10 ex",
- LOGLEVEL_CONSTRUCT);
- RESERVE(seq,10);
- seq.push_back(e1);
- seq.push_back(e2);
- seq.push_back(e3);
- seq.push_back(e4);
- seq.push_back(e5);
- seq.push_back(e6);
- seq.push_back(e7);
- seq.push_back(e8);
- seq.push_back(e9);
- seq.push_back(e10);
-}
+${constructors_implementation}
//////////
// archiving
return new ${CONTAINER}(*this);
}
-void ${CONTAINER}::printraw(ostream & os) const
+void ${CONTAINER}::printraw(std::ostream & os) const
{
debugmsg("${CONTAINER} printraw",LOGLEVEL_PRINT);
os << ")";
}
-void ${CONTAINER}::print(ostream & os, unsigned upper_precedence) const
+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);
}
-void ${CONTAINER}::printtree(ostream & os, unsigned indent) const
+void ${CONTAINER}::printtree(std::ostream & os, unsigned indent) const
{
debugmsg("${CONTAINER} printtree",LOGLEVEL_PRINT);
- os << string(indent,' ') << "type=" << typeid(*this).name()
- << ", hash=" << hashvalue << " (0x" << hex << hashvalue << dec << ")"
+ os << std::string(indent,' ') << "type=" << typeid(*this).name()
+ << ", hash=" << hashvalue
+ << " (0x" << std::hex << hashvalue << std::dec << ")"
<< ", flags=" << flags
- << ", nops=" << nops() << endl;
+ << ", nops=" << nops() << std::endl;
for (${STLT}::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
(*cit).printtree(os,indent+delta_indent);
}
- os << string(indent+delta_indent,' ') << "=====" << endl;
+ os << std::string(indent+delta_indent,' ') << "=====" << std::endl;
}
// ${CONTAINER}::info() will be implemented by user elsewhere";
return n.bp->basic::normal(sym_lst,repl_lst,level);
}
-ex ${CONTAINER}::diff(const symbol & s) const
+ex ${CONTAINER}::derivative(const symbol & s) const
{
return this${CONTAINER}(diffchildren(s));
}
// protected
-void ${CONTAINER}::printseq(ostream & os, char openbracket, char delim,
+void ${CONTAINER}::printseq(std::ostream & os, char openbracket, char delim,
char closebracket, unsigned this_precedence,
unsigned upper_precedence) const
{
for (++it; it!=seq.end(); it_last=it, ++it) {
if ((*it_last).compare(*it)>0) {
if ((*it_last).compare(*it)>0) {
- cout << *it_last << ">" << *it << "\\n";
+ std::cout << *it_last << ">" << *it << "\\n";
return 0;
}
}
const ${CONTAINER} some_${CONTAINER};
const type_info & typeid_${CONTAINER}=typeid(some_${CONTAINER});
-#ifndef NO_GINAC_NAMESPACE
+#ifndef NO_NAMESPACE_GINAC
} // namespace GiNaC
-#endif // ndef NO_GINAC_NAMESPACE
+#endif // ndef NO_NAMESPACE_GINAC
END_OF_IMPLEMENTATION