summaryrefslogtreecommitdiff
path: root/ripser.cpp
diff options
context:
space:
mode:
authorUlrich Bauer <mail@ulrich-bauer.org>2016-12-17 14:05:20 +0100
committerUlrich Bauer <mail@ulrich-bauer.org>2016-12-17 14:05:20 +0100
commit8b42fb2a7885b0e371ff6b0e1bbe31332ae63adb (patch)
tree2a7926fc79cb175ac382c97843141efd4e39621d /ripser.cpp
parentd32402d37998dd0d2c24be8e5a139ebc525a0a56 (diff)
cleanup compressed distance matrix access
Diffstat (limited to 'ripser.cpp')
-rw-r--r--ripser.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/ripser.cpp b/ripser.cpp
index aad196d..0f9d02f 100644
--- a/ripser.cpp
+++ b/ripser.cpp
@@ -206,13 +206,11 @@ template <> void compressed_distance_matrix<UPPER_TRIANGULAR>::init_rows() {
}
template <> value_t compressed_distance_matrix<UPPER_TRIANGULAR>::operator()(index_t i, index_t j) const {
- if (i > j) std::swap(i, j);
- return i == j ? 0 : rows[i][j];
+ return i == j ? 0 : i > j ? rows[j][i] : rows[i][j];
}
template <> value_t compressed_distance_matrix<LOWER_TRIANGULAR>::operator()(index_t i, index_t j) const {
- if (i > j) std::swap(i, j);
- return i == j ? 0 : rows[j][i];
+ return i == j ? 0 : i < j ? rows[j][i] : rows[i][j];
}
typedef compressed_distance_matrix<LOWER_TRIANGULAR> compressed_lower_distance_matrix;