My Project
Loading...
Searching...
No Matches
Functions | Variables
cf_util.h File Reference
#include "globaldefs.h"

Go to the source code of this file.

Functions

int ilog2 (int a)
 
int igcd (int a, int b)
 
int FACTORY_PUBLIC 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 75 of file cf_util.cc.

76{
77 fputs(s,stderr);
78 abort();
79}
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ igcd()

int igcd ( int  a,
int  b 
)

Definition at line 56 of file cf_util.cc.

57{
58 if ( a < 0 ) a = -a;
59 if ( b < 0 ) b = -b;
60
61 int c;
62
63 while ( b != 0 )
64 {
65 c = a % b;
66 a = b;
67 b = c;
68 }
69 return a;
70}
CanonicalForm b
Definition: cfModGcd.cc:4103

◆ ilog2()

int ilog2 ( int  a)

Definition at line 42 of file cf_util.cc.

43{
44 const unsigned int b[] = {0x2, 0xC, 0xF0, 0xFF00, 0xFFFF0000};
45 const unsigned int S[] = {1, 2, 4, 8, 16};
46
47 unsigned int r = 0; // result of log2(v) will go here
48 if (v & b[4]) { v >>= S[4]; r |= S[4]; }
49 if (v & b[3]) { v >>= S[3]; r |= S[3]; }
50 if (v & b[2]) { v >>= S[2]; r |= S[2]; }
51 if (v & b[1]) { v >>= S[1]; r |= S[1]; }
52 if (v & b[0]) { v >>= S[0]; r |= S[0]; }
53 return (int)r;
54}
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:39

◆ ipower()

int FACTORY_PUBLIC 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 27 of file cf_util.cc.

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

Variable Documentation

◆ factoryError

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

Definition at line 14 of file cf_util.h.