You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
12 lines
323 B
Matlab
12 lines
323 B
Matlab
10 years ago
|
function sim = linearKernel(x1, x2)
|
||
|
%LINEARKERNEL returns a linear kernel between x1 and x2
|
||
|
% sim = linearKernel(x1, x2) returns a linear kernel between x1 and x2
|
||
|
% and returns the value in sim
|
||
|
|
||
|
% Ensure that x1 and x2 are column vectors
|
||
|
x1 = x1(:); x2 = x2(:);
|
||
|
|
||
|
% Compute the kernel
|
||
|
sim = x1' * x2; % dot product
|
||
|
|
||
|
end
|