* @brief Populate the array with random floats, generated from a Gaussian distribution. * @param a The array to populate. * @param N The number of elements in the array. * @param gen The random number generator. * @param mean The mean of the Gaussian distribution. * @param std The standard deviation of the Gaussian distribution. */
| 211 | * @param std The standard deviation of the Gaussian distribution. |
| 212 | */ |
| 213 | inline void randn(float *a, size_t N, std::mt19937 &gen, float mean = 0.0, |
| 214 | float std = 1.0) { |
| 215 | std::normal_distribution<float> dist(mean, std); |
| 216 | for (int i = 0; i < N; i++) { |
| 217 | a[i] = static_cast<float>(dist(gen)); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | inline void randn(half *a, size_t N, std::mt19937 &gen, float mean = 0.0, |
| 222 | float std = 1.0) { |
no test coverage detected