

function   [ne0,R]=count_err(f,tch)
    [nclass,nsamp]=size(f);
    [mf,i1]=max(f,[],1);
    [mf,i2]=max(tch,[],1);
    ne0=sum(i1~=i2);
    if(nargout>1),
        for k=1:nclass,
            ii=find(tch(k,:)==1);
            [mh,im]=max(f(:,ii),[],1);
            for j=1:nclass,   R(k,j)=sum(im==j); end;
        end;
    end;
return


