|
|
| Distance (const Distance &d) |
| | Copy-constructor; deep-copies the current _index[] mapping (same narrowed/denarrowed state as d).
|
|
void | reset (const DIMTYPE n) |
| | Allocates for n raw features and makes _index[] the identity map 0..n-1, with all n features active (get_d()==get_n()); narrow_to() restricts that.
|
|
void | narrow_to (const PSubset sub) |
| | Restricts distance() to sub's selected features only. Rewrites _index[] to the subset's selected feature indices (raw-feature order) and sets get_d() to the subset size; distance() then reads only those _d entries of a pattern, through _index[], instead of all _n. Precondition: reset() must have been called with n >= the subset size.
|
|
void | denarrow () |
| | Undoes narrow_to(): _index[] reverts to the identity map and get_d() returns to get_n().
|
|
DIMTYPE | get_n () const |
| | the full (raw, unnarrowed) feature count fixed by reset()
|
|
DIMTYPE | get_d () const |
| | the currently active feature count: the narrowed subset size after narrow_to(), get_n() after reset()/denarrow()
|
| virtual DATATYPE | distance (const DATATYPE *pattern1, const DATATYPE *pattern2)=0 |
| | Distance between two raw patterns over the currently active features only. Reads exactly get_d() entries of each pattern, at the raw indices in _index[] (identity unless narrow_to() is in effect) – concrete distances must index through _index[], never assume a contiguous 0..get_d()-1 layout.
|
| Distance * | clone () const override=0 |
| Distance * | sharing_clone () const override |
| Distance * | stateless_clone () const override |
| bool | is_clone () const |
|
bool | is_sharing () const |
| | true if this instance is a sharing_clone() result (referencing, not owning, the source's structures)
|
|
bool | is_sharing_clone () const |
| | true if this instance is BOTH a clone and sharing – i.e. specifically a sharing_clone() result, not a clone()/stateless_clone() one
|
| virtual std::ostream & | print (std::ostream &os) const |
| | writes a human-readable identification of the object; base default writes nothing
|
template<typename DATATYPE, typename DIMTYPE, class SUBSET>
class FST::Distance< DATATYPE, DIMTYPE, SUBSET >
Abstract class, defines interface for distance evaluators to be used in Classifier_kNN.
template<typename DATATYPE, typename DIMTYPE, class SUBSET>
| Distance * FST::Distance< DATATYPE, DIMTYPE, SUBSET >::clone |
( |
| ) |
const |
|
overridepure virtual |
create 1:1 independent clone of the current object. The caller owns the returned object. Families that cannot support a given clone kind implement it to throw fst_error; Clonable_Impl's CLONE_INHERIT slot defers to such a body.
Implements FST::Clonable.
Implemented in FST::Clonable_Impl< Distance_Euclid< DATATYPE, DIMTYPE, SUBSET >, Distance< DATATYPE, DIMTYPE, SUBSET > >, FST::Clonable_Impl< Distance_L1< DATATYPE, DIMTYPE, SUBSET >, Distance< DATATYPE, DIMTYPE, SUBSET > >, and FST::Clonable_Impl< Distance_Lp< DATATYPE, REALTYPE, DIMTYPE, SUBSET, 1, 1 >, Distance< DATATYPE, DIMTYPE, SUBSET > >.
template<typename DATATYPE, typename DIMTYPE, class SUBSET>
| virtual DATATYPE FST::Distance< DATATYPE, DIMTYPE, SUBSET >::distance |
( |
const DATATYPE * | pattern1, |
|
|
const DATATYPE * | pattern2 ) |
|
pure virtual |
Distance between two raw patterns over the currently active features only. Reads exactly get_d() entries of each pattern, at the raw indices in _index[] (identity unless narrow_to() is in effect) – concrete distances must index through _index[], never assume a contiguous 0..get_d()-1 layout.
- Parameters
-
| pattern1,pattern2 | raw feature vectors of at least get_n() entries each |
- Returns
- a non-negative dissimilarity: 0 for identical patterns, larger values mean farther apart. Implementations are free to return any monotone transform of a true distance (e.g. a squared or fractionally powered one), so the value need NOT satisfy the triangle inequality and need not be a metric. Only the induced ORDER of neighbours matters to the callers (Classifier_kNN).
Implemented in FST::Distance_Euclid< DATATYPE, DIMTYPE, SUBSET >, FST::Distance_L1< DATATYPE, DIMTYPE, SUBSET >, and FST::Distance_Lp< DATATYPE, REALTYPE, DIMTYPE, SUBSET, numerator, denominator >.
template<typename DATATYPE, typename DIMTYPE, class SUBSET>
| Distance * FST::Distance< DATATYPE, DIMTYPE, SUBSET >::sharing_clone |
( |
| ) |
const |
|
inlineoverridevirtual |
create equivalent clone of the current object, permitting read-only access to structures in the source object (allows referencing instead of copying of large memory structures). may be faster and save space but requires more caution with respect to concurrency Use example: Data_Accessor memory data representation cloning
Implements FST::Clonable.
template<typename DATATYPE, typename DIMTYPE, class SUBSET>
| Distance * FST::Distance< DATATYPE, DIMTYPE, SUBSET >::stateless_clone |
( |
| ) |
const |
|
inlineoverridevirtual |
create clone of the current object, ignoring internal temporary structures to save speed. Does not replicate exact object state. The clone must be used carefully in a way that ensures internal structure re-initialization Use example: Data_Splitter cloning or Classifier_LIBSVM cloning due to inability to clone external structures defined in LibSVM
Implements FST::Clonable.