Skip to content

Commit

Permalink
Merge pull request #1362 from dimforge/dev-0.32.4
Browse files Browse the repository at this point in the history
Release v0.32.4
  • Loading branch information
sebcrozet committed Feb 19, 2024
2 parents d8ed277 + e726b65 commit 4a5855a
Show file tree
Hide file tree
Showing 47 changed files with 524 additions and 79 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,37 @@ documented here.

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

## [0.32.4] (19 Feb 2023)
- Add the `glam-0.25` feature to enable conversion from/to types from `glam` v0.25.

## [0.32.3] (09 July 2023)

### Modified
- Statically sized matrices are now serialized as tuples to match how serde
serialized plain arrays.
- Don’t require `Scalar` for matrix `PartialEq` and `Eq`.

### Added
- Allow trailing punctuation in macros `vector!`, `matrix!`, `point!`, etc.
- Add the methods `Matrix1::as_scalar`, `::as_scalar_mut`, `::to_scalar`, `::into_scalar`.
- Add `Rotation3::euler_angles_ordered`, a generalized euler angles calculation.
- Add the `glam-0.24` feature to enable conversion from/to types from `glam` v0.24.
- Add the `lerp` method to points.
- Implement `Clone` for `MatrixIter`.

### Fixed
- Fixed severe catastrophic cancellation issue in variance calculation.

## [0.32.2] (07 March 2023)

### Added
- Add the `glam-0.23` to enable conversion from/to type from `glam` v0.23.

## [0.32.1] (14 Jan. 2023)

### Modified
- Updated `nalgebra-macros` to use the new `Dyn`, avoiding macro-generated deprecation warnings.

## [0.32.0] (14 Jan. 2023)

### Modified
Expand Down
16 changes: 11 additions & 5 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "nalgebra"
version = "0.32.0"
version = "0.32.4"
authors = [ "Sébastien Crozet <developer@crozet.re>" ]

description = "General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices."
Expand Down Expand Up @@ -47,6 +47,9 @@ convert-glam019 = [ "glam019" ]
convert-glam020 = [ "glam020" ]
convert-glam021 = [ "glam021" ]
convert-glam022 = [ "glam022" ]
convert-glam023 = [ "glam023" ]
convert-glam024 = [ "glam024" ]
convert-glam025 = [ "glam025" ]

# Serialization
## To use serde in a #[no-std] environment, enable the
Expand All @@ -56,7 +59,7 @@ convert-glam022 = [ "glam022" ]
serde-serialize-no-std = [ "serde", "num-complex/serde" ]
serde-serialize = [ "serde-serialize-no-std", "serde/std" ]
rkyv-serialize-no-std = [ "rkyv/size_32" ]
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std", "rkyv/validation", "bytecheck" ]
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std", "rkyv/validation" ]

# Randomness
## To use rand in a #[no-std] environment, enable the
Expand All @@ -71,7 +74,7 @@ slow-tests = []
rkyv-safe-deser = [ "rkyv-serialize", "rkyv/validation" ]

[dependencies]
nalgebra-macros = { version = "0.1", path = "nalgebra-macros", optional = true }
nalgebra-macros = { version = "0.2.1", path = "nalgebra-macros", optional = true }
typenum = "1.12"
rand-package = { package = "rand", version = "0.8", optional = true, default-features = false }
num-traits = { version = "0.2", default-features = false }
Expand All @@ -83,8 +86,7 @@ alga = { version = "0.9", default-features = false, optional = true }
rand_distr = { version = "0.4", default-features = false, optional = true }
matrixmultiply = { version = "0.3", optional = true }
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
rkyv = { version = "0.7", default-features = false, optional = true }
bytecheck = { version = "~0.6.1", optional = true }
rkyv = { version = "0.7.41", default-features = false, optional = true }
mint = { version = "0.5", optional = true }
quickcheck = { version = "1", optional = true }
pest = { version = "2", optional = true }
Expand All @@ -101,6 +103,9 @@ glam019 = { package = "glam", version = "0.19", optional = true }
glam020 = { package = "glam", version = "0.20", optional = true }
glam021 = { package = "glam", version = "0.21", optional = true }
glam022 = { package = "glam", version = "0.22", optional = true }
glam023 = { package = "glam", version = "0.23", optional = true }
glam024 = { package = "glam", version = "0.24", optional = true }
glam025 = { package = "glam", version = "0.25", optional = true }
cust_core = { version = "0.1", optional = true }
rayon = { version = "1.6", optional = true }

Expand All @@ -109,6 +114,7 @@ serde_json = "1.0"
rand_xorshift = "0.3"
rand_isaac = "0.3"
criterion = { version = "0.4", features = ["html_reports"] }
nalgebra = { path = ".", features = ["debug", "compare", "rand", "macros"]}

# For matrix comparison macro
matrixcompare = "0.3.0"
Expand Down
19 changes: 0 additions & 19 deletions README.md
Expand Up @@ -29,22 +29,3 @@
</p>

-----

## Acknowledgements
nalgebra is supported by our **platinum** sponsors:
<p>
<a href="https://embark-studios.com">
<img src="https://www.embark.dev/img/logo_black.png" width="301px">
</a>
</p>

And our gold sponsors:

<p>
<a href="https://fragcolor.com">
<img src="https://dimforge.com/img/fragcolor_logo2_color_black.svg" width="300px">
</a>
<a href="https://resolutiongames.com/">
<img src="https://dimforge.com/img/logo_resolution_games.png" width="300px" />
</a>
</p>
8 changes: 4 additions & 4 deletions nalgebra-glm/src/gtc/epsilon.rs
Expand Up @@ -7,24 +7,24 @@ use na::DefaultAllocator;
use crate::traits::{Alloc, Number, Dimension};
use crate::aliases::TVec;
/// Component-wise approximate equality beween two vectors.
/// Component-wise approximate equality between two vectors.
pub fn epsilon_equal<T: Number, const D: usize>(x: &TVec<T, D>, y: &TVec<T, D>, epsilon: T) -> TVec<bool, D>
where DefaultAllocator: Alloc<T, D> {
x.zip_map(y, |x, y| abs_diff_eq!(x, y, epsilon = epsilon))
}
/// Component-wise approximate equality beween two scalars.
/// Component-wise approximate equality between two scalars.
pub fn epsilon_equal2<T: AbsDiffEq<Epsilon = T>>(x: T, y: T, epsilon: T) -> bool {
abs_diff_eq!(x, y, epsilon = epsilon)
}
/// Component-wise approximate non-equality beween two vectors.
/// Component-wise approximate non-equality between two vectors.
pub fn epsilon_not_equal<T: Number, const D: usize>(x: &TVec<T, D>, y: &TVec<T, D>, epsilon: T) -> TVec<bool, D>
where DefaultAllocator: Alloc<T, D> {
x.zip_map(y, |x, y| abs_diff_ne!(x, y, epsilon = epsilon))
}
/// Component-wise approximate non-equality beween two scalars.
/// Component-wise approximate non-equality between two scalars.
pub fn epsilon_not_equal2<T: AbsDiffEq<Epsilon = T>>(x: T, y: T, epsilon: T) -> bool {
abs_diff_ne!(x, y, epsilon = epsilon)
}
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-glm/src/gtx/quaternion.rs
Expand Up @@ -80,7 +80,7 @@ pub fn quat_to_mat3<T: RealNumber>(x: &Qua<T>) -> TMat3<T> {
.into_inner()
}

/// Converts a quaternion to a rotation matrix in homogenous coordinates.
/// Converts a quaternion to a rotation matrix in homogeneous coordinates.
pub fn quat_to_mat4<T: RealNumber>(x: &Qua<T>) -> TMat4<T> {
UnitQuaternion::new_unchecked(*x).to_homogeneous()
}
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-macros/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "nalgebra-macros"
version = "0.1.0"
version = "0.2.1"
authors = [ "Andreas Longva", "Sébastien Crozet <developer@crozet.re>" ]
edition = "2018"
description = "Procedural macros for nalgebra"
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-macros/src/lib.rs
Expand Up @@ -223,7 +223,7 @@ impl Parse for Vector {
elements: Vec::new(),
})
} else {
let elements = MatrixRowSyntax::parse_separated_nonempty(input)?
let elements = MatrixRowSyntax::parse_terminated(input)?
.into_iter()
.collect();
Ok(Self { elements })
Expand Down
13 changes: 13 additions & 0 deletions nalgebra-macros/tests/tests.rs
Expand Up @@ -94,6 +94,12 @@ fn dmatrix_small_dims_exhaustive() {
DMatrix::from_row_slice(4, 4, &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]));
}

#[test]
fn matrix_trailing_semi() {
matrix![1, 2;];
dmatrix![1, 2;];
}

// Skip rustfmt because it just makes the test bloated without making it more readable
#[rustfmt::skip]
#[test]
Expand Down Expand Up @@ -151,6 +157,13 @@ fn dvector_small_dims_exhaustive() {
assert_eq_and_type!(dvector![1, 2, 3, 4, 5, 6], DVector::from_column_slice(&[1, 2, 3, 4, 5, 6]));
}

#[test]
fn vector_trailing_comma() {
vector![1, 2,];
point![1, 2,];
dvector![1, 2,];
}

#[test]
fn matrix_trybuild_tests() {
let t = trybuild::TestCases::new();
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-sparse/src/cs.rs
Expand Up @@ -494,7 +494,7 @@ where
assert_eq!(source_minor_indices.len(), values.len());
let nnz = values.len();

// Count the number of occurences of each minor index
// Count the number of occurrences of each minor index
let mut minor_counts = vec![0; minor_dim];
for minor_idx in source_minor_indices {
minor_counts[*minor_idx] += 1;
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-sparse/src/ops/serial/csc.rs
Expand Up @@ -98,7 +98,7 @@ where

/// Faster sparse-sparse matrix multiplication, `C <- beta * C + alpha * op(A) * op(B)`.
/// This will not return an error even if the patterns don't match.
/// Should be used for situations where pattern creation immediately preceeds multiplication.
/// Should be used for situations where pattern creation immediately precedes multiplication.
///
/// Panics if the dimensions of the matrices involved are not compatible with the expression.
pub fn spmm_csc_prealloc_unchecked<T>(
Expand Down
2 changes: 1 addition & 1 deletion nalgebra-sparse/src/ops/serial/csr.rs
Expand Up @@ -89,7 +89,7 @@ where

/// Faster sparse-sparse matrix multiplication, `C <- beta * C + alpha * op(A) * op(B)`.
/// This will not return an error even if the patterns don't match.
/// Should be used for situations where pattern creation immediately preceeds multiplication.
/// Should be used for situations where pattern creation immediately precedes multiplication.
///
/// Panics if the dimensions of the matrices involved are not compatible with the expression.
pub fn spmm_csr_prealloc_unchecked<T>(
Expand Down
12 changes: 6 additions & 6 deletions src/base/alias.rs
Expand Up @@ -81,32 +81,32 @@ pub type MatrixXx5<T> = Matrix<T, Dyn, U5, VecStorage<T, Dyn, U5>>;
#[cfg(any(feature = "std", feature = "alloc"))]
pub type MatrixXx6<T> = Matrix<T, Dyn, U6, VecStorage<T, Dyn, U6>>;

/// A heap-allocated, row-major, matrix with 1 rows and a dynamic number of columns.
/// A heap-allocated, column-major, matrix with 1 rows and a dynamic number of columns.
///
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
#[cfg(any(feature = "std", feature = "alloc"))]
pub type Matrix1xX<T> = Matrix<T, U1, Dyn, VecStorage<T, U1, Dyn>>;
/// A heap-allocated, row-major, matrix with 2 rows and a dynamic number of columns.
/// A heap-allocated, column-major, matrix with 2 rows and a dynamic number of columns.
///
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
#[cfg(any(feature = "std", feature = "alloc"))]
pub type Matrix2xX<T> = Matrix<T, U2, Dyn, VecStorage<T, U2, Dyn>>;
/// A heap-allocated, row-major, matrix with 3 rows and a dynamic number of columns.
/// A heap-allocated, column-major, matrix with 3 rows and a dynamic number of columns.
///
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
#[cfg(any(feature = "std", feature = "alloc"))]
pub type Matrix3xX<T> = Matrix<T, U3, Dyn, VecStorage<T, U3, Dyn>>;
/// A heap-allocated, row-major, matrix with 4 rows and a dynamic number of columns.
/// A heap-allocated, column-major, matrix with 4 rows and a dynamic number of columns.
///
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
#[cfg(any(feature = "std", feature = "alloc"))]
pub type Matrix4xX<T> = Matrix<T, U4, Dyn, VecStorage<T, U4, Dyn>>;
/// A heap-allocated, row-major, matrix with 5 rows and a dynamic number of columns.
/// A heap-allocated, column-major, matrix with 5 rows and a dynamic number of columns.
///
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
#[cfg(any(feature = "std", feature = "alloc"))]
pub type Matrix5xX<T> = Matrix<T, U5, Dyn, VecStorage<T, U5, Dyn>>;
/// A heap-allocated, row-major, matrix with 6 rows and a dynamic number of columns.
/// A heap-allocated, column-major, matrix with 6 rows and a dynamic number of columns.
///
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
#[cfg(any(feature = "std", feature = "alloc"))]
Expand Down
4 changes: 2 additions & 2 deletions src/base/allocator.rs
Expand Up @@ -20,9 +20,9 @@ use std::mem::MaybeUninit;
/// Every allocator must be both static and dynamic. Though not all implementations may share the
/// same `Buffer` type.
pub trait Allocator<T, R: Dim, C: Dim = U1>: Any + Sized {
/// The type of buffer this allocator can instanciate.
/// The type of buffer this allocator can instantiate.
type Buffer: StorageMut<T, R, C> + IsContiguous + Clone + Debug;
/// The type of buffer with uninitialized components this allocator can instanciate.
/// The type of buffer with uninitialized components this allocator can instantiate.
type BufferUninit: RawStorageMut<MaybeUninit<T>, R, C> + IsContiguous;

/// Allocates a buffer with the given number of rows and columns without initializing its content.
Expand Down
9 changes: 6 additions & 3 deletions src/base/array_storage.rs
Expand Up @@ -5,12 +5,15 @@ use std::ops::Mul;
#[cfg(feature = "serde-serialize-no-std")]
use serde::de::{Error, SeqAccess, Visitor};
#[cfg(feature = "serde-serialize-no-std")]
use serde::ser::SerializeSeq;
use serde::ser::SerializeTuple;
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};
#[cfg(feature = "serde-serialize-no-std")]
use std::marker::PhantomData;

#[cfg(feature = "rkyv-serialize")]
use rkyv::bytecheck;

use crate::base::allocator::Allocator;
use crate::base::default_allocator::DefaultAllocator;
use crate::base::dimension::{Const, ToTypenum};
Expand Down Expand Up @@ -189,7 +192,7 @@ where
where
S: Serializer,
{
let mut serializer = serializer.serialize_seq(Some(R * C))?;
let mut serializer = serializer.serialize_tuple(R * C)?;

for e in self.as_slice().iter() {
serializer.serialize_element(e)?;
Expand All @@ -208,7 +211,7 @@ where
where
D: Deserializer<'a>,
{
deserializer.deserialize_seq(ArrayStorageVisitor::new())
deserializer.deserialize_tuple(R * C, ArrayStorageVisitor::new())
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/base/dimension.rs
Expand Up @@ -8,6 +8,8 @@ use std::fmt::Debug;
use std::ops::{Add, Div, Mul, Sub};
use typenum::{self, Diff, Max, Maximum, Min, Minimum, Prod, Quot, Sum, Unsigned};

#[cfg(feature = "rkyv-serialize")]
use rkyv::bytecheck;
#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

Expand Down
2 changes: 1 addition & 1 deletion src/base/edition.rs
Expand Up @@ -1077,7 +1077,7 @@ where
}

// Move the elements of `data` in such a way that the matrix with
// the rows `[i, i + nremove[` deleted is represented in a contigous
// the rows `[i, i + nremove[` deleted is represented in a contiguous
// way in `data` after this method completes.
// Every deleted element are manually dropped by this method.
unsafe fn compress_rows<T: Scalar>(
Expand Down
10 changes: 5 additions & 5 deletions src/base/iter.rs
Expand Up @@ -15,9 +15,9 @@ use crate::base::storage::{RawStorage, RawStorageMut};
use crate::base::{Matrix, MatrixView, MatrixViewMut, Scalar};

macro_rules! iterator {
(struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => {
(struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty, $($derives:ident),* $(,)?) => {
/// An iterator through a dense matrix with arbitrary strides matrix.
#[derive(Debug)]
#[derive($($derives),*)]
pub struct $Name<'a, T, R: Dim, C: Dim, S: 'a + $Storage<T, R, C>> {
ptr: $Ptr,
inner_ptr: $Ptr,
Expand All @@ -39,7 +39,7 @@ macro_rules! iterator {
let ptr = storage.$ptr();

// If we have a size of 0, 'ptr' must be
// dangling. Howver, 'inner_offset' might
// dangling. However, 'inner_offset' might
// not be zero if only one dimension is zero, so
// we don't want to call 'offset'.
// This pointer will never actually get used
Expand Down Expand Up @@ -177,8 +177,8 @@ macro_rules! iterator {
};
}

iterator!(struct MatrixIter for RawStorage.ptr -> *const T, &'a T, &'a S);
iterator!(struct MatrixIterMut for RawStorageMut.ptr_mut -> *mut T, &'a mut T, &'a mut S);
iterator!(struct MatrixIter for RawStorage.ptr -> *const T, &'a T, &'a S, Clone, Debug);
iterator!(struct MatrixIterMut for RawStorageMut.ptr_mut -> *mut T, &'a mut T, &'a mut S, Debug);

/*
*
Expand Down

0 comments on commit 4a5855a

Please sign in to comment.