89template<
typename DATATYPE,
typename DIMTYPE,
class SUBSET>
90class Distance_L1 :
public Clonable_Impl<Distance_L1<DATATYPE,DIMTYPE,SUBSET>,Distance<DATATYPE,DIMTYPE,SUBSET> > {
94 Distance_L1() {
notify(
"Distance_L1 (empty) constructor.");}
101 virtual DATATYPE
distance(
const DATATYPE *pattern1,
const DATATYPE *pattern2)
override;
105 virtual std::ostream&
print(std::ostream& os)
const override {os <<
"Distance_L1()";
return os;}
108template<
typename DATATYPE,
typename DIMTYPE,
class SUBSET>
113 assert(pattern1!=
nullptr);
114 assert(pattern2!=
nullptr);
119 result+=std::abs(pattern1[index_i]-pattern2[index_i]);
CRTP mixin implementing the Clonable protocol for a concrete class.
Definition clonable.hpp:184
Implements L_1 (city-block / Manhattan) distance.
Definition distance_L1.hpp:90
virtual DATATYPE distance(const DATATYPE *pattern1, const DATATYPE *pattern2) override
Distance between two raw patterns over the currently active features only. Reads exactly get_d() entr...
Definition distance_L1.hpp:109
Clonable_Impl< Distance_L1, parent > parent_impl
implements clone(); sharing/stateless_clone throw in Distance
Definition distance_L1.hpp:93
virtual std::ostream & print(std::ostream &os) const override
writes a human-readable identification of the object; base default writes nothing
Definition distance_L1.hpp:105
Distance_L1(const DIMTYPE n)
Constructs and immediately reset()s for n raw features (see Distance::reset()).
Definition distance_L1.hpp:96
Distance_L1(const Distance_L1 &dl1)
Copy-constructor; delegates to parent_impl (deep-copies the current _index[] mapping).
Definition distance_L1.hpp:98
Distance< DATATYPE, DIMTYPE, SUBSET > parent
base class: the abstract distance interface
Definition distance_L1.hpp:92
Abstract class, defines interface for distance evaluators to be used in Classifier_kNN.
Definition distance.hpp:89
DIMTYPE _d
currently active feature count (see get_d())
Definition distance.hpp:128
void reset(const DIMTYPE n)
Allocates for n raw features and makes _index[] the identity map 0..n-1, with all n features active (...
Definition distance.hpp:142
std::unique_ptr< DIMTYPE[]> _index
maps active-feature position [0,_d) to a raw feature index in [0,_n)
Definition distance.hpp:129
Defines interface for distance evaluators (to be used primarily in Classifier_kNN).
FST4 specific error passing class.
The Feature Selection Toolbox 4 library: every library component – data access, criteria and classifi...
Definition data_accessor.hpp:80
void notify(const std::string msg)
Prints msg followed by a newline via syncout::print(); a no-op unless the preprocessor macro DEBUG is...
Definition global.hpp:112