11 #ifndef _CUSTOMDISTANCE_H___
12 #define _CUSTOMDISTANCE_H___
58 const float64_t* dm, int32_t rows, int32_t cols);
71 const float32_t* dm, int32_t rows, int32_t cols);
85 virtual bool dummy_init(int32_t rows, int32_t cols);
120 virtual const char*
get_name()
const {
return "CustomDistance"; }
166 const T* dm, int64_t len)
171 int64_t cols = (int64_t) floor(-0.5 +
CMath::sqrt(0.25+2*len));
173 int64_t int32_max=2147483647;
176 SG_ERROR(
"Matrix larger than %d x %d\n", int32_max)
178 if (cols*(cols+1)/2 != len)
180 SG_ERROR(
"dm should be a vector containing a lower triangle matrix, with len=cols*(cols+1)/2 elements\n")
185 SG_DEBUG(
"using custom distance of size %dx%d\n", cols,cols)
193 for (int64_t i=0; i<len; i++)
211 const float64_t* dm, int32_t rows, int32_t cols)
227 const float32_t* dm, int32_t rows, int32_t cols)
242 const T* dm, int32_t rows, int32_t cols)
247 SG_DEBUG(
"using custom distance of size %dx%d\n", cols,cols)
255 for (int64_t row=0; row<
num_rows; row++)
257 for (int64_t col=row; col<
num_cols; col++)
259 int64_t idx=row * num_cols - row*(row+1)/2 + col;
277 const float64_t* dm, int32_t rows, int32_t cols)
292 const float32_t* dm, int32_t rows, int32_t cols)
308 SG_DEBUG(
"using custom distance of size %dx%d\n", rows,cols)
316 for (int32_t row=0; row<
num_rows; row++)
318 for (int32_t col=0; col<
num_cols; col++)
320 dmatrix[row * num_cols + col]=dm[col*num_rows+row];
368 void cleanup_custom();