NumCpp  2.13.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
allclose.hpp
Go to the documentation of this file.
1
28#pragma once
29
30#include <cmath>
31#include <string>
32
37#include "NumCpp/NdArray.hpp"
38
39namespace nc
40{
41 //============================================================================
42 // Method Description:
53 template<typename dtype>
55 {
57
58 if (inArray1.shape() != inArray2.shape())
59 {
60 THROW_INVALID_ARGUMENT_ERROR("input array dimensions are not consistant.");
61 }
62
63 for (uint32 i = 0; i < inArray1.size(); ++i)
64 {
65 if (std::abs(inArray1[i] - inArray2[i]) > inTolerance)
66 {
67 return false;
68 }
69 }
70
71 return true;
72 }
73} // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
Definition Cartesian.hpp:40
NdArray< dtype > arange(dtype inStart, dtype inStop, dtype inStep=1)
Definition arange.hpp:59
bool allclose(const NdArray< dtype > &inArray1, const NdArray< dtype > &inArray2, double inTolerance=1e-5)
Definition allclose.hpp:54
std::uint32_t uint32
Definition Types.hpp:40