Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Macros
Pages
arithm
field
modfield.cpp
Go to the documentation of this file.
1
12
#include "
modfield.hpp
"
13
14
15
using namespace
arithm;
16
17
18
ModField::ModField
(mpz_class order) :
19
Field
(order)
20
{
21
multOrder
= order - 1;
22
generator
= 2;
23
}
24
25
26
Elmt
ModField::multiplication
(
Elmt
e1,
Elmt
e2)
27
{
28
return
Elmt
((e1.
getValue
() * e2.
getValue
()) %
addOrder
,
this
);
29
}
30
31
32
Elmt
ModField::multInverse
(
Elmt
e)
33
{
34
mpz_class inverseValue;
35
mpz_invert(inverseValue.get_mpz_t(),
36
e.
getValue
().get_mpz_t(),
37
addOrder
.get_mpz_t());
38
return
Elmt
(inverseValue,
this
);
39
}
40
41
42
Elmt
ModField::exponentiation
(
Elmt
e,
Elmt
s)
43
{
44
mpz_class expValue;
45
mpz_powm(expValue.get_mpz_t(),
46
e.
getValue
().get_mpz_t(),
47
s.
getValue
().get_mpz_t(),
48
addOrder
.get_mpz_t());
49
return
Elmt
(expValue,
this
);
50
}
51
52
53
Elmt
ModField::addition
(
Elmt
e1,
Elmt
e2)
54
{
55
return
Elmt
((e1.
getValue
() + e2.
getValue
()) %
addOrder
,
this
);
56
}
57
58
59
Elmt
ModField::addInverse
(
Elmt
e)
60
{
61
return
Elmt
(
addOrder
- e.
getValue
(),
this
);
62
}
63
64
65
std::string
ModField::getType
()
66
{
67
return
"ModField"
;
68
}