def _update_coordinate_descent(X, W, Ht, l1_reg, l2_reg, shuffle, random_state):
 n_components = Ht.shape[1]
 HHt = fast_dot(Ht.T, Ht)
 XHt = safe_sparse_dot(X, Ht)
 if (l2_reg != 0.0):
  HHt.flat[::(n_components + 1)] += l2_reg
 if (l1_reg != 0.0):
  XHt -= l1_reg
 if shuffle:
  permutation = random_state.permutation(n_components)
 else:
  permutation = np.arange(n_components)
 permutation = np.asarray(permutation, dtype=np.intp)
 return _update_cdnmf_fast(W, HHt, XHt, permutation)

def _update_coordinate_descent ( X , W , Ht , l1_reg , l2_reg , shuffle , random_state ) : n_components = Ht . shape [ 1 ] HHt = fast_dot ( Ht . T , Ht ) XHt = safe_sparse_dot ( X , Ht ) if ( l2_reg != 0.0 ) : HHt . flat [ : : ( n_components + 1 ) ] += l2_reg if ( l1_reg != 0.0 ) : XHt -= l1_reg if shuffle : permutation = random_state . permutation ( n_components ) else : permutation = np . arange ( n_components ) permutation = np . asarray ( permutation , dtype = np . intp ) return _update_cdnmf_fast ( W , HHt , XHt , permutation )
helper function for _fit_coordinate_descent update w to minimize the objective function .