% input matrix V must be given first
[m,n] = size(V);
d = 64;
Winit=max(randn(m, d),0); Hinit = max(randn(d,n),0);
tol = 1.0e-6; timelimit=1000; maxiter=20;

V = gpuArray(V);
Winit = gpuArray(Winit);
Hinit = gpuArray(Hinit);

[W,H] = nmf(V,Winit,Hinit,tol,timelimit,maxiter);
