19 using namespace shogun;
32 int32_t size, int32_t num_cells2,
34 int32_t width_computation_type2,
36 :
CDotKernel(size), num_cells(num_cells2),weights(NULL),
37 width_computation_type(width_computation_type2), width(width2),
38 num_randfeats_forwidthcomputation(-1)
41 SG_ERROR(
"CPyramidChi2 Constructor fatal error: parameter num_cells2 NOT positive");
43 if(weights_foreach_cell2)
46 weights[i]=weights_foreach_cell2[i];
79 CDotKernel::init(l, r);
85 int32_t size, int32_t num_cells2,
87 int32_t width_computation_type2,
89 :
CDotKernel(size), num_cells(num_cells2), weights(NULL),
90 width_computation_type(width_computation_type2), width(width2),
91 num_randfeats_forwidthcomputation(-1)
94 SG_ERROR(
"CPyramidChi2 Constructor fatal error: parameter num_cells2 NOT positive");
96 if(weights_foreach_cell2)
99 weights[i]=weights_foreach_cell2[i];
126 SG_ERROR(
"CPyramidChi2::compute(...) fatal error: parameter num_cells NOT positive");
136 SG_ERROR(
"CPyramidChi2::compute(...) fatal error: lhs feature dim != rhs feature dim");
161 for(int32_t i=0; i< numind;++i)
166 for(int32_t i=0; i< numind;++i)
174 for (int32_t li=0; li < numind;++li)
178 for (int32_t ri=0; ri <=li;++ri)
185 for (int32_t histoind=0; histoind<
num_cells; ++histoind)
189 for (int32_t i=0; i< dims; ++i)
191 int32_t index= histoind*dims+i;
192 if(avec[index] + bvec[index]>0)
194 result+= curweight*(avec[index] - bvec[index])*(avec[index]
195 - bvec[index])/(avec[index] + bvec[index]);
199 width+=result*2.0/((double)numind)/(numind+1.0);
207 SG_ERROR(
"CPyramidChi2::compute(...) fatal error: width<=0");
219 for (int32_t histoind=0; histoind<
num_cells; ++histoind)
223 for (int32_t i=0; i< dims; ++i)
225 int32_t index= histoind*dims+i;
226 if(avec[index] + bvec[index]>0)
228 result+= curweight*(avec[index] - bvec[index])*(avec[index]
229 - bvec[index])/(avec[index] + bvec[index]);
244 int32_t width_computation_type2,
253 SG_ERROR(
"CPyramidChi2::setparams_pychi2(...) fatal error: parameter num_cells2 NOT positive");
257 if(weights_foreach_cell2)
260 weights[i]=weights_foreach_cell2[i];