32 #ifndef __MLPACK_METHODS_LMF_UPDATE_RULES_NMF_MULT_DIV_HPP
33 #define __MLPACK_METHODS_LMF_UPDATE_RULES_NMF_MULT_DIV_HPP
46 template<
typename MatType>
47 void Initialize(
const MatType& dataset,
const size_t rank)
66 template<
typename MatType>
67 inline static void WUpdate(
const MatType& V,
76 for (
size_t i = 0; i < W.n_rows; ++i)
78 for (
size_t j = 0; j < W.n_cols; ++j)
84 t2.set_size(H.n_cols);
85 for (
size_t k = 0; k < t2.n_elem; ++k)
87 t2(k) = H(j, k) * V(i, k) / t1(i, k);
90 W(i, j) = W(i, j) * sum(t2) / sum(H.row(j));
108 template<
typename MatType>
118 for (
size_t i = 0; i < H.n_rows; i++)
120 for (
size_t j = 0; j < H.n_cols; j++)
126 t2.set_size(W.n_rows);
127 for (
size_t k = 0; k < t2.n_elem; ++k)
129 t2(k) = W(k, i) * V(k, j) / t1(k, j);
132 H(i,j) = H(i,j) * sum(t2) / sum(W.col(i));
static void WUpdate(const MatType &V, arma::mat &W, const arma::mat &H)
The update rule for the basis matrix W.
Linear algebra utility functions, generally performed on matrices or vectors.
void Initialize(const MatType &dataset, const size_t rank)
NMFMultiplicativeDivergenceUpdate()
static void HUpdate(const MatType &V, const arma::mat &W, arma::mat &H)
The update rule for the encoding matrix H.