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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

5.8 <strong>The</strong> smod kernel of type residual ( residual )<br />

1. Definition<br />

Type residual ::smod is a variant of class residual ::mod that uses a signed representation.<br />

Here numbers modulo p are represented by integral doubles in (−p/2, +p/2). All functions<br />

have the common precondition that p is a prime between 3 and 2 26 . <strong>The</strong> functions of type<br />

residual :: mod are also provided for class residual :: smod and have the same meaning, so<br />

we do not list them separately here.<br />

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

2. Operations<br />

double residual :: frac(double a)<br />

3. Creation<br />

returns a + z where z is the unique integer such that<br />

a + z ∈ [−1/2, 1/2)<br />

residual x; creates an instance x of type residual and initializes it with zero.<br />

residual x(long a); creates an instance x of type residual and initializes it with the<br />

value of a.<br />

residual x(int a); creates an instance x of type residual and initializes it with the<br />

value of a.<br />

residual<br />

residual<br />

x(double a);<br />

x(const integer& a);<br />

creates an instance x of type residual and initializes it with the<br />

integral part of x.<br />

creates an instance x of type residual and initializes it with the<br />

value of a.<br />

4. Operations<br />

int<br />

residual :: set maximal bit length(int b, bool with check = do overflow check)<br />

sets the maximal bit size of the representable numbers<br />

to b and returns the previous maximal bit size<br />

int residual :: get maximal bit length( )<br />

returns the maximal bit size of the representable<br />

numbers

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

Saved successfully!

Ooh no, something went wrong!