Make rand optional
Tests pass with default features (rand_with_std) Tests pass with std only, with --tests restriction (doc tests fail)
This commit is contained in:
parent
01f155b00a
commit
6ebb768309
10
Cargo.toml
10
Cargo.toml
|
@ -20,9 +20,11 @@ name = "nalgebra"
|
||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = [ "std" ]
|
default = [ "std", "rand_with_std" ]
|
||||||
std = [ "matrixmultiply", "rand/std", "alga/std", "rand_distr" ]
|
std = [ "matrixmultiply", "alga/std" ]
|
||||||
stdweb = [ "rand/stdweb" ]
|
# Since Cargo doesn't support multiplicitave features, use this to enable rand+std:
|
||||||
|
rand_with_std = [ "rand/std", "std", "rand_distr" ]
|
||||||
|
stdweb = [ "rand", "rand/stdweb" ]
|
||||||
arbitrary = [ "quickcheck" ]
|
arbitrary = [ "quickcheck" ]
|
||||||
serde-serialize = [ "serde", "serde_derive", "num-complex/serde" ]
|
serde-serialize = [ "serde", "serde_derive", "num-complex/serde" ]
|
||||||
abomonation-serialize = [ "abomonation" ]
|
abomonation-serialize = [ "abomonation" ]
|
||||||
|
@ -34,7 +36,7 @@ io = [ "pest", "pest_derive" ]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
typenum = "1.10"
|
typenum = "1.10"
|
||||||
generic-array = "0.12"
|
generic-array = "0.12"
|
||||||
rand = { version = "0.7", default-features = false }
|
rand = { version = "0.7", optional = true, default-features = false }
|
||||||
rand_distr = { version = "0.2", optional = true }
|
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 }
|
||||||
|
|
|
@ -5,6 +5,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 --no-default-features --lib;
|
||||||
|
cargo test --verbose --no-default-features --features "std" --tests;
|
||||||
cargo test --verbose;
|
cargo test --verbose;
|
||||||
cargo test --verbose "arbitrary";
|
cargo test --verbose "arbitrary";
|
||||||
cargo test --verbose --all-features;
|
cargo test --verbose --all-features;
|
||||||
|
|
|
@ -4,14 +4,12 @@ use crate::base::storage::Owned;
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use num::{Bounded, One, Zero};
|
use num::{Bounded, One, Zero};
|
||||||
use rand::distributions::{Distribution, Standard};
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::{Rng, distributions::{Distribution, Standard}};
|
||||||
#[cfg(feature = "std")]
|
|
||||||
use rand_distr::StandardNormal;
|
|
||||||
use std::iter;
|
use std::iter;
|
||||||
use typenum::{self, Cmp, Greater};
|
use typenum::{self, Cmp, Greater};
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "rand_distr")]
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
use alga::general::{ClosedAdd, ClosedMul};
|
use alga::general::{ClosedAdd, ClosedMul};
|
||||||
|
|
||||||
|
@ -240,7 +238,7 @@ where DefaultAllocator: Allocator<N, R, C>
|
||||||
|
|
||||||
/// Creates a matrix filled with random values.
|
/// Creates a matrix filled with random values.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "rand_with_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> {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
|
@ -248,6 +246,7 @@ where DefaultAllocator: Allocator<N, R, C>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a matrix filled with random values from the given distribution.
|
/// Creates a matrix filled with random values from the given distribution.
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_distribution_generic<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
|
pub fn from_distribution_generic<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
|
||||||
nrows: R,
|
nrows: R,
|
||||||
|
@ -548,6 +547,7 @@ macro_rules! impl_constructors(
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a matrix or vector filled with random values from the given distribution.
|
/// Creates a matrix or vector filled with random values from the given distribution.
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
|
pub fn from_distribution<Distr: Distribution<N> + ?Sized, G: Rng + ?Sized>(
|
||||||
$($args: usize,)*
|
$($args: usize,)*
|
||||||
|
@ -558,6 +558,7 @@ macro_rules! impl_constructors(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: Scalar, $($DimIdent: $DimBound, )*> MatrixMN<N $(, $Dims)*>
|
impl<N: Scalar, $($DimIdent: $DimBound, )*> MatrixMN<N $(, $Dims)*>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<N $(, $Dims)*>,
|
DefaultAllocator: Allocator<N $(, $Dims)*>,
|
||||||
|
@ -565,7 +566,7 @@ macro_rules! impl_constructors(
|
||||||
|
|
||||||
/// Creates a matrix filled with random values.
|
/// Creates a matrix filled with random values.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "rand_with_std")]
|
||||||
pub fn new_random($($args: usize),*) -> Self {
|
pub fn new_random($($args: usize),*) -> Self {
|
||||||
Self::new_random_generic($($gargs),*)
|
Self::new_random_generic($($gargs),*)
|
||||||
}
|
}
|
||||||
|
@ -761,6 +762,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: Scalar, R: Dim, C: Dim> Distribution<MatrixMN<N, R, C>> for Standard
|
impl<N: Scalar, R: Dim, C: Dim> Distribution<MatrixMN<N, R, C>> for Standard
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<N, R, C>,
|
DefaultAllocator: Allocator<N, R, C>,
|
||||||
|
@ -796,11 +798,11 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(specialization): faster impls possible for D≤4 (see rand_distr::{UnitCircle, UnitSphere})
|
// TODO(specialization): faster impls possible for D≤4 (see rand_distr::{UnitCircle, UnitSphere})
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "rand_distr")]
|
||||||
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
|
||||||
DefaultAllocator: Allocator<N, D>,
|
DefaultAllocator: Allocator<N, D>,
|
||||||
StandardNormal: Distribution<N>,
|
rand_distr::StandardNormal: Distribution<N>,
|
||||||
{
|
{
|
||||||
/// Generate a uniformly distributed random unit vector.
|
/// Generate a uniformly distributed random unit vector.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -808,7 +810,7 @@ where
|
||||||
Unit::new_normalize(VectorN::from_distribution_generic(
|
Unit::new_normalize(VectorN::from_distribution_generic(
|
||||||
D::name(),
|
D::name(),
|
||||||
U1,
|
U1,
|
||||||
&StandardNormal,
|
&rand_distr::StandardNormal,
|
||||||
rng,
|
rng,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![cfg(feature = "rand")]
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
use rand::distributions::{Distribution, Standard};
|
use rand::distributions::{Distribution, Standard};
|
||||||
|
|
|
@ -4,8 +4,8 @@ use crate::base::storage::Owned;
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use num::One;
|
use num::One;
|
||||||
use rand::distributions::{Distribution, Standard};
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::{Rng, distributions::{Distribution, Standard}};
|
||||||
|
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
use alga::linear::Rotation as AlgaRotation;
|
use alga::linear::Rotation as AlgaRotation;
|
||||||
|
@ -75,6 +75,7 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: RealField, D: DimName, R> Distribution<Isometry<N, D, R>> for Standard
|
impl<N: RealField, D: DimName, R> Distribution<Isometry<N, D, R>> for Standard
|
||||||
where
|
where
|
||||||
R: AlgaRotation<Point<N, D>>,
|
R: AlgaRotation<Point<N, D>>,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
use rand::distributions::{Distribution, Standard};
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::{Rng, distributions::{Distribution, Standard}};
|
||||||
#[cfg(feature = "serde-serialize")]
|
#[cfg(feature = "serde-serialize")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
@ -10,6 +10,7 @@ use std::mem;
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
|
|
||||||
use crate::base::dimension::U3;
|
use crate::base::dimension::U3;
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
use crate::base::helper;
|
use crate::base::helper;
|
||||||
use crate::base::storage::Storage;
|
use crate::base::storage::Storage;
|
||||||
use crate::base::{Matrix4, Vector, Vector3};
|
use crate::base::{Matrix4, Vector, Vector3};
|
||||||
|
@ -678,6 +679,7 @@ impl<N: RealField> Orthographic3<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: RealField> Distribution<Orthographic3<N>> for Standard
|
impl<N: RealField> Distribution<Orthographic3<N>> for Standard
|
||||||
where Standard: Distribution<N>
|
where Standard: Distribution<N>
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
use rand::distributions::{Distribution, Standard};
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::{Rng, distributions::{Distribution, Standard}};
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize")]
|
#[cfg(feature = "serde-serialize")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
@ -11,6 +11,7 @@ use std::mem;
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
|
|
||||||
use crate::base::dimension::U3;
|
use crate::base::dimension::U3;
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
use crate::base::helper;
|
use crate::base::helper;
|
||||||
use crate::base::storage::Storage;
|
use crate::base::storage::Storage;
|
||||||
use crate::base::{Matrix4, Scalar, Vector, Vector3};
|
use crate::base::{Matrix4, Scalar, Vector, Vector3};
|
||||||
|
@ -261,6 +262,7 @@ impl<N: RealField> Perspective3<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: RealField> Distribution<Perspective3<N>> for Standard
|
impl<N: RealField> Distribution<Perspective3<N>> for Standard
|
||||||
where Standard: Distribution<N>
|
where Standard: Distribution<N>
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use num::{Bounded, One, Zero};
|
use num::{Bounded, One, Zero};
|
||||||
use rand::distributions::{Distribution, Standard};
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::{Rng, distributions::{Distribution, Standard}};
|
||||||
|
|
||||||
use alga::general::ClosedDiv;
|
use alga::general::ClosedDiv;
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
|
@ -126,6 +126,7 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: Scalar, D: DimName> Distribution<Point<N, D>> for Standard
|
impl<N: Scalar, D: DimName> Distribution<Point<N, D>> for Standard
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<N, D>,
|
DefaultAllocator: Allocator<N, D>,
|
||||||
|
|
|
@ -6,8 +6,8 @@ use crate::base::storage::Owned;
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use rand::distributions::{Distribution, OpenClosed01, Standard};
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::{Rng, distributions::{Distribution, OpenClosed01, Standard}};
|
||||||
|
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
|
|
||||||
|
@ -124,6 +124,7 @@ impl<N: RealField> Zero for Quaternion<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: RealField> Distribution<Quaternion<N>> for Standard
|
impl<N: RealField> Distribution<Quaternion<N>> for Standard
|
||||||
where Standard: Distribution<N>
|
where Standard: Distribution<N>
|
||||||
{
|
{
|
||||||
|
@ -685,6 +686,7 @@ impl<N: RealField> One for UnitQuaternion<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: RealField> Distribution<UnitQuaternion<N>> for Standard
|
impl<N: RealField> Distribution<UnitQuaternion<N>> for Standard
|
||||||
where OpenClosed01: Distribution<N>
|
where OpenClosed01: Distribution<N>
|
||||||
{
|
{
|
||||||
|
@ -722,10 +724,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(all(test, feature="rand"))]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use rand::{SeedableRng, rngs::SmallRng};
|
use rand::{Rng, SeedableRng, rngs::SmallRng};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn random_unit_quats_are_unit() {
|
fn random_unit_quats_are_unit() {
|
||||||
|
|
|
@ -5,7 +5,9 @@ use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
use num::Zero;
|
use num::Zero;
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
use rand::distributions::{Distribution, OpenClosed01, Standard, uniform::SampleUniform};
|
use rand::distributions::{Distribution, OpenClosed01, Standard, uniform::SampleUniform};
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
use std::ops::Neg;
|
use std::ops::Neg;
|
||||||
|
|
||||||
|
@ -230,6 +232,7 @@ impl<N: RealField> Rotation2<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: RealField> Distribution<Rotation2<N>> for Standard
|
impl<N: RealField> Distribution<Rotation2<N>> for Standard
|
||||||
where N: SampleUniform
|
where N: SampleUniform
|
||||||
{
|
{
|
||||||
|
@ -817,6 +820,7 @@ impl<N: RealField> Rotation3<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: RealField> Distribution<Rotation3<N>> for Standard
|
impl<N: RealField> Distribution<Rotation3<N>> for Standard
|
||||||
where OpenClosed01: Distribution<N>, N: SampleUniform
|
where OpenClosed01: Distribution<N>, N: SampleUniform
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,8 +4,8 @@ use crate::base::storage::Owned;
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use num::One;
|
use num::One;
|
||||||
use rand::distributions::{Distribution, Standard};
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::{Rng, distributions::{Distribution, Standard}};
|
||||||
|
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
use alga::linear::Rotation as AlgaRotation;
|
use alga::linear::Rotation as AlgaRotation;
|
||||||
|
@ -57,6 +57,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: RealField, D: DimName, R> Distribution<Similarity<N, D, R>> for Standard
|
impl<N: RealField, D: DimName, R> Distribution<Similarity<N, D, R>> for Standard
|
||||||
where
|
where
|
||||||
R: AlgaRotation<Point<N, D>>,
|
R: AlgaRotation<Point<N, D>>,
|
||||||
|
|
|
@ -4,8 +4,8 @@ use crate::base::storage::Owned;
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use rand::distributions::{Distribution, Standard};
|
#[cfg(feature = "rand")]
|
||||||
use rand::Rng;
|
use rand::{Rng, distributions::{Distribution, Standard}};
|
||||||
|
|
||||||
use alga::general::ClosedAdd;
|
use alga::general::ClosedAdd;
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand")]
|
||||||
impl<N: Scalar, D: DimName> Distribution<Translation<N, D>> for Standard
|
impl<N: Scalar, D: DimName> Distribution<Translation<N, D>> for Standard
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<N, D>,
|
DefaultAllocator: Allocator<N, D>,
|
||||||
|
|
|
@ -3,7 +3,9 @@ use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use num::One;
|
use num::One;
|
||||||
use num_complex::Complex;
|
use num_complex::Complex;
|
||||||
|
#[cfg(feature = "rand_distr")]
|
||||||
use rand::distributions::{Distribution, Standard};
|
use rand::distributions::{Distribution, Standard};
|
||||||
|
#[cfg(feature = "rand_distr")]
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use alga::general::RealField;
|
use alga::general::RealField;
|
||||||
|
@ -275,7 +277,7 @@ impl<N: RealField> One for UnitComplex<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "rand_distr")]
|
||||||
impl<N: RealField> Distribution<UnitComplex<N>> for Standard
|
impl<N: RealField> Distribution<UnitComplex<N>> for Standard
|
||||||
where rand_distr::UnitCircle: Distribution<[N; 2]>
|
where rand_distr::UnitCircle: Distribution<[N; 2]>
|
||||||
{
|
{
|
||||||
|
@ -287,17 +289,6 @@ where rand_distr::UnitCircle: Distribution<[N; 2]>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
|
||||||
impl<N: RealField> Distribution<UnitComplex<N>> for Standard
|
|
||||||
where N: rand::distributions::uniform::SampleUniform
|
|
||||||
{
|
|
||||||
/// Generate a uniformly distributed random `UnitComplex`.
|
|
||||||
#[inline]
|
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, rng: &mut R) -> UnitComplex<N> {
|
|
||||||
UnitComplex::from_angle(rng.gen_range(N::zero(), N::two_pi()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "arbitrary")]
|
#[cfg(feature = "arbitrary")]
|
||||||
impl<N: RealField + Arbitrary> Arbitrary for UnitComplex<N> {
|
impl<N: RealField + Arbitrary> Arbitrary for UnitComplex<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -112,7 +112,6 @@ extern crate matrixmultiply;
|
||||||
extern crate num_complex;
|
extern crate num_complex;
|
||||||
extern crate num_traits as num;
|
extern crate num_traits as num;
|
||||||
extern crate num_rational;
|
extern crate num_rational;
|
||||||
extern crate rand;
|
|
||||||
extern crate typenum;
|
extern crate typenum;
|
||||||
|
|
||||||
extern crate alga;
|
extern crate alga;
|
||||||
|
|
|
@ -354,7 +354,7 @@ mod test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "rand_with_std")]
|
||||||
#[test]
|
#[test]
|
||||||
fn wilkinson_shift_random() {
|
fn wilkinson_shift_random() {
|
||||||
for _ in 0..1000 {
|
for _ in 0..1000 {
|
||||||
|
|
|
@ -466,6 +466,7 @@ fn zip_map() {
|
||||||
assert_eq!(computed, expected);
|
assert_eq!(computed, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "rand_with_std")]
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn trace_panic() {
|
fn trace_panic() {
|
||||||
|
|
Loading…
Reference in New Issue