From 5f8af5a38ae230ff4b79b104b2b764d928a031b7 Mon Sep 17 00:00:00 2001 From: TimQu Date: Tue, 26 Jun 2018 10:21:31 +0200 Subject: [PATCH] added coordinate utility file --- src/storm/storage/geometry/coordinates.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/storm/storage/geometry/coordinates.h diff --git a/src/storm/storage/geometry/coordinates.h b/src/storm/storage/geometry/coordinates.h new file mode 100644 index 000000000..f2795440f --- /dev/null +++ b/src/storm/storage/geometry/coordinates.h @@ -0,0 +1,24 @@ +#include "storm/utility/constants.h" +#include "storm/utility/macros.h" + +namespace storm { + namespace storage { + namespace geometry { + + template + T euclideanDistance(std::vector const& p, std::vector const& q) { + STORM_LOG_ASSERT(p.size() == q.size(), "Invalid dimensions of input vectors."); + T squaredSum = storm::utility::zero(); + auto pIt = p.begin(); + auto pItE = p.end(); + auto qIt = q.begin(); + for (; pIt != pItE; ++pIt, ++qIt) { + T diff = *pIt - *qIt; + squaredSum += diff * diff; + } + return storm::utility::sqrt(squaredSum); + } + + } + } +} \ No newline at end of file