Functions | Variables
cf_util.cc File Reference

miscellaneous functions, not necessarily related to canonical forms. More...

#include "config.h"
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

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

Variables

void(* factoryError )(const char *s) = factoryError_intern
 

Detailed Description

miscellaneous functions, not necessarily related to canonical forms.

Used by: fac_cantzass.cc, gfops.cc

Definition in file cf_util.cc.

Function Documentation

◆ factoryError_intern()

void factoryError_intern ( const char *  s)

Definition at line 70 of file cf_util.cc.

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

◆ igcd()

int igcd ( int  a,
int  b 
)

Definition at line 51 of file cf_util.cc.

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 }
CanonicalForm b
Definition: cfModGcd.cc:4044

◆ ilog2()

int ilog2 ( int  a)

Definition at line 40 of file cf_util.cc.

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

◆ 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 25 of file cf_util.cc.

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 }
CanonicalForm b
Definition: cfModGcd.cc:4044
int m
Definition: cfEzgcd.cc:121
fq_nmod_poly_t prod
Definition: facHensel.cc:95

Variable Documentation

◆ factoryError

void(* factoryError) (const char *s) = factoryError_intern

Definition at line 75 of file cf_util.cc.