|
|
|
@ -330,10 +330,10 @@ void CvSVMKernel::calc_intersec( int vcount, int var_count, const float** vecs, |
|
|
|
|
const float* sample = vecs[j]; |
|
|
|
|
double s = 0; |
|
|
|
|
for( k = 0; k <= var_count - 4; k += 4 ) |
|
|
|
|
s += min(sample[k],another[k]) + min(sample[k+1],another[k+1]) + |
|
|
|
|
min(sample[k+2],another[k+2]) + min(sample[k+3],another[k+3]); |
|
|
|
|
s += std::min(sample[k],another[k]) + std::min(sample[k+1],another[k+1]) + |
|
|
|
|
std::min(sample[k+2],another[k+2]) + std::min(sample[k+3],another[k+3]); |
|
|
|
|
for( ; k < var_count; k++ ) |
|
|
|
|
s += min(sample[k],another[k]); |
|
|
|
|
s += std::min(sample[k],another[k]); |
|
|
|
|
results[j] = (Qfloat)(s); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -350,15 +350,15 @@ void CvSVMKernel::calc_chi2( int vcount, int var_count, const float** vecs, |
|
|
|
|
const float* sample = vecs[j]; |
|
|
|
|
double chi2 = 0; |
|
|
|
|
for(k = 0 ; k < var_count; k++ ) |
|
|
|
|
{ |
|
|
|
|
{ |
|
|
|
|
double d = sample[k]-another[k]; |
|
|
|
|
double devisor = sample[k]+another[k]; |
|
|
|
|
/// if devisor == 0, the Chi2 distance would be zero, but calculation would rise an error because of deviding by zero
|
|
|
|
|
if (devisor != 0)
|
|
|
|
|
{
|
|
|
|
|
chi2 += d*d/devisor; |
|
|
|
|
}
|
|
|
|
|
} |
|
|
|
|
double devisor = sample[k]+another[k]; |
|
|
|
|
/// if devisor == 0, the Chi2 distance would be zero, but calculation would rise an error because of deviding by zero
|
|
|
|
|
if (devisor != 0) |
|
|
|
|
{ |
|
|
|
|
chi2 += d*d/devisor; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
results[j] = (Qfloat) (gamma*chi2); |
|
|
|
|
} |
|
|
|
|
if( vcount > 0 ) |
|
|
|
|