-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRcppModules.cpp
More file actions
133 lines (117 loc) · 4.33 KB
/
RcppModules.cpp
File metadata and controls
133 lines (117 loc) · 4.33 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Copyright (c) 2017-2024 King Abdullah University of Science and Technology,
// All rights reserved.
// ExaGeoStat is a software package, provided by King Abdullah University of Science and Technology (KAUST).
/**
* @file RcppModules.cpp
* @brief Rcpp module definitions for ExaGeoStatCPP.
* @version 1.1.0
* @author Mahmoud ElKarargy
* @author David Helmy
* @date 2023-01-20
**/
#include <Rcpp.h>
#include <hardware/ExaGeoStatHardware.hpp>
#include <Rcpp-adapters/FunctionsAdapter.hpp>
#include <data-units/ExaGeoStatData.hpp>
/** Expose C++ class to R to be able to use Wrap and As
* Allows C++ to Send and Receive Class object from R
**/
RCPP_EXPOSED_CLASS(ExaGeoStatHardware)
RCPP_EXPOSED_CLASS_NODECL(ExaGeoStatData<double>)
/** Expose C++ Object With the Given functions **/
RCPP_MODULE(ExaGeoStatCPP) {
/** ExaGeoStatCPP Class **/
using namespace Rcpp;
/** Hardware Class **/
class_<ExaGeoStatHardware>("Hardware")
.constructor<std::string, int, int, int, int>()
.method("finalize_hardware", &ExaGeoStatHardware::FinalizeHardware,
"Manually finalize the hardware");
/** Data Class **/
class_<ExaGeoStatData<double>>("Data")
.constructor<int, std::string>();
function("simulate_data", &exageostat::adapters::R_ExaGeoStatLoadData,
List::create(
_["kernel"],
_["initial_theta"],
_["distance_matrix"] = "euclidean",
_["problem_size"],
_["seed"] = static_cast<unsigned int>(time(0)),
_["dts"],
_["lts"] = 0,
_["dimension"] = "2D",
_["log_path"] = "",
_["data_path"] = "",
_["observations_file"] = "",
_["recovery_file"] = ""
));
function("model_data", &exageostat::adapters::R_ExaGeoStatModelData,
List::create(
_["computation"] = "exact",
_["kernel"],
_["distance_matrix"] = "euclidean",
_["lb"],
_["ub"],
_["tol"] = 4,
_["mle_itr"],
_["dts"],
_["lts"] = 0,
_["dimension"] = "2D",
_["band"] = 0,
_["max_rank"] = 500,
_["acc"] = 0,
_["data"] = R_NilValue,
_["matrix"] = R_NilValue,
_["x"] = R_NilValue,
_["y"] = R_NilValue,
_["z"] = R_NilValue
));
function("predict_data", &exageostat::adapters::R_ExaGeoStatPredictData,
List::create(
_["kernel"],
_["distance_matrix"] = "euclidean",
_["estimated_theta"],
_["dts"],
_["lts"] = 0,
_["dimension"] = "2D",
_["train_data"],
_["test_data"],
_["test_measurements"] = std::vector<double>(),
_["computation"] = "exact"
));
function("mloe_mmom", &exageostat::adapters::R_ExaGeoStatMLOE_MMOM,
List::create(
_["kernel"],
_["distance_matrix"] = "euclidean",
_["estimated_theta"],
_["true_theta"],
_["dts"],
_["lts"] = 0,
_["dimension"] = "2D",
_["train_data"],
_["test_data"]
));
function("fisher", &exageostat::adapters::R_ExaGeoStatFisher,
List::create(
_["kernel"],
_["distance_matrix"] = "euclidean",
_["estimated_theta"],
_["dts"],
_["lts"] = 0,
_["dimension"] = "2D",
_["train_data"],
_["test_data"]
));
function("idw", &exageostat::adapters::R_ExaGeoStatIDW,
List::create(
_["kernel"],
_["distance_matrix"] = "euclidean",
_["estimated_theta"],
_["dts"],
_["lts"] = 0,
_["dimension"] = "2D",
_["train_data"],
_["test_data"],
_["test_measurements"]
));
}