Functions | Variables
cf_util.h File Reference

Go to the source code of this file.

Functions

int ilog2 (int a)
 
int igcd (int a, int b)
 
int ipower (int b, int n)
 int ipower ( int b, int m ) More...
 
void factoryError_intern (const char *s)
 

Variables

EXTERN_VAR void(* factoryError )(const char *s)
 

Function Documentation

◆ factoryError_intern()

void factoryError_intern ( const char *  s)

Definition at line 71 of file cf_util.cc.

72 {
73  fputs(s,stderr);
74  abort();
75 }
const CanonicalForm int s
Definition: facAbsFact.cc:55

◆ igcd()

int igcd ( int  a,
int  b 
)

Definition at line 52 of file cf_util.cc.

53 {
54  if ( a < 0 ) a = -a;
55  if ( b < 0 ) b = -b;
56 
57  int c;
58 
59  while ( b != 0 )
60  {
61  c = a % b;
62  a = b;
63  b = c;
64  }
65  return a;
66 }
CanonicalForm b
Definition: cfModGcd.cc:4044

◆ ilog2()

int ilog2 ( int  a)

Definition at line 41 of file cf_util.cc.

42 {
43  int n = -1;
44  while ( a > 0 )
45  {
46  n++;
47  a /=2;
48  }
49  return n;
50 }

◆ ipower()

int ipower ( int  b,
int  m 
)

int ipower ( int b, int m )

ipower() - calculate b^m in standard integer arithmetic.

Note: Beware of overflows.

Definition at line 26 of file cf_util.cc.

27 {
28  int prod = 1;
29 
30  while ( m != 0 )
31  {
32  if ( m % 2 != 0 )
33  prod *= b;
34  m /= 2;
35  if ( m != 0 )
36  b *= b;
37  }
38  return prod;
39 }
CanonicalForm b
Definition: cfModGcd.cc:4044
int m
Definition: cfEzgcd.cc:121
fq_nmod_poly_t prod
Definition: facHensel.cc:95

Variable Documentation

◆ factoryError

EXTERN_VAR void(* factoryError) (const char *s)

Definition at line 14 of file cf_util.h.