31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

5.7 <strong>The</strong> mod kernel of type residual ( residual )<br />

1. Definition<br />

Type residual ::mod provides the basic modular arithmetic modulo primes of maximal size<br />

2 26 . Here numbers modulo the prime p are represented by integral doubles in [0, · · · p − 1].<br />

This type cannot be instantiated, so there are only static functions and no constructors.<br />

<strong>The</strong> following functions have the common precondition that p is a prime between 2 and<br />

2 26 .<br />

#include < <strong>LEDA</strong>/numbers/residual.h ><br />

2. Operations<br />

double residual :: reduce of positive(double a, double p)<br />

double residual :: reduce(double a, double p)<br />

double residual :: add(double a, double b, double p)<br />

double residual :: sub(double a, double b, double p)<br />

double residual :: mul(double a, double b, double p)<br />

double residual :: div(double a, double b, double p)<br />

double residual :: negate(double a, double p)<br />

double residual :: inverse(double a, double p)<br />

returns a modulo p for nonnegative integral 0 ≤ a <<br />

2 54<br />

returns a modulo p for any integral a with |a| < 2 54<br />

returns (a + b) mod p where a, b are integral with<br />

|a|, |b| < 2 52<br />

returns (a − b) mod p where a, b are integral with<br />

|a|, |b| < 2 52<br />

returns (a·b) mod p where a, b are integral with |a·b| <<br />

2 53<br />

returns (a · b −1 ) mod p where a, b are integral with<br />

|a| < 2 26 and b ≠ 0 mod p<br />

returns −a mod p for nonnegative a < p<br />

returns the inverse of a modulo p for intergal 0 ≤ a <<br />

p < 2 32

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!