3 #ifndef COMMON_NTF_UTILS_HPP_ 4 #define COMMON_NTF_UTILS_HPP_ 16 assert(i_A.n_cols == i_B.n_cols);
17 VEC acol = arma::zeros<VEC>(i_A.n_rows);
18 VEC bcol = arma::zeros<VEC>(i_B.n_rows);
19 for (
unsigned int i = 0; i < i_A.n_cols; i++) {
22 for (
unsigned int j = 0; j < acol.n_rows; j++) {
23 (*o_C)(arma::span(j * bcol.n_rows, (j + 1) * bcol.n_rows - 1), i) =
35 for (
unsigned int j = 0; j < i_acol.n_rows; j++) {
36 (*o_c).rows(arma::span(j * i_bcol.n_rows, (j + 1) * i_bcol.n_rows - 1)) =
52 X.
mttkrp(i_n, krp, o_mttkrp);
55 #endif // COMMON_NTF_UTILS_HPP_
Data is stored such that the unfolding is column major.
void mttkrp(const int i_n, const MAT &i_krp, MAT *o_mttkrp) const
size of krp must be product of all dimensions leaving out nxk.
MAT krp_leave_out_one(const unsigned int i_n)
KRP leaving out the mode i_n.
void kronecker(const VEC &i_acol, const VEC &i_bcol, VEC *o_c)
Returns the kronecker product between two vectors.
void mttkrp(const int i_n, const planc::Tensor &X, planc::NCPFactors &i_F, MAT *o_mttkrp)
Return the mttkrp of mode i_n of tensor X.
void khatrirao(const MAT &i_A, const MAT &i_B, MAT *o_C)
Returns the khatri-rao product between two matrices.