Commit Graph

142 Commits

Author SHA1 Message Date
Crozet Sébastien
ee1c0be2dd Add a note about the PhantomData in Matrix. 2021-04-12 11:27:21 +02:00
Crozet Sébastien
bedf48dbc2 Mark small matrix/vector "new" constractors as const-fn. 2021-04-12 09:18:17 +02:00
Crozet Sébastien
24d546d3b6 Rename generic parameter N -> T 2021-04-11 13:57:54 +02:00
Crozet Sébastien
d17088398a Replace generic-array with a regular array based on min-const-generics. 2021-04-11 13:53:45 +02:00
Crozet Sébastien
f2c49aecb0 Add "cast" methods to cast the type of the components of most nalgebra types. 2021-03-05 17:08:46 +01:00
Sébastien Crozet
21cc428480
Merge pull request #803 from aweinstock314/no_unsound_assume_init
Propagate `mem::MaybeUninit` through the return types of `Allocator::…
2021-02-25 15:46:49 +01:00
Crozet Sébastien
dc15261ec1 Move the bytemuck impls to GenericArray and add a transitive impl for matrices. 2021-02-25 14:10:34 +01:00
Avi Weinstock
ee32f7d4cf Run cargo fmt. 2021-02-25 13:42:23 +01:00
Avi Weinstock
cd12422d6f Change zero_or_uninitialized_generic to unimplemented_or_uninitialized_generic, and use it instead of manually dispatching on feature=no_unsound_assume_init in functions without N: Zero. 2021-02-25 13:42:23 +01:00
Avi Weinstock
36a3ac814f Propagate mem::MaybeUninit through the return types of Allocator::allocate_uninitialized and Matrix::new_uninitialized_generic.
Most call sites still invoke UB through `assume_init`. Said call sites instead invoke `unimplemented!()` if the `no_unsound_assume_init` feature is enabled, to make it easier to gradually fix them.

Progress towards #556.
2021-02-25 13:42:23 +01:00
iMplode nZ
c667b1f9c8 Added bytemuck implementations for static storages. 2021-02-10 20:12:24 -08:00
Philippe Renon
bbc6a28f7d clippy: fix len_without_is_empty warnings 2020-11-19 12:24:26 +01:00
Philippe Renon
f1211b0d99 clippy: remove unused imports 2020-11-16 14:46:04 +01:00
Crozet Sébastien
e852df6124 Add sections for most Matrix methods. 2020-11-15 16:57:49 +01:00
Crozet Sébastien
9a4cf0b69f Reorganize matrix construction macros. 2020-11-13 18:34:47 +01:00
Crozet Sébastien
45f2fc4f92 Move all matrix decomposition methods under a single impl. 2020-11-13 17:26:47 +01:00
Philippe Renon
6293d3375b clippy: fix #redundant_field_names 2020-10-11 11:42:22 +02:00
Andreas Longva
9196759bc2 Improve matrixcompare example 2020-06-29 19:03:20 +02:00
Andreas Longva
f6730dac1f Basic matrixcompare functionality 2020-06-29 18:50:19 +02:00
Jenan Wise
85a64fb517 More verbose DMatrix dim asserts where possible.
Previously, most dimension mismatch asserts used raw `assert!` and did
not include the mismatching dimensions in the panic message. When using
dynamic matrices, this led to somewhat-opaque panics such as:

```rust
let m1 = DMatrix::<f32>::zeros(2, 3);
let m2 = DMatrix::<f32>::zeros(5, 10);
m1 + m2 // panic: Matrix addition/subtraction dimensions mismatch.
```

This patch adds dimension information in the panic messages wherever
doing so did not add additional bounds checks, mostly by simply changing
`assert!(a == b, ...)` cases to `assert_eq!`. After:

```rust
// panic: assertion failed: `(left == right)`
//   left: `(2, 3)`,
//  right: `(5, 10)`: Matrix addition/subtraction dimensions mismatch.
```

Note that the `gemv` and `ger` were not updated, as they are called from
within other functions on subset matricies -- e.g., `gemv` is called
from `gemm` which is called from `mul_to` . Including dimension
information in the `gemv` panic messages would be confusing to
`mul` / `mul_to` users, because it would include dimensions of the column
vectors that `gemm` passes to `gemv` rather than of the original `mul`
arguments. A fix would be to add bounds checks to `mul_to`, but that may
have performance and redundancy implications, so is left to another
patch.
2020-06-22 17:18:53 -07:00
Sébastien Crozet
423b4b27b0
Merge pull request #585 from fusion-engineering-forks/pr-default 2020-06-07 08:58:47 +02:00
Sébastien Crozet
b81aed767f
Merge pull request #713 from rustsim/soa_simd
Switch to Simba and make the base and geometry modules mostly SIMD AoSoA friendly.
2020-04-05 21:16:48 +02:00
sebcrozet
bbb3be512e Run cargo fmt. 2020-04-05 18:49:48 +02:00
Chia-Sheng Chen
65bc037b5d Supplement the document of fn as_ptr 2020-04-03 17:56:08 +08:00
Chia-Sheng Chen
b996a6f0ce Supplement the document of fn vector_to_matrix_index 2020-04-03 17:39:49 +08:00
sebcrozet
f8cd26cfa9 Replace alga by simba. 2020-03-21 12:16:46 +01:00
Sébastien Crozet
002e735c76 Make blas, matrix, norm, and ops.rs compatible with SoA Simd. 2020-03-17 17:58:36 +01:00
Sébastien Crozet
a67c451ae5 Merge pull request #607 from cauthmann/dev
Add #[must_use] to all functions with a _mut variant (#598)
2020-03-02 12:45:39 +01:00
S.Brandeis
08d990f276 Make shape check a one-liner in impl PartialEq for Matrix 2020-03-02 12:45:38 +01:00
S.Brandeis
d35ef06f44 Remove unnecessary PartialEq trait use in PartialEq impl for Matrix 2020-03-02 12:45:38 +01:00
S.Brandeis
403e63dc5e Remove trailing whitespace 2020-03-02 12:45:38 +01:00
S.Brandeis
50ea55e877 Modify PartialEq for Matrix to allow comparison with all types of Matrix 2020-03-02 12:45:38 +01:00
S.Brandeis
2b8410e08b Fix bug - PartialEq for Matrix no longer panics when shapes do not match 2020-03-02 12:45:38 +01:00
Sébastien Crozet
12fa938516 Merge pull request #686 from rustsim/fix_vector_slerp
Fix slerp for regular vectors.
2020-03-02 12:45:38 +01:00
sebcrozet
e911bfc7db Fix doc-test for vector slerp. 2020-03-02 12:45:38 +01:00
sebcrozet
5f4a0c7b13 Fix slerp for regular vectors. 2020-03-02 12:45:38 +01:00
Avi Weinstock
774f4da3e2 Add Clone to Scalar, providing a default implementation of inlined_clone. Change Scalar + Clone bounds to just Scalar. 2020-03-02 12:45:37 +01:00
Avi Weinstock
52aac8b975 Add inlined_clone to Scalar, and relax bounds from Scalar + Copy to Scalar + Clone nearly everywhere.
The various nalgebra-lapack FooScalars are still Copy because they make use of uninitialized memory.
nalgebgra-glm Number still uses Copy because upstream `approx` requires it.
2020-03-02 12:45:37 +01:00
Avi Weinstock
7d99015473 Move Copy constraint from the definition of Scalar to all its use-sites.
This should semantically be a no-op, but enables refactorings to use non-Copy scalars on a case-by-case basis.
Also, the only instance of a `One + Zero` trait bound was changed into a `Zero + One` bound to match the others.

The following sed scripts were used in the refactoring (with each clause added to reduce the error count of `cargo check`):

```bash
export RELEVANT_SOURCEFILES="$(find src -name '*.rs') $(find examples -name '*.rs')"
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar,/N: Scalar+Copy,/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar + Field/N: Scalar + Copy + Field/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar + Zero/N: Scalar + Copy + Zero/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar + Closed/N: Scalar + Copy + Closed/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar + Eq/N: Scalar + Copy + Eq/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar + PartialOrd/N: Scalar + Copy + PartialOrd/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: *Scalar + Zero/N: Scalar + Copy + Zero/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar + PartialEq/N: Scalar + Copy + PartialEq/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar>/N: Scalar+Copy>/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: Scalar + $bound/N: Scalar + Copy + $bound/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: *Scalar + $bound/N: Scalar + Copy + $bound/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\): *Scalar,/N\1: Scalar+Copy,/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N: *Scalar + $trait/N: Scalar + Copy + $trait/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\): *Scalar + Superset/N\1: Scalar + Copy + Superset/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\): *Scalar + \([a-zA-Z]*Eq\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \([a-zA-Z]*Eq\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(hash::\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar {/N\1: Scalar + Copy {/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Zero\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Bounded\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Lattice\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Meet\|Join\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(fmt::\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Ring\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Hash\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Send\|Sync\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/One + Zero/Zero + One/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Zero\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \($marker\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar>/N\1: Scalar + Copy>/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/Scalar+Copy/Scalar + Copy/' $f; done
```
2020-03-02 12:45:37 +01:00
Pierre Avital
b5f43c6efc Switched fmt implementation to a macro, applied that macro to all formats in std 2019-10-28 14:15:03 +01:00
Pierre Avital
6ee0e02612 implemented LowerExp 2019-10-28 14:15:03 +01:00
Christian Authmann
589aebbf85 Add #[must_use] to all functions with a _mut variant (#598) 2019-06-05 23:04:04 +02:00
Mara Bos
e6265da980 Implement Default for MatrixMN. 2019-04-16 10:11:27 +02:00
sebcrozet
ae4afa3d2c Merge branch 'master-public' into dev
# Conflicts:
#	Cargo.toml
#	src/base/matrix.rs
#	src/geometry/quaternion.rs
2019-03-31 16:33:25 +02:00
sebcrozet
4ef4001836 Rename Real to RealField. 2019-03-25 11:21:41 +01:00
sebcrozet
5b28c39fa7 Rename Complex to ComplexField. 2019-03-25 11:19:36 +01:00
Samuel Hurel
b4d800f3e2 Fix matrix slerp function (#568)
* Fix matrix slerp function

* Adding slerp doc test
2019-03-24 21:44:49 +01:00
sebcrozet
3cbe60523a 2018 edition. 2019-03-23 14:33:47 +01:00
sebcrozet
ce24ea972e Remove all spurious allocation introduced by complex number support on decompositions. 2019-03-23 14:13:00 +01:00
sebcrozet
921a05d523 Implement some BLAS opertaions involving adjoint. 2019-03-23 11:48:12 +01:00
sebcrozet
1001e8ee0f Cleanup warnings and rename Schur -> RealSchur 2019-03-23 11:46:56 +01:00
sebcrozet
3edef2f006 Decomposition results: return a real vector whenever applicable.
This includes singular values, eigenvalues of hermitian matrices, tridiagonalization and bidiagonalization diagonal and off-diagonal elements.
2019-03-19 14:22:59 +01:00
sebcrozet
2f0d95bdbb Fix most tests. 2019-03-19 12:00:10 +01:00
sebcrozet
010c009cff Fix Schur decomposition. 2019-03-12 13:15:02 +01:00
sebcrozet
77f048b6b9 WIP use Complex instead of Real whenever possible on the linalg module. 2019-03-02 19:33:49 +01:00
sebcrozet
7c91f2eeb5 Use Complex instead of Real whenever possible on the base/ module. 2019-02-23 11:24:07 +01:00
adamnemecek
975d72f070 Replace explicit types with Self where possible. 2019-02-16 22:29:41 +01:00
Sébastien Crozet
cc7bab9755
Merge branch 'master' into as_ptr 2019-02-03 16:55:54 +01:00
sebcrozet
48e9bbc065 Add tests for row and column iterators. 2019-02-03 11:17:23 +01:00
sebcrozet
dcae274d2e Fix rebase fallback + add missing docs. 2019-02-03 08:33:07 +01:00
sebcrozet
414fe8afda Pass references to zip_apply and zip_zip_apply. 2019-02-03 08:08:03 +01:00
sebcrozet
d1391592a0 Add zip_apply and zip_zip_apply. 2019-02-03 08:08:03 +01:00
sebcrozet
0d2c1be8da Add row and column iterators. 2019-02-03 08:08:03 +01:00
sebcrozet
660b868603 Add more general norms and metrics.
Fix #258.
2019-02-03 08:06:24 +01:00
Sébastien Crozet
570611a59b
Merge pull request #524 from shivshank/master
Add `push` method to Vector
2019-02-03 07:52:03 +01:00
Wenping Guo
bb3f3ac2ee fix doc for map_with_location method 2019-01-30 09:33:45 +08:00
shivshank
85a943b7ef Rewrite to_homogenous for vectors to use push 2019-01-09 21:48:03 -05:00
shivshank
3055c289c0 Add push method to Vector 2019-01-09 21:38:58 -05:00
sebcrozet
c9351cb818 Fix merge fallout. 2018-12-29 14:57:26 +01:00
Jack Wrenn
57123ed6aa Overloaded Indexing 2018-12-29 13:41:56 +01:00
Jack Wrenn
53632cd1b4 Implement Hash for all Matrix<N, R, C> where N: Hash.
Implements #508.
2018-12-29 11:29:13 +01:00
Sébastien Crozet
bc9c74cbb6 RFC: Remove redundant Dim trait
Co-Authored-By: grtlr <grtlr@users.noreply.github.com>
2018-11-20 17:47:29 +01:00
Jochen Görtler
72f61918f4 RFC: Fix type annotations 2018-11-20 17:47:29 +01:00
Jochen Görtler
3ac5efeac1 WIP: to_homogeneous for MatrixN 2018-11-20 17:47:29 +01:00
Jim Turner
267d9760bd Add as_ptr and as_mut_ptr methods
This is useful for moving around a matrix/slice in unsafe code and for
converting slices to other types (e.g. `ndarray::ArrayView`).
2018-11-19 16:53:46 -05:00
sebcrozet
bfab204a24 Add lerp for vectors.
Fix #453
2018-10-27 16:06:45 +02:00
sebcrozet
14ad10a7e0 Add rustfmt.toml and run it. 2018-10-27 15:00:18 +02:00
sebcrozet
8e3edf102c Start adding doc-tests for BLAS operations. 2018-10-16 20:57:52 +02:00
sebcrozet
a68937990b Consider two empty matrices as equal. 2018-10-13 12:59:36 +02:00
sebcrozet
a390732b97 Fix partial_cmp 2018-10-13 12:59:36 +02:00
Bruce Mitchener
3a24afd111 clippy: Use println!(f), without empty string. 2018-10-05 20:31:29 +02:00
mborst
12962c3c13 Implement map_with_location. 2018-09-28 05:22:32 +02:00
Bruce Mitchener
175c41ed3a Typo fixes. 2018-09-24 21:15:07 +02:00
sebcrozet
c6bc62c95f For matrices, return the actual result of partial_clamp instead of None.
Fix #401
2018-09-24 20:58:09 +02:00
sebcrozet
832bf42b56 Add slerp for unit vectors. 2018-09-22 16:15:11 +02:00
sebcrozet
a03fd6bff7 Add zip_zip_map to map on three matrices simultaneously. 2018-09-22 16:15:11 +02:00
Jacob Kiesel
787d20cff4 Add magnitude synonym functions for ease of use 2018-09-21 18:28:44 +02:00
sebcrozet
99b54465c7 Add a copy_from_slice method.
Fix #381.
2018-09-13 08:37:20 +02:00
sebcrozet
378b39db9c Update impls of abomonation. 2018-07-20 16:33:59 +02:00
sebcrozet
cdfa73eba6 Fix warnings. 2018-05-26 22:07:57 +02:00
sebcrozet
40e74e0186 Fix compilation with and without #![no_std]. 2018-05-26 22:07:57 +02:00
sebcrozet
ca093fad29 Move core/* to base/* + add conditional compilation to dynamics matrices when no_std is enabled. 2018-05-26 22:07:57 +02:00