diff --git a/.circleci/config.yml b/.circleci/config.yml
deleted file mode 100644
index 446e1139..00000000
--- a/.circleci/config.yml
+++ /dev/null
@@ -1,119 +0,0 @@
-version: 2.1
-
-executors:
- rust-nightly-executor:
- docker:
- - image: rustlang/rust:nightly
- rust-executor:
- docker:
- - image: rust:latest
-
-
-jobs:
- check-fmt:
- executor: rust-executor
- steps:
- - checkout
- - run:
- name: install rustfmt
- command: rustup component add rustfmt
- - run:
- name: check formatting
- command: cargo fmt -- --check
- clippy:
- executor: rust-executor
- steps:
- - checkout
- - run:
- name: install clippy
- command: rustup component add clippy
- - run:
- name: clippy
- command: cargo clippy
- build-native:
- executor: rust-executor
- steps:
- - checkout
- - run: apt-get update
- - run: apt-get install -y cmake gfortran libblas-dev liblapack-dev
- - run:
- name: build --no-default-feature
- command: cargo build --no-default-features;
- - run:
- name: build (default features)
- command: cargo build;
- - run:
- name: build --all-features
- command: cargo build --all-features
- - run:
- name: build nalgebra-glm
- command: cargo build -p nalgebra-glm --all-features
- - run:
- name: build nalgebra-lapack
- command: cd nalgebra-lapack; cargo build
- test-native:
- executor: rust-executor
- steps:
- - checkout
- - run:
- name: test
- command: cargo test --features arbitrary --features serde-serialize --features abomonation-serialize --features sparse --features debug --features io --features compare --features libm
- - run:
- name: test nalgebra-glm
- command: cargo test -p nalgebra-glm --features arbitrary --features serde-serialize --features abomonation-serialize --features sparse --features debug --features io --features compare --features libm
- build-wasm:
- executor: rust-executor
- steps:
- - checkout
- - run:
- name: install cargo-web
- command: cargo install -f cargo-web;
- - run:
- name: build --all-features
- command: cargo web build --verbose --target wasm32-unknown-unknown;
- - run:
- name: build nalgebra-glm
- command: cargo build -p nalgebra-glm --all-features
- build-no-std:
- executor: rust-nightly-executor
- steps:
- - checkout
- - run:
- name: install xargo
- command: cp .circleci/Xargo.toml .; rustup component add rust-src; cargo install -f xargo;
- - run:
- name: build
- command: xargo build --verbose --no-default-features --target=x86_64-unknown-linux-gnu;
- - run:
- name: build --features alloc
- command: xargo build --verbose --no-default-features --features alloc --target=x86_64-unknown-linux-gnu;
- build-nightly:
- executor: rust-nightly-executor
- steps:
- - checkout
- - run:
- name: build --all-features
- command: cargo build --all-features
-
-
-workflows:
- version: 2
- build:
- jobs:
- - check-fmt
- - clippy
- - build-native:
- requires:
- - check-fmt
- - build-wasm:
- requires:
- - check-fmt
- - build-no-std:
- requires:
- - check-fmt
- - build-nightly:
- requires:
- - check-fmt
- - test-native:
- requires:
- - build-native
diff --git a/.circleci/Xargo.toml b/.github/Xargo.toml
similarity index 100%
rename from .circleci/Xargo.toml
rename to .github/Xargo.toml
diff --git a/.github/workflows/nalgebra-ci-build.yml b/.github/workflows/nalgebra-ci-build.yml
new file mode 100644
index 00000000..181e092e
--- /dev/null
+++ b/.github/workflows/nalgebra-ci-build.yml
@@ -0,0 +1,96 @@
+name: nalgebra CI build
+
+on:
+ push:
+ branches: [ dev, master ]
+ pull_request:
+ branches: [ dev, master ]
+
+env:
+ CARGO_TERM_COLOR: always
+
+jobs:
+ check-fmt:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Check formatting
+ run: cargo fmt -- --check
+ clippy:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install clippy
+ run: rustup component add clippy
+ - name: Run clippy
+ run: cargo clippy
+ build-nalgebra:
+ runs-on: ubuntu-latest
+# env:
+# RUSTFLAGS: -D warnings
+ steps:
+ - uses: actions/checkout@v2
+ - name: Build --no-default-feature
+ run: cargo build --no-default-features;
+ - name: Build (default features)
+ run: cargo build;
+ - name: Build --all-features
+ run: cargo build --all-features;
+ - name: Build nalgebra-glm
+ run: cargo build -p nalgebra-glm --all-features;
+ - name: Build nalgebra-lapack
+ run: cd nalgebra-lapack; cargo build;
+ - name: Build nalgebra-sparse
+ run: cd nalgebra-sparse; cargo build;
+ test-nalgebra:
+ runs-on: ubuntu-latest
+# env:
+# RUSTFLAGS: -D warnings
+ steps:
+ - uses: actions/checkout@v2
+ - name: test
+ run: cargo test --features arbitrary --features serde-serialize,abomonation-serialize,sparse,debug,io,compare,libm,proptest-support,slow-tests;
+ test-nalgebra-glm:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: test nalgebra-glm
+ run: cargo test -p nalgebra-glm --features arbitrary,serde-serialize,abomonation-serialize,sparse,debug,io,compare,libm,proptest-support,slow-tests;
+ test-nalgebra-sparse:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: test nalgebra-sparse
+ # Manifest-path is necessary because cargo otherwise won't correctly forward features
+ # We increase number of proptest cases to hopefully catch more potential bugs
+ run: PROPTEST_CASES=10000 cargo test --manifest-path=nalgebra-sparse/Cargo.toml --features compare,proptest-support
+ - name: test nalgebra-sparse (slow tests)
+ # Unfortunately, the "slow-tests" take so much time that we need to run them with --release
+ run: PROPTEST_CASES=10000 cargo test --release --manifest-path=nalgebra-sparse/Cargo.toml --features compare,proptest-support,slow-tests slow
+ build-wasm:
+ runs-on: ubuntu-latest
+# env:
+# RUSTFLAGS: -D warnings
+ steps:
+ - uses: actions/checkout@v2
+ - run: rustup target add wasm32-unknown-unknown
+ - name: build nalgebra
+ run: cargo build --verbose --target wasm32-unknown-unknown;
+ - name: build nalgebra-glm
+ run: cargo build -p nalgebra-glm --verbose --target wasm32-unknown-unknown;
+ build-no-std:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Install latest nightly
+ uses: actions-rs/toolchain@v1
+ with:
+ toolchain: nightly
+ override: true
+ components: rustfmt
+ - name: install xargo
+ run: cp .github/Xargo.toml .; rustup component add rust-src; cargo install -f xargo;
+ - name: build
+ run: xargo build --verbose --no-default-features --target=x86_64-unknown-linux-gnu;
+ - name: build --feature alloc
+ run: xargo build --verbose --no-default-features --features alloc --target=x86_64-unknown-linux-gnu;
diff --git a/.gitignore b/.gitignore
index 796e70b3..3ae51367 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ Cargo.lock
site/
.vscode/
.idea/
+proptest-regressions
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index cfc0e080..23cdd62e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,27 @@ documented here.
This project adheres to [Semantic Versioning](https://semver.org/).
+## [0.25.0]
+This updates all the dependencies of nalgebra to their latest version, including:
+- rand 0.8
+- proptest 1.0
+- simba 0.4
+
+### New crate!
+Alongside this release of `nalgebra`, we are releasing `nalgebra-sparse`: a crate dedicated to sparse matrix
+computation with `nalgebra`. The `sparse` module of `nalgebra`itself still exists for backward compatibility
+but it will be deprecated soon in favor of the `nalgebra-sparse` crate.
+
+### Added
+* Add `UnitDualQuaternion`, a dual-quaternion with unit magnitude which can be used as an isometry transformation.
+* Add `UDU::new()` and `matrix.udu()` to compute the UDU factorization of a matrix.
+* Add `ColPivQR::new()` and `matrix.col_piv_qr()` to compute the QR decomposition with column pivoting of a matrix.
+* Add `from_basis_unchecked` to all the rotation types. This builds a rotation from a set of basis vectors (representing the columns of the corresponding rotation matrix).
+* Add `Matrix::cap_magnitude` to cap the magnitude of a vector.
+* Add `UnitQuaternion::append_axisangle_linearized` to approximately append a rotation represented as an axis-angle to a rotation represented as an unit quaternion.
+* Mark the iterators on matrix components as `DoubleEndedIter`.
+* Re-export `simba::simd::SimdValue` at the root of the `nalgebra` crate.
+
## [0.24.0]
### Added
@@ -67,7 +88,7 @@ In this release, we are no longer relying on traits from the __alga__ crate for
Instead, we use traits from the new [simba](https://crates.io/crates/simba) crate which are both
simpler, and allow for significant optimizations like AoSoA SIMD.
-Refer to the [monthly Rustsim blogpost](https://www.rustsim.org/blog/2020/04/01/this-month-in-rustsim/)
+Refer to the [monthly dimforge blogpost](https://www.dimforge.org/blog/2020/04/01/this-month-in-dimforge/)
for details about this switch and its benefits.
### Added
diff --git a/Cargo.toml b/Cargo.toml
index 615942a8..15f9effd 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,28 +1,29 @@
[package]
name = "nalgebra"
-version = "0.24.0"
+version = "0.25.0"
authors = [ "Sébastien Crozet
- Users guide | Documentation | Forum + Users guide | Documentation | Forum
@@ -36,4 +36,4 @@ Rapier is supported by: - \ No newline at end of file + diff --git a/benches/core/matrix.rs b/benches/core/matrix.rs index 7b4f85bd..7f4432e3 100644 --- a/benches/core/matrix.rs +++ b/benches/core/matrix.rs @@ -136,6 +136,30 @@ fn mat500_mul_mat500(bench: &mut criterion::Criterion) { bench.bench_function("mat500_mul_mat500", move |bh| bh.iter(|| &a * &b)); } +fn iter(bench: &mut criterion::Criterion) { + let a = DMatrix::(&self, predicate: P) -> Self
+ where
+ T: Clone,
+ P: Fn(usize, usize, &T) -> bool,
+ {
+ let (major_dim, minor_dim) = (self.pattern().major_dim(), self.pattern().minor_dim());
+ let mut new_offsets = Vec::with_capacity(self.pattern().major_dim() + 1);
+ let mut new_indices = Vec::new();
+ let mut new_values = Vec::new();
+
+ new_offsets.push(0);
+ for (i, lane) in self.lane_iter().enumerate() {
+ for (&j, value) in lane.minor_indices().iter().zip(lane.values) {
+ if predicate(i, j, value) {
+ new_indices.push(j);
+ new_values.push(value.clone());
+ }
+ }
+
+ new_offsets.push(new_indices.len());
+ }
+
+ // TODO: Avoid checks here
+ let new_pattern = SparsityPattern::try_from_offsets_and_indices(
+ major_dim,
+ minor_dim,
+ new_offsets,
+ new_indices,
+ )
+ .expect("Internal error: Sparsity pattern must always be valid.");
+
+ Self::from_pattern_and_values(new_pattern, new_values)
+ }
+
+ /// Returns the diagonal of the matrix as a sparse matrix.
+ pub fn diagonal_as_matrix(&self) -> Self
+ where
+ T: Clone,
+ {
+ // TODO: This might be faster with a binary search for each diagonal entry
+ self.filter(|i, j, _| i == j)
+ }
+}
+
+impl (&self, predicate: P) -> Self
+ where
+ T: Clone,
+ P: Fn(usize, usize, &T) -> bool,
+ {
+ // Note: Predicate uses (row, col, value), so we have to switch around since
+ // cs uses (major, minor, value)
+ Self {
+ cs: self
+ .cs
+ .filter(|col_idx, row_idx, v| predicate(row_idx, col_idx, v)),
+ }
+ }
+
+ /// Returns a new matrix representing the upper triangular part of this matrix.
+ ///
+ /// The result includes the diagonal of the matrix.
+ pub fn upper_triangle(&self) -> Self
+ where
+ T: Clone,
+ {
+ self.filter(|i, j, _| i <= j)
+ }
+
+ /// Returns a new matrix representing the lower triangular part of this matrix.
+ ///
+ /// The result includes the diagonal of the matrix.
+ pub fn lower_triangle(&self) -> Self
+ where
+ T: Clone,
+ {
+ self.filter(|i, j, _| i >= j)
+ }
+
+ /// Returns the diagonal of the matrix as a sparse matrix.
+ pub fn diagonal_as_csc(&self) -> Self
+ where
+ T: Clone,
+ {
+ Self {
+ cs: self.cs.diagonal_as_matrix(),
+ }
+ }
+
+ /// Compute the transpose of the matrix.
+ pub fn transpose(&self) -> CscMatrix (&self, predicate: P) -> Self
+ where
+ T: Clone,
+ P: Fn(usize, usize, &T) -> bool,
+ {
+ Self {
+ cs: self
+ .cs
+ .filter(|row_idx, col_idx, v| predicate(row_idx, col_idx, v)),
+ }
+ }
+
+ /// Returns a new matrix representing the upper triangular part of this matrix.
+ ///
+ /// The result includes the diagonal of the matrix.
+ pub fn upper_triangle(&self) -> Self
+ where
+ T: Clone,
+ {
+ self.filter(|i, j, _| i <= j)
+ }
+
+ /// Returns a new matrix representing the lower triangular part of this matrix.
+ ///
+ /// The result includes the diagonal of the matrix.
+ pub fn lower_triangle(&self) -> Self
+ where
+ T: Clone,
+ {
+ self.filter(|i, j, _| i >= j)
+ }
+
+ /// Returns the diagonal of the matrix as a sparse matrix.
+ pub fn diagonal_as_csr(&self) -> Self
+ where
+ T: Clone,
+ {
+ Self {
+ cs: self.cs.diagonal_as_matrix(),
+ }
+ }
+
+ /// Compute the transpose of the matrix.
+ pub fn transpose(&self) -> CsrMatrix