This class defines integer numbers with overflow control and with some specific properties of an Euclidean domain.
More...
#include <integer.h>
List of all members.
Detailed Description
This class defines integer numbers with overflow control and with some specific properties of an Euclidean domain.
Note that this class has very few features which are limited on purpose to optimize it for application in a chain complex class for homology computation.
Definition at line 134 of file integer.h.
Member Function Documentation
int chomp::homology::integer::cut_down |
( |
int |
n |
) |
[inline, static, protected] |
Definition at line 195 of file integer.h.
References num, and p.
Referenced by operator=().
{
if (n >= 0)
if (n < p)
return n;
else
return (n % p);
else
{
int num = p - ((-n) % p);
if (num == p)
return 0;
else
return num;
}
}
int chomp::homology::integer::delta |
( |
void |
|
) |
const [inline] |
int chomp::homology::integer::initialize |
( |
int |
n |
) |
[inline, static] |
static unsigned chomp::homology::integer::invert |
( |
unsigned |
n, |
|
|
unsigned |
q | |
|
) |
| | [static, protected] |
static int chomp::homology::integer::is_prime |
( |
int |
n |
) |
[static, protected] |
integer chomp::homology::integer::normalized |
( |
void |
|
) |
const [inline] |
integer chomp::homology::integer::operator% |
( |
const integer & |
n |
) |
const [inline] |
Definition at line 265 of file integer.h.
References num, and p.
{
integer result;
if (p)
result. num = 0;
else
result = num % n. num;
return result;
}
integer chomp::homology::integer::operator* |
( |
const integer & |
n |
) |
const [inline] |
Definition at line 338 of file integer.h.
{
integer m (n);
m *= *this;
return m;
}
integer & chomp::homology::integer::operator*= |
( |
const integer & |
n |
) |
[inline] |
Definition at line 307 of file integer.h.
References num, and p.
{
if (p)
{
long result = (long) num * (long) n. num;
if (result >= 0)
num = (numbertype) (result % p);
else
{
num = (numbertype) (p - ((-result) % p));
if (num == p)
num = 0;
}
}
else
{
long result = (long) num * (long) (n. num);
num = (numbertype) result;
if ((long) num != result)
throw "Number out of range (*).";
}
return *this;
}
integer chomp::homology::integer::operator+ |
( |
const integer & |
n |
) |
const [inline] |
Definition at line 331 of file integer.h.
{
integer m (n);
m += *this;
return m;
}
integer & chomp::homology::integer::operator+= |
( |
const integer & |
n |
) |
[inline] |
integer chomp::homology::integer::operator- |
( |
|
) |
const [inline] |
Definition at line 275 of file integer.h.
References num, and p.
{
if (p)
{
integer negative;
negative. num = (numbertype) (p - num);
return negative;
}
else
{
numbertype result = (numbertype) -num;
if ((long) result + (long) num != 0)
throw "Number out of range (unary -).";
integer intresult;
intresult = result;
return intresult;
}
}
integer chomp::homology::integer::operator/ |
( |
const integer & |
n |
) |
const [inline] |
integer & chomp::homology::integer::operator= |
( |
int |
n |
) |
[inline] |
Definition at line 242 of file integer.h.
References cut_down(), num, and p.
{
if (p)
num = (numbertype) cut_down (n);
else
{
num = (numbertype) n;
if ((long) num != (long) n)
throw "Number out of range at assignment.";
}
return *this;
}
int chomp::homology::integer::operator== |
( |
const integer & |
n |
) |
const [inline] |
static int chomp::homology::integer::prime_number |
( |
int |
n |
) |
[static, protected] |
static const char* chomp::homology::integer::ringname |
( |
|
) |
[static] |
static const char* chomp::homology::integer::ringsymbol |
( |
|
) |
[static] |
Friends And Related Function Documentation
std::ostream& operator<< |
( |
std::ostream & |
out, |
|
|
const integer & |
n | |
|
) |
| | [friend] |
Definition at line 350 of file integer.h.
{
out << (long) n. num;
return out;
}
Member Data Documentation
The documentation for this class was generated from the following file: