dlvhex  2.5.0
Distance metrics
Collaboration diagram for 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, 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...
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, 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)
 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)
 Distance computing template function.
template<class BV >
unsigned bm::distance_and_operation (const BV &bv1, const BV &bv2)
 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)
 Distance screening template function.
template<class BV >
bm::id_t bm::count_and (const BV &bv1, const BV &bv2)
 Computes bitcount of AND operation of two bitsets.
template<class BV >
bm::id_t bm::any_and (const BV &bv1, const BV &bv2)
 Computes if there is any bit in AND operation of two bitsets.
template<class BV >
bm::id_t bm::count_xor (const BV &bv1, const BV &bv2)
 Computes bitcount of XOR operation of two bitsets.
template<class BV >
bm::id_t bm::any_xor (const BV &bv1, const BV &bv2)
 Computes if there is any bit in XOR operation of two bitsets.
template<class BV >
bm::id_t bm::count_sub (const BV &bv1, const BV &bv2)
 Computes bitcount of SUB operation of two bitsets.
template<class BV >
bm::id_t bm::any_sub (const BV &bv1, const BV &bv2)
 Computes if there is any bit in SUB operation of two bitsets.
template<class BV >
bm::id_t bm::count_or (const BV &bv1, const BV &bv2)
 Computes bitcount of OR operation of two bitsets.
template<class BV >
bm::id_t bm::any_or (const BV &bv1, const BV &bv2)
 Computes if there is any bit in OR operation of two bitsets.

Detailed Description

Algorithms to compute binary distance metrics


Enumeration Type Documentation

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()

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 55 of file bmalgo_impl.h.

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()

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 55 of file bmalgo_impl.h.


Function Documentation

template<class BV >
bm::id_t bm::any_and ( const BV &  bv1,
const BV &  bv2 
)

Computes if there is any bit in AND operation of two bitsets.

Parameters:
bv1- Argument bit-vector.
bv2- Argument bit-vector.
Returns:
non zero value if there is any bit

Definition at line 995 of file bmalgo_impl.h.

References bm::COUNT_AND, bm::distance_operation_any(), and bm::distance_metric_descriptor::result.

template<class BV >
bm::id_t bm::any_or ( const BV &  bv1,
const BV &  bv2 
)

Computes if there is any bit in OR operation of two bitsets.

Parameters:
bv1- Argument bit-vector.
bv2- Argument bit-vector.
Returns:
non zero value if there is any bit

Definition at line 1097 of file bmalgo_impl.h.

References bm::COUNT_OR, bm::distance_operation_any(), and bm::distance_metric_descriptor::result.

template<class BV >
bm::id_t bm::any_sub ( const BV &  bv1,
const BV &  bv2 
)

Computes if there is any bit in SUB operation of two bitsets.

Parameters:
bv1- Argument bit-vector.
bv2- Argument bit-vector.
Returns:
non zero value if there is any bit

Definition at line 1064 of file bmalgo_impl.h.

References bm::COUNT_SUB_AB, bm::distance_operation_any(), and bm::distance_metric_descriptor::result.

Referenced by ExternalAtomEvaluationHeuristicsEAComplete::doEvaluate().

template<class BV >
bm::id_t bm::any_xor ( const BV &  bv1,
const BV &  bv2 
)

Computes if there is any bit in XOR operation of two bitsets.

Parameters:
bv1- Argument bit-vector.
bv2- Argument bit-vector.
Returns:
non zero value if there is any bit

Definition at line 1029 of file bmalgo_impl.h.

References bm::COUNT_XOR, bm::distance_operation_any(), and bm::distance_metric_descriptor::result.

template<class BV >
bm::id_t bm::count_and ( const BV &  bv1,
const BV &  bv2 
)

Computes bitcount of AND operation of two bitsets.

Parameters:
bv1- Argument bit-vector.
bv2- Argument bit-vector.
Returns:
bitcount of the result

Definition at line 982 of file bmalgo_impl.h.

References bm::distance_and_operation().

template<class BV >
bm::id_t bm::count_or ( const BV &  bv1,
const BV &  bv2 
)

Computes bitcount of OR operation of two bitsets.

Parameters:
bv1- Argument bit-vector.
bv2- Argument bit-vector.
Returns:
bitcount of the result

Definition at line 1081 of file bmalgo_impl.h.

References bm::COUNT_OR, bm::distance_operation(), and bm::distance_metric_descriptor::result.

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

template<class BV >
bm::id_t bm::count_sub ( const BV &  bv1,
const BV &  bv2 
)

Computes bitcount of SUB operation of two bitsets.

Parameters:
bv1- Argument bit-vector.
bv2- Argument bit-vector.
Returns:
bitcount of the result

Definition at line 1047 of file bmalgo_impl.h.

References bm::COUNT_SUB_AB, bm::distance_operation(), and bm::distance_metric_descriptor::result.

template<class BV >
bm::id_t bm::count_xor ( const BV &  bv1,
const BV &  bv2 
)

Computes bitcount of XOR operation of two bitsets.

Parameters:
bv1- Argument bit-vector.
bv2- Argument bit-vector.
Returns:
bitcount of the result

Definition at line 1013 of file bmalgo_impl.h.

References bm::COUNT_XOR, bm::distance_operation(), and bm::distance_metric_descriptor::result.

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

template<class BV >
unsigned 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 783 of file bmalgo_impl.h.

References bm::combine_count_and_operation_with_block(), bm::min_value(), and bm::set_array_size.

Referenced by bm::count_and().

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

Definition at line 693 of file bmalgo_impl.h.

References bm::combine_count_operation_with_block(), bm::distance_stage(), and bm::set_array_size.

Referenced by bm::count_or(), bm::count_sub(), and bm::count_xor().

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 853 of file bmalgo_impl.h.

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

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

distance_metric bm::operation2metric ( set_operation  op) [inline]

Convert set operation into compatible distance metric.

Definition at line 71 of file bmalgo_impl.h.

References bm::is_const_set_operation(), bm::set_COUNT, and bm::set_COUNT_B.

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