Binary-distance metrics
BitMagic Library » bvector<> container » bvector<> algorithms
Collaboration diagram for Binary-distance metrics:

## Enumerations

enum | bm::distance_metric { bm::COUNT_AND = set_COUNT_AND , bm::COUNT_XOR = set_COUNT_XOR , bm::COUNT_OR = set_COUNT_OR , bm::COUNT_SUB_AB = set_COUNT_SUB_AB , bm::COUNT_SUB_BA = set_COUNT_SUB_BA , bm::COUNT_A = set_COUNT_A , bm::COUNT_B = set_COUNT_B }
| Distance metrics codes defined for vectors A and B. More...

## Functions

distance_metric | bm::operation2metric (set_operation op) BMNOEXCEPT
| Convert set operation into compatible distance metric.
template<class BV>
void | bm::distance_operation (const BV &bv1, const BV &bv2, distance_metric_descriptor *dmit, distance_metric_descriptor *dmit_end) BMNOEXCEPT
| Distance computing template function.
template<class BV>
BV::size_type | bm::distance_and_operation (const BV &bv1, const BV &bv2) BMNOEXCEPT
| Distance AND computing template function.
template<class BV>
void | bm::distance_operation_any (const BV &bv1, const BV &bv2, distance_metric_descriptor *dmit, distance_metric_descriptor *dmit_end) BMNOEXCEPT
| Distance screening template function.

## Detailed Description

Distance metrics and algorithms to compute binary distances

## Enumeration Type Documentation

## distance_metric

enum bm::distance_metric

Distance metrics codes defined for vectors A and B.

Enumerator
COUNT_AND | (A & B).count()
COUNT_XOR | (A ^ B).count()
COUNT_OR | (A | B).count()
COUNT_SUB_AB | (A - B).count()
COUNT_SUB_BA | (B - A).count()
COUNT_A | A.count().
COUNT_B | B.count().

Definition at line 57 of file bmalgo_impl.h.

## Function Documentation

## distance_and_operation()

template<class BV>

BV::size_type bm::distance_and_operation | ( | const BV & | bv1,
|  | const BV & | bv2 )

Distance AND computing template function.

Parameters

  bv1 | - argument bitvector 1 (A)
  bv2 | - argument bitvector 2 (B)

Definition at line 853 of file bmalgo_impl.h.

References BLOCK_ADDR_SAN, BMNOEXCEPT, combine_count_and_operation_with_block(), FULL_BLOCK_FAKE_ADDR, FULL_SUB_BLOCK_REAL_ADDR, min_value(), and set_sub_array_size.

Referenced by count_and().

## distance_operation()

template<class BV>

void bm::distance_operation | ( | const BV & | bv1,
|  | const BV & | bv2,
|  | distance_metric_descriptor * | dmit,
|  | distance_metric_descriptor * | dmit_end )

Distance computing template function.

Function receives two bitvectors and an array of distance metrics (metrics pipeline). Function computes all metrics saves result into corresponding pipeline results (distance_metric_descriptor::result) An important detail is that function reuses metric descriptors, incrementing received values. It allows you to accumulate results from different calls in the pipeline.

Parameters

  bv1 | - argument bitvector 1 (A)
  bv2 | - argument bitvector 2 (B)
  dmit | - pointer to first element of metric descriptors array Input-Output parameter, receives metric code as input, computation is added to "result" field
  dmit_end | - pointer to (last+1) element of metric descriptors array

Examples
  sample9.cpp.

Definition at line 766 of file bmalgo_impl.h.

References BMNOEXCEPT, combine_count_operation_with_block(), distance_stage(), and set_sub_array_size.

Referenced by bm::similarity_batch< SDESCR >::calculate(), count_or(), count_sub(), count_xor(), and main().

## distance_operation_any()

template<class BV>

void bm::distance_operation_any | ( | const BV & | bv1,
|  | const BV & | bv2,
|  | distance_metric_descriptor * | dmit,
|  | distance_metric_descriptor * | dmit_end )

Distance screening template function.

Function receives two bitvectors and an array of distance metrics (metrics pipeline). Function computes possybility of a metric(any bit) saves result into corresponding pipeline results (distance_metric_descriptor::result) An important detail is that function reuses metric descriptors, incrementing received values. It allows you to accumulate results from different calls in the pipeline.

Parameters

  bv1 | - argument bitvector 1 (A)
  bv2 | - argument bitvector 2 (B)
  dmit | - pointer to first element of metric descriptors array Input-Output parameter, receives metric code as input, computation is added to "result" field
  dmit_end | - pointer to (last+1) element of metric descriptors array

Definition at line 922 of file bmalgo_impl.h.

References BM_IS_GAP, BMNOEXCEPT, combine_any_operation_with_block(), distance_stage(), bm::distance_metric_descriptor::result, and set_sub_array_size.

Referenced by any_and(), any_or(), any_sub(), and any_xor().

## operation2metric()

distance_metric bm::operation2metric | ( | set_operation | op | ) |

inline

Convert set operation into compatible distance metric.

Definition at line 73 of file bmalgo_impl.h.

References BM_ASSERT, BMNOEXCEPT, is_const_set_operation(), set_COUNT, and set_COUNT_B.

Referenced by bm::iterator_deserializer< BV, SerialIterator >::deserialize().