| 298 | } |
| 299 | |
| 300 | void |
| 301 | update_f(SyncArray<float_type> &f, const SyncArray<float_type> &alpha_diff, |
| 302 | const SyncArray<kernel_type> &k_mat_rows, |
| 303 | int n_instances) { |
| 304 | //"n_instances" equals to the number of rows of the whole kernel matrix for both SVC and SVR. |
| 305 | float_type *f_data = f.host_data(); |
| 306 | const float_type *alpha_diff_data = alpha_diff.host_data(); |
| 307 | const kernel_type *k_mat_rows_data = k_mat_rows.host_data(); |
| 308 | #pragma omp parallel for schedule(guided) |
| 309 | for (int idx = 0; idx < n_instances; ++idx) { |
| 310 | double sum_diff = 0; |
| 311 | for (int i = 0; i < alpha_diff.size(); ++i) { |
| 312 | float_type d = alpha_diff_data[i]; |
| 313 | if (d != 0) { |
| 314 | sum_diff += d * k_mat_rows_data[i * n_instances + idx]; |
| 315 | } |
| 316 | } |
| 317 | f_data[idx] -= sum_diff; |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | void sort_f(SyncArray<float_type> &f_val2sort, SyncArray<int> &f_idx2sort) { |
| 322 | vector<std::pair<float_type, int>> paris; |