matrix factorization code for summer tutorial