Update rand dependency to 0.7 + some tweaks
This commit is contained in:
parent
8d756f47ce
commit
2e22821740
|
@ -21,7 +21,7 @@ path = "src/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "std" ]
|
default = [ "std" ]
|
||||||
std = [ "matrixmultiply", "rand/std", "alga/std" ]
|
std = [ "matrixmultiply", "rand/std", "alga/std", "rand_distr" ]
|
||||||
stdweb = [ "rand/stdweb" ]
|
stdweb = [ "rand/stdweb" ]
|
||||||
arbitrary = [ "quickcheck" ]
|
arbitrary = [ "quickcheck" ]
|
||||||
serde-serialize = [ "serde", "serde_derive", "num-complex/serde" ]
|
serde-serialize = [ "serde", "serde_derive", "num-complex/serde" ]
|
||||||
|
@ -34,7 +34,8 @@ io = [ "pest", "pest_derive" ]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
typenum = "1.10"
|
typenum = "1.10"
|
||||||
generic-array = "0.12"
|
generic-array = "0.12"
|
||||||
rand = { version = "0.6", default-features = false }
|
rand = { version = "0.7", default-features = false }
|
||||||
|
rand_distr = { version = "0.2", optional = true }
|
||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
num-complex = { version = "0.2", default-features = false }
|
num-complex = { version = "0.2", default-features = false }
|
||||||
num-rational = { version = "0.2", default-features = false }
|
num-rational = { version = "0.2", default-features = false }
|
||||||
|
@ -54,7 +55,9 @@ pest_derive = { version = "2.0", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
rand_xorshift = "0.1"
|
rand = { version = "0.7", features = ["small_rng"] }
|
||||||
|
# IsaacRng is used by benches; keep for reproducibility?
|
||||||
|
rand_isaac = "0.2"
|
||||||
### Uncomment this line before running benchmarks.
|
### Uncomment this line before running benchmarks.
|
||||||
### We can't just let this uncommented because that would break
|
### We can't just let this uncommented because that would break
|
||||||
### compilation for #[no-std] because of the terrible Cargo bug
|
### compilation for #[no-std] because of the terrible Cargo bug
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use na::{DMatrix, DVector, Matrix2, Matrix3, Matrix4, MatrixN, Vector2, Vector3, Vector4, U10};
|
use na::{DMatrix, DVector, Matrix2, Matrix3, Matrix4, MatrixN, Vector2, Vector3, Vector4, U10};
|
||||||
use rand::{IsaacRng, Rng};
|
|
||||||
use std::ops::{Add, Div, Mul, Sub};
|
use std::ops::{Add, Div, Mul, Sub};
|
||||||
|
|
||||||
#[path = "../common/macros.rs"]
|
#[path = "../common/macros.rs"]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use na::{DVector, Vector2, Vector3, Vector4, VectorN};
|
use na::{DVector, Vector2, Vector3, Vector4, VectorN};
|
||||||
use rand::{IsaacRng, Rng};
|
use rand::{Rng, SeedableRng};
|
||||||
|
use rand_isaac::IsaacRng;
|
||||||
use std::ops::{Add, Div, Mul, Sub};
|
use std::ops::{Add, Div, Mul, Sub};
|
||||||
use typenum::U10000;
|
use typenum::U10000;
|
||||||
|
|
||||||
|
@ -48,7 +49,6 @@ bench_binop_ref!(vec10000_dot_f64, VectorN<f64, U10000>, VectorN<f64, U10000>, d
|
||||||
bench_binop_ref!(vec10000_dot_f32, VectorN<f32, U10000>, VectorN<f32, U10000>, dot);
|
bench_binop_ref!(vec10000_dot_f32, VectorN<f32, U10000>, VectorN<f32, U10000>, dot);
|
||||||
|
|
||||||
fn vec10000_axpy_f64(bh: &mut criterion::Criterion) {
|
fn vec10000_axpy_f64(bh: &mut criterion::Criterion) {
|
||||||
use rand::SeedableRng;
|
|
||||||
let mut rng = IsaacRng::seed_from_u64(0);
|
let mut rng = IsaacRng::seed_from_u64(0);
|
||||||
let mut a = DVector::new_random(10000);
|
let mut a = DVector::new_random(10000);
|
||||||
let b = DVector::new_random(10000);
|
let b = DVector::new_random(10000);
|
||||||
|
@ -58,7 +58,6 @@ fn vec10000_axpy_f64(bh: &mut criterion::Criterion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vec10000_axpy_beta_f64(bh: &mut criterion::Criterion) {
|
fn vec10000_axpy_beta_f64(bh: &mut criterion::Criterion) {
|
||||||
use rand::SeedableRng;
|
|
||||||
let mut rng = IsaacRng::seed_from_u64(0);
|
let mut rng = IsaacRng::seed_from_u64(0);
|
||||||
let mut a = DVector::new_random(10000);
|
let mut a = DVector::new_random(10000);
|
||||||
let b = DVector::new_random(10000);
|
let b = DVector::new_random(10000);
|
||||||
|
@ -69,7 +68,6 @@ fn vec10000_axpy_beta_f64(bh: &mut criterion::Criterion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vec10000_axpy_f64_slice(bh: &mut criterion::Criterion) {
|
fn vec10000_axpy_f64_slice(bh: &mut criterion::Criterion) {
|
||||||
use rand::SeedableRng;
|
|
||||||
let mut rng = IsaacRng::seed_from_u64(0);
|
let mut rng = IsaacRng::seed_from_u64(0);
|
||||||
let mut a = DVector::new_random(10000);
|
let mut a = DVector::new_random(10000);
|
||||||
let b = DVector::new_random(10000);
|
let b = DVector::new_random(10000);
|
||||||
|
@ -84,7 +82,6 @@ fn vec10000_axpy_f64_slice(bh: &mut criterion::Criterion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vec10000_axpy_f64_static(bh: &mut criterion::Criterion) {
|
fn vec10000_axpy_f64_static(bh: &mut criterion::Criterion) {
|
||||||
use rand::SeedableRng;
|
|
||||||
let mut rng = IsaacRng::seed_from_u64(0);
|
let mut rng = IsaacRng::seed_from_u64(0);
|
||||||
let mut a = VectorN::<f64, U10000>::new_random();
|
let mut a = VectorN::<f64, U10000>::new_random();
|
||||||
let b = VectorN::<f64, U10000>::new_random();
|
let b = VectorN::<f64, U10000>::new_random();
|
||||||
|
@ -95,7 +92,6 @@ fn vec10000_axpy_f64_static(bh: &mut criterion::Criterion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vec10000_axpy_f32(bh: &mut criterion::Criterion) {
|
fn vec10000_axpy_f32(bh: &mut criterion::Criterion) {
|
||||||
use rand::SeedableRng;
|
|
||||||
let mut rng = IsaacRng::seed_from_u64(0);
|
let mut rng = IsaacRng::seed_from_u64(0);
|
||||||
let mut a = DVector::new_random(10000);
|
let mut a = DVector::new_random(10000);
|
||||||
let b = DVector::new_random(10000);
|
let b = DVector::new_random(10000);
|
||||||
|
@ -105,7 +101,6 @@ fn vec10000_axpy_f32(bh: &mut criterion::Criterion) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vec10000_axpy_beta_f32(bh: &mut criterion::Criterion) {
|
fn vec10000_axpy_beta_f32(bh: &mut criterion::Criterion) {
|
||||||
use rand::SeedableRng;
|
|
||||||
let mut rng = IsaacRng::seed_from_u64(0);
|
let mut rng = IsaacRng::seed_from_u64(0);
|
||||||
let mut a = DVector::new_random(10000);
|
let mut a = DVector::new_random(10000);
|
||||||
let b = DVector::new_random(10000);
|
let b = DVector::new_random(10000);
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use na::{Quaternion, UnitQuaternion, Vector3};
|
use na::{Quaternion, UnitQuaternion, Vector3};
|
||||||
use rand::{IsaacRng, Rng};
|
|
||||||
use std::ops::{Add, Div, Mul, Sub};
|
use std::ops::{Add, Div, Mul, Sub};
|
||||||
|
|
||||||
#[path = "../common/macros.rs"]
|
#[path = "../common/macros.rs"]
|
||||||
|
|
|
@ -10,15 +10,14 @@ extern crate typenum;
|
||||||
extern crate criterion;
|
extern crate criterion;
|
||||||
|
|
||||||
use na::DMatrix;
|
use na::DMatrix;
|
||||||
use rand::{IsaacRng, Rng};
|
use rand::{Rng, SeedableRng};
|
||||||
|
|
||||||
pub mod core;
|
pub mod core;
|
||||||
pub mod geometry;
|
pub mod geometry;
|
||||||
pub mod linalg;
|
pub mod linalg;
|
||||||
|
|
||||||
fn reproductible_dmatrix(nrows: usize, ncols: usize) -> DMatrix<f64> {
|
fn reproductible_dmatrix(nrows: usize, ncols: usize) -> DMatrix<f64> {
|
||||||
use rand::SeedableRng;
|
let mut rng = rand_isaac::IsaacRng::seed_from_u64(0);
|
||||||
let mut rng = IsaacRng::seed_from_u64(0);
|
|
||||||
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.gen())
|
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.gen())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ set -ev
|
||||||
|
|
||||||
if [ -z "$NO_STD" ]; then
|
if [ -z "$NO_STD" ]; then
|
||||||
if [ -z "$LAPACK" ]; then
|
if [ -z "$LAPACK" ]; then
|
||||||
|
cargo build --verbose -p nalgebra --no-default-features --lib;
|
||||||
cargo build --verbose -p nalgebra;
|
cargo build --verbose -p nalgebra;
|
||||||
cargo build --verbose -p nalgebra --features "arbitrary";
|
cargo build --verbose -p nalgebra --features "arbitrary";
|
||||||
cargo build --verbose -p nalgebra --features "mint";
|
cargo build --verbose -p nalgebra --features "mint";
|
||||||
|
|
|
@ -4,6 +4,7 @@ set -ev
|
||||||
|
|
||||||
if [ -z "$NO_STD" ]; then
|
if [ -z "$NO_STD" ]; then
|
||||||
if [ -z "$LAPACK" ]; then
|
if [ -z "$LAPACK" ]; then
|
||||||
|
cargo test --verbose --no-default-features --lib;
|
||||||
cargo test --verbose;
|
cargo test --verbose;
|
||||||
cargo test --verbose "arbitrary";
|
cargo test --verbose "arbitrary";
|
||||||
cargo test --verbose --all-features;
|
cargo test --verbose --all-features;
|
||||||
|
|
|
@ -37,4 +37,4 @@ lapack-src = { version = "0.2", default-features = false }
|
||||||
nalgebra = { version = "0.18", path = "..", features = [ "arbitrary" ] }
|
nalgebra = { version = "0.18", path = "..", features = [ "arbitrary" ] }
|
||||||
quickcheck = "0.8"
|
quickcheck = "0.8"
|
||||||
approx = "0.3"
|
approx = "0.3"
|
||||||
rand = "0.6"
|
rand = "0.7"
|
||||||
|
|
|
@ -7,7 +7,7 @@ use num::{Bounded, One, Zero};
|
||||||
use rand::distributions::{Distribution, Standard};
|
use rand::distributions::{Distribution, Standard};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
use rand::{self, distributions::StandardNormal};
|
use rand_distr::StandardNormal;
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use typenum::{self, Cmp, Greater};
|
use typenum::{self, Cmp, Greater};
|
||||||
|
|
||||||
|
@ -243,7 +243,8 @@ where DefaultAllocator: Allocator<N, R, C>
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
pub fn new_random_generic(nrows: R, ncols: C) -> Self
|
pub fn new_random_generic(nrows: R, ncols: C) -> Self
|
||||||
where Standard: Distribution<N> {
|
where Standard: Distribution<N> {
|
||||||
Self::from_fn_generic(nrows, ncols, |_, _| rand::random())
|
let mut rng = rand::thread_rng();
|
||||||
|
Self::from_fn_generic(nrows, ncols, |_, _| rng.gen())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a matrix filled with random values from the given distribution.
|
/// Creates a matrix filled with random values from the given distribution.
|
||||||
|
@ -794,6 +795,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(specialization): faster impls possible for D≤4 (see rand_distr::{UnitCircle, UnitSphere})
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
impl<N: RealField, D: DimName> Distribution<Unit<VectorN<N, D>>> for Standard
|
impl<N: RealField, D: DimName> Distribution<Unit<VectorN<N, D>>> for Standard
|
||||||
where
|
where
|
||||||
|
|
|
@ -681,6 +681,7 @@ impl<N: RealField> Orthographic3<N> {
|
||||||
impl<N: RealField> Distribution<Orthographic3<N>> for Standard
|
impl<N: RealField> Distribution<Orthographic3<N>> for Standard
|
||||||
where Standard: Distribution<N>
|
where Standard: Distribution<N>
|
||||||
{
|
{
|
||||||
|
/// Generate an arbitrary random variate for testing purposes.
|
||||||
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> Orthographic3<N> {
|
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> Orthographic3<N> {
|
||||||
let left = r.gen();
|
let left = r.gen();
|
||||||
let right = helper::reject_rand(r, |x: &N| *x > left);
|
let right = helper::reject_rand(r, |x: &N| *x > left);
|
||||||
|
|
|
@ -264,6 +264,7 @@ impl<N: RealField> Perspective3<N> {
|
||||||
impl<N: RealField> Distribution<Perspective3<N>> for Standard
|
impl<N: RealField> Distribution<Perspective3<N>> for Standard
|
||||||
where Standard: Distribution<N>
|
where Standard: Distribution<N>
|
||||||
{
|
{
|
||||||
|
/// Generate an arbitrary random variate for testing purposes.
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, r: &'a mut R) -> Perspective3<N> {
|
fn sample<'a, R: Rng + ?Sized>(&self, r: &'a mut R) -> Perspective3<N> {
|
||||||
let znear = r.gen();
|
let znear = r.gen();
|
||||||
let zfar = helper::reject_rand(r, |&x: &N| !(x - znear).is_zero());
|
let zfar = helper::reject_rand(r, |&x: &N| !(x - znear).is_zero());
|
||||||
|
|
|
@ -131,6 +131,7 @@ where
|
||||||
DefaultAllocator: Allocator<N, D>,
|
DefaultAllocator: Allocator<N, D>,
|
||||||
Standard: Distribution<N>,
|
Standard: Distribution<N>,
|
||||||
{
|
{
|
||||||
|
/// Generates a `Point` where each coordinate is an independent variate from `[0, 1)`.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> Point<N, D> {
|
fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> Point<N, D> {
|
||||||
Point::from(rng.gen::<VectorN<N, D>>())
|
Point::from(rng.gen::<VectorN<N, D>>())
|
||||||
|
|
|
@ -724,13 +724,12 @@ where
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
extern crate rand_xorshift;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use rand::SeedableRng;
|
use rand::{SeedableRng, rngs::SmallRng};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn random_unit_quats_are_unit() {
|
fn random_unit_quats_are_unit() {
|
||||||
let mut rng = rand_xorshift::XorShiftRng::from_seed([0xAB; 16]);
|
let mut rng = SmallRng::seed_from_u64(2);
|
||||||
for _ in 0..1000 {
|
for _ in 0..1000 {
|
||||||
let x = rng.gen::<UnitQuaternion<f32>>();
|
let x = rng.gen::<UnitQuaternion<f32>>();
|
||||||
assert!(relative_eq!(x.into_inner().norm(), 1.0))
|
assert!(relative_eq!(x.into_inner().norm(), 1.0))
|
||||||
|
|
|
@ -5,7 +5,7 @@ use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
use num::Zero;
|
use num::Zero;
|
||||||
use rand::distributions::{Distribution, OpenClosed01, Standard};
|
use rand::distributions::{Distribution, OpenClosed01, Standard, uniform::SampleUniform};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use std::ops::Neg;
|
use std::ops::Neg;
|
||||||
|
|
||||||
|
@ -231,12 +231,12 @@ impl<N: RealField> Rotation2<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: RealField> Distribution<Rotation2<N>> for Standard
|
impl<N: RealField> Distribution<Rotation2<N>> for Standard
|
||||||
where OpenClosed01: Distribution<N>
|
where N: SampleUniform
|
||||||
{
|
{
|
||||||
/// Generate a uniformly distributed random rotation.
|
/// Generate a uniformly distributed random rotation.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Rotation2<N> {
|
fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Rotation2<N> {
|
||||||
Rotation2::new(rng.sample(OpenClosed01) * N::two_pi())
|
Rotation2::new(rng.gen_range(N::zero(), N::two_pi()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -818,7 +818,7 @@ impl<N: RealField> Rotation3<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: RealField> Distribution<Rotation3<N>> for Standard
|
impl<N: RealField> Distribution<Rotation3<N>> for Standard
|
||||||
where OpenClosed01: Distribution<N>
|
where OpenClosed01: Distribution<N>, N: SampleUniform
|
||||||
{
|
{
|
||||||
/// Generate a uniformly distributed random rotation.
|
/// Generate a uniformly distributed random rotation.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -828,7 +828,7 @@ where OpenClosed01: Distribution<N>
|
||||||
// In D. Kirk, editor, Graphics Gems III, pages 117-120. Academic, New York, 1992.
|
// In D. Kirk, editor, Graphics Gems III, pages 117-120. Academic, New York, 1992.
|
||||||
|
|
||||||
// Compute a random rotation around Z
|
// Compute a random rotation around Z
|
||||||
let theta = N::two_pi() * rng.sample(OpenClosed01);
|
let theta = rng.gen_range(N::zero(), N::two_pi());
|
||||||
let (ts, tc) = theta.sin_cos();
|
let (ts, tc) = theta.sin_cos();
|
||||||
let a = MatrixN::<N, U3>::new(
|
let a = MatrixN::<N, U3>::new(
|
||||||
tc,
|
tc,
|
||||||
|
@ -843,7 +843,7 @@ where OpenClosed01: Distribution<N>
|
||||||
);
|
);
|
||||||
|
|
||||||
// Compute a random rotation *of* Z
|
// Compute a random rotation *of* Z
|
||||||
let phi = N::two_pi() * rng.sample(OpenClosed01);
|
let phi = rng.gen_range(N::zero(), N::two_pi());
|
||||||
let z = rng.sample(OpenClosed01);
|
let z = rng.sample(OpenClosed01);
|
||||||
let (ps, pc) = phi.sin_cos();
|
let (ps, pc) = phi.sin_cos();
|
||||||
let sqrt_z = z.sqrt();
|
let sqrt_z = z.sqrt();
|
||||||
|
|
|
@ -63,6 +63,7 @@ where
|
||||||
DefaultAllocator: Allocator<N, D>,
|
DefaultAllocator: Allocator<N, D>,
|
||||||
Standard: Distribution<N> + Distribution<R>,
|
Standard: Distribution<N> + Distribution<R>,
|
||||||
{
|
{
|
||||||
|
/// Generate an arbitrary random variate for testing purposes.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> Similarity<N, D, R> {
|
fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> Similarity<N, D, R> {
|
||||||
let mut s = rng.gen();
|
let mut s = rng.gen();
|
||||||
|
|
|
@ -52,6 +52,7 @@ where
|
||||||
DefaultAllocator: Allocator<N, D>,
|
DefaultAllocator: Allocator<N, D>,
|
||||||
Standard: Distribution<N>,
|
Standard: Distribution<N>,
|
||||||
{
|
{
|
||||||
|
/// Generate an arbitrary random variate for testing purposes.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Translation<N, D> {
|
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Translation<N, D> {
|
||||||
Translation::from(rng.gen::<VectorN<N, D>>())
|
Translation::from(rng.gen::<VectorN<N, D>>())
|
||||||
|
|
|
@ -3,7 +3,7 @@ use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use num::One;
|
use num::One;
|
||||||
use num_complex::Complex;
|
use num_complex::Complex;
|
||||||
use rand::distributions::{Distribution, OpenClosed01, Standard};
|
use rand::distributions::{Distribution, Standard, uniform::SampleUniform};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
|
@ -276,12 +276,12 @@ impl<N: RealField> One for UnitComplex<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: RealField> Distribution<UnitComplex<N>> for Standard
|
impl<N: RealField> Distribution<UnitComplex<N>> for Standard
|
||||||
where OpenClosed01: Distribution<N>
|
where N: SampleUniform
|
||||||
{
|
{
|
||||||
/// Generate a uniformly distributed random `UnitComplex`.
|
/// Generate a uniformly distributed random `UnitComplex`.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, rng: &mut R) -> UnitComplex<N> {
|
fn sample<'a, R: Rng + ?Sized>(&self, rng: &mut R) -> UnitComplex<N> {
|
||||||
UnitComplex::from_angle(rng.sample(OpenClosed01) * N::two_pi())
|
UnitComplex::from_angle(rng.gen_range(N::zero(), N::two_pi()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -354,6 +354,7 @@ mod test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "std")]
|
||||||
#[test]
|
#[test]
|
||||||
fn wilkinson_shift_random() {
|
fn wilkinson_shift_random() {
|
||||||
for _ in 0..1000 {
|
for _ in 0..1000 {
|
||||||
|
|
|
@ -33,6 +33,7 @@ impl<N: RealField> Distribution<RandComplex<N>> for Standard
|
||||||
|
|
||||||
// This is a wrapper similar to RandComplex, but for non-complex.
|
// This is a wrapper similar to RandComplex, but for non-complex.
|
||||||
// This exists only to make generic tests easier to write.
|
// This exists only to make generic tests easier to write.
|
||||||
|
// Generates variates in the range [0, 1). Do we want this? E.g. we could use standard normal samples instead.
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub struct RandScalar<N>(pub N);
|
pub struct RandScalar<N>(pub N);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue