MCPcopy Create free account
hub / github.com/bgrimstad/splinter / splinter_datatable_add_samples_col_major

Function splinter_datatable_add_samples_col_major

src/cinterface/datatable.cpp:84–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void splinter_datatable_add_samples_col_major(splinter_obj_ptr datatable_ptr, double *x, int n_samples, int x_dim)
85{
86 auto dataTable = get_datatable(datatable_ptr);
87 if (dataTable != nullptr)
88 {
89 try
90 {
91// std::ofstream out("test.txt");
92 DenseVector vec(x_dim);
93 for (int i = 0; i < n_samples; ++i)
94 {
95 for (int j = 0; j < x_dim; ++j)
96 {
97 vec(j) = x[i + j * n_samples];
98 }
99
100// out << "Adding sample: (";
101// for(int l = 0; l < vec.size(); l++)
102// {
103// if(l != 0)
104// out << ",";
105// out << vec(l);
106// }
107// out << ") = ";
108// out << x[i + x_dim * n_samples] << std::endl;
109
110 dataTable->addSample(vec, x[i + x_dim * n_samples]);
111 }
112 }
113 catch(const Exception &e)
114 {
115 set_error_string(e.what());
116 }
117 }
118}
119
120int splinter_datatable_get_num_variables(splinter_obj_ptr datatable_ptr)
121{

Callers

nothing calls this directly

Calls 4

get_datatableFunction · 0.85
set_error_stringFunction · 0.85
addSampleMethod · 0.80
whatMethod · 0.80

Tested by

no test coverage detected