| 71 | } |
| 72 | |
| 73 | void KernelMatrix::get_rows(const SyncArray<int> &idx, |
| 74 | SyncArray<kernel_type> &kernel_rows) const {//compute multiple rows of kernel matrix according to idx |
| 75 | CHECK_GE(kernel_rows.size(), idx.size() * n_instances_) << "kernel_rows memory is too small"; |
| 76 | #ifdef USE_CUDA |
| 77 | get_dot_product_dns_csr(idx, kernel_rows); |
| 78 | #else |
| 79 | if(n_features_ < 1000000) |
| 80 | get_dot_product_dns_csr(idx, kernel_rows); |
| 81 | else |
| 82 | get_dot_product_csr_csr(idx, kernel_rows); |
| 83 | // get_dot_product_dns_dns(idx, kernel_rows); |
| 84 | #endif |
| 85 | switch (param.kernel_type) { |
| 86 | case SvmParam::RBF: |
| 87 | case SvmParam::PRECOMPUTED://precomputed uses rbf as default |
| 88 | RBF_kernel(idx, self_dot_, kernel_rows, idx.size(), n_instances_, param.gamma); |
| 89 | break; |
| 90 | case SvmParam::LINEAR: |
| 91 | //do nothing |
| 92 | break; |
| 93 | case SvmParam::POLY: |
| 94 | poly_kernel(kernel_rows, param.gamma, param.coef0, param.degree, kernel_rows.size()); |
| 95 | break; |
| 96 | case SvmParam::SIGMOID: |
| 97 | sigmoid_kernel(kernel_rows, param.gamma, param.coef0, kernel_rows.size()); |
| 98 | break; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | void KernelMatrix::get_rows(const DataSet::node2d &instances, |
| 103 | SyncArray<kernel_type> &kernel_rows) const {//compute the whole (sub-) kernel matrix of the given instances. |