Add matrix slice construction from array slices.
This commit is contained in:
parent
adbb7d989e
commit
94c1ab8e7b
3
Makefile
3
Makefile
|
@ -1,5 +1,6 @@
|
||||||
all:
|
all:
|
||||||
cargo check --features "debug arbitrary serde-serialize"
|
cargo test --features "debug arbitrary serde-serialize abomonation-serialize"
|
||||||
|
# cargo check --features "debug arbitrary serde-serialize"
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
cargo doc --no-deps --features "debug arbitrary serde-serialize abomonation"
|
cargo doc --no-deps --features "debug arbitrary serde-serialize abomonation"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use core::Matrix;
|
use core::Matrix;
|
||||||
use core::dimension::{Dynamic, U1, U2, U3, U4, U5, U6};
|
use core::dimension::{Dynamic, U1, U2, U3, U4, U5, U6};
|
||||||
use core::matrix_vec::MatrixVec;
|
|
||||||
use core::storage::Owned;
|
|
||||||
use core::matrix_slice::{SliceStorage, SliceStorageMut};
|
use core::matrix_slice::{SliceStorage, SliceStorageMut};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -15,52 +13,117 @@ use core::matrix_slice::{SliceStorage, SliceStorageMut};
|
||||||
pub type MatrixSliceMN<'a, N, R, C, RStride = U1, CStride = R>
|
pub type MatrixSliceMN<'a, N, R, C, RStride = U1, CStride = R>
|
||||||
= Matrix<N, R, C, SliceStorage<'a, N, R, C, RStride, CStride>>;
|
= Matrix<N, R, C, SliceStorage<'a, N, R, C, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major matrix slice with `D` rows and columns.
|
||||||
pub type MatrixSliceN<'a, N, D, RStride = U1, CStride = D> = MatrixSliceMN<'a, N, D, D, RStride, CStride>;
|
pub type MatrixSliceN<'a, N, D, RStride = U1, CStride = D> = MatrixSliceMN<'a, N, D, D, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major matrix slice dynamic numbers of rows and columns.
|
||||||
pub type DMatrixSlice<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceN<'a, N, Dynamic, RStride, CStride>;
|
pub type DMatrixSlice<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceN<'a, N, Dynamic, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major 1x1 matrix slice.
|
||||||
pub type MatrixSlice1<'a, N, RStride = U1, CStride = U1> = MatrixSliceN<'a, N, U1, RStride, CStride>;
|
pub type MatrixSlice1<'a, N, RStride = U1, CStride = U1> = MatrixSliceN<'a, N, U1, RStride, CStride>;
|
||||||
|
/// A column-major 2x2 matrix slice.
|
||||||
pub type MatrixSlice2<'a, N, RStride = U1, CStride = U2> = MatrixSliceN<'a, N, U2, RStride, CStride>;
|
pub type MatrixSlice2<'a, N, RStride = U1, CStride = U2> = MatrixSliceN<'a, N, U2, RStride, CStride>;
|
||||||
|
/// A column-major 3x3 matrix slice.
|
||||||
pub type MatrixSlice3<'a, N, RStride = U1, CStride = U3> = MatrixSliceN<'a, N, U3, RStride, CStride>;
|
pub type MatrixSlice3<'a, N, RStride = U1, CStride = U3> = MatrixSliceN<'a, N, U3, RStride, CStride>;
|
||||||
|
/// A column-major 4x4 matrix slice.
|
||||||
pub type MatrixSlice4<'a, N, RStride = U1, CStride = U4> = MatrixSliceN<'a, N, U4, RStride, CStride>;
|
pub type MatrixSlice4<'a, N, RStride = U1, CStride = U4> = MatrixSliceN<'a, N, U4, RStride, CStride>;
|
||||||
|
/// A column-major 5x5 matrix slice.
|
||||||
pub type MatrixSlice5<'a, N, RStride = U1, CStride = U5> = MatrixSliceN<'a, N, U5, RStride, CStride>;
|
pub type MatrixSlice5<'a, N, RStride = U1, CStride = U5> = MatrixSliceN<'a, N, U5, RStride, CStride>;
|
||||||
|
/// A column-major 6x6 matrix slice.
|
||||||
pub type MatrixSlice6<'a, N, RStride = U1, CStride = U6> = MatrixSliceN<'a, N, U6, RStride, CStride>;
|
pub type MatrixSlice6<'a, N, RStride = U1, CStride = U6> = MatrixSliceN<'a, N, U6, RStride, CStride>;
|
||||||
|
|
||||||
pub type MatrixSlice1x2<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U2, U1, RStride, CStride>;
|
/// A column-major 1x2 matrix slice.
|
||||||
pub type MatrixSlice1x3<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U3, U1, RStride, CStride>;
|
pub type MatrixSlice1x2<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U1, U2, RStride, CStride>;
|
||||||
pub type MatrixSlice1x4<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U4, U1, RStride, CStride>;
|
/// A column-major 1x3 matrix slice.
|
||||||
pub type MatrixSlice1x5<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U5, U1, RStride, CStride>;
|
pub type MatrixSlice1x3<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U1, U3, RStride, CStride>;
|
||||||
pub type MatrixSlice1x6<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U6, U1, RStride, CStride>;
|
/// A column-major 1x4 matrix slice.
|
||||||
|
pub type MatrixSlice1x4<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U1, U4, RStride, CStride>;
|
||||||
|
/// A column-major 1x5 matrix slice.
|
||||||
|
pub type MatrixSlice1x5<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U1, U5, RStride, CStride>;
|
||||||
|
/// A column-major 1x6 matrix slice.
|
||||||
|
pub type MatrixSlice1x6<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U1, U6, RStride, CStride>;
|
||||||
|
|
||||||
pub type MatrixSlice2x2<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U2, U2, RStride, CStride>;
|
/// A column-major 2x1 matrix slice.
|
||||||
pub type MatrixSlice2x3<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U3, U2, RStride, CStride>;
|
pub type MatrixSlice2x1<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U2, U1, RStride, CStride>;
|
||||||
pub type MatrixSlice2x4<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U4, U2, RStride, CStride>;
|
/// A column-major 2x3 matrix slice.
|
||||||
pub type MatrixSlice2x5<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U5, U2, RStride, CStride>;
|
pub type MatrixSlice2x3<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U2, U3, RStride, CStride>;
|
||||||
pub type MatrixSlice2x6<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U6, U2, RStride, CStride>;
|
/// A column-major 2x4 matrix slice.
|
||||||
|
pub type MatrixSlice2x4<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U2, U4, RStride, CStride>;
|
||||||
|
/// A column-major 2x5 matrix slice.
|
||||||
|
pub type MatrixSlice2x5<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U2, U5, RStride, CStride>;
|
||||||
|
/// A column-major 2x6 matrix slice.
|
||||||
|
pub type MatrixSlice2x6<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U2, U6, RStride, CStride>;
|
||||||
|
|
||||||
pub type MatrixSlice3x2<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U2, U3, RStride, CStride>;
|
/// A column-major 3x1 matrix slice.
|
||||||
pub type MatrixSlice3x3<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U3, U3, RStride, CStride>;
|
pub type MatrixSlice3x1<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U3, U1, RStride, CStride>;
|
||||||
pub type MatrixSlice3x4<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U4, U3, RStride, CStride>;
|
/// A column-major 3x2 matrix slice.
|
||||||
pub type MatrixSlice3x5<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U5, U3, RStride, CStride>;
|
pub type MatrixSlice3x2<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U3, U2, RStride, CStride>;
|
||||||
pub type MatrixSlice3x6<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U6, U3, RStride, CStride>;
|
/// A column-major 3x4 matrix slice.
|
||||||
|
pub type MatrixSlice3x4<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U3, U4, RStride, CStride>;
|
||||||
|
/// A column-major 3x5 matrix slice.
|
||||||
|
pub type MatrixSlice3x5<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U3, U5, RStride, CStride>;
|
||||||
|
/// A column-major 3x6 matrix slice.
|
||||||
|
pub type MatrixSlice3x6<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U3, U6, RStride, CStride>;
|
||||||
|
|
||||||
pub type MatrixSlice4x2<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U2, U4, RStride, CStride>;
|
/// A column-major 4x1 matrix slice.
|
||||||
pub type MatrixSlice4x3<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U3, U4, RStride, CStride>;
|
pub type MatrixSlice4x1<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U4, U1, RStride, CStride>;
|
||||||
pub type MatrixSlice4x4<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U4, U4, RStride, CStride>;
|
/// A column-major 4x2 matrix slice.
|
||||||
pub type MatrixSlice4x5<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U5, U4, RStride, CStride>;
|
pub type MatrixSlice4x2<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U4, U2, RStride, CStride>;
|
||||||
pub type MatrixSlice4x6<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U6, U4, RStride, CStride>;
|
/// A column-major 4x3 matrix slice.
|
||||||
|
pub type MatrixSlice4x3<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U4, U3, RStride, CStride>;
|
||||||
|
/// A column-major 4x5 matrix slice.
|
||||||
|
pub type MatrixSlice4x5<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U4, U5, RStride, CStride>;
|
||||||
|
/// A column-major 4x6 matrix slice.
|
||||||
|
pub type MatrixSlice4x6<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U4, U6, RStride, CStride>;
|
||||||
|
|
||||||
pub type MatrixSlice5x2<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U2, U5, RStride, CStride>;
|
/// A column-major 5x1 matrix slice.
|
||||||
pub type MatrixSlice5x3<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U3, U5, RStride, CStride>;
|
pub type MatrixSlice5x1<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U5, U1, RStride, CStride>;
|
||||||
pub type MatrixSlice5x4<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U4, U5, RStride, CStride>;
|
/// A column-major 5x2 matrix slice.
|
||||||
pub type MatrixSlice5x5<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U5, U5, RStride, CStride>;
|
pub type MatrixSlice5x2<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U5, U2, RStride, CStride>;
|
||||||
pub type MatrixSlice5x6<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U6, U5, RStride, CStride>;
|
/// A column-major 5x3 matrix slice.
|
||||||
|
pub type MatrixSlice5x3<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U5, U3, RStride, CStride>;
|
||||||
|
/// A column-major 5x4 matrix slice.
|
||||||
|
pub type MatrixSlice5x4<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U5, U4, RStride, CStride>;
|
||||||
|
/// A column-major 5x6 matrix slice.
|
||||||
|
pub type MatrixSlice5x6<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U5, U6, RStride, CStride>;
|
||||||
|
|
||||||
pub type MatrixSlice6x2<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U2, U6, RStride, CStride>;
|
/// A column-major 6x1 matrix slice.
|
||||||
pub type MatrixSlice6x3<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U3, U6, RStride, CStride>;
|
pub type MatrixSlice6x1<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U6, U1, RStride, CStride>;
|
||||||
pub type MatrixSlice6x4<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U4, U6, RStride, CStride>;
|
/// A column-major 6x2 matrix slice.
|
||||||
pub type MatrixSlice6x5<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U5, U6, RStride, CStride>;
|
pub type MatrixSlice6x2<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U6, U2, RStride, CStride>;
|
||||||
pub type MatrixSlice6x6<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U6, U6, RStride, CStride>;
|
/// A column-major 6x3 matrix slice.
|
||||||
|
pub type MatrixSlice6x3<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U6, U3, RStride, CStride>;
|
||||||
|
/// A column-major 6x4 matrix slice.
|
||||||
|
pub type MatrixSlice6x4<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U6, U4, RStride, CStride>;
|
||||||
|
/// A column-major 6x5 matrix slice.
|
||||||
|
pub type MatrixSlice6x5<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U6, U6, RStride, CStride>;
|
||||||
|
|
||||||
|
|
||||||
|
/// A column-major matrix slice with 1 row and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSlice1xX<'a, N, RStride = U1, CStride = U1> = MatrixSliceMN<'a, N, U1, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with 2 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSlice2xX<'a, N, RStride = U1, CStride = U2> = MatrixSliceMN<'a, N, U2, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with 3 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSlice3xX<'a, N, RStride = U1, CStride = U3> = MatrixSliceMN<'a, N, U3, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with 4 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSlice4xX<'a, N, RStride = U1, CStride = U4> = MatrixSliceMN<'a, N, U4, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with 5 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSlice5xX<'a, N, RStride = U1, CStride = U5> = MatrixSliceMN<'a, N, U5, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with 6 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSlice6xX<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a, N, U6, Dynamic, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major matrix slice with a number of rows chosen at runtime and 1 column.
|
||||||
|
pub type MatrixSliceXx1<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMN<'a, N, Dynamic, U1, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with a number of rows chosen at runtime and 2 columns.
|
||||||
|
pub type MatrixSliceXx2<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMN<'a, N, Dynamic, U2, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with a number of rows chosen at runtime and 3 columns.
|
||||||
|
pub type MatrixSliceXx3<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMN<'a, N, Dynamic, U3, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with a number of rows chosen at runtime and 4 columns.
|
||||||
|
pub type MatrixSliceXx4<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMN<'a, N, Dynamic, U4, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with a number of rows chosen at runtime and 5 columns.
|
||||||
|
pub type MatrixSliceXx5<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMN<'a, N, Dynamic, U5, RStride, CStride>;
|
||||||
|
/// A column-major matrix slice with a number of rows chosen at runtime and 6 columns.
|
||||||
|
pub type MatrixSliceXx6<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMN<'a, N, Dynamic, U6, RStride, CStride>;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -70,5 +133,118 @@ pub type MatrixSlice6x6<'a, N, RStride = U1, CStride = U6> = MatrixSliceMN<'a,
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
/// A column-major mutable matrix slice with `R` rows and `C` columns.
|
||||||
pub type MatrixSliceMutMN<'a, N, R, C, RStride = U1, CStride = R>
|
pub type MatrixSliceMutMN<'a, N, R, C, RStride = U1, CStride = R>
|
||||||
= Matrix<N, R, C, SliceStorageMut<'a, N, R, C, RStride, CStride>>;
|
= Matrix<N, R, C, SliceStorageMut<'a, N, R, C, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major mutable matrix slice with `D` rows and columns.
|
||||||
|
pub type MatrixSliceMutN<'a, N, D, RStride = U1, CStride = D> = MatrixSliceMutMN<'a, N, D, D, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major mutable matrix slice dynamic numbers of rows and columns.
|
||||||
|
pub type DMatrixSliceMut<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMutN<'a, N, Dynamic, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major 1x1 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut1<'a, N, RStride = U1, CStride = U1> = MatrixSliceMutN<'a, N, U1, RStride, CStride>;
|
||||||
|
/// A column-major 2x2 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut2<'a, N, RStride = U1, CStride = U2> = MatrixSliceMutN<'a, N, U2, RStride, CStride>;
|
||||||
|
/// A column-major 3x3 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut3<'a, N, RStride = U1, CStride = U3> = MatrixSliceMutN<'a, N, U3, RStride, CStride>;
|
||||||
|
/// A column-major 4x4 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut4<'a, N, RStride = U1, CStride = U4> = MatrixSliceMutN<'a, N, U4, RStride, CStride>;
|
||||||
|
/// A column-major 5x5 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut5<'a, N, RStride = U1, CStride = U5> = MatrixSliceMutN<'a, N, U5, RStride, CStride>;
|
||||||
|
/// A column-major 6x6 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut6<'a, N, RStride = U1, CStride = U6> = MatrixSliceMutN<'a, N, U6, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major 1x2 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut1x2<'a, N, RStride = U1, CStride = U1> = MatrixSliceMutMN<'a, N, U1, U2, RStride, CStride>;
|
||||||
|
/// A column-major 1x3 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut1x3<'a, N, RStride = U1, CStride = U1> = MatrixSliceMutMN<'a, N, U1, U3, RStride, CStride>;
|
||||||
|
/// A column-major 1x4 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut1x4<'a, N, RStride = U1, CStride = U1> = MatrixSliceMutMN<'a, N, U1, U4, RStride, CStride>;
|
||||||
|
/// A column-major 1x5 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut1x5<'a, N, RStride = U1, CStride = U1> = MatrixSliceMutMN<'a, N, U1, U5, RStride, CStride>;
|
||||||
|
/// A column-major 1x6 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut1x6<'a, N, RStride = U1, CStride = U1> = MatrixSliceMutMN<'a, N, U1, U6, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major 2x1 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut2x1<'a, N, RStride = U1, CStride = U2> = MatrixSliceMutMN<'a, N, U2, U1, RStride, CStride>;
|
||||||
|
/// A column-major 2x3 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut2x3<'a, N, RStride = U1, CStride = U2> = MatrixSliceMutMN<'a, N, U2, U3, RStride, CStride>;
|
||||||
|
/// A column-major 2x4 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut2x4<'a, N, RStride = U1, CStride = U2> = MatrixSliceMutMN<'a, N, U2, U4, RStride, CStride>;
|
||||||
|
/// A column-major 2x5 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut2x5<'a, N, RStride = U1, CStride = U2> = MatrixSliceMutMN<'a, N, U2, U5, RStride, CStride>;
|
||||||
|
/// A column-major 2x6 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut2x6<'a, N, RStride = U1, CStride = U2> = MatrixSliceMutMN<'a, N, U2, U6, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major 3x1 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut3x1<'a, N, RStride = U1, CStride = U3> = MatrixSliceMutMN<'a, N, U3, U1, RStride, CStride>;
|
||||||
|
/// A column-major 3x2 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut3x2<'a, N, RStride = U1, CStride = U3> = MatrixSliceMutMN<'a, N, U3, U2, RStride, CStride>;
|
||||||
|
/// A column-major 3x4 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut3x4<'a, N, RStride = U1, CStride = U3> = MatrixSliceMutMN<'a, N, U3, U4, RStride, CStride>;
|
||||||
|
/// A column-major 3x5 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut3x5<'a, N, RStride = U1, CStride = U3> = MatrixSliceMutMN<'a, N, U3, U5, RStride, CStride>;
|
||||||
|
/// A column-major 3x6 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut3x6<'a, N, RStride = U1, CStride = U3> = MatrixSliceMutMN<'a, N, U3, U6, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major 4x1 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut4x1<'a, N, RStride = U1, CStride = U4> = MatrixSliceMutMN<'a, N, U4, U1, RStride, CStride>;
|
||||||
|
/// A column-major 4x2 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut4x2<'a, N, RStride = U1, CStride = U4> = MatrixSliceMutMN<'a, N, U4, U2, RStride, CStride>;
|
||||||
|
/// A column-major 4x3 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut4x3<'a, N, RStride = U1, CStride = U4> = MatrixSliceMutMN<'a, N, U4, U3, RStride, CStride>;
|
||||||
|
/// A column-major 4x5 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut4x5<'a, N, RStride = U1, CStride = U4> = MatrixSliceMutMN<'a, N, U4, U5, RStride, CStride>;
|
||||||
|
/// A column-major 4x6 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut4x6<'a, N, RStride = U1, CStride = U4> = MatrixSliceMutMN<'a, N, U4, U6, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major 5x1 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut5x1<'a, N, RStride = U1, CStride = U5> = MatrixSliceMutMN<'a, N, U5, U1, RStride, CStride>;
|
||||||
|
/// A column-major 5x2 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut5x2<'a, N, RStride = U1, CStride = U5> = MatrixSliceMutMN<'a, N, U5, U2, RStride, CStride>;
|
||||||
|
/// A column-major 5x3 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut5x3<'a, N, RStride = U1, CStride = U5> = MatrixSliceMutMN<'a, N, U5, U3, RStride, CStride>;
|
||||||
|
/// A column-major 5x4 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut5x4<'a, N, RStride = U1, CStride = U5> = MatrixSliceMutMN<'a, N, U5, U4, RStride, CStride>;
|
||||||
|
/// A column-major 5x6 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut5x6<'a, N, RStride = U1, CStride = U5> = MatrixSliceMutMN<'a, N, U5, U6, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major 6x1 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut6x1<'a, N, RStride = U1, CStride = U6> = MatrixSliceMutMN<'a, N, U6, U1, RStride, CStride>;
|
||||||
|
/// A column-major 6x2 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut6x2<'a, N, RStride = U1, CStride = U6> = MatrixSliceMutMN<'a, N, U6, U2, RStride, CStride>;
|
||||||
|
/// A column-major 6x3 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut6x3<'a, N, RStride = U1, CStride = U6> = MatrixSliceMutMN<'a, N, U6, U3, RStride, CStride>;
|
||||||
|
/// A column-major 6x4 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut6x4<'a, N, RStride = U1, CStride = U6> = MatrixSliceMutMN<'a, N, U6, U4, RStride, CStride>;
|
||||||
|
/// A column-major 6x5 mutable matrix slice.
|
||||||
|
pub type MatrixSliceMut6x5<'a, N, RStride = U1, CStride = U6> = MatrixSliceMutMN<'a, N, U6, U5, RStride, CStride>;
|
||||||
|
|
||||||
|
|
||||||
|
/// A column-major mutable matrix slice with 1 row and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSliceMut1xX<'a, N, RStride = U1, CStride = U1> = MatrixSliceMutMN<'a, N, U1, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with 2 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSliceMut2xX<'a, N, RStride = U1, CStride = U2> = MatrixSliceMutMN<'a, N, U2, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with 3 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSliceMut3xX<'a, N, RStride = U1, CStride = U3> = MatrixSliceMutMN<'a, N, U3, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with 4 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSliceMut4xX<'a, N, RStride = U1, CStride = U4> = MatrixSliceMutMN<'a, N, U4, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with 5 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSliceMut5xX<'a, N, RStride = U1, CStride = U5> = MatrixSliceMutMN<'a, N, U5, Dynamic, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with 6 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixSliceMut6xX<'a, N, RStride = U1, CStride = U6> = MatrixSliceMutMN<'a, N, U6, Dynamic, RStride, CStride>;
|
||||||
|
|
||||||
|
/// A column-major mutable matrix slice with a number of rows chosen at runtime and 1 column.
|
||||||
|
pub type MatrixSliceMutXx1<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMutMN<'a, N, Dynamic, U1, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with a number of rows chosen at runtime and 2 columns.
|
||||||
|
pub type MatrixSliceMutXx2<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMutMN<'a, N, Dynamic, U2, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with a number of rows chosen at runtime and 3 columns.
|
||||||
|
pub type MatrixSliceMutXx3<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMutMN<'a, N, Dynamic, U3, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with a number of rows chosen at runtime and 4 columns.
|
||||||
|
pub type MatrixSliceMutXx4<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMutMN<'a, N, Dynamic, U4, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with a number of rows chosen at runtime and 5 columns.
|
||||||
|
pub type MatrixSliceMutXx5<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMutMN<'a, N, Dynamic, U5, RStride, CStride>;
|
||||||
|
/// A column-major mutable matrix slice with a number of rows chosen at runtime and 6 columns.
|
||||||
|
pub type MatrixSliceMutXx6<'a, N, RStride = U1, CStride = Dynamic> = MatrixSliceMutMN<'a, N, Dynamic, U6, RStride, CStride>;
|
||||||
|
|
|
@ -213,45 +213,6 @@ impl<N, D: Dim> MatrixN<N, D>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Slice constructors.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> MatrixSliceMN<'a, N, R, C, RStride, CStride> {
|
|
||||||
pub fn new_slice_generic(data: &'a [N], nrows: R, ncols: C, rstride: RStride, cstride: CStride) -> Self {
|
|
||||||
// NOTE: The assertion implements the following formula, but without subtractions to avoid
|
|
||||||
// underflow panics:
|
|
||||||
// len >= (ncols - 1) * cstride + (nrows - 1) * rstride + 1
|
|
||||||
assert!(data.len() + cstride.value() + rstride.value() >=
|
|
||||||
ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
|
||||||
"Matrix slice: input data buffer to small.");
|
|
||||||
|
|
||||||
|
|
||||||
let data = unsafe {
|
|
||||||
SliceStorage::from_raw_parts(data.as_ptr(), (nrows, ncols), (rstride, cstride))
|
|
||||||
};
|
|
||||||
Self::from_data(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> MatrixSliceMutMN<'a, N, R, C, RStride, CStride> {
|
|
||||||
pub fn new_slice_mut_generic(data: &'a mut [N], nrows: R, ncols: C, rstride: RStride, cstride: CStride) -> Self {
|
|
||||||
// NOTE: The assertion implements the following formula, but without subtractions to avoid
|
|
||||||
// underflow panics:
|
|
||||||
// len >= (ncols - 1) * cstride + (nrows - 1) * rstride + 1
|
|
||||||
assert!(data.len() + cstride.value() + rstride.value() >=
|
|
||||||
ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
|
||||||
"Matrix slice: input data buffer to small.");
|
|
||||||
|
|
||||||
let data = unsafe {
|
|
||||||
SliceStorageMut::from_raw_parts(data.as_mut_ptr(), (nrows, ncols), (rstride, cstride))
|
|
||||||
};
|
|
||||||
Self::from_data(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Generate constructors with varying number of arguments, depending on the object type.
|
* Generate constructors with varying number of arguments, depending on the object type.
|
||||||
|
|
|
@ -0,0 +1,152 @@
|
||||||
|
#[cfg(feature = "arbitrary")]
|
||||||
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
#[cfg(feature = "arbitrary")]
|
||||||
|
use core::storage::Owned;
|
||||||
|
|
||||||
|
use std::iter;
|
||||||
|
use num::{Zero, One, Bounded};
|
||||||
|
use rand::{self, Rand, Rng};
|
||||||
|
use typenum::{self, Cmp, Greater};
|
||||||
|
|
||||||
|
use alga::general::{ClosedAdd, ClosedMul};
|
||||||
|
|
||||||
|
use core::{DefaultAllocator, Scalar, Matrix, Vector, Unit, MatrixMN, MatrixN, VectorN,
|
||||||
|
MatrixSliceMN, MatrixSliceMutMN};
|
||||||
|
use core::dimension::{Dim, DimName, Dynamic, U1, U2, U3, U4, U5, U6};
|
||||||
|
use core::allocator::Allocator;
|
||||||
|
use core::storage::Storage;
|
||||||
|
use core::matrix_slice::{SliceStorage, SliceStorageMut};
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Slice constructors.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> MatrixSliceMN<'a, N, R, C, RStride, CStride> {
|
||||||
|
#[inline]
|
||||||
|
pub fn new_slice_with_strides_generic(data: &'a [N], nrows: R, ncols: C, rstride: RStride, cstride: CStride) -> Self {
|
||||||
|
// NOTE: The assertion implements the following formula, but without subtractions to avoid
|
||||||
|
// underflow panics:
|
||||||
|
// len >= (ncols - 1) * cstride + (nrows - 1) * rstride + 1
|
||||||
|
assert!(data.len() + cstride.value() + rstride.value() >=
|
||||||
|
ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
||||||
|
"Matrix slice: input data buffer to small.");
|
||||||
|
|
||||||
|
let data = unsafe {
|
||||||
|
SliceStorage::from_raw_parts(data.as_ptr(), (nrows, ncols), (rstride, cstride))
|
||||||
|
};
|
||||||
|
Self::from_data(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, N: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> MatrixSliceMutMN<'a, N, R, C, RStride, CStride> {
|
||||||
|
#[inline]
|
||||||
|
pub fn new_slice_with_strides_mut_generic(data: &'a mut [N], nrows: R, ncols: C, rstride: RStride, cstride: CStride) -> Self {
|
||||||
|
// NOTE: The assertion implements the following formula, but without subtractions to avoid
|
||||||
|
// underflow panics:
|
||||||
|
// len >= (ncols - 1) * cstride + (nrows - 1) * rstride + 1
|
||||||
|
assert!(data.len() + cstride.value() + rstride.value() >=
|
||||||
|
ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
||||||
|
"Matrix slice: input data buffer to small.");
|
||||||
|
|
||||||
|
let data = unsafe {
|
||||||
|
SliceStorageMut::from_raw_parts(data.as_mut_ptr(), (nrows, ncols), (rstride, cstride))
|
||||||
|
};
|
||||||
|
Self::from_data(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMN<'a, N, R, C> {
|
||||||
|
#[inline]
|
||||||
|
pub fn new_slice_generic(data: &'a [N], nrows: R, ncols: C) -> Self {
|
||||||
|
Self::new_slice_with_strides_generic(data, nrows, ncols, U1, nrows)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, N: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, N, R, C> {
|
||||||
|
#[inline]
|
||||||
|
pub fn new_slice_mut_generic(data: &'a mut [N], nrows: R, ncols: C) -> Self {
|
||||||
|
Self::new_slice_with_strides_mut_generic(data, nrows, ncols, U1, nrows)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! impl_constructors(
|
||||||
|
($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => {
|
||||||
|
impl<'a, N: Scalar, $($DimIdent: $DimBound),*> MatrixSliceMN<'a, N, $($Dims),*> {
|
||||||
|
#[inline]
|
||||||
|
pub fn new(data: &'a [N], $($args: usize),*) -> Self {
|
||||||
|
Self::new_slice_generic(data, $($gargs),*)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, N: Scalar, $($DimIdent: $DimBound, )*> MatrixSliceMN<'a, N, $($Dims,)* Dynamic, Dynamic> {
|
||||||
|
#[inline]
|
||||||
|
pub fn new_with_strides(data: &'a [N], $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
||||||
|
Self::new_slice_with_strides_generic(data, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// FIXME: this is not very pretty. We could find a better call syntax.
|
||||||
|
impl_constructors!(R, C; // Arguments for Matrix<N, ..., S>
|
||||||
|
=> R: DimName, => C: DimName; // Type parameters for impl<N, ..., S>
|
||||||
|
R::name(), C::name(); // Arguments for `_generic` constructors.
|
||||||
|
); // Arguments for non-generic constructors.
|
||||||
|
|
||||||
|
impl_constructors!(R, Dynamic;
|
||||||
|
=> R: DimName;
|
||||||
|
R::name(), Dynamic::new(ncols);
|
||||||
|
ncols);
|
||||||
|
|
||||||
|
impl_constructors!(Dynamic, C;
|
||||||
|
=> C: DimName;
|
||||||
|
Dynamic::new(nrows), C::name();
|
||||||
|
nrows);
|
||||||
|
|
||||||
|
impl_constructors!(Dynamic, Dynamic;
|
||||||
|
;
|
||||||
|
Dynamic::new(nrows), Dynamic::new(ncols);
|
||||||
|
nrows, ncols);
|
||||||
|
|
||||||
|
|
||||||
|
macro_rules! impl_constructors_mut(
|
||||||
|
($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => {
|
||||||
|
impl<'a, N: Scalar, $($DimIdent: $DimBound),*> MatrixSliceMutMN<'a, N, $($Dims),*> {
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn new(data: &'a mut [N], $($args: usize),*) -> Self {
|
||||||
|
Self::new_slice_mut_generic(data, $($gargs),*)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, N: Scalar, $($DimIdent: $DimBound, )*> MatrixSliceMutMN<'a, N, $($Dims,)* Dynamic, Dynamic> {
|
||||||
|
#[inline]
|
||||||
|
pub fn new_with_strides(data: &'a mut [N], $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
||||||
|
Self::new_slice_with_strides_mut_generic(
|
||||||
|
data, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// FIXME: this is not very pretty. We could find a better call syntax.
|
||||||
|
impl_constructors_mut!(R, C; // Arguments for Matrix<N, ..., S>
|
||||||
|
=> R: DimName, => C: DimName; // Type parameters for impl<N, ..., S>
|
||||||
|
R::name(), C::name(); // Arguments for `_generic` constructors.
|
||||||
|
); // Arguments for non-generic constructors.
|
||||||
|
|
||||||
|
impl_constructors_mut!(R, Dynamic;
|
||||||
|
=> R: DimName;
|
||||||
|
R::name(), Dynamic::new(ncols);
|
||||||
|
ncols);
|
||||||
|
|
||||||
|
impl_constructors_mut!(Dynamic, C;
|
||||||
|
=> C: DimName;
|
||||||
|
Dynamic::new(nrows), C::name();
|
||||||
|
nrows);
|
||||||
|
|
||||||
|
impl_constructors_mut!(Dynamic, Dynamic;
|
||||||
|
;
|
||||||
|
Dynamic::new(nrows), Dynamic::new(ncols);
|
||||||
|
nrows, ncols);
|
|
@ -13,6 +13,7 @@ pub mod default_allocator;
|
||||||
mod scalar;
|
mod scalar;
|
||||||
mod matrix;
|
mod matrix;
|
||||||
mod construction;
|
mod construction;
|
||||||
|
mod construction_slice;
|
||||||
mod properties;
|
mod properties;
|
||||||
mod alias;
|
mod alias;
|
||||||
mod alias_slice;
|
mod alias_slice;
|
||||||
|
|
|
@ -13,7 +13,7 @@ use abomonation::Abomonation;
|
||||||
|
|
||||||
use alga::general::Real;
|
use alga::general::Real;
|
||||||
|
|
||||||
use core::{Unit, Vector3, Vector4, MatrixSlice, MatrixSliceMut, SquareMatrix, MatrixN};
|
use core::{Unit, Vector3, Vector4, MatrixSlice, MatrixSliceMut, SquareMatrix, MatrixN, Matrix3};
|
||||||
use core::dimension::{U1, U3, U4};
|
use core::dimension::{U1, U3, U4};
|
||||||
use core::storage::{RStride, CStride};
|
use core::storage::{RStride, CStride};
|
||||||
|
|
||||||
|
@ -533,7 +533,7 @@ impl<N: Real> UnitQuaternion<N> {
|
||||||
let wi = w * i * ::convert(2.0f64);
|
let wi = w * i * ::convert(2.0f64);
|
||||||
|
|
||||||
Rotation::from_matrix_unchecked(
|
Rotation::from_matrix_unchecked(
|
||||||
SquareMatrix::<_, U3, _>::new(
|
Matrix3::new(
|
||||||
ww + ii - jj - kk, ij - wk, wj + ik,
|
ww + ii - jj - kk, ij - wk, wj + ik,
|
||||||
wk + ij, ww - ii + jj - kk, jk - wi,
|
wk + ij, ww - ii + jj - kk, jk - wi,
|
||||||
ik - wj, wi + jk, ww - ii - jj + kk
|
ik - wj, wi + jk, ww - ii - jj + kk
|
||||||
|
|
|
@ -8,7 +8,7 @@ use num::Zero;
|
||||||
use rand::{Rand, Rng};
|
use rand::{Rand, Rng};
|
||||||
use alga::general::Real;
|
use alga::general::Real;
|
||||||
|
|
||||||
use core::{Unit, Vector, MatrixN, VectorN, Vector3};
|
use core::{Unit, Vector, Vector1, MatrixN, VectorN, Vector3};
|
||||||
use core::dimension::{U1, U2, U3};
|
use core::dimension::{U1, U2, U3};
|
||||||
use core::storage::Storage;
|
use core::storage::Storage;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ impl<N: Real> Rotation2<N> {
|
||||||
/// The rotation angle returned as a 1-dimensional vector.
|
/// The rotation angle returned as a 1-dimensional vector.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn scaled_axis(&self) -> VectorN<N, U1> {
|
pub fn scaled_axis(&self) -> VectorN<N, U1> {
|
||||||
Vector::<_, U1, _>::new(self.angle())
|
Vector1::new(self.angle())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
use na::{U2, U3, U4};
|
use na::{U2, U3, U4};
|
||||||
use na::{DMatrix,
|
use na::{DMatrix,
|
||||||
RowVector4,
|
RowVector4,
|
||||||
Vector3,
|
Vector3,
|
||||||
Matrix2, Matrix3,
|
Matrix2, Matrix3,
|
||||||
Matrix3x4, Matrix4x2, Matrix2x4, Matrix6x2, Matrix2x6};
|
Matrix2x3, Matrix3x2, Matrix3x4, Matrix4x2, Matrix2x4, Matrix6x2, Matrix2x6,
|
||||||
|
MatrixSlice2, MatrixSlice3, MatrixSlice2x3, MatrixSlice3x2,
|
||||||
|
MatrixSliceXx3, MatrixSlice2xX, DMatrixSlice,
|
||||||
|
MatrixSliceMut2, MatrixSliceMut3, MatrixSliceMut2x3, MatrixSliceMut3x2,
|
||||||
|
MatrixSliceMutXx3, MatrixSliceMut2xX, DMatrixSliceMut};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn nested_fixed_slices() {
|
fn nested_fixed_slices() {
|
||||||
|
@ -190,6 +196,83 @@ fn columns_range_pair() {
|
||||||
assert!(l.eq(&expected_l) && r.eq(&expected_r));
|
assert!(l.eq(&expected_l) && r.eq(&expected_r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn new_slice() {
|
||||||
|
let data = [ 1.0, 2.0, 3.0, 4.0,
|
||||||
|
5.0, 6.0, 7.0, 8.0,
|
||||||
|
9.0, 10.0, 11.0, 12.0 ];
|
||||||
|
|
||||||
|
let expected2 = Matrix2::from_column_slice(&data);
|
||||||
|
let expected3 = Matrix3::from_column_slice(&data);
|
||||||
|
let expected2x3 = Matrix2x3::from_column_slice(&data);
|
||||||
|
let expected3x2 = Matrix3x2::from_column_slice(&data);
|
||||||
|
|
||||||
|
{
|
||||||
|
let m2 = MatrixSlice2::new(&data);
|
||||||
|
let m3 = MatrixSlice3::new(&data);
|
||||||
|
let m2x3 = MatrixSlice2x3::new(&data);
|
||||||
|
let m3x2 = MatrixSlice3x2::new(&data);
|
||||||
|
let m2xX = MatrixSlice2xX::new(&data, 3);
|
||||||
|
let mXx3 = MatrixSliceXx3::new(&data, 2);
|
||||||
|
let mXxX = DMatrixSlice::new(&data, 2, 3);
|
||||||
|
|
||||||
|
assert!(m2.eq(&expected2));
|
||||||
|
assert!(m3.eq(&expected3));
|
||||||
|
assert!(m2x3.eq(&expected2x3));
|
||||||
|
assert!(m3x2.eq(&expected3x2));
|
||||||
|
assert!(m2xX.eq(&expected2x3));
|
||||||
|
assert!(mXx3.eq(&expected2x3));
|
||||||
|
assert!(mXxX.eq(&expected2x3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn new_slice_mut() {
|
||||||
|
let data = [ 1.0, 2.0, 3.0, 4.0,
|
||||||
|
5.0, 6.0, 7.0, 8.0,
|
||||||
|
9.0, 10.0, 11.0, 12.0 ];
|
||||||
|
let expected2 = [ 0.0, 0.0, 0.0, 0.0,
|
||||||
|
5.0, 6.0, 7.0, 8.0,
|
||||||
|
9.0, 10.0, 11.0, 12.0 ];
|
||||||
|
let expected3 = [ 0.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 10.0, 11.0, 12.0 ];
|
||||||
|
let expected2x3 = [ 0.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 7.0, 8.0,
|
||||||
|
9.0, 10.0, 11.0, 12.0 ];
|
||||||
|
let expected3x2 = [ 0.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 7.0, 8.0,
|
||||||
|
9.0, 10.0, 11.0, 12.0 ];
|
||||||
|
|
||||||
|
let mut data_mut = data.clone();
|
||||||
|
MatrixSliceMut2::new(&mut data_mut).fill(0.0);
|
||||||
|
assert!(data_mut == expected2);
|
||||||
|
|
||||||
|
let mut data_mut = data.clone();
|
||||||
|
MatrixSliceMut3::new(&mut data_mut).fill(0.0);
|
||||||
|
assert!(data_mut == expected3);
|
||||||
|
|
||||||
|
let mut data_mut = data.clone();
|
||||||
|
MatrixSliceMut2x3::new(&mut data_mut).fill(0.0);
|
||||||
|
assert!(data_mut == expected2x3);
|
||||||
|
|
||||||
|
let mut data_mut = data.clone();
|
||||||
|
MatrixSliceMut3x2::new(&mut data_mut).fill(0.0);
|
||||||
|
assert!(data_mut == expected3x2);
|
||||||
|
|
||||||
|
let mut data_mut = data.clone();
|
||||||
|
MatrixSliceMut2xX::new(&mut data_mut, 3).fill(0.0);
|
||||||
|
assert!(data_mut == expected2x3);
|
||||||
|
|
||||||
|
let mut data_mut = data.clone();
|
||||||
|
MatrixSliceMutXx3::new(&mut data_mut, 2).fill(0.0);
|
||||||
|
assert!(data_mut == expected2x3);
|
||||||
|
|
||||||
|
let mut data_mut = data.clone();
|
||||||
|
DMatrixSliceMut::new(&mut data_mut, 2, 3).fill(0.0);
|
||||||
|
assert!(data_mut == expected2x3);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn row_out_of_bounds() {
|
fn row_out_of_bounds() {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
mod conversion;
|
// mod conversion;
|
||||||
mod edition;
|
// mod edition;
|
||||||
mod matrix;
|
// mod matrix;
|
||||||
mod matrix_slice;
|
mod matrix_slice;
|
||||||
mod blas;
|
// mod blas;
|
||||||
mod serde;
|
// mod serde;
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
// #[cfg(feature = "abomonation-serialize")]
|
||||||
mod abomonation;
|
// mod abomonation;
|
||||||
#[cfg(feature = "mint")]
|
// #[cfg(feature = "mint")]
|
||||||
mod mint;
|
// mod mint;
|
||||||
|
|
|
@ -15,5 +15,5 @@ extern crate nalgebra as na;
|
||||||
|
|
||||||
|
|
||||||
mod core;
|
mod core;
|
||||||
mod linalg;
|
// mod linalg;
|
||||||
mod geometry;
|
// mod geometry;
|
||||||
|
|
Loading…
Reference in New Issue