function K = dtw_kernel(X,Y,dst,lambda)
% K = dtw_kernel(X,Y,dst,lambda)
%
% X n1 x m1 row matrix with n1 sequences of length m1
% Y n2 x m2 row matrix with n2 sequences of length m2
% dst distance indicator
%     1:    edit distance
%     2:    Euclidean DTW
%     else  Derivative DTW (default)
% lambda kernel parameter
%
% Returns DTW kernel.

n1 = size(X,1);
n2 = size(Y,1);
K  = zeros(n1,n2);
for i = 1:n1
    i
    for j = 1:n2
        K(i,j) = exp(-lambda * dtw(X(i,:), Y(j,:), dst));
    end
end
