MCPcopy Create free account
hub / github.com/MikeLankamp/fpm / main

Function main

accuracy/accuracy.cpp:85–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85int main()
86{
87 csv_output out_sin("sin.csv");
88 csv_output out_cos("cos.csv");
89 csv_output out_tan("tan.csv");
90 csv_output out_atan2("atan2.csv");
91 for (int angle = -179; angle <= 180; ++angle)
92 {
93 const double val = angle * PI / 180.0;
94
95 check_all(out_sin, val, [](auto x) { return sin(x); }, val);
96 check_all(out_cos, val, [](auto x) { return cos(x); }, val);
97 if ((angle + 90) % 180 != 0)
98 {
99 check_all(out_tan, val, [](auto x) { return tan(x); }, val);
100 }
101
102 const auto y = std::sin(val);
103 const auto x = std::cos(val);
104 check_all(out_atan2, val, [](auto y, auto x) { return atan2(y, x); }, y, x);
105 }
106
107 csv_output out_asin("asin.csv");
108 csv_output out_acos("acos.csv");
109 for (int value = -100; value <= 100; ++value)
110 {
111 const double val = value / 100.0;
112 check_all(out_asin, val, [](auto x) { return asin(x); }, val);
113 check_all(out_acos, val, [](auto x) { return acos(x); }, val);
114 }
115
116 csv_output out_atan("atan.csv");
117 for (int value = -5000; value <= 5000; value += 5)
118 {
119 const double val = value / 1000.0;
120 check_all(out_atan, val, [](auto x) { return atan(x); }, val);
121 }
122
123 csv_output out_sqrt("sqrt.csv");
124 for (int i = 0; i < 1000; ++i)
125 {
126 const auto val = i / 10.0;
127 check_all(out_sqrt, val, [](auto x) { return sqrt(x); }, val);
128 }
129
130 csv_output out_cbrt("cbrt.csv");
131 for (int i = -1000; i < 1000; ++i)
132 {
133 const auto val = i / 10.0;
134 check_fpm(out_cbrt, val, [](auto x) { return cbrt(x); }, val);
135 }
136
137 csv_output out_exp("exp.csv");
138 csv_output out_exp2("exp2.csv");
139 csv_output out_pow("pow.csv");
140 for (int i = -40; i <= 40; i++)
141 {
142 const auto val = i / 10.0;

Callers

nothing calls this directly

Calls 15

check_allFunction · 0.85
check_fpmFunction · 0.85
cbrtFunction · 0.85
exp2Function · 0.85
powFunction · 0.85
log10Function · 0.85
sinFunction · 0.70
cosFunction · 0.70
tanFunction · 0.70
atan2Function · 0.70
asinFunction · 0.70
acosFunction · 0.70

Tested by

no test coverage detected