% test the NMF update equations
%
%   (c) Joachim Thiemann 2013    joachim.thiemann@ieee.org


F = 4;
N = 10;
V = rand(F,N);

midD = 3;
W = rand(F,midD);
Wbak = W;
U = eye(midD);
G = eye(midD);
H = rand(midD,N);
Hbak = H;

for n = 1:10
    fprintf( 'It: %d Dist: %g\n', n-1, mD_IS(V,W*U*G*H) );
    [ W, U, G, H ] = mlNMFupd( V, W, U, G, H, 1 );
    [ W, U, G, H ] = mlNMFupd( V, W, U, G, H, 4 );
end

fprintf( 'End: It: %d Dist: %g\n', n, mD_IS(V,W*U*G*H) );

fprintf('Test with E\n');
E = rand(size(V));
%E = ones(size(V));  % for sanity: should be same as above
W = Wbak;
H = Hbak;

for n = 1:10
    fprintf( 'It: %d Dist: %g\n', n-1, mD_IS(V,(W*U*G*H).*E) );
    [ W, U, G, H ] = mlNMFupd( V, W, U, G, H, E, 1 );
    [ W, U, G, H ] = mlNMFupd( V, W, U, G, H, E, 4 );
end

fprintf( 'End: It: %d Dist: %g\n', n, mD_IS(V,(W*U*G*H).*E) );
