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
31 /* Version information buried into the library */
32 const int version_major = GINACLIB_MAJOR_VERSION;
33 const int version_minor = GINACLIB_MINOR_VERSION;
34 const int version_micro = GINACLIB_MICRO_VERSION;
37 /** ctor for pole_error exception class. */
38 pole_error::pole_error(const std::string& what_arg, int degree)
39 : domain_error(what_arg)
44 /** Return the degree of the pole_error exception class. */
45 int pole_error::degree(void) const
50 // some compilers (e.g. cygwin) define a macro log2, causing confusion
52 /** Integer binary logarithm */
53 unsigned log2(unsigned n)
56 for (k = 0; n > 1; n >>= 1)
62 /** Append one exvector to another */
63 void append_exvector_to_exvector(exvector & dest, const exvector & source)
65 dest.reserve(dest.size() + source.size());
66 dest.insert(dest.end(), source.begin(), source.end());
70 // `construct on first use' chest of numbers
74 const numeric & _num_120(void)
76 const static ex e = ex(numeric(-120));
77 const static numeric * n = static_cast<const numeric *>(e.bp);
81 const ex & _ex_120(void)
83 static ex * e = new ex(_num_120());
88 const numeric & _num_60(void)
90 const static ex e = ex(numeric(-60));
91 const static numeric * n = static_cast<const numeric *>(e.bp);
95 const ex & _ex_60(void)
97 static ex * e = new ex(_num_60());
102 const numeric & _num_48(void)
104 const static ex e = ex(numeric(-48));
105 const static numeric * n = static_cast<const numeric *>(e.bp);
109 const ex & _ex_48(void)
111 static ex * e = new ex(_num_48());
116 const numeric & _num_30(void)
118 const static ex e = ex(numeric(-30));
119 const static numeric * n = static_cast<const numeric *>(e.bp);
123 const ex & _ex_30(void)
125 static ex * e = new ex(_num_30());
130 const numeric & _num_25(void)
132 const static ex e = ex(numeric(-25));
133 const static numeric * n = static_cast<const numeric *>(e.bp);
137 const ex & _ex_25(void)
139 static ex * e = new ex(_num_25());
144 const numeric & _num_24(void)
146 const static ex e = ex(numeric(-24));
147 const static numeric * n = static_cast<const numeric *>(e.bp);
151 const ex & _ex_24(void)
153 static ex * e = new ex(_num_24());
158 const numeric & _num_20(void)
160 const static ex e = ex(numeric(-20));
161 const static numeric * n = static_cast<const numeric *>(e.bp);
165 const ex & _ex_20(void)
167 static ex * e = new ex(_num_20());
172 const numeric & _num_18(void)
174 const static ex e = ex(numeric(-18));
175 const static numeric * n = static_cast<const numeric *>(e.bp);
179 const ex & _ex_18(void)
181 static ex * e = new ex(_num_18());
186 const numeric & _num_15(void)
188 const static ex e = ex(numeric(-15));
189 const static numeric * n = static_cast<const numeric *>(e.bp);
193 const ex & _ex_15(void)
195 static ex * e = new ex(_num_15());
200 const numeric & _num_12(void)
202 const static ex e = ex(numeric(-12));
203 const static numeric * n = static_cast<const numeric *>(e.bp);
207 const ex & _ex_12(void)
209 static ex * e = new ex(_num_12());
214 const numeric & _num_11(void)
216 const static ex e = ex(numeric(-11));
217 const static numeric * n = static_cast<const numeric *>(e.bp);
221 const ex & _ex_11(void)
223 static ex * e = new ex(_num_11());
228 const numeric & _num_10(void)
230 const static ex e = ex(numeric(-10));
231 const static numeric * n = static_cast<const numeric *>(e.bp);
235 const ex & _ex_10(void)
237 static ex * e = new ex(_num_10());
242 const numeric & _num_9(void)
244 const static ex e = ex(numeric(-9));
245 const static numeric * n = static_cast<const numeric *>(e.bp);
249 const ex & _ex_9(void)
251 static ex * e = new ex(_num_9());
256 const numeric & _num_8(void)
258 const static ex e = ex(numeric(-8));
259 const static numeric * n = static_cast<const numeric *>(e.bp);
263 const ex & _ex_8(void)
265 static ex * e = new ex(_num_8());
270 const numeric & _num_7(void)
272 const static ex e = ex(numeric(-7));
273 const static numeric * n = static_cast<const numeric *>(e.bp);
277 const ex & _ex_7(void)
279 static ex * e = new ex(_num_7());
284 const numeric & _num_6(void)
286 const static ex e = ex(numeric(-6));
287 const static numeric * n = static_cast<const numeric *>(e.bp);
291 const ex & _ex_6(void)
293 static ex * e = new ex(_num_6());
298 const numeric & _num_5(void)
300 const static ex e = ex(numeric(-5));
301 const static numeric * n = static_cast<const numeric *>(e.bp);
305 const ex & _ex_5(void)
307 static ex * e = new ex(_num_5());
312 const numeric & _num_4(void)
314 const static ex e = ex(numeric(-4));
315 const static numeric * n = static_cast<const numeric *>(e.bp);
319 const ex & _ex_4(void)
321 static ex * e = new ex(_num_4());
326 const numeric & _num_3(void)
328 const static ex e = ex(numeric(-3));
329 const static numeric * n = static_cast<const numeric *>(e.bp);
333 const ex & _ex_3(void)
335 static ex * e = new ex(_num_3());
340 const numeric & _num_2(void)
342 const static ex e = ex(numeric(-2));
343 const static numeric * n = static_cast<const numeric *>(e.bp);
347 const ex & _ex_2(void)
349 static ex * e = new ex(_num_2());
354 const numeric & _num_1(void)
356 const static ex e = ex(numeric(-1));
357 const static numeric * n = static_cast<const numeric *>(e.bp);
361 const ex & _ex_1(void)
363 static ex * e = new ex(_num_1());
368 const numeric & _num_1_2(void)
370 const static ex e = ex(numeric(-1,2));
371 const static numeric * n = static_cast<const numeric *>(e.bp);
375 const ex & _ex_1_2(void)
377 static ex * e = new ex(_num_1_2());
382 const numeric & _num_1_3(void)
384 const static ex e = ex(numeric(-1,3));
385 const static numeric * n = static_cast<const numeric *>(e.bp);
389 const ex & _ex_1_3(void)
391 static ex * e = new ex(_num_1_3());
396 const numeric & _num_1_4(void)
398 const static ex e = ex(numeric(-1,4));
399 const static numeric * n = static_cast<const numeric *>(e.bp);
403 const ex & _ex_1_4(void)
405 static ex * e = new ex(_num_1_4());
410 const numeric & _num0(void)
412 const static ex e = ex(numeric(0));
413 const static numeric * n = static_cast<const numeric *>(e.bp);
417 const ex & _ex0(void)
419 static ex * e = new ex(_num0());
424 const numeric & _num1_4(void)
426 const static ex e = ex(numeric(1,4));
427 const static numeric * n = static_cast<const numeric *>(e.bp);
431 const ex & _ex1_4(void)
433 static ex * e = new ex(_num1_4());
438 const numeric & _num1_3(void)
440 const static ex e = ex(numeric(1,3));
441 const static numeric * n = static_cast<const numeric *>(e.bp);
445 const ex & _ex1_3(void)
447 static ex * e = new ex(_num1_3());
452 const numeric & _num1_2(void)
454 const static ex e = ex(numeric(1,2));
455 const static numeric * n = static_cast<const numeric *>(e.bp);
459 const ex & _ex1_2(void)
461 static ex * e = new ex(_num1_2());
466 const numeric & _num1(void)
468 const static ex e = ex(numeric(1));
469 const static numeric * n = static_cast<const numeric *>(e.bp);
473 const ex & _ex1(void)
475 static ex * e = new ex(_num1());
480 const numeric & _num2(void)
482 const static ex e = ex(numeric(2));
483 const static numeric * n = static_cast<const numeric *>(e.bp);
487 const ex & _ex2(void)
489 static ex * e = new ex(_num2());
494 const numeric & _num3(void)
496 const static ex e = ex(numeric(3));
497 const static numeric * n = static_cast<const numeric *>(e.bp);
501 const ex & _ex3(void)
503 static ex * e = new ex(_num3());
508 const numeric & _num4(void)
510 const static ex e = ex(numeric(4));
511 const static numeric * n = static_cast<const numeric *>(e.bp);
515 const ex & _ex4(void)
517 static ex * e = new ex(_num4());
522 const numeric & _num5(void)
524 const static ex e = ex(numeric(5));
525 const static numeric * n = static_cast<const numeric *>(e.bp);
529 const ex & _ex5(void)
531 static ex * e = new ex(_num5());
536 const numeric & _num6(void)
538 const static ex e = ex(numeric(6));
539 const static numeric * n = static_cast<const numeric *>(e.bp);
543 const ex & _ex6(void)
545 static ex * e = new ex(_num6());
550 const numeric & _num7(void)
552 const static ex e = ex(numeric(7));
553 const static numeric * n = static_cast<const numeric *>(e.bp);
557 const ex & _ex7(void)
559 static ex * e = new ex(_num7());
564 const numeric & _num8(void)
566 const static ex e = ex(numeric(8));
567 const static numeric * n = static_cast<const numeric *>(e.bp);
571 const ex & _ex8(void)
573 static ex * e = new ex(_num8());
578 const numeric & _num9(void)
580 const static ex e = ex(numeric(9));
581 const static numeric * n = static_cast<const numeric *>(e.bp);
585 const ex & _ex9(void)
587 static ex * e = new ex(_num9());
592 const numeric & _num10(void)
594 const static ex e = ex(numeric(10));
595 const static numeric * n = static_cast<const numeric *>(e.bp);
599 const ex & _ex10(void)
601 static ex * e = new ex(_num10());
606 const numeric & _num11(void)
608 const static ex e = ex(numeric(11));
609 const static numeric * n = static_cast<const numeric *>(e.bp);
613 const ex & _ex11(void)
615 static ex * e = new ex(_num11());
620 const numeric & _num12(void)
622 const static ex e = ex(numeric(12));
623 const static numeric * n = static_cast<const numeric *>(e.bp);
627 const ex & _ex12(void)
629 static ex * e = new ex(_num12());
634 const numeric & _num15(void)
636 const static ex e = ex(numeric(15));
637 const static numeric * n = static_cast<const numeric *>(e.bp);
641 const ex & _ex15(void)
643 static ex * e = new ex(_num15());
648 const numeric & _num18(void)
650 const static ex e = ex(numeric(18));
651 const static numeric * n = static_cast<const numeric *>(e.bp);
655 const ex & _ex18(void)
657 static ex * e = new ex(_num18());
662 const numeric & _num20(void)
664 const static ex e = ex(numeric(20));
665 const static numeric * n = static_cast<const numeric *>(e.bp);
669 const ex & _ex20(void)
671 static ex * e = new ex(_num20());
676 const numeric & _num24(void)
678 const static ex e = ex(numeric(24));
679 const static numeric * n = static_cast<const numeric *>(e.bp);
683 const ex & _ex24(void)
685 static ex * e = new ex(_num24());
690 const numeric & _num25(void)
692 const static ex e = ex(numeric(25));
693 const static numeric * n = static_cast<const numeric *>(e.bp);
697 const ex & _ex25(void)
699 static ex * e = new ex(_num25());
704 const numeric & _num30(void)
706 const static ex e = ex(numeric(30));
707 const static numeric * n = static_cast<const numeric *>(e.bp);
711 const ex & _ex30(void)
713 static ex * e = new ex(_num30());
718 const numeric & _num48(void)
720 const static ex e = ex(numeric(48));
721 const static numeric * n = static_cast<const numeric *>(e.bp);
725 const ex & _ex48(void)
727 static ex * e = new ex(_num48());
732 const numeric & _num60(void)
734 const static ex e = ex(numeric(60));
735 const static numeric * n = static_cast<const numeric *>(e.bp);
739 const ex & _ex60(void)
741 static ex * e = new ex(_num60());
746 const numeric & _num120(void)
748 const static ex e = ex(numeric(120));
749 const static numeric * n = static_cast<const numeric *>(e.bp);
753 const ex & _ex120(void)
755 static ex * e = new ex(_num120());
759 // comment skeleton for header files
764 // default ctor, dtor, copy ctor assignment operator and helpers
770 // functions overriding virtual functions from bases classes
773 // new virtual functions which can be overridden by derived classes
776 // non-virtual functions in this class
784 // comment skeleton for implementation files
788 // default ctor, dtor, copy ctor assignment operator and helpers
802 // functions overriding virtual functions from bases classes
810 // new virtual functions which can be overridden by derived classes
818 // non-virtual functions in this class
826 // static member variables