function [match,k_match] = IAS_match_kernel(K,kernels)
%

num_kernels = length(kernels);
dists = zeros(num_kernels,1);

d_min = Inf;
index = 0;
for k = 1:num_kernels
    Kk = kernels(k).kernel;
    dk = IAS_kernel_dist(K,Kk);
    Kn = K(:)/norm(K(:));
    Kkn = Kk(:)/norm(Kk(:));
    dk = acos(dot(Kkn,Kn));
    dists(k) = dk;
    if dk<d_min
        d_min = dk;
        index = k;
    end
end

match = kernels(index).kernel;
k_match = kernels(index);
