-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.cpp
72 lines (52 loc) · 1.82 KB
/
main.cpp
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
68
69
70
71
72
int main(int argc, char* argv[]){
char* paramfile;
int chunkstart,chunknum;
fparam param(paramfile,chunkstart,chunknum);
Mat<int> BootMat = GenBoot(param.rownum,param.bootnum);
mat A(param.rownum,param.Acols(1));
mat BA(param.rownum,param.Acols(1));
mat B(param.rownum,param.Bcols(1));
mat BB(param.rownum,param.Bcols(1));
mat Co(param.Acols(1),param.Bcols(1));
if(param.streaming){
running_stat_vec<rowvec> stats;
} else{
cube C(param.Acols(1),param.Bcols(1),param.bootnum);
}
cube Quant(param.Acols(1).param.Bcols(1),param.quantiles.size());
for( int i=param.chunkstart; i<param.chunknum; i++){
if((param.Acols(i)!=A.n_cols)||(param.Bcols(i)!=B.n_cols)){
A.set_size(param.rownum,param.Acols(i));
B.set_size(param.rownum,param.Bcols(i));
if(param.streaming){
stats.set_size(param.Acols(i),param.Bcols(i));
} else {
C.set_size(param.Acols(i),param.Bcols(i),param.bootnum);
}
Quant.set_size(param.Acols(i),param.Bcols(i),param.quantiles.size());
Co.set_size(param.Acols(i),param.Bcols(i));
BA.set_size(param.rownum,param.Acols(i));
BB.set_size(param.rownum,param.Bcols(i));
}
readh5mat(param.h5id,param.Amatfield,param.startA(i),param.Acols(i),0,param.rownum,A);
readh5mat(param.h5id,param.Bmatfield,param.startB(i),param.Bcols(i),0,param.rownum,B);
Co=cor(A,B);
for(in j=0; j<param.bootnum; j++){
BA=A.rows(BootMat.col(j));
BB=B.rows(BootMat.col(j));
if( param.streaming){
Co=cor(BA,BB);
stats(vectorise(cor(BA,BB),1));
}else{
C.slice(j)=cor(BA,BB);
}
}
if(param.streaming){
ComputeQuantiles(stats,Co,Quant);
}else{
ComputeQuantiles(C,Co,&Quant);
}
filterQuantiles(param,Quant);
writeQuantiles(param,Quant);
return(0);
}