#ifndef around namespace GiNaC { }
[ginac.git] / ginac / add.cpp
1 /** @file add.cpp
2  *
3  *  Implementation of GiNaC's sums of expressions. */
4
5 /*
6  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include <iostream>
24 #include <stdexcept>
25
26 #include "add.h"
27 #include "mul.h"
28 #include "debugmsg.h"
29
30 #ifndef NO_GINAC_NAMESPACE
31 namespace GiNaC {
32 #endif // ndef NO_GINAC_NAMESPACE
33
34 //////////
35 // default constructor, destructor, copy constructor assignment operator and helpers
36 //////////
37
38 // public
39
40 add::add()
41 {
42     debugmsg("add default constructor",LOGLEVEL_CONSTRUCT);
43     tinfo_key = TINFO_add;
44 }
45
46 add::~add()
47 {
48     debugmsg("add destructor",LOGLEVEL_DESTRUCT);
49     destroy(0);
50 }
51
52 add::add(add const & other)
53 {
54     debugmsg("add copy constructor",LOGLEVEL_CONSTRUCT);
55     copy(other);
56 }
57
58 add const & add::operator=(add const & other)
59 {
60     debugmsg("add operator=",LOGLEVEL_ASSIGNMENT);
61     if (this != &other) {
62         destroy(1);
63         copy(other);
64     }
65     return *this;
66 }
67
68 // protected
69
70 void add::copy(add const & other)
71 {
72     expairseq::copy(other);
73 }
74
75 void add::destroy(bool call_parent)
76 {
77     if (call_parent) expairseq::destroy(call_parent);
78 }
79
80 //////////
81 // other constructors
82 //////////
83
84 // public
85
86 add::add(ex const & lh, ex const & rh)
87 {
88     debugmsg("add constructor from ex,ex",LOGLEVEL_CONSTRUCT);
89     tinfo_key = TINFO_add;
90     overall_coeff=exZERO();
91     construct_from_2_ex(lh,rh);
92     GINAC_ASSERT(is_canonical());
93 }
94
95 add::add(exvector const & v)
96 {
97     debugmsg("add constructor from exvector",LOGLEVEL_CONSTRUCT);
98     tinfo_key = TINFO_add;
99     overall_coeff=exZERO();
100     construct_from_exvector(v);
101     GINAC_ASSERT(is_canonical());
102 }
103
104 /*
105 add::add(epvector const & v, bool do_not_canonicalize)
106 {
107     debugmsg("add constructor from epvector,bool",LOGLEVEL_CONSTRUCT);
108     tinfo_key = TINFO_add;
109     if (do_not_canonicalize) {
110         seq=v;
111 #ifdef EXPAIRSEQ_USE_HASHTAB
112         combine_same_terms(); // to build hashtab
113 #endif // def EXPAIRSEQ_USE_HASHTAB
114     } else {
115         construct_from_epvector(v);
116     }
117     GINAC_ASSERT(is_canonical());
118 }
119 */
120
121 add::add(epvector const & v)
122 {
123     debugmsg("add constructor from epvector",LOGLEVEL_CONSTRUCT);
124     tinfo_key = TINFO_add;
125     overall_coeff=exZERO();
126     construct_from_epvector(v);
127     GINAC_ASSERT(is_canonical());
128 }
129
130 add::add(epvector const & v, ex const & oc)
131 {
132     debugmsg("add constructor from epvector,ex",LOGLEVEL_CONSTRUCT);
133     tinfo_key = TINFO_add;
134     overall_coeff=oc;
135     construct_from_epvector(v);
136     GINAC_ASSERT(is_canonical());
137 }
138
139 add::add(epvector * vp, ex const & oc)
140 {
141     debugmsg("add constructor from epvector *,ex",LOGLEVEL_CONSTRUCT);
142     tinfo_key = TINFO_add;
143     GINAC_ASSERT(vp!=0);
144     overall_coeff=oc;
145     construct_from_epvector(*vp);
146     delete vp;
147     GINAC_ASSERT(is_canonical());
148 }
149
150 //////////
151 // functions overriding virtual functions from bases classes
152 //////////
153
154 // public
155
156 basic * add::duplicate() const
157 {
158     debugmsg("add duplicate",LOGLEVEL_DUPLICATE);
159     return new add(*this);
160 }
161
162 bool add::info(unsigned inf) const
163 {
164     // TODO: optimize
165     if (inf==info_flags::polynomial || inf==info_flags::integer_polynomial || inf==info_flags::rational_polynomial || inf==info_flags::rational_function) {
166         for (epvector::const_iterator it=seq.begin(); it!=seq.end(); ++it) {
167             if (!(recombine_pair_to_ex(*it).info(inf)))
168                 return false;
169         }
170         return true;
171     } else {
172         return expairseq::info(inf);
173     }
174 }
175
176 int add::degree(symbol const & s) const
177 {
178     int deg=INT_MIN;
179     if (!overall_coeff.is_equal(exZERO())) {
180         deg=0;
181     }
182     int cur_deg;
183     for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
184         cur_deg=(*cit).rest.degree(s);
185         if (cur_deg>deg) deg=cur_deg;
186     }
187     return deg;
188 }
189
190 int add::ldegree(symbol const & s) const
191 {
192     int deg=INT_MAX;
193     if (!overall_coeff.is_equal(exZERO())) {
194         deg=0;
195     }
196     int cur_deg;
197     for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
198         cur_deg=(*cit).rest.ldegree(s);
199         if (cur_deg<deg) deg=cur_deg;
200     }
201     return deg;
202 }
203
204 ex add::coeff(symbol const & s, int const n) const
205 {
206     epvector coeffseq;
207     coeffseq.reserve(seq.size());
208
209     epvector::const_iterator it=seq.begin();
210     while (it!=seq.end()) {
211         coeffseq.push_back(combine_ex_with_coeff_to_pair((*it).rest.coeff(s,n),
212                                                          (*it).coeff));
213         ++it;
214     }
215     if (n==0) {
216         return (new add(coeffseq,overall_coeff))->setflag(status_flags::dynallocated);
217     }
218     return (new add(coeffseq))->setflag(status_flags::dynallocated);
219 }
220
221 /*
222 ex add::eval(int level) const
223 {
224     // simplifications: +(...,x,c1,c2) -> +(...,x,c1+c2) (c1, c2 numeric())
225     //                  +(...,(c1,c2)) -> (...,(c1*c2,1)) (normalize)
226     //                  +(...,x,0) -> +(...,x)
227     //                  +(x) -> x
228     //                  +() -> 0
229
230     debugmsg("add eval",LOGLEVEL_MEMBER_FUNCTION);
231
232     epvector newseq=seq;
233     epvector::iterator it1,it2;
234     
235     // +(...,x,c1,c2) -> +(...,x,c1+c2) (c1, c2 numeric())
236     it2=newseq.end()-1;
237     it1=it2-1;
238     while ((newseq.size()>=2)&&is_exactly_of_type(*(*it1).rest.bp,numeric)&&
239                                is_exactly_of_type(*(*it2).rest.bp,numeric)) {
240         *it1=expair(ex_to_numeric((*it1).rest).mul(ex_to_numeric((*it1).coeff))
241                     .add(ex_to_numeric((*it2).rest).mul(ex_to_numeric((*it2).coeff))),exONE());
242         newseq.pop_back();
243         it2=newseq.end()-1;
244         it1=it2-1;
245     }
246
247     if ((newseq.size()>=1)&&is_exactly_of_type(*(*it2).rest.bp,numeric)) {
248         // +(...,(c1,c2)) -> (...,(c1*c2,1)) (normalize)
249         *it2=expair(ex_to_numeric((*it2).rest).mul(ex_to_numeric((*it2).coeff)),exONE());
250         // +(...,x,0) -> +(...,x)
251         if (ex_to_numeric((*it2).rest).compare(0)==0) {
252             newseq.pop_back();
253         }
254     }
255
256     if (newseq.size()==0) {
257         // +() -> 0
258         return exZERO();
259     } else if (newseq.size()==1) {
260         // +(x) -> x
261         return recombine_pair_to_ex(*(newseq.begin()));
262     }
263
264     return (new add(newseq,1))->setflag(status_flags::dynallocated  |
265                                         status_flags::evaluated );
266 }
267 */
268
269 /*
270 ex add::eval(int level) const
271 {
272     // simplifications: +(...,x,c1,c2) -> +(...,x,c1+c2) (c1, c2 numeric())
273     //                  +(...,(c1,c2)) -> (...,(c1*c2,1)) (normalize)
274     //                  +(...,x,0) -> +(...,x)
275     //                  +(x) -> x
276     //                  +() -> 0
277
278     debugmsg("add eval",LOGLEVEL_MEMBER_FUNCTION);
279
280     if ((level==1)&&(flags & status_flags::evaluated)) {
281 #ifdef DO_GINAC_ASSERT
282         for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
283             GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
284             GINAC_ASSERT(!(is_ex_exactly_of_type((*cit).rest,numeric)&&
285                      (ex_to_numeric((*cit).coeff).compare(numONE())!=0)));
286         }
287 #endif // def DO_GINAC_ASSERT
288         return *this;
289     }
290
291     epvector newseq;
292     epvector::iterator it1,it2;
293     bool seq_copied=false;
294
295     epvector * evaled_seqp=evalchildren(level);
296     if (evaled_seqp!=0) {
297         // do more evaluation later
298         return (new add(evaled_seqp))->setflag(status_flags::dynallocated);
299     }
300
301 #ifdef DO_GINAC_ASSERT
302     for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
303         GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
304         GINAC_ASSERT(!(is_ex_exactly_of_type((*cit).rest,numeric)&&
305                  (ex_to_numeric((*cit).coeff).compare(numONE())!=0)));
306     }
307 #endif // def DO_GINAC_ASSERT
308
309     if (flags & status_flags::evaluated) {
310         return *this;
311     }
312     
313     expair const & last_expair=*(seq.end()-1);
314     expair const & next_to_last_expair=*(seq.end()-2);
315     int seq_size = seq.size();
316
317     // +(...,x,c1,c2) -> +(...,x,c1+c2) (c1, c2 numeric())
318     if ((!seq_copied)&&(seq_size>=2)&&
319         is_ex_exactly_of_type(last_expair.rest,numeric)&&
320         is_ex_exactly_of_type(next_to_last_expair.rest,numeric)) {
321         newseq=seq;
322         seq_copied=true;
323         it2=newseq.end()-1;
324         it1=it2-1;
325     }
326     while (seq_copied&&(newseq.size()>=2)&&
327            is_ex_exactly_of_type((*it1).rest,numeric)&&
328            is_ex_exactly_of_type((*it2).rest,numeric)) {
329         *it1=expair(ex_to_numeric((*it1).rest).mul(ex_to_numeric((*it1).coeff))
330                     .add_dyn(ex_to_numeric((*it2).rest).mul(ex_to_numeric((*it2).coeff))),exONE());
331         newseq.pop_back();
332         it2=newseq.end()-1;
333         it1=it2-1;
334     }
335
336     // +(...,(c1,c2)) -> (...,(c1*c2,1)) (normalize)
337     if ((!seq_copied)&&(seq_size>=1)&&
338         (is_ex_exactly_of_type(last_expair.rest,numeric))&&
339         (ex_to_numeric(last_expair.coeff).compare(numONE())!=0)) {
340         newseq=seq;
341         seq_copied=true;
342         it2=newseq.end()-1;
343     }
344     if (seq_copied&&(newseq.size()>=1)&&
345         (is_ex_exactly_of_type((*it2).rest,numeric))&&
346         (ex_to_numeric((*it2).coeff).compare(numONE())!=0)) {
347         *it2=expair(ex_to_numeric((*it2).rest).mul_dyn(ex_to_numeric((*it2).coeff)),exONE());
348     }
349         
350     // +(...,x,0) -> +(...,x)
351     if ((!seq_copied)&&(seq_size>=1)&&
352         (is_ex_exactly_of_type(last_expair.rest,numeric))&&
353         (ex_to_numeric(last_expair.rest).is_zero())) {
354         newseq=seq;
355         seq_copied=true;
356         it2=newseq.end()-1;
357     }
358     if (seq_copied&&(newseq.size()>=1)&&
359         (is_ex_exactly_of_type((*it2).rest,numeric))&&
360         (ex_to_numeric((*it2).rest).is_zero())) {
361         newseq.pop_back();
362     }
363
364     // +() -> 0
365     if ((!seq_copied)&&(seq_size==0)) {
366         return exZERO();
367     } else if (seq_copied&&(newseq.size()==0)) {
368         return exZERO();
369     }
370
371     // +(x) -> x
372     if ((!seq_copied)&&(seq_size==1)) {
373         return recombine_pair_to_ex(*(seq.begin()));
374     } else if (seq_copied&&(newseq.size()==1)) {
375         return recombine_pair_to_ex(*(newseq.begin()));
376     }
377
378     if (!seq_copied) return this->hold();
379
380     return (new add(newseq,1))->setflag(status_flags::dynallocated  |
381                                         status_flags::evaluated );
382 }
383 */
384
385 ex add::eval(int level) const
386 {
387     // simplifications: +(;c) -> c
388     //                  +(x;1) -> x
389
390     debugmsg("add eval",LOGLEVEL_MEMBER_FUNCTION);
391
392     epvector * evaled_seqp=evalchildren(level);
393     if (evaled_seqp!=0) {
394         // do more evaluation later
395         return (new add(evaled_seqp,overall_coeff))->
396                    setflag(status_flags::dynallocated);
397     }
398
399 #ifdef DO_GINAC_ASSERT
400     for (epvector::const_iterator cit=seq.begin(); cit!=seq.end(); ++cit) {
401         GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,add));
402         if (is_ex_exactly_of_type((*cit).rest,numeric)) {
403             dbgprint();
404         }
405         GINAC_ASSERT(!is_ex_exactly_of_type((*cit).rest,numeric));
406     }
407 #endif // def DO_GINAC_ASSERT
408
409     if (flags & status_flags::evaluated) {
410         GINAC_ASSERT(seq.size()>0);
411         GINAC_ASSERT((seq.size()>1)||!overall_coeff.is_equal(exZERO()));
412         return *this;
413     }
414
415     int seq_size=seq.size();
416     if (seq_size==0) {
417         // +(;c) -> c
418         return overall_coeff;
419     } else if ((seq_size==1)&&overall_coeff.is_equal(exZERO())) {
420         // +(x;0) -> x
421         return recombine_pair_to_ex(*(seq.begin()));
422     }
423     return this->hold();
424 }
425
426 exvector add::get_indices(void) const
427 {
428     // FIXME: all terms in the sum should have the same indices (compatible
429     // tensors) however this is not checked, since there is no function yet
430     // which compares indices (idxvector can be unsorted)
431     if (seq.size()==0) {
432         return exvector();
433     }
434     return (seq.begin())->rest.get_indices();
435 }    
436
437 ex add::simplify_ncmul(exvector const & v) const
438 {
439     if (seq.size()==0) {
440         return expairseq::simplify_ncmul(v);
441     }
442     return (*seq.begin()).rest.simplify_ncmul(v);
443 }    
444
445 // protected
446
447 int add::compare_same_type(basic const & other) const
448 {
449     return expairseq::compare_same_type(other);
450 }
451
452 bool add::is_equal_same_type(basic const & other) const
453 {
454     return expairseq::is_equal_same_type(other);
455 }
456
457 unsigned add::return_type(void) const
458 {
459     if (seq.size()==0) {
460         return return_types::commutative;
461     }
462     return (*seq.begin()).rest.return_type();
463 }
464    
465 unsigned add::return_type_tinfo(void) const
466 {
467     if (seq.size()==0) {
468         return tinfo_key;
469     }
470     return (*seq.begin()).rest.return_type_tinfo();
471 }
472
473 ex add::thisexpairseq(epvector const & v, ex const & oc) const
474 {
475     return (new add(v,oc))->setflag(status_flags::dynallocated);
476 }
477
478 ex add::thisexpairseq(epvector * vp, ex const & oc) const
479 {
480     return (new add(vp,oc))->setflag(status_flags::dynallocated);
481 }
482
483 /*
484 expair add::split_ex_to_pair(ex const & e) const
485 {
486     if (is_ex_exactly_of_type(e,mul)) {
487         mul const & mulref=ex_to_mul(e);
488         GINAC_ASSERT(mulref.seq.size()>1);
489         ex const & lastfactor_rest=(*(mulref.seq.end()-1)).rest;
490         ex const & lastfactor_coeff=(*(mulref.seq.end()-1)).coeff;
491         if (is_ex_exactly_of_type(lastfactor_rest,numeric) &&
492             ex_to_numeric(lastfactor_coeff).is_equal(numONE())) {
493             epvector s=mulref.seq;
494             //s.pop_back();
495             //return expair((new mul(s,1))->setflag(status_flags::dynallocated),
496             //              lastfactor);
497             mul * mulp=static_cast<mul *>(mulref.duplicate());
498 #ifdef EXPAIRSEQ_USE_HASHTAB
499             mulp->remove_hashtab_entry(mulp->seq.end()-1);
500 #endif // def EXPAIRSEQ_USE_HASHTAB
501             mulp->seq.pop_back();
502 #ifdef EXPAIRSEQ_USE_HASHTAB
503             mulp->shrink_hashtab();
504 #endif // def EXPAIRSEQ_USE_HASHTAB
505             mulp->clearflag(status_flags::evaluated);
506             mulp->clearflag(status_flags::hash_calculated);
507             return expair(mulp->setflag(status_flags::dynallocated),lastfactor_rest);
508         }
509     }
510     return expair(e,exONE());
511 }
512 */
513
514 expair add::split_ex_to_pair(ex const & e) const
515 {
516     if (is_ex_exactly_of_type(e,mul)) {
517         mul const & mulref=ex_to_mul(e);
518         ex numfactor=mulref.overall_coeff;
519         // mul * mulcopyp=static_cast<mul *>(mulref.duplicate());
520         mul * mulcopyp=new mul(mulref);
521         mulcopyp->overall_coeff=exONE();
522         mulcopyp->clearflag(status_flags::evaluated);
523         mulcopyp->clearflag(status_flags::hash_calculated);
524         return expair(mulcopyp->setflag(status_flags::dynallocated),numfactor);
525     }
526     return expair(e,exONE());
527 }
528
529 /*
530 expair add::combine_ex_with_coeff_to_pair(ex const & e,
531                                           ex const & c) const
532 {
533     GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
534     if (is_ex_exactly_of_type(e,mul)) {
535         mul const & mulref=ex_to_mul(e);
536         GINAC_ASSERT(mulref.seq.size()>1);
537         ex const & lastfactor_rest=(*(mulref.seq.end()-1)).rest;
538         ex const & lastfactor_coeff=(*(mulref.seq.end()-1)).coeff;
539         if (is_ex_exactly_of_type(lastfactor_rest,numeric) &&
540             ex_to_numeric(lastfactor_coeff).is_equal(numONE())) {
541             //epvector s=mulref.seq;
542             //s.pop_back();
543             //return expair((new mul(s,1))->setflag(status_flags::dynallocated),
544             //              ex_to_numeric(lastfactor).mul_dyn(ex_to_numeric(c)));
545             mul * mulp=static_cast<mul *>(mulref.duplicate());
546 #ifdef EXPAIRSEQ_USE_HASHTAB
547             mulp->remove_hashtab_entry(mulp->seq.end()-1);
548 #endif // def EXPAIRSEQ_USE_HASHTAB
549             mulp->seq.pop_back();
550 #ifdef EXPAIRSEQ_USE_HASHTAB
551             mulp->shrink_hashtab();
552 #endif // def EXPAIRSEQ_USE_HASHTAB
553             mulp->clearflag(status_flags::evaluated);
554             mulp->clearflag(status_flags::hash_calculated);
555             if (are_ex_trivially_equal(c,exONE())) {
556                 return expair(mulp->setflag(status_flags::dynallocated),lastfactor_rest);
557             } else if (are_ex_trivially_equal(lastfactor_rest,exONE())) {
558                 return expair(mulp->setflag(status_flags::dynallocated),c);
559             }                
560             return expair(mulp->setflag(status_flags::dynallocated),
561                           ex_to_numeric(lastfactor_rest).mul_dyn(ex_to_numeric(c)));
562         }
563     }
564     return expair(e,c);
565 }
566 */
567
568 expair add::combine_ex_with_coeff_to_pair(ex const & e,
569                                           ex const & c) const
570 {
571     GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
572     if (is_ex_exactly_of_type(e,mul)) {
573         mul const & mulref=ex_to_mul(e);
574         ex numfactor=mulref.overall_coeff;
575         //mul * mulcopyp=static_cast<mul *>(mulref.duplicate());
576         mul * mulcopyp=new mul(mulref);
577         mulcopyp->overall_coeff=exONE();
578         mulcopyp->clearflag(status_flags::evaluated);
579         mulcopyp->clearflag(status_flags::hash_calculated);
580         if (are_ex_trivially_equal(c,exONE())) {
581             return expair(mulcopyp->setflag(status_flags::dynallocated),numfactor);
582         } else if (are_ex_trivially_equal(numfactor,exONE())) {
583             return expair(mulcopyp->setflag(status_flags::dynallocated),c);
584         }
585         return expair(mulcopyp->setflag(status_flags::dynallocated),
586                           ex_to_numeric(numfactor).mul_dyn(ex_to_numeric(c)));
587     } else if (is_ex_exactly_of_type(e,numeric)) {
588         if (are_ex_trivially_equal(c,exONE())) {
589             return expair(e,exONE());
590         }
591         return expair(ex_to_numeric(e).mul_dyn(ex_to_numeric(c)),exONE());
592     }
593     return expair(e,c);
594 }
595     
596 expair add::combine_pair_with_coeff_to_pair(expair const & p,
597                                             ex const & c) const
598 {
599     GINAC_ASSERT(is_ex_exactly_of_type(p.coeff,numeric));
600     GINAC_ASSERT(is_ex_exactly_of_type(c,numeric));
601
602     if (is_ex_exactly_of_type(p.rest,numeric)) {
603         GINAC_ASSERT(ex_to_numeric(p.coeff).is_equal(numONE())); // should be normalized
604         return expair(ex_to_numeric(p.rest).mul_dyn(ex_to_numeric(c)),exONE());
605     }
606
607     return expair(p.rest,ex_to_numeric(p.coeff).mul_dyn(ex_to_numeric(c)));
608 }
609     
610 ex add::recombine_pair_to_ex(expair const & p) const
611 {
612     //if (p.coeff.compare(exONE())==0) {
613     //if (are_ex_trivially_equal(p.coeff,exONE())) {
614     if (ex_to_numeric(p.coeff).is_equal(numONE())) {
615         return p.rest;
616     } else {
617         return p.rest*p.coeff;
618     }
619 }
620
621 ex add::expand(unsigned options) const
622 {
623     epvector * vp=expandchildren(options);
624     if (vp==0) {
625         return *this;
626     }
627     return (new add(vp,overall_coeff))->setflag(status_flags::expanded    |
628                                                 status_flags::dynallocated );
629 }
630
631 //////////
632 // new virtual functions which can be overridden by derived classes
633 //////////
634
635 // none
636
637 //////////
638 // non-virtual functions in this class
639 //////////
640
641 // none
642
643 //////////
644 // static member variables
645 //////////
646
647 // protected
648
649 unsigned add::precedence=40;
650
651 //////////
652 // global constants
653 //////////
654
655 const add some_add;
656 type_info const & typeid_add=typeid(some_add);
657
658 #ifndef NO_GINAC_NAMESPACE
659 } // namespace GiNaC
660 #endif // ndef NO_GINAC_NAMESPACE