function U01_test_distmat
%U01_TEST_DISTMAT            Test distmat.
%
%usage
%  U06_test_distmat
%
%author
%  saputra@cs.tu-berlin.de

% Data
X = [ 0.9, 2, 0.1, -3, 7.5; -2.4, 2.1, 0.3, -8, 4; 3.2, 1.1, -0.6, -0.9, 8; 9.4, -1.2, 2.1, 9.8, 7];

% Correct distances
correct_dist = [
                   0  11.757125499032490   8.698275691193054   7.971198153351853  10.645186705737011
  11.757125499032490                   0   4.542025979670306  15.874822833657074  12.194670967270907
   8.698275691193054   4.542025979670306                   0  11.742231474468557  12.900387591076479
   7.971198153351853  15.874822833657074  11.742231474468557                   0  18.474306482247176
  10.645186705737011  12.194670967270907  12.900387591076479  18.474306482247176                   0 ];

% Run test.

if exist('distmat.m', 'file') 
  fprintf('Testing distmat.m ...\n');
  [D1, D2, td] = distmat(X);

  if max(max(abs(D1 - correct_dist))) > 1e-10
    fprintf('D1 failed (discrepancy > 1e-10).\n');
  else
    fprintf('D1 OK.\n'); 
  end

  if max(max(abs(D2 - correct_dist))) > 1e-10
    fprintf('D2 failed (discrepancy > 1e-10).\n');
  else
    fprintf('D2 OK.\n'); 
  end
end
