]> www.ginac.de Git - ginac.git/blob - ginac/utils.cpp
lortensor class
[ginac.git] / ginac / utils.cpp
1 /** @file utils.cpp
2  *
3  *  Implementation of several small and furry utilities. */
4
5 /*
6  *  GiNaC Copyright (C) 1999 Johannes Gutenberg University Mainz, Germany
7  *
8  *  This program is free software; you can redistribute it and/or modify
9  *  it under the terms of the GNU General Public License as published by
10  *  the Free Software Foundation; either version 2 of the License, or
11  *  (at your option) any later version.
12  *
13  *  This program is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  *  GNU General Public License for more details.
17  *
18  *  You should have received a copy of the GNU General Public License
19  *  along with this program; if not, write to the Free Software
20  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
22
23 #include "utils.h"
24
25 #ifndef NO_GINAC_NAMESPACE
26 namespace GiNaC {
27 #endif // ndef NO_GINAC_NAMESPACE
28
29 /** Integer binary logarithm */
30 unsigned log2(unsigned n)
31 {
32     unsigned k;
33     for (k = 0; n > 1; n >>= 1) ++k;
34     return k;
35 }
36
37 /** Compare two pointers (just to establish some sort of canonical order).
38  *  @return -1, 0, or 1 */
39 int compare_pointers(void const * a, void const * b)
40 {
41     if (a<b) {
42         return -1;
43     } else if (a>b) {
44         return 1;
45     }
46     return 0;
47 }
48
49
50 // comment skeleton for header files
51
52
53 // member functions
54
55     // default constructor, destructor, copy constructor assignment operator and helpers
56     // none
57
58     // other constructors
59     // none
60
61     // functions overriding virtual functions from bases classes
62     // none
63     
64     // new virtual functions which can be overridden by derived classes
65     // none
66
67     // non-virtual functions in this class
68     // none
69
70 // member variables
71 // none
72     
73
74
75 // comment skeleton for implementation files
76
77
78 //////////
79 // default constructor, destructor, copy constructor assignment operator and helpers
80 //////////
81
82 // public
83 // protected
84
85 //////////
86 // other constructors
87 //////////
88
89 // public
90 // none
91
92 //////////
93 // functions overriding virtual functions from bases classes
94 //////////
95
96 // public
97 // protected
98 // none
99
100 //////////
101 // new virtual functions which can be overridden by derived classes
102 //////////
103
104 // public
105 // protected
106 // none
107
108 //////////
109 // non-virtual functions in this class
110 //////////
111
112 // public
113 // protected
114 // none
115
116 //////////
117 // static member variables
118 //////////
119
120 // protected
121 // private
122 // none
123
124 #ifndef NO_GINAC_NAMESPACE
125 } // namespace GiNaC
126 #endif // ndef NO_GINAC_NAMESPACE