MCPcopy Create free account
hub / github.com/Xtra-Computing/thundersvm / calculate_obj

Method calculate_obj

src/thundersvm/solver/csmosolver.cpp:227–239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

225}
226
227float_type CSMOSolver::calculate_obj(const SyncArray<float_type> &f_val, const SyncArray<float_type> &alpha,
228 const SyncArray<int> &y) const {
229 //todo use parallel reduction for gpu and cpu
230 int n_instances = f_val.size();
231 float_type obj = 0;
232 const float_type *f_val_data = f_val.host_data();
233 const float_type *alpha_data = alpha.host_data();
234 const int *y_data = y.host_data();
235 for (int i = 0; i < n_instances; ++i) {
236 obj += alpha_data[i] - (f_val_data[i] + y_data[i]) * alpha_data[i] * y_data[i] / 2;
237 }
238 return -obj;
239}
240

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
host_dataMethod · 0.45

Tested by

no test coverage detected