]> www.ginac.de Git - ginac.git/blob - ginac/container.pl
* Supplement some (now deprecated) macros by inlined template functions:
[ginac.git] / ginac / container.pl
1 if (($#ARGV!=0) and ($#ARGV!=1)) {
2         die 'usage: container.pl type [maxargs] (type=lst or exprseq)';
3 }
4
5 if ($ARGV[0] eq 'lst') {
6         $type='lst';
7 } elsif ($ARGV[0] eq 'exprseq') {
8         $type='exprseq';
9 } else {
10         die 'only lst and exprseq supported';
11 }
12
13 if ($#ARGV==1) {
14         $maxargs=$ARGV[1];
15 } else {
16         $maxargs=16; # must be greater or equal than the value used in function.pl
17 }
18
19 if ($type eq 'exprseq') {
20
21         # settings for exprseq
22         $CONTAINER="exprseq";
23         $STLHEADER="vector";
24         $reserve=1;
25         $prepend=0;
26         $let_op=0;
27         $open_bracket='(';
28         $close_bracket=')';
29         
30 } elsif ($type eq 'lst') {
31  
32         # settings for lst
33         $CONTAINER="lst";
34         $STLHEADER="list";
35         $reserve=0;
36         $prepend=1;
37         $let_op=1;
38         $open_bracket='{';
39         $close_bracket='}';
40
41 } else {
42         die "invalid type $type";
43 }
44
45 $CONTAINER_UC=uc(${CONTAINER});
46 $STLT="ex".$STLHEADER;
47
48 if ($reserve) {
49         $RESERVE_IMPLEMENTATION="#define RESERVE(s,size) (s).reserve(size)";
50 } else {
51         $RESERVE_IMPLEMENTATION="#define RESERVE(s,size) // no reserve needed for ${STLHEADER}";
52 }
53
54 if ($prepend) {
55         $PREPEND_INTERFACE=<<END_OF_PREPEND_INTERFACE;
56         virtual ${CONTAINER} & prepend(const ex & b);
57         virtual ${CONTAINER} & remove_first(void);
58 END_OF_PREPEND_INTERFACE
59
60         $PREPEND_IMPLEMENTATION=<<END_OF_PREPEND_IMPLEMENTATION;
61 ${CONTAINER} & ${CONTAINER}::prepend(const ex & b)
62 {
63         ensure_if_modifiable();
64         seq.push_front(b);
65         return *this;
66 }
67 ${CONTAINER} & ${CONTAINER}::remove_first(void)
68 {
69         ensure_if_modifiable();
70         seq.pop_front();
71         return *this;
72 }
73 END_OF_PREPEND_IMPLEMENTATION
74 } else {
75         $PREPEND_INTERFACE="    // no prepend possible for ${CONTAINER}";
76         $PREPEND_IMPLEMENTATION="";
77 }
78
79 if ($let_op) {
80         $LET_OP_IMPLEMENTATION=<<END_OF_LET_OP_IMPLEMENTATION
81 ex & ${CONTAINER}::let_op(int i)
82 {
83         GINAC_ASSERT(i>=0);
84         GINAC_ASSERT(i<nops());
85
86         ${STLT}::iterator it=seq.begin();
87         for (int j=0; j<i; j++) {
88                 ++it;
89         }
90         return *it;
91 }
92 END_OF_LET_OP_IMPLEMENTATION
93 } else {
94         $LET_OP_IMPLEMENTATION="// ${CONTAINER}::let_op() will be implemented by user elsewhere";
95 }
96
97 sub generate_seq {
98         my ($seq_template,$n,$separator)=@_;
99         my ($res,$N);
100         
101         $res='';
102         for ($N=1; $N<=$n; $N++) {
103                 $res .= eval('"' . $seq_template . '"');
104                 if ($N!=$n) {
105                         $res .= $separator;
106                 }
107         }
108         return $res;
109 }
110
111 sub generate_from_to {
112         my ($template,$seq_template1,$seq_separator1,$seq_template2,
113             $seq_separator2,$from,$to)=@_;
114         my ($res,$N,$SEQ);
115
116         $res='';
117         for ($N=$from; $N<=$to; $N++) {
118                 $SEQ1=generate_seq($seq_template1,$N,$seq_separator1);
119                 $SEQ2=generate_seq($seq_template2,$N,$seq_separator2);
120                 $res .= eval('"' . $template . '"');
121                 $SEQ1=''; # to avoid main::SEQ1 used only once warning
122                 $SEQ2=''; # same as above
123         }
124         return $res;
125 }
126
127 sub generate {
128         my ($template,$seq_template1,$seq_separator1,$seq_template2,
129             $seq_separator2)=@_;
130         return generate_from_to($template,$seq_template1,$seq_separator1,
131                                                         $seq_template2,$seq_separator2,1,$maxargs);
132 }
133
134 $constructors_interface=generate(
135 '       explicit ${CONTAINER}(${SEQ1});'."\n",
136 'const ex & param${N}',', ','','');
137
138 $constructors_implementation=generate(
139         <<'END_OF_CONSTRUCTORS_IMPLEMENTATION','const ex & param${N}',', ','    seq.push_back(param${N});',"\n");
140 ${CONTAINER}::${CONTAINER}(${SEQ1}) : basic(TINFO_${CONTAINER})
141 {
142         debugmsg(\"${CONTAINER} ctor from ${N}*ex\",LOGLEVEL_CONSTRUCT);
143         RESERVE(seq,${N});
144 ${SEQ2}
145 }
146 END_OF_CONSTRUCTORS_IMPLEMENTATION
147
148 $interface=<<END_OF_INTERFACE;
149 /** \@file ${CONTAINER}.h
150  *
151  *  Definition of GiNaC's ${CONTAINER}. */
152
153 /*
154  *  This file was generated automatically by container.pl.
155  *  Please do not modify it directly, edit the perl script instead!
156  *  container.pl options: \$CONTAINER=${CONTAINER}
157  *                        \$STLHEADER=${STLHEADER}
158  *                        \$reserve=${reserve}
159  *                        \$prepend=${prepend}
160  *                        \$let_op=${let_op}
161  *                        \$open_bracket=${open_bracket}
162  *                        \$close_bracket=${close_bracket}
163  *                        \$maxargs=${maxargs}
164  *
165  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
166  *
167  *  This program is free software; you can redistribute it and/or modify
168  *  it under the terms of the GNU General Public License as published by
169  *  the Free Software Foundation; either version 2 of the License, or
170  *  (at your option) any later version.
171  *
172  *  This program is distributed in the hope that it will be useful,
173  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
174  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
175  *  GNU General Public License for more details.
176  *
177  *  You should have received a copy of the GNU General Public License
178  *  along with this program; if not, write to the Free Software
179  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
180  */
181
182 #ifndef __GINAC_${CONTAINER_UC}_H__
183 #define __GINAC_${CONTAINER_UC}_H__
184
185 #include <${STLHEADER}>
186
187 // CINT needs <algorithm> to work properly with <vector> and <list> 
188 #include <algorithm>
189
190 #include "basic.h"
191 #include "ex.h"
192
193 namespace GiNaC {
194
195
196 typedef std::${STLHEADER}<ex> ${STLT};
197
198 class ${CONTAINER} : public basic
199 {
200         GINAC_DECLARE_REGISTERED_CLASS(${CONTAINER}, basic)
201
202 public:
203         ${CONTAINER}(${STLT} const & s, bool discardable=0);
204         ${CONTAINER}(${STLT} * vp); // vp will be deleted
205 ${constructors_interface}
206
207 public:
208         void print(const print_context & c, unsigned level = 0) const;
209         unsigned precedence(void) const {return 10;}
210         bool info(unsigned inf) const;
211         unsigned nops() const;
212         ex & let_op(int i);
213         ex map(map_function & f) const;
214         ex expand(unsigned options=0) const;
215         ex eval(int level=0) const;
216         ex evalf(int level=0) const;
217         ex normal(lst &sym_lst, lst &repl_lst, int level=0) const;
218         ex derivative(const symbol & s) const;
219         ex subs(const lst & ls, const lst & lr, bool no_pattern = false) const;
220 protected:
221         bool is_equal_same_type(const basic & other) const;
222         unsigned return_type(void) const;
223
224         // new virtual functions which can be overridden by derived classes
225 public:
226         virtual ${CONTAINER} & append(const ex & b);
227         virtual ${CONTAINER} & remove_last(void);
228 ${PREPEND_INTERFACE}
229 protected:
230         virtual void printseq(const print_context & c, char openbracket, char delim,
231                               char closebracket, unsigned this_precedence,
232                               unsigned upper_precedence = 0) const;
233         virtual ex this${CONTAINER}(${STLT} const & v) const;
234         virtual ex this${CONTAINER}(${STLT} * vp) const;
235
236 protected:
237         bool is_canonical() const;
238         ${STLT} evalchildren(int level) const;
239         ${STLT} evalfchildren(int level) const;
240         ${STLT} normalchildren(int level) const;
241         ${STLT} diffchildren(const symbol & s) const;
242         ${STLT} * subschildren(const lst & ls, const lst & lr, bool no_pattern = false) const;
243
244 protected:
245         ${STLT} seq;
246 };
247
248 // utility functions
249
250 /** Return the ${CONTAINER} object handled by an ex.
251  *  This is unsafe: you need to check the type first. */
252 inline const ${CONTAINER} &ex_to_${CONTAINER}(const ex &e)
253 {
254         return static_cast<const ${CONTAINER} &>(*e.bp);
255 }
256
257 /** Specialization of is_exactly_a<${CONTAINER}>(obj) for ${CONTAINER} objects. */
258 template<> inline bool is_exactly_a<${CONTAINER}>(const basic & obj)
259 {
260         return obj.tinfo()==TINFO_${CONTAINER};
261 }
262
263 inline ${CONTAINER} &ex_to_nonconst_${CONTAINER}(const ex &e)
264 {
265         return static_cast<${CONTAINER} &>(*e.bp);
266 }
267
268 } // namespace GiNaC
269
270 #endif // ndef __GINAC_${CONTAINER_UC}_H__
271
272 END_OF_INTERFACE
273
274 $implementation=<<END_OF_IMPLEMENTATION;
275 /** \@file ${CONTAINER}.cpp
276  *
277  *  Implementation of GiNaC's ${CONTAINER}. */
278
279 /*
280  *  This file was generated automatically by container.pl.
281  *  Please do not modify it directly, edit the perl script instead!
282  *  container.pl options: \$CONTAINER=${CONTAINER}
283  *                        \$STLHEADER=${STLHEADER}
284  *                        \$reserve=${reserve}
285  *                        \$prepend=${prepend}
286  *                        \$let_op=${let_op}
287  *                        \$open_bracket=${open_bracket}
288  *                        \$close_bracket=${close_bracket}
289  *                        \$maxargs=${maxargs}
290  *
291  *  GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
292  *
293  *  This program is free software; you can redistribute it and/or modify
294  *  it under the terms of the GNU General Public License as published by
295  *  the Free Software Foundation; either version 2 of the License, or
296  *  (at your option) any later version.
297  *
298  *  This program is distributed in the hope that it will be useful,
299  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
300  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
301  *  GNU General Public License for more details.
302  *
303  *  You should have received a copy of the GNU General Public License
304  *  along with this program; if not, write to the Free Software
305  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
306  */
307
308 #include <iostream>
309 #include <stdexcept>
310
311 #include "${CONTAINER}.h"
312 #include "ex.h"
313 #include "print.h"
314 #include "archive.h"
315 #include "debugmsg.h"
316
317 namespace GiNaC {
318
319 GINAC_IMPLEMENT_REGISTERED_CLASS(${CONTAINER}, basic)
320
321 ${RESERVE_IMPLEMENTATION}
322
323 //////////
324 // default ctor, dtor, copy ctor assignment operator and helpers
325 //////////
326
327 // public
328
329 ${CONTAINER}::${CONTAINER}() : basic(TINFO_${CONTAINER})
330 {
331         debugmsg("${CONTAINER} default ctor",LOGLEVEL_CONSTRUCT);
332 }
333
334 // protected
335
336 void ${CONTAINER}::copy(${CONTAINER} const & other)
337 {
338         inherited::copy(other);
339         seq=other.seq;
340 }
341
342 void ${CONTAINER}::destroy(bool call_parent)
343 {
344         seq.clear();
345         if (call_parent) inherited::destroy(call_parent);
346 }
347
348 //////////
349 // other ctors
350 //////////
351
352 // public
353
354 ${CONTAINER}::${CONTAINER}(${STLT} const & s, bool discardable) :  basic(TINFO_${CONTAINER})
355 {
356         debugmsg("${CONTAINER} ctor from ${STLT}", LOGLEVEL_CONSTRUCT);
357         if (discardable) {
358                 seq.swap(const_cast<${STLT} &>(s));
359         } else {
360                 seq=s;
361         }
362 }
363
364 ${CONTAINER}::${CONTAINER}(${STLT} * vp) : basic(TINFO_${CONTAINER})
365 {
366         debugmsg("${CONTAINER} ctor from ${STLT} *",LOGLEVEL_CONSTRUCT);
367         GINAC_ASSERT(vp!=0);
368         seq.swap(*vp);
369         delete vp;
370 }
371
372 ${constructors_implementation}
373
374 //////////
375 // archiving
376 //////////
377
378 /** Construct object from archive_node. */
379 ${CONTAINER}::${CONTAINER}(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
380 {
381         debugmsg("${CONTAINER} ctor from archive_node", LOGLEVEL_CONSTRUCT);
382         for (unsigned int i=0; true; i++) {
383                 ex e;
384                 if (n.find_ex("seq", e, sym_lst, i))
385                         seq.push_back(e);
386                 else
387                         break;
388         }
389 }
390
391 /** Unarchive the object. */
392 ex ${CONTAINER}::unarchive(const archive_node &n, const lst &sym_lst)
393 {
394         return (new ${CONTAINER}(n, sym_lst))->setflag(status_flags::dynallocated);
395 }
396
397 /** Archive the object. */
398 void ${CONTAINER}::archive(archive_node &n) const
399 {
400         inherited::archive(n);
401         ${STLT}::const_iterator i = seq.begin(), iend = seq.end();
402         while (i != iend) {
403                 n.add_ex("seq", *i);
404                 i++;
405         }
406 }
407
408 //////////
409 // functions overriding virtual functions from bases classes
410 //////////
411
412 // public
413
414 void ${CONTAINER}::print(const print_context & c, unsigned level) const
415 {
416         debugmsg("${CONTAINER} print", LOGLEVEL_PRINT);
417
418         if (is_a<print_tree>(c)) {
419
420                 c.s << std::string(level, ' ') << class_name()
421                     << std::hex << ", hash=0x" << hashvalue << ", flags=0x" << flags << std::dec
422                     << ", nops=" << nops()
423                     << std::endl;
424                 unsigned delta_indent = static_cast<const print_tree &>(c).delta_indent;
425                 for (${STLT}::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit)
426                         cit->print(c, level + delta_indent);
427                 c.s << std::string(level + delta_indent,' ') << "=====" << std::endl;
428
429         } else {
430                 // always print brackets around seq, ignore upper_precedence
431                 printseq(c, '${open_bracket}', ',', '${close_bracket}', precedence(), precedence()+1);
432         }
433 }
434
435 // ${CONTAINER}::info() will be implemented by user elsewhere";
436
437 unsigned ${CONTAINER}::nops() const
438 {
439         return seq.size();
440 }
441
442 ${LET_OP_IMPLEMENTATION}
443
444 ex ${CONTAINER}::map(map_function & f) const
445 {
446         ${STLT} s;
447         RESERVE(s,seq.size());
448         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
449                 s.push_back(f(*it));
450         }
451
452         return this${CONTAINER}(s);
453 }
454
455 ex ${CONTAINER}::expand(unsigned options) const
456 {
457         ${STLT} s;
458         RESERVE(s,seq.size());
459         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
460                 s.push_back((*it).expand(options));
461         }
462
463         return this${CONTAINER}(s);
464 }
465
466 ex ${CONTAINER}::eval(int level) const
467 {
468         if (level==1) {
469                 return this->hold();
470         }
471         return this${CONTAINER}(evalchildren(level));
472 }
473
474 ex ${CONTAINER}::evalf(int level) const
475 {
476         return this${CONTAINER}(evalfchildren(level));
477 }
478
479 /** Implementation of ex::normal() for ${CONTAINER}s. It normalizes the arguments
480  *  and replaces the ${CONTAINER} by a temporary symbol.
481  *  \@see ex::normal */
482 ex ${CONTAINER}::normal(lst &sym_lst, lst &repl_lst, int level) const
483 {
484         ex n=this${CONTAINER}(normalchildren(level));
485         return n.bp->basic::normal(sym_lst,repl_lst,level);
486 }
487
488 ex ${CONTAINER}::derivative(const symbol & s) const
489 {
490         return this${CONTAINER}(diffchildren(s));
491 }
492
493 ex ${CONTAINER}::subs(const lst & ls, const lst & lr, bool no_pattern) const
494 {
495         ${STLT} *vp = subschildren(ls, lr, no_pattern);
496         if (vp)
497                 return this${CONTAINER}(vp).bp->basic::subs(ls, lr, no_pattern);
498         else
499                 return basic::subs(ls, lr, no_pattern);
500 }
501
502 // protected
503
504 int ${CONTAINER}::compare_same_type(const basic & other) const
505 {
506         GINAC_ASSERT(is_a<${CONTAINER}>(other));
507         ${CONTAINER} const & o=static_cast<${CONTAINER} const &>
508                                                                         (const_cast<basic &>(other));
509         int cmpval;
510         ${STLT}::const_iterator it1=seq.begin();
511         ${STLT}::const_iterator it2=o.seq.begin();
512
513         for (; (it1!=seq.end())&&(it2!=o.seq.end()); ++it1, ++it2) {
514                 cmpval=(*it1).compare(*it2);
515                 if (cmpval!=0) return cmpval;
516         }
517
518         if (it1==seq.end()) {
519                 return (it2==o.seq.end() ? 0 : -1);
520         }
521
522         return 1;
523 }
524
525 bool ${CONTAINER}::is_equal_same_type(const basic & other) const
526 {
527         GINAC_ASSERT(is_a<${CONTAINER}>(other));
528         ${CONTAINER} const & o = static_cast<${CONTAINER} const &>(const_cast<basic &>(other));
529         if (seq.size()!=o.seq.size()) return false;
530
531         ${STLT}::const_iterator it1 = seq.begin();
532         ${STLT}::const_iterator it2 = o.seq.begin();
533
534         for (; it1!=seq.end(); ++it1, ++it2) {
535                 if (!(*it1).is_equal(*it2)) return false;
536         }
537
538         return true;
539 }
540
541 unsigned ${CONTAINER}::return_type(void) const
542 {
543         return return_types::noncommutative_composite;
544 }
545
546 //////////
547 // new virtual functions which can be overridden by derived classes
548 //////////
549
550 // public
551
552 ${CONTAINER} & ${CONTAINER}::append(const ex & b)
553 {
554         ensure_if_modifiable();
555         seq.push_back(b);
556         return *this;
557 }
558
559 ${CONTAINER} & ${CONTAINER}::remove_last(void)
560 {
561         ensure_if_modifiable();
562         seq.pop_back();
563         return *this;
564 }
565
566 ${PREPEND_IMPLEMENTATION}
567
568 // protected
569
570 void ${CONTAINER}::printseq(const print_context & c, char openbracket, char delim,
571                             char closebracket, unsigned this_precedence,
572                             unsigned upper_precedence) const
573 {
574         if (this_precedence <= upper_precedence)
575                 c.s << openbracket;
576
577         if (seq.size() != 0) {
578                 ${STLT}::const_iterator it = seq.begin(), itend = seq.end();
579                 --itend;
580                 while (it != itend) {
581                         it->print(c, this_precedence);
582                         c.s << delim;
583                         it++;
584                 }
585                 it->print(c, this_precedence);
586         }
587
588         if (this_precedence <= upper_precedence)
589                 c.s << closebracket;
590 }
591
592 ex ${CONTAINER}::this${CONTAINER}(${STLT} const & v) const
593 {
594         return ${CONTAINER}(v);
595 }
596
597 ex ${CONTAINER}::this${CONTAINER}(${STLT} * vp) const
598 {
599         return ${CONTAINER}(vp);
600 }
601
602 //////////
603 // non-virtual functions in this class
604 //////////
605
606 // public
607
608 // none
609
610 // protected
611
612 bool ${CONTAINER}::is_canonical() const
613 {
614         if (seq.size()<=1) { return 1; }
615
616         ${STLT}::const_iterator it=seq.begin();
617         ${STLT}::const_iterator it_last=it;
618         for (++it; it!=seq.end(); it_last=it, ++it) {
619                 if ((*it_last).compare(*it)>0) {
620                         if ((*it_last).compare(*it)>0) {
621                                 std::cout << *it_last << ">" << *it << "\\n";
622                                 return 0;
623                         }
624                 }
625         }
626         return 1;
627 }
628
629
630 ${STLT} ${CONTAINER}::evalchildren(int level) const
631 {
632         ${STLT} s;
633         RESERVE(s,seq.size());
634
635         if (level==1) {
636                 return seq;
637         }
638         if (level == -max_recursion_level) {
639                 throw(std::runtime_error("max recursion level reached"));
640         }
641         --level;
642         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
643                 s.push_back((*it).eval(level));
644         }
645         return s;
646 }
647
648 ${STLT} ${CONTAINER}::evalfchildren(int level) const
649 {
650         ${STLT} s;
651         RESERVE(s,seq.size());
652
653         if (level==1) {
654                 return seq;
655         }
656         if (level == -max_recursion_level) {
657                 throw(std::runtime_error("max recursion level reached"));
658         }
659         --level;
660         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
661                 s.push_back((*it).evalf(level));
662         }
663         return s;
664 }
665
666 ${STLT} ${CONTAINER}::normalchildren(int level) const
667 {
668         ${STLT} s;
669         RESERVE(s,seq.size());
670
671         if (level==1) {
672                 return seq;
673         }
674         if (level == -max_recursion_level) {
675                 throw(std::runtime_error("max recursion level reached"));
676         }
677         --level;
678         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
679                 s.push_back((*it).normal(level));
680         }
681         return s;
682 }
683
684 ${STLT} ${CONTAINER}::diffchildren(const symbol & y) const
685 {
686         ${STLT} s;
687         RESERVE(s,seq.size());
688         for (${STLT}::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
689                 s.push_back((*it).diff(y));
690         }
691         return s;
692 }
693
694 ${STLT} * ${CONTAINER}::subschildren(const lst & ls, const lst & lr, bool no_pattern) const
695 {
696         // returns a NULL pointer if nothing had to be substituted
697         // returns a pointer to a newly created epvector otherwise
698         // (which has to be deleted somewhere else)
699
700         ${STLT}::const_iterator last=seq.end();
701         ${STLT}::const_iterator cit=seq.begin();
702         while (cit!=last) {
703                 const ex & subsed_ex=(*cit).subs(ls,lr,no_pattern);
704                 if (!are_ex_trivially_equal(*cit,subsed_ex)) {
705
706                         // something changed, copy seq, subs and return it
707                         ${STLT} *s=new ${STLT};
708                         RESERVE(*s,seq.size());
709
710                         // copy parts of seq which are known not to have changed
711                         ${STLT}::const_iterator cit2=seq.begin();
712                         while (cit2!=cit) {
713                                 s->push_back(*cit2);
714                                 ++cit2;
715                         }
716                         // copy first changed element
717                         s->push_back(subsed_ex);
718                         ++cit2;
719                         // copy rest
720                         while (cit2!=last) {
721                                 s->push_back((*cit2).subs(ls,lr,no_pattern));
722                                 ++cit2;
723                         }
724                         return s;
725                 }
726                 ++cit;
727         }
728         
729         return 0; // nothing has changed
730 }
731
732 } // namespace GiNaC
733
734 END_OF_IMPLEMENTATION
735
736 print "Creating interface file ${CONTAINER}.h...";
737 open OUT,">${CONTAINER}.h" or die "cannot open ${CONTAINER}.h";
738 print OUT $interface;
739 close OUT;
740 print "ok.\n";
741
742 print "Creating implementation file ${CONTAINER}.cpp...";
743 open OUT,">${CONTAINER}.cpp" or die "cannot open ${CONTAINER}.cpp";
744 print OUT $implementation;
745 close OUT;
746 print "ok.\n";
747
748 print "done.\n";