MCL
A C++ library mirroring some of the most common Matlab functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
comparisonop.h
Go to the documentation of this file.
1 /*
2  MCL
3  Copyright (c) 2012-18, Enzo De Sena
4  All rights reserved.
5 
6  Authors: Enzo De Sena, enzodesena@gmail.com
7  */
8 
9 
10 #ifndef MCL_EQUALITYOP_H
11 #define MCL_EQUALITYOP_H
12 
13 #ifndef VERY_SMALL
14  #define VERY_SMALL (0.0001f)
15 #endif
16 
17 #include "mcltypes.h"
18 #include "quaternion.h"
19 #include <vector>
20 
21 namespace mcl {
22 
23 
24 bool IsEqual(Real num_a, Real num_b, Real precision = VERY_SMALL);
25 
26 bool IsEqual(Complex num_a, Complex num_b, Real precision = VERY_SMALL);
27 
28 bool IsSmallerOrEqual(const Real num_a, const Real num_b,
29  const Real precision = VERY_SMALL);
30 
31 bool IsLargerOrEqual(const Real num_a, const Real num_b,
32  const Real precision = VERY_SMALL);
33 
34 bool AreAllSmallerOrEqual(const std::vector<Real>& vector_a,
35  const std::vector<Real>& vector_b);
36 
37 template<class T>
38 bool IsEqual(const std::vector<T>& vector_a, const std::vector<T>& vector_b,
39  Real precision = VERY_SMALL) noexcept {
40  if ((Int)vector_a.size() != (Int)vector_b.size())
41  return false;
42 
43  for (Int i=0; i<(Int)(Int)vector_a.size(); ++i) {
44  if (! IsEqual(vector_a[i], vector_b[i], precision))
45  return false;
46  }
47  return true;
48 }
49 
50 
51 bool IsEqual(const std::vector<Int>& vector_a, const std::vector<Int>& vector_b);
52 
53 bool IsEqual(const Quaternion& quaternion_a, const Quaternion& quaternion_b);
54 
55 
56 
57 bool IsEqual(const Point& point_a, const Point& point_b,
58  const Real precision = VERY_SMALL);
59 
60 bool IsEqual(std::vector<Point> points_a, std::vector<Point> points_b);
61 
62 bool IsEqual(const Real* input_data_a, const Real* input_data_b,
63  const Int num_samples, Real precision = VERY_SMALL);
64 
65 bool IsEqual(const Real* input_data_a, const std::vector<Real> input_data_b,
66  Real precision = VERY_SMALL);
67 
68 bool IsEqual(const std::vector<Real> input_data_b, const Real* input_data_a,
69  Real precision = VERY_SMALL);
70 
72 bool IsNan(Real num);
73 
75 std::vector<bool> IsNan(std::vector<Real> input);
76 
78 std::vector<bool> Not(std::vector<bool> input);
79 
81 bool All(std::vector<bool> input);
82 
84 bool Any(std::vector<bool> input);
85 
87 bool None(std::vector<bool> input);
88 
90 bool IsInf(Real num);
91 
93 std::vector<bool> IsInf(std::vector<Real> input);
94 
95 bool ComparisonOpTest();
96 
97 
98 
99 } // namespace mcl
100 
101 
102 
103 #endif