@@ -175,8 +175,9 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
175
175
/// use concrete_csprng::seeders::Seed;
176
176
/// use tfhe::core_crypto::commons::math::random::RandomGenerator;
177
177
/// let mut generator = RandomGenerator::<SoftwareRandomGenerator>::new(Seed(0));
178
- /// let mut vec = vec![1u32; 100 ];
178
+ /// let mut vec = vec![0u32; 1000 ];
179
179
/// generator.fill_slice_with_random_uniform(&mut vec);
180
+ /// assert!(vec.iter().all(|&x| x != 0));
180
181
/// ```
181
182
pub fn fill_slice_with_random_uniform < Scalar > ( & mut self , output : & mut [ Scalar ] )
182
183
where
@@ -196,11 +197,12 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
196
197
/// use tfhe::core_crypto::commons::math::random::RandomGenerator;
197
198
/// use tfhe::core_crypto::commons::parameters::CiphertextModulus;
198
199
/// let mut generator = RandomGenerator::<SoftwareRandomGenerator>::new(Seed(0));
199
- /// let mut vec = vec![1u32; 100 ];
200
+ /// let mut vec = vec![0u32; 1000 ];
200
201
/// generator.fill_slice_with_random_uniform_custom_mod(
201
202
/// &mut vec,
202
203
/// CiphertextModulus::try_new_power_of_2(31).unwrap(),
203
204
/// );
205
+ /// assert!(vec.iter().all(|&x| x != 0));
204
206
/// ```
205
207
pub fn fill_slice_with_random_uniform_custom_mod < Scalar > (
206
208
& mut self ,
@@ -243,8 +245,9 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
243
245
/// use concrete_csprng::seeders::Seed;
244
246
/// use tfhe::core_crypto::commons::math::random::RandomGenerator;
245
247
/// let mut generator = RandomGenerator::<SoftwareRandomGenerator>::new(Seed(0));
246
- /// let mut vec = vec![2u32; 100 ];
248
+ /// let mut vec = vec![0u32; 1000 ];
247
249
/// generator.fill_slice_with_random_uniform_binary(&mut vec);
250
+ /// assert!(vec.iter().any(|&x| x != 0));
248
251
/// ```
249
252
pub fn fill_slice_with_random_uniform_binary < Scalar > ( & mut self , output : & mut [ Scalar ] )
250
253
where
@@ -348,11 +351,15 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
348
351
/// // check that both samples are in 6 sigmas.
349
352
/// assert!(g1.abs() <= 6.);
350
353
/// assert!(g2.abs() <= 6.);
354
+ /// assert!(g1 != 0.);
355
+ /// assert!(g2 != 0.);
351
356
/// // for f64
352
357
/// let (g1, g2): (f64, f64) = generator.random_gaussian(0. as f64, 1. as f64);
353
358
/// // check that both samples are in 6 sigmas.
354
359
/// assert!(g1.abs() <= 6.);
355
360
/// assert!(g2.abs() <= 6.);
361
+ /// assert!(g1 != 0.);
362
+ /// assert!(g2 != 0.);
356
363
/// ```
357
364
pub fn random_gaussian < Float , Scalar > ( & mut self , mean : Float , std : Float ) -> ( Scalar , Scalar )
358
365
where
@@ -371,8 +378,9 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
371
378
/// use concrete_csprng::seeders::Seed;
372
379
/// use tfhe::core_crypto::commons::math::random::RandomGenerator;
373
380
/// let mut generator = RandomGenerator::<SoftwareRandomGenerator>::new(Seed(0));
374
- /// let mut vec = vec![1000f32; 100 ];
381
+ /// let mut vec = vec![0f32; 1000 ];
375
382
/// generator.fill_slice_with_random_gaussian(&mut vec, 0., 1.);
383
+ /// assert!(vec.iter().all(|&x| x != 0.));
376
384
/// ```
377
385
pub fn fill_slice_with_random_gaussian < Float , Scalar > (
378
386
& mut self ,
@@ -404,13 +412,14 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
404
412
/// use tfhe::core_crypto::commons::math::random::RandomGenerator;
405
413
/// use tfhe::core_crypto::commons::parameters::CiphertextModulus;
406
414
/// let mut generator = RandomGenerator::<SoftwareRandomGenerator>::new(Seed(0));
407
- /// let mut vec = vec![1000u64; 100 ];
415
+ /// let mut vec = vec![0u64; 1000 ];
408
416
/// generator.fill_slice_with_random_gaussian_custom_mod(
409
417
/// &mut vec,
410
418
/// 0.,
411
419
/// 1.,
412
420
/// CiphertextModulus::try_new_power_of_2(63).unwrap(),
413
421
/// );
422
+ /// assert!(vec.iter().all(|&x| x != 0));
414
423
/// ```
415
424
pub fn fill_slice_with_random_gaussian_custom_mod < Float , Scalar > (
416
425
& mut self ,
@@ -453,8 +462,9 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
453
462
/// use concrete_csprng::seeders::Seed;
454
463
/// use tfhe::core_crypto::commons::math::random::RandomGenerator;
455
464
/// let mut generator = RandomGenerator::<SoftwareRandomGenerator>::new(Seed(0));
456
- /// let mut vec = vec![1000u32; 100 ];
465
+ /// let mut vec = vec![0u32; 1000 ];
457
466
/// generator.unsigned_torus_slice_wrapping_add_random_gaussian_assign(&mut vec, 0., 1.);
467
+ /// assert!(vec.iter().all(|&x| x != 0));
458
468
/// ```
459
469
pub fn unsigned_torus_slice_wrapping_add_random_gaussian_assign < Float , Scalar > (
460
470
& mut self ,
@@ -484,9 +494,16 @@ impl<G: ByteRandomGenerator> RandomGenerator<G> {
484
494
/// use concrete_csprng::generators::SoftwareRandomGenerator;
485
495
/// use concrete_csprng::seeders::Seed;
486
496
/// use tfhe::core_crypto::commons::math::random::RandomGenerator;
497
+ /// use tfhe::core_crypto::commons::parameters::CiphertextModulus;
487
498
/// let mut generator = RandomGenerator::<SoftwareRandomGenerator>::new(Seed(0));
488
- /// let mut vec = vec![1000u32; 100];
489
- /// generator.unsigned_torus_slice_wrapping_add_random_gaussian_assign(&mut vec, 0., 1.);
499
+ /// let mut vec = vec![0u32; 1000];
500
+ /// generator.unsigned_torus_slice_wrapping_add_random_gaussian_custom_mod_assign(
501
+ /// &mut vec,
502
+ /// 0.,
503
+ /// 1.,
504
+ /// CiphertextModulus::try_new_power_of_2(31).unwrap(),
505
+ /// );
506
+ /// assert!(vec.iter().all(|&x| x != 0));
490
507
/// ```
491
508
pub fn unsigned_torus_slice_wrapping_add_random_gaussian_custom_mod_assign < Float , Scalar > (
492
509
& mut self ,
0 commit comments