3 * Implementation of several small and furry utilities needed within GiNaC
4 * but not of any interest to the user of the library. */
7 * GiNaC Copyright (C) 1999-2001 Johannes Gutenberg University Mainz, Germany
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.
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.
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
29 #ifndef NO_NAMESPACE_GINAC
31 #endif // ndef NO_NAMESPACE_GINAC
33 /* Version information buried into the library */
34 const int version_major = GINACLIB_MAJOR_VERSION;
35 const int version_minor = GINACLIB_MINOR_VERSION;
36 const int version_micro = GINACLIB_MICRO_VERSION;
39 /** ctor for pole_error exception class. */
40 pole_error::pole_error(const std::string& what_arg, int degree)
41 : domain_error(what_arg)
46 /** Return the degree of the pole_error exception class. */
47 int pole_error::degree(void) const
52 // some compilers (e.g. cygwin) define a macro log2, causing confusion
54 /** Integer binary logarithm */
55 unsigned log2(unsigned n)
58 for (k = 0; n > 1; n >>= 1) ++k;
63 /** Compare two pointers (just to establish some sort of canonical order).
64 * @return -1, 0, or 1 */
65 int compare_pointers(const void * a, const void * b)
75 /** Append one exvector to another */
76 void append_exvector_to_exvector(exvector & dest, const exvector & source)
78 dest.reserve(dest.size() + source.size());
79 dest.insert(dest.end(), source.begin(), source.end());
83 // `construct on first use' chest of numbers
87 const numeric & _num_120(void)
89 const static ex e = ex(numeric(-120));
90 const static numeric * n = static_cast<const numeric *>(e.bp);
94 const ex & _ex_120(void)
96 static ex * e = new ex(_num_120());
101 const numeric & _num_60(void)
103 const static ex e = ex(numeric(-60));
104 const static numeric * n = static_cast<const numeric *>(e.bp);
108 const ex & _ex_60(void)
110 static ex * e = new ex(_num_60());
115 const numeric & _num_48(void)
117 const static ex e = ex(numeric(-48));
118 const static numeric * n = static_cast<const numeric *>(e.bp);
122 const ex & _ex_48(void)
124 static ex * e = new ex(_num_48());
129 const numeric & _num_30(void)
131 const static ex e = ex(numeric(-30));
132 const static numeric * n = static_cast<const numeric *>(e.bp);
136 const ex & _ex_30(void)
138 static ex * e = new ex(_num_30());
143 const numeric & _num_25(void)
145 const static ex e = ex(numeric(-25));
146 const static numeric * n = static_cast<const numeric *>(e.bp);
150 const ex & _ex_25(void)
152 static ex * e = new ex(_num_25());
157 const numeric & _num_24(void)
159 const static ex e = ex(numeric(-24));
160 const static numeric * n = static_cast<const numeric *>(e.bp);
164 const ex & _ex_24(void)
166 static ex * e = new ex(_num_24());
171 const numeric & _num_20(void)
173 const static ex e = ex(numeric(-20));
174 const static numeric * n = static_cast<const numeric *>(e.bp);
178 const ex & _ex_20(void)
180 static ex * e = new ex(_num_20());
185 const numeric & _num_18(void)
187 const static ex e = ex(numeric(-18));
188 const static numeric * n = static_cast<const numeric *>(e.bp);
192 const ex & _ex_18(void)
194 static ex * e = new ex(_num_18());
199 const numeric & _num_15(void)
201 const static ex e = ex(numeric(-15));
202 const static numeric * n = static_cast<const numeric *>(e.bp);
206 const ex & _ex_15(void)
208 static ex * e = new ex(_num_15());
213 const numeric & _num_12(void)
215 const static ex e = ex(numeric(-12));
216 const static numeric * n = static_cast<const numeric *>(e.bp);
220 const ex & _ex_12(void)
222 static ex * e = new ex(_num_12());
227 const numeric & _num_11(void)
229 const static ex e = ex(numeric(-11));
230 const static numeric * n = static_cast<const numeric *>(e.bp);
234 const ex & _ex_11(void)
236 static ex * e = new ex(_num_11());
241 const numeric & _num_10(void)
243 const static ex e = ex(numeric(-10));
244 const static numeric * n = static_cast<const numeric *>(e.bp);
248 const ex & _ex_10(void)
250 static ex * e = new ex(_num_10());
255 const numeric & _num_9(void)
257 const static ex e = ex(numeric(-9));
258 const static numeric * n = static_cast<const numeric *>(e.bp);
262 const ex & _ex_9(void)
264 static ex * e = new ex(_num_9());
269 const numeric & _num_8(void)
271 const static ex e = ex(numeric(-8));
272 const static numeric * n = static_cast<const numeric *>(e.bp);
276 const ex & _ex_8(void)
278 static ex * e = new ex(_num_8());
283 const numeric & _num_7(void)
285 const static ex e = ex(numeric(-7));
286 const static numeric * n = static_cast<const numeric *>(e.bp);
290 const ex & _ex_7(void)
292 static ex * e = new ex(_num_7());
297 const numeric & _num_6(void)
299 const static ex e = ex(numeric(-6));
300 const static numeric * n = static_cast<const numeric *>(e.bp);
304 const ex & _ex_6(void)
306 static ex * e = new ex(_num_6());
311 const numeric & _num_5(void)
313 const static ex e = ex(numeric(-5));
314 const static numeric * n = static_cast<const numeric *>(e.bp);
318 const ex & _ex_5(void)
320 static ex * e = new ex(_num_5());
325 const numeric & _num_4(void)
327 const static ex e = ex(numeric(-4));
328 const static numeric * n = static_cast<const numeric *>(e.bp);
332 const ex & _ex_4(void)
334 static ex * e = new ex(_num_4());
339 const numeric & _num_3(void)
341 const static ex e = ex(numeric(-3));
342 const static numeric * n = static_cast<const numeric *>(e.bp);
346 const ex & _ex_3(void)
348 static ex * e = new ex(_num_3());
353 const numeric & _num_2(void)
355 const static ex e = ex(numeric(-2));
356 const static numeric * n = static_cast<const numeric *>(e.bp);
360 const ex & _ex_2(void)
362 static ex * e = new ex(_num_2());
367 const numeric & _num_1(void)
369 const static ex e = ex(numeric(-1));
370 const static numeric * n = static_cast<const numeric *>(e.bp);
374 const ex & _ex_1(void)
376 static ex * e = new ex(_num_1());
381 const numeric & _num_1_2(void)
383 const static ex e = ex(numeric(-1,2));
384 const static numeric * n = static_cast<const numeric *>(e.bp);
388 const ex & _ex_1_2(void)
390 static ex * e = new ex(_num_1_2());
395 const numeric & _num_1_3(void)
397 const static ex e = ex(numeric(-1,3));
398 const static numeric * n = static_cast<const numeric *>(e.bp);
402 const ex & _ex_1_3(void)
404 static ex * e = new ex(_num_1_3());
409 const numeric & _num_1_4(void)
411 const static ex e = ex(numeric(-1,4));
412 const static numeric * n = static_cast<const numeric *>(e.bp);
416 const ex & _ex_1_4(void)
418 static ex * e = new ex(_num_1_4());
423 const numeric & _num0(void)
425 const static ex e = ex(numeric(0));
426 const static numeric * n = static_cast<const numeric *>(e.bp);
430 const ex & _ex0(void)
432 static ex * e = new ex(_num0());
437 const numeric & _num1_4(void)
439 const static ex e = ex(numeric(1,4));
440 const static numeric * n = static_cast<const numeric *>(e.bp);
444 const ex & _ex1_4(void)
446 static ex * e = new ex(_num1_4());
451 const numeric & _num1_3(void)
453 const static ex e = ex(numeric(1,3));
454 const static numeric * n = static_cast<const numeric *>(e.bp);
458 const ex & _ex1_3(void)
460 static ex * e = new ex(_num1_3());
465 const numeric & _num1_2(void)
467 const static ex e = ex(numeric(1,2));
468 const static numeric * n = static_cast<const numeric *>(e.bp);
472 const ex & _ex1_2(void)
474 static ex * e = new ex(_num1_2());
479 const numeric & _num1(void)
481 const static ex e = ex(numeric(1));
482 const static numeric * n = static_cast<const numeric *>(e.bp);
486 const ex & _ex1(void)
488 static ex * e = new ex(_num1());
493 const numeric & _num2(void)
495 const static ex e = ex(numeric(2));
496 const static numeric * n = static_cast<const numeric *>(e.bp);
500 const ex & _ex2(void)
502 static ex * e = new ex(_num2());
507 const numeric & _num3(void)
509 const static ex e = ex(numeric(3));
510 const static numeric * n = static_cast<const numeric *>(e.bp);
514 const ex & _ex3(void)
516 static ex * e = new ex(_num3());
521 const numeric & _num4(void)
523 const static ex e = ex(numeric(4));
524 const static numeric * n = static_cast<const numeric *>(e.bp);
528 const ex & _ex4(void)
530 static ex * e = new ex(_num4());
535 const numeric & _num5(void)
537 const static ex e = ex(numeric(5));
538 const static numeric * n = static_cast<const numeric *>(e.bp);
542 const ex & _ex5(void)
544 static ex * e = new ex(_num5());
549 const numeric & _num6(void)
551 const static ex e = ex(numeric(6));
552 const static numeric * n = static_cast<const numeric *>(e.bp);
556 const ex & _ex6(void)
558 static ex * e = new ex(_num6());
563 const numeric & _num7(void)
565 const static ex e = ex(numeric(7));
566 const static numeric * n = static_cast<const numeric *>(e.bp);
570 const ex & _ex7(void)
572 static ex * e = new ex(_num7());
577 const numeric & _num8(void)
579 const static ex e = ex(numeric(8));
580 const static numeric * n = static_cast<const numeric *>(e.bp);
584 const ex & _ex8(void)
586 static ex * e = new ex(_num8());
591 const numeric & _num9(void)
593 const static ex e = ex(numeric(9));
594 const static numeric * n = static_cast<const numeric *>(e.bp);
598 const ex & _ex9(void)
600 static ex * e = new ex(_num9());
605 const numeric & _num10(void)
607 const static ex e = ex(numeric(10));
608 const static numeric * n = static_cast<const numeric *>(e.bp);
612 const ex & _ex10(void)
614 static ex * e = new ex(_num10());
619 const numeric & _num11(void)
621 const static ex e = ex(numeric(11));
622 const static numeric * n = static_cast<const numeric *>(e.bp);
626 const ex & _ex11(void)
628 static ex * e = new ex(_num11());
633 const numeric & _num12(void)
635 const static ex e = ex(numeric(12));
636 const static numeric * n = static_cast<const numeric *>(e.bp);
640 const ex & _ex12(void)
642 static ex * e = new ex(_num12());
647 const numeric & _num15(void)
649 const static ex e = ex(numeric(15));
650 const static numeric * n = static_cast<const numeric *>(e.bp);
654 const ex & _ex15(void)
656 static ex * e = new ex(_num15());
661 const numeric & _num18(void)
663 const static ex e = ex(numeric(18));
664 const static numeric * n = static_cast<const numeric *>(e.bp);
668 const ex & _ex18(void)
670 static ex * e = new ex(_num18());
675 const numeric & _num20(void)
677 const static ex e = ex(numeric(20));
678 const static numeric * n = static_cast<const numeric *>(e.bp);
682 const ex & _ex20(void)
684 static ex * e = new ex(_num20());
689 const numeric & _num24(void)
691 const static ex e = ex(numeric(24));
692 const static numeric * n = static_cast<const numeric *>(e.bp);
696 const ex & _ex24(void)
698 static ex * e = new ex(_num24());
703 const numeric & _num25(void)
705 const static ex e = ex(numeric(25));
706 const static numeric * n = static_cast<const numeric *>(e.bp);
710 const ex & _ex25(void)
712 static ex * e = new ex(_num25());
717 const numeric & _num30(void)
719 const static ex e = ex(numeric(30));
720 const static numeric * n = static_cast<const numeric *>(e.bp);
724 const ex & _ex30(void)
726 static ex * e = new ex(_num30());
731 const numeric & _num48(void)
733 const static ex e = ex(numeric(48));
734 const static numeric * n = static_cast<const numeric *>(e.bp);
738 const ex & _ex48(void)
740 static ex * e = new ex(_num48());
745 const numeric & _num60(void)
747 const static ex e = ex(numeric(60));
748 const static numeric * n = static_cast<const numeric *>(e.bp);
752 const ex & _ex60(void)
754 static ex * e = new ex(_num60());
759 const numeric & _num120(void)
761 const static ex e = ex(numeric(120));
762 const static numeric * n = static_cast<const numeric *>(e.bp);
766 const ex & _ex120(void)
768 static ex * e = new ex(_num120());
772 // comment skeleton for header files
777 // default constructor, destructor, copy constructor assignment operator and helpers
780 // other constructors
783 // functions overriding virtual functions from bases classes
786 // new virtual functions which can be overridden by derived classes
789 // non-virtual functions in this class
797 // comment skeleton for implementation files
801 // default constructor, destructor, copy constructor assignment operator and helpers
808 // other constructors
815 // functions overriding virtual functions from bases classes
823 // new virtual functions which can be overridden by derived classes
831 // non-virtual functions in this class
839 // static member variables
847 #ifndef NO_NAMESPACE_GINAC
849 #endif // ndef NO_NAMESPACE_GINAC