Loading...
Searching...
No Matches
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.

## Macros

#define | LIKELY(expression)
| For optimizing if-branches.
#define | UNLIKELY(expression)

## Functions

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

## Variables

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

## Macro Definition Documentation

## LIKELY

#define LIKELY | ( |  | expression | ) |

Value:
(expression)

For optimizing if-branches.

Definition at line 19 of file ffops.cc.

## UNLIKELY

#define UNLIKELY | ( |  | expression | ) |

Value:
(expression)

Definition at line 20 of file ffops.cc.

## Function Documentation

## ff_biginv()

int ff_biginv | ( | const int | a | ) |

Definition at line 81 of file ffops.cc.

{
if (UNLIKELY(a < 2))
return a;
int p, q, r1, r2, y1, y2;
r1 = p = ff_prime;
q = r1 / a;
y1 = -q;
r1 -= a * q;
if (r1 == 1)
return p + y1;
r2 = a;
y2 = 1;
for (;;)
{
q = r2 / r1;
y2 -= y1 * q;
r2 -= r1 * q;
if (r2 == 1)
{
if (y2 > 0)
return y2;
else
return p + y2;
}
q = r1 / r2;
y1 -= y2 * q;
r1 -= r2 * q;
if (r1 == 1)
{
if (y1 > 0)
return y1;
else
return p + y1;
}
}
}
p
int p
Definition cfModGcd.cc:4086
UNLIKELY
#define UNLIKELY(expression)
Definition ffops.cc:20
ff_prime
VAR int ff_prime
Definition ffops.cc:23

## ff_newinv()

int ff_newinv | ( | const int | a | ) |

Definition at line 39 of file ffops.cc.

{
if (a < 2)
return (ff_invtab[a] = a);
int p, q, r1, r2, y1, y2;
r1 = p = ff_prime;
q = r1 / a;
y1 = -q;
r1 -= a * q;
if (r1 == 1)
{
y1 += p;
ff_invtab[y1] = a;
return (ff_invtab[a] = y1);
}
r2 = a;
y2 = 1;
for (;;)
{
q = r2 / r1;
y2 -= y1 * q;
r2 -= r1 * q;
if (r2 == 1)
{
if (y2 < 0)
y2 += p;
ff_invtab[y2] = a;
return (ff_invtab[a] = y2);
}
q = r1 / r2;
y1 -= y2 * q;
r1 -= r2 * q;
if (r1 == 1)
{
if (y1 < 0)
y1 += p;
ff_invtab[y1] = a;
return (ff_invtab[a] = y1);
}
}
}
ff_invtab
VAR short * ff_invtab
Definition ffops.cc:26

## ff_setprime()

void ff_setprime | ( | const int | p | ) |

Definition at line 28 of file ffops.cc.

{
if ( p != ff_prime )
{
ff_prime = p;
ff_halfprime = ff_prime / 2;
if ( ! ff_big )
memset( ff_invtab, 0, ff_prime*sizeof(short) );
}
}
ff_halfprime
VAR int ff_halfprime
Definition ffops.cc:24
ff_big
VAR bool ff_big
Definition ffops.cc:25

## Variable Documentation

## ff_big

VAR bool ff_big = false

Definition at line 25 of file ffops.cc.

## ff_halfprime

VAR int ff_halfprime = 0

Definition at line 24 of file ffops.cc.

## ff_invtab

VAR short* ff_invtab = new short [32767]

Definition at line 26 of file ffops.cc.

## ff_prime

VAR int ff_prime = 0

Definition at line 23 of file ffops.cc.