Skip to content

Commit

Permalink
Add a couple of numerical checks.
Browse files Browse the repository at this point in the history
lisitsyn#53 (comment)
Obviously, this is not to merge.
  • Loading branch information
iglesias committed Apr 8, 2024
1 parent ba5f052 commit 1dddf45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/tapkee/methods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ class ImplementationBase
Neighbors neighbors = findNeighborsWith(kernel_distance);
SparseWeightMatrix weight_matrix =
linear_weight_matrix(begin, end, neighbors, kernel, parameters[nullspace_shift], parameters[klle_shift]);
for (int k = 0; k < weight_matrix.outerSize(); ++k) {
for (Eigen::SparseMatrix<double>::InnerIterator it(weight_matrix, k); it; ++it) {
assert(std::isfinite(it.value()));
}
}
DenseMatrix embedding = eigendecomposition(parameters[eigen_method], parameters[computation_strategy], SmallestEigenvalues,
weight_matrix, parameters[target_dimension])
.first;
Expand Down
9 changes: 9 additions & 0 deletions include/tapkee/neighbors/neighbors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/* End of Tapkee includes */

#include <algorithm>
#include <cmath>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -195,6 +196,14 @@ Neighbors find_neighbors(NeighborsMethod method, const RandomAccessIterator& beg
if (!is_connected(begin, end, neighbors))
LoggingSingleton::instance().message_warning("The neighborhood graph is not connected.");
}
int min_element = 10000000, max_element = -1;
for (auto const& neighbor : neighbors) {
for (auto const& item : neighbor) {
assert(std::isfinite(item));
min_element = std::min(min_element, item);
max_element = std::max(max_element, item);
}
}
return neighbors;
}

Expand Down

0 comments on commit 1dddf45

Please sign in to comment.