Skip to content

Commit

Permalink
Merge pull request #869 from dimforge/dev
Browse files Browse the repository at this point in the history
Release v0.26.0
  • Loading branch information
sebcrozet committed Apr 12, 2021
2 parents e9535d5 + c5c6c13 commit 156f292
Show file tree
Hide file tree
Showing 245 changed files with 10,110 additions and 10,552 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/nalgebra-ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
run: cargo build --no-default-features;
- name: Build (default features)
run: cargo build;
- name: Build --features serde-serialize
run: cargo build --features serde-serialize
- name: Build --all-features
run: cargo build --all-features;
- name: Build nalgebra-glm
Expand All @@ -55,7 +57,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: test nalgebra-glm
run: cargo test -p nalgebra-glm --features arbitrary,rand,serde-serialize,abomonation-serialize,sparse,debug,io,compare,libm,proptest-support,slow-tests;
run: cargo test -p nalgebra-glm --features arbitrary,serde-serialize,abomonation-serialize;
test-nalgebra-sparse:
runs-on: ubuntu-latest
steps:
Expand Down
44 changes: 44 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,50 @@ documented here.

This project adheres to [Semantic Versioning](https://semver.org/).

## [0.26.0]
This releases integrates `min-const-generics` to nalgebra. See
[our blog post](https://dimforge.com/blog/2021/04/12/nalgebra-const-generics)
for details about this release.

### Added
- Add type aliases for unit vector, e.g., `UnitVector3`.
- Add a `pow` and `pow_mut` function to square matrices.
- Add `Cholesky::determinant` to compute the determinant of a matrix decomposed
with Cholesky.
- Add the `serde-serialize-no-std` feature to enable serialization of static matrices/vectors
with serde, but without requiring `std`.


### Modified
- The `serde` crate isn't enabled by default now. Enable the `serde-serialize` or the
`serde-serialize-no-std` features instead.
- The `Const<const D: usize>` type has been introduced to represent dimensions known
at compile-time. This replaces the type-level integers from `typenum` as well as
the `U1, U2, ..., U127` types from `nalgebra`. These `U1, U2, ..., U127` are now
just aliases for `Const<D>`, e.g., `type U2 = Const<2>`.
- The `ArrayStorage` now uses a standard array `[[T; R]; C]` instead of a `GenericArray`.
- Many trait bounds were changed to accommodate const-generics. Most of these changes
should be transparent wrt. non-generic code.
- The `MatrixMN` alias has been deprecated. Use `OMatrix` or `SMatrix` instead.
- The `MatrixN<T, D>` alias has been deprecated. Use `OMatrix<T, D, D>` or `SMatrix` instead.
- The `VectorN<T, D>` alias has been deprecated. Use `OVector` or `SVector` instead.
- The `Point`, `Translation`, `Isometry`, `Similarity`, and `Transformation` types now take an
integer for their dimension (instead of a type-level integer).
- The type parameter order of `Isometry`, `Similarity`, `Transformation` changed to put
the integer dimensions in the last position (this is required by the compiler).
- The `::new` constructors of translations, points, matrices, and vectors of dimensions `<= 6`
are now `const fn`, making them usable to define constant globals. The `Quaternion::new`
constructor is also a `const fn` now.

## [0.25.4]
### Fixed
- Fix a compilation error when only the `serde-serialize` feature is enabled.

## [0.25.3]
### Added
- The `Vector::simd_cap_magnitude` method to cap the magnitude of the a vector with
SIMD components.

## [0.25.2]
### Added
- A `convert-glam` cargo feature to enable implementations of `From` traits to convert
Expand Down
41 changes: 24 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nalgebra"
version = "0.25.2"
version = "0.26.0"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]

description = "General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices."
Expand All @@ -22,28 +22,35 @@ name = "nalgebra"
path = "src/lib.rs"

[features]
default = [ "std" ]
std = [ "matrixmultiply", "simba/std" ]
sparse = [ ]
debug = [ "approx/num-complex", "rand" ]
alloc = [ ]
io = [ "pest", "pest_derive" ]
default = [ "std" ]
std = [ "matrixmultiply", "simba/std" ]
sparse = [ ]
debug = [ "approx/num-complex", "rand" ]
alloc = [ ]
io = [ "pest", "pest_derive" ]
compare = [ "matrixcompare-core" ]
libm = [ "simba/libm" ]
libm = [ "simba/libm" ]
libm-force = [ "simba/libm_force" ]
no_unsound_assume_init = [ ]

# Conversion
convert-mint = [ "mint" ]
convert-glam = [ "glam" ]
convert-glam-unchecked = [ "convert-glam" ] # Unable edgy conversions like Mat4 -> Isometry3
convert-glam-unchecked = [ "convert-glam" ] # Enable edgy conversions like Mat4 -> Isometry3
convert-bytemuck = [ "bytemuck" ]

# Serialization
serde-serialize = [ "serde", "num-complex/serde" ]
abomonation-serialize = [ "abomonation" ]
## To use serde in a #[no-std] environment, enable the
## `serde-serialize-no-std` feature instead of `serde-serialize`.
## Serialization of dynamically-sized matrices/vectors require
## `serde-serialize`.
serde-serialize-no-std = [ "serde", "num-complex/serde" ]
serde-serialize = [ "serde-serialize-no-std", "serde/std" ]
abomonation-serialize = [ "abomonation" ]

# Randomness
## To use rand in a #[no-std] environment, enable the
## `rand-no-std` feature instead of `rand`.
rand-no-std = [ "rand-package" ]
rand = [ "rand-no-std", "rand-package/std", "rand-package/std_rng", "rand_distr" ]

Expand All @@ -54,7 +61,6 @@ slow-tests = []

[dependencies]
typenum = "1.12"
generic-array = "0.14"
rand-package = { package = "rand", version = "0.8", optional = true, default-features = false }
num-traits = { version = "0.2", default-features = false }
num-complex = { version = "0.3", default-features = false }
Expand All @@ -79,18 +85,19 @@ proptest = { version = "1", optional = true, default-features = false, features
serde_json = "1.0"
rand_xorshift = "0.3"
rand_isaac = "0.3"
### 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
### https://github.com/rust-lang/cargo/issues/4866
#criterion = "0.2.10"
criterion = "0.2.10"

# For matrix comparison macro
matrixcompare = "0.2.0"
itertools = "0.10"

[workspace]
members = [ "nalgebra-lapack", "nalgebra-glm", "nalgebra-sparse" ]
resolver = "2"

[[example]]
name = "matrixcompare"
required-features = ["compare"]

[[bench]]
name = "nalgebra_bench"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

-----

## Gold sponsors
## Platinum sponsors
Rapier is supported by:
<p>
<a href="https://embark-studios.com">
<img src="https://www.embark.dev/img/logo_black.png" width="301px">
<img src="https://www.embark.dev/img/logo_black.png" width="401px">
</a>
</p>
6 changes: 3 additions & 3 deletions benches/common/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ macro_rules! bench_unop_na(
i = (i + 1) & (LEN - 1);

unsafe {
test::black_box(na::$unop(elems.get_unchecked(i)))
std::hint::black_box(na::$unop(elems.get_unchecked(i)))
}
}));
}
Expand All @@ -82,7 +82,7 @@ macro_rules! bench_unop(
i = (i + 1) & (LEN - 1);

unsafe {
test::black_box(elems.get_unchecked_mut(i).$unop())
std::hint::black_box(elems.get_unchecked_mut(i).$unop())
}
}));
}
Expand All @@ -105,7 +105,7 @@ macro_rules! bench_construction(

unsafe {
let res = $constructor($(*$args.get_unchecked(i),)*);
test::black_box(res)
std::hint::black_box(res)
}
}));
}
Expand Down
8 changes: 4 additions & 4 deletions benches/core/matrix.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use na::{DMatrix, DVector, Matrix2, Matrix3, Matrix4, MatrixN, Vector2, Vector3, Vector4, U10};
use na::{DMatrix, DVector, Matrix2, Matrix3, Matrix4, OMatrix, Vector2, Vector3, Vector4, U10};
use rand::Rng;
use rand_isaac::IsaacRng;
use std::ops::{Add, Div, Mul, Sub};
Expand Down Expand Up @@ -116,8 +116,8 @@ fn mat10_mul_mat10(bench: &mut criterion::Criterion) {
}

fn mat10_mul_mat10_static(bench: &mut criterion::Criterion) {
let a = MatrixN::<f64, U10>::new_random();
let b = MatrixN::<f64, U10>::new_random();
let a = OMatrix::<f64, U10, U10>::new_random();
let b = OMatrix::<f64, U10, U10>::new_random();

bench.bench_function("mat10_mul_mat10_static", move |bh| bh.iter(|| &a * &b));
}
Expand Down Expand Up @@ -198,7 +198,7 @@ fn mat_mul_mat(bench: &mut criterion::Criterion) {

bench.bench_function("mat_mul_mat", move |bh| {
bh.iter(|| {
test::black_box(a.mul_to(&b, &mut ab));
std::hint::black_box(a.mul_to(&b, &mut ab));
})
});
}
Expand Down
17 changes: 8 additions & 9 deletions benches/core/vector.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use na::{DVector, Vector2, Vector3, Vector4, VectorN};
use na::{DVector, SVector, Vector2, Vector3, Vector4};
use rand::Rng;
use rand_isaac::IsaacRng;
use std::ops::{Add, Div, Mul, Sub};
use typenum::U10000;

#[path = "../common/macros.rs"]
mod macros;
Expand Down Expand Up @@ -45,8 +44,8 @@ bench_unop!(vec2_normalize, Vector2<f32>, normalize);
bench_unop!(vec3_normalize, Vector3<f32>, normalize);
bench_unop!(vec4_normalize, Vector4<f32>, normalize);

bench_binop_ref!(vec10000_dot_f64, VectorN<f64, U10000>, VectorN<f64, U10000>, dot);
bench_binop_ref!(vec10000_dot_f32, VectorN<f32, U10000>, VectorN<f32, U10000>, dot);
bench_binop_ref!(vec10000_dot_f64, SVector<f64, 10000>, SVector<f64, 10000>, dot);
bench_binop_ref!(vec10000_dot_f32, SVector<f32, 10000>, SVector<f32, 10000>, dot);

fn vec10000_axpy_f64(bh: &mut criterion::Criterion) {
use rand::SeedableRng;
Expand Down Expand Up @@ -82,8 +81,8 @@ fn vec10000_axpy_f64_slice(bh: &mut criterion::Criterion) {

bh.bench_function("vec10000_axpy_f64_slice", move |bh| {
bh.iter(|| {
let mut a = a.fixed_rows_mut::<U10000>(0);
let b = b.fixed_rows::<U10000>(0);
let mut a = a.fixed_rows_mut::<10000>(0);
let b = b.fixed_rows::<10000>(0);

a.axpy(n, &b, 1.0)
})
Expand All @@ -93,11 +92,11 @@ 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();
let mut a = SVector::<f64, 10000>::new_random();
let b = SVector::<f64, 10000>::new_random();
let n = rng.gen::<f64>();

// NOTE: for some reasons, it is much faster if the arument are boxed (Box::new(VectorN...)).
// NOTE: for some reasons, it is much faster if the arument are boxed (Box::new(OVector...)).
bh.bench_function("vec10000_axpy_f64_static", move |bh| {
bh.iter(|| a.axpy(n, &b, 1.0))
});
Expand Down
5 changes: 1 addition & 4 deletions benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
#![allow(unused_macros)]

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

#[macro_use]
extern crate criterion;
Expand Down
10 changes: 5 additions & 5 deletions benches/linalg/bidiagonal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ mod macros;
fn bidiagonalize_100x100(bh: &mut criterion::Criterion) {
let m = DMatrix::<f64>::new_random(100, 100);
bh.bench_function("bidiagonalize_100x100", move |bh| {
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
bh.iter(|| std::hint::black_box(Bidiagonal::new(m.clone())))
});
}

fn bidiagonalize_100x500(bh: &mut criterion::Criterion) {
let m = DMatrix::<f64>::new_random(100, 500);
bh.bench_function("bidiagonalize_100x500", move |bh| {
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
bh.iter(|| std::hint::black_box(Bidiagonal::new(m.clone())))
});
}

fn bidiagonalize_4x4(bh: &mut criterion::Criterion) {
let m = Matrix4::<f64>::new_random();
bh.bench_function("bidiagonalize_4x4", move |bh| {
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
bh.iter(|| std::hint::black_box(Bidiagonal::new(m.clone())))
});
}

fn bidiagonalize_500x100(bh: &mut criterion::Criterion) {
let m = DMatrix::<f64>::new_random(500, 100);
bh.bench_function("bidiagonalize_500x100", move |bh| {
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
bh.iter(|| std::hint::black_box(Bidiagonal::new(m.clone())))
});
}

fn bidiagonalize_500x500(bh: &mut criterion::Criterion) {
let m = DMatrix::<f64>::new_random(500, 500);
bh.bench_function("bidiagonalize_500x500", move |bh| {
bh.iter(|| test::black_box(Bidiagonal::new(m.clone())))
bh.iter(|| std::hint::black_box(Bidiagonal::new(m.clone())))
});
}

Expand Down
4 changes: 2 additions & 2 deletions benches/linalg/cholesky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ fn cholesky_100x100(bh: &mut criterion::Criterion) {
let m = &m * m.transpose();

bh.bench_function("cholesky_100x100", move |bh| {
bh.iter(|| test::black_box(Cholesky::new(m.clone())))
bh.iter(|| std::hint::black_box(Cholesky::new(m.clone())))
});
}

Expand All @@ -14,7 +14,7 @@ fn cholesky_500x500(bh: &mut criterion::Criterion) {
let m = &m * m.transpose();

bh.bench_function("cholesky_500x500", move |bh| {
bh.iter(|| test::black_box(Cholesky::new(m.clone())))
bh.iter(|| std::hint::black_box(Cholesky::new(m.clone())))
});
}

Expand Down

0 comments on commit 156f292

Please sign in to comment.