Skip to content

Commit 72362f3

Browse files
authored
[oneMKL][RNG] Extend parameter type for random distributions (#557)
* make changes for poisson_v * fix markup * generalize type * more fixes for lambda * added more distributions
1 parent e4628d5 commit 72362f3

File tree

3 files changed

+46
-36
lines changed

3 files changed

+46
-36
lines changed

source/elements/oneMKL/source/domains/rng/host_api/mkl-rng-gaussian_mv.rst

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ The probability density function is given by:
2626
class gaussian_mv
2727
-----------------
2828

29+
Let ``SequenceContainerOrView`` be a type that can be one of C++ Sequence containers or C++ Views (``span``, ``mdspan``).
30+
It's implementation defined which type ``SequenceContainerOrView`` represents.
31+
2932
.. rubric:: Syntax
3033

3134
.. code-block:: cpp
@@ -36,10 +39,10 @@ class gaussian_mv
3639
public:
3740
using method_type = Method;
3841
using result_type = RealType;
39-
explicit gaussian_mv(std::uint32_t dimen, std::vector<RealType> mean, std::vector<RealType> matrix);
42+
explicit gaussian_mv(std::uint32_t dimen, SequenceContainerOrView<RealType> mean, SequenceContainerOrView<RealType> matrix);
4043
std::int32_t dimen() const;
41-
std::vector<RealType> mean() const;
42-
std::vector<RealType> matrix() const;
44+
SequenceContainerOrView<RealType> mean() const;
45+
SequenceContainerOrView<RealType> matrix() const;
4346
};
4447
}
4548
@@ -85,13 +88,13 @@ class gaussian_mv
8588

8689
* - Routine
8790
- Description
88-
* - `explicit gaussian_mv(std::uint32_t dimen, std::vector<RealType> mean, std::vector<RealType> matrix)`_
91+
* - `explicit gaussian_mv(std::uint32_t dimen, SequenceContainerOrView<RealType> mean, SequenceContainerOrView<RealType> matrix)`_
8992
- Constructor with parameters
9093
* - `std::int32_t dimen() const`_
9194
- Method to obtain number of dimensions in output random vectors
92-
* - `std::vector<double> mean() const`_
95+
* - `SequenceContainerOrView<double> mean() const`_
9396
- Method to obtain mean vector `a` of dimension d.
94-
* - `std::vector<double> matrix() const`_
97+
* - `SequenceContainerOrView<double> matrix() const`_
9598
- Method to obtain variance-covariance matrix `C`
9699

97100
.. container:: section
@@ -128,17 +131,17 @@ class gaussian_mv
128131

129132
.. container:: section
130133

131-
.. _`explicit gaussian_mv(std::uint32_t dimen, std::vector<RealType> mean, std::vector<RealType> matrix)`:
134+
.. _`explicit gaussian_mv(std::uint32_t dimen, SequenceContainerOrView<RealType> mean, SequenceContainerOrView<RealType> matrix)`:
132135

133136
.. code-block:: cpp
134137
135-
explicit gaussian_mv::gaussian_mv(std::uint32_t dimen, std::vector<RealType> mean, std::vector<RealType> matrix)
138+
explicit gaussian_mv::gaussian_mv(std::uint32_t dimen, SequenceContainerOrView<RealType> mean, SequenceContainerOrView<RealType> matrix)
136139
137140
.. container:: section
138141

139142
.. rubric:: Description
140143

141-
Constructor with parameters. `dimen` is the number of dimensions, `mean` is a mean vector, `matrix` is a variance-covariance matrix.
144+
Constructor with parameters. ``dimen`` is the number of dimensions, ``mean`` is a mean vector, ``matrix`` is a variance-covariance matrix.
142145

143146
.. container:: section
144147

@@ -167,11 +170,11 @@ class gaussian_mv
167170

168171
.. container:: section
169172

170-
.. _`std::vector<double> mean() const`:
173+
.. _`SequenceContainerOrView<double> mean() const`:
171174

172175
.. code-block:: cpp
173176
174-
std::vector<double> gaussian_mv::mean() const
177+
SequenceContainerOrView<double> gaussian_mv::mean() const
175178
176179
.. container:: section
177180

@@ -181,16 +184,16 @@ class gaussian_mv
181184

182185
.. container:: section
183186

184-
.. _`std::vector<double> matrix() const`:
187+
.. _`SequenceContainerOrView<double> matrix() const`:
185188

186189
.. code-block:: cpp
187190
188-
std::vector<double> gaussian_mv::matrix() const
191+
SequenceContainerOrView<double> gaussian_mv::matrix() const
189192
190193
.. container:: section
191194

192195
.. rubric:: Return Value
193196

194197
Returns the variance-covariance matrix.
195198

196-
**Parent topic:** :ref:`onemkl_rng_distributions`
199+
**Parent topic:** :ref:`onemkl_rng_distributions`

source/elements/oneMKL/source/domains/rng/host_api/mkl-rng-multinomial.rst

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ The probability distribution is given by:
2626
class multinomial
2727
-----------------
2828

29+
Let ``SequenceContainerOrView`` be a type that can be one of C++ Sequence containers or C++ Views (``span``, ``mdspan``).
30+
It's implementation defined which type ``SequenceContainerOrView`` represents.
31+
2932
.. rubric:: Syntax
3033

3134
.. code-block:: cpp
@@ -36,9 +39,9 @@ class multinomial
3639
public:
3740
using method_type = Method;
3841
using result_type = IntType;
39-
explicit multinomial(double ntrial, std::vector<double> p);
42+
explicit multinomial(double ntrial, SequenceContainerOrView<double> p);
4043
std::int32_t ntrial() const;
41-
std::vector<double> p() const;
44+
SequenceContainerOrView<double> p() const;
4245
};
4346
}
4447
@@ -72,12 +75,12 @@ class multinomial
7275

7376
* - Routine
7477
- Description
75-
* - `explicit multinomial(double ntrial, std::vector<double> p)`_
78+
* - `explicit multinomial(double ntrial, SequenceContainerOrView<double> p)`_
7679
- Constructor with parameters
7780
* - `std::int32_t ntrial() const`_
7881
- Method to obtain number of independent trials
79-
* - `std::vector<double> p() const`_
80-
- Method to obtain probability vector of possible outcomes
82+
* - `SequenceContainerOrView<double> p() const`_
83+
- Method to obtain a probability parameter of possible outcomes
8184

8285
.. container:: section
8386

@@ -113,17 +116,17 @@ class multinomial
113116

114117
.. container:: section
115118

116-
.. _`explicit multinomial(double ntrial, std::vector<double> p)`:
119+
.. _`explicit multinomial(double ntrial, SequenceContainerOrView<double> p)`:
117120

118121
.. code-block:: cpp
119122
120-
explicit multinomial::multinomial(double ntrial, std::vector<double> p)
123+
explicit multinomial::multinomial(double ntrial, SequenceContainerOrView<double> p)
121124
122125
.. container:: section
123126

124127
.. rubric:: Description
125128

126-
Constructor with parameters. `ntrial` is a number of independent trials, `p` is a probability vector.
129+
Constructor with parameters. ``ntrial`` is a number of independent trials, ``p`` is a probability parameter.
127130

128131
.. container:: section
129132

@@ -152,11 +155,11 @@ class multinomial
152155

153156
.. container:: section
154157

155-
.. _`std::vector<double> p() const`:
158+
.. _`SequenceContainerOrView<double> p() const`:
156159

157160
.. code-block:: cpp
158161
159-
std::vector<double> multinomial::p() const
162+
SequenceContainerOrView<double> multinomial::p() const
160163
161164
.. container:: section
162165

source/elements/oneMKL/source/domains/rng/host_api/mkl-rng-poisson_v.rst

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Class is used for generation of Poisson distributed integer types random numbers
1313

1414
.. rubric:: Description
1515

16-
The class object is used in the :ref:`oneapi::mkl::rng::generate()<onemkl_rng_generate>` function to provide n random numbers Poisson distributed, with distribution parameter :math:`\lambda_i`, where :math:`\lambda_i \in R; \lambda_i > 0; i = 1, ... , n`.
16+
The class object is used in the :ref:`oneapi::mkl::rng::generate()<onemkl_rng_generate>` function to provide
17+
n random numbers Poisson distributed, with distribution parameter :math:`\lambda_i`, where :math:`\lambda_i \in R; \lambda_i > 0; i = 1, ... , n`.
1718

1819
The probability distribution is given by:
1920

@@ -32,6 +33,9 @@ The cumulative distribution function is as follows:
3233
class poisson_v
3334
---------------
3435

36+
Let ``SequenceContainerOrView`` be a type that can be one of C++ Sequence containers or C++ Views (``span``, ``mdspan``).
37+
It's implementation defined which type ``SequenceContainerOrView`` represents.
38+
3539
.. rubric:: Syntax
3640

3741
.. code-block:: cpp
@@ -42,8 +46,8 @@ class poisson_v
4246
public:
4347
using method_type = Method;
4448
using result_type = IntType;
45-
explicit poisson_v(std::vector<double> lambda);
46-
std::vector<double> lambda() const;
49+
explicit poisson_v(SequenceContainerOrView<double> lambda);
50+
SequenceContainerOrView<double> lambda() const;
4751
};
4852
}
4953
@@ -76,9 +80,9 @@ class poisson_v
7680

7781
* - Routine
7882
- Description
79-
* - `explicit poisson_v(std::vector<double> lambda)`_
83+
* - `explicit poisson_v(SequenceContainerOrView<double> lambda)`_
8084
- Constructor with parameters
81-
* - `std::vector<double> lambda() const`_
85+
* - `SequenceContainerOrView<double> lambda() const`_
8286
- Method to obtain distribution parameter
8387

8488
.. container:: section
@@ -115,17 +119,17 @@ class poisson_v
115119

116120
.. container:: section
117121

118-
.. _`explicit poisson_v(std::vector<double> lambda)`:
122+
.. _`explicit poisson_v(SequenceContainerOrView<double> lambda)`:
119123

120124
.. code-block:: cpp
121125
122-
explicit poisson_v::poisson_v(std::vector<double> lambda)
126+
explicit poisson_v::poisson_v(SequenceContainerOrView<double> lambda)
123127
124128
.. container:: section
125129

126130
.. rubric:: Description
127131

128-
Constructor with parameters. `lambda` is a distribution parameter.
132+
Constructor with parameters. ``lambda`` is a distribution parameter.
129133

130134
.. container:: section
131135

@@ -140,16 +144,16 @@ class poisson_v
140144

141145
.. container:: section
142146

143-
.. _`std::vector<double> lambda() const`:
147+
.. _`SequenceContainerOrView<double> lambda() const`:
144148

145149
.. code-block:: cpp
146150
147-
double poisson_v::lambda() const
151+
SequenceContainerOrView<double> poisson_v::lambda() const
148152
149153
.. container:: section
150154

151155
.. rubric:: Return Value
152156

153-
Returns the distribution parameter `lambda`.
157+
Returns the distribution parameter ``lambda``.
154158

155-
**Parent topic:** :ref:`onemkl_rng_distributions`
159+
**Parent topic:** :ref:`onemkl_rng_distributions`

0 commit comments

Comments
 (0)