-
Notifications
You must be signed in to change notification settings - Fork 3
/
alvinfractions.cpp
58 lines (44 loc) · 1.49 KB
/
alvinfractions.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "alvinfractions.h"
AlVinFractions::AlVinFractions(vector<AlgebraicInteger *> aiPossibleNorms2)
: aiPossibleNorms2(aiPossibleNorms2),
aiPossibleNorms2_max(aiPossibleNorms2[aiPossibleNorms2.size() - 1]),
iLastMaximum(0), iBatchSize(1) {}
AlVinFractions::~AlVinFractions() {
for (auto i : alvinfractions)
delete i;
for (auto i : aiPossibleNorms2)
delete i;
}
vector<AlVinFraction *> AlVinFractions::getNextAlVinFraction() {
if (!alvinfractions.size()) // Frist call of the function?
{
while (!alvinfractions.size())
computeNextAlVinFractions(); // Compute next fractions
}
if (alvinfractions.size() &&
alvinfractions_it ==
alvinfractions.end()) // All the fractions were tested
{
for (auto i : alvinfractions)
delete i;
alvinfractions.clear();
while (!alvinfractions.size())
computeNextAlVinFractions(); // Compute next fractions
}
vector<AlVinFraction *> vf;
AlgebraicInteger *aiNumerator((*alvinfractions_it)->aiNumerator);
do // We may have to return more than one fraction
{
vf.push_back(*alvinfractions_it);
++alvinfractions_it;
} while (alvinfractions_it != alvinfractions.end() &&
aiNumerator->isEqualTo(*(*alvinfractions_it)->aiNumerator));
return vf;
}
std::vector<AlgebraicInteger *> AlVinFractions::get_aiPossibleNorm2() const {
return aiPossibleNorms2;
}
const std::vector<AlgebraicInteger *> *
AlVinFractions::get_ptraiPossibleNorm2() const {
return &aiPossibleNorms2;
}