]> www.ginac.de Git - ginac.git/blob - ginac/pseries.cpp
- The paragraph about regression tests reflects the new 3-step scheme now.
[ginac.git] / ginac / pseries.cpp
1 /** @file pseries.cpp
2  *
3  *  Implementation of class for extended truncated power series and
4  *  methods for series expansion. */
5
6 /*
7  *  GiNaC Copyright (C) 1999-2000 Johannes Gutenberg University Mainz, Germany
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23
24 #include <stdexcept>
25
26 #include "pseries.h"
27 #include "add.h"
28 #include "inifcns.h"
29 #include "lst.h"
30 #include "mul.h"
31 #include "power.h"
32 #include "relational.h"
33 #include "symbol.h"
34 #include "archive.h"
35 #include "utils.h"
36 #include "debugmsg.h"
37
38 #ifndef NO_NAMESPACE_GINAC
39 namespace GiNaC {
40 #endif // ndef NO_NAMESPACE_GINAC
41
42 GINAC_IMPLEMENT_REGISTERED_CLASS(pseries, basic)
43
44 /*
45  *  Default constructor, destructor, copy constructor, assignment operator and helpers
46  */
47
48 pseries::pseries() : basic(TINFO_pseries)
49 {
50     debugmsg("pseries default constructor", LOGLEVEL_CONSTRUCT);
51 }
52
53 pseries::~pseries()
54 {
55     debugmsg("pseries destructor", LOGLEVEL_DESTRUCT);
56     destroy(false);
57 }
58
59 pseries::pseries(const pseries &other)
60 {
61     debugmsg("pseries copy constructor", LOGLEVEL_CONSTRUCT);
62     copy(other);
63 }
64
65 const pseries &pseries::operator=(const pseries & other)
66 {
67     debugmsg("pseries operator=", LOGLEVEL_ASSIGNMENT);
68     if (this != &other) {
69         destroy(true);
70         copy(other);
71     }
72     return *this;
73 }
74
75 void pseries::copy(const pseries &other)
76 {
77     inherited::copy(other);
78     seq = other.seq;
79     var = other.var;
80     point = other.point;
81 }
82
83 void pseries::destroy(bool call_parent)
84 {
85     if (call_parent)
86         inherited::destroy(call_parent);
87 }
88
89
90 /*
91  *  Other constructors
92  */
93
94 /** Construct pseries from a vector of coefficients and powers.
95  *  expair.rest holds the coefficient, expair.coeff holds the power.
96  *  The powers must be integers (positive or negative) and in ascending order;
97  *  the last coefficient can be Order(_ex1()) to represent a truncated,
98  *  non-terminating series.
99  *
100  *  @param var_  series variable (must hold a symbol)
101  *  @param point_  expansion point
102  *  @param ops_  vector of {coefficient, power} pairs (coefficient must not be zero)
103  *  @return newly constructed pseries */
104 pseries::pseries(const ex &var_, const ex &point_, const epvector &ops_)
105     : basic(TINFO_pseries), seq(ops_), var(var_), point(point_)
106 {
107     debugmsg("pseries constructor from ex,ex,epvector", LOGLEVEL_CONSTRUCT);
108     GINAC_ASSERT(is_ex_exactly_of_type(var_, symbol));
109 }
110
111
112 /*
113  *  Archiving
114  */
115
116 /** Construct object from archive_node. */
117 pseries::pseries(const archive_node &n, const lst &sym_lst) : inherited(n, sym_lst)
118 {
119     debugmsg("pseries constructor from archive_node", LOGLEVEL_CONSTRUCT);
120     for (unsigned int i=0; true; i++) {
121         ex rest;
122         ex coeff;
123         if (n.find_ex("coeff", rest, sym_lst, i) && n.find_ex("power", coeff, sym_lst, i))
124             seq.push_back(expair(rest, coeff));
125         else
126             break;
127     }
128     n.find_ex("var", var, sym_lst);
129     n.find_ex("point", point, sym_lst);
130 }
131
132 /** Unarchive the object. */
133 ex pseries::unarchive(const archive_node &n, const lst &sym_lst)
134 {
135     return (new pseries(n, sym_lst))->setflag(status_flags::dynallocated);
136 }
137
138 /** Archive the object. */
139 void pseries::archive(archive_node &n) const
140 {
141     inherited::archive(n);
142     epvector::const_iterator i = seq.begin(), iend = seq.end();
143     while (i != iend) {
144         n.add_ex("coeff", i->rest);
145         n.add_ex("power", i->coeff);
146         i++;
147     }
148     n.add_ex("var", var);
149     n.add_ex("point", point);
150 }
151
152
153 /*
154  *  Functions overriding virtual functions from base classes
155  */
156
157 basic *pseries::duplicate() const
158 {
159     debugmsg("pseries duplicate", LOGLEVEL_DUPLICATE);
160     return new pseries(*this);
161 }
162
163 void pseries::print(ostream &os, unsigned upper_precedence) const
164 {
165     debugmsg("pseries print", LOGLEVEL_PRINT);
166     convert_to_poly().print(os, upper_precedence);
167 }
168
169 void pseries::printraw(ostream &os) const
170 {
171         debugmsg("pseries printraw", LOGLEVEL_PRINT);
172         os << "pseries(" << var << ";" << point << ";";
173         for (epvector::const_iterator i=seq.begin(); i!=seq.end(); i++) {
174                 os << "(" << (*i).rest << "," << (*i).coeff << "),";
175         }
176         os << ")";
177 }
178
179 unsigned pseries::nops(void) const
180 {
181     return seq.size();
182 }
183
184 ex pseries::op(int i) const
185 {
186     if (i < 0 || unsigned(i) >= seq.size())
187         throw (std::out_of_range("op() out of range"));
188     return seq[i].rest * power(var - point, seq[i].coeff);
189 }
190
191 ex &pseries::let_op(int i)
192 {
193     throw (std::logic_error("let_op not defined for pseries"));
194 }
195
196 int pseries::degree(const symbol &s) const
197 {
198     if (var.is_equal(s)) {
199         // Return last exponent
200         if (seq.size())
201             return ex_to_numeric((*(seq.end() - 1)).coeff).to_int();
202         else
203             return 0;
204     } else {
205         epvector::const_iterator it = seq.begin(), itend = seq.end();
206         if (it == itend)
207             return 0;
208         int max_pow = INT_MIN;
209         while (it != itend) {
210             int pow = it->rest.degree(s);
211             if (pow > max_pow)
212                 max_pow = pow;
213             it++;
214         }
215         return max_pow;
216     }
217 }
218
219 int pseries::ldegree(const symbol &s) const
220 {
221     if (var.is_equal(s)) {
222         // Return first exponent
223         if (seq.size())
224             return ex_to_numeric((*(seq.begin())).coeff).to_int();
225         else
226             return 0;
227     } else {
228         epvector::const_iterator it = seq.begin(), itend = seq.end();
229         if (it == itend)
230             return 0;
231         int min_pow = INT_MAX;
232         while (it != itend) {
233             int pow = it->rest.ldegree(s);
234             if (pow < min_pow)
235                 min_pow = pow;
236             it++;
237         }
238         return min_pow;
239     }
240 }
241
242 ex pseries::coeff(const symbol &s, int n) const
243 {
244     if (var.is_equal(s)) {
245                 if (seq.size() == 0)
246                         return _ex0();
247
248                 // Binary search in sequence for given power
249                 numeric looking_for = numeric(n);
250                 int lo = 0, hi = seq.size() - 1;
251                 while (lo <= hi) {
252                         int mid = (lo + hi) / 2;
253                         GINAC_ASSERT(is_ex_exactly_of_type(seq[mid].coeff, numeric));
254                         int cmp = ex_to_numeric(seq[mid].coeff).compare(looking_for);
255                         switch (cmp) {
256                                 case -1:
257                                         lo = mid + 1;
258                                         break;
259                                 case 0:
260                                         return seq[mid].rest;
261                                 case 1:
262                                         hi = mid - 1;
263                                         break;
264                                 default:
265                                         throw(std::logic_error("pseries::coeff: compare() didn't return -1, 0 or 1"));
266                         }
267                 }
268                 return _ex0();
269     } else
270         return convert_to_poly().coeff(s, n);
271 }
272
273 ex pseries::collect(const symbol &s) const
274 {
275         if (var.is_equal(s))
276                 return convert_to_poly();
277         else
278                 return inherited::collect(s);
279 }
280
281 ex pseries::eval(int level) const
282 {
283     if (level == 1)
284         return this->hold();
285     
286     // Construct a new series with evaluated coefficients
287     epvector new_seq;
288     new_seq.reserve(seq.size());
289     epvector::const_iterator it = seq.begin(), itend = seq.end();
290     while (it != itend) {
291         new_seq.push_back(expair(it->rest.eval(level-1), it->coeff));
292         it++;
293     }
294     return (new pseries(var, point, new_seq))->setflag(status_flags::dynallocated | status_flags::evaluated);
295 }
296
297 /** Evaluate numerically.  The order term is dropped. */
298 ex pseries::evalf(int level) const
299 {
300     return convert_to_poly().evalf(level);
301 }
302
303 ex pseries::subs(const lst & ls, const lst & lr) const
304 {
305         // If expansion variable is being substituted, convert the series to a
306         // polynomial and do the substitution there because the result might
307         // no longer be a power series
308         if (ls.has(var))
309                 return convert_to_poly(true).subs(ls, lr);
310
311         // Otherwise construct a new series with substituted coefficients and
312         // expansion point
313         epvector new_seq;
314         new_seq.reserve(seq.size());
315         epvector::const_iterator it = seq.begin(), itend = seq.end();
316         while (it != itend) {
317                 new_seq.push_back(expair(it->rest.subs(ls, lr), it->coeff));
318                 it++;
319         }
320     return (new pseries(var, point.subs(ls, lr), new_seq))->setflag(status_flags::dynallocated);
321 }
322
323 /** Implementation of ex::diff() for a power series.  It treats the series as a
324  *  polynomial.
325  *  @see ex::diff */
326 ex pseries::derivative(const symbol & s) const
327 {
328     if (s == var) {
329         epvector new_seq;
330         epvector::const_iterator it = seq.begin(), itend = seq.end();
331         
332         // FIXME: coeff might depend on var
333         while (it != itend) {
334             if (is_order_function(it->rest)) {
335                 new_seq.push_back(expair(it->rest, it->coeff - 1));
336             } else {
337                 ex c = it->rest * it->coeff;
338                 if (!c.is_zero())
339                     new_seq.push_back(expair(c, it->coeff - 1));
340             }
341             it++;
342         }
343         return pseries(var, point, new_seq);
344     } else {
345         return *this;
346     }
347 }
348
349
350 /*
351  *  Construct ordinary polynomial out of series
352  */
353
354 /** Convert a pseries object to an ordinary polynomial.
355  *
356  *  @param no_order flag: discard higher order terms */
357 ex pseries::convert_to_poly(bool no_order) const
358 {
359     ex e;
360     epvector::const_iterator it = seq.begin(), itend = seq.end();
361     
362     while (it != itend) {
363         if (is_order_function(it->rest)) {
364             if (!no_order)
365                 e += Order(power(var - point, it->coeff));
366         } else
367             e += it->rest * power(var - point, it->coeff);
368         it++;
369     }
370     return e;
371 }
372
373
374 /*
375  *  Implementation of series expansion
376  */
377
378 /** Default implementation of ex::series(). This performs Taylor expansion.
379  *  @see ex::series */
380 ex basic::series(const symbol & s, const ex & point, int order) const
381 {
382     epvector seq;
383     numeric fac(1);
384     ex deriv = *this;
385     ex coeff = deriv.subs(s == point);
386     if (!coeff.is_zero())
387         seq.push_back(expair(coeff, numeric(0)));
388     
389     int n;
390     for (n=1; n<order; n++) {
391         fac = fac.mul(numeric(n));
392         deriv = deriv.diff(s).expand();
393         if (deriv.is_zero()) {
394             // Series terminates
395             return pseries(s, point, seq);
396         }
397         coeff = fac.inverse() * deriv.subs(s == point);
398         if (!coeff.is_zero())
399             seq.push_back(expair(coeff, numeric(n)));
400     }
401     
402     // Higher-order terms, if present
403     deriv = deriv.diff(s);
404     if (!deriv.is_zero())
405         seq.push_back(expair(Order(_ex1()), numeric(n)));
406     return pseries(s, point, seq);
407 }
408
409
410 /** Implementation of ex::series() for symbols.
411  *  @see ex::series */
412 ex symbol::series(const symbol & s, const ex & point, int order) const
413 {
414         epvector seq;
415         if (is_equal(s)) {
416                 if (order > 0 && !point.is_zero())
417                         seq.push_back(expair(point, _ex0()));
418                 if (order > 1)
419                         seq.push_back(expair(_ex1(), _ex1()));
420                 else
421                         seq.push_back(expair(Order(_ex1()), numeric(order)));
422         } else
423                 seq.push_back(expair(*this, _ex0()));
424         return pseries(s, point, seq);
425 }
426
427
428 /** Add one series object to another, producing a pseries object that
429  *  represents the sum.
430  *
431  *  @param other  pseries object to add with
432  *  @return the sum as a pseries */
433 ex pseries::add_series(const pseries &other) const
434 {
435     // Adding two series with different variables or expansion points
436     // results in an empty (constant) series 
437     if (!is_compatible_to(other)) {
438         epvector nul;
439         nul.push_back(expair(Order(_ex1()), _ex0()));
440         return pseries(var, point, nul);
441     }
442     
443     // Series addition
444     epvector new_seq;
445     epvector::const_iterator a = seq.begin();
446     epvector::const_iterator b = other.seq.begin();
447     epvector::const_iterator a_end = seq.end();
448     epvector::const_iterator b_end = other.seq.end();
449     int pow_a = INT_MAX, pow_b = INT_MAX;
450     for (;;) {
451         // If a is empty, fill up with elements from b and stop
452         if (a == a_end) {
453             while (b != b_end) {
454                 new_seq.push_back(*b);
455                 b++;
456             }
457             break;
458         } else
459             pow_a = ex_to_numeric((*a).coeff).to_int();
460         
461         // If b is empty, fill up with elements from a and stop
462         if (b == b_end) {
463             while (a != a_end) {
464                 new_seq.push_back(*a);
465                 a++;
466             }
467             break;
468         } else
469             pow_b = ex_to_numeric((*b).coeff).to_int();
470         
471         // a and b are non-empty, compare powers
472         if (pow_a < pow_b) {
473             // a has lesser power, get coefficient from a
474             new_seq.push_back(*a);
475             if (is_order_function((*a).rest))
476                 break;
477             a++;
478         } else if (pow_b < pow_a) {
479             // b has lesser power, get coefficient from b
480             new_seq.push_back(*b);
481             if (is_order_function((*b).rest))
482                 break;
483             b++;
484         } else {
485             // Add coefficient of a and b
486             if (is_order_function((*a).rest) || is_order_function((*b).rest)) {
487                 new_seq.push_back(expair(Order(_ex1()), (*a).coeff));
488                 break;  // Order term ends the sequence
489             } else {
490                 ex sum = (*a).rest + (*b).rest;
491                 if (!(sum.is_zero()))
492                     new_seq.push_back(expair(sum, numeric(pow_a)));
493                 a++;
494                 b++;
495             }
496         }
497     }
498     return pseries(var, point, new_seq);
499 }
500
501
502 /** Implementation of ex::series() for sums. This performs series addition when
503  *  adding pseries objects.
504  *  @see ex::series */
505 ex add::series(const symbol & s, const ex & point, int order) const
506 {
507     ex acc; // Series accumulator
508     
509     // Get first term from overall_coeff
510     acc = overall_coeff.series(s, point, order);
511
512     // Add remaining terms
513     epvector::const_iterator it = seq.begin();
514     epvector::const_iterator itend = seq.end();
515     for (; it!=itend; it++) {
516         ex op;
517         if (is_ex_exactly_of_type(it->rest, pseries))
518             op = it->rest;
519         else
520             op = it->rest.series(s, point, order);
521         if (!it->coeff.is_equal(_ex1()))
522             op = ex_to_pseries(op).mul_const(ex_to_numeric(it->coeff));
523         
524         // Series addition
525         acc = ex_to_pseries(acc).add_series(ex_to_pseries(op));
526     }
527     return acc;
528 }
529
530
531 /** Multiply a pseries object with a numeric constant, producing a pseries
532  *  object that represents the product.
533  *
534  *  @param other  constant to multiply with
535  *  @return the product as a pseries */
536 ex pseries::mul_const(const numeric &other) const
537 {
538     epvector new_seq;
539     new_seq.reserve(seq.size());
540     
541     epvector::const_iterator it = seq.begin(), itend = seq.end();
542     while (it != itend) {
543         if (!is_order_function(it->rest))
544             new_seq.push_back(expair(it->rest * other, it->coeff));
545         else
546             new_seq.push_back(*it);
547         it++;
548     }
549     return pseries(var, point, new_seq);
550 }
551
552
553 /** Multiply one pseries object to another, producing a pseries object that
554  *  represents the product.
555  *
556  *  @param other  pseries object to multiply with
557  *  @return the product as a pseries */
558 ex pseries::mul_series(const pseries &other) const
559 {
560     // Multiplying two series with different variables or expansion points
561     // results in an empty (constant) series 
562     if (!is_compatible_to(other)) {
563         epvector nul;
564         nul.push_back(expair(Order(_ex1()), _ex0()));
565         return pseries(var, point, nul);
566     }
567
568     // Series multiplication
569     epvector new_seq;
570     
571     const symbol *s = static_cast<symbol *>(var.bp);
572     int a_max = degree(*s);
573     int b_max = other.degree(*s);
574     int a_min = ldegree(*s);
575     int b_min = other.ldegree(*s);
576     int cdeg_min = a_min + b_min;
577     int cdeg_max = a_max + b_max;
578     
579     int higher_order_a = INT_MAX;
580     int higher_order_b = INT_MAX;
581     if (is_order_function(coeff(*s, a_max)))
582         higher_order_a = a_max + b_min;
583     if (is_order_function(other.coeff(*s, b_max)))
584         higher_order_b = b_max + a_min;
585     int higher_order_c = min(higher_order_a, higher_order_b);
586     if (cdeg_max >= higher_order_c)
587         cdeg_max = higher_order_c - 1;
588     
589     for (int cdeg=cdeg_min; cdeg<=cdeg_max; cdeg++) {
590         ex co = _ex0();
591         // c(i)=a(0)b(i)+...+a(i)b(0)
592         for (int i=a_min; cdeg-i>=b_min; i++) {
593             ex a_coeff = coeff(*s, i);
594             ex b_coeff = other.coeff(*s, cdeg-i);
595             if (!is_order_function(a_coeff) && !is_order_function(b_coeff))
596                 co += coeff(*s, i) * other.coeff(*s, cdeg-i);
597         }
598         if (!co.is_zero())
599             new_seq.push_back(expair(co, numeric(cdeg)));
600     }
601     if (higher_order_c < INT_MAX)
602         new_seq.push_back(expair(Order(_ex1()), numeric(higher_order_c)));
603     return pseries(var, point, new_seq);
604 }
605
606
607 /** Implementation of ex::series() for product. This performs series
608  *  multiplication when multiplying series.
609  *  @see ex::series */
610 ex mul::series(const symbol & s, const ex & point, int order) const
611 {
612     ex acc; // Series accumulator
613     
614     // Get first term from overall_coeff
615     acc = overall_coeff.series(s, point, order);
616     
617     // Multiply with remaining terms
618     epvector::const_iterator it = seq.begin();
619     epvector::const_iterator itend = seq.end();
620     for (; it!=itend; it++) {
621         ex op = it->rest;
622         if (op.info(info_flags::numeric)) {
623             // series * const (special case, faster)
624             ex f = power(op, it->coeff);
625             acc = ex_to_pseries(acc).mul_const(ex_to_numeric(f));
626             continue;
627         } else if (!is_ex_exactly_of_type(op, pseries))
628             op = op.series(s, point, order);
629         if (!it->coeff.is_equal(_ex1()))
630             op = ex_to_pseries(op).power_const(ex_to_numeric(it->coeff), order);
631
632         // Series multiplication
633         acc = ex_to_pseries(acc).mul_series(ex_to_pseries(op));
634     }
635     return acc;
636 }
637
638
639 /** Compute the p-th power of a series.
640  *
641  *  @param p  power to compute
642  *  @param deg  truncation order of series calculation */
643 ex pseries::power_const(const numeric &p, int deg) const
644 {
645     int i;
646     const symbol *s = static_cast<symbol *>(var.bp);
647     int ldeg = ldegree(*s);
648     
649     // Calculate coefficients of powered series
650     exvector co;
651     co.reserve(deg);
652     ex co0;
653     co.push_back(co0 = power(coeff(*s, ldeg), p));
654     bool all_sums_zero = true;
655     for (i=1; i<deg; i++) {
656         ex sum = _ex0();
657         for (int j=1; j<=i; j++) {
658             ex c = coeff(*s, j + ldeg);
659             if (is_order_function(c)) {
660                 co.push_back(Order(_ex1()));
661                 break;
662             } else
663                 sum += (p * j - (i - j)) * co[i - j] * c;
664         }
665         if (!sum.is_zero())
666             all_sums_zero = false;
667         co.push_back(co0 * sum / numeric(i));
668     }
669     
670     // Construct new series (of non-zero coefficients)
671     epvector new_seq;
672     bool higher_order = false;
673     for (i=0; i<deg; i++) {
674         if (!co[i].is_zero())
675             new_seq.push_back(expair(co[i], numeric(i) + p * ldeg));
676         if (is_order_function(co[i])) {
677             higher_order = true;
678             break;
679         }
680     }
681     if (!higher_order && !all_sums_zero)
682         new_seq.push_back(expair(Order(_ex1()), numeric(deg) + p * ldeg));
683     return pseries(var, point, new_seq);
684 }
685
686
687 /** Implementation of ex::series() for powers. This performs Laurent expansion
688  *  of reciprocals of series at singularities.
689  *  @see ex::series */
690 ex power::series(const symbol & s, const ex & point, int order) const
691 {
692     ex e;
693     if (!is_ex_exactly_of_type(basis, pseries)) {
694         // Basis is not a series, may there be a singulary?
695         if (!exponent.info(info_flags::negint))
696             return basic::series(s, point, order);
697         
698         // Expression is of type something^(-int), check for singularity
699         if (!basis.subs(s == point).is_zero())
700             return basic::series(s, point, order);
701         
702         // Singularity encountered, expand basis into series
703         e = basis.series(s, point, order);
704     } else {
705         // Basis is a series
706         e = basis;
707     }
708     
709     // Power e
710     return ex_to_pseries(e).power_const(ex_to_numeric(exponent), order);
711 }
712
713
714 /** Re-expansion of a pseries object. */
715 ex pseries::series(const symbol & s, const ex & p, int order) const
716 {
717         if (var.is_equal(s) && point.is_equal(p)) {
718                 if (order > degree(s))
719                         return *this;
720                 else {
721                 epvector new_seq;
722                 epvector::const_iterator it = seq.begin(), itend = seq.end();
723                         while (it != itend) {
724                                 int o = ex_to_numeric(it->coeff).to_int();
725                                 if (o >= order) {
726                                         new_seq.push_back(expair(Order(_ex1()), o));
727                                         break;
728                                 }
729                                 new_seq.push_back(*it);
730                                 it++;
731                         }
732                         return pseries(var, point, new_seq);
733                 }
734         } else
735                 return convert_to_poly().series(s, p, order);
736 }
737
738
739 /** Compute the truncated series expansion of an expression.
740  *  This function returns an expression containing an object of class pseries to
741  *  represent the series. If the series does not terminate within the given
742  *  truncation order, the last term of the series will be an order term.
743  *
744  *  @param s  expansion variable
745  *  @param point  expansion point
746  *  @param order  truncation order of series calculations
747  *  @return an expression holding a pseries object */
748 ex ex::series(const symbol &s, const ex &point, int order) const
749 {
750     GINAC_ASSERT(bp!=0);
751     return bp->series(s, point, order);
752 }
753
754
755 // Global constants
756 const pseries some_pseries;
757 const type_info & typeid_pseries = typeid(some_pseries);
758
759 #ifndef NO_NAMESPACE_GINAC
760 } // namespace GiNaC
761 #endif // ndef NO_NAMESPACE_GINAC