#ifndef CALC_HPP_ #define CALC_HPP_ #include "data.hpp" #include #include #include namespace calc { template double norm(iter_t first, iter_t last) { return std::sqrt(std::inner_product(first, last, first, 0.0)); } std::pair position_segment(std::vector const& position, double time); void interpolate_positions(std::vector& magnetics, std::vector const& truth); void crop_temporal_inersection(std::vector& magnetics, std::vector const& truth); std::tuple spatial_extent(std::vector const& mag); template void average_grid(grid_t& grid, avg_grid_t& average_grid) { for (size_t x = 0; x < grid.size_x(); x++) { for (size_t y = 0; y < grid.size_y(); y++) { auto const& cell = grid[x][y]; if (cell.size() > 0) { double const sum = std::accumulate(cell.cbegin(), cell.cend(), 0.0); size_t const n = cell.size(); average_grid[x][y] = sum / n; } } } } } // namespace calc #endif // CALC_HPP_