25 void allocateMatrices() {
26 WtW = arma::zeros<MAT>(this->k, this->k);
27 HtH = arma::zeros<MAT>(this->k, this->k);
28 WtA = arma::zeros<MAT>(this->n, this->k);
29 AH = arma::zeros<MAT>(this->m, this->k);
41 this->normalize_by_W();
43 this->At = this->A.t();
46 this->normalize_by_W();
48 this->At = this->A.t();
51 unsigned int currentIteration = 0;
57 WtA = this->W.t() * this->A;
58 WtW = this->W.t() * this->W;
59 INFO <<
"starting H Prereq for " 66 for (
unsigned int x = 0; x < this->k; x++) {
68 Hx = this->H.col(x) + (((WtA.row(x)).t()) - (this->H * (WtW.col(x))));
69 fixNumericalError<VEC>(&Hx);
75 INFO <<
"Completed H (" << currentIteration <<
"/" 77 <<
" time =" <<
toc() << std::endl;
80 AH = this->A * this->H;
81 HtH = this->H.t() * this->H;
82 INFO <<
"starting W Prereq for " 87 for (
unsigned int x = 0; x < this->k; x++) {
91 Wx = (this->W.col(x) * HtH(x, x)) +
92 (((AH.col(x))) - (this->W * (HtH.col(x))));
93 fixNumericalError<VEC>(&Wx);
100 this->normalize_by_W();
102 INFO <<
"Completed W (" << currentIteration <<
"/" 104 <<
" time =" <<
toc() << std::endl;
106 INFO <<
"Completed It (" << currentIteration <<
"/" 108 <<
" time =" <<
toc() << std::endl;
110 INFO <<
"Completed it = " << currentIteration
111 <<
" HALSERR=" << sqrt(this->objective_err) / this->normA
121 #endif // NMF_HALS_HPP_ void tic()
start the timer. easy to call as tic(); some code; double t=toc();
const unsigned int num_iterations() const
Returns the number of iterations.
HALSNMF(const T &A, const MAT &llf, const MAT &rlf)
HALSNMF(const T &A, int lowrank)
ncp_factors contains the factors of the ncp every ith factor is of size n_i * k number of factors is ...
void computeObjectiveError()