#ifndef DEF_utils_test
#define DEF_utils_test

#include <cassert>

template<typename T, typename T2>
bool check_almost_equal(const T & a, const T & b, const T2 & tol)
{
    T a_b = a - b;
    return ((a_b < T(0)) ? -a_b : a_b) <= tol;
}

template<typename Vector, typename T>
bool check_almost_equalV(const Vector & v1, const Vector & v2, T tol)
{
    assert(v1.size() == v2.size());
    bool ok = true;
    for(size_t i = 0 ; i < v1.size() ; i++)
    {
        auto v1_v2_i = v1[i] - v2[i];
        if(((v1_v2_i < 0) ? -v1_v2_i : v1_v2_i) > tol)
        {
            ok = false;
            break;
        }
    }
    return ok;
}

#endif
