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 /** Integer binary logarithm */
33 unsigned log2(unsigned n)
36 for (k = 0; n > 1; n >>= 1) ++k;
40 /** Compare two pointers (just to establish some sort of canonical order).
41 * @return -1, 0, or 1 */
42 int compare_pointers(const void * a, const void * b)
53 // `construct on first use' chest of numbers
57 const numeric & _num_60(void)
59 const static ex e = ex(numeric(-60));
60 const static numeric * n = static_cast<const numeric *>(e.bp);
64 const ex & _ex_60(void)
66 static ex * e = new ex(_num_60());
71 const numeric & _num_120(void)
73 const static ex e = ex(numeric(-120));
74 const static numeric * n = static_cast<const numeric *>(e.bp);
78 const ex & _ex_120(void)
80 static ex * e = new ex(_num_120());
85 const numeric & _num_30(void)
87 const static ex e = ex(numeric(-30));
88 const static numeric * n = static_cast<const numeric *>(e.bp);
92 const ex & _ex_30(void)
94 static ex * e = new ex(_num_30());
99 const numeric & _num_25(void)
101 const static ex e = ex(numeric(-25));
102 const static numeric * n = static_cast<const numeric *>(e.bp);
106 const ex & _ex_25(void)
108 static ex * e = new ex(_num_25());
113 const numeric & _num_24(void)
115 const static ex e = ex(numeric(-24));
116 const static numeric * n = static_cast<const numeric *>(e.bp);
120 const ex & _ex_24(void)
122 static ex * e = new ex(_num_24());
127 const numeric & _num_20(void)
129 const static ex e = ex(numeric(-20));
130 const static numeric * n = static_cast<const numeric *>(e.bp);
134 const ex & _ex_20(void)
136 static ex * e = new ex(_num_20());
141 const numeric & _num_18(void)
143 const static ex e = ex(numeric(-18));
144 const static numeric * n = static_cast<const numeric *>(e.bp);
148 const ex & _ex_18(void)
150 static ex * e = new ex(_num_18());
155 const numeric & _num_15(void)
157 const static ex e = ex(numeric(-15));
158 const static numeric * n = static_cast<const numeric *>(e.bp);
162 const ex & _ex_15(void)
164 static ex * e = new ex(_num_15());
169 const numeric & _num_12(void)
171 const static ex e = ex(numeric(-12));
172 const static numeric * n = static_cast<const numeric *>(e.bp);
176 const ex & _ex_12(void)
178 static ex * e = new ex(_num_12());
183 const numeric & _num_11(void)
185 const static ex e = ex(numeric(-11));
186 const static numeric * n = static_cast<const numeric *>(e.bp);
190 const ex & _ex_11(void)
192 static ex * e = new ex(_num_11());
197 const numeric & _num_10(void)
199 const static ex e = ex(numeric(-10));
200 const static numeric * n = static_cast<const numeric *>(e.bp);
204 const ex & _ex_10(void)
206 static ex * e = new ex(_num_10());
211 const numeric & _num_9(void)
213 const static ex e = ex(numeric(-9));
214 const static numeric * n = static_cast<const numeric *>(e.bp);
218 const ex & _ex_9(void)
220 static ex * e = new ex(_num_9());
225 const numeric & _num_8(void)
227 const static ex e = ex(numeric(-8));
228 const static numeric * n = static_cast<const numeric *>(e.bp);
232 const ex & _ex_8(void)
234 static ex * e = new ex(_num_8());
239 const numeric & _num_7(void)
241 const static ex e = ex(numeric(-7));
242 const static numeric * n = static_cast<const numeric *>(e.bp);
246 const ex & _ex_7(void)
248 static ex * e = new ex(_num_7());
253 const numeric & _num_6(void)
255 const static ex e = ex(numeric(-6));
256 const static numeric * n = static_cast<const numeric *>(e.bp);
260 const ex & _ex_6(void)
262 static ex * e = new ex(_num_6());
267 const numeric & _num_5(void)
269 const static ex e = ex(numeric(-5));
270 const static numeric * n = static_cast<const numeric *>(e.bp);
274 const ex & _ex_5(void)
276 static ex * e = new ex(_num_5());
281 const numeric & _num_4(void)
283 const static ex e = ex(numeric(-4));
284 const static numeric * n = static_cast<const numeric *>(e.bp);
288 const ex & _ex_4(void)
290 static ex * e = new ex(_num_4());
295 const numeric & _num_3(void)
297 const static ex e = ex(numeric(-3));
298 const static numeric * n = static_cast<const numeric *>(e.bp);
302 const ex & _ex_3(void)
304 static ex * e = new ex(_num_3());
309 const numeric & _num_2(void)
311 const static ex e = ex(numeric(-2));
312 const static numeric * n = static_cast<const numeric *>(e.bp);
316 const ex & _ex_2(void)
318 static ex * e = new ex(_num_2());
323 const numeric & _num_1(void)
325 const static ex e = ex(numeric(-1));
326 const static numeric * n = static_cast<const numeric *>(e.bp);
330 const ex & _ex_1(void)
332 static ex * e = new ex(_num_1());
337 const numeric & _num_1_2(void)
339 const static ex e = ex(numeric(-1,2));
340 const static numeric * n = static_cast<const numeric *>(e.bp);
344 const ex & _ex_1_2(void)
346 static ex * e = new ex(_num_1_2());
351 const numeric & _num_1_3(void)
353 const static ex e = ex(numeric(-1,3));
354 const static numeric * n = static_cast<const numeric *>(e.bp);
358 const ex & _ex_1_3(void)
360 static ex * e = new ex(_num_1_3());
365 const numeric & _num_1_4(void)
367 const static ex e = ex(numeric(-1,4));
368 const static numeric * n = static_cast<const numeric *>(e.bp);
372 const ex & _ex_1_4(void)
374 static ex * e = new ex(_num_1_4());
379 const numeric & _num0(void)
381 const static ex e = ex(numeric(0));
382 const static numeric * n = static_cast<const numeric *>(e.bp);
386 const ex & _ex0(void)
388 static ex * e = new ex(_num0());
393 const numeric & _num1_4(void)
395 const static ex e = ex(numeric(1,4));
396 const static numeric * n = static_cast<const numeric *>(e.bp);
400 const ex & _ex1_4(void)
402 static ex * e = new ex(_num1_4());
407 const numeric & _num1_3(void)
409 const static ex e = ex(numeric(1,3));
410 const static numeric * n = static_cast<const numeric *>(e.bp);
414 const ex & _ex1_3(void)
416 static ex * e = new ex(_num1_3());
421 const numeric & _num1_2(void)
423 const static ex e = ex(numeric(1,2));
424 const static numeric * n = static_cast<const numeric *>(e.bp);
428 const ex & _ex1_2(void)
430 static ex * e = new ex(_num1_2());
435 const numeric & _num1(void)
437 const static ex e = ex(numeric(1));
438 const static numeric * n = static_cast<const numeric *>(e.bp);
442 const ex & _ex1(void)
444 static ex * e = new ex(_num1());
449 const numeric & _num2(void)
451 const static ex e = ex(numeric(2));
452 const static numeric * n = static_cast<const numeric *>(e.bp);
456 const ex & _ex2(void)
458 static ex * e = new ex(_num2());
463 const numeric & _num3(void)
465 const static ex e = ex(numeric(3));
466 const static numeric * n = static_cast<const numeric *>(e.bp);
470 const ex & _ex3(void)
472 static ex * e = new ex(_num3());
477 const numeric & _num4(void)
479 const static ex e = ex(numeric(4));
480 const static numeric * n = static_cast<const numeric *>(e.bp);
484 const ex & _ex4(void)
486 static ex * e = new ex(_num4());
491 const numeric & _num5(void)
493 const static ex e = ex(numeric(5));
494 const static numeric * n = static_cast<const numeric *>(e.bp);
498 const ex & _ex5(void)
500 static ex * e = new ex(_num5());
505 const numeric & _num6(void)
507 const static ex e = ex(numeric(6));
508 const static numeric * n = static_cast<const numeric *>(e.bp);
512 const ex & _ex6(void)
514 static ex * e = new ex(_num6());
519 const numeric & _num7(void)
521 const static ex e = ex(numeric(7));
522 const static numeric * n = static_cast<const numeric *>(e.bp);
526 const ex & _ex7(void)
528 static ex * e = new ex(_num7());
533 const numeric & _num8(void)
535 const static ex e = ex(numeric(8));
536 const static numeric * n = static_cast<const numeric *>(e.bp);
540 const ex & _ex8(void)
542 static ex * e = new ex(_num8());
547 const numeric & _num9(void)
549 const static ex e = ex(numeric(9));
550 const static numeric * n = static_cast<const numeric *>(e.bp);
554 const ex & _ex9(void)
556 static ex * e = new ex(_num9());
561 const numeric & _num10(void)
563 const static ex e = ex(numeric(10));
564 const static numeric * n = static_cast<const numeric *>(e.bp);
568 const ex & _ex10(void)
570 static ex * e = new ex(_num10());
575 const numeric & _num11(void)
577 const static ex e = ex(numeric(11));
578 const static numeric * n = static_cast<const numeric *>(e.bp);
582 const ex & _ex11(void)
584 static ex * e = new ex(_num11());
589 const numeric & _num12(void)
591 const static ex e = ex(numeric(12));
592 const static numeric * n = static_cast<const numeric *>(e.bp);
596 const ex & _ex12(void)
598 static ex * e = new ex(_num12());
603 const numeric & _num15(void)
605 const static ex e = ex(numeric(15));
606 const static numeric * n = static_cast<const numeric *>(e.bp);
610 const ex & _ex15(void)
612 static ex * e = new ex(_num15());
617 const numeric & _num18(void)
619 const static ex e = ex(numeric(18));
620 const static numeric * n = static_cast<const numeric *>(e.bp);
624 const ex & _ex18(void)
626 static ex * e = new ex(_num18());
631 const numeric & _num20(void)
633 const static ex e = ex(numeric(20));
634 const static numeric * n = static_cast<const numeric *>(e.bp);
638 const ex & _ex20(void)
640 static ex * e = new ex(_num20());
645 const numeric & _num24(void)
647 const static ex e = ex(numeric(24));
648 const static numeric * n = static_cast<const numeric *>(e.bp);
652 const ex & _ex24(void)
654 static ex * e = new ex(_num24());
659 const numeric & _num25(void)
661 const static ex e = ex(numeric(25));
662 const static numeric * n = static_cast<const numeric *>(e.bp);
666 const ex & _ex25(void)
668 static ex * e = new ex(_num25());
673 const numeric & _num30(void)
675 const static ex e = ex(numeric(30));
676 const static numeric * n = static_cast<const numeric *>(e.bp);
680 const ex & _ex30(void)
682 static ex * e = new ex(_num30());
687 const numeric & _num60(void)
689 const static ex e = ex(numeric(60));
690 const static numeric * n = static_cast<const numeric *>(e.bp);
694 const ex & _ex60(void)
696 static ex * e = new ex(_num60());
701 const numeric & _num120(void)
703 const static ex e = ex(numeric(120));
704 const static numeric * n = static_cast<const numeric *>(e.bp);
708 const ex & _ex120(void)
710 static ex * e = new ex(_num120());
714 // comment skeleton for header files
719 // default constructor, destructor, copy constructor assignment operator and helpers
722 // other constructors
725 // functions overriding virtual functions from bases classes
728 // new virtual functions which can be overridden by derived classes
731 // non-virtual functions in this class
739 // comment skeleton for implementation files
743 // default constructor, destructor, copy constructor assignment operator and helpers
750 // other constructors
757 // functions overriding virtual functions from bases classes
765 // new virtual functions which can be overridden by derived classes
773 // non-virtual functions in this class
781 // static member variables
789 #ifndef NO_NAMESPACE_GINAC
791 #endif // ndef NO_NAMESPACE_GINAC