Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

double Kernel::k_function ( const svm_node x,
const svm_node y,
const svm_parameter param 
) [static]

Definition at line 280 of file svm.cpp.

References svm_parameter::coef0, svm_parameter::degree, dot(), svm_parameter::gamma, svm_node::index, svm_parameter::kernel_type, POLY, RBF, SIGMOID, SVM_LINEAR, svm_node::value, and x.

Referenced by svm_predict_values().

00282 {
00283         switch(param.kernel_type)
00284         {
00285                 case SVM_LINEAR:
00286                         return dot(x,y);
00287                 case POLY:
00288                         return pow(param.gamma*dot(x,y)+param.coef0,param.degree);
00289                 case RBF:
00290                 {
00291                         double sum = 0;
00292                         while(x->index != -1 && y->index !=-1)
00293                         {
00294                                 if(x->index == y->index)
00295                                 {
00296                                         double d = x->value - y->value;
00297                                         sum += d*d;
00298                                         ++x;
00299                                         ++y;
00300                                 }
00301                                 else
00302                                 {
00303                                         if(x->index > y->index)
00304                                         {       
00305                                                 sum += y->value * y->value;
00306                                                 ++y;
00307                                         }
00308                                         else
00309                                         {
00310                                                 sum += x->value * x->value;
00311                                                 ++x;
00312                                         }
00313                                 }
00314                         }
00315 
00316                         while(x->index != -1)
00317                         {
00318                                 sum += x->value * x->value;
00319                                 ++x;
00320                         }
00321 
00322                         while(y->index != -1)
00323                         {
00324                                 sum += y->value * y->value;
00325                                 ++y;
00326                         }
00327                         
00328                         return exp(-param.gamma*sum);
00329                 }
00330                 case SIGMOID:
00331                         return tanh(param.gamma*dot(x,y)+param.coef0);
00332                 default:
00333                         return 0;       /* Unreachable */
00334         }
00335 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:32:20 2010 for ImpalaSrc by  doxygen 1.5.1