Commit Graph

38 Commits

Author SHA1 Message Date
Crozet Sébastien 857ce13b63 Add DVector::from(Vec). 2020-11-19 16:28:06 +01:00
Philippe Renon 726b8eeecf clippy: fix or_fun_call warnings 2020-11-19 11:43:08 +01:00
Philippe Renon de4a067d27 clippy: fix len_zero warnings 2020-11-16 12:11:24 +01:00
Philippe Renon d577a18a45 clippy: fix or_fun_call warnings 2020-11-16 11:11:58 +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 9c93a58b5d Add Vector::ith_axis to build an unit vector with its i-th component set to 1. 2020-10-25 11:25:38 +01:00
Sébastien Crozet 6300d34356 Add the ::ith constructor for vectors.
This initializes a vectors to zero except the i-th element set to a given value.
2020-08-25 20:46:04 +02:00
sebcrozet bbb3be512e Run cargo fmt. 2020-04-05 18:49:48 +02:00
sebcrozet f8cd26cfa9 Replace alga by simba. 2020-03-21 12:16:46 +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 6c236af696 Add Scalar + Copy bounds to code that's under feature flags.
`./ci/test.sh` now passes locally.

Refactoring done via the following sed commands:
```bash
export RELEVANT_SOURCEFILES="$(find src -name '*.rs') $(find examples -name '*.rs')"
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Arbitrary\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Serialize\)/N\1: Scalar + Copy + \2/' $f; done
for f in $RELEVANT_SOURCEFILES; do sed -i 's/N\([0-9]\?\): *Scalar + \(Deserialize\)/N\1: Scalar + Copy + \2/' $f; do
export RELEVANT_SOURCEFILES="$(find nalgebra-glm -name '*.rs')"
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>/N\1: Scalar + Copy>/' $f; done
for f in algebra-glm/src/traits.rs; do sed -i 's/Scalar + Ring/Scalar + Copy + Ring>/' $f; done # Number trait definition
```
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
Edoardo Morandi d0d1172d4b Rand 0.6 -> 0.7
* Bumped rand version to 0.7
 * Added dependency to rand_distr
 * Bumped quickcheck version to 0.9 (because of rand)
 * Bumped rand_xorshift version to 0.2
2019-10-28 14:15:03 +01:00
sebcrozet 4ef4001836 Rename Real to RealField. 2019-03-25 11:21:41 +01:00
sebcrozet 3cbe60523a 2018 edition. 2019-03-23 14:33:47 +01:00
sebcrozet f52bd4be3d Rename VecStorage::data/data_mut to ::as_vec/as_vec_mut 2019-02-03 11:48:42 +01:00
sebcrozet bba1f48e81 Add select_rows and select_columns. 2019-02-03 08:06:24 +01:00
sebcrozet 01d1f9d24b Simplify the construction of DVector.
Fix #377.
2019-02-03 08:06:24 +01:00
Jack Wrenn 57123ed6aa Overloaded Indexing 2018-12-29 13:41:56 +01:00
Jack Wrenn 9e763bbcff doc tests for `from_vec_generic` and `from_vec` 2018-11-08 06:42:55 +01:00
Jack Wrenn d6fb07dad2 Introduce `from_vec`, to complement `from_vec_generic` 2018-11-08 06:42:55 +01:00
Jack Wrenn 68bdb427cf Rename: `from_vec` -> `from_vec_generic` 2018-11-08 06:42:55 +01:00
Jack Wrenn ff4e44a8ed Introduces a `from_vec` constructor for `MatrixMN`.
Addresses #378.

The implementation of `from_vec` simply wraps a call to
`from_iterator_generic`. Because the standard library's implementation
of `into_iter` is specialized for the `.into_iter().collect<Vec<_>>()`
case (see https://github.com/rust-lang/rust/issues/46084#issuecomment-345524508),
this is equivalent to re-using the original Vec as storage.
2018-11-08 06:42:55 +01:00
Antony Lesage c370564dba Fix MatrixMN::from_distribution (#463) 2018-11-06 19:24:20 +01:00
sebcrozet 14ad10a7e0 Add rustfmt.toml and run it. 2018-10-27 15:00:18 +02:00
sebcrozet f6cd81b028 Add doc-tests for several matrix construction methods. 2018-10-27 15:00:18 +02:00
sebcrozet afb6317893 Fix Xargo build. 2018-07-20 16:33:59 +02:00
Benjamin Saunders aad94661c9 Document distribution uniformity, fix `Rotation2` distribution
Also tweak UnitComplex distribution for consistency
2018-07-10 20:17:52 +02:00
Sébastien Crozet 8e90e2adf7 Use StandardNormal on rand::distributions. 2018-07-10 20:17:52 +02:00
Sébastien Crozet a1d8aba501 Use StandardNormal only with the "std" feature. 2018-07-10 20:17:52 +02:00
Benjamin Saunders 352e71656d Uniformly distributed random rotations, unit vectors 2018-07-10 20:17:52 +02:00
sebcrozet 3eaa65c9cf Minor doc fixes. 2018-07-07 17:37:15 +02:00
Thomas Forgione b1616e236c Changed loops order in from_fn_generic 2018-06-16 14:27:55 +02:00
sebcrozet cdfa73eba6 Fix warnings. 2018-05-26 22:07:57 +02:00
sebcrozet a51744f86b Update to rand 0.5. 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