 #include <stdio.h>
+#include <stdlib.h>
 #include <math.h>
 
 extern "C" 

    for( int i = 0; i < trainingSize; i++ )
    { 
      float tempSum = 0.0f;

      for( int j = 0; j < trainingSize; j++ )
      {  
        tempSum += ( alphas[j] * y[j] * K[ INDX(j,i,trainingSize) ] );
      } /* end for j */

      E[i] = b + tempSum - y[i];

          j = ceil( (float) trainingSize * 
                      float( rand() ) / ( float(RAND_MAX) + 1.0f ) );
//        j = 3918;
//       j = (i + 1) % trainingSize;
 //      printf("j =  %d\n",j+1);
  //     if( j >= 19 ) exit(911);

        tempSum = 0.0f;
        for( int k = 0; k < trainingSize; k++ )
        {  
          tempSum += ( alphas[k] * y[k] * K[ INDX(k,j,trainingSize) ] );
//        if( alphas[k] != 0.0f ) 
 //          printf("k %d alphas %f y %f K %f\n",k+1,alphas[k],
  //           y[k],K[INDX(k,j,trainingSize)] );
        } /* end for j */
        
        E[j] = b + tempSum - y[j];

//printf("b = %f\n",b);
//printf("tempsum = %f\n",tempSum);
//printf("Yj = %f\n",y[j] );
//printf("E_j = %f\n\n",E[j]);

        float alphaIOld = alphas[i];
        float alphaJOld = alphas[j];
