title: Histogram intersection kernel optimization in MATLAB
body: <p>I want to try a svm classifier using histogram intersection kernel, for a dataset of 153 images but it takes a long time. This is my code:</p>
  
  <pre><code>a = load('...'); %vectors
  b = load('...'); %labels
  g = dataset(a,b);
  
  error = crossval(g,libsvc([],proxm([],'ih'),100),10,10);
  error1 = crossval(g,libsvc([],proxm([],'ih'),10),10,10);
  error2 = crossval(g,libsvc([],proxm([],'ih'),1),10,10);
  </code></pre>
  
  <p>My implementation of the kernel within the proxm function is:</p>
  
  <pre><code>...
  case {'dist_histint','ih'}
      [m,d]=size(A);
      [n,d1]=size(B);
      if (d ~= d1)
          error('column length of A (%d) != column length of B (%d)\n',d,d1);
      end
  
      % With the MATLAB JIT compiler the trivial implementation turns out
      % to be the fastest, especially for large matrices.
      D = zeros(m,n);
      for i=1:m % m is number of samples of A 
          if (0==mod(i,1000)) fprintf('.'); end
          for j=1:n % n is number of samples of B
              D(i,j) = sum(min([A(i,:);B(j,:)]));%./max(A(:,i),B(:,j)));
          end            
      end
  </code></pre>
  
  <p>I need some matlab optimization for this code!</p>