diff options
author | Ulrich Bauer <mail@ulrich-bauer.org> | 2020-11-25 21:49:42 +0100 |
---|---|---|
committer | Ulrich Bauer <mail@ulrich-bauer.org> | 2020-11-25 21:49:42 +0100 |
commit | d045b5d3873ed6aa45a29cce81634d3c27441d3f (patch) | |
tree | fa50bbe5372e862bd6a72cd7b18ae5113b26fbd1 /ripser.cpp | |
parent | 1c0959db6bf21916937e68dc3266444607022519 (diff) | |
parent | 286d3696796a707eecd0f71e6377880f60c936da (diff) |
Merge branch 'master' into apparent-pairs-new
* master:
fixed documentation: the binary format for distance values is 32 bit, not 64 bit
fixed compile error pointed out by adamConnerSax
fix to read, properly handling premature end of file
endian conversion for binary read
removed examples and development files for master
removed benchmark files
Diffstat (limited to 'ripser.cpp')
-rw-r--r-- | ripser.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -962,10 +962,15 @@ enum file_format { BINARY }; +static const uint16_t endian_check(0xff00); +static const bool is_big_endian = *reinterpret_cast<const uint8_t*>(&endian_check); + template <typename T> T read(std::istream& input_stream) { T result; - input_stream.read(reinterpret_cast<char*>(&result), sizeof(T)); - return result; // on little endian: boost::endian::little_to_native(result); + char* p = reinterpret_cast<char*>(&result); + if (input_stream.read(p, sizeof(T)).gcount() != sizeof(T)) return T(); + if (is_big_endian) std::reverse(p, p + sizeof(T)); + return result; } compressed_lower_distance_matrix read_point_cloud(std::istream& input_stream) { |