function cm = confusionMatrix(test_outputs, true_outputs);
% Produces a confusion matrix from encoded outputs; this requires
% the binary coding...
%
% (Old function; will be replaced with functionality based on class
% indices instead of binary coded classes!)
%
% Inputs:
%
%   test_outputs    - classification output of the MLP being verified;
%                     the output must be "purified" before calling
%                     because here we use strict equality operator.
%
%
%   true_outputs    - known true output that the subject_output is to be
%                     compared with. Each of this should be
%                     exactly one of the class codings (for example,
%                     the three different permutations of
%                     [1,-1,-1]).
%
% Output:
%
%   cm - the confusion matrix; on the i:th row, j:th column, you have the
%        number of items predicted in class j when the true class is i.
%        Each row will thus sum up to the number of true items in a class.
%

nclasses = size(true_outputs,2);

cm = zeros(nclasses,nclasses);
for ic = 1:nclasses
  for jc = 1:nclasses
    cm(ic,jc) = sum(test_outputs(ic,:)==1 & true_outputs(jc,:)==1);
  end  
end
