Example demonstrates binary distance metrics. BM library can compute various distances without materializing a product set.
- See also
- bm::count_and
-
bm::count_xor
-
bm::count_sub
-
bm::count_or
-
bm::distance_operation
For more information please visit: http://bmagic.sourceforge.net
#include <iostream>
using namespace std;
{
try
{
bv1[10] = true;
bv1[100] = true;
bv1[10000] = true;
bv2[10] = true;
bv2[100] = true;
bv2[20000] = true;
bv2[30000] = true;
cout << "Hamming distance = " << hamming << endl;
double dice =
cout << "Dice distance = " << dice << endl;
double dice_p =
double(2 * dmd[0].result) / double(dmd[1].result + dmd[2].result);
cout << "Dice distance (pipeline) = " << dice_p << endl;
}
catch(std::exception& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
return 0;
}
Compressed bit-vector bvector<> container, set algebraic methods, traversal iterators.
Algorithms for bvector<> (main include)
pre-processor un-defines to avoid global space pollution (internal)
Bitvector Bit-vector container with runtime compression of bits.
size_type count() const BMNOEXCEPT
population count (count of ON bits)
void distance_operation(const BV &bv1, const BV &bv2, distance_metric_descriptor *dmit, distance_metric_descriptor *dmit_end) BMNOEXCEPT
Distance computing template function.
@ COUNT_AND
(A & B).count()
BV::size_type count_and(const BV &bv1, const BV &bv2) BMNOEXCEPT
Computes bitcount of AND operation of two bitsets.
bm::distance_metric_descriptor::size_type count_xor(const BV &bv1, const BV &bv2) BMNOEXCEPT
Computes bitcount of XOR operation of two bitsets.
Distance metric descriptor, holds metric code and result.