#encoding:latin-1 from py_nnma import * param = dict(alpha=.1, tau=2, regul=1e-1, sparse_par=1e-1, psi=1e-3) nc = 10 B = np.random.rand(100,nc) C = np.random.rand(nc,20) A = np.dot(B, C) import sys, time def run(name, routine): print "run %12s" % name, sys.stdout.flush() start = time.time() _,_,obj,count,converged = routine(A, 10, eps=5e-5, verbose= 0, maxcount=1000, **param) print "obj = %E count=%5d converged=%d TIME=%.2f secs" % \ (obj,count, converged, time.time()-start) print print "TEST WITH DENSE MATRIX\n" run("FNMAI_SPARSE", FNMAI_SPARSE) run("NNSC", NNSC) run("FNMAI", FNMAI) run("GDCLS_L1", GDCLS_L1) run("GDCLS", GDCLS) run("ALS", ALS) run("NMFKL", NMFKL) run("NMF", NMF) run("RRI", RRI) run("FastHALS", FastHALS) run("SNMF", SNMF) print print "TEST WITH SPARSE MATRIX\n" A = sp.csc_matrix(A) run("NNSC", NNSC) run("FNMAI_SPARSE", FNMAI_SPARSE) run("FNMAI", FNMAI) run("GDCLS_L1", GDCLS_L1) run("GDCLS", GDCLS) run("ALS", ALS) run("NMFKL", NMFKL) run("NMF", NMF) run("RRI", RRI) run("FastHALS", FastHALS) run("SNMF", SNMF)