11 #ifndef _CUSTOMDISTANCE_H___
12 #define _CUSTOMDISTANCE_H___
60 const float64_t* dm, int32_t rows, int32_t cols);
73 const float32_t* dm, int32_t rows, int32_t cols);
87 virtual bool dummy_init(int32_t rows, int32_t cols);
122 virtual const char*
get_name()
const {
return "CustomDistance"; }
168 const T* dm, int64_t len)
173 int64_t cols = (int64_t) floor(-0.5 +
CMath::sqrt(0.25+2*len));
175 int64_t int32_max=2147483647;
178 SG_ERROR(
"Matrix larger than %d x %d\n", int32_max)
180 if (cols*(cols+1)/2 != len)
182 SG_ERROR(
"dm should be a vector containing a lower triangle matrix, with len=cols*(cols+1)/2 elements\n")
187 SG_DEBUG(
"using custom distance of size %dx%d\n", cols,cols)
195 for (int64_t i=0; i<len; i++)
213 const float64_t* dm, int32_t rows, int32_t cols)
229 const float32_t* dm, int32_t rows, int32_t cols)
244 const T* dm, int32_t rows, int32_t cols)
249 SG_DEBUG(
"using custom distance of size %dx%d\n", cols,cols)
257 for (int64_t row=0; row<
num_rows; row++)
259 for (int64_t col=row; col<
num_cols; col++)
261 int64_t idx=row * num_cols - row*(row+1)/2 + col;
279 const float64_t* dm, int32_t rows, int32_t cols)
294 const float32_t* dm, int32_t rows, int32_t cols)
310 SG_DEBUG(
"using custom distance of size %dx%d\n", rows,cols)
318 for (int32_t row=0; row<
num_rows; row++)
320 for (int32_t col=0; col<
num_cols; col++)
322 dmatrix[row * num_cols + col]=dm[col*num_rows+row];
370 void cleanup_custom();
bool set_triangle_distance_matrix_from_full(const float64_t *dm, int32_t rows, int32_t cols)
virtual float64_t compute(int32_t row, int32_t col)
bool set_triangle_distance_matrix_from_triangle(const float32_t *dm, int32_t len)
Class Distance, a base class for all the distances used in the Shogun toolbox.
virtual int32_t get_num_vec_lhs()
virtual bool dummy_init(int32_t rows, int32_t cols)
bool set_triangle_distance_matrix_from_full_generic(const T *dm, int32_t rows, int32_t cols)
EFeatureClass
shogun feature class
virtual int32_t get_num_vec_rhs()
bool set_triangle_distance_matrix_from_triangle_generic(const T *dm, int64_t len)
bool set_full_distance_matrix_from_full(const float64_t *dm, int32_t rows, int32_t cols)
virtual EFeatureClass get_feature_class()
EFeatureType
shogun feature type
bool set_triangle_distance_matrix_from_full(const float32_t *dm, int32_t rows, int32_t cols)
virtual EFeatureType get_feature_type()
all of classes and functions are contained in the shogun namespace
The class Features is the base class of all feature objects.
bool set_full_distance_matrix_from_full_generic(const T *dm, int32_t rows, int32_t cols)
virtual ~CCustomDistance()
virtual bool init(CFeatures *l, CFeatures *r)
The Custom Distance allows for custom user provided distance matrices.
static float32_t sqrt(float32_t x)
virtual bool has_features()
bool set_full_distance_matrix_from_full(const float32_t *dm, int32_t rows, int32_t cols)
virtual EDistanceType get_distance_type()
bool set_triangle_distance_matrix_from_triangle(const float64_t *dm, int32_t len)
virtual const char * get_name() const