22 #ifndef CRNLazyDistanceMatrix_HEADER
23 #define CRNLazyDistanceMatrix_HEADER
47 distance(std::forward<DISTANCE>(dist)),
49 cache(d.size(), std::vector<bool>(d.size(),
false))
59 inline size_t GetRows() const noexcept {
return data.size(); }
64 inline size_t GetCols() const noexcept {
return data.size(); }
72 inline double At(
size_t i,
size_t j)
76 distmat[i][j] = distmat[j][i] = distance(data[i], data[j]);
77 cache[i][j] = cache[j][i] =
true;
87 for (
size_t i = 0; i < data.size(); ++i)
88 for (
size_t j = i + 1; j < data.size(); ++j)
96 const std::vector<DATA> &data;
98 std::vector<std::vector<bool>> cache;
double At(size_t i, size_t j)
Distance between two elements.
const SquareMatrixDouble & GetDistanceMatrix()
Access to the whole distance matrix.
Lazy computation of a distance matrix.
LazyDistanceMatrix & operator=(const LazyDistanceMatrix &)=delete
size_t GetCols() const noexcept
Returns the number of columns.
LazyDistanceMatrix(const std::vector< DATA > &d, DISTANCE &&dist)
size_t GetRows() const noexcept
Returns the number of rows.
LazyDistanceMatrix< DATA, DISTANCE > MakeLazyDistanceMatrix(const std::vector< DATA > &d, DISTANCE &&dist)
Helper to avoid typing long type names.
Square double matrix class.