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 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_GINAC_NAMESPACE
30 #endif // ndef NO_GINAC_NAMESPACE
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(void const * a, void const * b)
53 // `construct on first use' chest of numbers
57 numeric const & _num_12(void)
59 const static ex e = ex(numeric(-12));
60 const static numeric * n = static_cast<const numeric *>(e.bp);
64 ex const & _ex_12(void)
66 static ex * e = new ex(_num_12());
71 numeric const & _num_11(void)
73 const static ex e = ex(numeric(-11));
74 const static numeric * n = static_cast<const numeric *>(e.bp);
78 ex const & _ex_11(void)
80 static ex * e = new ex(_num_11());
85 numeric const & _num_10(void)
87 const static ex e = ex(numeric(-10));
88 const static numeric * n = static_cast<const numeric *>(e.bp);
92 ex const & _ex_10(void)
94 static ex * e = new ex(_num_10());
99 numeric const & _num_9(void)
101 const static ex e = ex(numeric(-9));
102 const static numeric * n = static_cast<const numeric *>(e.bp);
106 ex const & _ex_9(void)
108 static ex * e = new ex(_num_9());
113 numeric const & _num_8(void)
115 const static ex e = ex(numeric(-8));
116 const static numeric * n = static_cast<const numeric *>(e.bp);
120 ex const & _ex_8(void)
122 static ex * e = new ex(_num_8());
127 numeric const & _num_7(void)
129 const static ex e = ex(numeric(-7));
130 const static numeric * n = static_cast<const numeric *>(e.bp);
134 ex const & _ex_7(void)
136 static ex * e = new ex(_num_7());
141 numeric const & _num_6(void)
143 const static ex e = ex(numeric(-6));
144 const static numeric * n = static_cast<const numeric *>(e.bp);
148 ex const & _ex_6(void)
150 static ex * e = new ex(_num_6());
155 numeric const & _num_5(void)
157 const static ex e = ex(numeric(-5));
158 const static numeric * n = static_cast<const numeric *>(e.bp);
162 ex const & _ex_5(void)
164 static ex * e = new ex(_num_5());
169 numeric const & _num_4(void)
171 const static ex e = ex(numeric(-4));
172 const static numeric * n = static_cast<const numeric *>(e.bp);
176 ex const & _ex_4(void)
178 static ex * e = new ex(_num_4());
183 numeric const & _num_3(void)
185 const static ex e = ex(numeric(-3));
186 const static numeric * n = static_cast<const numeric *>(e.bp);
190 ex const & _ex_3(void)
192 static ex * e = new ex(_num_3());
197 numeric const & _num_2(void)
199 const static ex e = ex(numeric(-2));
200 const static numeric * n = static_cast<const numeric *>(e.bp);
204 ex const & _ex_2(void)
206 static ex * e = new ex(_num_2());
211 numeric const & _num_1(void)
213 const static ex e = ex(numeric(-1));
214 const static numeric * n = static_cast<const numeric *>(e.bp);
218 ex const & _ex_1(void)
220 static ex * e = new ex(_num_1());
225 numeric const & _num_1_2(void)
227 const static ex e = ex(numeric(-1,2));
228 const static numeric * n = static_cast<const numeric *>(e.bp);
232 ex const & _ex_1_2(void)
234 static ex * e = new ex(_num_1_2());
239 numeric const & _num_1_3(void)
241 const static ex e = ex(numeric(-1,3));
242 const static numeric * n = static_cast<const numeric *>(e.bp);
246 ex const & _ex_1_3(void)
248 static ex * e = new ex(_num_1_3());
253 numeric const & _num0(void)
255 const static ex e = ex(numeric(0));
256 const static numeric * n = static_cast<const numeric *>(e.bp);
260 ex const & _ex0(void)
262 static ex * e = new ex(_num0());
267 numeric const & _num1_3(void)
269 const static ex e = ex(numeric(1,3));
270 const static numeric * n = static_cast<const numeric *>(e.bp);
274 ex const & _ex1_3(void)
276 static ex * e = new ex(_num1_3());
281 numeric const & _num1_2(void)
283 const static ex e = ex(numeric(1,2));
284 const static numeric * n = static_cast<const numeric *>(e.bp);
288 ex const & _ex1_2(void)
290 static ex * e = new ex(_num1_2());
295 numeric const & _num1(void)
297 const static ex e = ex(numeric(1));
298 const static numeric * n = static_cast<const numeric *>(e.bp);
302 ex const & _ex1(void)
304 static ex * e = new ex(_num1());
309 numeric const & _num2(void)
311 const static ex e = ex(numeric(2));
312 const static numeric * n = static_cast<const numeric *>(e.bp);
316 ex const & _ex2(void)
318 static ex * e = new ex(_num2());
323 numeric const & _num3(void)
325 const static ex e = ex(numeric(3));
326 const static numeric * n = static_cast<const numeric *>(e.bp);
330 ex const & _ex3(void)
332 static ex * e = new ex(_num3());
337 numeric const & _num4(void)
339 const static ex e = ex(numeric(4));
340 const static numeric * n = static_cast<const numeric *>(e.bp);
344 ex const & _ex4(void)
346 static ex * e = new ex(_num4());
351 numeric const & _num5(void)
353 const static ex e = ex(numeric(5));
354 const static numeric * n = static_cast<const numeric *>(e.bp);
358 ex const & _ex5(void)
360 static ex * e = new ex(_num5());
365 numeric const & _num6(void)
367 const static ex e = ex(numeric(6));
368 const static numeric * n = static_cast<const numeric *>(e.bp);
372 ex const & _ex6(void)
374 static ex * e = new ex(_num6());
379 numeric const & _num7(void)
381 const static ex e = ex(numeric(7));
382 const static numeric * n = static_cast<const numeric *>(e.bp);
386 ex const & _ex7(void)
388 static ex * e = new ex(_num7());
393 numeric const & _num8(void)
395 const static ex e = ex(numeric(8));
396 const static numeric * n = static_cast<const numeric *>(e.bp);
400 ex const & _ex8(void)
402 static ex * e = new ex(_num8());
407 numeric const & _num9(void)
409 const static ex e = ex(numeric(9));
410 const static numeric * n = static_cast<const numeric *>(e.bp);
414 ex const & _ex9(void)
416 static ex * e = new ex(_num9());
421 numeric const & _num10(void)
423 const static ex e = ex(numeric(10));
424 const static numeric * n = static_cast<const numeric *>(e.bp);
428 ex const & _ex10(void)
430 static ex * e = new ex(_num10());
435 numeric const & _num11(void)
437 const static ex e = ex(numeric(11));
438 const static numeric * n = static_cast<const numeric *>(e.bp);
442 ex const & _ex11(void)
444 static ex * e = new ex(_num11());
449 numeric const & _num12(void)
451 const static ex e = ex(numeric(12));
452 const static numeric * n = static_cast<const numeric *>(e.bp);
456 ex const & _ex12(void)
458 static ex * e = new ex(_num12());
462 // comment skeleton for header files
467 // default constructor, destructor, copy constructor assignment operator and helpers
470 // other constructors
473 // functions overriding virtual functions from bases classes
476 // new virtual functions which can be overridden by derived classes
479 // non-virtual functions in this class
487 // comment skeleton for implementation files
491 // default constructor, destructor, copy constructor assignment operator and helpers
498 // other constructors
505 // functions overriding virtual functions from bases classes
513 // new virtual functions which can be overridden by derived classes
521 // non-virtual functions in this class
529 // static member variables
537 #ifndef NO_GINAC_NAMESPACE
539 #endif // ndef NO_GINAC_NAMESPACE