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

Method calculate_rho

src/thundersvm/solver/csmosolver.cpp:167–187  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167float_type
168CSMOSolver::calculate_rho(const SyncArray<float_type> &f_val, const SyncArray<int> &y, SyncArray<float_type> &alpha,
169 float_type Cp,
170 float_type Cn) const {
171 int n_free = 0;
172 double sum_free = 0;
173 float_type up_value = INFINITY;
174 float_type low_value = -INFINITY;
175 const float_type *f_val_data = f_val.host_data();
176 const int *y_data = y.host_data();
177 float_type *alpha_data = alpha.host_data();
178 for (int i = 0; i < alpha.size(); ++i) {
179 if (is_free(alpha_data[i], y_data[i], Cp, Cn)) {
180 n_free++;
181 sum_free += f_val_data[i];
182 }
183 if (is_I_up(alpha_data[i], y_data[i], Cp, Cn)) up_value = min(up_value, f_val_data[i]);
184 if (is_I_low(alpha_data[i], y_data[i], Cp, Cn)) low_value = max(low_value, f_val_data[i]);
185 }
186 return 0 != n_free ? (sum_free / n_free) : (-(up_value + low_value) / 2);
187}
188
189void CSMOSolver::init_f(const SyncArray<float_type> &alpha, const SyncArray<int> &y, const KernelMatrix &k_mat,
190 SyncArray<float_type> &f_val) const {

Callers

nothing calls this directly

Calls 7

is_freeFunction · 0.85
is_I_upFunction · 0.85
minFunction · 0.85
is_I_lowFunction · 0.85
maxFunction · 0.85
host_dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected