basicNumber represents elements of finite Field F_q and finite Ring F_q[epsilon].
Limitation: field element representatives assumed as positive and only values between {0...characterristic-1}
More...
#include <basicNumber.h>
Public Member Functions | |
void | printMultSecure (std::ostream &os) const |
Constructors | |
basicNumber () | |
constructs a basic number {0 + 0*EPS } | |
basicNumber (TScalar s) | |
constructs a basic number {s + 0*EPS } | |
basicNumber (TScalar epsPrecision, std::string s) | |
constructs a basic number, epsPrecision is ignored and assumed =1 | |
basicNumber (TScalar s, TScalar t) | |
constructs a basic number {s + t*EPS } | |
basicNumber (const basicNumber &z) | |
copy constructor | |
properties | |
unsigned short | getEpsPrecision () const |
returns maximum possible epsPrecision (here: 1) | |
void | setEpsPrecision (int epsPrecision) const |
short | getEpsDegree () const |
returns the highest EpsExponent where the coeffitient is not zero. | |
data Access | |
TScalar | getX () const |
returns x | |
TScalar | getEps () const |
returns eps | |
void | setX (TScalar xxx) |
set x= xxx | |
void | setEps (TScalar _eps) |
set eps= _eps | |
TScalar | getValue (TScalar epsPrecision) const |
get coefficient with defined EPSPrecision to {val + coeff*epsPrcision } | |
void | setValue (TScalar epsPrecision, TScalar coeff) |
set coefficient with defined EPSPrecision to {val + coeff*epsPrcision } | |
getset | |
TScalar & | operator[] (int i) |
operators | |
int | nearlyEqual (const basicNumber z) const |
returs true if (z . x == this -> x); eps is ignored! | |
bool | isZero () const |
bool | isNotZero () const |
bool | operator== (const basicNumber z) const |
bool | operator!= (const basicNumber z) const |
Static Public Member Functions | |
safety | |
static bool | memsetClearAllowed () |
returns true, if it is allowed to initialise class objects with memset(0) | |
static bool | wellDefined (unsigned int characteristic) |
checks, if the datatype TScalar is large enough (in bits) to store field element representatives {0...characterristic-1} | |
index computation | |
static size_t | getPairIndex (const basicNumber a, const basicNumber b, const TScalar characteristic) |
static size_t | getPairIndexByRef (const basicNumber &a, const basicNumber &b, const TScalar &characteristic) |
static size_t | getSingleIndex (const basicNumber b, const TScalar characteristic) |
static size_t | getSingleIndexByRef (const basicNumber &b, const TScalar &characteristic) |
static size_t | getMaxSingleIndex (const TScalar characteristic) |
static size_t | getMaxPairIndex (const TScalar characteristic) |
Protected Attributes | |
TScalar | x |
represents x*EPS^0 | |
TScalar | eps |
represents eps*EPS^1 | |
static data | |
| |
typedef TScalar | scalarType |
static const basicNumber | Zero = basicNumber<TScalar>(0) |
represents zero (x=0 and eps=0) | |
static const basicNumber | One = basicNumber<TScalar>(1) |
represents one (x=1 and eps=0) |
Definition at line 59 of file basicNumber.h.
typedef TScalar basicNumber< TScalar >::scalarType |
Definition at line 71 of file basicNumber.h.
basicNumber< TScalar >::basicNumber | ( | ) | [inline] |
Definition at line 29 of file basicNumber.cpp.
basicNumber< TScalar >::basicNumber | ( | TScalar | s | ) | [inline] |
Definition at line 34 of file basicNumber.cpp.
basicNumber< TScalar >::basicNumber | ( | TScalar | epsPrecision, | |
std::string | s | |||
) | [inline] |
Definition at line 39 of file basicNumber.cpp.
basicNumber< TScalar >::basicNumber | ( | TScalar | s, | |
TScalar | t | |||
) | [inline] |
constructs a basic number {s + t*eps }
Definition at line 57 of file basicNumber.cpp.
basicNumber< TScalar >::basicNumber | ( | const basicNumber< TScalar > & | z | ) | [inline] |
Definition at line 51 of file basicNumber.cpp.
TScalar basicNumber< TScalar >::getEps | ( | ) | const [inline] |
Definition at line 116 of file basicNumber.cpp.
References basicNumber< TScalar >::eps.
Referenced by basicNumber< TScalar >::getEpsDegree(), basicNumber< TScalar >::getValue(), basicNumber< TScalar >::operator!=(), and basicNumber< TScalar >::operator==().
short basicNumber< TScalar >::getEpsDegree | ( | ) | const [inline] |
Definition at line 98 of file basicNumber.cpp.
References basicNumber< TScalar >::getEps(), and basicNumber< TScalar >::getX().
unsigned short basicNumber< TScalar >::getEpsPrecision | ( | ) | const [inline] |
Definition at line 91 of file basicNumber.cpp.
size_t basicNumber< TScalar >::getMaxPairIndex | ( | const TScalar | characteristic | ) | [inline, static] |
Definition at line 290 of file basicNumber.cpp.
size_t basicNumber< TScalar >::getMaxSingleIndex | ( | const TScalar | characteristic | ) | [inline, static] |
Definition at line 284 of file basicNumber.cpp.
size_t basicNumber< TScalar >::getPairIndex | ( | const basicNumber< TScalar > | a, | |
const basicNumber< TScalar > | b, | |||
const TScalar | characteristic | |||
) | [inline, static] |
Definition at line 249 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, and basicNumber< TScalar >::x.
size_t basicNumber< TScalar >::getPairIndexByRef | ( | const basicNumber< TScalar > & | a, | |
const basicNumber< TScalar > & | b, | |||
const TScalar & | characteristic | |||
) | [inline, static] |
Definition at line 259 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, and basicNumber< TScalar >::x.
size_t basicNumber< TScalar >::getSingleIndex | ( | const basicNumber< TScalar > | b, | |
const TScalar | characteristic | |||
) | [inline, static] |
Definition at line 268 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, and basicNumber< TScalar >::x.
size_t basicNumber< TScalar >::getSingleIndexByRef | ( | const basicNumber< TScalar > & | b, | |
const TScalar & | characteristic | |||
) | [inline, static] |
Definition at line 276 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, and basicNumber< TScalar >::x.
TScalar basicNumber< TScalar >::getValue | ( | TScalar | epsPrecision | ) | const [inline] |
Definition at line 156 of file basicNumber.cpp.
References basicNumber< TScalar >::getEps(), and basicNumber< TScalar >::getX().
TScalar basicNumber< TScalar >::getX | ( | ) | const [inline] |
Definition at line 110 of file basicNumber.cpp.
References basicNumber< TScalar >::x.
Referenced by basicNumber< TScalar >::getEpsDegree(), basicNumber< TScalar >::getValue(), basicNumber< TScalar >::operator!=(), and basicNumber< TScalar >::operator==().
bool basicNumber< TScalar >::isNotZero | ( | ) | const [inline] |
Definition at line 192 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, and basicNumber< TScalar >::x.
bool basicNumber< TScalar >::isZero | ( | ) | const [inline] |
Definition at line 185 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, and basicNumber< TScalar >::x.
static bool basicNumber< TScalar >::memsetClearAllowed | ( | ) | [inline, static] |
Definition at line 84 of file basicNumber.h.
int basicNumber< TScalar >::nearlyEqual | ( | const basicNumber< TScalar > | z | ) | const [inline] |
comparison; ignores EPS components.
Definition at line 199 of file basicNumber.cpp.
References basicNumber< TScalar >::x.
bool basicNumber< TScalar >::operator!= | ( | const basicNumber< TScalar > | z | ) | const [inline] |
Definition at line 211 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, basicNumber< TScalar >::getEps(), basicNumber< TScalar >::getX(), and basicNumber< TScalar >::x.
bool basicNumber< TScalar >::operator== | ( | const basicNumber< TScalar > | z | ) | const [inline] |
Definition at line 205 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, basicNumber< TScalar >::getEps(), basicNumber< TScalar >::getX(), and basicNumber< TScalar >::x.
TScalar & basicNumber< TScalar >::operator[] | ( | int | i | ) | [inline] |
Definition at line 122 of file basicNumber.cpp.
References basicNumber< TScalar >::eps, and basicNumber< TScalar >::x.
void basicNumber< TScalar >::printMultSecure | ( | std::ostream & | os | ) | const [inline] |
Definition at line 233 of file basicNumber.cpp.
void basicNumber< TScalar >::setEps | ( | TScalar | _eps | ) | [inline] |
Definition at line 174 of file basicNumber.cpp.
References basicNumber< TScalar >::eps.
Referenced by basicNumber< TScalar >::setValue().
void basicNumber< TScalar >::setEpsPrecision | ( | int | epsPrecision | ) | const [inline] |
Definition at line 116 of file basicNumber.h.
void basicNumber< TScalar >::setValue | ( | TScalar | epsPrecision, | |
TScalar | coeff | |||
) | [inline] |
set coeff of e^epsPrecision to 'coeff'. TODO:
Definition at line 140 of file basicNumber.cpp.
References basicNumber< TScalar >::setEps(), and basicNumber< TScalar >::setX().
void basicNumber< TScalar >::setX | ( | TScalar | xxx | ) | [inline] |
Definition at line 168 of file basicNumber.cpp.
References basicNumber< TScalar >::x.
Referenced by basicNumber< TScalar >::setValue().
bool basicNumber< TScalar >::wellDefined | ( | unsigned int | characteristic | ) | [inline, static] |
in the case, that TScalar is signed, sizeof(TScalar) must be one bit greater than nessesary to store positive field element representatives {0...characterristic-1}
Definition at line 61 of file basicNumber.cpp.
References make::test().
TScalar basicNumber< TScalar >::eps [protected] |
Definition at line 65 of file basicNumber.h.
Referenced by basicNumber< TScalar >::getEps(), basicNumber< TScalar >::getPairIndex(), basicNumber< TScalar >::getPairIndexByRef(), basicNumber< TScalar >::getSingleIndex(), basicNumber< TScalar >::getSingleIndexByRef(), basicNumber< TScalar >::isNotZero(), basicNumber< TScalar >::isZero(), basicNumber< TScalar >::operator!=(), basicNumber< TScalar >::operator==(), basicNumber< TScalar >::operator[](), and basicNumber< TScalar >::setEps().
const basicNumber< TScalar > basicNumber< TScalar >::One = basicNumber<TScalar>(1) [inline, static] |
Definition at line 77 of file basicNumber.h.
TScalar basicNumber< TScalar >::x [protected] |
Definition at line 64 of file basicNumber.h.
Referenced by basicNumber< TScalar >::getPairIndex(), basicNumber< TScalar >::getPairIndexByRef(), basicNumber< TScalar >::getSingleIndex(), basicNumber< TScalar >::getSingleIndexByRef(), basicNumber< TScalar >::getX(), basicNumber< TScalar >::isNotZero(), basicNumber< TScalar >::isZero(), basicNumber< TScalar >::nearlyEqual(), basicNumber< TScalar >::operator!=(), basicNumber< TScalar >::operator==(), basicNumber< TScalar >::operator[](), and basicNumber< TScalar >::setX().
const basicNumber< TScalar > basicNumber< TScalar >::Zero = basicNumber<TScalar>(0) [inline, static] |
Definition at line 74 of file basicNumber.h.