示例#1
0
/* --------------------------------------------------------------------
 Computes kernel function for a-th and b-th.

 The base address for the 1st argument is dataA and for the 2nd
 argument is dataB.
-------------------------------------------------------------------- */
double kernel( long a, long b )
{
   double c = 0;

   ker_cnt++;

   switch( ker ) {
      /* linear kernel */
      case 0:
         c = dot_prod( a, b );
         break;
      /* polynomial kernel */
      case 1:
         c = pow( (dot_prod( a, b) + arg1[1]), arg1[0] );
         break;
      /* radial basis functions kernel*/
      case 2:
         c = exp( -0.5*sub_dot_prod( a, b)/(arg1[0]*arg1[0]) );
         break;
      /* sigmoid */
      case 3:     
         c = tanh( arg1[0]*dot_prod( a,b) + arg1[1] );
         break;
      /* "custom": here comes definition of user's own kernel. 
      Currently, the linear kernel is used. */
      case 4:     
         c = dot_prod( a, b ); 
         break;
      default:
         c = 0;
   }
   return( c );
}
示例#2
0
/* --------------------------------------------------------------------
 Computes kernel function for a-th and b-th.

 The base address for the 1st argument is dataA and for the 2nd
 argument is dataB.
-------------------------------------------------------------------- */
double kernel( long a, long b )
{
   double c = 0;

   ker_cnt++;

   switch( ker ) {
      /* linear kernel */
      case 0:
         c = dot_prod( a, b );
         break;
      /* polynomial kernel */
      case 1:
         c = pow( (dot_prod( a, b) + arg1[1]), arg1[0] );
         break;
      /* radial basis functions kernel*/
      case 2:
         c = exp( -0.5*sub_dot_prod( a, b)/(arg1[0]*arg1[0]) );
         break;
      /* sigmoid */
      case 3:     
         c = tanh( arg1[0]*dot_prod( a,b) + arg1[1] );
         break;
      default:
         c = 0;
   }
   return( c );
}