diff --git a/src/ext/oxli/counting.hh b/src/ext/oxli/counting.hh index 779755b..cbfe220 100644 --- a/src/ext/oxli/counting.hh +++ b/src/ext/oxli/counting.hh @@ -140,7 +140,7 @@ public: // Writing to the tables outside of defined methods has undefined behavior! // As such, this should only be used to return read-only interfaces - Byte ** get_raw_tables() + Byte ** get_raw_tables() const { return _counts; } diff --git a/src/kernel.cc b/src/kernel.cc index 74fe953..01e9dc1 100644 --- a/src/kernel.cc +++ b/src/kernel.cc @@ -44,7 +44,7 @@ Kernel:: float Kernel:: -kernel(khmer::CountingHash &a, khmer::CountingHash &b) +kernel(const khmer::CountingHash &a, const khmer::CountingHash &b) { _check_hash_dimensions(a, b); return 0.0; @@ -228,7 +228,7 @@ _get_hash(std::string &filename) void Kernel:: -_check_hash_dimensions(khmer::CountingHash &a, khmer::CountingHash &b) +_check_hash_dimensions(const khmer::CountingHash &a, const khmer::CountingHash &b) { size_t i; bool ok = true; diff --git a/src/kernel.hh b/src/kernel.hh index 56096ee..d02755a 100644 --- a/src/kernel.hh +++ b/src/kernel.hh @@ -62,8 +62,8 @@ protected: // Ensure `a` and `b` have the same counting hash dimensions. Throws an // exception if they are not. virtual void - _check_hash_dimensions (khmer::CountingHash &a, - khmer::CountingHash &b); + _check_hash_dimensions (const khmer::CountingHash &a, + const khmer::CountingHash &b); CountingHashShrPtr _get_hash (std::string &filename); @@ -81,8 +81,8 @@ public: // Calculate the kernel between two counting hashes virtual float - kernel (khmer::CountingHash &a, - khmer::CountingHash &b); + kernel (const khmer::CountingHash &a, + const khmer::CountingHash &b); // Calculate the kernel between all pairs of counting hashes in parallel virtual void diff --git a/src/kernels/ip.cc b/src/kernels/ip.cc index e7f5c84..5b910a1 100644 --- a/src/kernels/ip.cc +++ b/src/kernels/ip.cc @@ -23,7 +23,7 @@ namespace metrics { float -IPKernel::kernel(khmer::CountingHash &a, khmer::CountingHash &b) +IPKernel::kernel(const khmer::CountingHash &a, const khmer::CountingHash &b) { std::vector tab_scores; khmer::Byte **a_counts = a.get_raw_tables(); diff --git a/src/kernels/ip.hh b/src/kernels/ip.hh index e29f5b3..94cf3ab 100644 --- a/src/kernels/ip.hh +++ b/src/kernels/ip.hh @@ -29,8 +29,8 @@ namespace metrics class IPKernel : public Kernel { public: - float kernel (khmer::CountingHash &a, - khmer::CountingHash &b); + float kernel (const khmer::CountingHash &a, + const khmer::CountingHash &b); }; }} // end namespace kwip::metrics diff --git a/src/kernels/wip.cc b/src/kernels/wip.cc index d34235e..0b4983a 100644 --- a/src/kernels/wip.cc +++ b/src/kernels/wip.cc @@ -38,7 +38,7 @@ add_hashtable(const std::string &hash_fname) uint64_t tab_count = 0; // Save these here to avoid dereferencing twice below. uint16_t *this_popcount = _pop_counts[tab]; - khmer::Byte *this_count = counts[tab]; + const khmer::Byte *this_count = counts[tab]; for (size_t j = 0; j < _tablesizes[tab]; j++) { if (this_count[j] > 0) { __sync_fetch_and_add(&(this_popcount[j]), 1); @@ -117,18 +117,18 @@ calculate_pairwise(std::vector &hash_fnames) float WIPKernel:: -kernel(khmer::CountingHash &a, khmer::CountingHash &b) +kernel(const khmer::CountingHash &a, const khmer::CountingHash &b) { std::vector tab_kernels; - khmer::Byte **a_counts = a.get_raw_tables(); - khmer::Byte **b_counts = b.get_raw_tables(); + khmer::Byte **a_counts = a.get_raw_tables(); + khmer::Byte **b_counts = b.get_raw_tables(); _check_hash_dimensions(a, b); for (size_t tab = 0; tab < _n_tables; tab++) { double tab_kernel = 0.0; - khmer::Byte *A = a_counts[tab]; - khmer::Byte *B = b_counts[tab]; + const khmer::Byte *A = a_counts[tab]; + const khmer::Byte *B = b_counts[tab]; for (size_t bin = 0; bin < _tablesizes[tab]; bin++) { float bin_entropy = _bin_entropies[tab][bin]; tab_kernel += A[bin] * B[bin] * bin_entropy; diff --git a/src/kernels/wip.hh b/src/kernels/wip.hh index 8044213..5194725 100644 --- a/src/kernels/wip.hh +++ b/src/kernels/wip.hh @@ -38,8 +38,8 @@ public: add_hashtable (const std::string &hash_fname); float - kernel (khmer::CountingHash &a, - khmer::CountingHash &b); + kernel (const khmer::CountingHash &a, + const khmer::CountingHash &b); void calculate_pairwise (std::vector &hash_fnames);