Skip to content

Commit

Permalink
Merge branch 'constify'
Browse files Browse the repository at this point in the history
Closes #10
  • Loading branch information
kdm9 committed Jan 12, 2016
2 parents be41177 + e6938fb commit b3a5784
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/ext/oxli/counting.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/kernel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/kernel.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/kernels/ip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> tab_scores;
khmer::Byte **a_counts = a.get_raw_tables();
Expand Down
4 changes: 2 additions & 2 deletions src/kernels/ip.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions src/kernels/wip.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -117,18 +117,18 @@ calculate_pairwise(std::vector<std::string> &hash_fnames)

float
WIPKernel::
kernel(khmer::CountingHash &a, khmer::CountingHash &b)
kernel(const khmer::CountingHash &a, const khmer::CountingHash &b)
{
std::vector<float> 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;
Expand Down
4 changes: 2 additions & 2 deletions src/kernels/wip.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> &hash_fnames);
Expand Down

0 comments on commit b3a5784

Please sign in to comment.