DP3
Epsilon.h
Go to the documentation of this file.
1 // Copyright (C) 2020 ASTRON (Netherlands Institute for Radio Astronomy)
2 // SPDX-License-Identifier: GPL-3.0-or-later
3 
7 
8 #ifndef COMMON_EPSILON_H
9 #define COMMON_EPSILON_H
10 
11 #include <cmath>
12 
13 namespace dp3 {
14 namespace common {
15 
19 template <class T>
20 bool EpsilonEqual(const std::vector<T>& left, const std::vector<T>& right,
21  const T& epsilon) {
22  if (left.size() != right.size()) {
23  return false;
24  }
25 
26  for (auto left_it = left.begin(), right_it = right.begin();
27  left_it != left.end(); ++left_it, ++right_it) {
28  if (std::abs(*left_it - *right_it) > epsilon) {
29  return false;
30  }
31  }
32 
33  return true;
34 }
35 
36 } // namespace common
37 } // namespace dp3
38 
39 #endif
bool EpsilonEqual(const std::vector< T > &left, const std::vector< T > &right, const T &epsilon)
Definition: Epsilon.h:20
This file has generic helper routines for testing steps.
Definition: AntennaConfig.h:53