diff --git a/Core/Multilayer/Hash2Doubles.cpp b/Core/Multilayer/Hash2Doubles.cpp new file mode 100644 index 0000000000000000000000000000000000000000..68a5eff31a26ceb79d109bb1314b157332506cfb --- /dev/null +++ b/Core/Multilayer/Hash2Doubles.cpp @@ -0,0 +1,22 @@ +// ************************************************************************** // +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file Core/Computation/Hash2Doubles.cpp +//! @brief Implements class Hash2Doubles. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2017 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors J. Burle, J. M. Fisher, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke +// +// ************************************************************************** // + +#include "Hash2Doubles.h" + +// Simple exclusive or of the std::hash<double> of its parts +size_t Hash2Doubles::operator()(std::pair<double, double> doubles) const noexcept +{ + return m_double_hash(doubles.first) ^ m_double_hash(doubles.second); +} diff --git a/Core/Multilayer/Hash2Doubles.h b/Core/Multilayer/Hash2Doubles.h new file mode 100644 index 0000000000000000000000000000000000000000..a8417f02f5a1304e2803ff80f65a5ba94518f82f --- /dev/null +++ b/Core/Multilayer/Hash2Doubles.h @@ -0,0 +1,32 @@ +// +// BornAgain: simulate and fit scattering at grazing incidence +// +//! @file Core/Computation/Hash2Doubles.h +//! @brief Defines class Hash2Doubles. +//! +//! @homepage http://www.bornagainproject.org +//! @license GNU General Public License v3 or higher (see COPYING) +//! @copyright Forschungszentrum Jülich GmbH 2017 +//! @authors Scientific Computing Group at MLZ Garching +//! @authors J. Burle, J. M. Fisher, M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke +// +// ************************************************************************** // + +#ifndef HASH2DOUBLES_H +#define HASH2DOUBLES_H + +#include <functional> +#include <utility> + +class Hash2Doubles +{ +public: + Hash2Doubles() {} + ~Hash2Doubles() {} + + size_t operator()(std::pair<double, double> doubles) const noexcept; +private: + std::hash<double> m_double_hash; +}; + +#endif // HASH2DOUBLES_H diff --git a/Core/Multilayer/HashKVector.cpp b/Core/Multilayer/HashKVector.cpp index 7a375bf59ae689a9535714fbe142e25fe5bc8020..706690ba9cb55914c7301c785925c6de46ffeaa2 100644 --- a/Core/Multilayer/HashKVector.cpp +++ b/Core/Multilayer/HashKVector.cpp @@ -20,8 +20,3 @@ size_t HashKVector::operator()(kvector_t kvec) const noexcept { return m_double_hash(kvec.x()) ^ m_double_hash(kvec.y()) ^ m_double_hash(kvec.z()); } - -size_t Hash2Doubles::operator()(std::pair<double, double> doubles) const noexcept -{ - return m_double_hash(doubles.first) ^ m_double_hash(doubles.second); -} diff --git a/Core/Multilayer/HashKVector.h b/Core/Multilayer/HashKVector.h index baac63fc27396e6c1d1c63b3b2890cba20a8e07e..2adae33b1a5cfe8a59c85217b0165c9c6fe704b6 100644 --- a/Core/Multilayer/HashKVector.h +++ b/Core/Multilayer/HashKVector.h @@ -31,15 +31,4 @@ private: std::hash<double> m_double_hash; }; -class Hash2Doubles -{ -public: - Hash2Doubles() {} - ~Hash2Doubles() {} - - size_t operator()(std::pair<double, double> doubles) const noexcept; -private: - std::hash<double> m_double_hash; -}; - #endif // HASHKVECTOR_H diff --git a/Core/Multilayer/ScalarFresnelMap.h b/Core/Multilayer/ScalarFresnelMap.h index cbb02ffa4a790e9b4d54745c9e7005c366775f33..007d20ad9eb32c90337f5544ca3d87d9466d890a 100644 --- a/Core/Multilayer/ScalarFresnelMap.h +++ b/Core/Multilayer/ScalarFresnelMap.h @@ -16,8 +16,9 @@ #ifndef SCALARFRESNELMAP_H #define SCALARFRESNELMAP_H -#include "HashKVector.h" +#include "Hash2Doubles.h" #include "IFresnelMap.h" +#include "Vectors3D.h" #include <unordered_map> #include <utility> #include <vector>