Skip to content

Commit 02be04c

Browse files
REFACTOR: refactor random backend srcs (#545)
* REFACTOR: refactor random backend srcs
1 parent 2eec363 commit 02be04c

File tree

3 files changed

+110
-100
lines changed

3 files changed

+110
-100
lines changed

dpnp/backend/include/dpnp_iface_random.hpp

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
* @param [out] result Output array.
6363
*/
6464
template <typename _DataType>
65-
INP_DLLEXPORT void dpnp_rng_beta_c(void* result, _DataType a, _DataType b, size_t size);
65+
INP_DLLEXPORT void dpnp_rng_beta_c(void* result, const _DataType a, const _DataType b, const size_t size);
6666

6767
/**
6868
* @ingroup BACKEND_RANDOM_API
@@ -74,7 +74,7 @@ INP_DLLEXPORT void dpnp_rng_beta_c(void* result, _DataType a, _DataType b, size_
7474
* @param [out] result Output array.
7575
*/
7676
template <typename _DataType>
77-
INP_DLLEXPORT void dpnp_rng_binomial_c(void* result, int ntrial, double p, size_t size);
77+
INP_DLLEXPORT void dpnp_rng_binomial_c(void* result, const int ntrial, const double p, const size_t size);
7878

7979
/**
8080
* @ingroup BACKEND_RANDOM_API
@@ -85,7 +85,7 @@ INP_DLLEXPORT void dpnp_rng_binomial_c(void* result, int ntrial, double p, size_
8585
* @param [out] result Output array.
8686
*/
8787
template <typename _DataType>
88-
INP_DLLEXPORT void dpnp_rng_chi_square_c(void* result, int df, size_t size);
88+
INP_DLLEXPORT void dpnp_rng_chisquare_c(void* result, const int df, const size_t size);
8989

9090
/**
9191
* @ingroup BACKEND_RANDOM_API
@@ -96,7 +96,7 @@ INP_DLLEXPORT void dpnp_rng_chi_square_c(void* result, int df, size_t size);
9696
* @param [out] result Output array.
9797
*/
9898
template <typename _DataType>
99-
INP_DLLEXPORT void dpnp_rng_exponential_c(void* result, _DataType beta, size_t size);
99+
INP_DLLEXPORT void dpnp_rng_exponential_c(void* result, const _DataType beta, const size_t size);
100100

101101
/**
102102
* @ingroup BACKEND_RANDOM_API
@@ -108,7 +108,7 @@ INP_DLLEXPORT void dpnp_rng_exponential_c(void* result, _DataType beta, size_t s
108108
* @param [out] result Output array.
109109
*/
110110
template <typename _DataType>
111-
INP_DLLEXPORT void dpnp_rng_f_c(void* result, _DataType df_num, _DataType df_den, size_t size);
111+
INP_DLLEXPORT void dpnp_rng_f_c(void* result, const _DataType df_num, const _DataType df_den, const size_t size);
112112

113113
/**
114114
* @ingroup BACKEND_RANDOM_API
@@ -120,7 +120,7 @@ INP_DLLEXPORT void dpnp_rng_f_c(void* result, _DataType df_num, _DataType df_den
120120
* @param [out] result Output array.
121121
*/
122122
template <typename _DataType>
123-
INP_DLLEXPORT void dpnp_rng_gamma_c(void* result, _DataType shape, _DataType scale, size_t size);
123+
INP_DLLEXPORT void dpnp_rng_gamma_c(void* result, const _DataType shape, const _DataType scale, const size_t size);
124124

125125
/**
126126
* @ingroup BACKEND_RANDOM_API
@@ -132,43 +132,43 @@ INP_DLLEXPORT void dpnp_rng_gamma_c(void* result, _DataType shape, _DataType sca
132132
* @param [out] result Output array.
133133
*/
134134
template <typename _DataType>
135-
INP_DLLEXPORT void dpnp_rng_gaussian_c(void* result, _DataType mean, _DataType stddev, size_t size);
135+
INP_DLLEXPORT void dpnp_rng_gaussian_c(void* result, const _DataType mean, const _DataType stddev, const size_t size);
136136

137137
/**
138138
* @ingroup BACKEND_RANDOM_API
139-
* @brief math library implementation of random number generator (hypergeometric distribution)
139+
* @brief math library implementation of random number generator (Geometric distribution)
140140
*
141141
* @param [in] size Number of elements in `result` arrays.
142-
* @param [in] l Lot size of l.
143-
* @param [in] s Size of sampling without replacement.
144-
* @param [in] m Number of marked elements m.
142+
* @param [in] p The probability of success of an individual trial.
145143
* @param [out] result Output array.
146144
*/
147145
template <typename _DataType>
148-
INP_DLLEXPORT void dpnp_rng_hypergeometric_c(void* result, int l, int s, int m, size_t size);
146+
INP_DLLEXPORT void dpnp_rng_geometric_c(void* result, const float p, const size_t size);
149147

150148
/**
151149
* @ingroup BACKEND_RANDOM_API
152-
* @brief math library implementation of random number generator (geometric distribution)
150+
* @brief math library implementation of random number generator (Gumbel distribution)
153151
*
154152
* @param [in] size Number of elements in `result` arrays.
155-
* @param [in] p Success probability p of a trial.
153+
* @param [in] loc The location of the mode of the distribution.
154+
* @param [in] scale The scale parameter of the distribution. Default is 1.
156155
* @param [out] result Output array.
157156
*/
158157
template <typename _DataType>
159-
INP_DLLEXPORT void dpnp_rng_geometric_c(void* result, float p, size_t size);
158+
INP_DLLEXPORT void dpnp_rng_gumbel_c(void* result, const double loc, const double scale, const size_t size);
160159

161160
/**
162161
* @ingroup BACKEND_RANDOM_API
163-
* @brief math library implementation of random number generator (gumbel distribution)
162+
* @brief math library implementation of random number generator (hypergeometric distribution)
164163
*
165164
* @param [in] size Number of elements in `result` arrays.
166-
* @param [in] loc The location of the mode of the distribution.
167-
* @param [in] scale The scale parameter of the distribution.
165+
* @param [in] l Lot size of l.
166+
* @param [in] s Size of sampling without replacement.
167+
* @param [in] m Number of marked elements m.
168168
* @param [out] result Output array.
169169
*/
170170
template <typename _DataType>
171-
INP_DLLEXPORT void dpnp_rng_gumbel_c(void* result, double loc, double scale, size_t size);
171+
INP_DLLEXPORT void dpnp_rng_hypergeometric_c(void* result, const int l, const int s, const int m, const size_t size);
172172

173173
/**
174174
* @ingroup BACKEND_RANDOM_API
@@ -180,7 +180,7 @@ INP_DLLEXPORT void dpnp_rng_gumbel_c(void* result, double loc, double scale, siz
180180
* @param [out] result Output array.
181181
*/
182182
template <typename _DataType>
183-
INP_DLLEXPORT void dpnp_rng_laplace_c(void* result, double loc, double scale, size_t size);
183+
INP_DLLEXPORT void dpnp_rng_laplace_c(void* result, const double loc, const double scale, const size_t size);
184184

185185
/**
186186
* @ingroup BACKEND_RANDOM_API
@@ -192,7 +192,7 @@ INP_DLLEXPORT void dpnp_rng_laplace_c(void* result, double loc, double scale, si
192192
* @param [out] result Output array.
193193
*/
194194
template <typename _DataType>
195-
INP_DLLEXPORT void dpnp_rng_logistic_c(void* result, double loc, double scale, size_t size);
195+
INP_DLLEXPORT void dpnp_rng_logistic_c(void* result, const double loc, double const scale, const size_t size);
196196

197197
/**
198198
* @ingroup BACKEND_RANDOM_API
@@ -204,7 +204,8 @@ INP_DLLEXPORT void dpnp_rng_logistic_c(void* result, double loc, double scale, s
204204
* @param [out] result Output array.
205205
*/
206206
template <typename _DataType>
207-
INP_DLLEXPORT void dpnp_rng_lognormal_c(void* result, _DataType mean, _DataType stddev, size_t size);
207+
INP_DLLEXPORT void dpnp_rng_lognormal_c(void* result, const _DataType mean, const _DataType stddev,
208+
const size_t size);
208209

209210
/**
210211
* @ingroup BACKEND_RANDOM_API
@@ -217,8 +218,8 @@ INP_DLLEXPORT void dpnp_rng_lognormal_c(void* result, _DataType mean, _DataType
217218
* @param [out] result Output array.
218219
*/
219220
template <typename _DataType>
220-
INP_DLLEXPORT void
221-
dpnp_rng_multinomial_c(void* result, int ntrial, const double* p_vector, const size_t p_vector_size, size_t size);
221+
INP_DLLEXPORT void dpnp_rng_multinomial_c(void* result, const int ntrial, const double* p_vector,
222+
const size_t p_vector_size, const size_t size);
222223

223224
/**
224225
* @ingroup BACKEND_RANDOM_API
@@ -239,7 +240,7 @@ INP_DLLEXPORT void dpnp_rng_multivariate_normal_c(void* result,
239240
const size_t mean_vector_size,
240241
const double* cov_vector,
241242
const size_t cov_vector_size,
242-
size_t size);
243+
const size_t size);
243244

244245
/**
245246
* @ingroup BACKEND_RANDOM_API
@@ -252,7 +253,7 @@ INP_DLLEXPORT void dpnp_rng_multivariate_normal_c(void* result,
252253
*
253254
*/
254255
template <typename _DataType>
255-
INP_DLLEXPORT void dpnp_rng_negative_binomial_c(void* result, double a, double p, size_t size);
256+
INP_DLLEXPORT void dpnp_rng_negative_binomial_c(void* result, const double a, const double p, const size_t size);
256257

257258
/**
258259
* @ingroup BACKEND_RANDOM_API
@@ -264,7 +265,7 @@ INP_DLLEXPORT void dpnp_rng_negative_binomial_c(void* result, double a, double p
264265
* @param [out] result Output array.
265266
*/
266267
template <typename _DataType>
267-
INP_DLLEXPORT void dpnp_rng_normal_c(void* result, _DataType mean, _DataType stddev, size_t size);
268+
INP_DLLEXPORT void dpnp_rng_normal_c(void* result, const _DataType mean, const _DataType stddev, const size_t size);
268269

269270
/**
270271
* @ingroup BACKEND_RANDOM_API
@@ -275,7 +276,7 @@ INP_DLLEXPORT void dpnp_rng_normal_c(void* result, _DataType mean, _DataType std
275276
* @param [out] result Output array.
276277
*/
277278
template <typename _DataType>
278-
INP_DLLEXPORT void dpnp_rng_pareto_c(void* result, double alpha, size_t size);
279+
INP_DLLEXPORT void dpnp_rng_pareto_c(void* result, const double alpha, const size_t size);
279280

280281
/**
281282
* @ingroup BACKEND_RANDOM_API
@@ -286,7 +287,7 @@ INP_DLLEXPORT void dpnp_rng_pareto_c(void* result, double alpha, size_t size);
286287
* @param [out] result Output array.
287288
*/
288289
template <typename _DataType>
289-
INP_DLLEXPORT void dpnp_rng_poisson_c(void* result, double lambda, size_t size);
290+
INP_DLLEXPORT void dpnp_rng_poisson_c(void* result, const double lambda, const size_t size);
290291

291292
/**
292293
* @ingroup BACKEND_RANDOM_API
@@ -297,7 +298,7 @@ INP_DLLEXPORT void dpnp_rng_poisson_c(void* result, double lambda, size_t size);
297298
* @param [out] result Output array.
298299
*/
299300
template <typename _DataType>
300-
INP_DLLEXPORT void dpnp_rng_power_c(void* result, double alpha, size_t size);
301+
INP_DLLEXPORT void dpnp_rng_power_c(void* result, const double alpha, const size_t size);
301302

302303
/**
303304
* @ingroup BACKEND_RANDOM_API
@@ -308,7 +309,7 @@ INP_DLLEXPORT void dpnp_rng_power_c(void* result, double alpha, size_t size);
308309
* @param [out] result Output array.
309310
*/
310311
template <typename _DataType>
311-
INP_DLLEXPORT void dpnp_rng_rayleigh_c(void* result, _DataType scale, size_t size);
312+
INP_DLLEXPORT void dpnp_rng_rayleigh_c(void* result, const _DataType scale, const size_t size);
312313

313314
/**
314315
* @ingroup BACKEND_RANDOM_API
@@ -326,7 +327,7 @@ INP_DLLEXPORT void dpnp_rng_srand_c(size_t seed = 1);
326327
* @param [out] result Output array.
327328
*/
328329
template <typename _DataType>
329-
INP_DLLEXPORT void dpnp_rng_standard_cauchy_c(void* result, size_t size);
330+
INP_DLLEXPORT void dpnp_rng_standard_cauchy_c(void* result, const size_t size);
330331

331332
/**
332333
* @ingroup BACKEND_RANDOM_API
@@ -336,7 +337,7 @@ INP_DLLEXPORT void dpnp_rng_standard_cauchy_c(void* result, size_t size);
336337
* @param [out] result Output array.
337338
*/
338339
template <typename _DataType>
339-
INP_DLLEXPORT void dpnp_rng_standard_exponential_c(void* result, size_t size);
340+
INP_DLLEXPORT void dpnp_rng_standard_exponential_c(void* result, const size_t size);
340341

341342
/**
342343
* @ingroup BACKEND_RANDOM_API
@@ -347,7 +348,7 @@ INP_DLLEXPORT void dpnp_rng_standard_exponential_c(void* result, size_t size);
347348
* @param [out] result Output array.
348349
*/
349350
template <typename _DataType>
350-
INP_DLLEXPORT void dpnp_rng_standard_gamma_c(void* result, _DataType shape, size_t size);
351+
INP_DLLEXPORT void dpnp_rng_standard_gamma_c(void* result, const _DataType shape, const size_t size);
351352

352353
/**
353354
* @ingroup BACKEND_RANDOM_API
@@ -357,7 +358,7 @@ INP_DLLEXPORT void dpnp_rng_standard_gamma_c(void* result, _DataType shape, size
357358
* @param [out] result Output array.
358359
*/
359360
template <typename _DataType>
360-
INP_DLLEXPORT void dpnp_rng_standard_normal_c(void* result, size_t size);
361+
INP_DLLEXPORT void dpnp_rng_standard_normal_c(void* result, const size_t size);
361362

362363
/**
363364
* @ingroup BACKEND_RANDOM_API
@@ -368,7 +369,7 @@ INP_DLLEXPORT void dpnp_rng_standard_normal_c(void* result, size_t size);
368369
* @param [out] result Output array.
369370
*/
370371
template <typename _DataType>
371-
INP_DLLEXPORT void dpnp_rng_standard_t_c(void* result, _DataType df, size_t size);
372+
INP_DLLEXPORT void dpnp_rng_standard_t_c(void* result, const _DataType df, const size_t size);
372373

373374
/**
374375
* @ingroup BACKEND_RANDOM_API
@@ -380,7 +381,7 @@ INP_DLLEXPORT void dpnp_rng_standard_t_c(void* result, _DataType df, size_t size
380381
* @param [out] result Output array.
381382
*/
382383
template <typename _DataType>
383-
INP_DLLEXPORT void dpnp_rng_uniform_c(void* result, long low, long high, size_t size);
384+
INP_DLLEXPORT void dpnp_rng_uniform_c(void* result, const long low, const long high, const size_t size);
384385

385386
/**
386387
* @ingroup BACKEND_RANDOM_API
@@ -391,6 +392,6 @@ INP_DLLEXPORT void dpnp_rng_uniform_c(void* result, long low, long high, size_t
391392
* @param [out] result Output array.
392393
*/
393394
template <typename _DataType>
394-
INP_DLLEXPORT void dpnp_rng_weibull_c(void* result, double alpha, size_t size);
395+
INP_DLLEXPORT void dpnp_rng_weibull_c(void* result, const double alpha, const size_t size);
395396

396397
#endif // BACKEND_IFACE_RANDOM_H

0 commit comments

Comments
 (0)