spielwiese
Last change
on this file since a52291 was
e4fe2b,
checked in by Oleksandr Motsak <motsak@…>, 13 years ago
|
FIX: Fixed huge BUG in cf_gmp.h
CHG: starting to cleanup factory
|
-
Property mode set to
100644
|
File size:
872 bytes
|
Line | |
---|
1 | /* emacs edit mode for this file is -*- C++ -*- */ |
---|
2 | /* $Id$ */ |
---|
3 | |
---|
4 | //{{{ docu |
---|
5 | // |
---|
6 | // cf_util.cc - miscellaneous functions, not necessarily related |
---|
7 | // to canonical forms. |
---|
8 | // |
---|
9 | // Used by: fac_cantzass.cc, gfops.cc |
---|
10 | // |
---|
11 | //}}} |
---|
12 | |
---|
13 | #include "config.h" |
---|
14 | |
---|
15 | //{{{ int ipower ( int b, int m ) |
---|
16 | //{{{ docu |
---|
17 | // |
---|
18 | // ipower() - calculate b^m in standard integer arithmetic. |
---|
19 | // |
---|
20 | // Note: Beware of overflows. |
---|
21 | // |
---|
22 | //}}} |
---|
23 | int ipower ( int b, int m ) |
---|
24 | { |
---|
25 | int prod = 1; |
---|
26 | |
---|
27 | while ( m != 0 ) |
---|
28 | { |
---|
29 | if ( m % 2 != 0 ) |
---|
30 | prod *= b; |
---|
31 | m /= 2; |
---|
32 | if ( m != 0 ) |
---|
33 | b *= b; |
---|
34 | } |
---|
35 | return prod; |
---|
36 | } |
---|
37 | //}}} |
---|
38 | |
---|
39 | int ilog2 (int a) |
---|
40 | { |
---|
41 | int n = -1; |
---|
42 | while ( a > 0 ) |
---|
43 | { |
---|
44 | n++; |
---|
45 | a /=2; |
---|
46 | } |
---|
47 | return n; |
---|
48 | } |
---|
49 | |
---|
50 | #include<stdio.h> |
---|
51 | #include<stdlib.h> |
---|
52 | |
---|
53 | void factoryError_intern(const char *s) |
---|
54 | { |
---|
55 | fputs(s,stderr); |
---|
56 | abort(); |
---|
57 | } |
---|
58 | void (*factoryError)(const char *s) = factoryError_intern; |
---|
59 | |
---|
60 | |
---|
Note: See
TracBrowser
for help on using the repository browser.