planc
Parallel Lowrank Approximation with Non-negativity Constraints
ntfhals.hpp
Go to the documentation of this file.
1 /* Copyright Ramakrishnan Kannan 2018 */
2 
3 #ifndef NTF_NTFHALS_HPP_
4 #define NTF_NTFHALS_HPP_
5 
6 #include "ntf/auntf.hpp"
7 #include "common/utils.hpp"
8 
9 namespace planc {
10 
11 class NTFHALS : public AUNTF {
12  protected:
13  MAT update(const int mode) {
14  MAT H(this->m_ncp_factors.factor(mode));
15  // iterate over all columns of H
16  for (int i = 0; i < this->m_ncp_factors.rank(); i++) {
17  VEC updHi =
18  H.col(i) + ((this->ncp_mttkrp_t[mode].row(i)).t() -
19  H * this->gram_without_one.col(i));
20  fixNumericalError<VEC>(&updHi);
21  double normHi = arma::norm(updHi, 2);
22  normHi *= normHi;
23  double globalnormHi = normHi;
24  if (globalnormHi > 0) {
25  H.col(i) = updHi;
26  }
27  }
28  return H.t();
29  }
30 
31  public:
32  NTFHALS(const Tensor &i_tensor, const int i_k, algotype i_algo)
33  : AUNTF(i_tensor, i_k, i_algo) {}
34 }; // class NTFHALS
35 
36 } // namespace planc
37 
38 #endif // NTF_NTFHALS_HPP_
Data is stored such that the unfolding is column major.
Definition: tensor.hpp:32
NTFHALS(const Tensor &i_tensor, const int i_k, algotype i_algo)
Definition: ntfhals.hpp:32
algotype
Definition: utils.h:10
#define MAT
Definition: utils.h:52
ncp_factors contains the factors of the ncp every ith factor is of size n_i * k number of factors is ...
Definition: ncpfactors.hpp:20
#define VEC
Definition: utils.h:61