Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rand dependency to 0.7 + some tweaks #622

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nalgebra"
version = "0.18.1"
version = "0.18.2"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]

description = "Linear algebra library with transformations and statically-sized or dynamically-sized matrices."
Expand All @@ -20,32 +20,35 @@ name = "nalgebra"
path = "src/lib.rs"

[features]
default = [ "std" ]
std = [ "matrixmultiply", "rand/std", "alga/std" ]
stdweb = [ "rand/stdweb" ]
arbitrary = [ "quickcheck" ]
default = [ "std", "rand_with_std" ]
std = [ "matrixmultiply", "alga/std", "alloc" ]
# 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", "rand" ]
serde-serialize = [ "serde", "serde_derive", "num-complex/serde" ]
abomonation-serialize = [ "abomonation" ]
sparse = [ ]
debug = [ "approx/num-complex", "rand/std" ]
debug = [ "rand_with_std" ]
alloc = [ ]
io = [ "pest", "pest_derive" ]
serde_derive = [] # dummy feature to avoid breakage

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR already is not backwards compatible with v0.18, why keep this feature? Same in the nalgebra-lapack crate.

Same goes for the stdweb feature, I think it should be removed in the same way as you plan to do in rust-random/rand#886.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave that decision to @sebcrozet


[dependencies]
typenum = "1.10"
generic-array = "0.12"
rand = { version = "0.6", default-features = false }
rand = { version = "0.7", optional = true, default-features = false }
rand_distr = { version = "0.2", optional = true }
num-traits = { version = "0.2", default-features = false }
num-complex = { version = "0.2", default-features = false }
num-rational = { version = "0.2", default-features = false }
approx = { version = "0.3", default-features = false }
approx = { version = "0.3", default-features = false, features = ["num-complex"] }
alga = { version = "0.9", default-features = false }
matrixmultiply = { version = "0.2", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
abomonation = { version = "0.7", optional = true }
mint = { version = "0.5", optional = true }
quickcheck = { version = "0.8", optional = true }
quickcheck = { version = "0.9", optional = true }
pest = { version = "2.0", optional = true }
pest_derive = { version = "2.0", optional = true }

Expand All @@ -54,7 +57,9 @@ pest_derive = { version = "2.0", optional = true }

[dev-dependencies]
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.
### We can't just let this uncommented because that would break
### compilation for #[no-std] because of the terrible Cargo bug
Expand Down
1 change: 0 additions & 1 deletion benches/core/matrix.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use na::{DMatrix, DVector, Matrix2, Matrix3, Matrix4, MatrixN, Vector2, Vector3, Vector4, U10};
use rand::{IsaacRng, Rng};
use std::ops::{Add, Div, Mul, Sub};

#[path = "../common/macros.rs"]
Expand Down
9 changes: 2 additions & 7 deletions benches/core/vector.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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 typenum::U10000;

Expand Down Expand Up @@ -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);

fn vec10000_axpy_f64(bh: &mut criterion::Criterion) {
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);
let mut a = DVector::new_random(10000);
let b = DVector::new_random(10000);
Expand All @@ -58,7 +58,6 @@ fn vec10000_axpy_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 a = DVector::new_random(10000);
let b = DVector::new_random(10000);
Expand All @@ -69,7 +68,6 @@ fn vec10000_axpy_beta_f64(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 a = DVector::new_random(10000);
let b = DVector::new_random(10000);
Expand All @@ -84,7 +82,6 @@ fn vec10000_axpy_f64_slice(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 a = VectorN::<f64, U10000>::new_random();
let b = VectorN::<f64, U10000>::new_random();
Expand All @@ -95,7 +92,6 @@ fn vec10000_axpy_f64_static(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 a = DVector::new_random(10000);
let b = DVector::new_random(10000);
Expand All @@ -105,7 +101,6 @@ fn vec10000_axpy_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 a = DVector::new_random(10000);
let b = DVector::new_random(10000);
Expand Down
1 change: 0 additions & 1 deletion benches/geometry/quaternion.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use na::{Quaternion, UnitQuaternion, Vector3};
use rand::{IsaacRng, Rng};
use std::ops::{Add, Div, Mul, Sub};

#[path = "../common/macros.rs"]
Expand Down
10 changes: 3 additions & 7 deletions benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,19 @@
#![allow(unused_macros)]

extern crate nalgebra as na;
extern crate rand;
extern crate test;
extern crate typenum;

#[macro_use]
extern crate criterion;

use na::DMatrix;
use rand::{IsaacRng, Rng};
use rand::{Rng, SeedableRng};

pub mod core;
pub mod geometry;
pub mod linalg;

fn reproductible_dmatrix(nrows: usize, ncols: usize) -> DMatrix<f64> {
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);
let mut rng = rand_isaac::IsaacRng::seed_from_u64(0);
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.gen())
}

Expand All @@ -36,4 +32,4 @@ criterion_main!(
linalg::solve,
linalg::svd,
linalg::symmetric_eigen,
);
);
4 changes: 3 additions & 1 deletion ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ set -ev

if [ -z "$NO_STD" ]; then
if [ -z "$LAPACK" ]; then
cargo build --verbose -p nalgebra --no-default-features --lib;
cargo build --verbose -p nalgebra;
cargo build --verbose -p nalgebra --features "rand";
cargo build --verbose -p nalgebra --features "arbitrary";
cargo build --verbose -p nalgebra --features "mint";
cargo build --verbose -p nalgebra --features "alloc";
Expand All @@ -25,4 +27,4 @@ EOF
rustup component add rust-src
cargo install xargo
xargo build --verbose --no-default-features --target=x86_64-unknown-linux-gnu --features "${CARGO_FEATURES}";
fi
fi
5 changes: 3 additions & 2 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ set -ev

if [ -z "$NO_STD" ]; then
if [ -z "$LAPACK" ]; then
cargo test --verbose --no-default-features --features "std" --tests;
cargo test --verbose;
cargo test --verbose "arbitrary";
cargo test --verbose --features "arbitrary";
cargo test --verbose --all-features;
cd nalgebra-glm; cargo test --verbose;
else
cd nalgebra-lapack; cargo test --verbose;
fi
fi
fi
1 change: 0 additions & 1 deletion examples/dimensional_genericity.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern crate alga;
extern crate nalgebra as na;

use alga::linear::FiniteDimInnerSpace;
Expand Down
3 changes: 1 addition & 2 deletions examples/identity.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern crate alga;
extern crate nalgebra as na;

use alga::linear::Transformation;
Expand Down Expand Up @@ -36,4 +35,4 @@ fn main() {
// They both return the same result.
assert!(result1 == Vector3::new(100001.0, 200002.0, 300003.0));
assert!(result2 == Vector3::new(100001.0, 200002.0, 300003.0));
}
}
1 change: 0 additions & 1 deletion examples/scalar_genericity.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern crate alga;
extern crate nalgebra as na;

use alga::general::{RealField, RingCommutative};
Expand Down
1 change: 0 additions & 1 deletion examples/transform_matrix4.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern crate alga;
#[macro_use]
extern crate approx;
extern crate nalgebra as na;
Expand Down
1 change: 0 additions & 1 deletion examples/transform_vector_point3.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
extern crate alga;
extern crate nalgebra as na;

use na::{Matrix4, Point3, Vector3, Vector4};
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/geometric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::aliases::{TVec, TVec3};
use crate::traits::{Alloc, Dimension, Number};

/// The cross product of two vectors.
pub fn cross<N: Number, D: Dimension>(x: &TVec3<N>, y: &TVec3<N>) -> TVec3<N> {
pub fn cross<N: Number>(x: &TVec3<N>, y: &TVec3<N>) -> TVec3<N> {
x.cross(y)
}

Expand Down
1 change: 0 additions & 1 deletion nalgebra-glm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
extern crate num_traits as num;
#[macro_use]
extern crate approx;
extern crate alga;
extern crate nalgebra as na;

pub use crate::aliases::*;
Expand Down
10 changes: 5 additions & 5 deletions nalgebra-lapack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ license = "BSD-3-Clause"
edition = "2018"

[features]
serde-serialize = [ "serde", "serde_derive" ]
serde-serialize = [ "serde" ] # kept to avoid breakage; prefer to use serde feature directly
serde_derive = [] # dummy feature to avoid breakage

# For BLAS/LAPACK
default = ["openblas"]
Expand All @@ -27,14 +28,13 @@ nalgebra = { version = "0.18", path = ".." }
num-traits = "0.2"
num-complex = { version = "0.2", default-features = false }
alga = { version = "0.9", default-features = false }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
serde = { version = "1.0", optional = true, features = ["derive"] }
lapack = { version = "0.16", default-features = false }
lapack-src = { version = "0.2", default-features = false }
# clippy = "*"

[dev-dependencies]
nalgebra = { version = "0.18", path = "..", features = [ "arbitrary" ] }
quickcheck = "0.8"
quickcheck = "0.9"
approx = "0.3"
rand = "0.6"
rand = "0.7"
2 changes: 0 additions & 2 deletions nalgebra-lapack/benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@

extern crate nalgebra as na;
extern crate nalgebra_lapack as nl;
extern crate rand;
extern crate test;

mod linalg;
4 changes: 0 additions & 4 deletions nalgebra-lapack/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@
html_root_url = "https://nalgebra.org/rustdoc"
)]

extern crate alga;
extern crate lapack;
extern crate lapack_src;
extern crate nalgebra as na;
extern crate num_complex;
extern crate num_traits as num;

mod lapack_check;
Expand Down
10 changes: 5 additions & 5 deletions src/base/alias.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(any(feature = "alloc", feature = "std"))]
#[cfg(feature = "alloc")]
use crate::base::dimension::Dynamic;
use crate::base::dimension::{U1, U2, U3, U4, U5, U6};
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg(feature = "alloc")]
use crate::base::vec_storage::VecStorage;
use crate::base::storage::Owned;
use crate::base::Matrix;
Expand All @@ -24,7 +24,7 @@ pub type MatrixMN<N, R, C> = Matrix<N, R, C, Owned<N, R, C>>;
pub type MatrixN<N, D> = MatrixMN<N, D, D>;

/// A dynamically sized column-major matrix.
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg(feature = "alloc")]
pub type DMatrix<N> = MatrixN<N, Dynamic>;

/// A stack-allocated, column-major, 1x1 square matrix.
Expand Down Expand Up @@ -118,7 +118,7 @@ pub type Matrix6x5<N> = MatrixMN<N, U6, U5>;
*
*/
/// A dynamically sized column vector.
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg(feature = "alloc")]
pub type DVector<N> = Matrix<N, Dynamic, U1, VecStorage<N, Dynamic, U1>>;

/// A statically sized D-dimensional column vector.
Expand All @@ -145,7 +145,7 @@ pub type Vector6<N> = VectorN<N, U6>;
*
*/
/// A dynamically sized row vector.
#[cfg(any(feature = "std", feature = "alloc"))]
#[cfg(feature = "alloc")]
pub type RowDVector<N> = Matrix<N, U1, Dynamic, VecStorage<N, U1, Dynamic>>;

/// A statically sized D-dimensional row vector.
Expand Down
Loading