summaryrefslogtreecommitdiffhomepage
path: root/compat/correlation-calibrator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'compat/correlation-calibrator.cpp')
-rw-r--r--compat/correlation-calibrator.cpp44
1 files changed, 20 insertions, 24 deletions
diff --git a/compat/correlation-calibrator.cpp b/compat/correlation-calibrator.cpp
index 949f10ae..07ef7d3d 100644
--- a/compat/correlation-calibrator.cpp
+++ b/compat/correlation-calibrator.cpp
@@ -2,6 +2,7 @@
#include "variance.hpp"
#include "compat/math.hpp"
#include "compat/meta.hpp"
+#include "compat/macros.h"
#include <cmath>
#include <iterator>
@@ -11,16 +12,9 @@
#define DEBUG_PRINT
#ifdef DEBUG_PRINT
# include <cstdio>
-# include <cwchar>
- using std::fwprintf;
- using std::fflush;
#endif
-using namespace correlation_calibrator_impl;
-
-correlation_calibrator::correlation_calibrator()
-{
-}
+namespace correlation_calibrator_impl {
static constexpr unsigned nbuckets[6] =
{
@@ -44,26 +38,26 @@ static constexpr double spacing[6] =
roll_spacing_in_degrees,
};
-static constexpr wchar_t const* const names[6] {
- L"x", L"y", L"z",
- L"yaw", L"pitch", L"roll",
+static constexpr char const* const names[6] {
+ "x", "y", "z",
+ "yaw", "pitch", "roll",
};
-bool correlation_calibrator::check_buckets(const vec6 &data)
+bool correlation_calibrator::check_buckets(const vec6& data)
{
bool ret = false;
unsigned pos[6];
for (unsigned k = 0; k < 6; k++)
{
- const double val = clamp(data[k], min[k], max[k]);
- pos[k] = (val-min[k])/spacing[k];
+ const double val = std::clamp(data[k], min[k], max[k]);
+ pos[k] = unsigned((val-min[k])/spacing[k]);
if (pos[k] >= nbuckets[k])
{
- once_only(qDebug() << "idx" << k
+ eval_once(qDebug() << "idx" << k
<< "bucket" << (int)pos[k]
- << "outside bounds" << nbuckets[k]);;
+ << "outside bounds" << nbuckets[k]);
return false;
}
@@ -133,18 +127,18 @@ mat66 correlation_calibrator::get_coefficients() const
cs = cs * (1./(data.size() - 1));
#if defined DEBUG_PRINT
- fwprintf(stderr, L"v:change-of h:due-to\n");
- fwprintf(stderr, L"%10s ", L"");
- for (unsigned k = 0; k < 6; k++)
- fwprintf(stderr, L"%10s", names[k]);
- fwprintf(stderr, L"\n");
+ fprintf(stderr, "v:change-of h:due-to\n");
+ fprintf(stderr, "%10s ", "");
+ for (char const* k : names)
+ fprintf(stderr, "%10s", k);
+ fprintf(stderr, "\n");
for (unsigned i = 0; i < 6; i++)
{
- fwprintf(stderr, L"%10s ", names[i]);
+ fprintf(stderr, "%10s ", names[i]);
for (unsigned k = 0; k < 6; k++)
- fwprintf(stderr, L"%10.3f", cs(i, k));
- fwprintf(stderr, L"\n");
+ fprintf(stderr, "%10.3f", cs(i, k));
+ fprintf(stderr, "\n");
}
fflush(stderr);
#endif
@@ -162,3 +156,5 @@ unsigned correlation_calibrator::sample_count() const
{
return data.size();
}
+
+} // ns correlation_calibrator_impl