Loading [MathJax]/extensions/tex2jax.js
cuML C++ API  23.12
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
rproj_c.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2022, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <raft/core/handle.hpp>
20 #include <rmm/device_uvector.hpp>
21 
22 namespace ML {
23 
36 struct paramsRPROJ {
37  int n_samples;
40  double eps;
42  double density;
45 };
46 
48 
49 template <typename math_t>
50 struct rand_mat {
51  rand_mat(cudaStream_t stream)
52  : dense_data(0, stream),
53  indices(0, stream),
54  indptr(0, stream),
55  sparse_data(0, stream),
56  stream(stream),
57  type(unset)
58  {
59  }
60 
61  ~rand_mat() { this->reset(); }
62 
63  // For dense matrices
64  rmm::device_uvector<math_t> dense_data;
65 
66  // For sparse CSC matrices
67  rmm::device_uvector<int> indices;
68  rmm::device_uvector<int> indptr;
69  rmm::device_uvector<math_t> sparse_data;
70 
71  cudaStream_t stream;
72 
74 
75  void reset()
76  {
77  this->dense_data.release();
78  this->indices.release();
79  this->indptr.release();
80  this->sparse_data.release();
81  this->type = unset;
82  };
83 };
84 
85 template <typename math_t>
86 void RPROJfit(const raft::handle_t& handle, rand_mat<math_t>* random_matrix, paramsRPROJ* params);
87 
88 template <typename math_t>
89 void RPROJtransform(const raft::handle_t& handle,
90  math_t* input,
91  rand_mat<math_t>* random_matrix,
92  math_t* output,
94 
95 size_t johnson_lindenstrauss_min_dim(size_t n_samples, double eps);
96 
97 } // namespace ML
Definition: params.hpp:34
random_matrix_type
Definition: rproj_c.h:47
double density
Definition: rproj_c.h:42
int n_features
Definition: rproj_c.h:38
int n_samples
Definition: rproj_c.h:37
double eps
Definition: rproj_c.h:40
void RPROJtransform(const raft::handle_t &handle, math_t *input, rand_mat< math_t > *random_matrix, math_t *output, paramsRPROJ *params)
cudaStream_t stream
Definition: rproj_c.h:71
void RPROJfit(const raft::handle_t &handle, rand_mat< math_t > *random_matrix, paramsRPROJ *params)
rmm::device_uvector< math_t > dense_data
Definition: rproj_c.h:64
bool gaussian_method
Definition: rproj_c.h:41
rand_mat(cudaStream_t stream)
Definition: rproj_c.h:51
rmm::device_uvector< math_t > sparse_data
Definition: rproj_c.h:69
bool dense_output
Definition: rproj_c.h:43
void reset()
Definition: rproj_c.h:75
rmm::device_uvector< int > indptr
Definition: rproj_c.h:68
~rand_mat()
Definition: rproj_c.h:61
int random_state
Definition: rproj_c.h:44
size_t johnson_lindenstrauss_min_dim(size_t n_samples, double eps)
int n_components
Definition: rproj_c.h:39
random_matrix_type type
Definition: rproj_c.h:73
rmm::device_uvector< int > indices
Definition: rproj_c.h:67
@ unset
Definition: rproj_c.h:47
@ sparse
Definition: rproj_c.h:47
@ dense
Definition: rproj_c.h:47
Definition: dbscan.hpp:27
Definition: rproj_c.h:36
Definition: rproj_c.h:50