planc
Parallel Lowrank Approximation with Non-negativity Constraints
mttkrp_test.cpp
Go to the documentation of this file.
1 /* Copyright 2017 Ramakrishnan Kannan */
2 
3 #include <armadillo>
4 #include "ncpfactors.hpp"
5 #include "ntf_utils.hpp"
6 #include "tensor.hpp"
7 #include "utils.h"
8 
9 int main(int argc, char* argv[]) {
10  int test_order = 5;
11  int low_rank = 2;
12  UVEC dimensions(test_order);
13  FMAT* mttkrps = new FMAT[test_order];
14  // UVEC dimensions(4);
15  for (int i = 0; i < test_order; i++) {
16  dimensions(i) = i + 2;
17  }
18  // dimensions(3) = 6;
19  PLANC::NCPFactors cpfactors(dimensions, low_rank);
20  cpfactors.print();
21  FMAT krp_2 = cpfactors.krp_leave_out_one(2);
22  cout << "krp" << endl << "------" << endl << krp_2;
23  PLANC::Tensor my_tensor = cpfactors.rankk_tensor();
24  // cout << "input tensor" << endl << "--------" << endl;
25  // my_tensor.print();
26  for (int i = 0; i < test_order; i++) {
27  mttkrps[i] = arma::zeros<FMAT>(dimensions(i), low_rank);
28  }
29  for (int i = 0; i < test_order; i++) {
30  mttkrp(i, my_tensor, cpfactors, &mttkrps[i]);
31  cout << "mttkrp " << i << endl << "---------" << endl << mttkrps[i];
32  }
33 }
#define FMAT
Definition: utils.h:51
#define UVEC
Definition: utils.h:58
int main(int argc, char *argv[])
Definition: mttkrp_test.cpp:9
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.
Definition: ntf_utils.hpp:49