function y=SLMP(p,W,X)

%
% Single Layer Morphological Perceptrons
% Implementation following Ritter-Urcid
%
% M. E. Valle, November 18, 2005
%
% This code comes with no guarantee or warranty of any kind.
%
% function y=SLMP(p,W,X)
%
% Inputs: p = response of the dendrites.
%         W = sinpatic weight matrix.
%         X = matrix where each column is a point, i.e. X = [X1,X2,...,Xp].
%
% Output: y = class vector, i.e. y = [y1,y2,...,yp] where yi is the class of 
%             pattern Xi.
% 
% See LearnSLMP or LearnSLMPA to train a SLMP network.
%

K=length(p);
M=size(X,2);

for m=1:M
    for k=1:K
        tau(k)=p(k)*min(min(W(:,k,1)+X(:,m)),min(-W(:,k,2)-X(:,m)));
    end
    y(1,m)=min(tau)>=0;
end
