Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/nalgebra-ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
- name: Select rustc version
uses: actions-rs/toolchain@v1
with:
toolchain: 1.79.0
toolchain: 1.85.0
override: true
- uses: actions/checkout@v4
- name: check
Expand All @@ -77,7 +77,7 @@ jobs:
- name: Select rustc version
uses: actions-rs/toolchain@v1
with:
toolchain: 1.81.0
toolchain: 1.85.0
override: true
- uses: actions/checkout@v4
- name: test
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ This project adheres to [Semantic Versioning](https://semver.org/).

- Add the `convert-glam030` feature to enable conversion from/to types from `glam` v0.30.

### Changed

- Moved to Rust 2024 edition.

## [0.33.2] (29 October 2024)

### Added
Expand Down
6 changes: 4 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ readme = "README.md"
categories = ["science", "mathematics", "wasm", "no-std"]
keywords = ["linear", "algebra", "matrix", "vector", "math"]
license = "Apache-2.0"
edition = "2018"
edition = "2024"
rust-version = "1.85.0"
exclude = ["/ci/*", "/.travis.yml", "/Makefile"]

[badges]
Expand Down Expand Up @@ -103,6 +104,7 @@ matrixmultiply = { version = "0.3", optional = true }
serde = { version = "1.0", default-features = false, features = [
"derive",
], optional = true }
# TODO: once rkyv is updated to 0.8, we could consider removing the `allow(unsafe_op_in_unsafe_fn)`.
rkyv = { version = "0.7.41", default-features = false, optional = true }
mint = { version = "0.5", optional = true }
quickcheck = { version = "1", optional = true }
Expand Down Expand Up @@ -134,7 +136,7 @@ rayon = { version = "1.6", optional = true }
[dev-dependencies]
serde_json = "1.0"
rand_xorshift = "0.4"
rand_isaac = "0.3"
rand_isaac = "0.4"
criterion = { version = "0.4", features = ["html_reports"] }
nalgebra = { path = ".", features = ["debug", "compare", "rand", "macros"] }

Expand Down
18 changes: 9 additions & 9 deletions benches/common/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ macro_rules! bench_binop(
fn $name(bh: &mut criterion::Criterion) {
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);
let a = rng.gen::<$t1>();
let b = rng.gen::<$t2>();
let a = rng.random::<$t1>();
let b = rng.random::<$t2>();

bh.bench_function(stringify!($name), move |bh| bh.iter(|| {
a.$binop(b)
Expand All @@ -20,8 +20,8 @@ macro_rules! bench_binop_ref(
fn $name(bh: &mut criterion::Criterion) {
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);
let a = rng.gen::<$t1>();
let b = rng.gen::<$t2>();
let a = rng.random::<$t1>();
let b = rng.random::<$t2>();

bh.bench_function(stringify!($name), move |bh| bh.iter(|| {
a.$binop(&b)
Expand All @@ -35,8 +35,8 @@ macro_rules! bench_binop_fn(
fn $name(bh: &mut criterion::Criterion) {
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);
let a = rng.gen::<$t1>();
let b = rng.gen::<$t2>();
let a = rng.random::<$t1>();
let b = rng.random::<$t2>();

bh.bench_function(stringify!($name), move |bh| bh.iter(|| {
$binop(&a, &b)
Expand All @@ -53,7 +53,7 @@ macro_rules! bench_unop_na(
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);

let elems: Vec<$t> = (0usize .. LEN).map(|_| rng.gen::<$t>()).collect();
let elems: Vec<$t> = (0usize .. LEN).map(|_| rng.random::<$t>()).collect();
let mut i = 0;

bh.bench_function(stringify!($name), move |bh| bh.iter(|| {
Expand All @@ -75,7 +75,7 @@ macro_rules! bench_unop(
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);

let mut elems: Vec<$t> = (0usize .. LEN).map(|_| rng.gen::<$t>()).collect();
let mut elems: Vec<$t> = (0usize .. LEN).map(|_| rng.random::<$t>()).collect();
let mut i = 0;

bh.bench_function(stringify!($name), move |bh| bh.iter(|| {
Expand All @@ -97,7 +97,7 @@ macro_rules! bench_construction(
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);

$(let $args: Vec<$types> = (0usize .. LEN).map(|_| rng.gen::<$types>()).collect();)*
$(let $args: Vec<$types> = (0usize .. LEN).map(|_| rng.random::<$types>()).collect();)*
let mut i = 0;

bh.bench_function(stringify!($name), move |bh| bh.iter(|| {
Expand Down
2 changes: 1 addition & 1 deletion 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, OMatrix, Vector2, Vector3, Vector4, U10};
use na::{DMatrix, DVector, Matrix2, Matrix3, Matrix4, OMatrix, U10, Vector2, Vector3, Vector4};
use rand::Rng;
use rand_isaac::IsaacRng;
use std::ops::{Add, Div, Mul, Sub};
Expand Down
16 changes: 8 additions & 8 deletions benches/core/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn vec10000_axpy_f64(bh: &mut criterion::Criterion) {
let mut rng = IsaacRng::seed_from_u64(0);
let mut a = DVector::new_random(10000);
let b = DVector::new_random(10000);
let n = rng.gen::<f64>();
let n = rng.random::<f64>();

bh.bench_function("vec10000_axpy_f64", move |bh| {
bh.iter(|| a.axpy(n, &b, 1.0))
Expand All @@ -64,8 +64,8 @@ fn vec10000_axpy_beta_f64(bh: &mut criterion::Criterion) {
let mut rng = IsaacRng::seed_from_u64(0);
let mut a = DVector::new_random(10000);
let b = DVector::new_random(10000);
let n = rng.gen::<f64>();
let beta = rng.gen::<f64>();
let n = rng.random::<f64>();
let beta = rng.random::<f64>();

bh.bench_function("vec10000_axpy_beta_f64", move |bh| {
bh.iter(|| a.axpy(n, &b, beta))
Expand All @@ -77,7 +77,7 @@ fn vec10000_axpy_f64_slice(bh: &mut criterion::Criterion) {
let mut rng = IsaacRng::seed_from_u64(0);
let mut a = DVector::new_random(10000);
let b = DVector::new_random(10000);
let n = rng.gen::<f64>();
let n = rng.random::<f64>();

bh.bench_function("vec10000_axpy_f64_slice", move |bh| {
bh.iter(|| {
Expand All @@ -94,7 +94,7 @@ fn vec10000_axpy_f64_static(bh: &mut criterion::Criterion) {
let mut rng = IsaacRng::seed_from_u64(0);
let mut a = SVector::<f64, 10000>::new_random();
let b = SVector::<f64, 10000>::new_random();
let n = rng.gen::<f64>();
let n = rng.random::<f64>();

// NOTE: for some reasons, it is much faster if the argument are boxed (Box::new(OVector...)).
bh.bench_function("vec10000_axpy_f64_static", move |bh| {
Expand All @@ -107,7 +107,7 @@ fn vec10000_axpy_f32(bh: &mut criterion::Criterion) {
let mut rng = IsaacRng::seed_from_u64(0);
let mut a = DVector::new_random(10000);
let b = DVector::new_random(10000);
let n = rng.gen::<f32>();
let n = rng.random::<f32>();

bh.bench_function("vec10000_axpy_f32", move |bh| {
bh.iter(|| a.axpy(n, &b, 1.0))
Expand All @@ -119,8 +119,8 @@ fn vec10000_axpy_beta_f32(bh: &mut criterion::Criterion) {
let mut rng = IsaacRng::seed_from_u64(0);
let mut a = DVector::new_random(10000);
let b = DVector::new_random(10000);
let n = rng.gen::<f32>();
let beta = rng.gen::<f32>();
let n = rng.random::<f32>();
let beta = rng.random::<f32>();

bh.bench_function("vec10000_axpy_beta_f32", move |bh| {
bh.iter(|| a.axpy(n, &b, beta))
Expand Down
2 changes: 1 addition & 1 deletion benches/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod linalg;
fn reproducible_dmatrix(nrows: usize, ncols: usize) -> DMatrix<f64> {
use rand::SeedableRng;
let mut rng = IsaacRng::seed_from_u64(0);
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.gen())
DMatrix::<f64>::from_fn(nrows, ncols, |_, _| rng.random())
}

criterion_main!(
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readme = "../README.md"
categories = ["science", "mathematics", "wasm", "no standard library"]
keywords = ["linear", "algebra", "matrix", "vector", "math"]
license = "Apache-2.0"
edition = "2018"
edition = "2024"

[badges]
maintenance = { status = "actively-developed" }
Expand Down
8 changes: 2 additions & 6 deletions nalgebra-glm/src/common.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use core::mem;

use crate::RealNumber;
use crate::aliases::{TMat, TVec};
use crate::traits::Number;
use crate::RealNumber;

/// For each matrix or vector component `x` if `x >= 0`; otherwise, it returns `-x`.
///
Expand Down Expand Up @@ -515,11 +515,7 @@ pub fn smoothstep<T: RealNumber>(edge0: T, edge1: T, x: T) -> T {

/// Returns 0.0 if `x < edge`, otherwise it returns 1.0.
pub fn step_scalar<T: Number>(edge: T, x: T) -> T {
if edge > x {
T::zero()
} else {
T::one()
}
if edge > x { T::zero() } else { T::one() }
}

/// Returns 0.0 if `x[i] < edge`, otherwise it returns 1.0.
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/constructors.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::RealNumber;
use crate::aliases::{
Qua, TMat, TMat2, TMat2x3, TMat2x4, TMat3, TMat3x2, TMat3x4, TMat4, TMat4x2, TMat4x3, TVec1,
TVec2, TVec3, TVec4,
};
use crate::RealNumber;
use na::Scalar;

/// Creates a new 1D vector.
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/exponential.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::aliases::TVec;
use crate::RealNumber;
use crate::aliases::TVec;

/// Component-wise exponential.
///
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/ext/matrix_clip_space.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::aliases::TMat4;
use crate::RealNumber;
use crate::aliases::TMat4;

//pub fn frustum<T: RealNumber>(left: T, right: T, bottom: T, top: T, near: T, far: T) -> TMat4<T> {
// unimplemented!()
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/ext/matrix_projection.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::aliases::{TMat4, TVec2, TVec3, TVec4};
use crate::RealNumber;
use crate::aliases::{TMat4, TVec2, TVec3, TVec4};

/// Define a picking region.
///
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/ext/quaternion_common.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use na::Unit;

use crate::aliases::Qua;
use crate::RealNumber;
use crate::aliases::Qua;

/// The conjugate of `q`.
pub fn quat_conjugate<T: RealNumber>(q: &Qua<T>) -> Qua<T> {
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/ext/quaternion_relational.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::aliases::{Qua, TVec};
use crate::RealNumber;
use crate::aliases::{Qua, TVec};

/// Component-wise equality comparison between two quaternions.
pub fn quat_equal<T: RealNumber>(x: &Qua<T>, y: &Qua<T>) -> TVec<bool, 4> {
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/ext/quaternion_transform.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use na::{Unit, UnitQuaternion};

use crate::aliases::{Qua, TVec3};
use crate::RealNumber;
use crate::aliases::{Qua, TVec3};

/// Computes the quaternion exponential.
pub fn quat_exp<T: RealNumber>(q: &Qua<T>) -> Qua<T> {
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/ext/quaternion_trigonometric.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use na::{Unit, UnitQuaternion};

use crate::aliases::{Qua, TVec3};
use crate::RealNumber;
use crate::aliases::{Qua, TVec3};

/// The rotation angle of this quaternion assumed to be normalized.
pub fn quat_angle<T: RealNumber>(x: &Qua<T>) -> T {
Expand Down
12 changes: 2 additions & 10 deletions nalgebra-glm/src/ext/scalar_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ use crate::traits::Number;
/// * [`min3_scalar()`]
/// * [`min4_scalar()`]
pub fn max2_scalar<T: Number>(a: T, b: T) -> T {
if a >= b {
a
} else {
b
}
if a >= b { a } else { b }
}

/// Returns the maximum among two values.
Expand All @@ -39,11 +35,7 @@ pub fn max2_scalar<T: Number>(a: T, b: T) -> T {
/// * [`min3_scalar()`]
/// * [`min4_scalar()`]
pub fn min2_scalar<T: Number>(a: T, b: T) -> T {
if a <= b {
a
} else {
b
}
if a <= b { a } else { b }
}

/// Returns the maximum among three values.
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/gtc/quaternion.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use na::UnitQuaternion;

use crate::aliases::{Qua, TMat4, TVec, TVec3};
use crate::RealNumber;
use crate::aliases::{Qua, TMat4, TVec, TVec3};

/// Euler angles of the quaternion `q` as (pitch, yaw, roll).
pub fn quat_euler_angles<T: RealNumber>(x: &Qua<T>) -> TVec3<T> {
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/gtx/matrix_cross_product.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::aliases::{TMat3, TMat4, TVec3};
use crate::RealNumber;
use crate::aliases::{TMat3, TMat4, TVec3};

/// Builds a 3x3 matrix `m` such that for any `v`: `m * v == cross(x, v)`.
///
Expand Down
4 changes: 2 additions & 2 deletions nalgebra-glm/src/gtx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ pub use self::rotate_vector::{
};
pub use self::transform::{rotation, rotation2d, scaling, scaling2d, translation, translation2d};
pub use self::transform2::{
proj, proj2d, reflect, reflect2d, scale_bias, scale_bias_matrix, shear2d_x, shear2d_y, shear_x,
shear_y, shear_z,
proj, proj2d, reflect, reflect2d, scale_bias, scale_bias_matrix, shear_x, shear_y, shear_z,
shear2d_x, shear2d_y,
};
pub use self::transform2d::{rotate2d, scale2d, translate2d};
pub use self::vector_angle::angle;
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/gtx/norm.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::aliases::TVec;
use crate::RealNumber;
use crate::aliases::TVec;

/// The squared distance between two points.
///
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/gtx/quaternion.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use na::{Rotation3, Unit, UnitQuaternion};

use crate::aliases::{Qua, TMat3, TMat4, TVec3, TVec4};
use crate::RealNumber;
use crate::aliases::{Qua, TMat3, TMat4, TVec3, TVec4};

/// Rotate the vector `v` by the quaternion `q` assumed to be normalized.
pub fn quat_cross_vec<T: RealNumber>(q: &Qua<T>, v: &TVec3<T>) -> TVec3<T> {
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/gtx/rotate_normalized_axis.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use na::{Rotation3, Unit, UnitQuaternion};

use crate::aliases::{Qua, TMat4, TVec3};
use crate::RealNumber;
use crate::aliases::{Qua, TMat4, TVec3};

/// Builds a rotation 4 * 4 matrix created from a normalized axis and an angle.
///
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/gtx/rotate_vector.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use na::{Rotation3, Unit, UnitComplex};

use crate::aliases::{TMat4, TVec2, TVec3, TVec4};
use crate::RealNumber;
use crate::aliases::{TMat4, TVec2, TVec3, TVec4};

/// Build the rotation matrix needed to align `normal` and `up`.
pub fn orientation<T: RealNumber>(normal: &TVec3<T>, up: &TVec3<T>) -> TMat4<T> {
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/gtx/transform2.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::RealNumber;
use crate::aliases::{TMat3, TMat4, TVec2, TVec3};
use crate::traits::Number;
use crate::RealNumber;

/// Build planar projection matrix along normal axis and right-multiply it to `m`.
pub fn proj2d<T: Number>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
Expand Down
Loading
Loading