Contents
Generate problem data
rand('seed', 0); randn('seed', 0);
m = 500; n = 500;
r = 20;
L = max(0,randn(m,r)); U = max(0,randn(r,n));
Mtrue = L*U;
sn = 60;
N = max(0,randn(m,n));
M = Mtrue + 10^(-sn/20) * norm(Mtrue,'fro') * N/norm(N,'fro');
sr = 0.4;
known = randsample(m*n,round(sr*m*n));
data = M(known);
Solve problem
opts.maxit = 1000;
opts.tol = 1e-4;
esr = round(r*1.25);
t0 = tic;
[X, Y, Out] = nmfc(data,known,m,n,esr,opts);
time = toc(t0);
Iteration: 686
Reporting
fprintf('time = %4.2e, ', time);
fprintf('solution relative error = %4.2e\n\n', norm(X*Y - Mtrue,'fro')/norm(Mtrue,'fro'));
figure;
semilogy(1:Out.iter, Out.hist_obj, 'k-', 'LineWidth', 2);
xlabel('iteration','fontsize',12); ylabel('objective','fontsize',12);
figure;
semilogy(1:Out.iter, Out.hist_rel(2,:), 'k-', 'LineWidth', 2);
xlabel('iteration','fontsize',12);
ylabel('Relative residual','fontsize',12);
time = 3.60e+000, solution relative error = 7.06e-004