diff options
author | Gard Spreemann <gard.spreemann@epfl.ch> | 2018-03-15 16:45:16 +0100 |
---|---|---|
committer | Gard Spreemann <gard.spreemann@epfl.ch> | 2018-03-15 16:45:16 +0100 |
commit | bcdf9e795ae5c75c87f5b667b5fc9a0e59e31030 (patch) | |
tree | 9ef2c9600007b4eae8d27884841fe2f91e98760b /geom_matching/wasserstein/include/basic_defs_ws.hpp | |
parent | c01bfb9543b1144e2c5adf291eac50c489c501b6 (diff) |
Support for reading persistence diagrams in the DIPHA format.
Diffstat (limited to 'geom_matching/wasserstein/include/basic_defs_ws.hpp')
-rw-r--r-- | geom_matching/wasserstein/include/basic_defs_ws.hpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/geom_matching/wasserstein/include/basic_defs_ws.hpp b/geom_matching/wasserstein/include/basic_defs_ws.hpp index 629a2f8..de25d48 100644 --- a/geom_matching/wasserstein/include/basic_defs_ws.hpp +++ b/geom_matching/wasserstein/include/basic_defs_ws.hpp @@ -25,9 +25,14 @@ derivative works thereof, in binary and source code form. */ +#pragma once + #include <algorithm> #include <cfloat> #include <set> +#include <algorithm> +#include <istream> +#include <cstdint> #include "basic_defs_ws.h" #ifndef FOR_R_TDA @@ -37,6 +42,9 @@ derivative works thereof, in binary and source code form. #include <sstream> namespace hera { +static const int64_t DIPHA_MAGIC = 8067171840; +static const int64_t DIPHA_PERSISTENCE_DIAGRAM = 2; + namespace ws { // Point @@ -190,4 +198,22 @@ std::string format_int(T i) } // end of namespace ws + + +template <typename T> inline void reverse_endianness(T & x) +{ + uint8_t * p = reinterpret_cast<uint8_t *>(&x); + std::reverse(p, p + sizeof(T)); +} + +template <typename T> inline T read_le(std::istream & s) +{ + T result; + s.read(reinterpret_cast<char *>(&result), sizeof(T)); + #ifdef BIGENDIAN + reverse_endianness(result); + #endif + return result; +} + } // hera |