ThunderSVM
ThunderSVM: An Open-Source SVM Library on GPUs and CPUs
smo_kernel.h
1 //
2 // Created by jiashuai on 17-9-21.
3 //
4 
5 #ifndef THUNDERSVM_SMO_KERNEL_H
6 #define THUNDERSVM_SMO_KERNEL_H
7 
8 #include <thundersvm/thundersvm.h>
9 #include <thundersvm/clion_cuda.h>
10 #include <thundersvm/syncarray.h>
11 
12 namespace svm_kernel {
13  __host__ __device__ inline bool is_I_up(float a, float y, float Cp, float Cn) {
14  return (y > 0 && a < Cp) || (y < 0 && a > 0);
15  }
16 
17  __host__ __device__ inline bool is_I_low(float a, float y, float Cp, float Cn) {
18  return (y > 0 && a > 0) || (y < 0 && a < Cn);
19  }
20 
21  __host__ __device__ inline bool is_free(float a, float y, float Cp, float Cn) {
22  return a > 0 && (y > 0 ? a < Cp : a < Cn);
23  }
24 
25  void
26  c_smo_solve(const SyncArray<int> &y, SyncArray<float_type> &f_val, SyncArray<float_type> &alpha,
27  SyncArray<float_type> &alpha_diff,
28  const SyncArray<int> &working_set, float_type Cp, float_type Cn,
29  const SyncArray<float_type> &k_mat_rows,
30  const SyncArray<float_type> &k_mat_diag, int row_len, float_type eps, SyncArray<float_type> &diff,
31  int max_iter);
32 
33  void
34  nu_smo_solve(const SyncArray<int> &y, SyncArray<float_type> &f_val, SyncArray<float_type> &alpha,
35  SyncArray<float_type> &alpha_diff,
36  const SyncArray<int> &working_set, float_type C, const SyncArray<float_type> &k_mat_rows,
37  const SyncArray<float_type> &k_mat_diag, int row_len, float_type eps, SyncArray<float_type> &diff,
38  int max_iter);
39 
40  void
41  update_f(SyncArray<float_type> &f, const SyncArray<float_type> &alpha_diff, const SyncArray<float_type> &k_mat_rows,
42  int n_instances);
43 
44  void sort_f(SyncArray<float_type> &f_val2sort, SyncArray<int> &f_idx2sort);
45 }
46 
47 #endif //THUNDERSVM_SMO_KERNEL_H
Definition: kernelmatrix_kernel.h:12