factory
cf_util.cc
Go to the documentation of this file.
1
/* emacs edit mode for this file is -*- C++ -*- */
2
3
/**
4
*
5
* @file cf_util.cc
6
*
7
* miscellaneous functions, not necessarily related
8
* to canonical forms.
9
*
10
* Used by: fac_cantzass.cc, gfops.cc
11
*
12
**/
13
14
15
#include "config.h"
16
17
18
/** int ipower ( int b, int m )
19
*
20
* ipower() - calculate b^m in standard integer arithmetic.
21
*
22
* Note: Beware of overflows.
23
*
24
**/
25
int
ipower
(
int
b
,
int
m
)
26
{
27
int
prod
= 1;
28
29
while
( m != 0 )
30
{
31
if
( m % 2 != 0 )
32
prod *=
b
;
33
m /= 2;
34
if
( m != 0 )
35
b *=
b
;
36
}
37
return
prod
;
38
}
39
40
int
ilog2
(
int
a
)
41
{
42
int
n = -1;
43
while
( a > 0 )
44
{
45
n++;
46
a /=2;
47
}
48
return
n;
49
}
50
51
int
igcd
(
int
a
,
int
b
)
52
{
53
if
( a < 0 ) a = -
a
;
54
if
( b < 0 ) b = -
b
;
55
56
int
c;
57
58
while
( b != 0 )
59
{
60
c = a %
b
;
61
a =
b
;
62
b = c;
63
}
64
return
a
;
65
}
66
67
#include<stdio.h>
68
#include<stdlib.h>
69
70
void
factoryError_intern
(
const
char
*
s
)
71
{
72
fputs(s,stderr);
73
abort();
74
}
75
void (*
factoryError
)(
const
char
*
s
) =
factoryError_intern
;
76
77
s
const CanonicalForm int s
Definition:
facAbsFact.cc:55
a
const poly a
Definition:
syzextra.cc:212
igcd
int igcd(int a, int b)
Definition:
cf_util.cc:51
m
int m
Definition:
cfEzgcd.cc:119
ilog2
int ilog2(int a)
Definition:
cf_util.cc:40
ipower
int ipower(int b, int m)
int ipower ( int b, int m )
Definition:
cf_util.cc:25
prod
fq_nmod_poly_t prod
Definition:
facHensel.cc:95
b
const poly b
Definition:
syzextra.cc:213
factoryError_intern
void factoryError_intern(const char *s)
Definition:
cf_util.cc:70
factoryError
void(* factoryError)(const char *s)
Definition:
cf_util.cc:75
Generated on Mon Nov 21 2016 05:25:14 by
doxygen 1.8.12
for
Singular debian-1:4.1.0-p1+ds-1