-
Notifications
You must be signed in to change notification settings - Fork 0
/
all_data.h
68 lines (58 loc) · 1.09 KB
/
all_data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* data.h
*
* Created on: Apr 5, 2014
* Author: zarcon
*/
#ifndef ALL_DATA_H_
#define ALL_DATA_H_
#include <vector>
#include <algorithm>
#include "common.h"
#include "sparse_mat.h"
#include "dense_mat.h"
class AllData {
//data
SparseMat X_;
DenseMat W_;
DenseMat H_;
//parameters
UINT N_, D_, R_;
public:
UINT const &N;
UINT const &D;
UINT const &R;
DenseVect* const &WV;
DenseVect* const &HV;
std::vector <SparseVect> const &XV;
AllData(UINT Rval):
R_(Rval), N(N_), D(D_), R(R_), WV(W_.M), HV(H_.M), XV(X_.M) {
N_ = 0;
D_ = 0;
}
void swapX(UINT i, UINT j) {
std::swap(X_.M[i], X_.M[j]);
}
void addXi(std::vector<FeatType> const &F, UINT featInd) {
N_++;
X_.addVect(F, featInd);
}
void initWH(UINT Dval) {
D_ = Dval;
H_.init(N,R);
W_.init(R,D);
}
void putWval(UINT i, UINT j, double val) {
W_.put(i,j,val);
}
void putHval(UINT i, UINT j, double val) {
H_.put(i,j,val);
}
void copyXW();
void putHvect(UINT i, double * lambda);
void putWvect(UINT i, double * lambda);
void clearW();
void clearH();
double calcNorm();
};
#endif /* ALL_DATA_H_ */