-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRcppDeepState_TestCode.cpp
101 lines (98 loc) · 3.75 KB
/
RcppDeepState_TestCode.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <deepstate/DeepState.hpp>
using namespace deepstate;
class DeepState_Test{
public:
Rcpp::NumericVector Exceptional_values(){
Rcpp::NumericVector values = Rcpp::NumericVector::create(NA_REAL,R_NaN,R_PosInf,R_NegInf);
return values;
}
Rcpp::NumericVector RcppDeepState_NumericVector()
{
int max_val = DeepState_MaxInt();
size_t size_limit ={max_val,DeepState_RandInt()};
int rand_val = OneOf(size_limit);
int num_vector_size = DeepState_IntInRange(0,rand_val);
int low_val = DeepState_Double();
int high_val = DeepState_Double();
Rcpp::NumericVector NumericRand_vec[num_vector_size];
for(int i=0; i< num_vector_size; i++){
OneOf(
[&] {
NumericRand_vec[i] = DeepState_Float();
},
[&] {
if(low_val > high_val)
NumericRand_vec[i] = DeepState_DoubleInRange(high_val,low_val);
else
NumericRand_vec[i] = DeepState_DoubleInRange(low_val,high_val);
},
[&] {
// need to check on this for NA,Nan,Inf,-Inf
NumericRand_vec[i] = OneOf(Exceptional_values());
},
);
return NumericRand_vec;
}
}
Rcpp::NumericVector RcppDeepState_NumericVector(int size_of_vector)
{
int low_val = DeepState_Double();
int high_val = DeepState_Double();
Rcpp::NumericVector NumericRand_vec[size_of_vector];
for(int i=0; i< size_of_vector; i++){
OneOf(
[&] {
NumericRand_vec[i] = DeepState_Double();
},
[&] {
if(low_val > high_val)
NumericRand_vec[i] = DeepState_DoubleInRange(high_val,low_val);
else
NumericRand_vec[i] = DeepState_DoubleInRange(low_val,high_val);
},
[&] {
// need to check on this for NA,Nan,Inf,-Inf
NumericRand_vec[i] = OneOf(Exceptional_values());
},
);
return NumericRand_vec;
}
}
Rcpp::IntegerVector RcppDeepState_IntegerVector(){
int min_val = DeepState_MinInt();
int max_val = DeepState_MaxInt();
int int_vector_size = DeepState_IntInRange(0,max_val);
Rcpp::IntegerVector IntegerRand_vec[int_vector_size];
for(int i=0; i< int_vector_size; i++){
OneOf(
[&] {
IntegerRand_vec[i] = DeepState_Int();
},
[&] {
IntegerRand_vec[i] = DeepState_IntInRange(min_val,max_val);
}
);
return IntegerRand_vec;
}
}
Rcpp::IntegerVector RcppDeepState_IntegerVector(int size_of_vector){
Rcpp::IntegerVector IntegerRand_vec[size_of_vector];
for(int i=0; i< size_of_vector; i++){
OneOf(
[&] {
IntegerRand_vec[i] = DeepState_Int();
},
[&] {
IntegerRand_vec[i] = DeepState_IntInRange(min_val,max_val);
}
);
return IntegerRand_vec;
}
};
TEST(Random_Set, Ranges) {
DeepState_Test deeptest= new deeptest();
Rcpp::RObject rcpp_result_gen;
Rcpp::NumericVector data_vec = deeptest.RcppDeepState_NumericVector();
Rcpp::IntegerVector max_segments = deeptest.RcppDeepState_IntegerVector();
rcpp_result_gen = Rcpp::wrap(rcpp_binseg_normal(data_vec, max_segments));
}