-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprint_fixed_point.cpp
57 lines (47 loc) · 1.79 KB
/
print_fixed_point.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
#include <iostream>
#include <memory>
#include <vector>
#include "angular_fixed_point.hpp"
#include "cordic.hpp"
#include "fixed_point.hpp"
#include "generate_constants.hpp"
#include "types.hpp"
typedef AngularFixedPoint<15> Angular;
typedef FixedPoint<2, 13> Linear;
int main() {
constexpr unsigned cordicIterations = 12;
const std::vector<Angular> angleLut =
generateAngleLut<Angular>(cordicIterations);
const Linear cordicGain = generateCordicGain<Linear>(cordicIterations);
CosSinPair<Linear> cosSin;
std::unique_ptr<Cordic<Linear, Angular>> cordic =
std::make_unique<Cordic<Linear, Angular>>(cordicIterations);
std::cout << "Angular::max() " << Angular::max() << std::endl;
std::cout << "Angular::lowest() " << Angular::lowest() << std::endl;
std::cout << "Cordic Angles are :" << std::endl;
for (unsigned i = 0; i < angleLut.size(); i++) {
std::cout << "Angle " << i
<< " is " << angleLut.at(i)
<< std::endl;
}
std::cout << "Cordic Gain is " << cordicGain << std::endl;
cosSin = cordic->calculateCordicCosine(0.4f);
std::cout << "Result of cordic->calculateCordicCosine("
<< Angular(0.4f) << ") is: "
<< "{ cos: " << cosSin.cos
<< ", sin: " << cosSin.sin
<< " }" << std::endl;
cosSin = cordic->calculateCordicCosine(-0.4f);
std::cout << "Result of cordic->calculateCordicCosine("
<< Angular(-0.4f) << ") is: "
<< "{ cos: " << cosSin.cos
<< ", sin: " << cosSin.sin
<< " }" << std::endl;
cosSin = cordic->calculateCordicCosine(-2.f);
std::cout << "Result of cordic->calculateCordicCosine("
<< Angular(-2.f) << ") is: "
<< "{ cos: " << cosSin.cos
<< ", sin: " << cosSin.sin
<< " }" << std::endl;
return 0;
}