31 int32_t size, int32_t num_cells2,
33 int32_t width_computation_type2,
35 :
CDotKernel(size), num_cells(num_cells2),weights(NULL),
36 width_computation_type(width_computation_type2), width(width2),
37 num_randfeats_forwidthcomputation(-1)
40 SG_ERROR(
"CPyramidChi2 Constructor fatal error: parameter num_cells2 NOT positive")
42 if(weights_foreach_cell2)
45 weights[i]=weights_foreach_cell2[i];
78 CDotKernel::init(l, r);
84 int32_t size, int32_t num_cells2,
86 int32_t width_computation_type2,
88 :
CDotKernel(size), num_cells(num_cells2), weights(NULL),
89 width_computation_type(width_computation_type2), width(width2),
90 num_randfeats_forwidthcomputation(-1)
93 SG_ERROR(
"CPyramidChi2 Constructor fatal error: parameter num_cells2 NOT positive")
95 if(weights_foreach_cell2)
98 weights[i]=weights_foreach_cell2[i];
125 SG_ERROR(
"CPyramidChi2::compute(...) fatal error: parameter num_cells NOT positive")
135 SG_ERROR(
"CPyramidChi2::compute(...) fatal error: lhs feature dim != rhs feature dim")
160 for(int32_t i=0; i< numind;++i)
165 for(int32_t i=0; i< numind;++i)
173 for (int32_t li=0; li < numind;++li)
177 for (int32_t ri=0; ri <=li;++ri)
184 for (int32_t histoind=0; histoind<
num_cells; ++histoind)
188 for (int32_t i=0; i< dims; ++i)
190 int32_t index= histoind*dims+i;
191 if(avec[index] + bvec[index]>0)
193 result+= curweight*(avec[index] - bvec[index])*(avec[index]
194 - bvec[index])/(avec[index] + bvec[index]);
198 width+=result*2.0/((double)numind)/(numind+1.0);
202 SG_FREE(featindices);
206 SG_ERROR(
"CPyramidChi2::compute(...) fatal error: width<=0")
218 for (int32_t histoind=0; histoind<
num_cells; ++histoind)
222 for (int32_t i=0; i< dims; ++i)
224 int32_t index= histoind*dims+i;
225 if(avec[index] + bvec[index]>0)
227 result+= curweight*(avec[index] - bvec[index])*(avec[index]
228 - bvec[index])/(avec[index] + bvec[index]);
243 int32_t width_computation_type2,
252 SG_ERROR(
"CPyramidChi2::setparams_pychi2(...) fatal error: parameter num_cells2 NOT positive")
256 if(weights_foreach_cell2)
259 weights[i]=weights_foreach_cell2[i];
virtual float64_t compute(int32_t idx_a, int32_t idx_b)
virtual bool init(CFeatures *l, CFeatures *r)
Template class DotKernel is the base class for kernels working on DotFeatures.
int32_t width_computation_type
virtual bool init_normalizer()
CFeatures * rhs
feature vectors to occur on right hand side
all of classes and functions are contained in the shogun namespace
int32_t num_randfeats_forwidthcomputation
CFeatures * lhs
feature vectors to occur on left hand side
The class Features is the base class of all feature objects.
static float64_t exp(float64_t x)
static float64_t round(float64_t d)
virtual void setparams_pychi2(int32_t num_cells2, float64_t *weights_foreach_cell2, int32_t width_computation_type2, float64_t width2)