Commit Graph

19 Commits

Author SHA1 Message Date
Sébastien Crozet 9ec8d4dbd8 Merge pull request #688 from rustsim/matrix_to_slice
Add matrix/slice conversions.
2020-03-02 12:45:37 +01:00
sebcrozet 8bf94f7afb Add matrix/slice conversions.
Fix #687.
2020-03-02 12:45:37 +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
Andreas Longva 2f77d73226 Generalize From<_> for MatrixSlice(Mut) to allow different strides 2020-03-02 12:45:35 +01:00
Andreas Longva a05aa313da Implement From<&Matrix> for MatrixSlice 2020-03-02 12:45:35 +01:00
sebcrozet 3cbe60523a 2018 edition. 2019-03-23 14:33:47 +01:00
sebcrozet cb367a645d Fix mint tests. 2019-03-19 22:53:21 +01:00
sebcrozet 7be7fc8776 Fix compilation with no-std. 2019-02-03 15:16:50 +01:00
Jack Wrenn 57123ed6aa Overloaded Indexing 2018-12-29 13:41:56 +01:00
Jack Wrenn 0f66403cbb Rename `MatrixVec` to `VecStorage`.
See #470.
2018-12-06 20:51:29 +01:00
Jack Wrenn b83c3b857b Rename `MatrixArray` to `ArrayStorage`.
See #470.
2018-12-06 20:51:29 +01:00
sebcrozet 18e9b8998d Add impls of From/Into to convert any transformation types to a matrix. 2018-10-13 11:25:19 +02:00
Sébastien Crozet 5059d7ee7b Add conditional compilation for the base::MatrixVec import too. 2018-10-04 20:37:12 +02:00
Sébastien Crozet 3abeae04f5 Add conditional compilation to From impls for dynamically-sized matrices. 2018-10-04 20:37:12 +02:00
Jack Wrenn 23d646c342 Add an `Into` impl for converting `MatrixSlice`s into `MatrixMN`
See #342.
2018-10-04 20:37:12 +02:00
sebcrozet 0c29a04042 Fix compilation with the 'mint' feature. 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