function labels = test_classifier(M, fm_test)

%function labels = test_classifier(M, fm_test)
%
% TEST_CLASSIFIER -- Performs classification for a generalize multi-class
%                    classifier using the nearest-representative rule
%
% Input Parameters:
%   M        --  Classifier matrix produced by train_classifier
%   fm_test  --  Feature matrix containing instances to be classified
%
% Output Parameters:
%   labels   --  A vector of integers, one per instance in fm_test.
%                1 is the first class in M, 2 is the second class, etc.
%


d = [];

for i=1:size(M,1)
    xm = (fm_test - repmat(M(i,:),[size(fm_test,1) 1]));
    d(:,i) = sum(xm.^2,2);
end

[mn,labels] = min(d,[],2);
