Line data Source code
1 : // Copyright (C) 2015 Technische Universitaet Muenchen 2 : // This file is part of the Mamico project. For conditions of distribution 3 : // and use, please see the copyright notice in Mamico's main folder, or at 4 : // www5.in.tum.de/mamico 5 : #ifndef _TARCH_LA_SCALAROPERATIONS_H_ 6 : #define _TARCH_LA_SCALAROPERATIONS_H_ 7 : #include <cmath> 8 : #include <Kokkos_Core.hpp> 9 : /** namespace tarch */ 10 : namespace tarch { 11 : /** namespace la */ 12 : namespace la { 13 : 14 : /** This function template checks if the difference of two given numbers is 15 : *smaller than a given tolerance i.e. if they are mathematically equal. 16 : * @tparam T data type 17 : * @param l First number 18 : * @param r Second number 19 : * @param tolerance Tolerance 20 : * @return 1: if they are equal. 0: if the are not equal. 21 : * @author Philipp Neumann 22 : */ 23 : 24 0 : template <class T> KOKKOS_INLINE_FUNCTION bool equals(const T& l, const T& r, const T& tolerance) { return std::abs(l - r) <= tolerance; } 25 : 26 : } // namespace la 27 : } // namespace tarch 28 : #endif