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