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

Class KernelMatrix

include/thundersvm/kernelmatrix.h:16–80  ·  view source on GitHub ↗

* @brief The management class of kernel values. */

Source from the content-addressed store, hash-verified

14 * @brief The management class of kernel values.
15 */
16class KernelMatrix{
17public:
18 /**
19 * Create KernelMatrix with given instances (training data or support vectors).
20 * @param instances the instances, either are training instances for training, or are support vectors for prediction.
21 * @param param kernel_type in parm is used
22 */
23 explicit KernelMatrix(const DataSet::node2d &instances, SvmParam param);
24
25 /**
26 * return specific rows in kernel matrix
27 * @param [in] idx the indices of the rows
28 * @param [out] kernel_rows
29 */
30 void get_rows(const SyncArray<int> &idx, SyncArray<kernel_type> &kernel_rows) const;
31
32 /**
33 * return kernel values of each given instance and each instance stored in KernelMatrix
34 * @param [in] instances the given instances
35 * @param [out] kernel_rows
36 */
37 void get_rows(const DataSet::node2d &instances, SyncArray<kernel_type> &kernel_rows) const;
38
39 ///return the diagonal elements of kernel matrix
40 const SyncArray<kernel_type> &diag() const;
41
42 ///the number of instances in KernelMatrix
43 size_t n_instances() const { return n_instances_; };
44
45 ///the maximum number of features of instances
46 size_t n_features() const { return n_features_; }
47
48 ///the number of non-zero features of all instances
49 size_t nnz() const {return nnz_;};//number of nonzero
50private:
51 KernelMatrix &operator=(const KernelMatrix &) const;
52
53 KernelMatrix(const KernelMatrix &);
54
55 SyncArray<kernel_type> val_;
56 SyncArray<int> col_ind_;
57 SyncArray<int> row_ptr_;
58 SyncArray<kernel_type> diag_;
59 SyncArray<kernel_type> self_dot_;
60 size_t nnz_;
61 size_t n_instances_;
62 size_t n_features_;
63 SvmParam param;
64 void dns_csr_mul(const SyncArray<kernel_type> &dense_mat, int n_rows, SyncArray<kernel_type> &result) const;
65#ifndef USE_CUDA
66 void csr_csr_mul(const SyncArray<kernel_type> &ws_val, int n_rows, const SyncArray<int> &ws_col_ind,
67 const SyncArray<int> &ws_row_ptr, SyncArray<kernel_type> &result) const;
68 void dns_dns_mul(const SyncArray<kernel_type> &dense_mat, int n_rows,
69 const SyncArray<kernel_type> &origin_dense, SyncArray<kernel_type> &result) const;
70#endif
71 void get_dot_product_dns_csr(const SyncArray<int> &idx, SyncArray<kernel_type> &dot_product) const;
72
73 void get_dot_product_csr_csr(const SyncArray<int> &idx, SyncArray<kernel_type> &dot_product) const;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected