My Project  debian-1:4.1.1-p2+ds-4build1
Functions | Variables
ffops.cc File Reference
#include "config.h"
#include <string.h>
#include "cf_assert.h"
#include "cf_defs.h"
#include "ffops.h"

Go to the source code of this file.

Functions

void ff_setprime (const int p)
 
int ff_newinv (const int a)
 
int ff_biginv (const int a)
 

Variables

int ff_prime = 0
 
int ff_halfprime = 0
 
bool ff_big = false
 
short * ff_invtab = new short [32767]
 

Function Documentation

◆ ff_biginv()

int ff_biginv ( const int  a)

Definition at line 71 of file ffops.cc.

72 {
73  if (a < 2)
74  return a;
75  int p, q, r1, r2, y1, y2;
76  r1 = p = ff_prime;
77  q = r1 / a;
78  y1 = -q;
79  r1 -= a * q;
80  if (r1 == 1)
81  return p + y1;
82  r2 = a;
83  y2 = 1;
84  for (;;)
85  {
86  q = r2 / r1;
87  y2 -= y1 * q;
88  r2 -= r1 * q;
89  if (r2 == 1)
90  {
91  if (y2 > 0)
92  return y2;
93  else
94  return p + y2;
95  }
96  q = r1 / r2;
97  y1 -= y2 * q;
98  r1 -= r2 * q;
99  if (r1 == 1)
100  {
101  if (y1 > 0)
102  return y1;
103  else
104  return p + y1;
105  }
106  }
107 }

◆ ff_newinv()

int ff_newinv ( const int  a)

Definition at line 29 of file ffops.cc.

30 {
31  if (a < 2)
32  return (ff_invtab[a] = a);
33  int p, q, r1, r2, y1, y2;
34  r1 = p = ff_prime;
35  q = r1 / a;
36  y1 = -q;
37  r1 -= a * q;
38  if (r1 == 1)
39  {
40  y1 += p;
41  ff_invtab[y1] = a;
42  return (ff_invtab[a] = y1);
43  }
44  r2 = a;
45  y2 = 1;
46  for (;;)
47  {
48  q = r2 / r1;
49  y2 -= y1 * q;
50  r2 -= r1 * q;
51  if (r2 == 1)
52  {
53  if (y2 < 0)
54  y2 += p;
55  ff_invtab[y2] = a;
56  return (ff_invtab[a] = y2);
57  }
58  q = r1 / r2;
59  y1 -= y2 * q;
60  r1 -= r2 * q;
61  if (r1 == 1)
62  {
63  if (y1 < 0)
64  y1 += p;
65  ff_invtab[y1] = a;
66  return (ff_invtab[a] = y1);
67  }
68  }
69 }

◆ ff_setprime()

void ff_setprime ( const int  p)

Definition at line 19 of file ffops.cc.

20 {
21  if ( p != ff_prime ) {
22  ff_prime = p;
23  ff_halfprime = ff_prime / 2;
24  if ( ! ff_big )
25  memset( ff_invtab, 0, ff_prime*sizeof(short) );
26  }
27 }

Variable Documentation

◆ ff_big

bool ff_big = false

Definition at line 16 of file ffops.cc.

◆ ff_halfprime

int ff_halfprime = 0

Definition at line 15 of file ffops.cc.

◆ ff_invtab

short* ff_invtab = new short [32767]

Definition at line 17 of file ffops.cc.

◆ ff_prime

int ff_prime = 0

Definition at line 14 of file ffops.cc.

ff_invtab
short * ff_invtab
Definition: ffops.cc:17
ff_prime
int ff_prime
Definition: ffops.cc:14
ff_big
bool ff_big
Definition: ffops.cc:16
p
int p
Definition: cfModGcd.cc:4019
ff_halfprime
int ff_halfprime
Definition: ffops.cc:15