commit
d8ed277243
|
@ -50,7 +50,7 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
# Needed because the --all-features build which enables cuda support.
|
# Needed because the --all-features build which enables cuda support.
|
||||||
- uses: Jimver/cuda-toolkit@v0.2.4
|
- uses: Jimver/cuda-toolkit@v0.2.8
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- run: cargo build --all-features;
|
- run: cargo build --all-features;
|
||||||
- run: cargo build -p nalgebra-glm --all-features;
|
- run: cargo build -p nalgebra-glm --all-features;
|
||||||
|
@ -61,7 +61,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: test
|
- name: test
|
||||||
run: cargo test --features arbitrary,rand,serde-serialize,sparse,debug,io,compare,libm,proptest-support,slow-tests;
|
run: cargo test --features arbitrary,rand,serde-serialize,sparse,debug,io,compare,libm,proptest-support,slow-tests,rkyv-safe-deser,rayon;
|
||||||
test-nalgebra-glm:
|
test-nalgebra-glm:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
|
@ -123,9 +123,9 @@ jobs:
|
||||||
build-cuda:
|
build-cuda:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: Jimver/cuda-toolkit@v0.2.4
|
- uses: Jimver/cuda-toolkit@v0.2.8
|
||||||
with:
|
with:
|
||||||
cuda: '11.2.2'
|
cuda: '11.5.0'
|
||||||
- name: Install nightly-2021-12-04
|
- name: Install nightly-2021-12-04
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
|
@ -137,3 +137,9 @@ jobs:
|
||||||
- run: cargo build --no-default-features --features cuda --target=nvptx64-nvidia-cuda
|
- run: cargo build --no-default-features --features cuda --target=nvptx64-nvidia-cuda
|
||||||
env:
|
env:
|
||||||
CUDA_ARCH: "350"
|
CUDA_ARCH: "350"
|
||||||
|
docs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Generate documentation
|
||||||
|
run: cargo doc
|
||||||
|
|
37
CHANGELOG.md
37
CHANGELOG.md
|
@ -4,6 +4,43 @@ documented here.
|
||||||
|
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/).
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|
## [0.32.0] (14 Jan. 2023)
|
||||||
|
|
||||||
|
### Modified
|
||||||
|
- Renamed all `MatrixSlice` types to `MatrixView`. In general all occurrences of the world `Slice` or `slice` have been
|
||||||
|
replaced by `View` or `view`.
|
||||||
|
- Deprecated all the types involving `Slice` in its name, in favor of the word `View`.
|
||||||
|
- Make it so that most `nalgebra` objects archive as themselves (when using `rkyv` for serialization).
|
||||||
|
- Renamed `Dynamic` to `Dyn` and make `Dyn` a tuple struct.
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add `Cholesky::ln_determinant` to compute the natural logarithm of the determinant of a matrix decomposed
|
||||||
|
with Cholesky. This can be more numerically stable than computing the determinant itself when very small and/or
|
||||||
|
large values are involved.
|
||||||
|
- Added new methods `Matrix::as_view` and `Matrix::as_view_mut`, which are very useful when working with view-based APIs.
|
||||||
|
- Added parallel column iterator using `rayon`: `Matrix::par_column_iter` and `Matrix::par_column_iter_mut`. The `rayon`
|
||||||
|
feature must be enabled to access these methods.
|
||||||
|
- Implement `ReshapableStorage` for matrix slices (only for unit strides at the moment).
|
||||||
|
- Add `U0, U1, …` constants alongside the `U0, U1, …` types. This lets us write `U4` instead of `U4::name()` or
|
||||||
|
`Const::<4>` when we need const dimensions.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed the implementation of `Rotation3::euler_angles` to return the angles in the documented order (roll, pitch, yaw).
|
||||||
|
|
||||||
|
## [0.31.4] (13 Nov. 2022)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add a `convert-glam022` feature to enable conversion between `nalgebra` and `glam v0.22`.
|
||||||
|
|
||||||
|
|
||||||
|
## [0.31.3] (30 Oct. 2022)
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add `Matrix::try_cast` to attempt casting the inner scalar types when that cast may fail.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed the usage of `CheckBytes` with `rkyv`.
|
||||||
|
|
||||||
## [0.31.2] (09 Oct. 2022)
|
## [0.31.2] (09 Oct. 2022)
|
||||||
|
|
||||||
### Modified
|
### Modified
|
||||||
|
|
21
Cargo.toml
21
Cargo.toml
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nalgebra"
|
name = "nalgebra"
|
||||||
version = "0.31.2"
|
version = "0.32.0"
|
||||||
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
|
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
|
||||||
|
|
||||||
description = "General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices."
|
description = "General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices."
|
||||||
|
@ -34,6 +34,7 @@ libm-force = [ "simba/libm_force" ]
|
||||||
macros = [ "nalgebra-macros" ]
|
macros = [ "nalgebra-macros" ]
|
||||||
cuda = [ "cust_core", "simba/cuda" ]
|
cuda = [ "cust_core", "simba/cuda" ]
|
||||||
|
|
||||||
|
|
||||||
# Conversion
|
# Conversion
|
||||||
convert-mint = [ "mint" ]
|
convert-mint = [ "mint" ]
|
||||||
convert-bytemuck = [ "bytemuck" ]
|
convert-bytemuck = [ "bytemuck" ]
|
||||||
|
@ -45,6 +46,7 @@ convert-glam018 = [ "glam018" ]
|
||||||
convert-glam019 = [ "glam019" ]
|
convert-glam019 = [ "glam019" ]
|
||||||
convert-glam020 = [ "glam020" ]
|
convert-glam020 = [ "glam020" ]
|
||||||
convert-glam021 = [ "glam021" ]
|
convert-glam021 = [ "glam021" ]
|
||||||
|
convert-glam022 = [ "glam022" ]
|
||||||
|
|
||||||
# Serialization
|
# Serialization
|
||||||
## To use serde in a #[no-std] environment, enable the
|
## To use serde in a #[no-std] environment, enable the
|
||||||
|
@ -53,8 +55,8 @@ convert-glam021 = [ "glam021" ]
|
||||||
## `serde-serialize`.
|
## `serde-serialize`.
|
||||||
serde-serialize-no-std = [ "serde", "num-complex/serde" ]
|
serde-serialize-no-std = [ "serde", "num-complex/serde" ]
|
||||||
serde-serialize = [ "serde-serialize-no-std", "serde/std" ]
|
serde-serialize = [ "serde-serialize-no-std", "serde/std" ]
|
||||||
rkyv-serialize-no-std = [ "rkyv" ]
|
rkyv-serialize-no-std = [ "rkyv/size_32" ]
|
||||||
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std", "bytecheck" ]
|
rkyv-serialize = [ "rkyv-serialize-no-std", "rkyv/std", "rkyv/validation", "bytecheck" ]
|
||||||
|
|
||||||
# Randomness
|
# Randomness
|
||||||
## To use rand in a #[no-std] environment, enable the
|
## To use rand in a #[no-std] environment, enable the
|
||||||
|
@ -66,6 +68,7 @@ rand = [ "rand-no-std", "rand-package/std", "rand-package/std_rng", "rand
|
||||||
arbitrary = [ "quickcheck" ]
|
arbitrary = [ "quickcheck" ]
|
||||||
proptest-support = [ "proptest" ]
|
proptest-support = [ "proptest" ]
|
||||||
slow-tests = []
|
slow-tests = []
|
||||||
|
rkyv-safe-deser = [ "rkyv-serialize", "rkyv/validation" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra-macros = { version = "0.1", path = "nalgebra-macros", optional = true }
|
nalgebra-macros = { version = "0.1", path = "nalgebra-macros", optional = true }
|
||||||
|
@ -75,12 +78,12 @@ num-traits = { version = "0.2", default-features = false }
|
||||||
num-complex = { version = "0.4", default-features = false }
|
num-complex = { version = "0.4", default-features = false }
|
||||||
num-rational = { version = "0.4", default-features = false }
|
num-rational = { version = "0.4", default-features = false }
|
||||||
approx = { version = "0.5", default-features = false }
|
approx = { version = "0.5", default-features = false }
|
||||||
simba = { version = "0.7", default-features = false }
|
simba = { version = "0.8", default-features = false }
|
||||||
alga = { version = "0.9", default-features = false, optional = true }
|
alga = { version = "0.9", default-features = false, optional = true }
|
||||||
rand_distr = { version = "0.4", default-features = false, optional = true }
|
rand_distr = { version = "0.4", default-features = false, optional = true }
|
||||||
matrixmultiply = { version = "0.3", optional = true }
|
matrixmultiply = { version = "0.3", optional = true }
|
||||||
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
|
serde = { version = "1.0", default-features = false, features = [ "derive" ], optional = true }
|
||||||
rkyv = { version = "~0.7.1", optional = true }
|
rkyv = { version = "0.7", default-features = false, optional = true }
|
||||||
bytecheck = { version = "~0.6.1", optional = true }
|
bytecheck = { version = "~0.6.1", optional = true }
|
||||||
mint = { version = "0.5", optional = true }
|
mint = { version = "0.5", optional = true }
|
||||||
quickcheck = { version = "1", optional = true }
|
quickcheck = { version = "1", optional = true }
|
||||||
|
@ -97,14 +100,15 @@ glam018 = { package = "glam", version = "0.18", optional = true }
|
||||||
glam019 = { package = "glam", version = "0.19", optional = true }
|
glam019 = { package = "glam", version = "0.19", optional = true }
|
||||||
glam020 = { package = "glam", version = "0.20", optional = true }
|
glam020 = { package = "glam", version = "0.20", optional = true }
|
||||||
glam021 = { package = "glam", version = "0.21", optional = true }
|
glam021 = { package = "glam", version = "0.21", optional = true }
|
||||||
|
glam022 = { package = "glam", version = "0.22", optional = true }
|
||||||
cust_core = { version = "0.1", optional = true }
|
cust_core = { version = "0.1", optional = true }
|
||||||
|
rayon = { version = "1.6", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
rand_xorshift = "0.3"
|
rand_xorshift = "0.3"
|
||||||
rand_isaac = "0.3"
|
rand_isaac = "0.3"
|
||||||
criterion = { version = "0.3", features = ["html_reports"] }
|
criterion = { version = "0.4", features = ["html_reports"] }
|
||||||
|
|
||||||
# For matrix comparison macro
|
# For matrix comparison macro
|
||||||
matrixcompare = "0.3.0"
|
matrixcompare = "0.3.0"
|
||||||
|
@ -134,4 +138,5 @@ lto = true
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
# Enable all the features when building the docs on docs.rs
|
# Enable all the features when building the docs on docs.rs
|
||||||
all-features = true
|
all-features = true
|
||||||
|
# define the configuration attribute `docsrs`
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
|
@ -53,7 +53,7 @@ fn mat_div_scalar(b: &mut criterion::Criterion) {
|
||||||
b.bench_function("mat_div_scalar", move |bh| {
|
b.bench_function("mat_div_scalar", move |bh| {
|
||||||
bh.iter(|| {
|
bh.iter(|| {
|
||||||
let mut aa = a.clone();
|
let mut aa = a.clone();
|
||||||
let mut b = aa.slice_mut((0, 0), (1000, 1000));
|
let mut b = aa.view_mut((0, 0), (1000, 1000));
|
||||||
b /= n
|
b /= n
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ version = "0.0.0"
|
||||||
authors = [ "You" ]
|
authors = [ "You" ]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = "0.31.0"
|
nalgebra = "0.32.0"
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
name = "example"
|
name = "example"
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
extern crate nalgebra as na;
|
extern crate nalgebra as na;
|
||||||
|
|
||||||
use na::{DMatrix, Dynamic, Matrix2x3, Matrix3x2, Const};
|
use na::{DMatrix, Dyn, Matrix2x3, Matrix3x2, Const};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Matrices can be reshaped in-place without moving or copying values.
|
// Matrices can be reshaped in-place without moving or copying values.
|
||||||
|
@ -46,9 +46,9 @@ fn main() {
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
let dm3 = dm1.reshape_generic(Dynamic::new(6), Dynamic::new(2));
|
let dm3 = dm1.reshape_generic(Dyn(6), Dyn(2));
|
||||||
assert_eq!(dm3, dm2);
|
assert_eq!(dm3, dm2);
|
||||||
|
|
||||||
// Invalid reshapings of dynamic matrices will panic at run-time.
|
// Invalid reshapings of dynamic matrices will panic at run-time.
|
||||||
//let dm4 = dm3.reshape_generic(Dynamic::new(6), Dynamic::new(6));
|
//let dm4 = dm3.reshape_generic(Dyn(6), Dyn(6));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nalgebra-glm"
|
name = "nalgebra-glm"
|
||||||
version = "0.17.0"
|
version = "0.18.0"
|
||||||
authors = ["sebcrozet <developer@crozet.re>"]
|
authors = ["sebcrozet <developer@crozet.re>"]
|
||||||
|
|
||||||
description = "A computer-graphics oriented API for nalgebra, inspired by the C++ GLM library."
|
description = "A computer-graphics oriented API for nalgebra, inspired by the C++ GLM library."
|
||||||
|
@ -35,5 +35,5 @@ convert-glam018 = [ "nalgebra/glam018" ]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
approx = { version = "0.5", default-features = false }
|
approx = { version = "0.5", default-features = false }
|
||||||
simba = { version = "0.7", default-features = false }
|
simba = { version = "0.8", default-features = false }
|
||||||
nalgebra = { path = "..", version = "0.31", default-features = false }
|
nalgebra = { path = "..", version = "0.32", default-features = false }
|
||||||
|
|
|
@ -93,6 +93,6 @@ pub fn mat3_to_quat<T: RealNumber>(x: &TMat3<T>) -> Qua<T> {
|
||||||
|
|
||||||
/// Converts a rotation matrix in homogeneous coordinates to a quaternion.
|
/// Converts a rotation matrix in homogeneous coordinates to a quaternion.
|
||||||
pub fn to_quat<T: RealNumber>(x: &TMat4<T>) -> Qua<T> {
|
pub fn to_quat<T: RealNumber>(x: &TMat4<T>) -> Qua<T> {
|
||||||
let rot = x.fixed_slice::<3, 3>(0, 0).into_owned();
|
let rot = x.fixed_view::<3, 3>(0, 0).into_owned();
|
||||||
mat3_to_quat(&rot)
|
mat3_to_quat(&rot)
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ pub fn proj2d<T: Number>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
|
||||||
let mut res = TMat3::identity();
|
let mut res = TMat3::identity();
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut part = res.fixed_slice_mut::<2, 2>(0, 0);
|
let mut part = res.fixed_view_mut::<2, 2>(0, 0);
|
||||||
part -= normal * normal.transpose();
|
part -= normal * normal.transpose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ pub fn proj<T: Number>(m: &TMat4<T>, normal: &TVec3<T>) -> TMat4<T> {
|
||||||
let mut res = TMat4::identity();
|
let mut res = TMat4::identity();
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut part = res.fixed_slice_mut::<3, 3>(0, 0);
|
let mut part = res.fixed_view_mut::<3, 3>(0, 0);
|
||||||
part -= normal * normal.transpose();
|
part -= normal * normal.transpose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ pub fn reflect2d<T: RealNumber>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
|
||||||
let mut res = TMat3::identity();
|
let mut res = TMat3::identity();
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut part = res.fixed_slice_mut::<2, 2>(0, 0);
|
let mut part = res.fixed_view_mut::<2, 2>(0, 0);
|
||||||
part -= (normal * T::from_subset(&2.0)) * normal.transpose();
|
part -= (normal * T::from_subset(&2.0)) * normal.transpose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ pub fn reflect<T: RealNumber>(m: &TMat4<T>, normal: &TVec3<T>) -> TMat4<T> {
|
||||||
let mut res = TMat4::identity();
|
let mut res = TMat4::identity();
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut part = res.fixed_slice_mut::<3, 3>(0, 0);
|
let mut part = res.fixed_view_mut::<3, 3>(0, 0);
|
||||||
part -= (normal * T::from_subset(&2.0)) * normal.transpose();
|
part -= (normal * T::from_subset(&2.0)) * normal.transpose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nalgebra-lapack"
|
name = "nalgebra-lapack"
|
||||||
version = "0.22.0"
|
version = "0.24.0"
|
||||||
authors = [ "Sébastien Crozet <developer@crozet.re>", "Andrew Straw <strawman@astraw.com>" ]
|
authors = [ "Sébastien Crozet <developer@crozet.re>", "Andrew Straw <strawman@astraw.com>" ]
|
||||||
|
|
||||||
description = "Matrix decompositions using nalgebra matrices and Lapack bindings."
|
description = "Matrix decompositions using nalgebra matrices and Lapack bindings."
|
||||||
|
@ -29,18 +29,19 @@ accelerate = ["lapack-src/accelerate"]
|
||||||
intel-mkl = ["lapack-src/intel-mkl"]
|
intel-mkl = ["lapack-src/intel-mkl"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = { version = "0.31", path = ".." }
|
nalgebra = { version = "0.32", path = ".." }
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
num-complex = { version = "0.4", default-features = false }
|
num-complex = { version = "0.4", default-features = false }
|
||||||
simba = "0.7"
|
simba = "0.8"
|
||||||
serde = { version = "1.0", features = [ "derive" ], optional = true }
|
serde = { version = "1.0", features = [ "derive" ], optional = true }
|
||||||
lapack = { version = "0.19", default-features = false }
|
lapack = { version = "0.19", default-features = false }
|
||||||
lapack-src = { version = "0.8", default-features = false }
|
lapack-src = { version = "0.8", default-features = false }
|
||||||
# clippy = "*"
|
# clippy = "*"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nalgebra = { version = "0.31", features = [ "arbitrary", "rand" ], path = ".." }
|
nalgebra = { version = "0.32", features = [ "arbitrary", "rand" ], path = ".." }
|
||||||
proptest = { version = "1", default-features = false, features = ["std"] }
|
proptest = { version = "1", default-features = false, features = ["std"] }
|
||||||
quickcheck = "1"
|
quickcheck = "1"
|
||||||
approx = "0.5"
|
approx = "0.5"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
|
|
||||||
|
|
|
@ -7,13 +7,12 @@ use num_complex::Complex;
|
||||||
use simba::scalar::RealField;
|
use simba::scalar::RealField;
|
||||||
|
|
||||||
use crate::ComplexHelper;
|
use crate::ComplexHelper;
|
||||||
use na::allocator::Allocator;
|
|
||||||
use na::dimension::{Const, Dim};
|
use na::dimension::{Const, Dim};
|
||||||
use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar};
|
use na::{allocator::Allocator, DefaultAllocator, Matrix, OMatrix, OVector, Scalar};
|
||||||
|
|
||||||
use lapack;
|
use lapack;
|
||||||
|
|
||||||
/// Eigendecomposition of a real square matrix with real eigenvalues.
|
/// Eigendecomposition of a real square matrix with real or complex eigenvalues.
|
||||||
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde-serialize",
|
feature = "serde-serialize",
|
||||||
|
@ -36,8 +35,10 @@ pub struct Eigen<T: Scalar, D: Dim>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
|
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
|
||||||
{
|
{
|
||||||
/// The eigenvalues of the decomposed matrix.
|
/// The real parts of eigenvalues of the decomposed matrix.
|
||||||
pub eigenvalues: OVector<T, D>,
|
pub eigenvalues_re: OVector<T, D>,
|
||||||
|
/// The imaginary parts of the eigenvalues of the decomposed matrix.
|
||||||
|
pub eigenvalues_im: OVector<T, D>,
|
||||||
/// The (right) eigenvectors of the decomposed matrix.
|
/// The (right) eigenvectors of the decomposed matrix.
|
||||||
pub eigenvectors: Option<OMatrix<T, D, D>>,
|
pub eigenvectors: Option<OMatrix<T, D, D>>,
|
||||||
/// The left eigenvectors of the decomposed matrix.
|
/// The left eigenvectors of the decomposed matrix.
|
||||||
|
@ -69,8 +70,8 @@ where
|
||||||
"Unable to compute the eigenvalue decomposition of a non-square matrix."
|
"Unable to compute the eigenvalue decomposition of a non-square matrix."
|
||||||
);
|
);
|
||||||
|
|
||||||
let ljob = if left_eigenvectors { b'V' } else { b'T' };
|
let ljob = if left_eigenvectors { b'V' } else { b'N' };
|
||||||
let rjob = if eigenvectors { b'V' } else { b'T' };
|
let rjob = if eigenvectors { b'V' } else { b'N' };
|
||||||
|
|
||||||
let (nrows, ncols) = m.shape_generic();
|
let (nrows, ncols) = m.shape_generic();
|
||||||
let n = nrows.value();
|
let n = nrows.value();
|
||||||
|
@ -104,213 +105,232 @@ where
|
||||||
lapack_check!(info);
|
lapack_check!(info);
|
||||||
|
|
||||||
let mut work = vec![T::zero(); lwork as usize];
|
let mut work = vec![T::zero(); lwork as usize];
|
||||||
|
let mut vl = if left_eigenvectors {
|
||||||
|
Some(Matrix::zeros_generic(nrows, ncols))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let mut vr = if eigenvectors {
|
||||||
|
Some(Matrix::zeros_generic(nrows, ncols))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
match (left_eigenvectors, eigenvectors) {
|
let vl_ref = vl
|
||||||
(true, true) => {
|
.as_mut()
|
||||||
// TODO: avoid the initializations?
|
.map(|m| m.as_mut_slice())
|
||||||
let mut vl = Matrix::zeros_generic(nrows, ncols);
|
.unwrap_or(&mut placeholder1);
|
||||||
let mut vr = Matrix::zeros_generic(nrows, ncols);
|
let vr_ref = vr
|
||||||
|
.as_mut()
|
||||||
T::xgeev(
|
.map(|m| m.as_mut_slice())
|
||||||
ljob,
|
.unwrap_or(&mut placeholder2);
|
||||||
rjob,
|
|
||||||
n as i32,
|
|
||||||
m.as_mut_slice(),
|
|
||||||
lda,
|
|
||||||
wr.as_mut_slice(),
|
|
||||||
wi.as_mut_slice(),
|
|
||||||
&mut vl.as_mut_slice(),
|
|
||||||
n as i32,
|
|
||||||
&mut vr.as_mut_slice(),
|
|
||||||
n as i32,
|
|
||||||
&mut work,
|
|
||||||
lwork,
|
|
||||||
&mut info,
|
|
||||||
);
|
|
||||||
lapack_check!(info);
|
|
||||||
|
|
||||||
if wi.iter().all(|e| e.is_zero()) {
|
|
||||||
return Some(Self {
|
|
||||||
eigenvalues: wr,
|
|
||||||
left_eigenvectors: Some(vl),
|
|
||||||
eigenvectors: Some(vr),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(true, false) => {
|
|
||||||
// TODO: avoid the initialization?
|
|
||||||
let mut vl = Matrix::zeros_generic(nrows, ncols);
|
|
||||||
|
|
||||||
T::xgeev(
|
|
||||||
ljob,
|
|
||||||
rjob,
|
|
||||||
n as i32,
|
|
||||||
m.as_mut_slice(),
|
|
||||||
lda,
|
|
||||||
wr.as_mut_slice(),
|
|
||||||
wi.as_mut_slice(),
|
|
||||||
&mut vl.as_mut_slice(),
|
|
||||||
n as i32,
|
|
||||||
&mut placeholder2,
|
|
||||||
1 as i32,
|
|
||||||
&mut work,
|
|
||||||
lwork,
|
|
||||||
&mut info,
|
|
||||||
);
|
|
||||||
lapack_check!(info);
|
|
||||||
|
|
||||||
if wi.iter().all(|e| e.is_zero()) {
|
|
||||||
return Some(Self {
|
|
||||||
eigenvalues: wr,
|
|
||||||
left_eigenvectors: Some(vl),
|
|
||||||
eigenvectors: None,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(false, true) => {
|
|
||||||
// TODO: avoid the initialization?
|
|
||||||
let mut vr = Matrix::zeros_generic(nrows, ncols);
|
|
||||||
|
|
||||||
T::xgeev(
|
|
||||||
ljob,
|
|
||||||
rjob,
|
|
||||||
n as i32,
|
|
||||||
m.as_mut_slice(),
|
|
||||||
lda,
|
|
||||||
wr.as_mut_slice(),
|
|
||||||
wi.as_mut_slice(),
|
|
||||||
&mut placeholder1,
|
|
||||||
1 as i32,
|
|
||||||
&mut vr.as_mut_slice(),
|
|
||||||
n as i32,
|
|
||||||
&mut work,
|
|
||||||
lwork,
|
|
||||||
&mut info,
|
|
||||||
);
|
|
||||||
lapack_check!(info);
|
|
||||||
|
|
||||||
if wi.iter().all(|e| e.is_zero()) {
|
|
||||||
return Some(Self {
|
|
||||||
eigenvalues: wr,
|
|
||||||
left_eigenvectors: None,
|
|
||||||
eigenvectors: Some(vr),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
(false, false) => {
|
|
||||||
T::xgeev(
|
|
||||||
ljob,
|
|
||||||
rjob,
|
|
||||||
n as i32,
|
|
||||||
m.as_mut_slice(),
|
|
||||||
lda,
|
|
||||||
wr.as_mut_slice(),
|
|
||||||
wi.as_mut_slice(),
|
|
||||||
&mut placeholder1,
|
|
||||||
1 as i32,
|
|
||||||
&mut placeholder2,
|
|
||||||
1 as i32,
|
|
||||||
&mut work,
|
|
||||||
lwork,
|
|
||||||
&mut info,
|
|
||||||
);
|
|
||||||
lapack_check!(info);
|
|
||||||
|
|
||||||
if wi.iter().all(|e| e.is_zero()) {
|
|
||||||
return Some(Self {
|
|
||||||
eigenvalues: wr,
|
|
||||||
left_eigenvectors: None,
|
|
||||||
eigenvectors: None,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// The complex eigenvalues of the given matrix.
|
|
||||||
///
|
|
||||||
/// Panics if the eigenvalue computation does not converge.
|
|
||||||
pub fn complex_eigenvalues(mut m: OMatrix<T, D, D>) -> OVector<Complex<T>, D>
|
|
||||||
where
|
|
||||||
DefaultAllocator: Allocator<Complex<T>, D>,
|
|
||||||
{
|
|
||||||
assert!(
|
|
||||||
m.is_square(),
|
|
||||||
"Unable to compute the eigenvalue decomposition of a non-square matrix."
|
|
||||||
);
|
|
||||||
|
|
||||||
let nrows = m.shape_generic().0;
|
|
||||||
let n = nrows.value();
|
|
||||||
|
|
||||||
let lda = n as i32;
|
|
||||||
|
|
||||||
// TODO: avoid the initialization?
|
|
||||||
let mut wr = Matrix::zeros_generic(nrows, Const::<1>);
|
|
||||||
let mut wi = Matrix::zeros_generic(nrows, Const::<1>);
|
|
||||||
|
|
||||||
let mut info = 0;
|
|
||||||
let mut placeholder1 = [T::zero()];
|
|
||||||
let mut placeholder2 = [T::zero()];
|
|
||||||
|
|
||||||
let lwork = T::xgeev_work_size(
|
|
||||||
b'T',
|
|
||||||
b'T',
|
|
||||||
n as i32,
|
|
||||||
m.as_mut_slice(),
|
|
||||||
lda,
|
|
||||||
wr.as_mut_slice(),
|
|
||||||
wi.as_mut_slice(),
|
|
||||||
&mut placeholder1,
|
|
||||||
n as i32,
|
|
||||||
&mut placeholder2,
|
|
||||||
n as i32,
|
|
||||||
&mut info,
|
|
||||||
);
|
|
||||||
|
|
||||||
lapack_panic!(info);
|
|
||||||
|
|
||||||
let mut work = vec![T::zero(); lwork as usize];
|
|
||||||
|
|
||||||
T::xgeev(
|
T::xgeev(
|
||||||
b'T',
|
ljob,
|
||||||
b'T',
|
rjob,
|
||||||
n as i32,
|
n as i32,
|
||||||
m.as_mut_slice(),
|
m.as_mut_slice(),
|
||||||
lda,
|
lda,
|
||||||
wr.as_mut_slice(),
|
wr.as_mut_slice(),
|
||||||
wi.as_mut_slice(),
|
wi.as_mut_slice(),
|
||||||
&mut placeholder1,
|
vl_ref,
|
||||||
1 as i32,
|
if left_eigenvectors { n as i32 } else { 1 },
|
||||||
&mut placeholder2,
|
vr_ref,
|
||||||
1 as i32,
|
if eigenvectors { n as i32 } else { 1 },
|
||||||
&mut work,
|
&mut work,
|
||||||
lwork,
|
lwork,
|
||||||
&mut info,
|
&mut info,
|
||||||
);
|
);
|
||||||
lapack_panic!(info);
|
lapack_check!(info);
|
||||||
|
|
||||||
let mut res = Matrix::zeros_generic(nrows, Const::<1>);
|
Some(Self {
|
||||||
|
eigenvalues_re: wr,
|
||||||
|
eigenvalues_im: wi,
|
||||||
|
left_eigenvectors: vl,
|
||||||
|
eigenvectors: vr,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
for i in 0..res.len() {
|
/// Returns `true` if all the eigenvalues are real.
|
||||||
res[i] = Complex::new(wr[i].clone(), wi[i].clone());
|
pub fn eigenvalues_are_real(&self) -> bool {
|
||||||
}
|
self.eigenvalues_im.iter().all(|e| e.is_zero())
|
||||||
|
|
||||||
res
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The determinant of the decomposed matrix.
|
/// The determinant of the decomposed matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn determinant(&self) -> T {
|
pub fn determinant(&self) -> Complex<T> {
|
||||||
let mut det = T::one();
|
let mut det: Complex<T> = na::one();
|
||||||
for e in self.eigenvalues.iter() {
|
for (re, im) in self.eigenvalues_re.iter().zip(self.eigenvalues_im.iter()) {
|
||||||
det *= e.clone();
|
det *= Complex::new(re.clone(), im.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
det
|
det
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a tuple of vectors. The elements of the tuple are the real parts of the eigenvalues, left eigenvectors and right eigenvectors respectively.
|
||||||
|
pub fn get_real_elements(
|
||||||
|
&self,
|
||||||
|
) -> (
|
||||||
|
Vec<T>,
|
||||||
|
Option<Vec<OVector<T, D>>>,
|
||||||
|
Option<Vec<OVector<T, D>>>,
|
||||||
|
)
|
||||||
|
where
|
||||||
|
DefaultAllocator: Allocator<T, D>,
|
||||||
|
{
|
||||||
|
let (number_of_elements, _) = self.eigenvalues_re.shape_generic();
|
||||||
|
let number_of_elements_value = number_of_elements.value();
|
||||||
|
let mut eigenvalues = Vec::<T>::with_capacity(number_of_elements_value);
|
||||||
|
let mut eigenvectors = match self.eigenvectors.is_some() {
|
||||||
|
true => Some(Vec::<OVector<T, D>>::with_capacity(
|
||||||
|
number_of_elements_value,
|
||||||
|
)),
|
||||||
|
false => None,
|
||||||
|
};
|
||||||
|
let mut left_eigenvectors = match self.left_eigenvectors.is_some() {
|
||||||
|
true => Some(Vec::<OVector<T, D>>::with_capacity(
|
||||||
|
number_of_elements_value,
|
||||||
|
)),
|
||||||
|
false => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut c = 0;
|
||||||
|
while c < number_of_elements_value {
|
||||||
|
eigenvalues.push(self.eigenvalues_re[c].clone());
|
||||||
|
|
||||||
|
if eigenvectors.is_some() {
|
||||||
|
eigenvectors.as_mut().unwrap().push(
|
||||||
|
(&self.eigenvectors.as_ref())
|
||||||
|
.unwrap()
|
||||||
|
.column(c)
|
||||||
|
.into_owned(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if left_eigenvectors.is_some() {
|
||||||
|
left_eigenvectors.as_mut().unwrap().push(
|
||||||
|
(&self.left_eigenvectors.as_ref())
|
||||||
|
.unwrap()
|
||||||
|
.column(c)
|
||||||
|
.into_owned(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if self.eigenvalues_im[c] != T::zero() {
|
||||||
|
//skip next entry
|
||||||
|
c += 1;
|
||||||
|
}
|
||||||
|
c += 1;
|
||||||
|
}
|
||||||
|
(eigenvalues, left_eigenvectors, eigenvectors)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns a tuple of vectors. The elements of the tuple are the complex eigenvalues, complex left eigenvectors and complex right eigenvectors respectively.
|
||||||
|
/// The elements appear as conjugate pairs within each vector, with the positive of the pair always being first.
|
||||||
|
pub fn get_complex_elements(
|
||||||
|
&self,
|
||||||
|
) -> (
|
||||||
|
Option<Vec<Complex<T>>>,
|
||||||
|
Option<Vec<OVector<Complex<T>, D>>>,
|
||||||
|
Option<Vec<OVector<Complex<T>, D>>>,
|
||||||
|
)
|
||||||
|
where
|
||||||
|
DefaultAllocator: Allocator<Complex<T>, D>,
|
||||||
|
{
|
||||||
|
match self.eigenvalues_are_real() {
|
||||||
|
true => (None, None, None),
|
||||||
|
false => {
|
||||||
|
let (number_of_elements, _) = self.eigenvalues_re.shape_generic();
|
||||||
|
let number_of_elements_value = number_of_elements.value();
|
||||||
|
let number_of_complex_entries =
|
||||||
|
self.eigenvalues_im
|
||||||
|
.iter()
|
||||||
|
.fold(0, |acc, e| if !e.is_zero() { acc + 1 } else { acc });
|
||||||
|
let mut eigenvalues = Vec::<Complex<T>>::with_capacity(number_of_complex_entries);
|
||||||
|
let mut eigenvectors = match self.eigenvectors.is_some() {
|
||||||
|
true => Some(Vec::<OVector<Complex<T>, D>>::with_capacity(
|
||||||
|
number_of_complex_entries,
|
||||||
|
)),
|
||||||
|
false => None,
|
||||||
|
};
|
||||||
|
let mut left_eigenvectors = match self.left_eigenvectors.is_some() {
|
||||||
|
true => Some(Vec::<OVector<Complex<T>, D>>::with_capacity(
|
||||||
|
number_of_complex_entries,
|
||||||
|
)),
|
||||||
|
false => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut c = 0;
|
||||||
|
while c < number_of_elements_value {
|
||||||
|
if self.eigenvalues_im[c] != T::zero() {
|
||||||
|
//Complex conjugate pairs of eigenvalues appear consecutively with the eigenvalue having the positive imaginary part first.
|
||||||
|
eigenvalues.push(Complex::<T>::new(
|
||||||
|
self.eigenvalues_re[c].clone(),
|
||||||
|
self.eigenvalues_im[c].clone(),
|
||||||
|
));
|
||||||
|
eigenvalues.push(Complex::<T>::new(
|
||||||
|
self.eigenvalues_re[c + 1].clone(),
|
||||||
|
self.eigenvalues_im[c + 1].clone(),
|
||||||
|
));
|
||||||
|
|
||||||
|
if eigenvectors.is_some() {
|
||||||
|
let mut vec = OVector::<Complex<T>, D>::zeros_generic(
|
||||||
|
number_of_elements,
|
||||||
|
Const::<1>,
|
||||||
|
);
|
||||||
|
let mut vec_conj = OVector::<Complex<T>, D>::zeros_generic(
|
||||||
|
number_of_elements,
|
||||||
|
Const::<1>,
|
||||||
|
);
|
||||||
|
|
||||||
|
for r in 0..number_of_elements_value {
|
||||||
|
vec[r] = Complex::<T>::new(
|
||||||
|
(&self.eigenvectors.as_ref()).unwrap()[(r, c)].clone(),
|
||||||
|
(&self.eigenvectors.as_ref()).unwrap()[(r, c + 1)].clone(),
|
||||||
|
);
|
||||||
|
vec_conj[r] = Complex::<T>::new(
|
||||||
|
(&self.eigenvectors.as_ref()).unwrap()[(r, c)].clone(),
|
||||||
|
(&self.eigenvectors.as_ref()).unwrap()[(r, c + 1)].clone(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
eigenvectors.as_mut().unwrap().push(vec);
|
||||||
|
eigenvectors.as_mut().unwrap().push(vec_conj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if left_eigenvectors.is_some() {
|
||||||
|
let mut vec = OVector::<Complex<T>, D>::zeros_generic(
|
||||||
|
number_of_elements,
|
||||||
|
Const::<1>,
|
||||||
|
);
|
||||||
|
let mut vec_conj = OVector::<Complex<T>, D>::zeros_generic(
|
||||||
|
number_of_elements,
|
||||||
|
Const::<1>,
|
||||||
|
);
|
||||||
|
|
||||||
|
for r in 0..number_of_elements_value {
|
||||||
|
vec[r] = Complex::<T>::new(
|
||||||
|
(&self.left_eigenvectors.as_ref()).unwrap()[(r, c)].clone(),
|
||||||
|
(&self.left_eigenvectors.as_ref()).unwrap()[(r, c + 1)].clone(),
|
||||||
|
);
|
||||||
|
vec_conj[r] = Complex::<T>::new(
|
||||||
|
(&self.left_eigenvectors.as_ref()).unwrap()[(r, c)].clone(),
|
||||||
|
(&self.left_eigenvectors.as_ref()).unwrap()[(r, c + 1)].clone(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
left_eigenvectors.as_mut().unwrap().push(vec);
|
||||||
|
left_eigenvectors.as_mut().unwrap().push(vec_conj);
|
||||||
|
}
|
||||||
|
//skip next entry
|
||||||
|
c += 1;
|
||||||
|
}
|
||||||
|
c += 1;
|
||||||
|
}
|
||||||
|
(Some(eigenvalues), left_eigenvectors, eigenvectors)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -126,7 +126,7 @@ where
|
||||||
|
|
||||||
let mut q = self
|
let mut q = self
|
||||||
.qr
|
.qr
|
||||||
.generic_slice((0, 0), (nrows, min_nrows_ncols))
|
.generic_view((0, 0), (nrows, min_nrows_ncols))
|
||||||
.into_owned();
|
.into_owned();
|
||||||
|
|
||||||
let mut info = 0;
|
let mut info = 0;
|
||||||
|
|
|
@ -157,7 +157,7 @@ macro_rules! svd_impl(
|
||||||
let mut res: OMatrix<_, R, C> = Matrix::zeros_generic(nrows, ncols);
|
let mut res: OMatrix<_, R, C> = Matrix::zeros_generic(nrows, ncols);
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut sres = res.generic_slice_mut((0, 0), (min_nrows_ncols, ncols));
|
let mut sres = res.generic_view_mut((0, 0), (min_nrows_ncols, ncols));
|
||||||
sres.copy_from(&self.vt.rows_generic(0, min_nrows_ncols));
|
sres.copy_from(&self.vt.rows_generic(0, min_nrows_ncols));
|
||||||
|
|
||||||
for i in 0 .. min_nrows_ncols.value() {
|
for i in 0 .. min_nrows_ncols.value() {
|
||||||
|
@ -183,7 +183,7 @@ macro_rules! svd_impl(
|
||||||
let mut res: OMatrix<_, C, R> = Matrix::zeros_generic(ncols, nrows);
|
let mut res: OMatrix<_, C, R> = Matrix::zeros_generic(ncols, nrows);
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut sres = res.generic_slice_mut((0, 0), (min_nrows_ncols, nrows));
|
let mut sres = res.generic_view_mut((0, 0), (min_nrows_ncols, nrows));
|
||||||
self.u.columns_generic(0, min_nrows_ncols).transpose_to(&mut sres);
|
self.u.columns_generic(0, min_nrows_ncols).transpose_to(&mut sres);
|
||||||
|
|
||||||
for i in 0 .. min_nrows_ncols.value() {
|
for i in 0 .. min_nrows_ncols.value() {
|
||||||
|
|
|
@ -58,8 +58,8 @@ proptest! {
|
||||||
let sol1 = chol.solve(&b1).unwrap();
|
let sol1 = chol.solve(&b1).unwrap();
|
||||||
let sol2 = chol.solve(&b2).unwrap();
|
let sol2 = chol.solve(&b2).unwrap();
|
||||||
|
|
||||||
prop_assert!(relative_eq!(m * sol1, b1, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(m * sol1, b1, epsilon = 1.0e-4));
|
||||||
prop_assert!(relative_eq!(m * sol2, b2, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(m * sol2, b2, epsilon = 1.0e-4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ proptest! {
|
||||||
let id1 = &m * &m1;
|
let id1 = &m * &m1;
|
||||||
let id2 = &m1 * &m;
|
let id2 = &m1 * &m;
|
||||||
|
|
||||||
prop_assert!(id1.is_identity(1.0e-5) && id2.is_identity(1.0e-5))
|
prop_assert!(id1.is_identity(1.0e-4) && id2.is_identity(1.0e-4))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
use na::Matrix3;
|
||||||
|
use nalgebra_lapack::Eigen;
|
||||||
|
use num_complex::Complex;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn complex_eigen() {
|
||||||
|
let m = Matrix3::<f64>::new(
|
||||||
|
4.0 / 5.0,
|
||||||
|
-3.0 / 5.0,
|
||||||
|
0.0,
|
||||||
|
3.0 / 5.0,
|
||||||
|
4.0 / 5.0,
|
||||||
|
0.0,
|
||||||
|
1.0,
|
||||||
|
2.0,
|
||||||
|
2.0,
|
||||||
|
);
|
||||||
|
let eigen = Eigen::new(m, true, true).expect("Eigen Creation Failed!");
|
||||||
|
let (some_eigenvalues, some_left_vec, some_right_vec) = eigen.get_complex_elements();
|
||||||
|
let eigenvalues = some_eigenvalues.expect("Eigenvalues Failed");
|
||||||
|
let _left_eigenvectors = some_left_vec.expect("Left Eigenvectors Failed");
|
||||||
|
let eigenvectors = some_right_vec.expect("Right Eigenvectors Failed");
|
||||||
|
|
||||||
|
assert_relative_eq!(
|
||||||
|
eigenvalues[0].re,
|
||||||
|
Complex::<f64>::new(4.0 / 5.0, 3.0 / 5.0).re
|
||||||
|
);
|
||||||
|
assert_relative_eq!(
|
||||||
|
eigenvalues[0].im,
|
||||||
|
Complex::<f64>::new(4.0 / 5.0, 3.0 / 5.0).im
|
||||||
|
);
|
||||||
|
assert_relative_eq!(
|
||||||
|
eigenvalues[1].re,
|
||||||
|
Complex::<f64>::new(4.0 / 5.0, -3.0 / 5.0).re
|
||||||
|
);
|
||||||
|
assert_relative_eq!(
|
||||||
|
eigenvalues[1].im,
|
||||||
|
Complex::<f64>::new(4.0 / 5.0, -3.0 / 5.0).im
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_relative_eq!(eigenvectors[0][0].re, -12.0 / 32.7871926215100059134410999);
|
||||||
|
assert_relative_eq!(eigenvectors[0][0].im, -9.0 / 32.7871926215100059134410999);
|
||||||
|
assert_relative_eq!(eigenvectors[0][1].re, -9.0 / 32.7871926215100059134410999);
|
||||||
|
assert_relative_eq!(eigenvectors[0][1].im, 12.0 / 32.7871926215100059134410999);
|
||||||
|
assert_relative_eq!(eigenvectors[0][2].re, 25.0 / 32.7871926215100059134410999);
|
||||||
|
assert_relative_eq!(eigenvectors[0][2].im, 0.0);
|
||||||
|
}
|
|
@ -51,10 +51,10 @@ proptest! {
|
||||||
let tr_sol1 = lup.solve_transpose(&b1).unwrap();
|
let tr_sol1 = lup.solve_transpose(&b1).unwrap();
|
||||||
let tr_sol2 = lup.solve_transpose(&b2).unwrap();
|
let tr_sol2 = lup.solve_transpose(&b2).unwrap();
|
||||||
|
|
||||||
prop_assert!(relative_eq!(&m * sol1, b1, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(&m * sol1, b1, epsilon = 1.0e-5));
|
||||||
prop_assert!(relative_eq!(&m * sol2, b2, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(&m * sol2, b2, epsilon = 1.0e-5));
|
||||||
prop_assert!(relative_eq!(m.transpose() * tr_sol1, b1, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(m.transpose() * tr_sol1, b1, epsilon = 1.0e-5));
|
||||||
prop_assert!(relative_eq!(m.transpose() * tr_sol2, b2, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(m.transpose() * tr_sol2, b2, epsilon = 1.0e-5));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -68,10 +68,10 @@ proptest! {
|
||||||
let tr_sol1 = lup.solve_transpose(&b1).unwrap();
|
let tr_sol1 = lup.solve_transpose(&b1).unwrap();
|
||||||
let tr_sol2 = lup.solve_transpose(&b2).unwrap();
|
let tr_sol2 = lup.solve_transpose(&b2).unwrap();
|
||||||
|
|
||||||
prop_assert!(relative_eq!(m * sol1, b1, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(m * sol1, b1, epsilon = 1.0e-5));
|
||||||
prop_assert!(relative_eq!(m * sol2, b2, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(m * sol2, b2, epsilon = 1.0e-5));
|
||||||
prop_assert!(relative_eq!(m.transpose() * tr_sol1, b1, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(m.transpose() * tr_sol1, b1, epsilon = 1.0e-5));
|
||||||
prop_assert!(relative_eq!(m.transpose() * tr_sol2, b2, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(m.transpose() * tr_sol2, b2, epsilon = 1.0e-5));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
mod cholesky;
|
mod cholesky;
|
||||||
|
mod complex_eigen;
|
||||||
mod generalized_eigenvalues;
|
mod generalized_eigenvalues;
|
||||||
mod lu;
|
mod lu;
|
||||||
mod qr;
|
mod qr;
|
||||||
|
|
|
@ -13,30 +13,36 @@ proptest! {
|
||||||
let m = DMatrix::<f64>::new_random(n, n);
|
let m = DMatrix::<f64>::new_random(n, n);
|
||||||
|
|
||||||
if let Some(eig) = Eigen::new(m.clone(), true, true) {
|
if let Some(eig) = Eigen::new(m.clone(), true, true) {
|
||||||
let eigvals = DMatrix::from_diagonal(&eig.eigenvalues);
|
// TODO: test the complex case too.
|
||||||
let transformed_eigvectors = &m * eig.eigenvectors.as_ref().unwrap();
|
if eig.eigenvalues_are_real() {
|
||||||
let scaled_eigvectors = eig.eigenvectors.as_ref().unwrap() * &eigvals;
|
let eigvals = DMatrix::from_diagonal(&eig.eigenvalues_re);
|
||||||
|
let transformed_eigvectors = &m * eig.eigenvectors.as_ref().unwrap();
|
||||||
|
let scaled_eigvectors = eig.eigenvectors.as_ref().unwrap() * &eigvals;
|
||||||
|
|
||||||
let transformed_left_eigvectors = m.transpose() * eig.left_eigenvectors.as_ref().unwrap();
|
let transformed_left_eigvectors = m.transpose() * eig.left_eigenvectors.as_ref().unwrap();
|
||||||
let scaled_left_eigvectors = eig.left_eigenvectors.as_ref().unwrap() * &eigvals;
|
let scaled_left_eigvectors = eig.left_eigenvectors.as_ref().unwrap() * &eigvals;
|
||||||
|
|
||||||
prop_assert!(relative_eq!(transformed_eigvectors, scaled_eigvectors, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(transformed_eigvectors, scaled_eigvectors, epsilon = 1.0e-5));
|
||||||
prop_assert!(relative_eq!(transformed_left_eigvectors, scaled_left_eigvectors, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(transformed_left_eigvectors, scaled_left_eigvectors, epsilon = 1.0e-5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn eigensystem_static(m in matrix4()) {
|
fn eigensystem_static(m in matrix4()) {
|
||||||
if let Some(eig) = Eigen::new(m, true, true) {
|
if let Some(eig) = Eigen::new(m, true, true) {
|
||||||
let eigvals = Matrix4::from_diagonal(&eig.eigenvalues);
|
// TODO: test the complex case too.
|
||||||
let transformed_eigvectors = m * eig.eigenvectors.unwrap();
|
if eig.eigenvalues_are_real() {
|
||||||
let scaled_eigvectors = eig.eigenvectors.unwrap() * eigvals;
|
let eigvals = Matrix4::from_diagonal(&eig.eigenvalues_re);
|
||||||
|
let transformed_eigvectors = m * eig.eigenvectors.unwrap();
|
||||||
|
let scaled_eigvectors = eig.eigenvectors.unwrap() * eigvals;
|
||||||
|
|
||||||
let transformed_left_eigvectors = m.transpose() * eig.left_eigenvectors.unwrap();
|
let transformed_left_eigvectors = m.transpose() * eig.left_eigenvectors.unwrap();
|
||||||
let scaled_left_eigvectors = eig.left_eigenvectors.unwrap() * eigvals;
|
let scaled_left_eigvectors = eig.left_eigenvectors.unwrap() * eigvals;
|
||||||
|
|
||||||
prop_assert!(relative_eq!(transformed_eigvectors, scaled_eigvectors, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(transformed_eigvectors, scaled_eigvectors, epsilon = 1.0e-5));
|
||||||
prop_assert!(relative_eq!(transformed_left_eigvectors, scaled_left_eigvectors, epsilon = 1.0e-7));
|
prop_assert!(relative_eq!(transformed_left_eigvectors, scaled_left_eigvectors, epsilon = 1.0e-5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,14 +11,17 @@ proptest! {
|
||||||
let n = cmp::max(1, cmp::min(n, 10));
|
let n = cmp::max(1, cmp::min(n, 10));
|
||||||
let m = DMatrix::<f64>::new_random(n, n);
|
let m = DMatrix::<f64>::new_random(n, n);
|
||||||
|
|
||||||
let (vecs, vals) = Schur::new(m.clone()).unpack();
|
if let Some(schur) = Schur::try_new(m.clone()) {
|
||||||
|
let (vecs, vals) = schur.unpack();
|
||||||
prop_assert!(relative_eq!(&vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7))
|
prop_assert!(relative_eq!(&vecs * vals * vecs.transpose(), m, epsilon = 1.0e-5))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn schur_static(m in matrix4()) {
|
fn schur_static(m in matrix4()) {
|
||||||
let (vecs, vals) = Schur::new(m.clone()).unpack();
|
if let Some(schur) = Schur::try_new(m.clone()) {
|
||||||
prop_assert!(relative_eq!(vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7))
|
let (vecs, vals) = schur.unpack();
|
||||||
|
prop_assert!(relative_eq!(vecs * vals * vecs.transpose(), m, epsilon = 1.0e-5))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,5 +21,5 @@ quote = "1.0"
|
||||||
proc-macro2 = "1.0"
|
proc-macro2 = "1.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
nalgebra = { version = "0.31.0", path = ".." }
|
nalgebra = { version = "0.32.0", path = ".." }
|
||||||
trybuild = "1.0.42"
|
trybuild = "1.0.42"
|
||||||
|
|
|
@ -191,8 +191,8 @@ pub fn dmatrix(stream: TokenStream) -> TokenStream {
|
||||||
let output = quote! {
|
let output = quote! {
|
||||||
nalgebra::DMatrix::<_>
|
nalgebra::DMatrix::<_>
|
||||||
::from_vec_storage(nalgebra::VecStorage::new(
|
::from_vec_storage(nalgebra::VecStorage::new(
|
||||||
nalgebra::Dynamic::new(#row_dim),
|
nalgebra::Dyn(#row_dim),
|
||||||
nalgebra::Dynamic::new(#col_dim),
|
nalgebra::Dyn(#col_dim),
|
||||||
vec!#array_tokens))
|
vec!#array_tokens))
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ pub fn dvector(stream: TokenStream) -> TokenStream {
|
||||||
let output = quote! {
|
let output = quote! {
|
||||||
nalgebra::DVector::<_>
|
nalgebra::DVector::<_>
|
||||||
::from_vec_storage(nalgebra::VecStorage::new(
|
::from_vec_storage(nalgebra::VecStorage::new(
|
||||||
nalgebra::Dynamic::new(#len),
|
nalgebra::Dyn(#len),
|
||||||
nalgebra::Const::<1>,
|
nalgebra::Const::<1>,
|
||||||
vec!#array_tokens))
|
vec!#array_tokens))
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "nalgebra-sparse"
|
name = "nalgebra-sparse"
|
||||||
version = "0.7.1"
|
version = "0.9.0"
|
||||||
authors = [ "Andreas Longva", "Sébastien Crozet <developer@crozet.re>" ]
|
authors = [ "Andreas Longva", "Sébastien Crozet <developer@crozet.re>" ]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "Sparse matrix computation based on nalgebra."
|
description = "Sparse matrix computation based on nalgebra."
|
||||||
|
@ -24,7 +24,7 @@ io = [ "pest", "pest_derive" ]
|
||||||
slow-tests = []
|
slow-tests = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nalgebra = { version="0.31", path = "../" }
|
nalgebra = { version="0.32", path = "../" }
|
||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
proptest = { version = "1.0", optional = true }
|
proptest = { version = "1.0", optional = true }
|
||||||
matrixcompare-core = { version = "0.1.0", optional = true }
|
matrixcompare-core = { version = "0.1.0", optional = true }
|
||||||
|
@ -35,7 +35,7 @@ serde = { version = "1.0", default-features = false, features = [ "derive" ], op
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
itertools = "0.10"
|
itertools = "0.10"
|
||||||
matrixcompare = { version = "0.3.0", features = [ "proptest-support" ] }
|
matrixcompare = { version = "0.3.0", features = [ "proptest-support" ] }
|
||||||
nalgebra = { version="0.31", path = "../", features = ["compare"] }
|
nalgebra = { version="0.32", path = "../", features = ["compare"] }
|
||||||
tempfile = "3.3"
|
tempfile = "3.3"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,16 @@ impl<T> CooMatrix<T> {
|
||||||
.map(|((i, j), v)| (*i, *j, v))
|
.map(|((i, j), v)| (*i, *j, v))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// A mutable iterator over triplets (i, j, v).
|
||||||
|
// TODO: Consider giving the iterator a concrete type instead of impl trait...?
|
||||||
|
pub fn triplet_iter_mut(&mut self) -> impl Iterator<Item = (usize, usize, &mut T)> {
|
||||||
|
self.row_indices
|
||||||
|
.iter()
|
||||||
|
.zip(&self.col_indices)
|
||||||
|
.zip(self.values.iter_mut())
|
||||||
|
.map(|((i, j), v)| (*i, *j, v))
|
||||||
|
}
|
||||||
|
|
||||||
/// Reserves capacity for COO matrix by at least `additional` elements.
|
/// Reserves capacity for COO matrix by at least `additional` elements.
|
||||||
///
|
///
|
||||||
/// This increase the capacities of triplet holding arrays by reserving more space to avoid
|
/// This increase the capacities of triplet holding arrays by reserving more space to avoid
|
||||||
|
|
|
@ -24,6 +24,7 @@ use std::slice::{Iter, IterMut};
|
||||||
/// # Usage
|
/// # Usage
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// use nalgebra_sparse::coo::CooMatrix;
|
||||||
/// use nalgebra_sparse::csc::CscMatrix;
|
/// use nalgebra_sparse::csc::CscMatrix;
|
||||||
/// use nalgebra::{DMatrix, Matrix3x4};
|
/// use nalgebra::{DMatrix, Matrix3x4};
|
||||||
/// use matrixcompare::assert_matrix_eq;
|
/// use matrixcompare::assert_matrix_eq;
|
||||||
|
@ -32,8 +33,9 @@ use std::slice::{Iter, IterMut};
|
||||||
/// // change the sparsity pattern of the matrix after it has been constructed. The easiest
|
/// // change the sparsity pattern of the matrix after it has been constructed. The easiest
|
||||||
/// // way to construct a CSC matrix is to first incrementally construct a COO matrix,
|
/// // way to construct a CSC matrix is to first incrementally construct a COO matrix,
|
||||||
/// // and then convert it to CSC.
|
/// // and then convert it to CSC.
|
||||||
/// # use nalgebra_sparse::coo::CooMatrix;
|
///
|
||||||
/// # let coo = CooMatrix::<f64>::new(3, 3);
|
/// let mut coo = CooMatrix::<f64>::new(3, 3);
|
||||||
|
/// coo.push(2, 0, 1.0);
|
||||||
/// let csc = CscMatrix::from(&coo);
|
/// let csc = CscMatrix::from(&coo);
|
||||||
///
|
///
|
||||||
/// // Alternatively, a CSC matrix can be constructed directly from raw CSC data.
|
/// // Alternatively, a CSC matrix can be constructed directly from raw CSC data.
|
||||||
|
|
|
@ -25,6 +25,7 @@ use std::slice::{Iter, IterMut};
|
||||||
/// # Usage
|
/// # Usage
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
|
/// use nalgebra_sparse::coo::CooMatrix;
|
||||||
/// use nalgebra_sparse::csr::CsrMatrix;
|
/// use nalgebra_sparse::csr::CsrMatrix;
|
||||||
/// use nalgebra::{DMatrix, Matrix3x4};
|
/// use nalgebra::{DMatrix, Matrix3x4};
|
||||||
/// use matrixcompare::assert_matrix_eq;
|
/// use matrixcompare::assert_matrix_eq;
|
||||||
|
@ -33,8 +34,9 @@ use std::slice::{Iter, IterMut};
|
||||||
/// // change the sparsity pattern of the matrix after it has been constructed. The easiest
|
/// // change the sparsity pattern of the matrix after it has been constructed. The easiest
|
||||||
/// // way to construct a CSR matrix is to first incrementally construct a COO matrix,
|
/// // way to construct a CSR matrix is to first incrementally construct a COO matrix,
|
||||||
/// // and then convert it to CSR.
|
/// // and then convert it to CSR.
|
||||||
/// # use nalgebra_sparse::coo::CooMatrix;
|
///
|
||||||
/// # let coo = CooMatrix::<f64>::new(3, 3);
|
/// let mut coo = CooMatrix::<f64>::new(3, 3);
|
||||||
|
/// coo.push(2, 0, 1.0);
|
||||||
/// let csr = CsrMatrix::from(&coo);
|
/// let csr = CsrMatrix::from(&coo);
|
||||||
///
|
///
|
||||||
/// // Alternatively, a CSR matrix can be constructed directly from raw CSR data.
|
/// // Alternatively, a CSR matrix can be constructed directly from raw CSR data.
|
||||||
|
|
|
@ -3,7 +3,7 @@ use crate::ops::serial::spsolve_csc_lower_triangular;
|
||||||
use crate::ops::Op;
|
use crate::ops::Op;
|
||||||
use crate::pattern::SparsityPattern;
|
use crate::pattern::SparsityPattern;
|
||||||
use core::{iter, mem};
|
use core::{iter, mem};
|
||||||
use nalgebra::{DMatrix, DMatrixSlice, DMatrixSliceMut, RealField};
|
use nalgebra::{DMatrix, DMatrixView, DMatrixViewMut, RealField};
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
|
|
||||||
/// A symbolic sparse Cholesky factorization of a CSC matrix.
|
/// A symbolic sparse Cholesky factorization of a CSC matrix.
|
||||||
|
@ -264,7 +264,7 @@ impl<T: RealField> CscCholesky<T> {
|
||||||
///
|
///
|
||||||
/// Panics if `B` is not square.
|
/// Panics if `B` is not square.
|
||||||
#[must_use = "Did you mean to use solve_mut()?"]
|
#[must_use = "Did you mean to use solve_mut()?"]
|
||||||
pub fn solve<'a>(&'a self, b: impl Into<DMatrixSlice<'a, T>>) -> DMatrix<T> {
|
pub fn solve<'a>(&'a self, b: impl Into<DMatrixView<'a, T>>) -> DMatrix<T> {
|
||||||
let b = b.into();
|
let b = b.into();
|
||||||
let mut output = b.clone_owned();
|
let mut output = b.clone_owned();
|
||||||
self.solve_mut(&mut output);
|
self.solve_mut(&mut output);
|
||||||
|
@ -278,7 +278,7 @@ impl<T: RealField> CscCholesky<T> {
|
||||||
/// # Panics
|
/// # Panics
|
||||||
///
|
///
|
||||||
/// Panics if `b` is not square.
|
/// Panics if `b` is not square.
|
||||||
pub fn solve_mut<'a>(&'a self, b: impl Into<DMatrixSliceMut<'a, T>>) {
|
pub fn solve_mut<'a>(&'a self, b: impl Into<DMatrixViewMut<'a, T>>) {
|
||||||
let expect_msg = "If the Cholesky factorization succeeded,\
|
let expect_msg = "If the Cholesky factorization succeeded,\
|
||||||
then the triangular solve should never fail";
|
then the triangular solve should never fail";
|
||||||
// Solve LY = B
|
// Solve LY = B
|
||||||
|
|
|
@ -10,7 +10,7 @@ use nalgebra::allocator::Allocator;
|
||||||
use nalgebra::base::storage::RawStorage;
|
use nalgebra::base::storage::RawStorage;
|
||||||
use nalgebra::constraint::{DimEq, ShapeConstraint};
|
use nalgebra::constraint::{DimEq, ShapeConstraint};
|
||||||
use nalgebra::{
|
use nalgebra::{
|
||||||
ClosedAdd, ClosedDiv, ClosedMul, ClosedSub, DefaultAllocator, Dim, Dynamic, Matrix, OMatrix,
|
ClosedAdd, ClosedDiv, ClosedMul, ClosedSub, DefaultAllocator, Dim, Dyn, Matrix, OMatrix,
|
||||||
Scalar, U1,
|
Scalar, U1,
|
||||||
};
|
};
|
||||||
use num_traits::{One, Zero};
|
use num_traits::{One, Zero};
|
||||||
|
@ -273,8 +273,8 @@ macro_rules! impl_spmm_cs_dense {
|
||||||
// Implement ref-ref
|
// Implement ref-ref
|
||||||
impl_spmm_cs_dense!(&'a $matrix_type_name<T>, &'a Matrix<T, R, C, S>, $spmm_fn, |lhs, rhs| {
|
impl_spmm_cs_dense!(&'a $matrix_type_name<T>, &'a Matrix<T, R, C, S>, $spmm_fn, |lhs, rhs| {
|
||||||
let (_, ncols) = rhs.shape_generic();
|
let (_, ncols) = rhs.shape_generic();
|
||||||
let nrows = Dynamic::new(lhs.nrows());
|
let nrows = Dyn(lhs.nrows());
|
||||||
let mut result = OMatrix::<T, Dynamic, C>::zeros_generic(nrows, ncols);
|
let mut result = OMatrix::<T, Dyn, C>::zeros_generic(nrows, ncols);
|
||||||
$spmm_fn(T::zero(), &mut result, T::one(), Op::NoOp(lhs), Op::NoOp(rhs));
|
$spmm_fn(T::zero(), &mut result, T::one(), Op::NoOp(lhs), Op::NoOp(rhs));
|
||||||
result
|
result
|
||||||
});
|
});
|
||||||
|
@ -302,21 +302,21 @@ macro_rules! impl_spmm_cs_dense {
|
||||||
R: Dim,
|
R: Dim,
|
||||||
C: Dim,
|
C: Dim,
|
||||||
S: RawStorage<T, R, C>,
|
S: RawStorage<T, R, C>,
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C>,
|
DefaultAllocator: Allocator<T, Dyn, C>,
|
||||||
// TODO: Is it possible to simplify these bounds?
|
// TODO: Is it possible to simplify these bounds?
|
||||||
ShapeConstraint:
|
ShapeConstraint:
|
||||||
// Bounds so that we can turn OMatrix<T, Dynamic, C> into a DMatrixSliceMut
|
// Bounds so that we can turn OMatrix<T, Dyn, C> into a DMatrixSliceMut
|
||||||
DimEq<U1, <<DefaultAllocator as Allocator<T, Dynamic, C>>::Buffer as RawStorage<T, Dynamic, C>>::RStride>
|
DimEq<U1, <<DefaultAllocator as Allocator<T, Dyn, C>>::Buffer as RawStorage<T, Dyn, C>>::RStride>
|
||||||
+ DimEq<C, Dynamic>
|
+ DimEq<C, Dyn>
|
||||||
+ DimEq<Dynamic, <<DefaultAllocator as Allocator<T, Dynamic, C>>::Buffer as RawStorage<T, Dynamic, C>>::CStride>
|
+ DimEq<Dyn, <<DefaultAllocator as Allocator<T, Dyn, C>>::Buffer as RawStorage<T, Dyn, C>>::CStride>
|
||||||
// Bounds so that we can turn &Matrix<T, R, C, S> into a DMatrixSlice
|
// Bounds so that we can turn &Matrix<T, R, C, S> into a DMatrixSlice
|
||||||
+ DimEq<U1, S::RStride>
|
+ DimEq<U1, S::RStride>
|
||||||
+ DimEq<R, Dynamic>
|
+ DimEq<R, Dyn>
|
||||||
+ DimEq<Dynamic, S::CStride>
|
+ DimEq<Dyn, S::CStride>
|
||||||
{
|
{
|
||||||
// We need the column dimension to be generic, so that if RHS is a vector, then
|
// We need the column dimension to be generic, so that if RHS is a vector, then
|
||||||
// we also get a vector (and not a matrix)
|
// we also get a vector (and not a matrix)
|
||||||
type Output = OMatrix<T, Dynamic, C>;
|
type Output = OMatrix<T, Dyn, C>;
|
||||||
|
|
||||||
fn mul(self, rhs: $dense_matrix_type) -> Self::Output {
|
fn mul(self, rhs: $dense_matrix_type) -> Self::Output {
|
||||||
let $lhs = self;
|
let $lhs = self;
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::cs::CsMatrix;
|
||||||
use crate::ops::serial::{OperationError, OperationErrorKind};
|
use crate::ops::serial::{OperationError, OperationErrorKind};
|
||||||
use crate::ops::Op;
|
use crate::ops::Op;
|
||||||
use crate::SparseEntryMut;
|
use crate::SparseEntryMut;
|
||||||
use nalgebra::{ClosedAdd, ClosedMul, DMatrixSlice, DMatrixSliceMut, Scalar};
|
use nalgebra::{ClosedAdd, ClosedMul, DMatrixView, DMatrixViewMut, Scalar};
|
||||||
use num_traits::{One, Zero};
|
use num_traits::{One, Zero};
|
||||||
|
|
||||||
fn spmm_cs_unexpected_entry() -> OperationError {
|
fn spmm_cs_unexpected_entry() -> OperationError {
|
||||||
|
@ -176,10 +176,10 @@ where
|
||||||
/// the transposed operation must be specified for the CSC matrix.
|
/// the transposed operation must be specified for the CSC matrix.
|
||||||
pub fn spmm_cs_dense<T>(
|
pub fn spmm_cs_dense<T>(
|
||||||
beta: T,
|
beta: T,
|
||||||
mut c: DMatrixSliceMut<'_, T>,
|
mut c: DMatrixViewMut<'_, T>,
|
||||||
alpha: T,
|
alpha: T,
|
||||||
a: Op<&CsMatrix<T>>,
|
a: Op<&CsMatrix<T>>,
|
||||||
b: Op<DMatrixSlice<'_, T>>,
|
b: Op<DMatrixView<'_, T>>,
|
||||||
) where
|
) where
|
||||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::ops::serial::cs::{
|
||||||
};
|
};
|
||||||
use crate::ops::serial::{OperationError, OperationErrorKind};
|
use crate::ops::serial::{OperationError, OperationErrorKind};
|
||||||
use crate::ops::Op;
|
use crate::ops::Op;
|
||||||
use nalgebra::{ClosedAdd, ClosedMul, DMatrixSlice, DMatrixSliceMut, RealField, Scalar};
|
use nalgebra::{ClosedAdd, ClosedMul, DMatrixView, DMatrixViewMut, RealField, Scalar};
|
||||||
use num_traits::{One, Zero};
|
use num_traits::{One, Zero};
|
||||||
|
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
@ -16,10 +16,10 @@ use std::borrow::Cow;
|
||||||
/// Panics if the dimensions of the matrices involved are not compatible with the expression.
|
/// Panics if the dimensions of the matrices involved are not compatible with the expression.
|
||||||
pub fn spmm_csc_dense<'a, T>(
|
pub fn spmm_csc_dense<'a, T>(
|
||||||
beta: T,
|
beta: T,
|
||||||
c: impl Into<DMatrixSliceMut<'a, T>>,
|
c: impl Into<DMatrixViewMut<'a, T>>,
|
||||||
alpha: T,
|
alpha: T,
|
||||||
a: Op<&CscMatrix<T>>,
|
a: Op<&CscMatrix<T>>,
|
||||||
b: Op<impl Into<DMatrixSlice<'a, T>>>,
|
b: Op<impl Into<DMatrixView<'a, T>>>,
|
||||||
) where
|
) where
|
||||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||||
{
|
{
|
||||||
|
@ -29,10 +29,10 @@ pub fn spmm_csc_dense<'a, T>(
|
||||||
|
|
||||||
fn spmm_csc_dense_<T>(
|
fn spmm_csc_dense_<T>(
|
||||||
beta: T,
|
beta: T,
|
||||||
c: DMatrixSliceMut<'_, T>,
|
c: DMatrixViewMut<'_, T>,
|
||||||
alpha: T,
|
alpha: T,
|
||||||
a: Op<&CscMatrix<T>>,
|
a: Op<&CscMatrix<T>>,
|
||||||
b: Op<DMatrixSlice<'_, T>>,
|
b: Op<DMatrixView<'_, T>>,
|
||||||
) where
|
) where
|
||||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ where
|
||||||
/// Panics if `L` is not square, or if `L` and `B` are not dimensionally compatible.
|
/// Panics if `L` is not square, or if `L` and `B` are not dimensionally compatible.
|
||||||
pub fn spsolve_csc_lower_triangular<'a, T: RealField>(
|
pub fn spsolve_csc_lower_triangular<'a, T: RealField>(
|
||||||
l: Op<&CscMatrix<T>>,
|
l: Op<&CscMatrix<T>>,
|
||||||
b: impl Into<DMatrixSliceMut<'a, T>>,
|
b: impl Into<DMatrixViewMut<'a, T>>,
|
||||||
) -> Result<(), OperationError> {
|
) -> Result<(), OperationError> {
|
||||||
let b = b.into();
|
let b = b.into();
|
||||||
let l_matrix = l.into_inner();
|
let l_matrix = l.into_inner();
|
||||||
|
@ -195,7 +195,7 @@ pub fn spsolve_csc_lower_triangular<'a, T: RealField>(
|
||||||
|
|
||||||
fn spsolve_csc_lower_triangular_no_transpose<T: RealField>(
|
fn spsolve_csc_lower_triangular_no_transpose<T: RealField>(
|
||||||
l: &CscMatrix<T>,
|
l: &CscMatrix<T>,
|
||||||
b: DMatrixSliceMut<'_, T>,
|
b: DMatrixViewMut<'_, T>,
|
||||||
) -> Result<(), OperationError> {
|
) -> Result<(), OperationError> {
|
||||||
let mut x = b;
|
let mut x = b;
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ fn spsolve_encountered_zero_diagonal() -> Result<(), OperationError> {
|
||||||
|
|
||||||
fn spsolve_csc_lower_triangular_transpose<T: RealField>(
|
fn spsolve_csc_lower_triangular_transpose<T: RealField>(
|
||||||
l: &CscMatrix<T>,
|
l: &CscMatrix<T>,
|
||||||
b: DMatrixSliceMut<'_, T>,
|
b: DMatrixViewMut<'_, T>,
|
||||||
) -> Result<(), OperationError> {
|
) -> Result<(), OperationError> {
|
||||||
let mut x = b;
|
let mut x = b;
|
||||||
|
|
||||||
|
|
|
@ -4,17 +4,17 @@ use crate::ops::serial::cs::{
|
||||||
};
|
};
|
||||||
use crate::ops::serial::OperationError;
|
use crate::ops::serial::OperationError;
|
||||||
use crate::ops::Op;
|
use crate::ops::Op;
|
||||||
use nalgebra::{ClosedAdd, ClosedMul, DMatrixSlice, DMatrixSliceMut, Scalar};
|
use nalgebra::{ClosedAdd, ClosedMul, DMatrixView, DMatrixViewMut, Scalar};
|
||||||
use num_traits::{One, Zero};
|
use num_traits::{One, Zero};
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
/// Sparse-dense matrix-matrix multiplication `C <- beta * C + alpha * op(A) * op(B)`.
|
/// Sparse-dense matrix-matrix multiplication `C <- beta * C + alpha * op(A) * op(B)`.
|
||||||
pub fn spmm_csr_dense<'a, T>(
|
pub fn spmm_csr_dense<'a, T>(
|
||||||
beta: T,
|
beta: T,
|
||||||
c: impl Into<DMatrixSliceMut<'a, T>>,
|
c: impl Into<DMatrixViewMut<'a, T>>,
|
||||||
alpha: T,
|
alpha: T,
|
||||||
a: Op<&CsrMatrix<T>>,
|
a: Op<&CsrMatrix<T>>,
|
||||||
b: Op<impl Into<DMatrixSlice<'a, T>>>,
|
b: Op<impl Into<DMatrixView<'a, T>>>,
|
||||||
) where
|
) where
|
||||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||||
{
|
{
|
||||||
|
@ -24,10 +24,10 @@ pub fn spmm_csr_dense<'a, T>(
|
||||||
|
|
||||||
fn spmm_csr_dense_<T>(
|
fn spmm_csr_dense_<T>(
|
||||||
beta: T,
|
beta: T,
|
||||||
c: DMatrixSliceMut<'_, T>,
|
c: DMatrixViewMut<'_, T>,
|
||||||
alpha: T,
|
alpha: T,
|
||||||
a: Op<&CsrMatrix<T>>,
|
a: Op<&CsrMatrix<T>>,
|
||||||
b: Op<DMatrixSlice<'_, T>>,
|
b: Op<DMatrixView<'_, T>>,
|
||||||
) where
|
) where
|
||||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||||
{
|
{
|
||||||
|
|
|
@ -87,6 +87,40 @@ fn coo_construction_for_valid_data() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn coo_triplets_iter_mut() {
|
||||||
|
// Arbitrary matrix, with duplicates
|
||||||
|
let i = vec![0, 1, 0, 0, 0, 0, 2, 1];
|
||||||
|
let j = vec![0, 2, 0, 1, 0, 3, 3, 2];
|
||||||
|
let v = vec![2, 3, 4, 7, 1, 3, 1, 5];
|
||||||
|
let mut coo =
|
||||||
|
CooMatrix::<i32>::try_from_triplets(3, 5, i.clone(), j.clone(), v.clone()).unwrap();
|
||||||
|
|
||||||
|
let actual_triplets: Vec<_> = coo.triplet_iter_mut().map(|(i, j, v)| (i, j, *v)).collect();
|
||||||
|
|
||||||
|
let expected_triplets: Vec<_> = i
|
||||||
|
.iter()
|
||||||
|
.zip(&j)
|
||||||
|
.zip(&v)
|
||||||
|
.map(|((i, j), v)| (*i, *j, *v))
|
||||||
|
.collect();
|
||||||
|
assert_eq!(expected_triplets, actual_triplets);
|
||||||
|
|
||||||
|
for (_i, _j, v) in coo.triplet_iter_mut() {
|
||||||
|
*v += *v;
|
||||||
|
}
|
||||||
|
|
||||||
|
let actual_triplets: Vec<_> = coo.triplet_iter_mut().map(|(i, j, v)| (i, j, *v)).collect();
|
||||||
|
let v = vec![4, 6, 8, 14, 2, 6, 2, 10];
|
||||||
|
let expected_triplets: Vec<_> = i
|
||||||
|
.iter()
|
||||||
|
.zip(&j)
|
||||||
|
.zip(&v)
|
||||||
|
.map(|((i, j), v)| (*i, *j, *v))
|
||||||
|
.collect();
|
||||||
|
assert_eq!(expected_triplets, actual_triplets);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn coo_try_from_triplets_reports_out_of_bounds_indices() {
|
fn coo_try_from_triplets_reports_out_of_bounds_indices() {
|
||||||
{
|
{
|
||||||
|
@ -314,8 +348,8 @@ fn coo_push_matrix_valid_entries() {
|
||||||
// Works with sliced
|
// Works with sliced
|
||||||
{
|
{
|
||||||
let source = nalgebra::SMatrix::<i32, 2, 2>::new(6, 7, 8, 9);
|
let source = nalgebra::SMatrix::<i32, 2, 2>::new(6, 7, 8, 9);
|
||||||
let sliced = source.fixed_slice::<2, 1>(0, 0);
|
let view = source.fixed_view::<2, 1>(0, 0);
|
||||||
coo.push_matrix(1, 0, &sliced);
|
coo.push_matrix(1, 0, &view);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
coo.triplet_iter().collect::<Vec<_>>(),
|
coo.triplet_iter().collect::<Vec<_>>(),
|
||||||
|
|
|
@ -14,7 +14,7 @@ use nalgebra_sparse::pattern::SparsityPattern;
|
||||||
use nalgebra_sparse::proptest::{csc, csr, sparsity_pattern};
|
use nalgebra_sparse::proptest::{csc, csr, sparsity_pattern};
|
||||||
|
|
||||||
use nalgebra::proptest::{matrix, vector};
|
use nalgebra::proptest::{matrix, vector};
|
||||||
use nalgebra::{DMatrix, DMatrixSlice, DMatrixSliceMut, Scalar};
|
use nalgebra::{DMatrix, DMatrixView, DMatrixViewMut, Scalar};
|
||||||
|
|
||||||
use proptest::prelude::*;
|
use proptest::prelude::*;
|
||||||
|
|
||||||
|
@ -333,10 +333,10 @@ fn csc_square_with_non_zero_diagonals() -> impl Strategy<Value = CscMatrix<f64>>
|
||||||
/// Helper function to help us call dense GEMM with our `Op` type
|
/// Helper function to help us call dense GEMM with our `Op` type
|
||||||
fn dense_gemm<'a>(
|
fn dense_gemm<'a>(
|
||||||
beta: i32,
|
beta: i32,
|
||||||
c: impl Into<DMatrixSliceMut<'a, i32>>,
|
c: impl Into<DMatrixViewMut<'a, i32>>,
|
||||||
alpha: i32,
|
alpha: i32,
|
||||||
a: Op<impl Into<DMatrixSlice<'a, i32>>>,
|
a: Op<impl Into<DMatrixView<'a, i32>>>,
|
||||||
b: Op<impl Into<DMatrixSlice<'a, i32>>>,
|
b: Op<impl Into<DMatrixView<'a, i32>>>,
|
||||||
) {
|
) {
|
||||||
let mut c = c.into();
|
let mut c = c.into();
|
||||||
let a = a.convert();
|
let a = a.convert();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
use crate::base::dimension::Dynamic;
|
use crate::base::dimension::Dyn;
|
||||||
use crate::base::dimension::{U1, U2, U3, U4, U5, U6};
|
use crate::base::dimension::{U1, U2, U3, U4, U5, U6};
|
||||||
use crate::base::storage::Owned;
|
use crate::base::storage::Owned;
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
@ -48,69 +48,69 @@ pub type SMatrix<T, const R: usize, const C: usize> =
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type DMatrix<T> = Matrix<T, Dynamic, Dynamic, VecStorage<T, Dynamic, Dynamic>>;
|
pub type DMatrix<T> = Matrix<T, Dyn, Dyn, VecStorage<T, Dyn, Dyn>>;
|
||||||
|
|
||||||
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 1 columns.
|
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 1 columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type MatrixXx1<T> = Matrix<T, Dynamic, U1, VecStorage<T, Dynamic, U1>>;
|
pub type MatrixXx1<T> = Matrix<T, Dyn, U1, VecStorage<T, Dyn, U1>>;
|
||||||
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 2 columns.
|
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 2 columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type MatrixXx2<T> = Matrix<T, Dynamic, U2, VecStorage<T, Dynamic, U2>>;
|
pub type MatrixXx2<T> = Matrix<T, Dyn, U2, VecStorage<T, Dyn, U2>>;
|
||||||
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 3 columns.
|
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 3 columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type MatrixXx3<T> = Matrix<T, Dynamic, U3, VecStorage<T, Dynamic, U3>>;
|
pub type MatrixXx3<T> = Matrix<T, Dyn, U3, VecStorage<T, Dyn, U3>>;
|
||||||
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 4 columns.
|
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 4 columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type MatrixXx4<T> = Matrix<T, Dynamic, U4, VecStorage<T, Dynamic, U4>>;
|
pub type MatrixXx4<T> = Matrix<T, Dyn, U4, VecStorage<T, Dyn, U4>>;
|
||||||
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 5 columns.
|
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 5 columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type MatrixXx5<T> = Matrix<T, Dynamic, U5, VecStorage<T, Dynamic, U5>>;
|
pub type MatrixXx5<T> = Matrix<T, Dyn, U5, VecStorage<T, Dyn, U5>>;
|
||||||
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 6 columns.
|
/// A heap-allocated, column-major, matrix with a dynamic number of rows and 6 columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type MatrixXx6<T> = Matrix<T, Dynamic, U6, VecStorage<T, Dynamic, U6>>;
|
pub type MatrixXx6<T> = Matrix<T, Dyn, U6, VecStorage<T, Dyn, U6>>;
|
||||||
|
|
||||||
/// A heap-allocated, row-major, matrix with 1 rows and a dynamic number of columns.
|
/// A heap-allocated, row-major, matrix with 1 rows and a dynamic number of columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type Matrix1xX<T> = Matrix<T, U1, Dynamic, VecStorage<T, U1, Dynamic>>;
|
pub type Matrix1xX<T> = Matrix<T, U1, Dyn, VecStorage<T, U1, Dyn>>;
|
||||||
/// A heap-allocated, row-major, matrix with 2 rows and a dynamic number of columns.
|
/// A heap-allocated, row-major, matrix with 2 rows and a dynamic number of columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type Matrix2xX<T> = Matrix<T, U2, Dynamic, VecStorage<T, U2, Dynamic>>;
|
pub type Matrix2xX<T> = Matrix<T, U2, Dyn, VecStorage<T, U2, Dyn>>;
|
||||||
/// A heap-allocated, row-major, matrix with 3 rows and a dynamic number of columns.
|
/// A heap-allocated, row-major, matrix with 3 rows and a dynamic number of columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type Matrix3xX<T> = Matrix<T, U3, Dynamic, VecStorage<T, U3, Dynamic>>;
|
pub type Matrix3xX<T> = Matrix<T, U3, Dyn, VecStorage<T, U3, Dyn>>;
|
||||||
/// A heap-allocated, row-major, matrix with 4 rows and a dynamic number of columns.
|
/// A heap-allocated, row-major, matrix with 4 rows and a dynamic number of columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type Matrix4xX<T> = Matrix<T, U4, Dynamic, VecStorage<T, U4, Dynamic>>;
|
pub type Matrix4xX<T> = Matrix<T, U4, Dyn, VecStorage<T, U4, Dyn>>;
|
||||||
/// A heap-allocated, row-major, matrix with 5 rows and a dynamic number of columns.
|
/// A heap-allocated, row-major, matrix with 5 rows and a dynamic number of columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type Matrix5xX<T> = Matrix<T, U5, Dynamic, VecStorage<T, U5, Dynamic>>;
|
pub type Matrix5xX<T> = Matrix<T, U5, Dyn, VecStorage<T, U5, Dyn>>;
|
||||||
/// A heap-allocated, row-major, matrix with 6 rows and a dynamic number of columns.
|
/// A heap-allocated, row-major, matrix with 6 rows and a dynamic number of columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type Matrix6xX<T> = Matrix<T, U6, Dynamic, VecStorage<T, U6, Dynamic>>;
|
pub type Matrix6xX<T> = Matrix<T, U6, Dyn, VecStorage<T, U6, Dyn>>;
|
||||||
|
|
||||||
/// A stack-allocated, column-major, 1x1 square matrix.
|
/// A stack-allocated, column-major, 1x1 square matrix.
|
||||||
///
|
///
|
||||||
|
@ -276,7 +276,7 @@ pub type Matrix6x5<T> = Matrix<T, U6, U5, ArrayStorage<T, 6, 5>>;
|
||||||
*/
|
*/
|
||||||
/// A dynamically sized column vector.
|
/// A dynamically sized column vector.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type DVector<T> = Matrix<T, Dynamic, U1, VecStorage<T, Dynamic, U1>>;
|
pub type DVector<T> = Matrix<T, Dyn, U1, VecStorage<T, Dyn, U1>>;
|
||||||
|
|
||||||
/// An owned D-dimensional column vector.
|
/// An owned D-dimensional column vector.
|
||||||
pub type OVector<T, D> = Matrix<T, D, U1, Owned<T, D, U1>>;
|
pub type OVector<T, D> = Matrix<T, D, U1, Owned<T, D, U1>>;
|
||||||
|
@ -316,7 +316,7 @@ pub type Vector6<T> = Matrix<T, U6, U1, ArrayStorage<T, 6, 1>>;
|
||||||
*/
|
*/
|
||||||
/// A dynamically sized row vector.
|
/// A dynamically sized row vector.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub type RowDVector<T> = Matrix<T, U1, Dynamic, VecStorage<T, U1, Dynamic>>;
|
pub type RowDVector<T> = Matrix<T, U1, Dyn, VecStorage<T, U1, Dyn>>;
|
||||||
|
|
||||||
/// An owned D-dimensional row vector.
|
/// An owned D-dimensional row vector.
|
||||||
pub type RowOVector<T, D> = Matrix<T, U1, D, Owned<T, U1, D>>;
|
pub type RowOVector<T, D> = Matrix<T, U1, D, Owned<T, U1, D>>;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use crate::base::dimension::{Dynamic, U1, U2, U3, U4, U5, U6};
|
use crate::base::dimension::{Dyn, U1, U2, U3, U4, U5, U6};
|
||||||
use crate::base::matrix_slice::{SliceStorage, SliceStorageMut};
|
use crate::base::matrix_view::{ViewStorage, ViewStorageMut};
|
||||||
use crate::base::{Const, Matrix};
|
use crate::base::{Const, Matrix};
|
||||||
|
use crate::slice_deprecation_note;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -13,286 +14,345 @@ use crate::base::{Const, Matrix};
|
||||||
/// A column-major matrix slice with dimensions known at compile-time.
|
/// A column-major matrix slice with dimensions known at compile-time.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(SMatrixView)]
|
||||||
pub type SMatrixSlice<'a, T, const R: usize, const C: usize> =
|
pub type SMatrixSlice<'a, T, const R: usize, const C: usize> =
|
||||||
Matrix<T, Const<R>, Const<C>, SliceStorage<'a, T, Const<R>, Const<C>, Const<1>, Const<R>>>;
|
Matrix<T, Const<R>, Const<C>, ViewStorage<'a, T, Const<R>, Const<C>, Const<1>, Const<R>>>;
|
||||||
|
|
||||||
/// A column-major matrix slice dynamic numbers of rows and columns.
|
/// A column-major matrix slice dynamic numbers of rows and columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
pub type DMatrixSlice<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(DMatrixView)]
|
||||||
Matrix<T, Dynamic, Dynamic, SliceStorage<'a, T, Dynamic, Dynamic, RStride, CStride>>;
|
pub type DMatrixSlice<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, Dyn, ViewStorage<'a, T, Dyn, Dyn, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 1x1 matrix slice.
|
/// A column-major 1x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView1)]
|
||||||
pub type MatrixSlice1<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSlice1<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U1, SliceStorage<'a, T, U1, U1, RStride, CStride>>;
|
Matrix<T, U1, U1, ViewStorage<'a, T, U1, U1, RStride, CStride>>;
|
||||||
/// A column-major 2x2 matrix slice.
|
/// A column-major 2x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView2)]
|
||||||
pub type MatrixSlice2<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSlice2<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U2, SliceStorage<'a, T, U2, U2, RStride, CStride>>;
|
Matrix<T, U2, U2, ViewStorage<'a, T, U2, U2, RStride, CStride>>;
|
||||||
/// A column-major 3x3 matrix slice.
|
/// A column-major 3x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView3)]
|
||||||
pub type MatrixSlice3<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSlice3<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U3, SliceStorage<'a, T, U3, U3, RStride, CStride>>;
|
Matrix<T, U3, U3, ViewStorage<'a, T, U3, U3, RStride, CStride>>;
|
||||||
/// A column-major 4x4 matrix slice.
|
/// A column-major 4x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView4)]
|
||||||
pub type MatrixSlice4<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSlice4<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U4, SliceStorage<'a, T, U4, U4, RStride, CStride>>;
|
Matrix<T, U4, U4, ViewStorage<'a, T, U4, U4, RStride, CStride>>;
|
||||||
/// A column-major 5x5 matrix slice.
|
/// A column-major 5x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView5)]
|
||||||
pub type MatrixSlice5<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSlice5<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U5, SliceStorage<'a, T, U5, U5, RStride, CStride>>;
|
Matrix<T, U5, U5, ViewStorage<'a, T, U5, U5, RStride, CStride>>;
|
||||||
/// A column-major 6x6 matrix slice.
|
/// A column-major 6x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView6)]
|
||||||
pub type MatrixSlice6<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSlice6<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U6, SliceStorage<'a, T, U6, U6, RStride, CStride>>;
|
Matrix<T, U6, U6, ViewStorage<'a, T, U6, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 1x2 matrix slice.
|
/// A column-major 1x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView1x2)]
|
||||||
pub type MatrixSlice1x2<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSlice1x2<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U2, SliceStorage<'a, T, U1, U2, RStride, CStride>>;
|
Matrix<T, U1, U2, ViewStorage<'a, T, U1, U2, RStride, CStride>>;
|
||||||
/// A column-major 1x3 matrix slice.
|
/// A column-major 1x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView1x3)]
|
||||||
pub type MatrixSlice1x3<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSlice1x3<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U3, SliceStorage<'a, T, U1, U3, RStride, CStride>>;
|
Matrix<T, U1, U3, ViewStorage<'a, T, U1, U3, RStride, CStride>>;
|
||||||
/// A column-major 1x4 matrix slice.
|
/// A column-major 1x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView1x4)]
|
||||||
pub type MatrixSlice1x4<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSlice1x4<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U4, SliceStorage<'a, T, U1, U4, RStride, CStride>>;
|
Matrix<T, U1, U4, ViewStorage<'a, T, U1, U4, RStride, CStride>>;
|
||||||
/// A column-major 1x5 matrix slice.
|
/// A column-major 1x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView1x5)]
|
||||||
pub type MatrixSlice1x5<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSlice1x5<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U5, SliceStorage<'a, T, U1, U5, RStride, CStride>>;
|
Matrix<T, U1, U5, ViewStorage<'a, T, U1, U5, RStride, CStride>>;
|
||||||
/// A column-major 1x6 matrix slice.
|
/// A column-major 1x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView1x6)]
|
||||||
pub type MatrixSlice1x6<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSlice1x6<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U6, SliceStorage<'a, T, U1, U6, RStride, CStride>>;
|
Matrix<T, U1, U6, ViewStorage<'a, T, U1, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 2x1 matrix slice.
|
/// A column-major 2x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView2x1)]
|
||||||
pub type MatrixSlice2x1<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSlice2x1<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U1, SliceStorage<'a, T, U2, U1, RStride, CStride>>;
|
Matrix<T, U2, U1, ViewStorage<'a, T, U2, U1, RStride, CStride>>;
|
||||||
/// A column-major 2x3 matrix slice.
|
/// A column-major 2x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView2x3)]
|
||||||
pub type MatrixSlice2x3<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSlice2x3<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U3, SliceStorage<'a, T, U2, U3, RStride, CStride>>;
|
Matrix<T, U2, U3, ViewStorage<'a, T, U2, U3, RStride, CStride>>;
|
||||||
/// A column-major 2x4 matrix slice.
|
/// A column-major 2x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView2x4)]
|
||||||
pub type MatrixSlice2x4<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSlice2x4<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U4, SliceStorage<'a, T, U2, U4, RStride, CStride>>;
|
Matrix<T, U2, U4, ViewStorage<'a, T, U2, U4, RStride, CStride>>;
|
||||||
/// A column-major 2x5 matrix slice.
|
/// A column-major 2x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView2x5)]
|
||||||
pub type MatrixSlice2x5<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSlice2x5<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U5, SliceStorage<'a, T, U2, U5, RStride, CStride>>;
|
Matrix<T, U2, U5, ViewStorage<'a, T, U2, U5, RStride, CStride>>;
|
||||||
/// A column-major 2x6 matrix slice.
|
/// A column-major 2x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView2x6)]
|
||||||
pub type MatrixSlice2x6<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSlice2x6<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U6, SliceStorage<'a, T, U2, U6, RStride, CStride>>;
|
Matrix<T, U2, U6, ViewStorage<'a, T, U2, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 3x1 matrix slice.
|
/// A column-major 3x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView3x1)]
|
||||||
pub type MatrixSlice3x1<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSlice3x1<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U1, SliceStorage<'a, T, U3, U1, RStride, CStride>>;
|
Matrix<T, U3, U1, ViewStorage<'a, T, U3, U1, RStride, CStride>>;
|
||||||
/// A column-major 3x2 matrix slice.
|
/// A column-major 3x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView3x2)]
|
||||||
pub type MatrixSlice3x2<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSlice3x2<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U2, SliceStorage<'a, T, U3, U2, RStride, CStride>>;
|
Matrix<T, U3, U2, ViewStorage<'a, T, U3, U2, RStride, CStride>>;
|
||||||
/// A column-major 3x4 matrix slice.
|
/// A column-major 3x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView3x4)]
|
||||||
pub type MatrixSlice3x4<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSlice3x4<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U4, SliceStorage<'a, T, U3, U4, RStride, CStride>>;
|
Matrix<T, U3, U4, ViewStorage<'a, T, U3, U4, RStride, CStride>>;
|
||||||
/// A column-major 3x5 matrix slice.
|
/// A column-major 3x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView3x5)]
|
||||||
pub type MatrixSlice3x5<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSlice3x5<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U5, SliceStorage<'a, T, U3, U5, RStride, CStride>>;
|
Matrix<T, U3, U5, ViewStorage<'a, T, U3, U5, RStride, CStride>>;
|
||||||
/// A column-major 3x6 matrix slice.
|
/// A column-major 3x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView3x6)]
|
||||||
pub type MatrixSlice3x6<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSlice3x6<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U6, SliceStorage<'a, T, U3, U6, RStride, CStride>>;
|
Matrix<T, U3, U6, ViewStorage<'a, T, U3, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 4x1 matrix slice.
|
/// A column-major 4x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView4x1)]
|
||||||
pub type MatrixSlice4x1<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSlice4x1<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U1, SliceStorage<'a, T, U4, U1, RStride, CStride>>;
|
Matrix<T, U4, U1, ViewStorage<'a, T, U4, U1, RStride, CStride>>;
|
||||||
/// A column-major 4x2 matrix slice.
|
/// A column-major 4x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView4x2)]
|
||||||
pub type MatrixSlice4x2<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSlice4x2<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U2, SliceStorage<'a, T, U4, U2, RStride, CStride>>;
|
Matrix<T, U4, U2, ViewStorage<'a, T, U4, U2, RStride, CStride>>;
|
||||||
/// A column-major 4x3 matrix slice.
|
/// A column-major 4x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView4x3)]
|
||||||
pub type MatrixSlice4x3<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSlice4x3<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U3, SliceStorage<'a, T, U4, U3, RStride, CStride>>;
|
Matrix<T, U4, U3, ViewStorage<'a, T, U4, U3, RStride, CStride>>;
|
||||||
/// A column-major 4x5 matrix slice.
|
/// A column-major 4x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView4x5)]
|
||||||
pub type MatrixSlice4x5<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSlice4x5<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U5, SliceStorage<'a, T, U4, U5, RStride, CStride>>;
|
Matrix<T, U4, U5, ViewStorage<'a, T, U4, U5, RStride, CStride>>;
|
||||||
/// A column-major 4x6 matrix slice.
|
/// A column-major 4x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView4x6)]
|
||||||
pub type MatrixSlice4x6<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSlice4x6<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U6, SliceStorage<'a, T, U4, U6, RStride, CStride>>;
|
Matrix<T, U4, U6, ViewStorage<'a, T, U4, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 5x1 matrix slice.
|
/// A column-major 5x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView5x1)]
|
||||||
pub type MatrixSlice5x1<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSlice5x1<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U1, SliceStorage<'a, T, U5, U1, RStride, CStride>>;
|
Matrix<T, U5, U1, ViewStorage<'a, T, U5, U1, RStride, CStride>>;
|
||||||
/// A column-major 5x2 matrix slice.
|
/// A column-major 5x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView5x2)]
|
||||||
pub type MatrixSlice5x2<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSlice5x2<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U2, SliceStorage<'a, T, U5, U2, RStride, CStride>>;
|
Matrix<T, U5, U2, ViewStorage<'a, T, U5, U2, RStride, CStride>>;
|
||||||
/// A column-major 5x3 matrix slice.
|
/// A column-major 5x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView5x3)]
|
||||||
pub type MatrixSlice5x3<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSlice5x3<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U3, SliceStorage<'a, T, U5, U3, RStride, CStride>>;
|
Matrix<T, U5, U3, ViewStorage<'a, T, U5, U3, RStride, CStride>>;
|
||||||
/// A column-major 5x4 matrix slice.
|
/// A column-major 5x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView5x4)]
|
||||||
pub type MatrixSlice5x4<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSlice5x4<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U4, SliceStorage<'a, T, U5, U4, RStride, CStride>>;
|
Matrix<T, U5, U4, ViewStorage<'a, T, U5, U4, RStride, CStride>>;
|
||||||
/// A column-major 5x6 matrix slice.
|
/// A column-major 5x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView5x6)]
|
||||||
pub type MatrixSlice5x6<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSlice5x6<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U6, SliceStorage<'a, T, U5, U6, RStride, CStride>>;
|
Matrix<T, U5, U6, ViewStorage<'a, T, U5, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 6x1 matrix slice.
|
/// A column-major 6x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView6x1)]
|
||||||
pub type MatrixSlice6x1<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSlice6x1<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U1, SliceStorage<'a, T, U6, U1, RStride, CStride>>;
|
Matrix<T, U6, U1, ViewStorage<'a, T, U6, U1, RStride, CStride>>;
|
||||||
/// A column-major 6x2 matrix slice.
|
/// A column-major 6x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView6x2)]
|
||||||
pub type MatrixSlice6x2<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSlice6x2<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U2, SliceStorage<'a, T, U6, U2, RStride, CStride>>;
|
Matrix<T, U6, U2, ViewStorage<'a, T, U6, U2, RStride, CStride>>;
|
||||||
/// A column-major 6x3 matrix slice.
|
/// A column-major 6x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView6x3)]
|
||||||
pub type MatrixSlice6x3<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSlice6x3<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U3, SliceStorage<'a, T, U6, U3, RStride, CStride>>;
|
Matrix<T, U6, U3, ViewStorage<'a, T, U6, U3, RStride, CStride>>;
|
||||||
/// A column-major 6x4 matrix slice.
|
/// A column-major 6x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView6x4)]
|
||||||
pub type MatrixSlice6x4<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSlice6x4<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U4, SliceStorage<'a, T, U6, U4, RStride, CStride>>;
|
Matrix<T, U6, U4, ViewStorage<'a, T, U6, U4, RStride, CStride>>;
|
||||||
/// A column-major 6x5 matrix slice.
|
/// A column-major 6x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView6x5)]
|
||||||
pub type MatrixSlice6x5<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSlice6x5<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U5, SliceStorage<'a, T, U6, U5, RStride, CStride>>;
|
Matrix<T, U6, U5, ViewStorage<'a, T, U6, U5, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major matrix slice with 1 row and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 1 row and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView1xX)]
|
||||||
pub type MatrixSlice1xX<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSlice1xX<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, Dynamic, SliceStorage<'a, T, U1, Dynamic, RStride, CStride>>;
|
Matrix<T, U1, Dyn, ViewStorage<'a, T, U1, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 2 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 2 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView2xX)]
|
||||||
pub type MatrixSlice2xX<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSlice2xX<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, Dynamic, SliceStorage<'a, T, U2, Dynamic, RStride, CStride>>;
|
Matrix<T, U2, Dyn, ViewStorage<'a, T, U2, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 3 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 3 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView3xX)]
|
||||||
pub type MatrixSlice3xX<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSlice3xX<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, Dynamic, SliceStorage<'a, T, U3, Dynamic, RStride, CStride>>;
|
Matrix<T, U3, Dyn, ViewStorage<'a, T, U3, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 4 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 4 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView4xX)]
|
||||||
pub type MatrixSlice4xX<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSlice4xX<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, Dynamic, SliceStorage<'a, T, U4, Dynamic, RStride, CStride>>;
|
Matrix<T, U4, Dyn, ViewStorage<'a, T, U4, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 5 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 5 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView5xX)]
|
||||||
pub type MatrixSlice5xX<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSlice5xX<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, Dynamic, SliceStorage<'a, T, U5, Dynamic, RStride, CStride>>;
|
Matrix<T, U5, Dyn, ViewStorage<'a, T, U5, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 6 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 6 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixView6xX)]
|
||||||
pub type MatrixSlice6xX<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSlice6xX<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, Dynamic, SliceStorage<'a, T, U6, Dynamic, RStride, CStride>>;
|
Matrix<T, U6, Dyn, ViewStorage<'a, T, U6, Dyn, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 1 column.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 1 column.
|
||||||
pub type MatrixSliceXx1<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewXx1)]
|
||||||
Matrix<T, Dynamic, U1, SliceStorage<'a, T, Dynamic, U1, RStride, CStride>>;
|
pub type MatrixSliceXx1<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U1, ViewStorage<'a, T, Dyn, U1, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 2 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 2 columns.
|
||||||
pub type MatrixSliceXx2<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewXx2)]
|
||||||
Matrix<T, Dynamic, U2, SliceStorage<'a, T, Dynamic, U2, RStride, CStride>>;
|
pub type MatrixSliceXx2<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U2, ViewStorage<'a, T, Dyn, U2, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 3 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 3 columns.
|
||||||
pub type MatrixSliceXx3<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewXx3)]
|
||||||
Matrix<T, Dynamic, U3, SliceStorage<'a, T, Dynamic, U3, RStride, CStride>>;
|
pub type MatrixSliceXx3<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U3, ViewStorage<'a, T, Dyn, U3, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 4 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 4 columns.
|
||||||
pub type MatrixSliceXx4<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewXx4)]
|
||||||
Matrix<T, Dynamic, U4, SliceStorage<'a, T, Dynamic, U4, RStride, CStride>>;
|
pub type MatrixSliceXx4<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U4, ViewStorage<'a, T, Dyn, U4, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 5 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 5 columns.
|
||||||
pub type MatrixSliceXx5<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewXx5)]
|
||||||
Matrix<T, Dynamic, U5, SliceStorage<'a, T, Dynamic, U5, RStride, CStride>>;
|
pub type MatrixSliceXx5<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U5, ViewStorage<'a, T, Dyn, U5, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 6 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 6 columns.
|
||||||
pub type MatrixSliceXx6<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewXx6)]
|
||||||
Matrix<T, Dynamic, U6, SliceStorage<'a, T, Dynamic, U6, RStride, CStride>>;
|
pub type MatrixSliceXx6<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U6, ViewStorage<'a, T, Dyn, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column vector slice with dimensions known at compile-time.
|
/// A column vector slice with dimensions known at compile-time.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorView)]
|
||||||
pub type VectorSlice<'a, T, D, RStride = U1, CStride = D> =
|
pub type VectorSlice<'a, T, D, RStride = U1, CStride = D> =
|
||||||
Matrix<T, D, U1, SliceStorage<'a, T, D, U1, RStride, CStride>>;
|
Matrix<T, D, U1, ViewStorage<'a, T, D, U1, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column vector slice with dimensions known at compile-time.
|
/// A column vector slice with dimensions known at compile-time.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(SVectorView)]
|
||||||
pub type SVectorSlice<'a, T, const D: usize> =
|
pub type SVectorSlice<'a, T, const D: usize> =
|
||||||
Matrix<T, Const<D>, Const<1>, SliceStorage<'a, T, Const<D>, Const<1>, Const<1>, Const<D>>>;
|
Matrix<T, Const<D>, Const<1>, ViewStorage<'a, T, Const<D>, Const<1>, Const<1>, Const<D>>>;
|
||||||
|
|
||||||
/// A column vector slice dynamic numbers of rows and columns.
|
/// A column vector slice dynamic numbers of rows and columns.
|
||||||
pub type DVectorSlice<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(DVectorView)]
|
||||||
Matrix<T, Dynamic, U1, SliceStorage<'a, T, Dynamic, U1, RStride, CStride>>;
|
pub type DVectorSlice<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U1, ViewStorage<'a, T, Dyn, U1, RStride, CStride>>;
|
||||||
|
|
||||||
/// A 1D column vector slice.
|
/// A 1D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorView1)]
|
||||||
pub type VectorSlice1<'a, T, RStride = U1, CStride = U1> =
|
pub type VectorSlice1<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U1, SliceStorage<'a, T, U1, U1, RStride, CStride>>;
|
Matrix<T, U1, U1, ViewStorage<'a, T, U1, U1, RStride, CStride>>;
|
||||||
/// A 2D column vector slice.
|
/// A 2D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorView2)]
|
||||||
pub type VectorSlice2<'a, T, RStride = U1, CStride = U2> =
|
pub type VectorSlice2<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U1, SliceStorage<'a, T, U2, U1, RStride, CStride>>;
|
Matrix<T, U2, U1, ViewStorage<'a, T, U2, U1, RStride, CStride>>;
|
||||||
/// A 3D column vector slice.
|
/// A 3D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorView3)]
|
||||||
pub type VectorSlice3<'a, T, RStride = U1, CStride = U3> =
|
pub type VectorSlice3<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U1, SliceStorage<'a, T, U3, U1, RStride, CStride>>;
|
Matrix<T, U3, U1, ViewStorage<'a, T, U3, U1, RStride, CStride>>;
|
||||||
/// A 4D column vector slice.
|
/// A 4D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorView4)]
|
||||||
pub type VectorSlice4<'a, T, RStride = U1, CStride = U4> =
|
pub type VectorSlice4<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U1, SliceStorage<'a, T, U4, U1, RStride, CStride>>;
|
Matrix<T, U4, U1, ViewStorage<'a, T, U4, U1, RStride, CStride>>;
|
||||||
/// A 5D column vector slice.
|
/// A 5D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorView5)]
|
||||||
pub type VectorSlice5<'a, T, RStride = U1, CStride = U5> =
|
pub type VectorSlice5<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U1, SliceStorage<'a, T, U5, U1, RStride, CStride>>;
|
Matrix<T, U5, U1, ViewStorage<'a, T, U5, U1, RStride, CStride>>;
|
||||||
/// A 6D column vector slice.
|
/// A 6D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorView6)]
|
||||||
pub type VectorSlice6<'a, T, RStride = U1, CStride = U6> =
|
pub type VectorSlice6<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U1, SliceStorage<'a, T, U6, U1, RStride, CStride>>;
|
Matrix<T, U6, U1, ViewStorage<'a, T, U6, U1, RStride, CStride>>;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -304,297 +364,358 @@ pub type VectorSlice6<'a, T, RStride = U1, CStride = U6> =
|
||||||
/// A column-major matrix slice with `R` rows and `C` columns.
|
/// A column-major matrix slice with `R` rows and `C` columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = "Use MatrixViewMut instead, which has an identical definition."]
|
||||||
pub type MatrixSliceMutMN<'a, T, R, C, RStride = U1, CStride = R> =
|
pub type MatrixSliceMutMN<'a, T, R, C, RStride = U1, CStride = R> =
|
||||||
Matrix<T, R, C, SliceStorageMut<'a, T, R, C, RStride, CStride>>;
|
Matrix<T, R, C, ViewStorageMut<'a, T, R, C, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major matrix slice with `D` rows and columns.
|
/// A column-major matrix slice with `D` rows and columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = "Use MatrixViewMut instead."]
|
||||||
pub type MatrixSliceMutN<'a, T, D, RStride = U1, CStride = D> =
|
pub type MatrixSliceMutN<'a, T, D, RStride = U1, CStride = D> =
|
||||||
Matrix<T, D, D, SliceStorageMut<'a, T, D, D, RStride, CStride>>;
|
Matrix<T, D, D, ViewStorageMut<'a, T, D, D, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major matrix slice with dimensions known at compile-time.
|
/// A column-major matrix slice with dimensions known at compile-time.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(SMatrixViewMut)]
|
||||||
pub type SMatrixSliceMut<'a, T, const R: usize, const C: usize> =
|
pub type SMatrixSliceMut<'a, T, const R: usize, const C: usize> =
|
||||||
Matrix<T, Const<R>, Const<C>, SliceStorageMut<'a, T, Const<R>, Const<C>, Const<1>, Const<R>>>;
|
Matrix<T, Const<R>, Const<C>, ViewStorageMut<'a, T, Const<R>, Const<C>, Const<1>, Const<R>>>;
|
||||||
|
|
||||||
/// A column-major matrix slice dynamic numbers of rows and columns.
|
/// A column-major matrix slice dynamic numbers of rows and columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
pub type DMatrixSliceMut<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(DMatrixViewMut)]
|
||||||
Matrix<T, Dynamic, Dynamic, SliceStorageMut<'a, T, Dynamic, Dynamic, RStride, CStride>>;
|
pub type DMatrixSliceMut<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, Dyn, ViewStorageMut<'a, T, Dyn, Dyn, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 1x1 matrix slice.
|
/// A column-major 1x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut1)]
|
||||||
pub type MatrixSliceMut1<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSliceMut1<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U1, SliceStorageMut<'a, T, U1, U1, RStride, CStride>>;
|
Matrix<T, U1, U1, ViewStorageMut<'a, T, U1, U1, RStride, CStride>>;
|
||||||
/// A column-major 2x2 matrix slice.
|
/// A column-major 2x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut2)]
|
||||||
pub type MatrixSliceMut2<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSliceMut2<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U2, SliceStorageMut<'a, T, U2, U2, RStride, CStride>>;
|
Matrix<T, U2, U2, ViewStorageMut<'a, T, U2, U2, RStride, CStride>>;
|
||||||
/// A column-major 3x3 matrix slice.
|
/// A column-major 3x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut3)]
|
||||||
pub type MatrixSliceMut3<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSliceMut3<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U3, SliceStorageMut<'a, T, U3, U3, RStride, CStride>>;
|
Matrix<T, U3, U3, ViewStorageMut<'a, T, U3, U3, RStride, CStride>>;
|
||||||
/// A column-major 4x4 matrix slice.
|
/// A column-major 4x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut4)]
|
||||||
pub type MatrixSliceMut4<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSliceMut4<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U4, SliceStorageMut<'a, T, U4, U4, RStride, CStride>>;
|
Matrix<T, U4, U4, ViewStorageMut<'a, T, U4, U4, RStride, CStride>>;
|
||||||
/// A column-major 5x5 matrix slice.
|
/// A column-major 5x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut5)]
|
||||||
pub type MatrixSliceMut5<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSliceMut5<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U5, SliceStorageMut<'a, T, U5, U5, RStride, CStride>>;
|
Matrix<T, U5, U5, ViewStorageMut<'a, T, U5, U5, RStride, CStride>>;
|
||||||
/// A column-major 6x6 matrix slice.
|
/// A column-major 6x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut6)]
|
||||||
pub type MatrixSliceMut6<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSliceMut6<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U6, SliceStorageMut<'a, T, U6, U6, RStride, CStride>>;
|
Matrix<T, U6, U6, ViewStorageMut<'a, T, U6, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 1x2 matrix slice.
|
/// A column-major 1x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut1x2)]
|
||||||
pub type MatrixSliceMut1x2<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSliceMut1x2<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U2, SliceStorageMut<'a, T, U1, U2, RStride, CStride>>;
|
Matrix<T, U1, U2, ViewStorageMut<'a, T, U1, U2, RStride, CStride>>;
|
||||||
/// A column-major 1x3 matrix slice.
|
/// A column-major 1x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut1x3)]
|
||||||
pub type MatrixSliceMut1x3<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSliceMut1x3<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U3, SliceStorageMut<'a, T, U1, U3, RStride, CStride>>;
|
Matrix<T, U1, U3, ViewStorageMut<'a, T, U1, U3, RStride, CStride>>;
|
||||||
/// A column-major 1x4 matrix slice.
|
/// A column-major 1x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut1x4)]
|
||||||
pub type MatrixSliceMut1x4<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSliceMut1x4<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U4, SliceStorageMut<'a, T, U1, U4, RStride, CStride>>;
|
Matrix<T, U1, U4, ViewStorageMut<'a, T, U1, U4, RStride, CStride>>;
|
||||||
/// A column-major 1x5 matrix slice.
|
/// A column-major 1x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut1x5)]
|
||||||
pub type MatrixSliceMut1x5<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSliceMut1x5<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U5, SliceStorageMut<'a, T, U1, U5, RStride, CStride>>;
|
Matrix<T, U1, U5, ViewStorageMut<'a, T, U1, U5, RStride, CStride>>;
|
||||||
/// A column-major 1x6 matrix slice.
|
/// A column-major 1x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut1x6)]
|
||||||
pub type MatrixSliceMut1x6<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSliceMut1x6<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U6, SliceStorageMut<'a, T, U1, U6, RStride, CStride>>;
|
Matrix<T, U1, U6, ViewStorageMut<'a, T, U1, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 2x1 matrix slice.
|
/// A column-major 2x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut2x1)]
|
||||||
pub type MatrixSliceMut2x1<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSliceMut2x1<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U1, SliceStorageMut<'a, T, U2, U1, RStride, CStride>>;
|
Matrix<T, U2, U1, ViewStorageMut<'a, T, U2, U1, RStride, CStride>>;
|
||||||
/// A column-major 2x3 matrix slice.
|
/// A column-major 2x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut2x3)]
|
||||||
pub type MatrixSliceMut2x3<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSliceMut2x3<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U3, SliceStorageMut<'a, T, U2, U3, RStride, CStride>>;
|
Matrix<T, U2, U3, ViewStorageMut<'a, T, U2, U3, RStride, CStride>>;
|
||||||
/// A column-major 2x4 matrix slice.
|
/// A column-major 2x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut2x4)]
|
||||||
pub type MatrixSliceMut2x4<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSliceMut2x4<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U4, SliceStorageMut<'a, T, U2, U4, RStride, CStride>>;
|
Matrix<T, U2, U4, ViewStorageMut<'a, T, U2, U4, RStride, CStride>>;
|
||||||
/// A column-major 2x5 matrix slice.
|
/// A column-major 2x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut2x5)]
|
||||||
pub type MatrixSliceMut2x5<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSliceMut2x5<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U5, SliceStorageMut<'a, T, U2, U5, RStride, CStride>>;
|
Matrix<T, U2, U5, ViewStorageMut<'a, T, U2, U5, RStride, CStride>>;
|
||||||
/// A column-major 2x6 matrix slice.
|
/// A column-major 2x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut2x6)]
|
||||||
pub type MatrixSliceMut2x6<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSliceMut2x6<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U6, SliceStorageMut<'a, T, U2, U6, RStride, CStride>>;
|
Matrix<T, U2, U6, ViewStorageMut<'a, T, U2, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 3x1 matrix slice.
|
/// A column-major 3x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut3x1)]
|
||||||
pub type MatrixSliceMut3x1<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSliceMut3x1<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U1, SliceStorageMut<'a, T, U3, U1, RStride, CStride>>;
|
Matrix<T, U3, U1, ViewStorageMut<'a, T, U3, U1, RStride, CStride>>;
|
||||||
/// A column-major 3x2 matrix slice.
|
/// A column-major 3x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut3x2)]
|
||||||
pub type MatrixSliceMut3x2<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSliceMut3x2<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U2, SliceStorageMut<'a, T, U3, U2, RStride, CStride>>;
|
Matrix<T, U3, U2, ViewStorageMut<'a, T, U3, U2, RStride, CStride>>;
|
||||||
/// A column-major 3x4 matrix slice.
|
/// A column-major 3x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut3x4)]
|
||||||
pub type MatrixSliceMut3x4<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSliceMut3x4<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U4, SliceStorageMut<'a, T, U3, U4, RStride, CStride>>;
|
Matrix<T, U3, U4, ViewStorageMut<'a, T, U3, U4, RStride, CStride>>;
|
||||||
/// A column-major 3x5 matrix slice.
|
/// A column-major 3x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut3x5)]
|
||||||
pub type MatrixSliceMut3x5<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSliceMut3x5<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U5, SliceStorageMut<'a, T, U3, U5, RStride, CStride>>;
|
Matrix<T, U3, U5, ViewStorageMut<'a, T, U3, U5, RStride, CStride>>;
|
||||||
/// A column-major 3x6 matrix slice.
|
/// A column-major 3x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut3x6)]
|
||||||
pub type MatrixSliceMut3x6<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSliceMut3x6<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U6, SliceStorageMut<'a, T, U3, U6, RStride, CStride>>;
|
Matrix<T, U3, U6, ViewStorageMut<'a, T, U3, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 4x1 matrix slice.
|
/// A column-major 4x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut4x1)]
|
||||||
pub type MatrixSliceMut4x1<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSliceMut4x1<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U1, SliceStorageMut<'a, T, U4, U1, RStride, CStride>>;
|
Matrix<T, U4, U1, ViewStorageMut<'a, T, U4, U1, RStride, CStride>>;
|
||||||
/// A column-major 4x2 matrix slice.
|
/// A column-major 4x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut4x2)]
|
||||||
pub type MatrixSliceMut4x2<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSliceMut4x2<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U2, SliceStorageMut<'a, T, U4, U2, RStride, CStride>>;
|
Matrix<T, U4, U2, ViewStorageMut<'a, T, U4, U2, RStride, CStride>>;
|
||||||
/// A column-major 4x3 matrix slice.
|
/// A column-major 4x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut4x3)]
|
||||||
pub type MatrixSliceMut4x3<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSliceMut4x3<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U3, SliceStorageMut<'a, T, U4, U3, RStride, CStride>>;
|
Matrix<T, U4, U3, ViewStorageMut<'a, T, U4, U3, RStride, CStride>>;
|
||||||
/// A column-major 4x5 matrix slice.
|
/// A column-major 4x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut4x5)]
|
||||||
pub type MatrixSliceMut4x5<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSliceMut4x5<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U5, SliceStorageMut<'a, T, U4, U5, RStride, CStride>>;
|
Matrix<T, U4, U5, ViewStorageMut<'a, T, U4, U5, RStride, CStride>>;
|
||||||
/// A column-major 4x6 matrix slice.
|
/// A column-major 4x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut4x6)]
|
||||||
pub type MatrixSliceMut4x6<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSliceMut4x6<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U6, SliceStorageMut<'a, T, U4, U6, RStride, CStride>>;
|
Matrix<T, U4, U6, ViewStorageMut<'a, T, U4, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 5x1 matrix slice.
|
/// A column-major 5x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut5x1)]
|
||||||
pub type MatrixSliceMut5x1<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSliceMut5x1<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U1, SliceStorageMut<'a, T, U5, U1, RStride, CStride>>;
|
Matrix<T, U5, U1, ViewStorageMut<'a, T, U5, U1, RStride, CStride>>;
|
||||||
/// A column-major 5x2 matrix slice.
|
/// A column-major 5x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut5x2)]
|
||||||
pub type MatrixSliceMut5x2<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSliceMut5x2<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U2, SliceStorageMut<'a, T, U5, U2, RStride, CStride>>;
|
Matrix<T, U5, U2, ViewStorageMut<'a, T, U5, U2, RStride, CStride>>;
|
||||||
/// A column-major 5x3 matrix slice.
|
/// A column-major 5x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut5x3)]
|
||||||
pub type MatrixSliceMut5x3<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSliceMut5x3<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U3, SliceStorageMut<'a, T, U5, U3, RStride, CStride>>;
|
Matrix<T, U5, U3, ViewStorageMut<'a, T, U5, U3, RStride, CStride>>;
|
||||||
/// A column-major 5x4 matrix slice.
|
/// A column-major 5x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut5x4)]
|
||||||
pub type MatrixSliceMut5x4<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSliceMut5x4<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U4, SliceStorageMut<'a, T, U5, U4, RStride, CStride>>;
|
Matrix<T, U5, U4, ViewStorageMut<'a, T, U5, U4, RStride, CStride>>;
|
||||||
/// A column-major 5x6 matrix slice.
|
/// A column-major 5x6 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut5x6)]
|
||||||
pub type MatrixSliceMut5x6<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSliceMut5x6<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U6, SliceStorageMut<'a, T, U5, U6, RStride, CStride>>;
|
Matrix<T, U5, U6, ViewStorageMut<'a, T, U5, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major 6x1 matrix slice.
|
/// A column-major 6x1 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut6x1)]
|
||||||
pub type MatrixSliceMut6x1<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSliceMut6x1<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U1, SliceStorageMut<'a, T, U6, U1, RStride, CStride>>;
|
Matrix<T, U6, U1, ViewStorageMut<'a, T, U6, U1, RStride, CStride>>;
|
||||||
/// A column-major 6x2 matrix slice.
|
/// A column-major 6x2 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut6x2)]
|
||||||
pub type MatrixSliceMut6x2<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSliceMut6x2<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U2, SliceStorageMut<'a, T, U6, U2, RStride, CStride>>;
|
Matrix<T, U6, U2, ViewStorageMut<'a, T, U6, U2, RStride, CStride>>;
|
||||||
/// A column-major 6x3 matrix slice.
|
/// A column-major 6x3 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut6x3)]
|
||||||
pub type MatrixSliceMut6x3<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSliceMut6x3<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U3, SliceStorageMut<'a, T, U6, U3, RStride, CStride>>;
|
Matrix<T, U6, U3, ViewStorageMut<'a, T, U6, U3, RStride, CStride>>;
|
||||||
/// A column-major 6x4 matrix slice.
|
/// A column-major 6x4 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut6x4)]
|
||||||
pub type MatrixSliceMut6x4<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSliceMut6x4<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U4, SliceStorageMut<'a, T, U6, U4, RStride, CStride>>;
|
Matrix<T, U6, U4, ViewStorageMut<'a, T, U6, U4, RStride, CStride>>;
|
||||||
/// A column-major 6x5 matrix slice.
|
/// A column-major 6x5 matrix slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut6x5)]
|
||||||
pub type MatrixSliceMut6x5<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSliceMut6x5<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U5, SliceStorageMut<'a, T, U6, U5, RStride, CStride>>;
|
Matrix<T, U6, U5, ViewStorageMut<'a, T, U6, U5, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major matrix slice with 1 row and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 1 row and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut1xX)]
|
||||||
pub type MatrixSliceMut1xX<'a, T, RStride = U1, CStride = U1> =
|
pub type MatrixSliceMut1xX<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, Dynamic, SliceStorageMut<'a, T, U1, Dynamic, RStride, CStride>>;
|
Matrix<T, U1, Dyn, ViewStorageMut<'a, T, U1, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 2 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 2 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut2xX)]
|
||||||
pub type MatrixSliceMut2xX<'a, T, RStride = U1, CStride = U2> =
|
pub type MatrixSliceMut2xX<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, Dynamic, SliceStorageMut<'a, T, U2, Dynamic, RStride, CStride>>;
|
Matrix<T, U2, Dyn, ViewStorageMut<'a, T, U2, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 3 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 3 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut3xX)]
|
||||||
pub type MatrixSliceMut3xX<'a, T, RStride = U1, CStride = U3> =
|
pub type MatrixSliceMut3xX<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, Dynamic, SliceStorageMut<'a, T, U3, Dynamic, RStride, CStride>>;
|
Matrix<T, U3, Dyn, ViewStorageMut<'a, T, U3, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 4 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 4 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut4xX)]
|
||||||
pub type MatrixSliceMut4xX<'a, T, RStride = U1, CStride = U4> =
|
pub type MatrixSliceMut4xX<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, Dynamic, SliceStorageMut<'a, T, U4, Dynamic, RStride, CStride>>;
|
Matrix<T, U4, Dyn, ViewStorageMut<'a, T, U4, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 5 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 5 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut5xX)]
|
||||||
pub type MatrixSliceMut5xX<'a, T, RStride = U1, CStride = U5> =
|
pub type MatrixSliceMut5xX<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, Dynamic, SliceStorageMut<'a, T, U5, Dynamic, RStride, CStride>>;
|
Matrix<T, U5, Dyn, ViewStorageMut<'a, T, U5, Dyn, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with 6 rows and a number of columns chosen at runtime.
|
/// A column-major matrix slice with 6 rows and a number of columns chosen at runtime.
|
||||||
|
#[deprecated = slice_deprecation_note!(MatrixViewMut6xX)]
|
||||||
pub type MatrixSliceMut6xX<'a, T, RStride = U1, CStride = U6> =
|
pub type MatrixSliceMut6xX<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, Dynamic, SliceStorageMut<'a, T, U6, Dynamic, RStride, CStride>>;
|
Matrix<T, U6, Dyn, ViewStorageMut<'a, T, U6, Dyn, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 1 column.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 1 column.
|
||||||
pub type MatrixSliceMutXx1<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewMutXx1)]
|
||||||
Matrix<T, Dynamic, U1, SliceStorageMut<'a, T, Dynamic, U1, RStride, CStride>>;
|
pub type MatrixSliceMutXx1<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U1, ViewStorageMut<'a, T, Dyn, U1, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 2 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 2 columns.
|
||||||
pub type MatrixSliceMutXx2<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewMutXx2)]
|
||||||
Matrix<T, Dynamic, U2, SliceStorageMut<'a, T, Dynamic, U2, RStride, CStride>>;
|
pub type MatrixSliceMutXx2<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U2, ViewStorageMut<'a, T, Dyn, U2, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 3 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 3 columns.
|
||||||
pub type MatrixSliceMutXx3<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewMutXx3)]
|
||||||
Matrix<T, Dynamic, U3, SliceStorageMut<'a, T, Dynamic, U3, RStride, CStride>>;
|
pub type MatrixSliceMutXx3<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U3, ViewStorageMut<'a, T, Dyn, U3, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 4 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 4 columns.
|
||||||
pub type MatrixSliceMutXx4<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewMutXx4)]
|
||||||
Matrix<T, Dynamic, U4, SliceStorageMut<'a, T, Dynamic, U4, RStride, CStride>>;
|
pub type MatrixSliceMutXx4<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U4, ViewStorageMut<'a, T, Dyn, U4, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 5 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 5 columns.
|
||||||
pub type MatrixSliceMutXx5<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewMutXx5)]
|
||||||
Matrix<T, Dynamic, U5, SliceStorageMut<'a, T, Dynamic, U5, RStride, CStride>>;
|
pub type MatrixSliceMutXx5<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U5, ViewStorageMut<'a, T, Dyn, U5, RStride, CStride>>;
|
||||||
/// A column-major matrix slice with a number of rows chosen at runtime and 6 columns.
|
/// A column-major matrix slice with a number of rows chosen at runtime and 6 columns.
|
||||||
pub type MatrixSliceMutXx6<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(MatrixViewMutXx6)]
|
||||||
Matrix<T, Dynamic, U6, SliceStorageMut<'a, T, Dynamic, U6, RStride, CStride>>;
|
pub type MatrixSliceMutXx6<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U6, ViewStorageMut<'a, T, Dyn, U6, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column vector slice with dimensions known at compile-time.
|
/// A column vector slice with dimensions known at compile-time.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorViewMut)]
|
||||||
pub type VectorSliceMut<'a, T, D, RStride = U1, CStride = D> =
|
pub type VectorSliceMut<'a, T, D, RStride = U1, CStride = D> =
|
||||||
Matrix<T, D, U1, SliceStorageMut<'a, T, D, U1, RStride, CStride>>;
|
Matrix<T, D, U1, ViewStorageMut<'a, T, D, U1, RStride, CStride>>;
|
||||||
|
|
||||||
/// A column vector slice with dimensions known at compile-time.
|
/// A column vector slice with dimensions known at compile-time.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(SVectorViewMut)]
|
||||||
pub type SVectorSliceMut<'a, T, const D: usize> =
|
pub type SVectorSliceMut<'a, T, const D: usize> =
|
||||||
Matrix<T, Const<D>, Const<1>, SliceStorageMut<'a, T, Const<D>, Const<1>, Const<1>, Const<D>>>;
|
Matrix<T, Const<D>, Const<1>, ViewStorageMut<'a, T, Const<D>, Const<1>, Const<1>, Const<D>>>;
|
||||||
|
|
||||||
/// A column vector slice dynamic numbers of rows and columns.
|
/// A column vector slice dynamic numbers of rows and columns.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
pub type DVectorSliceMut<'a, T, RStride = U1, CStride = Dynamic> =
|
#[deprecated = slice_deprecation_note!(DVectorViewMut)]
|
||||||
Matrix<T, Dynamic, U1, SliceStorageMut<'a, T, Dynamic, U1, RStride, CStride>>;
|
pub type DVectorSliceMut<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U1, ViewStorageMut<'a, T, Dyn, U1, RStride, CStride>>;
|
||||||
|
|
||||||
/// A 1D column vector slice.
|
/// A 1D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorViewMut1)]
|
||||||
pub type VectorSliceMut1<'a, T, RStride = U1, CStride = U1> =
|
pub type VectorSliceMut1<'a, T, RStride = U1, CStride = U1> =
|
||||||
Matrix<T, U1, U1, SliceStorageMut<'a, T, U1, U1, RStride, CStride>>;
|
Matrix<T, U1, U1, ViewStorageMut<'a, T, U1, U1, RStride, CStride>>;
|
||||||
/// A 2D column vector slice.
|
/// A 2D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorViewMut2)]
|
||||||
pub type VectorSliceMut2<'a, T, RStride = U1, CStride = U2> =
|
pub type VectorSliceMut2<'a, T, RStride = U1, CStride = U2> =
|
||||||
Matrix<T, U2, U1, SliceStorageMut<'a, T, U2, U1, RStride, CStride>>;
|
Matrix<T, U2, U1, ViewStorageMut<'a, T, U2, U1, RStride, CStride>>;
|
||||||
/// A 3D column vector slice.
|
/// A 3D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorViewMut3)]
|
||||||
pub type VectorSliceMut3<'a, T, RStride = U1, CStride = U3> =
|
pub type VectorSliceMut3<'a, T, RStride = U1, CStride = U3> =
|
||||||
Matrix<T, U3, U1, SliceStorageMut<'a, T, U3, U1, RStride, CStride>>;
|
Matrix<T, U3, U1, ViewStorageMut<'a, T, U3, U1, RStride, CStride>>;
|
||||||
/// A 4D column vector slice.
|
/// A 4D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorViewMut4)]
|
||||||
pub type VectorSliceMut4<'a, T, RStride = U1, CStride = U4> =
|
pub type VectorSliceMut4<'a, T, RStride = U1, CStride = U4> =
|
||||||
Matrix<T, U4, U1, SliceStorageMut<'a, T, U4, U1, RStride, CStride>>;
|
Matrix<T, U4, U1, ViewStorageMut<'a, T, U4, U1, RStride, CStride>>;
|
||||||
/// A 5D column vector slice.
|
/// A 5D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorViewMut5)]
|
||||||
pub type VectorSliceMut5<'a, T, RStride = U1, CStride = U5> =
|
pub type VectorSliceMut5<'a, T, RStride = U1, CStride = U5> =
|
||||||
Matrix<T, U5, U1, SliceStorageMut<'a, T, U5, U1, RStride, CStride>>;
|
Matrix<T, U5, U1, ViewStorageMut<'a, T, U5, U1, RStride, CStride>>;
|
||||||
/// A 6D column vector slice.
|
/// A 6D column vector slice.
|
||||||
///
|
///
|
||||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
#[deprecated = slice_deprecation_note!(VectorViewMut6)]
|
||||||
pub type VectorSliceMut6<'a, T, RStride = U1, CStride = U6> =
|
pub type VectorSliceMut6<'a, T, RStride = U1, CStride = U6> =
|
||||||
Matrix<T, U6, U1, SliceStorageMut<'a, T, U6, U1, RStride, CStride>>;
|
Matrix<T, U6, U1, ViewStorageMut<'a, T, U6, U1, RStride, CStride>>;
|
||||||
|
|
|
@ -0,0 +1,589 @@
|
||||||
|
use crate::base::dimension::{Dyn, U1, U2, U3, U4, U5, U6};
|
||||||
|
use crate::base::matrix_view::{ViewStorage, ViewStorageMut};
|
||||||
|
use crate::base::{Const, Matrix};
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Matrix view aliases.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
// NOTE: we can't provide defaults for the strides because it's not supported yet by min_const_generics.
|
||||||
|
/// A column-major matrix view with dimensions known at compile-time.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type SMatrixView<'a, T, const R: usize, const C: usize> =
|
||||||
|
Matrix<T, Const<R>, Const<C>, ViewStorage<'a, T, Const<R>, Const<C>, Const<1>, Const<R>>>;
|
||||||
|
|
||||||
|
/// A column-major matrix view dynamic numbers of rows and columns.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type DMatrixView<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, Dyn, ViewStorage<'a, T, Dyn, Dyn, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 1x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView1<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U1, ViewStorage<'a, T, U1, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 2x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView2<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U2, ViewStorage<'a, T, U2, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 3x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView3<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U3, ViewStorage<'a, T, U3, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 4x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView4<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U4, ViewStorage<'a, T, U4, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 5x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView5<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U5, ViewStorage<'a, T, U5, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 6x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView6<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U6, ViewStorage<'a, T, U6, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 1x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView1x2<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U2, ViewStorage<'a, T, U1, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 1x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView1x3<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U3, ViewStorage<'a, T, U1, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 1x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView1x4<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U4, ViewStorage<'a, T, U1, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 1x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView1x5<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U5, ViewStorage<'a, T, U1, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 1x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView1x6<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U6, ViewStorage<'a, T, U1, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 2x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView2x1<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U1, ViewStorage<'a, T, U2, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 2x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView2x3<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U3, ViewStorage<'a, T, U2, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 2x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView2x4<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U4, ViewStorage<'a, T, U2, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 2x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView2x5<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U5, ViewStorage<'a, T, U2, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 2x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView2x6<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U6, ViewStorage<'a, T, U2, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 3x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView3x1<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U1, ViewStorage<'a, T, U3, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 3x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView3x2<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U2, ViewStorage<'a, T, U3, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 3x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView3x4<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U4, ViewStorage<'a, T, U3, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 3x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView3x5<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U5, ViewStorage<'a, T, U3, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 3x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView3x6<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U6, ViewStorage<'a, T, U3, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 4x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView4x1<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U1, ViewStorage<'a, T, U4, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 4x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView4x2<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U2, ViewStorage<'a, T, U4, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 4x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView4x3<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U3, ViewStorage<'a, T, U4, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 4x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView4x5<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U5, ViewStorage<'a, T, U4, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 4x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView4x6<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U6, ViewStorage<'a, T, U4, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 5x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView5x1<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U1, ViewStorage<'a, T, U5, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 5x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView5x2<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U2, ViewStorage<'a, T, U5, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 5x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView5x3<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U3, ViewStorage<'a, T, U5, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 5x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView5x4<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U4, ViewStorage<'a, T, U5, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 5x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView5x6<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U6, ViewStorage<'a, T, U5, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 6x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView6x1<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U1, ViewStorage<'a, T, U6, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 6x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView6x2<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U2, ViewStorage<'a, T, U6, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 6x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView6x3<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U3, ViewStorage<'a, T, U6, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 6x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView6x4<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U4, ViewStorage<'a, T, U6, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 6x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixView6x5<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U5, ViewStorage<'a, T, U6, U5, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major matrix view with 1 row and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixView1xX<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, Dyn, ViewStorage<'a, T, U1, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 2 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixView2xX<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, Dyn, ViewStorage<'a, T, U2, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 3 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixView3xX<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, Dyn, ViewStorage<'a, T, U3, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 4 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixView4xX<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, Dyn, ViewStorage<'a, T, U4, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 5 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixView5xX<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, Dyn, ViewStorage<'a, T, U5, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 6 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixView6xX<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, Dyn, ViewStorage<'a, T, U6, Dyn, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 1 column.
|
||||||
|
pub type MatrixViewXx1<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U1, ViewStorage<'a, T, Dyn, U1, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 2 columns.
|
||||||
|
pub type MatrixViewXx2<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U2, ViewStorage<'a, T, Dyn, U2, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 3 columns.
|
||||||
|
pub type MatrixViewXx3<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U3, ViewStorage<'a, T, Dyn, U3, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 4 columns.
|
||||||
|
pub type MatrixViewXx4<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U4, ViewStorage<'a, T, Dyn, U4, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 5 columns.
|
||||||
|
pub type MatrixViewXx5<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U5, ViewStorage<'a, T, Dyn, U5, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 6 columns.
|
||||||
|
pub type MatrixViewXx6<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U6, ViewStorage<'a, T, Dyn, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column vector view with dimensions known at compile-time.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorView<'a, T, D, RStride = U1, CStride = D> =
|
||||||
|
Matrix<T, D, U1, ViewStorage<'a, T, D, U1, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column vector view with dimensions known at compile-time.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type SVectorView<'a, T, const D: usize> =
|
||||||
|
Matrix<T, Const<D>, Const<1>, ViewStorage<'a, T, Const<D>, Const<1>, Const<1>, Const<D>>>;
|
||||||
|
|
||||||
|
/// A column vector view dynamic numbers of rows and columns.
|
||||||
|
pub type DVectorView<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U1, ViewStorage<'a, T, Dyn, U1, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A 1D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorView1<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U1, ViewStorage<'a, T, U1, U1, RStride, CStride>>;
|
||||||
|
/// A 2D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorView2<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U1, ViewStorage<'a, T, U2, U1, RStride, CStride>>;
|
||||||
|
/// A 3D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorView3<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U1, ViewStorage<'a, T, U3, U1, RStride, CStride>>;
|
||||||
|
/// A 4D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorView4<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U1, ViewStorage<'a, T, U4, U1, RStride, CStride>>;
|
||||||
|
/// A 5D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorView5<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U1, ViewStorage<'a, T, U5, U1, RStride, CStride>>;
|
||||||
|
/// A 6D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorView6<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U1, ViewStorage<'a, T, U6, U1, RStride, CStride>>;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Same thing, but for mutable views.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/// A column-major matrix view with dimensions known at compile-time.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type SMatrixViewMut<'a, T, const R: usize, const C: usize> =
|
||||||
|
Matrix<T, Const<R>, Const<C>, ViewStorageMut<'a, T, Const<R>, Const<C>, Const<1>, Const<R>>>;
|
||||||
|
|
||||||
|
/// A column-major matrix view dynamic numbers of rows and columns.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type DMatrixViewMut<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, Dyn, ViewStorageMut<'a, T, Dyn, Dyn, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 1x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut1<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U1, ViewStorageMut<'a, T, U1, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 2x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut2<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U2, ViewStorageMut<'a, T, U2, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 3x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut3<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U3, ViewStorageMut<'a, T, U3, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 4x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut4<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U4, ViewStorageMut<'a, T, U4, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 5x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut5<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U5, ViewStorageMut<'a, T, U5, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 6x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut6<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U6, ViewStorageMut<'a, T, U6, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 1x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut1x2<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U2, ViewStorageMut<'a, T, U1, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 1x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut1x3<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U3, ViewStorageMut<'a, T, U1, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 1x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut1x4<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U4, ViewStorageMut<'a, T, U1, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 1x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut1x5<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U5, ViewStorageMut<'a, T, U1, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 1x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut1x6<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U6, ViewStorageMut<'a, T, U1, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 2x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut2x1<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U1, ViewStorageMut<'a, T, U2, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 2x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut2x3<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U3, ViewStorageMut<'a, T, U2, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 2x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut2x4<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U4, ViewStorageMut<'a, T, U2, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 2x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut2x5<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U5, ViewStorageMut<'a, T, U2, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 2x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut2x6<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U6, ViewStorageMut<'a, T, U2, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 3x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut3x1<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U1, ViewStorageMut<'a, T, U3, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 3x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut3x2<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U2, ViewStorageMut<'a, T, U3, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 3x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut3x4<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U4, ViewStorageMut<'a, T, U3, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 3x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut3x5<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U5, ViewStorageMut<'a, T, U3, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 3x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut3x6<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U6, ViewStorageMut<'a, T, U3, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 4x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut4x1<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U1, ViewStorageMut<'a, T, U4, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 4x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut4x2<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U2, ViewStorageMut<'a, T, U4, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 4x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut4x3<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U3, ViewStorageMut<'a, T, U4, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 4x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut4x5<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U5, ViewStorageMut<'a, T, U4, U5, RStride, CStride>>;
|
||||||
|
/// A column-major 4x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut4x6<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U6, ViewStorageMut<'a, T, U4, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 5x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut5x1<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U1, ViewStorageMut<'a, T, U5, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 5x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut5x2<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U2, ViewStorageMut<'a, T, U5, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 5x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut5x3<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U3, ViewStorageMut<'a, T, U5, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 5x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut5x4<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U4, ViewStorageMut<'a, T, U5, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 5x6 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut5x6<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U6, ViewStorageMut<'a, T, U5, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major 6x1 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut6x1<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U1, ViewStorageMut<'a, T, U6, U1, RStride, CStride>>;
|
||||||
|
/// A column-major 6x2 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut6x2<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U2, ViewStorageMut<'a, T, U6, U2, RStride, CStride>>;
|
||||||
|
/// A column-major 6x3 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut6x3<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U3, ViewStorageMut<'a, T, U6, U3, RStride, CStride>>;
|
||||||
|
/// A column-major 6x4 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut6x4<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U4, ViewStorageMut<'a, T, U6, U4, RStride, CStride>>;
|
||||||
|
/// A column-major 6x5 matrix view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type MatrixViewMut6x5<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U5, ViewStorageMut<'a, T, U6, U5, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major matrix view with 1 row and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixViewMut1xX<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, Dyn, ViewStorageMut<'a, T, U1, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 2 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixViewMut2xX<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, Dyn, ViewStorageMut<'a, T, U2, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 3 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixViewMut3xX<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, Dyn, ViewStorageMut<'a, T, U3, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 4 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixViewMut4xX<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, Dyn, ViewStorageMut<'a, T, U4, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 5 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixViewMut5xX<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, Dyn, ViewStorageMut<'a, T, U5, Dyn, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with 6 rows and a number of columns chosen at runtime.
|
||||||
|
pub type MatrixViewMut6xX<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, Dyn, ViewStorageMut<'a, T, U6, Dyn, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 1 column.
|
||||||
|
pub type MatrixViewMutXx1<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U1, ViewStorageMut<'a, T, Dyn, U1, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 2 columns.
|
||||||
|
pub type MatrixViewMutXx2<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U2, ViewStorageMut<'a, T, Dyn, U2, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 3 columns.
|
||||||
|
pub type MatrixViewMutXx3<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U3, ViewStorageMut<'a, T, Dyn, U3, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 4 columns.
|
||||||
|
pub type MatrixViewMutXx4<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U4, ViewStorageMut<'a, T, Dyn, U4, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 5 columns.
|
||||||
|
pub type MatrixViewMutXx5<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U5, ViewStorageMut<'a, T, Dyn, U5, RStride, CStride>>;
|
||||||
|
/// A column-major matrix view with a number of rows chosen at runtime and 6 columns.
|
||||||
|
pub type MatrixViewMutXx6<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U6, ViewStorageMut<'a, T, Dyn, U6, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column vector view with dimensions known at compile-time.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorViewMut<'a, T, D, RStride = U1, CStride = D> =
|
||||||
|
Matrix<T, D, U1, ViewStorageMut<'a, T, D, U1, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A column vector view with dimensions known at compile-time.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type SVectorViewMut<'a, T, const D: usize> =
|
||||||
|
Matrix<T, Const<D>, Const<1>, ViewStorageMut<'a, T, Const<D>, Const<1>, Const<1>, Const<D>>>;
|
||||||
|
|
||||||
|
/// A column vector view dynamic numbers of rows and columns.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type DVectorViewMut<'a, T, RStride = U1, CStride = Dyn> =
|
||||||
|
Matrix<T, Dyn, U1, ViewStorageMut<'a, T, Dyn, U1, RStride, CStride>>;
|
||||||
|
|
||||||
|
/// A 1D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorViewMut1<'a, T, RStride = U1, CStride = U1> =
|
||||||
|
Matrix<T, U1, U1, ViewStorageMut<'a, T, U1, U1, RStride, CStride>>;
|
||||||
|
/// A 2D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorViewMut2<'a, T, RStride = U1, CStride = U2> =
|
||||||
|
Matrix<T, U2, U1, ViewStorageMut<'a, T, U2, U1, RStride, CStride>>;
|
||||||
|
/// A 3D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorViewMut3<'a, T, RStride = U1, CStride = U3> =
|
||||||
|
Matrix<T, U3, U1, ViewStorageMut<'a, T, U3, U1, RStride, CStride>>;
|
||||||
|
/// A 4D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorViewMut4<'a, T, RStride = U1, CStride = U4> =
|
||||||
|
Matrix<T, U4, U1, ViewStorageMut<'a, T, U4, U1, RStride, CStride>>;
|
||||||
|
/// A 5D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorViewMut5<'a, T, RStride = U1, CStride = U5> =
|
||||||
|
Matrix<T, U5, U1, ViewStorageMut<'a, T, U5, U1, RStride, CStride>>;
|
||||||
|
/// A 6D column vector view.
|
||||||
|
///
|
||||||
|
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||||
|
pub type VectorViewMut6<'a, T, RStride = U1, CStride = U6> =
|
||||||
|
Matrix<T, U6, U1, ViewStorageMut<'a, T, U6, U1, RStride, CStride>>;
|
|
@ -15,7 +15,7 @@ use std::mem::MaybeUninit;
|
||||||
///
|
///
|
||||||
/// An allocator is said to be:
|
/// An allocator is said to be:
|
||||||
/// − static: if `R` and `C` both implement `DimName`.
|
/// − static: if `R` and `C` both implement `DimName`.
|
||||||
/// − dynamic: if either one (or both) of `R` or `C` is equal to `Dynamic`.
|
/// − dynamic: if either one (or both) of `R` or `C` is equal to `Dyn`.
|
||||||
///
|
///
|
||||||
/// Every allocator must be both static and dynamic. Though not all implementations may share the
|
/// Every allocator must be both static and dynamic. Though not all implementations may share the
|
||||||
/// same `Buffer` type.
|
/// same `Buffer` type.
|
||||||
|
|
|
@ -27,11 +27,18 @@ use std::mem;
|
||||||
/// A array-based statically sized matrix data storage.
|
/// A array-based statically sized matrix data storage.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "ArrayStorage<T::Archived, R, C>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
[[T; R]; C]: rkyv::Archive<Archived = [[T::Archived; R]; C]>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
|
pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
|
||||||
|
|
||||||
|
|
|
@ -7,11 +7,11 @@ use crate::base::blas_uninit::{axcpy_uninit, gemm_uninit, gemv_uninit};
|
||||||
use crate::base::constraint::{
|
use crate::base::constraint::{
|
||||||
AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint,
|
AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint,
|
||||||
};
|
};
|
||||||
use crate::base::dimension::{Const, Dim, Dynamic, U1, U2, U3, U4};
|
use crate::base::dimension::{Const, Dim, Dyn, U1, U2, U3, U4};
|
||||||
use crate::base::storage::{Storage, StorageMut};
|
use crate::base::storage::{Storage, StorageMut};
|
||||||
use crate::base::uninit::Init;
|
use crate::base::uninit::Init;
|
||||||
use crate::base::{
|
use crate::base::{
|
||||||
DVectorSlice, DefaultAllocator, Matrix, Scalar, SquareMatrix, Vector, VectorSlice,
|
DVectorView, DefaultAllocator, Matrix, Scalar, SquareMatrix, Vector, VectorView,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// # Dot/scalar product
|
/// # Dot/scalar product
|
||||||
|
@ -363,8 +363,8 @@ where
|
||||||
x: &Vector<T, D3, SC>,
|
x: &Vector<T, D3, SC>,
|
||||||
beta: T,
|
beta: T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<'_, T, SB::RStride, SB::CStride>,
|
&DVectorView<'_, T, SB::RStride, SB::CStride>,
|
||||||
&DVectorSlice<'_, T, SC::RStride, SC::CStride>,
|
&DVectorView<'_, T, SC::RStride, SC::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) where
|
) where
|
||||||
T: One,
|
T: One,
|
||||||
|
@ -393,7 +393,7 @@ where
|
||||||
let col2 = a.column(0);
|
let col2 = a.column(0);
|
||||||
let val = unsafe { x.vget_unchecked(0).clone() };
|
let val = unsafe { x.vget_unchecked(0).clone() };
|
||||||
self.axpy(alpha.clone() * val, &col2, beta);
|
self.axpy(alpha.clone() * val, &col2, beta);
|
||||||
self[0] += alpha.clone() * dot(&a.slice_range(1.., 0), &x.rows_range(1..));
|
self[0] += alpha.clone() * dot(&a.view_range(1.., 0), &x.rows_range(1..));
|
||||||
|
|
||||||
for j in 1..dim2 {
|
for j in 1..dim2 {
|
||||||
let col2 = a.column(j);
|
let col2 = a.column(j);
|
||||||
|
@ -506,7 +506,7 @@ where
|
||||||
a: &Matrix<T, R2, C2, SB>,
|
a: &Matrix<T, R2, C2, SB>,
|
||||||
x: &Vector<T, D3, SC>,
|
x: &Vector<T, D3, SC>,
|
||||||
beta: T,
|
beta: T,
|
||||||
dot: impl Fn(&VectorSlice<'_, T, R2, SB::RStride, SB::CStride>, &Vector<T, D3, SC>) -> T,
|
dot: impl Fn(&VectorView<'_, T, R2, SB::RStride, SB::CStride>, &Vector<T, D3, SC>) -> T,
|
||||||
) where
|
) where
|
||||||
T: One,
|
T: One,
|
||||||
SB: Storage<T, R2, C2>,
|
SB: Storage<T, R2, C2>,
|
||||||
|
@ -890,9 +890,9 @@ where
|
||||||
|
|
||||||
for j in 0..dim1 {
|
for j in 0..dim1 {
|
||||||
let val = unsafe { conjugate(y.vget_unchecked(j).clone()) };
|
let val = unsafe { conjugate(y.vget_unchecked(j).clone()) };
|
||||||
let subdim = Dynamic::new(dim1 - j);
|
let subdim = Dyn(dim1 - j);
|
||||||
// TODO: avoid bound checks.
|
// TODO: avoid bound checks.
|
||||||
self.generic_slice_mut((j, j), (subdim, Const::<1>)).axpy(
|
self.generic_view_mut((j, j), (subdim, Const::<1>)).axpy(
|
||||||
alpha.clone() * val,
|
alpha.clone() * val,
|
||||||
&x.rows_range(j..),
|
&x.rows_range(j..),
|
||||||
beta.clone(),
|
beta.clone(),
|
||||||
|
|
|
@ -18,7 +18,7 @@ use std::mem;
|
||||||
use crate::base::constraint::{
|
use crate::base::constraint::{
|
||||||
AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint,
|
AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint,
|
||||||
};
|
};
|
||||||
use crate::base::dimension::{Dim, Dynamic, U1};
|
use crate::base::dimension::{Dim, Dyn, U1};
|
||||||
use crate::base::storage::{RawStorage, RawStorageMut};
|
use crate::base::storage::{RawStorage, RawStorageMut};
|
||||||
use crate::base::uninit::InitStatus;
|
use crate::base::uninit::InitStatus;
|
||||||
use crate::base::{Matrix, Scalar, Vector};
|
use crate::base::{Matrix, Scalar, Vector};
|
||||||
|
@ -209,16 +209,16 @@ pub unsafe fn gemm_uninit<
|
||||||
|
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
{
|
{
|
||||||
// We assume large matrices will be Dynamic but small matrices static.
|
// We assume large matrices will be Dyn but small matrices static.
|
||||||
// We could use matrixmultiply for large statically-sized matrices but the performance
|
// We could use matrixmultiply for large statically-sized matrices but the performance
|
||||||
// threshold to activate it would be different from SMALL_DIM because our code optimizes
|
// threshold to activate it would be different from SMALL_DIM because our code optimizes
|
||||||
// better for statically-sized matrices.
|
// better for statically-sized matrices.
|
||||||
if R1::is::<Dynamic>()
|
if R1::is::<Dyn>()
|
||||||
|| C1::is::<Dynamic>()
|
|| C1::is::<Dyn>()
|
||||||
|| R2::is::<Dynamic>()
|
|| R2::is::<Dyn>()
|
||||||
|| C2::is::<Dynamic>()
|
|| C2::is::<Dyn>()
|
||||||
|| R3::is::<Dynamic>()
|
|| R3::is::<Dyn>()
|
||||||
|| C3::is::<Dynamic>()
|
|| C3::is::<Dyn>()
|
||||||
{
|
{
|
||||||
// matrixmultiply can be used only if the std feature is available.
|
// matrixmultiply can be used only if the std feature is available.
|
||||||
let nrows1 = y.nrows();
|
let nrows1 = y.nrows();
|
||||||
|
|
|
@ -59,7 +59,7 @@ where
|
||||||
SB: Storage<T, DimNameDiff<D, U1>>,
|
SB: Storage<T, DimNameDiff<D, U1>>,
|
||||||
{
|
{
|
||||||
let mut res = Self::identity();
|
let mut res = Self::identity();
|
||||||
res.generic_slice_mut(
|
res.generic_view_mut(
|
||||||
(0, D::dim() - 1),
|
(0, D::dim() - 1),
|
||||||
(DimNameDiff::<D, U1>::name(), Const::<1>),
|
(DimNameDiff::<D, U1>::name(), Const::<1>),
|
||||||
)
|
)
|
||||||
|
@ -382,19 +382,19 @@ impl<T: Scalar + Zero + One + ClosedMul + ClosedAdd, D: DimName, S: Storage<T, D
|
||||||
DefaultAllocator: Allocator<T, DimNameDiff<D, U1>>,
|
DefaultAllocator: Allocator<T, DimNameDiff<D, U1>>,
|
||||||
{
|
{
|
||||||
let scale = self
|
let scale = self
|
||||||
.generic_slice(
|
.generic_view(
|
||||||
(D::dim() - 1, 0),
|
(D::dim() - 1, 0),
|
||||||
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
||||||
)
|
)
|
||||||
.tr_dot(shift);
|
.tr_dot(shift);
|
||||||
let post_translation = self.generic_slice(
|
let post_translation = self.generic_view(
|
||||||
(0, 0),
|
(0, 0),
|
||||||
(DimNameDiff::<D, U1>::name(), DimNameDiff::<D, U1>::name()),
|
(DimNameDiff::<D, U1>::name(), DimNameDiff::<D, U1>::name()),
|
||||||
) * shift;
|
) * shift;
|
||||||
|
|
||||||
self[(D::dim() - 1, D::dim() - 1)] += scale;
|
self[(D::dim() - 1, D::dim() - 1)] += scale;
|
||||||
|
|
||||||
let mut translation = self.generic_slice_mut(
|
let mut translation = self.generic_view_mut(
|
||||||
(0, D::dim() - 1),
|
(0, D::dim() - 1),
|
||||||
(DimNameDiff::<D, U1>::name(), Const::<1>),
|
(DimNameDiff::<D, U1>::name(), Const::<1>),
|
||||||
);
|
);
|
||||||
|
@ -415,11 +415,11 @@ where
|
||||||
&self,
|
&self,
|
||||||
v: &OVector<T, DimNameDiff<D, U1>>,
|
v: &OVector<T, DimNameDiff<D, U1>>,
|
||||||
) -> OVector<T, DimNameDiff<D, U1>> {
|
) -> OVector<T, DimNameDiff<D, U1>> {
|
||||||
let transform = self.generic_slice(
|
let transform = self.generic_view(
|
||||||
(0, 0),
|
(0, 0),
|
||||||
(DimNameDiff::<D, U1>::name(), DimNameDiff::<D, U1>::name()),
|
(DimNameDiff::<D, U1>::name(), DimNameDiff::<D, U1>::name()),
|
||||||
);
|
);
|
||||||
let normalizer = self.generic_slice(
|
let normalizer = self.generic_view(
|
||||||
(D::dim() - 1, 0),
|
(D::dim() - 1, 0),
|
||||||
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
||||||
);
|
);
|
||||||
|
@ -437,9 +437,9 @@ impl<T: RealField, S: Storage<T, Const<3>, Const<3>>> SquareMatrix<T, Const<3>,
|
||||||
/// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates.
|
/// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn transform_point(&self, pt: &Point<T, 2>) -> Point<T, 2> {
|
pub fn transform_point(&self, pt: &Point<T, 2>) -> Point<T, 2> {
|
||||||
let transform = self.fixed_slice::<2, 2>(0, 0);
|
let transform = self.fixed_view::<2, 2>(0, 0);
|
||||||
let translation = self.fixed_slice::<2, 1>(0, 2);
|
let translation = self.fixed_view::<2, 1>(0, 2);
|
||||||
let normalizer = self.fixed_slice::<1, 2>(2, 0);
|
let normalizer = self.fixed_view::<1, 2>(2, 0);
|
||||||
let n = normalizer.tr_dot(&pt.coords) + unsafe { self.get_unchecked((2, 2)).clone() };
|
let n = normalizer.tr_dot(&pt.coords) + unsafe { self.get_unchecked((2, 2)).clone() };
|
||||||
|
|
||||||
if !n.is_zero() {
|
if !n.is_zero() {
|
||||||
|
@ -454,9 +454,9 @@ impl<T: RealField, S: Storage<T, Const<4>, Const<4>>> SquareMatrix<T, Const<4>,
|
||||||
/// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates.
|
/// Transforms the given point, assuming the matrix `self` uses homogeneous coordinates.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn transform_point(&self, pt: &Point<T, 3>) -> Point<T, 3> {
|
pub fn transform_point(&self, pt: &Point<T, 3>) -> Point<T, 3> {
|
||||||
let transform = self.fixed_slice::<3, 3>(0, 0);
|
let transform = self.fixed_view::<3, 3>(0, 0);
|
||||||
let translation = self.fixed_slice::<3, 1>(0, 3);
|
let translation = self.fixed_view::<3, 1>(0, 3);
|
||||||
let normalizer = self.fixed_slice::<1, 3>(3, 0);
|
let normalizer = self.fixed_view::<1, 3>(3, 0);
|
||||||
let n = normalizer.tr_dot(&pt.coords) + unsafe { self.get_unchecked((3, 3)).clone() };
|
let n = normalizer.tr_dot(&pt.coords) + unsafe { self.get_unchecked((3, 3)).clone() };
|
||||||
|
|
||||||
if !n.is_zero() {
|
if !n.is_zero() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//! Compatibility constraints between matrix shapes, e.g., for addition or multiplication.
|
//! Compatibility constraints between matrix shapes, e.g., for addition or multiplication.
|
||||||
|
|
||||||
use crate::base::dimension::{Dim, DimName, Dynamic};
|
use crate::base::dimension::{Dim, DimName, Dyn};
|
||||||
|
|
||||||
/// A type used in `where` clauses for enforcing constraints.
|
/// A type used in `where` clauses for enforcing constraints.
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
@ -25,11 +25,11 @@ impl<D: Dim> DimEq<D, D> for ShapeConstraint {
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: DimName> DimEq<D, Dynamic> for ShapeConstraint {
|
impl<D: DimName> DimEq<D, Dyn> for ShapeConstraint {
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: DimName> DimEq<Dynamic, D> for ShapeConstraint {
|
impl<D: DimName> DimEq<Dyn, D> for ShapeConstraint {
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,11 +47,11 @@ macro_rules! equality_trait_decl(
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: DimName> $Trait<D, Dynamic> for ShapeConstraint {
|
impl<D: DimName> $Trait<D, Dyn> for ShapeConstraint {
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: DimName> $Trait<Dynamic, D> for ShapeConstraint {
|
impl<D: DimName> $Trait<Dyn, D> for ShapeConstraint {
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
)*}
|
)*}
|
||||||
|
@ -82,10 +82,10 @@ impl<D: Dim> SameDimension<D, D> for ShapeConstraint {
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: DimName> SameDimension<D, Dynamic> for ShapeConstraint {
|
impl<D: DimName> SameDimension<D, Dyn> for ShapeConstraint {
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: DimName> SameDimension<Dynamic, D> for ShapeConstraint {
|
impl<D: DimName> SameDimension<Dyn, D> for ShapeConstraint {
|
||||||
type Representative = D;
|
type Representative = D;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ use typenum::{self, Cmp, Greater};
|
||||||
use simba::scalar::{ClosedAdd, ClosedMul};
|
use simba::scalar::{ClosedAdd, ClosedMul};
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{Dim, DimName, Dynamic, ToTypenum};
|
use crate::base::dimension::{Dim, DimName, Dyn, ToTypenum};
|
||||||
use crate::base::storage::RawStorage;
|
use crate::base::storage::RawStorage;
|
||||||
use crate::base::{
|
use crate::base::{
|
||||||
ArrayStorage, Const, DefaultAllocator, Matrix, OMatrix, OVector, Scalar, Unit, Vector,
|
ArrayStorage, Const, DefaultAllocator, Matrix, OMatrix, OVector, Scalar, Unit, Vector,
|
||||||
|
@ -317,12 +317,12 @@ where
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// # use nalgebra::{Dynamic, DMatrix, Matrix, Const};
|
/// # use nalgebra::{Dyn, DMatrix, Matrix, Const};
|
||||||
///
|
///
|
||||||
/// let vec = vec![0, 1, 2, 3, 4, 5];
|
/// let vec = vec![0, 1, 2, 3, 4, 5];
|
||||||
/// let vec_ptr = vec.as_ptr();
|
/// let vec_ptr = vec.as_ptr();
|
||||||
///
|
///
|
||||||
/// let matrix = Matrix::from_vec_generic(Dynamic::new(vec.len()), Const::<1>, vec);
|
/// let matrix = Matrix::from_vec_generic(Dyn(vec.len()), Const::<1>, vec);
|
||||||
/// let matrix_storage_ptr = matrix.data.as_vec().as_ptr();
|
/// let matrix_storage_ptr = matrix.data.as_vec().as_ptr();
|
||||||
///
|
///
|
||||||
/// // `matrix` is backed by exactly the same `Vec` as it was constructed from.
|
/// // `matrix` is backed by exactly the same `Vec` as it was constructed from.
|
||||||
|
@ -656,35 +656,35 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Constructors of matrices with a dynamic number of columns
|
/// # Constructors of matrices with a dynamic number of columns
|
||||||
impl<T: Scalar, R: DimName> OMatrix<T, R, Dynamic>
|
impl<T: Scalar, R: DimName> OMatrix<T, R, Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, R, Dynamic>,
|
DefaultAllocator: Allocator<T, R, Dyn>,
|
||||||
{
|
{
|
||||||
impl_constructors!(R, Dynamic;
|
impl_constructors!(R, Dyn;
|
||||||
=> R: DimName;
|
=> R: DimName;
|
||||||
R::name(), Dynamic::new(ncols);
|
R::name(), Dyn(ncols);
|
||||||
ncols);
|
ncols);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Constructors of dynamic vectors and matrices with a dynamic number of rows
|
/// # Constructors of dynamic vectors and matrices with a dynamic number of rows
|
||||||
impl<T: Scalar, C: DimName> OMatrix<T, Dynamic, C>
|
impl<T: Scalar, C: DimName> OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C>,
|
DefaultAllocator: Allocator<T, Dyn, C>,
|
||||||
{
|
{
|
||||||
impl_constructors!(Dynamic, C;
|
impl_constructors!(Dyn, C;
|
||||||
=> C: DimName;
|
=> C: DimName;
|
||||||
Dynamic::new(nrows), C::name();
|
Dyn(nrows), C::name();
|
||||||
nrows);
|
nrows);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Constructors of fully dynamic matrices
|
/// # Constructors of fully dynamic matrices
|
||||||
impl<T: Scalar> OMatrix<T, Dynamic, Dynamic>
|
impl<T: Scalar> OMatrix<T, Dyn, Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, Dynamic, Dynamic>,
|
DefaultAllocator: Allocator<T, Dyn, Dyn>,
|
||||||
{
|
{
|
||||||
impl_constructors!(Dynamic, Dynamic;
|
impl_constructors!(Dyn, Dyn;
|
||||||
;
|
;
|
||||||
Dynamic::new(nrows), Dynamic::new(ncols);
|
Dyn(nrows), Dyn(ncols);
|
||||||
nrows, ncols);
|
nrows, ncols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -790,19 +790,19 @@ impl_constructors_from_data!(data; R, C; // Arguments for Matri
|
||||||
R::name(), C::name(); // Arguments for `_generic` constructors.
|
R::name(), C::name(); // Arguments for `_generic` constructors.
|
||||||
); // Arguments for non-generic constructors.
|
); // Arguments for non-generic constructors.
|
||||||
|
|
||||||
impl_constructors_from_data!(data; R, Dynamic;
|
impl_constructors_from_data!(data; R, Dyn;
|
||||||
=> R: DimName;
|
=> R: DimName;
|
||||||
R::name(), Dynamic::new(data.len() / R::dim());
|
R::name(), Dyn(data.len() / R::dim());
|
||||||
);
|
);
|
||||||
|
|
||||||
impl_constructors_from_data!(data; Dynamic, C;
|
impl_constructors_from_data!(data; Dyn, C;
|
||||||
=> C: DimName;
|
=> C: DimName;
|
||||||
Dynamic::new(data.len() / C::dim()), C::name();
|
Dyn(data.len() / C::dim()), C::name();
|
||||||
);
|
);
|
||||||
|
|
||||||
impl_constructors_from_data!(data; Dynamic, Dynamic;
|
impl_constructors_from_data!(data; Dyn, Dyn;
|
||||||
;
|
;
|
||||||
Dynamic::new(nrows), Dynamic::new(ncols);
|
Dyn(nrows), Dyn(ncols);
|
||||||
nrows, ncols);
|
nrows, ncols);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
use crate::base::dimension::{Const, Dim, DimName, Dynamic};
|
use crate::base::dimension::{Const, Dim, DimName, Dyn};
|
||||||
use crate::base::matrix_slice::{SliceStorage, SliceStorageMut};
|
use crate::base::matrix_view::{ViewStorage, ViewStorageMut};
|
||||||
use crate::base::{MatrixSlice, MatrixSliceMutMN, Scalar};
|
use crate::base::{MatrixView, MatrixViewMut, Scalar};
|
||||||
|
|
||||||
use num_rational::Ratio;
|
use num_rational::Ratio;
|
||||||
|
|
||||||
/// # Creating matrix slices from `&[T]`
|
/// # Creating matrix views from `&[T]`
|
||||||
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
MatrixSlice<'a, T, R, C, RStride, CStride>
|
MatrixView<'a, T, R, C, RStride, CStride>
|
||||||
{
|
{
|
||||||
/// Creates, without bound-checking, a matrix slice from an array and with dimensions and strides specified by generic types instances.
|
/// Creates, without bounds checking, a matrix view from an array and with dimensions and strides specified by generic types instances.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||||
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dyn()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_slice_with_strides_generic_unchecked(
|
pub unsafe fn from_slice_with_strides_generic_unchecked(
|
||||||
data: &'a [T],
|
data: &'a [T],
|
||||||
|
@ -22,7 +22,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
rstride: RStride,
|
rstride: RStride,
|
||||||
cstride: CStride,
|
cstride: CStride,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let data = SliceStorage::from_raw_parts(
|
let data = ViewStorage::from_raw_parts(
|
||||||
data.as_ptr().add(start),
|
data.as_ptr().add(start),
|
||||||
(nrows, ncols),
|
(nrows, ncols),
|
||||||
(rstride, cstride),
|
(rstride, cstride),
|
||||||
|
@ -30,10 +30,10 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
Self::from_data(data)
|
Self::from_data(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a matrix slice from an array and with dimensions and strides specified by generic types instances.
|
/// Creates a matrix view from an array and with dimensions and strides specified by generic types instances.
|
||||||
///
|
///
|
||||||
/// Panics if the input data array dose not contain enough elements.
|
/// Panics if the input data array dose not contain enough elements.
|
||||||
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dyn()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_slice_with_strides_generic(
|
pub fn from_slice_with_strides_generic(
|
||||||
data: &'a [T],
|
data: &'a [T],
|
||||||
|
@ -48,7 +48,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
assert!(
|
assert!(
|
||||||
data.len() + cstride.value() + rstride.value()
|
data.len() + cstride.value() + rstride.value()
|
||||||
>= ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
>= ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
||||||
"Matrix slice: input data buffer to small."
|
"Matrix view: input data buffer too small."
|
||||||
);
|
);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -57,12 +57,12 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSlice<'a, T, R, C> {
|
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixView<'a, T, R, C> {
|
||||||
/// Creates, without bound-checking, a matrix slice from an array and with dimensions specified by generic types instances.
|
/// Creates, without bound-checking, a matrix view from an array and with dimensions specified by generic types instances.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||||
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dyn()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_slice_generic_unchecked(
|
pub unsafe fn from_slice_generic_unchecked(
|
||||||
data: &'a [T],
|
data: &'a [T],
|
||||||
|
@ -75,10 +75,10 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSlice<'a, T, R, C> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a matrix slice from an array and with dimensions and strides specified by generic types instances.
|
/// Creates a matrix view from an array and with dimensions and strides specified by generic types instances.
|
||||||
///
|
///
|
||||||
/// Panics if the input data array dose not contain enough elements.
|
/// Panics if the input data array dose not contain enough elements.
|
||||||
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dyn()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_slice_generic(data: &'a [T], nrows: R, ncols: C) -> Self {
|
pub fn from_slice_generic(data: &'a [T], nrows: R, ncols: C) -> Self {
|
||||||
Self::from_slice_with_strides_generic(data, nrows, ncols, Const::<1>, nrows)
|
Self::from_slice_with_strides_generic(data, nrows, ncols, Const::<1>, nrows)
|
||||||
|
@ -87,8 +87,8 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSlice<'a, T, R, C> {
|
||||||
|
|
||||||
macro_rules! impl_constructors(
|
macro_rules! impl_constructors(
|
||||||
($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => {
|
($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => {
|
||||||
impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixSlice<'a, T, $($Dims),*> {
|
impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixView<'a, T, $($Dims),*> {
|
||||||
/// Creates a new matrix slice from the given data array.
|
/// Creates a new matrix view from the given data array.
|
||||||
///
|
///
|
||||||
/// Panics if `data` does not contain enough elements.
|
/// Panics if `data` does not contain enough elements.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -96,26 +96,26 @@ macro_rules! impl_constructors(
|
||||||
Self::from_slice_generic(data, $($gargs),*)
|
Self::from_slice_generic(data, $($gargs),*)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates, without bound checking, a new matrix slice from the given data array.
|
/// Creates, without bound checking, a new matrix view from the given data array.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_slice_unchecked(data: &'a [T], start: usize, $($args: usize),*) -> Self {
|
pub unsafe fn from_slice_unchecked(data: &'a [T], start: usize, $($args: usize),*) -> Self {
|
||||||
Self::from_slice_generic_unchecked(data, start, $($gargs),*)
|
Self::from_slice_generic_unchecked(data, start, $($gargs),*)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixSlice<'a, T, $($Dims,)* Dynamic, Dynamic> {
|
impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixView<'a, T, $($Dims,)* Dyn, Dyn> {
|
||||||
/// Creates a new matrix slice with the specified strides from the given data array.
|
/// Creates a new matrix view with the specified strides from the given data array.
|
||||||
///
|
///
|
||||||
/// Panics if `data` does not contain enough elements.
|
/// Panics if `data` does not contain enough elements.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_slice_with_strides(data: &'a [T], $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
pub fn from_slice_with_strides(data: &'a [T], $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
||||||
Self::from_slice_with_strides_generic(data, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride))
|
Self::from_slice_with_strides_generic(data, $($gargs,)* Dyn(rstride), Dyn(cstride))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates, without bound checking, a new matrix slice with the specified strides from the given data array.
|
/// Creates, without bound checking, a new matrix view with the specified strides from the given data array.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_slice_with_strides_unchecked(data: &'a [T], start: usize, $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
pub unsafe fn from_slice_with_strides_unchecked(data: &'a [T], start: usize, $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
||||||
Self::from_slice_with_strides_generic_unchecked(data, start, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride))
|
Self::from_slice_with_strides_generic_unchecked(data, start, $($gargs,)* Dyn(rstride), Dyn(cstride))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,30 +127,30 @@ impl_constructors!(R, C; // Arguments for Matrix<T, ...,
|
||||||
R::name(), C::name(); // Arguments for `_generic` constructors.
|
R::name(), C::name(); // Arguments for `_generic` constructors.
|
||||||
); // Arguments for non-generic constructors.
|
); // Arguments for non-generic constructors.
|
||||||
|
|
||||||
impl_constructors!(R, Dynamic;
|
impl_constructors!(R, Dyn;
|
||||||
=> R: DimName;
|
=> R: DimName;
|
||||||
R::name(), Dynamic::new(ncols);
|
R::name(), Dyn(ncols);
|
||||||
ncols);
|
ncols);
|
||||||
|
|
||||||
impl_constructors!(Dynamic, C;
|
impl_constructors!(Dyn, C;
|
||||||
=> C: DimName;
|
=> C: DimName;
|
||||||
Dynamic::new(nrows), C::name();
|
Dyn(nrows), C::name();
|
||||||
nrows);
|
nrows);
|
||||||
|
|
||||||
impl_constructors!(Dynamic, Dynamic;
|
impl_constructors!(Dyn, Dyn;
|
||||||
;
|
;
|
||||||
Dynamic::new(nrows), Dynamic::new(ncols);
|
Dyn(nrows), Dyn(ncols);
|
||||||
nrows, ncols);
|
nrows, ncols);
|
||||||
|
|
||||||
/// # Creating mutable matrix slices from `&mut [T]`
|
/// # Creating mutable matrix views from `&mut [T]`
|
||||||
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
MatrixSliceMutMN<'a, T, R, C, RStride, CStride>
|
MatrixViewMut<'a, T, R, C, RStride, CStride>
|
||||||
{
|
{
|
||||||
/// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions and strides specified by generic types instances.
|
/// Creates, without bound-checking, a mutable matrix view from an array and with dimensions and strides specified by generic types instances.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||||
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dyn()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_slice_with_strides_generic_unchecked(
|
pub unsafe fn from_slice_with_strides_generic_unchecked(
|
||||||
data: &'a mut [T],
|
data: &'a mut [T],
|
||||||
|
@ -160,7 +160,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
rstride: RStride,
|
rstride: RStride,
|
||||||
cstride: CStride,
|
cstride: CStride,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let data = SliceStorageMut::from_raw_parts(
|
let data = ViewStorageMut::from_raw_parts(
|
||||||
data.as_mut_ptr().add(start),
|
data.as_mut_ptr().add(start),
|
||||||
(nrows, ncols),
|
(nrows, ncols),
|
||||||
(rstride, cstride),
|
(rstride, cstride),
|
||||||
|
@ -168,10 +168,10 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
Self::from_data(data)
|
Self::from_data(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a mutable matrix slice from an array and with dimensions and strides specified by generic types instances.
|
/// Creates a mutable matrix view from an array and with dimensions and strides specified by generic types instances.
|
||||||
///
|
///
|
||||||
/// Panics if the input data array dose not contain enough elements.
|
/// Panics if the input data array dose not contain enough elements.
|
||||||
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dyn()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_slice_with_strides_generic(
|
pub fn from_slice_with_strides_generic(
|
||||||
data: &'a mut [T],
|
data: &'a mut [T],
|
||||||
|
@ -186,7 +186,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
assert!(
|
assert!(
|
||||||
data.len() + cstride.value() + rstride.value()
|
data.len() + cstride.value() + rstride.value()
|
||||||
>= ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
>= ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
||||||
"Matrix slice: input data buffer to small."
|
"Matrix view: input data buffer too small."
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
|
@ -208,7 +208,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"Matrix slice: dimensions and strides result in aliased indices."
|
"Matrix view: dimensions and strides result in aliased indices."
|
||||||
);
|
);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -217,12 +217,12 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, T, R, C> {
|
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixViewMut<'a, T, R, C> {
|
||||||
/// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions specified by generic types instances.
|
/// Creates, without bound-checking, a mutable matrix view from an array and with dimensions specified by generic types instances.
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||||
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dyn()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_slice_generic_unchecked(
|
pub unsafe fn from_slice_generic_unchecked(
|
||||||
data: &'a mut [T],
|
data: &'a mut [T],
|
||||||
|
@ -235,10 +235,10 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, T, R, C> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a mutable matrix slice from an array and with dimensions and strides specified by generic types instances.
|
/// Creates a mutable matrix view from an array and with dimensions and strides specified by generic types instances.
|
||||||
///
|
///
|
||||||
/// Panics if the input data array dose not contain enough elements.
|
/// Panics if the input data array dose not contain enough elements.
|
||||||
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dyn()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_slice_generic(data: &'a mut [T], nrows: R, ncols: C) -> Self {
|
pub fn from_slice_generic(data: &'a mut [T], nrows: R, ncols: C) -> Self {
|
||||||
Self::from_slice_with_strides_generic(data, nrows, ncols, Const::<1>, nrows)
|
Self::from_slice_with_strides_generic(data, nrows, ncols, Const::<1>, nrows)
|
||||||
|
@ -247,8 +247,8 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, T, R, C> {
|
||||||
|
|
||||||
macro_rules! impl_constructors_mut(
|
macro_rules! impl_constructors_mut(
|
||||||
($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => {
|
($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => {
|
||||||
impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixSliceMutMN<'a, T, $($Dims),*> {
|
impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixViewMut<'a, T, $($Dims),*> {
|
||||||
/// Creates a new mutable matrix slice from the given data array.
|
/// Creates a new mutable matrix view from the given data array.
|
||||||
///
|
///
|
||||||
/// Panics if `data` does not contain enough elements.
|
/// Panics if `data` does not contain enough elements.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -256,28 +256,28 @@ macro_rules! impl_constructors_mut(
|
||||||
Self::from_slice_generic(data, $($gargs),*)
|
Self::from_slice_generic(data, $($gargs),*)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates, without bound checking, a new mutable matrix slice from the given data array.
|
/// Creates, without bound checking, a new mutable matrix view from the given data array.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_slice_unchecked(data: &'a mut [T], start: usize, $($args: usize),*) -> Self {
|
pub unsafe fn from_slice_unchecked(data: &'a mut [T], start: usize, $($args: usize),*) -> Self {
|
||||||
Self::from_slice_generic_unchecked(data, start, $($gargs),*)
|
Self::from_slice_generic_unchecked(data, start, $($gargs),*)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixSliceMutMN<'a, T, $($Dims,)* Dynamic, Dynamic> {
|
impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixViewMut<'a, T, $($Dims,)* Dyn, Dyn> {
|
||||||
/// Creates a new mutable matrix slice with the specified strides from the given data array.
|
/// Creates a new mutable matrix view with the specified strides from the given data array.
|
||||||
///
|
///
|
||||||
/// Panics if `data` does not contain enough elements.
|
/// Panics if `data` does not contain enough elements.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_slice_with_strides_mut(data: &'a mut [T], $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
pub fn from_slice_with_strides_mut(data: &'a mut [T], $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
||||||
Self::from_slice_with_strides_generic(
|
Self::from_slice_with_strides_generic(
|
||||||
data, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride))
|
data, $($gargs,)* Dyn(rstride), Dyn(cstride))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates, without bound checking, a new mutable matrix slice with the specified strides from the given data array.
|
/// Creates, without bound checking, a new mutable matrix view with the specified strides from the given data array.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn from_slice_with_strides_unchecked(data: &'a mut [T], start: usize, $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
pub unsafe fn from_slice_with_strides_unchecked(data: &'a mut [T], start: usize, $($args: usize,)* rstride: usize, cstride: usize) -> Self {
|
||||||
Self::from_slice_with_strides_generic_unchecked(
|
Self::from_slice_with_strides_generic_unchecked(
|
||||||
data, start, $($gargs,)* Dynamic::new(rstride), Dynamic::new(cstride))
|
data, start, $($gargs,)* Dyn(rstride), Dyn(cstride))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,17 +289,17 @@ impl_constructors_mut!(R, C; // Arguments for Matrix<T,
|
||||||
R::name(), C::name(); // Arguments for `_generic` constructors.
|
R::name(), C::name(); // Arguments for `_generic` constructors.
|
||||||
); // Arguments for non-generic constructors.
|
); // Arguments for non-generic constructors.
|
||||||
|
|
||||||
impl_constructors_mut!(R, Dynamic;
|
impl_constructors_mut!(R, Dyn;
|
||||||
=> R: DimName;
|
=> R: DimName;
|
||||||
R::name(), Dynamic::new(ncols);
|
R::name(), Dyn(ncols);
|
||||||
ncols);
|
ncols);
|
||||||
|
|
||||||
impl_constructors_mut!(Dynamic, C;
|
impl_constructors_mut!(Dyn, C;
|
||||||
=> C: DimName;
|
=> C: DimName;
|
||||||
Dynamic::new(nrows), C::name();
|
Dyn(nrows), C::name();
|
||||||
nrows);
|
nrows);
|
||||||
|
|
||||||
impl_constructors_mut!(Dynamic, Dynamic;
|
impl_constructors_mut!(Dyn, Dyn;
|
||||||
;
|
;
|
||||||
Dynamic::new(nrows), Dynamic::new(ncols);
|
Dyn(nrows), Dyn(ncols);
|
||||||
nrows, ncols);
|
nrows, ncols);
|
|
@ -9,21 +9,21 @@ use simba::simd::{PrimitiveSimdValue, SimdValue};
|
||||||
use crate::base::allocator::{Allocator, SameShapeAllocator};
|
use crate::base::allocator::{Allocator, SameShapeAllocator};
|
||||||
use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
|
use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use crate::base::dimension::Dynamic;
|
use crate::base::dimension::Dyn;
|
||||||
use crate::base::dimension::{
|
use crate::base::dimension::{
|
||||||
Const, Dim, DimName, U1, U10, U11, U12, U13, U14, U15, U16, U2, U3, U4, U5, U6, U7, U8, U9,
|
Const, Dim, DimName, U1, U10, U11, U12, U13, U14, U15, U16, U2, U3, U4, U5, U6, U7, U8, U9,
|
||||||
};
|
};
|
||||||
use crate::base::iter::{MatrixIter, MatrixIterMut};
|
use crate::base::iter::{MatrixIter, MatrixIterMut};
|
||||||
use crate::base::storage::{IsContiguous, RawStorage, RawStorageMut};
|
use crate::base::storage::{IsContiguous, RawStorage, RawStorageMut};
|
||||||
use crate::base::{
|
use crate::base::{
|
||||||
ArrayStorage, DVectorSlice, DVectorSliceMut, DefaultAllocator, Matrix, MatrixSlice,
|
ArrayStorage, DVectorView, DVectorViewMut, DefaultAllocator, Matrix, MatrixView, MatrixViewMut,
|
||||||
MatrixSliceMut, OMatrix, Scalar,
|
OMatrix, Scalar,
|
||||||
};
|
};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use crate::base::{DVector, RowDVector, VecStorage};
|
use crate::base::{DVector, RowDVector, VecStorage};
|
||||||
use crate::base::{SliceStorage, SliceStorageMut};
|
use crate::base::{ViewStorage, ViewStorageMut};
|
||||||
use crate::constraint::DimEq;
|
use crate::constraint::DimEq;
|
||||||
use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector, VectorSlice, VectorSliceMut};
|
use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector, VectorView, VectorViewMut};
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
|
|
||||||
// TODO: too bad this won't work for slice conversions.
|
// TODO: too bad this won't work for slice conversions.
|
||||||
|
@ -126,19 +126,19 @@ impl<T: Scalar, const D: usize> From<SVector<T, D>> for [T; D] {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const D: usize>
|
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const D: usize>
|
||||||
From<VectorSlice<'a, T, Const<D>, RStride, CStride>> for [T; D]
|
From<VectorView<'a, T, Const<D>, RStride, CStride>> for [T; D]
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(vec: VectorSlice<'a, T, Const<D>, RStride, CStride>) -> Self {
|
fn from(vec: VectorView<'a, T, Const<D>, RStride, CStride>) -> Self {
|
||||||
vec.into_owned().into()
|
vec.into_owned().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const D: usize>
|
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const D: usize>
|
||||||
From<VectorSliceMut<'a, T, Const<D>, RStride, CStride>> for [T; D]
|
From<VectorViewMut<'a, T, Const<D>, RStride, CStride>> for [T; D]
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(vec: VectorSliceMut<'a, T, Const<D>, RStride, CStride>) -> Self {
|
fn from(vec: VectorViewMut<'a, T, Const<D>, RStride, CStride>) -> Self {
|
||||||
vec.into_owned().into()
|
vec.into_owned().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -221,19 +221,19 @@ impl<T: Scalar, const R: usize, const C: usize> From<SMatrix<T, R, C>> for [[T;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const R: usize, const C: usize>
|
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const R: usize, const C: usize>
|
||||||
From<MatrixSlice<'a, T, Const<R>, Const<C>, RStride, CStride>> for [[T; R]; C]
|
From<MatrixView<'a, T, Const<R>, Const<C>, RStride, CStride>> for [[T; R]; C]
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(mat: MatrixSlice<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
fn from(mat: MatrixView<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||||
mat.into_owned().into()
|
mat.into_owned().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const R: usize, const C: usize>
|
impl<'a, T: Scalar, RStride: Dim, CStride: Dim, const R: usize, const C: usize>
|
||||||
From<MatrixSliceMut<'a, T, Const<R>, Const<C>, RStride, CStride>> for [[T; R]; C]
|
From<MatrixViewMut<'a, T, Const<R>, Const<C>, RStride, CStride>> for [[T; R]; C]
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(mat: MatrixSliceMut<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
fn from(mat: MatrixViewMut<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||||
mat.into_owned().into()
|
mat.into_owned().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,192 +289,183 @@ impl_from_into_asref_borrow_2D!(
|
||||||
);
|
);
|
||||||
|
|
||||||
impl<'a, T, RStride, CStride, const R: usize, const C: usize>
|
impl<'a, T, RStride, CStride, const R: usize, const C: usize>
|
||||||
From<MatrixSlice<'a, T, Const<R>, Const<C>, RStride, CStride>>
|
From<MatrixView<'a, T, Const<R>, Const<C>, RStride, CStride>>
|
||||||
for Matrix<T, Const<R>, Const<C>, ArrayStorage<T, R, C>>
|
for Matrix<T, Const<R>, Const<C>, ArrayStorage<T, R, C>>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
{
|
{
|
||||||
fn from(matrix_slice: MatrixSlice<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
fn from(matrix_view: MatrixView<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||||
matrix_slice.into_owned()
|
matrix_view.into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<'a, T, C, RStride, CStride> From<MatrixSlice<'a, T, Dynamic, C, RStride, CStride>>
|
impl<'a, T, C, RStride, CStride> From<MatrixView<'a, T, Dyn, C, RStride, CStride>>
|
||||||
for Matrix<T, Dynamic, C, VecStorage<T, Dynamic, C>>
|
for Matrix<T, Dyn, C, VecStorage<T, Dyn, C>>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
C: Dim,
|
C: Dim,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
{
|
{
|
||||||
fn from(matrix_slice: MatrixSlice<'a, T, Dynamic, C, RStride, CStride>) -> Self {
|
fn from(matrix_view: MatrixView<'a, T, Dyn, C, RStride, CStride>) -> Self {
|
||||||
matrix_slice.into_owned()
|
matrix_view.into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<'a, T, R, RStride, CStride> From<MatrixSlice<'a, T, R, Dynamic, RStride, CStride>>
|
impl<'a, T, R, RStride, CStride> From<MatrixView<'a, T, R, Dyn, RStride, CStride>>
|
||||||
for Matrix<T, R, Dynamic, VecStorage<T, R, Dynamic>>
|
for Matrix<T, R, Dyn, VecStorage<T, R, Dyn>>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
R: DimName,
|
R: DimName,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
{
|
{
|
||||||
fn from(matrix_slice: MatrixSlice<'a, T, R, Dynamic, RStride, CStride>) -> Self {
|
fn from(matrix_view: MatrixView<'a, T, R, Dyn, RStride, CStride>) -> Self {
|
||||||
matrix_slice.into_owned()
|
matrix_view.into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, RStride, CStride, const R: usize, const C: usize>
|
impl<'a, T, RStride, CStride, const R: usize, const C: usize>
|
||||||
From<MatrixSliceMut<'a, T, Const<R>, Const<C>, RStride, CStride>>
|
From<MatrixViewMut<'a, T, Const<R>, Const<C>, RStride, CStride>>
|
||||||
for Matrix<T, Const<R>, Const<C>, ArrayStorage<T, R, C>>
|
for Matrix<T, Const<R>, Const<C>, ArrayStorage<T, R, C>>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
{
|
{
|
||||||
fn from(matrix_slice: MatrixSliceMut<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
fn from(matrix_view: MatrixViewMut<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||||
matrix_slice.into_owned()
|
matrix_view.into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<'a, T, C, RStride, CStride> From<MatrixSliceMut<'a, T, Dynamic, C, RStride, CStride>>
|
impl<'a, T, C, RStride, CStride> From<MatrixViewMut<'a, T, Dyn, C, RStride, CStride>>
|
||||||
for Matrix<T, Dynamic, C, VecStorage<T, Dynamic, C>>
|
for Matrix<T, Dyn, C, VecStorage<T, Dyn, C>>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
C: Dim,
|
C: Dim,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
{
|
{
|
||||||
fn from(matrix_slice: MatrixSliceMut<'a, T, Dynamic, C, RStride, CStride>) -> Self {
|
fn from(matrix_view: MatrixViewMut<'a, T, Dyn, C, RStride, CStride>) -> Self {
|
||||||
matrix_slice.into_owned()
|
matrix_view.into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<'a, T, R, RStride, CStride> From<MatrixSliceMut<'a, T, R, Dynamic, RStride, CStride>>
|
impl<'a, T, R, RStride, CStride> From<MatrixViewMut<'a, T, R, Dyn, RStride, CStride>>
|
||||||
for Matrix<T, R, Dynamic, VecStorage<T, R, Dynamic>>
|
for Matrix<T, R, Dyn, VecStorage<T, R, Dyn>>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
R: DimName,
|
R: DimName,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
{
|
{
|
||||||
fn from(matrix_slice: MatrixSliceMut<'a, T, R, Dynamic, RStride, CStride>) -> Self {
|
fn from(matrix_view: MatrixViewMut<'a, T, R, Dyn, RStride, CStride>) -> Self {
|
||||||
matrix_slice.into_owned()
|
matrix_view.into_owned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a Matrix<T, R, C, S>>
|
impl<'a, T, R, C, RView, CView, RStride, CStride, S> From<&'a Matrix<T, R, C, S>>
|
||||||
for MatrixSlice<'a, T, RSlice, CSlice, RStride, CStride>
|
for MatrixView<'a, T, RView, CView, RStride, CStride>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
|
||||||
R: Dim,
|
R: Dim,
|
||||||
C: Dim,
|
C: Dim,
|
||||||
RSlice: Dim,
|
RView: Dim,
|
||||||
CSlice: Dim,
|
CView: Dim,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
S: RawStorage<T, R, C>,
|
S: RawStorage<T, R, C>,
|
||||||
ShapeConstraint: DimEq<R, RSlice>
|
ShapeConstraint:
|
||||||
+ DimEq<C, CSlice>
|
DimEq<R, RView> + DimEq<C, CView> + DimEq<RStride, S::RStride> + DimEq<CStride, S::CStride>,
|
||||||
+ DimEq<RStride, S::RStride>
|
|
||||||
+ DimEq<CStride, S::CStride>,
|
|
||||||
{
|
{
|
||||||
fn from(m: &'a Matrix<T, R, C, S>) -> Self {
|
fn from(m: &'a Matrix<T, R, C, S>) -> Self {
|
||||||
let (row, col) = m.shape_generic();
|
let (row, col) = m.shape_generic();
|
||||||
let row_slice = RSlice::from_usize(row.value());
|
let rows_result = RView::from_usize(row.value());
|
||||||
let col_slice = CSlice::from_usize(col.value());
|
let cols_result = CView::from_usize(col.value());
|
||||||
|
|
||||||
let (rstride, cstride) = m.strides();
|
let (rstride, cstride) = m.strides();
|
||||||
|
|
||||||
let rstride_slice = RStride::from_usize(rstride);
|
let rstride_result = RStride::from_usize(rstride);
|
||||||
let cstride_slice = CStride::from_usize(cstride);
|
let cstride_result = CStride::from_usize(cstride);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = SliceStorage::from_raw_parts(
|
let data = ViewStorage::from_raw_parts(
|
||||||
m.data.ptr(),
|
m.data.ptr(),
|
||||||
(row_slice, col_slice),
|
(rows_result, cols_result),
|
||||||
(rstride_slice, cstride_slice),
|
(rstride_result, cstride_result),
|
||||||
);
|
);
|
||||||
Matrix::from_data_statically_unchecked(data)
|
Matrix::from_data_statically_unchecked(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a mut Matrix<T, R, C, S>>
|
impl<'a, T, R, C, RView, CView, RStride, CStride, S> From<&'a mut Matrix<T, R, C, S>>
|
||||||
for MatrixSlice<'a, T, RSlice, CSlice, RStride, CStride>
|
for MatrixView<'a, T, RView, CView, RStride, CStride>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
|
||||||
R: Dim,
|
R: Dim,
|
||||||
C: Dim,
|
C: Dim,
|
||||||
RSlice: Dim,
|
RView: Dim,
|
||||||
CSlice: Dim,
|
CView: Dim,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
S: RawStorage<T, R, C>,
|
S: RawStorage<T, R, C>,
|
||||||
ShapeConstraint: DimEq<R, RSlice>
|
ShapeConstraint:
|
||||||
+ DimEq<C, CSlice>
|
DimEq<R, RView> + DimEq<C, CView> + DimEq<RStride, S::RStride> + DimEq<CStride, S::CStride>,
|
||||||
+ DimEq<RStride, S::RStride>
|
|
||||||
+ DimEq<CStride, S::CStride>,
|
|
||||||
{
|
{
|
||||||
fn from(m: &'a mut Matrix<T, R, C, S>) -> Self {
|
fn from(m: &'a mut Matrix<T, R, C, S>) -> Self {
|
||||||
let (row, col) = m.shape_generic();
|
let (row, col) = m.shape_generic();
|
||||||
let row_slice = RSlice::from_usize(row.value());
|
let rows_result = RView::from_usize(row.value());
|
||||||
let col_slice = CSlice::from_usize(col.value());
|
let cols_result = CView::from_usize(col.value());
|
||||||
|
|
||||||
let (rstride, cstride) = m.strides();
|
let (rstride, cstride) = m.strides();
|
||||||
|
|
||||||
let rstride_slice = RStride::from_usize(rstride);
|
let rstride_result = RStride::from_usize(rstride);
|
||||||
let cstride_slice = CStride::from_usize(cstride);
|
let cstride_result = CStride::from_usize(cstride);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = SliceStorage::from_raw_parts(
|
let data = ViewStorage::from_raw_parts(
|
||||||
m.data.ptr(),
|
m.data.ptr(),
|
||||||
(row_slice, col_slice),
|
(rows_result, cols_result),
|
||||||
(rstride_slice, cstride_slice),
|
(rstride_result, cstride_result),
|
||||||
);
|
);
|
||||||
Matrix::from_data_statically_unchecked(data)
|
Matrix::from_data_statically_unchecked(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a mut Matrix<T, R, C, S>>
|
impl<'a, T, R, C, RView, CView, RStride, CStride, S> From<&'a mut Matrix<T, R, C, S>>
|
||||||
for MatrixSliceMut<'a, T, RSlice, CSlice, RStride, CStride>
|
for MatrixViewMut<'a, T, RView, CView, RStride, CStride>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
|
||||||
R: Dim,
|
R: Dim,
|
||||||
C: Dim,
|
C: Dim,
|
||||||
RSlice: Dim,
|
RView: Dim,
|
||||||
CSlice: Dim,
|
CView: Dim,
|
||||||
RStride: Dim,
|
RStride: Dim,
|
||||||
CStride: Dim,
|
CStride: Dim,
|
||||||
S: RawStorageMut<T, R, C>,
|
S: RawStorageMut<T, R, C>,
|
||||||
ShapeConstraint: DimEq<R, RSlice>
|
ShapeConstraint:
|
||||||
+ DimEq<C, CSlice>
|
DimEq<R, RView> + DimEq<C, CView> + DimEq<RStride, S::RStride> + DimEq<CStride, S::CStride>,
|
||||||
+ DimEq<RStride, S::RStride>
|
|
||||||
+ DimEq<CStride, S::CStride>,
|
|
||||||
{
|
{
|
||||||
fn from(m: &'a mut Matrix<T, R, C, S>) -> Self {
|
fn from(m: &'a mut Matrix<T, R, C, S>) -> Self {
|
||||||
let (row, col) = m.shape_generic();
|
let (row, col) = m.shape_generic();
|
||||||
let row_slice = RSlice::from_usize(row.value());
|
let rows_result = RView::from_usize(row.value());
|
||||||
let col_slice = CSlice::from_usize(col.value());
|
let cols_result = CView::from_usize(col.value());
|
||||||
|
|
||||||
let (rstride, cstride) = m.strides();
|
let (rstride, cstride) = m.strides();
|
||||||
|
|
||||||
let rstride_slice = RStride::from_usize(rstride);
|
let rstride_result = RStride::from_usize(rstride);
|
||||||
let cstride_slice = CStride::from_usize(cstride);
|
let cstride_result = CStride::from_usize(cstride);
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let data = SliceStorageMut::from_raw_parts(
|
let data = ViewStorageMut::from_raw_parts(
|
||||||
m.data.ptr_mut(),
|
m.data.ptr_mut(),
|
||||||
(row_slice, col_slice),
|
(rows_result, cols_result),
|
||||||
(rstride_slice, cstride_slice),
|
(rstride_result, cstride_result),
|
||||||
);
|
);
|
||||||
Matrix::from_data_statically_unchecked(data)
|
Matrix::from_data_statically_unchecked(data)
|
||||||
}
|
}
|
||||||
|
@ -515,28 +506,28 @@ impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: RawStorageMut<T, R, C> + IsContigu
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar + Copy> From<&'a [T]> for DVectorSlice<'a, T> {
|
impl<'a, T: Scalar + Copy> From<&'a [T]> for DVectorView<'a, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(slice: &'a [T]) -> Self {
|
fn from(slice: &'a [T]) -> Self {
|
||||||
Self::from_slice(slice, slice.len())
|
Self::from_slice(slice, slice.len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar> From<DVectorSlice<'a, T>> for &'a [T] {
|
impl<'a, T: Scalar> From<DVectorView<'a, T>> for &'a [T] {
|
||||||
fn from(vec: DVectorSlice<'a, T>) -> &'a [T] {
|
fn from(vec: DVectorView<'a, T>) -> &'a [T] {
|
||||||
vec.data.into_slice()
|
vec.data.into_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar + Copy> From<&'a mut [T]> for DVectorSliceMut<'a, T> {
|
impl<'a, T: Scalar + Copy> From<&'a mut [T]> for DVectorViewMut<'a, T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(slice: &'a mut [T]) -> Self {
|
fn from(slice: &'a mut [T]) -> Self {
|
||||||
Self::from_slice(slice, slice.len())
|
Self::from_slice(slice, slice.len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar> From<DVectorSliceMut<'a, T>> for &'a mut [T] {
|
impl<'a, T: Scalar> From<DVectorViewMut<'a, T>> for &'a mut [T] {
|
||||||
fn from(vec: DVectorSliceMut<'a, T>) -> &'a mut [T] {
|
fn from(vec: DVectorViewMut<'a, T>) -> &'a mut [T] {
|
||||||
vec.data.into_slice_mut()
|
vec.data.into_slice_mut()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ use super::Const;
|
||||||
use crate::base::allocator::{Allocator, Reallocator};
|
use crate::base::allocator::{Allocator, Reallocator};
|
||||||
use crate::base::array_storage::ArrayStorage;
|
use crate::base::array_storage::ArrayStorage;
|
||||||
#[cfg(any(feature = "alloc", feature = "std"))]
|
#[cfg(any(feature = "alloc", feature = "std"))]
|
||||||
use crate::base::dimension::Dynamic;
|
use crate::base::dimension::Dyn;
|
||||||
use crate::base::dimension::{Dim, DimName};
|
use crate::base::dimension::{Dim, DimName};
|
||||||
use crate::base::storage::{RawStorage, RawStorageMut};
|
use crate::base::storage::{RawStorage, RawStorageMut};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
@ -82,15 +82,15 @@ impl<T: Scalar, const R: usize, const C: usize> Allocator<T, Const<R>, Const<C>>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dynamic - Static
|
// Dyn - Static
|
||||||
// Dynamic - Dynamic
|
// Dyn - Dyn
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, C: Dim> Allocator<T, Dynamic, C> for DefaultAllocator {
|
impl<T: Scalar, C: Dim> Allocator<T, Dyn, C> for DefaultAllocator {
|
||||||
type Buffer = VecStorage<T, Dynamic, C>;
|
type Buffer = VecStorage<T, Dyn, C>;
|
||||||
type BufferUninit = VecStorage<MaybeUninit<T>, Dynamic, C>;
|
type BufferUninit = VecStorage<MaybeUninit<T>, Dyn, C>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn allocate_uninit(nrows: Dynamic, ncols: C) -> VecStorage<MaybeUninit<T>, Dynamic, C> {
|
fn allocate_uninit(nrows: Dyn, ncols: C) -> VecStorage<MaybeUninit<T>, Dyn, C> {
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
let length = nrows.value() * ncols.value();
|
let length = nrows.value() * ncols.value();
|
||||||
data.reserve_exact(length);
|
data.reserve_exact(length);
|
||||||
|
@ -99,9 +99,7 @@ impl<T: Scalar, C: Dim> Allocator<T, Dynamic, C> for DefaultAllocator {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn assume_init(
|
unsafe fn assume_init(uninit: VecStorage<MaybeUninit<T>, Dyn, C>) -> VecStorage<T, Dyn, C> {
|
||||||
uninit: VecStorage<MaybeUninit<T>, Dynamic, C>,
|
|
||||||
) -> VecStorage<T, Dynamic, C> {
|
|
||||||
// Avoids a double-drop.
|
// Avoids a double-drop.
|
||||||
let (nrows, ncols) = uninit.shape();
|
let (nrows, ncols) = uninit.shape();
|
||||||
let vec: Vec<_> = uninit.into();
|
let vec: Vec<_> = uninit.into();
|
||||||
|
@ -117,7 +115,7 @@ impl<T: Scalar, C: Dim> Allocator<T, Dynamic, C> for DefaultAllocator {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn allocate_from_iterator<I: IntoIterator<Item = T>>(
|
fn allocate_from_iterator<I: IntoIterator<Item = T>>(
|
||||||
nrows: Dynamic,
|
nrows: Dyn,
|
||||||
ncols: C,
|
ncols: C,
|
||||||
iter: I,
|
iter: I,
|
||||||
) -> Self::Buffer {
|
) -> Self::Buffer {
|
||||||
|
@ -130,14 +128,14 @@ impl<T: Scalar, C: Dim> Allocator<T, Dynamic, C> for DefaultAllocator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static - Dynamic
|
// Static - Dyn
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, R: DimName> Allocator<T, R, Dynamic> for DefaultAllocator {
|
impl<T: Scalar, R: DimName> Allocator<T, R, Dyn> for DefaultAllocator {
|
||||||
type Buffer = VecStorage<T, R, Dynamic>;
|
type Buffer = VecStorage<T, R, Dyn>;
|
||||||
type BufferUninit = VecStorage<MaybeUninit<T>, R, Dynamic>;
|
type BufferUninit = VecStorage<MaybeUninit<T>, R, Dyn>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn allocate_uninit(nrows: R, ncols: Dynamic) -> VecStorage<MaybeUninit<T>, R, Dynamic> {
|
fn allocate_uninit(nrows: R, ncols: Dyn) -> VecStorage<MaybeUninit<T>, R, Dyn> {
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
let length = nrows.value() * ncols.value();
|
let length = nrows.value() * ncols.value();
|
||||||
data.reserve_exact(length);
|
data.reserve_exact(length);
|
||||||
|
@ -147,9 +145,7 @@ impl<T: Scalar, R: DimName> Allocator<T, R, Dynamic> for DefaultAllocator {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn assume_init(
|
unsafe fn assume_init(uninit: VecStorage<MaybeUninit<T>, R, Dyn>) -> VecStorage<T, R, Dyn> {
|
||||||
uninit: VecStorage<MaybeUninit<T>, R, Dynamic>,
|
|
||||||
) -> VecStorage<T, R, Dynamic> {
|
|
||||||
// Avoids a double-drop.
|
// Avoids a double-drop.
|
||||||
let (nrows, ncols) = uninit.shape();
|
let (nrows, ncols) = uninit.shape();
|
||||||
let vec: Vec<_> = uninit.into();
|
let vec: Vec<_> = uninit.into();
|
||||||
|
@ -166,7 +162,7 @@ impl<T: Scalar, R: DimName> Allocator<T, R, Dynamic> for DefaultAllocator {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn allocate_from_iterator<I: IntoIterator<Item = T>>(
|
fn allocate_from_iterator<I: IntoIterator<Item = T>>(
|
||||||
nrows: R,
|
nrows: R,
|
||||||
ncols: Dynamic,
|
ncols: Dyn,
|
||||||
iter: I,
|
iter: I,
|
||||||
) -> Self::Buffer {
|
) -> Self::Buffer {
|
||||||
let it = iter.into_iter();
|
let it = iter.into_iter();
|
||||||
|
@ -215,20 +211,20 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static × Static -> Dynamic × Any
|
// Static × Static -> Dyn × Any
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, CTo, const RFROM: usize, const CFROM: usize>
|
impl<T: Scalar, CTo, const RFROM: usize, const CFROM: usize>
|
||||||
Reallocator<T, Const<RFROM>, Const<CFROM>, Dynamic, CTo> for DefaultAllocator
|
Reallocator<T, Const<RFROM>, Const<CFROM>, Dyn, CTo> for DefaultAllocator
|
||||||
where
|
where
|
||||||
CTo: Dim,
|
CTo: Dim,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn reallocate_copy(
|
unsafe fn reallocate_copy(
|
||||||
rto: Dynamic,
|
rto: Dyn,
|
||||||
cto: CTo,
|
cto: CTo,
|
||||||
buf: ArrayStorage<T, RFROM, CFROM>,
|
buf: ArrayStorage<T, RFROM, CFROM>,
|
||||||
) -> VecStorage<MaybeUninit<T>, Dynamic, CTo> {
|
) -> VecStorage<MaybeUninit<T>, Dyn, CTo> {
|
||||||
let mut res = <Self as Allocator<T, Dynamic, CTo>>::allocate_uninit(rto, cto);
|
let mut res = <Self as Allocator<T, Dyn, CTo>>::allocate_uninit(rto, cto);
|
||||||
|
|
||||||
let (rfrom, cfrom) = buf.shape();
|
let (rfrom, cfrom) = buf.shape();
|
||||||
|
|
||||||
|
@ -246,20 +242,20 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Static × Static -> Static × Dynamic
|
// Static × Static -> Static × Dyn
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, RTo, const RFROM: usize, const CFROM: usize>
|
impl<T: Scalar, RTo, const RFROM: usize, const CFROM: usize>
|
||||||
Reallocator<T, Const<RFROM>, Const<CFROM>, RTo, Dynamic> for DefaultAllocator
|
Reallocator<T, Const<RFROM>, Const<CFROM>, RTo, Dyn> for DefaultAllocator
|
||||||
where
|
where
|
||||||
RTo: DimName,
|
RTo: DimName,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn reallocate_copy(
|
unsafe fn reallocate_copy(
|
||||||
rto: RTo,
|
rto: RTo,
|
||||||
cto: Dynamic,
|
cto: Dyn,
|
||||||
buf: ArrayStorage<T, RFROM, CFROM>,
|
buf: ArrayStorage<T, RFROM, CFROM>,
|
||||||
) -> VecStorage<MaybeUninit<T>, RTo, Dynamic> {
|
) -> VecStorage<MaybeUninit<T>, RTo, Dyn> {
|
||||||
let mut res = <Self as Allocator<T, RTo, Dynamic>>::allocate_uninit(rto, cto);
|
let mut res = <Self as Allocator<T, RTo, Dyn>>::allocate_uninit(rto, cto);
|
||||||
|
|
||||||
let (rfrom, cfrom) = buf.shape();
|
let (rfrom, cfrom) = buf.shape();
|
||||||
|
|
||||||
|
@ -279,60 +275,58 @@ where
|
||||||
|
|
||||||
// All conversion from a dynamic buffer to a dynamic buffer.
|
// All conversion from a dynamic buffer to a dynamic buffer.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, CFrom: Dim, CTo: Dim> Reallocator<T, Dynamic, CFrom, Dynamic, CTo>
|
impl<T: Scalar, CFrom: Dim, CTo: Dim> Reallocator<T, Dyn, CFrom, Dyn, CTo> for DefaultAllocator {
|
||||||
for DefaultAllocator
|
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn reallocate_copy(
|
unsafe fn reallocate_copy(
|
||||||
rto: Dynamic,
|
rto: Dyn,
|
||||||
cto: CTo,
|
cto: CTo,
|
||||||
buf: VecStorage<T, Dynamic, CFrom>,
|
buf: VecStorage<T, Dyn, CFrom>,
|
||||||
) -> VecStorage<MaybeUninit<T>, Dynamic, CTo> {
|
) -> VecStorage<MaybeUninit<T>, Dyn, CTo> {
|
||||||
let new_buf = buf.resize(rto.value() * cto.value());
|
let new_buf = buf.resize(rto.value() * cto.value());
|
||||||
VecStorage::new(rto, cto, new_buf)
|
VecStorage::new(rto, cto, new_buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, CFrom: Dim, RTo: DimName> Reallocator<T, Dynamic, CFrom, RTo, Dynamic>
|
impl<T: Scalar, CFrom: Dim, RTo: DimName> Reallocator<T, Dyn, CFrom, RTo, Dyn>
|
||||||
for DefaultAllocator
|
for DefaultAllocator
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn reallocate_copy(
|
unsafe fn reallocate_copy(
|
||||||
rto: RTo,
|
rto: RTo,
|
||||||
cto: Dynamic,
|
cto: Dyn,
|
||||||
buf: VecStorage<T, Dynamic, CFrom>,
|
buf: VecStorage<T, Dyn, CFrom>,
|
||||||
) -> VecStorage<MaybeUninit<T>, RTo, Dynamic> {
|
) -> VecStorage<MaybeUninit<T>, RTo, Dyn> {
|
||||||
let new_buf = buf.resize(rto.value() * cto.value());
|
let new_buf = buf.resize(rto.value() * cto.value());
|
||||||
VecStorage::new(rto, cto, new_buf)
|
VecStorage::new(rto, cto, new_buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, RFrom: DimName, CTo: Dim> Reallocator<T, RFrom, Dynamic, Dynamic, CTo>
|
impl<T: Scalar, RFrom: DimName, CTo: Dim> Reallocator<T, RFrom, Dyn, Dyn, CTo>
|
||||||
for DefaultAllocator
|
for DefaultAllocator
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn reallocate_copy(
|
unsafe fn reallocate_copy(
|
||||||
rto: Dynamic,
|
rto: Dyn,
|
||||||
cto: CTo,
|
cto: CTo,
|
||||||
buf: VecStorage<T, RFrom, Dynamic>,
|
buf: VecStorage<T, RFrom, Dyn>,
|
||||||
) -> VecStorage<MaybeUninit<T>, Dynamic, CTo> {
|
) -> VecStorage<MaybeUninit<T>, Dyn, CTo> {
|
||||||
let new_buf = buf.resize(rto.value() * cto.value());
|
let new_buf = buf.resize(rto.value() * cto.value());
|
||||||
VecStorage::new(rto, cto, new_buf)
|
VecStorage::new(rto, cto, new_buf)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, RFrom: DimName, RTo: DimName> Reallocator<T, RFrom, Dynamic, RTo, Dynamic>
|
impl<T: Scalar, RFrom: DimName, RTo: DimName> Reallocator<T, RFrom, Dyn, RTo, Dyn>
|
||||||
for DefaultAllocator
|
for DefaultAllocator
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
unsafe fn reallocate_copy(
|
unsafe fn reallocate_copy(
|
||||||
rto: RTo,
|
rto: RTo,
|
||||||
cto: Dynamic,
|
cto: Dyn,
|
||||||
buf: VecStorage<T, RFrom, Dynamic>,
|
buf: VecStorage<T, RFrom, Dyn>,
|
||||||
) -> VecStorage<MaybeUninit<T>, RTo, Dynamic> {
|
) -> VecStorage<MaybeUninit<T>, RTo, Dyn> {
|
||||||
let new_buf = buf.resize(rto.value() * cto.value());
|
let new_buf = buf.resize(rto.value() * cto.value());
|
||||||
VecStorage::new(rto, cto, new_buf)
|
VecStorage::new(rto, cto, new_buf)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,54 +13,59 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
/// Dim of dynamically-sized algebraic entities.
|
/// Dim of dynamically-sized algebraic entities.
|
||||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(
|
||||||
|
feature = "rkyv-serialize",
|
||||||
|
archive_attr(derive(bytecheck::CheckBytes))
|
||||||
|
)]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
pub struct Dynamic {
|
pub struct Dyn(pub usize);
|
||||||
value: usize,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Dynamic {
|
#[deprecated(note = "use Dyn instead.")]
|
||||||
|
pub type Dynamic = Dyn;
|
||||||
|
|
||||||
|
impl Dyn {
|
||||||
/// A dynamic size equal to `value`.
|
/// A dynamic size equal to `value`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[deprecated(note = "use Dyn(value) instead.")]
|
||||||
pub const fn new(value: usize) -> Self {
|
pub const fn new(value: usize) -> Self {
|
||||||
Self { value }
|
Self(value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
impl Serialize for Dynamic {
|
impl Serialize for Dyn {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
self.value.serialize(serializer)
|
self.0.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
impl<'de> Deserialize<'de> for Dynamic {
|
impl<'de> Deserialize<'de> for Dyn {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
{
|
{
|
||||||
usize::deserialize(deserializer).map(|x| Dynamic { value: x })
|
usize::deserialize(deserializer).map(|x| Dyn(x))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Trait implemented by `Dynamic`.
|
/// Trait implemented by `Dyn`.
|
||||||
pub trait IsDynamic {}
|
pub trait IsDynamic {}
|
||||||
/// Trait implemented by `Dynamic` and type-level integers different from `U1`.
|
/// Trait implemented by `Dyn` and type-level integers different from `U1`.
|
||||||
pub trait IsNotStaticOne {}
|
pub trait IsNotStaticOne {}
|
||||||
|
|
||||||
impl IsDynamic for Dynamic {}
|
impl IsDynamic for Dyn {}
|
||||||
impl IsNotStaticOne for Dynamic {}
|
impl IsNotStaticOne for Dyn {}
|
||||||
|
|
||||||
/// Trait implemented by any type that can be used as a dimension. This includes type-level
|
/// Trait implemented by any type that can be used as a dimension. This includes type-level
|
||||||
/// integers and `Dynamic` (for dimensions not known at compile-time).
|
/// integers and `Dyn` (for dimensions not known at compile-time).
|
||||||
pub unsafe trait Dim: Any + Debug + Copy + PartialEq + Send + Sync {
|
pub unsafe trait Dim: Any + Debug + Copy + PartialEq + Send + Sync {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn is<D: Dim>() -> bool {
|
fn is<D: Dim>() -> bool {
|
||||||
|
@ -68,7 +73,7 @@ pub unsafe trait Dim: Any + Debug + Copy + PartialEq + Send + Sync {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the compile-time value of `Self`. Returns `None` if it is not known, i.e., if `Self =
|
/// Gets the compile-time value of `Self`. Returns `None` if it is not known, i.e., if `Self =
|
||||||
/// Dynamic`.
|
/// Dyn`.
|
||||||
fn try_to_usize() -> Option<usize>;
|
fn try_to_usize() -> Option<usize>;
|
||||||
|
|
||||||
/// Gets the run-time value of `self`. For type-level integers, this is the same as
|
/// Gets the run-time value of `self`. For type-level integers, this is the same as
|
||||||
|
@ -80,7 +85,7 @@ pub unsafe trait Dim: Any + Debug + Copy + PartialEq + Send + Sync {
|
||||||
fn from_usize(dim: usize) -> Self;
|
fn from_usize(dim: usize) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Dim for Dynamic {
|
unsafe impl Dim for Dyn {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn try_to_usize() -> Option<usize> {
|
fn try_to_usize() -> Option<usize> {
|
||||||
None
|
None
|
||||||
|
@ -88,30 +93,30 @@ unsafe impl Dim for Dynamic {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_usize(dim: usize) -> Self {
|
fn from_usize(dim: usize) -> Self {
|
||||||
Self::new(dim)
|
Self(dim)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn value(&self) -> usize {
|
fn value(&self) -> usize {
|
||||||
self.value
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Add<usize> for Dynamic {
|
impl Add<usize> for Dyn {
|
||||||
type Output = Dynamic;
|
type Output = Dyn;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn add(self, rhs: usize) -> Self {
|
fn add(self, rhs: usize) -> Self {
|
||||||
Self::new(self.value + rhs)
|
Self(self.0 + rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Sub<usize> for Dynamic {
|
impl Sub<usize> for Dyn {
|
||||||
type Output = Dynamic;
|
type Output = Dyn;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sub(self, rhs: usize) -> Self {
|
fn sub(self, rhs: usize) -> Self {
|
||||||
Self::new(self.value - rhs)
|
Self(self.0 - rhs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,22 +154,22 @@ macro_rules! dim_ops(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Dim> $DimOp<D> for Dynamic {
|
impl<D: Dim> $DimOp<D> for Dyn {
|
||||||
type Output = Dynamic;
|
type Output = Dyn;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $op(self, other: D) -> Dynamic {
|
fn $op(self, other: D) -> Dyn {
|
||||||
Dynamic::new($op_path(self.value, other.value()))
|
Dyn($op_path(self.value(), other.value()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use Const<T> instead of D: DimName?
|
// TODO: use Const<T> instead of D: DimName?
|
||||||
impl<D: DimName> $DimOp<Dynamic> for D {
|
impl<D: DimName> $DimOp<Dyn> for D {
|
||||||
type Output = Dynamic;
|
type Output = Dyn;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn $op(self, other: Dynamic) -> Dynamic {
|
fn $op(self, other: Dyn) -> Dyn {
|
||||||
Dynamic::new($op_path(self.value(), other.value))
|
Dyn($op_path(self.value(), other.value()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +210,8 @@ dim_ops!(
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(as = "Self")
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
|
@ -306,6 +312,11 @@ macro_rules! from_to_typenum (
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IsNotStaticOne for $D { }
|
impl IsNotStaticOne for $D { }
|
||||||
|
|
||||||
|
/// The constant dimension
|
||||||
|
#[doc = stringify!($VAL)]
|
||||||
|
/// .
|
||||||
|
pub const $D: $D = Const::<$VAL>;
|
||||||
)*}
|
)*}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -319,3 +330,7 @@ from_to_typenum!(
|
||||||
U111, 111; U112, 112; U113, 113; U114, 114; U115, 115; U116, 116; U117, 117; U118, 118; U119, 119; U120, 120; U121, 121; U122, 122; U123, 123; U124, 124; U125, 125; U126, 126;
|
U111, 111; U112, 112; U113, 113; U114, 114; U115, 115; U116, 116; U117, 117; U118, 118; U119, 119; U120, 120; U121, 121; U122, 122; U123, 123; U124, 124; U125, 125; U126, 126;
|
||||||
U127, 127
|
U127, 127
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// The constant dimension 1.
|
||||||
|
// Note: We add U1 separately since it's not covered by the from_to_typenum! macro.
|
||||||
|
pub const U1: U1 = Const::<1>;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::ptr;
|
||||||
use crate::base::allocator::{Allocator, Reallocator};
|
use crate::base::allocator::{Allocator, Reallocator};
|
||||||
use crate::base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
|
use crate::base::constraint::{DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use crate::base::dimension::Dynamic;
|
use crate::base::dimension::Dyn;
|
||||||
use crate::base::dimension::{Const, Dim, DimAdd, DimDiff, DimMin, DimMinimum, DimSub, DimSum, U1};
|
use crate::base::dimension::{Const, Dim, DimAdd, DimDiff, DimMin, DimMinimum, DimSub, DimSum, U1};
|
||||||
use crate::base::storage::{RawStorage, RawStorageMut, ReshapableStorage};
|
use crate::base::storage::{RawStorage, RawStorageMut, ReshapableStorage};
|
||||||
use crate::base::{DefaultAllocator, Matrix, OMatrix, RowVector, Scalar, Vector};
|
use crate::base::{DefaultAllocator, Matrix, OMatrix, RowVector, Scalar, Vector};
|
||||||
|
@ -48,15 +48,15 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// Creates a new matrix by extracting the given set of rows from `self`.
|
/// Creates a new matrix by extracting the given set of rows from `self`.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn select_rows<'a, I>(&self, irows: I) -> OMatrix<T, Dynamic, C>
|
pub fn select_rows<'a, I>(&self, irows: I) -> OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = &'a usize>,
|
I: IntoIterator<Item = &'a usize>,
|
||||||
I::IntoIter: ExactSizeIterator + Clone,
|
I::IntoIter: ExactSizeIterator + Clone,
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C>,
|
DefaultAllocator: Allocator<T, Dyn, C>,
|
||||||
{
|
{
|
||||||
let irows = irows.into_iter();
|
let irows = irows.into_iter();
|
||||||
let ncols = self.shape_generic().1;
|
let ncols = self.shape_generic().1;
|
||||||
let mut res = Matrix::uninit(Dynamic::new(irows.len()), ncols);
|
let mut res = Matrix::uninit(Dyn(irows.len()), ncols);
|
||||||
|
|
||||||
// First, check that all the indices from irows are valid.
|
// First, check that all the indices from irows are valid.
|
||||||
// This will allow us to use unchecked access in the inner loop.
|
// This will allow us to use unchecked access in the inner loop.
|
||||||
|
@ -85,15 +85,15 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// Creates a new matrix by extracting the given set of columns from `self`.
|
/// Creates a new matrix by extracting the given set of columns from `self`.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn select_columns<'a, I>(&self, icols: I) -> OMatrix<T, R, Dynamic>
|
pub fn select_columns<'a, I>(&self, icols: I) -> OMatrix<T, R, Dyn>
|
||||||
where
|
where
|
||||||
I: IntoIterator<Item = &'a usize>,
|
I: IntoIterator<Item = &'a usize>,
|
||||||
I::IntoIter: ExactSizeIterator,
|
I::IntoIter: ExactSizeIterator,
|
||||||
DefaultAllocator: Allocator<T, R, Dynamic>,
|
DefaultAllocator: Allocator<T, R, Dyn>,
|
||||||
{
|
{
|
||||||
let icols = icols.into_iter();
|
let icols = icols.into_iter();
|
||||||
let nrows = self.shape_generic().0;
|
let nrows = self.shape_generic().0;
|
||||||
let mut res = Matrix::uninit(nrows, Dynamic::new(icols.len()));
|
let mut res = Matrix::uninit(nrows, Dyn(icols.len()));
|
||||||
|
|
||||||
for (destination, source) in icols.enumerate() {
|
for (destination, source) in icols.enumerate() {
|
||||||
// NOTE: this is basically a copy_frow but wrapping the values insnide of MaybeUninit.
|
// NOTE: this is basically a copy_frow but wrapping the values insnide of MaybeUninit.
|
||||||
|
@ -359,10 +359,10 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
|
|
||||||
/// Removes all columns in `indices`
|
/// Removes all columns in `indices`
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn remove_columns_at(self, indices: &[usize]) -> OMatrix<T, R, Dynamic>
|
pub fn remove_columns_at(self, indices: &[usize]) -> OMatrix<T, R, Dyn>
|
||||||
where
|
where
|
||||||
C: DimSub<Dynamic, Output = Dynamic>,
|
C: DimSub<Dyn, Output = Dyn>,
|
||||||
DefaultAllocator: Reallocator<T, R, C, R, Dynamic>,
|
DefaultAllocator: Reallocator<T, R, C, R, Dyn>,
|
||||||
{
|
{
|
||||||
let mut m = self.into_owned();
|
let mut m = self.into_owned();
|
||||||
let (nrows, ncols) = m.shape_generic();
|
let (nrows, ncols) = m.shape_generic();
|
||||||
|
@ -400,7 +400,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let new_data = DefaultAllocator::reallocate_copy(
|
let new_data = DefaultAllocator::reallocate_copy(
|
||||||
nrows,
|
nrows,
|
||||||
ncols.sub(Dynamic::from_usize(offset)),
|
ncols.sub(Dyn::from_usize(offset)),
|
||||||
m.data,
|
m.data,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -410,10 +410,10 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
|
|
||||||
/// Removes all rows in `indices`
|
/// Removes all rows in `indices`
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn remove_rows_at(self, indices: &[usize]) -> OMatrix<T, Dynamic, C>
|
pub fn remove_rows_at(self, indices: &[usize]) -> OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
R: DimSub<Dynamic, Output = Dynamic>,
|
R: DimSub<Dyn, Output = Dyn>,
|
||||||
DefaultAllocator: Reallocator<T, R, C, Dynamic, C>,
|
DefaultAllocator: Reallocator<T, R, C, Dyn, C>,
|
||||||
{
|
{
|
||||||
let mut m = self.into_owned();
|
let mut m = self.into_owned();
|
||||||
let (nrows, ncols) = m.shape_generic();
|
let (nrows, ncols) = m.shape_generic();
|
||||||
|
@ -448,7 +448,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
// be assumed to be initialized.
|
// be assumed to be initialized.
|
||||||
unsafe {
|
unsafe {
|
||||||
let new_data = DefaultAllocator::reallocate_copy(
|
let new_data = DefaultAllocator::reallocate_copy(
|
||||||
nrows.sub(Dynamic::from_usize(offset / ncols.value())),
|
nrows.sub(Dyn::from_usize(offset / ncols.value())),
|
||||||
ncols,
|
ncols,
|
||||||
m.data,
|
m.data,
|
||||||
);
|
);
|
||||||
|
@ -474,12 +474,12 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// Removes `n` consecutive columns from this matrix, starting with the `i`-th (included).
|
/// Removes `n` consecutive columns from this matrix, starting with the `i`-th (included).
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn remove_columns(self, i: usize, n: usize) -> OMatrix<T, R, Dynamic>
|
pub fn remove_columns(self, i: usize, n: usize) -> OMatrix<T, R, Dyn>
|
||||||
where
|
where
|
||||||
C: DimSub<Dynamic, Output = Dynamic>,
|
C: DimSub<Dyn, Output = Dyn>,
|
||||||
DefaultAllocator: Reallocator<T, R, C, R, Dynamic>,
|
DefaultAllocator: Reallocator<T, R, C, R, Dyn>,
|
||||||
{
|
{
|
||||||
self.remove_columns_generic(i, Dynamic::new(n))
|
self.remove_columns_generic(i, Dyn(n))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes `nremove.value()` columns from this matrix, starting with the `i`-th (included).
|
/// Removes `nremove.value()` columns from this matrix, starting with the `i`-th (included).
|
||||||
|
@ -569,12 +569,12 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// Removes `n` consecutive rows from this matrix, starting with the `i`-th (included).
|
/// Removes `n` consecutive rows from this matrix, starting with the `i`-th (included).
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn remove_rows(self, i: usize, n: usize) -> OMatrix<T, Dynamic, C>
|
pub fn remove_rows(self, i: usize, n: usize) -> OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
R: DimSub<Dynamic, Output = Dynamic>,
|
R: DimSub<Dyn, Output = Dyn>,
|
||||||
DefaultAllocator: Reallocator<T, R, C, Dynamic, C>,
|
DefaultAllocator: Reallocator<T, R, C, Dyn, C>,
|
||||||
{
|
{
|
||||||
self.remove_rows_generic(i, Dynamic::new(n))
|
self.remove_rows_generic(i, Dyn(n))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes `nremove.value()` rows from this matrix, starting with the `i`-th (included).
|
/// Removes `nremove.value()` rows from this matrix, starting with the `i`-th (included).
|
||||||
|
@ -659,12 +659,12 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// Inserts `n` columns filled with `val` starting at the `i-th` position.
|
/// Inserts `n` columns filled with `val` starting at the `i-th` position.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn insert_columns(self, i: usize, n: usize, val: T) -> OMatrix<T, R, Dynamic>
|
pub fn insert_columns(self, i: usize, n: usize, val: T) -> OMatrix<T, R, Dyn>
|
||||||
where
|
where
|
||||||
C: DimAdd<Dynamic, Output = Dynamic>,
|
C: DimAdd<Dyn, Output = Dyn>,
|
||||||
DefaultAllocator: Reallocator<T, R, C, R, Dynamic>,
|
DefaultAllocator: Reallocator<T, R, C, R, Dyn>,
|
||||||
{
|
{
|
||||||
let mut res = unsafe { self.insert_columns_generic_uninitialized(i, Dynamic::new(n)) };
|
let mut res = unsafe { self.insert_columns_generic_uninitialized(i, Dyn(n)) };
|
||||||
res.columns_mut(i, n)
|
res.columns_mut(i, n)
|
||||||
.fill_with(|| MaybeUninit::new(val.clone()));
|
.fill_with(|| MaybeUninit::new(val.clone()));
|
||||||
|
|
||||||
|
@ -752,12 +752,12 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// Inserts `n` rows filled with `val` starting at the `i-th` position.
|
/// Inserts `n` rows filled with `val` starting at the `i-th` position.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn insert_rows(self, i: usize, n: usize, val: T) -> OMatrix<T, Dynamic, C>
|
pub fn insert_rows(self, i: usize, n: usize, val: T) -> OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
R: DimAdd<Dynamic, Output = Dynamic>,
|
R: DimAdd<Dyn, Output = Dyn>,
|
||||||
DefaultAllocator: Reallocator<T, R, C, Dynamic, C>,
|
DefaultAllocator: Reallocator<T, R, C, Dyn, C>,
|
||||||
{
|
{
|
||||||
let mut res = unsafe { self.insert_rows_generic_uninitialized(i, Dynamic::new(n)) };
|
let mut res = unsafe { self.insert_rows_generic_uninitialized(i, Dyn(n)) };
|
||||||
res.rows_mut(i, n)
|
res.rows_mut(i, n)
|
||||||
.fill_with(|| MaybeUninit::new(val.clone()));
|
.fill_with(|| MaybeUninit::new(val.clone()));
|
||||||
|
|
||||||
|
@ -815,11 +815,11 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more
|
/// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more
|
||||||
/// rows and/or columns than `self`, then the extra rows or columns are filled with `val`.
|
/// rows and/or columns than `self`, then the extra rows or columns are filled with `val`.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn resize(self, new_nrows: usize, new_ncols: usize, val: T) -> OMatrix<T, Dynamic, Dynamic>
|
pub fn resize(self, new_nrows: usize, new_ncols: usize, val: T) -> OMatrix<T, Dyn, Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Reallocator<T, R, C, Dynamic, Dynamic>,
|
DefaultAllocator: Reallocator<T, R, C, Dyn, Dyn>,
|
||||||
{
|
{
|
||||||
self.resize_generic(Dynamic::new(new_nrows), Dynamic::new(new_ncols), val)
|
self.resize_generic(Dyn(new_nrows), Dyn(new_ncols), val)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resizes this matrix vertically, i.e., so that it contains `new_nrows` rows while keeping the same number of columns.
|
/// Resizes this matrix vertically, i.e., so that it contains `new_nrows` rows while keeping the same number of columns.
|
||||||
|
@ -827,12 +827,12 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more
|
/// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more
|
||||||
/// rows than `self`, then the extra rows are filled with `val`.
|
/// rows than `self`, then the extra rows are filled with `val`.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn resize_vertically(self, new_nrows: usize, val: T) -> OMatrix<T, Dynamic, C>
|
pub fn resize_vertically(self, new_nrows: usize, val: T) -> OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Reallocator<T, R, C, Dynamic, C>,
|
DefaultAllocator: Reallocator<T, R, C, Dyn, C>,
|
||||||
{
|
{
|
||||||
let ncols = self.shape_generic().1;
|
let ncols = self.shape_generic().1;
|
||||||
self.resize_generic(Dynamic::new(new_nrows), ncols, val)
|
self.resize_generic(Dyn(new_nrows), ncols, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resizes this matrix horizontally, i.e., so that it contains `new_ncolumns` columns while keeping the same number of columns.
|
/// Resizes this matrix horizontally, i.e., so that it contains `new_ncolumns` columns while keeping the same number of columns.
|
||||||
|
@ -840,12 +840,12 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more
|
/// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more
|
||||||
/// columns than `self`, then the extra columns are filled with `val`.
|
/// columns than `self`, then the extra columns are filled with `val`.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn resize_horizontally(self, new_ncols: usize, val: T) -> OMatrix<T, R, Dynamic>
|
pub fn resize_horizontally(self, new_ncols: usize, val: T) -> OMatrix<T, R, Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Reallocator<T, R, C, R, Dynamic>,
|
DefaultAllocator: Reallocator<T, R, C, R, Dyn>,
|
||||||
{
|
{
|
||||||
let nrows = self.shape_generic().0;
|
let nrows = self.shape_generic().0;
|
||||||
self.resize_generic(nrows, Dynamic::new(new_ncols), val)
|
self.resize_generic(nrows, Dyn(new_ncols), val)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resizes this matrix so that it contains `R2::value()` rows and `C2::value()` columns.
|
/// Resizes this matrix so that it contains `R2::value()` rows and `C2::value()` columns.
|
||||||
|
@ -938,7 +938,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if new_nrows.value() > nrows {
|
if new_nrows.value() > nrows {
|
||||||
res.slice_range_mut(nrows.., ..cmp::min(ncols, new_ncols.value()))
|
res.view_range_mut(nrows.., ..cmp::min(ncols, new_ncols.value()))
|
||||||
.fill_with(|| MaybeUninit::new(val.clone()));
|
.fill_with(|| MaybeUninit::new(val.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -962,7 +962,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use nalgebra::{Matrix3x2, Matrix2x3, DMatrix, Const, Dynamic};
|
/// # use nalgebra::{Matrix3x2, Matrix2x3, DMatrix, Const, Dyn};
|
||||||
///
|
///
|
||||||
/// let m1 = Matrix2x3::new(
|
/// let m1 = Matrix2x3::new(
|
||||||
/// 1.1, 1.2, 1.3,
|
/// 1.1, 1.2, 1.3,
|
||||||
|
@ -998,7 +998,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// 0.0, 0.0,
|
/// 0.0, 0.0,
|
||||||
/// ],
|
/// ],
|
||||||
/// );
|
/// );
|
||||||
/// let reshaped = dm1.reshape_generic(Dynamic::new(6), Dynamic::new(2));
|
/// let reshaped = dm1.reshape_generic(Dyn(6), Dyn(2));
|
||||||
/// assert_eq!(reshaped, dm2);
|
/// assert_eq!(reshaped, dm2);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn reshape_generic<R2, C2>(
|
pub fn reshape_generic<R2, C2>(
|
||||||
|
@ -1018,7 +1018,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
|
|
||||||
/// # In-place resizing
|
/// # In-place resizing
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar> OMatrix<T, Dynamic, Dynamic> {
|
impl<T: Scalar> OMatrix<T, Dyn, Dyn> {
|
||||||
/// Resizes this matrix in-place.
|
/// Resizes this matrix in-place.
|
||||||
///
|
///
|
||||||
/// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more
|
/// The values are copied such that `self[(i, j)] == result[(i, j)]`. If the result has more
|
||||||
|
@ -1027,7 +1027,7 @@ impl<T: Scalar> OMatrix<T, Dynamic, Dynamic> {
|
||||||
/// Defined only for owned fully-dynamic matrices, i.e., `DMatrix`.
|
/// Defined only for owned fully-dynamic matrices, i.e., `DMatrix`.
|
||||||
pub fn resize_mut(&mut self, new_nrows: usize, new_ncols: usize, val: T)
|
pub fn resize_mut(&mut self, new_nrows: usize, new_ncols: usize, val: T)
|
||||||
where
|
where
|
||||||
DefaultAllocator: Reallocator<T, Dynamic, Dynamic, Dynamic, Dynamic>,
|
DefaultAllocator: Reallocator<T, Dyn, Dyn, Dyn, Dyn>,
|
||||||
{
|
{
|
||||||
// TODO: avoid the clone.
|
// TODO: avoid the clone.
|
||||||
*self = self.clone().resize(new_nrows, new_ncols, val);
|
*self = self.clone().resize(new_nrows, new_ncols, val);
|
||||||
|
@ -1035,9 +1035,9 @@ impl<T: Scalar> OMatrix<T, Dynamic, Dynamic> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, C: Dim> OMatrix<T, Dynamic, C>
|
impl<T: Scalar, C: Dim> OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C>,
|
DefaultAllocator: Allocator<T, Dyn, C>,
|
||||||
{
|
{
|
||||||
/// Changes the number of rows of this matrix in-place.
|
/// Changes the number of rows of this matrix in-place.
|
||||||
///
|
///
|
||||||
|
@ -1048,7 +1048,7 @@ where
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn resize_vertically_mut(&mut self, new_nrows: usize, val: T)
|
pub fn resize_vertically_mut(&mut self, new_nrows: usize, val: T)
|
||||||
where
|
where
|
||||||
DefaultAllocator: Reallocator<T, Dynamic, C, Dynamic, C>,
|
DefaultAllocator: Reallocator<T, Dyn, C, Dyn, C>,
|
||||||
{
|
{
|
||||||
// TODO: avoid the clone.
|
// TODO: avoid the clone.
|
||||||
*self = self.clone().resize_vertically(new_nrows, val);
|
*self = self.clone().resize_vertically(new_nrows, val);
|
||||||
|
@ -1056,9 +1056,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T: Scalar, R: Dim> OMatrix<T, R, Dynamic>
|
impl<T: Scalar, R: Dim> OMatrix<T, R, Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, R, Dynamic>,
|
DefaultAllocator: Allocator<T, R, Dyn>,
|
||||||
{
|
{
|
||||||
/// Changes the number of column of this matrix in-place.
|
/// Changes the number of column of this matrix in-place.
|
||||||
///
|
///
|
||||||
|
@ -1069,7 +1069,7 @@ where
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub fn resize_horizontally_mut(&mut self, new_ncols: usize, val: T)
|
pub fn resize_horizontally_mut(&mut self, new_ncols: usize, val: T)
|
||||||
where
|
where
|
||||||
DefaultAllocator: Reallocator<T, R, Dynamic, R, Dynamic>,
|
DefaultAllocator: Reallocator<T, R, Dyn, R, Dyn>,
|
||||||
{
|
{
|
||||||
// TODO: avoid the clone.
|
// TODO: avoid the clone.
|
||||||
*self = self.clone().resize_horizontally(new_ncols, val);
|
*self = self.clone().resize_horizontally(new_ncols, val);
|
||||||
|
@ -1167,7 +1167,7 @@ unsafe fn extend_rows<T>(data: &mut [T], nrows: usize, ncols: usize, i: usize, n
|
||||||
/// Extend the number of columns of the `Matrix` with elements from
|
/// Extend the number of columns of the `Matrix` with elements from
|
||||||
/// a given iterator.
|
/// a given iterator.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T, R, S> Extend<T> for Matrix<T, R, Dynamic, S>
|
impl<T, R, S> Extend<T> for Matrix<T, R, Dyn, S>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
R: Dim,
|
R: Dim,
|
||||||
|
@ -1178,7 +1178,7 @@ where
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// # use nalgebra::{DMatrix, Dynamic, Matrix, OMatrix, Matrix3};
|
/// # use nalgebra::{DMatrix, Dyn, Matrix, OMatrix, Matrix3};
|
||||||
///
|
///
|
||||||
/// let data = vec![0, 1, 2, // column 1
|
/// let data = vec![0, 1, 2, // column 1
|
||||||
/// 3, 4, 5]; // column 2
|
/// 3, 4, 5]; // column 2
|
||||||
|
@ -1198,7 +1198,7 @@ where
|
||||||
/// `Matrix`.
|
/// `Matrix`.
|
||||||
///
|
///
|
||||||
/// ```should_panic
|
/// ```should_panic
|
||||||
/// # use nalgebra::{DMatrix, Dynamic, OMatrix};
|
/// # use nalgebra::{DMatrix, Dyn, OMatrix};
|
||||||
/// let data = vec![0, 1, 2, // column 1
|
/// let data = vec![0, 1, 2, // column 1
|
||||||
/// 3, 4, 5]; // column 2
|
/// 3, 4, 5]; // column 2
|
||||||
///
|
///
|
||||||
|
@ -1215,7 +1215,7 @@ where
|
||||||
/// Extend the number of rows of the `Vector` with elements from
|
/// Extend the number of rows of the `Vector` with elements from
|
||||||
/// a given iterator.
|
/// a given iterator.
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T, S> Extend<T> for Matrix<T, Dynamic, U1, S>
|
impl<T, S> Extend<T> for Matrix<T, Dyn, U1, S>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
S: Extend<T>,
|
S: Extend<T>,
|
||||||
|
@ -1236,7 +1236,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T, R, S, RV, SV> Extend<Vector<T, RV, SV>> for Matrix<T, R, Dynamic, S>
|
impl<T, R, S, RV, SV> Extend<Vector<T, RV, SV>> for Matrix<T, R, Dyn, S>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
R: Dim,
|
R: Dim,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
use crate::base::storage::{RawStorage, RawStorageMut};
|
use crate::base::storage::{RawStorage, RawStorageMut};
|
||||||
use crate::base::{
|
use crate::base::{
|
||||||
Const, Dim, DimDiff, DimName, DimSub, Dynamic, Matrix, MatrixSlice, MatrixSliceMut, Scalar, U1,
|
Const, Dim, DimDiff, DimName, DimSub, Dyn, Matrix, MatrixView, MatrixViewMut, Scalar, U1,
|
||||||
};
|
};
|
||||||
|
|
||||||
use std::ops;
|
use std::ops;
|
||||||
|
@ -49,7 +49,7 @@ fn dimrange_usize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Dim> DimRange<D> for ops::Range<usize> {
|
impl<D: Dim> DimRange<D> for ops::Range<usize> {
|
||||||
type Length = Dynamic;
|
type Length = Dyn;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn lower(&self, _: D) -> usize {
|
fn lower(&self, _: D) -> usize {
|
||||||
|
@ -58,7 +58,7 @@ impl<D: Dim> DimRange<D> for ops::Range<usize> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn length(&self, _: D) -> Self::Length {
|
fn length(&self, _: D) -> Self::Length {
|
||||||
Dynamic::new(self.end.saturating_sub(self.start))
|
Dyn(self.end.saturating_sub(self.start))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -74,24 +74,24 @@ fn dimrange_range_usize() {
|
||||||
assert!(DimRange::contained_by(&(0..1), Const::<1>));
|
assert!(DimRange::contained_by(&(0..1), Const::<1>));
|
||||||
assert!(DimRange::contained_by(
|
assert!(DimRange::contained_by(
|
||||||
&((usize::MAX - 1)..usize::MAX),
|
&((usize::MAX - 1)..usize::MAX),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
));
|
));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&((usize::MAX - 1)..usize::MAX), Dynamic::new(usize::MAX)),
|
DimRange::length(&((usize::MAX - 1)..usize::MAX), Dyn(usize::MAX)),
|
||||||
Dynamic::new(1)
|
Dyn(1)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&(usize::MAX..(usize::MAX - 1)), Dynamic::new(usize::MAX)),
|
DimRange::length(&(usize::MAX..(usize::MAX - 1)), Dyn(usize::MAX)),
|
||||||
Dynamic::new(0)
|
Dyn(0)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&(usize::MAX..usize::MAX), Dynamic::new(usize::MAX)),
|
DimRange::length(&(usize::MAX..usize::MAX), Dyn(usize::MAX)),
|
||||||
Dynamic::new(0)
|
Dyn(0)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Dim> DimRange<D> for ops::RangeFrom<usize> {
|
impl<D: Dim> DimRange<D> for ops::RangeFrom<usize> {
|
||||||
type Length = Dynamic;
|
type Length = Dyn;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn lower(&self, _: D) -> usize {
|
fn lower(&self, _: D) -> usize {
|
||||||
|
@ -116,16 +116,13 @@ fn dimrange_rangefrom_usize() {
|
||||||
assert!(DimRange::contained_by(&(0..), Const::<1>));
|
assert!(DimRange::contained_by(&(0..), Const::<1>));
|
||||||
assert!(DimRange::contained_by(
|
assert!(DimRange::contained_by(
|
||||||
&((usize::MAX - 1)..),
|
&((usize::MAX - 1)..),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
));
|
));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&((usize::MAX - 1)..), Dynamic::new(usize::MAX)),
|
DimRange::length(&((usize::MAX - 1)..), Dyn(usize::MAX)),
|
||||||
Dynamic::new(1)
|
Dyn(1)
|
||||||
);
|
|
||||||
assert_eq!(
|
|
||||||
DimRange::length(&(usize::MAX..), Dynamic::new(usize::MAX)),
|
|
||||||
Dynamic::new(0)
|
|
||||||
);
|
);
|
||||||
|
assert_eq!(DimRange::length(&(usize::MAX..), Dyn(usize::MAX)), Dyn(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Dim, T: Dim> DimRange<D> for ops::RangeFrom<T>
|
impl<D: Dim, T: Dim> DimRange<D> for ops::RangeFrom<T>
|
||||||
|
@ -181,7 +178,7 @@ fn dimrange_rangefull() {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Dim> DimRange<D> for ops::RangeInclusive<usize> {
|
impl<D: Dim> DimRange<D> for ops::RangeInclusive<usize> {
|
||||||
type Length = Dynamic;
|
type Length = Dyn;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn lower(&self, _: D) -> usize {
|
fn lower(&self, _: D) -> usize {
|
||||||
|
@ -190,7 +187,7 @@ impl<D: Dim> DimRange<D> for ops::RangeInclusive<usize> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn length(&self, _: D) -> Self::Length {
|
fn length(&self, _: D) -> Self::Length {
|
||||||
Dynamic::new(if self.end() < self.start() {
|
Dyn(if self.end() < self.start() {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
self.end().wrapping_sub(self.start().wrapping_sub(1))
|
self.end().wrapping_sub(self.start().wrapping_sub(1))
|
||||||
|
@ -209,33 +206,33 @@ fn dimrange_rangeinclusive_usize() {
|
||||||
assert!(DimRange::contained_by(&(0..=0), Const::<1>));
|
assert!(DimRange::contained_by(&(0..=0), Const::<1>));
|
||||||
assert!(!DimRange::contained_by(
|
assert!(!DimRange::contained_by(
|
||||||
&(usize::MAX..=usize::MAX),
|
&(usize::MAX..=usize::MAX),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
));
|
));
|
||||||
assert!(!DimRange::contained_by(
|
assert!(!DimRange::contained_by(
|
||||||
&((usize::MAX - 1)..=usize::MAX),
|
&((usize::MAX - 1)..=usize::MAX),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
));
|
));
|
||||||
assert!(DimRange::contained_by(
|
assert!(DimRange::contained_by(
|
||||||
&((usize::MAX - 1)..=(usize::MAX - 1)),
|
&((usize::MAX - 1)..=(usize::MAX - 1)),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
));
|
));
|
||||||
assert_eq!(DimRange::length(&(0..=0), Const::<1>), Dynamic::new(1));
|
assert_eq!(DimRange::length(&(0..=0), Const::<1>), Dyn(1));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&((usize::MAX - 1)..=usize::MAX), Dynamic::new(usize::MAX)),
|
DimRange::length(&((usize::MAX - 1)..=usize::MAX), Dyn(usize::MAX)),
|
||||||
Dynamic::new(2)
|
Dyn(2)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&(usize::MAX..=(usize::MAX - 1)), Dynamic::new(usize::MAX)),
|
DimRange::length(&(usize::MAX..=(usize::MAX - 1)), Dyn(usize::MAX)),
|
||||||
Dynamic::new(0)
|
Dyn(0)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&(usize::MAX..=usize::MAX), Dynamic::new(usize::MAX)),
|
DimRange::length(&(usize::MAX..=usize::MAX), Dyn(usize::MAX)),
|
||||||
Dynamic::new(1)
|
Dyn(1)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Dim> DimRange<D> for ops::RangeTo<usize> {
|
impl<D: Dim> DimRange<D> for ops::RangeTo<usize> {
|
||||||
type Length = Dynamic;
|
type Length = Dyn;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn lower(&self, _: D) -> usize {
|
fn lower(&self, _: D) -> usize {
|
||||||
|
@ -244,7 +241,7 @@ impl<D: Dim> DimRange<D> for ops::RangeTo<usize> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn length(&self, _: D) -> Self::Length {
|
fn length(&self, _: D) -> Self::Length {
|
||||||
Dynamic::new(self.end)
|
Dyn(self.end)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -260,20 +257,20 @@ fn dimrange_rangeto_usize() {
|
||||||
assert!(DimRange::contained_by(&(..0), Const::<1>));
|
assert!(DimRange::contained_by(&(..0), Const::<1>));
|
||||||
assert!(DimRange::contained_by(
|
assert!(DimRange::contained_by(
|
||||||
&(..(usize::MAX - 1)),
|
&(..(usize::MAX - 1)),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
));
|
));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&(..(usize::MAX - 1)), Dynamic::new(usize::MAX)),
|
DimRange::length(&(..(usize::MAX - 1)), Dyn(usize::MAX)),
|
||||||
Dynamic::new(usize::MAX - 1)
|
Dyn(usize::MAX - 1)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&(..usize::MAX), Dynamic::new(usize::MAX)),
|
DimRange::length(&(..usize::MAX), Dyn(usize::MAX)),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Dim> DimRange<D> for ops::RangeToInclusive<usize> {
|
impl<D: Dim> DimRange<D> for ops::RangeToInclusive<usize> {
|
||||||
type Length = Dynamic;
|
type Length = Dyn;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn lower(&self, _: D) -> usize {
|
fn lower(&self, _: D) -> usize {
|
||||||
|
@ -282,7 +279,7 @@ impl<D: Dim> DimRange<D> for ops::RangeToInclusive<usize> {
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn length(&self, _: D) -> Self::Length {
|
fn length(&self, _: D) -> Self::Length {
|
||||||
Dynamic::new(self.end + 1)
|
Dyn(self.end + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -296,17 +293,14 @@ fn dimrange_rangetoinclusive_usize() {
|
||||||
assert!(!DimRange::contained_by(&(..=0), Const::<0>));
|
assert!(!DimRange::contained_by(&(..=0), Const::<0>));
|
||||||
assert!(!DimRange::contained_by(&(..=1), Const::<0>));
|
assert!(!DimRange::contained_by(&(..=1), Const::<0>));
|
||||||
assert!(DimRange::contained_by(&(..=0), Const::<1>));
|
assert!(DimRange::contained_by(&(..=0), Const::<1>));
|
||||||
assert!(!DimRange::contained_by(
|
assert!(!DimRange::contained_by(&(..=(usize::MAX)), Dyn(usize::MAX)));
|
||||||
&(..=(usize::MAX)),
|
|
||||||
Dynamic::new(usize::MAX)
|
|
||||||
));
|
|
||||||
assert!(DimRange::contained_by(
|
assert!(DimRange::contained_by(
|
||||||
&(..=(usize::MAX - 1)),
|
&(..=(usize::MAX - 1)),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
));
|
));
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
DimRange::length(&(..=(usize::MAX - 1)), Dynamic::new(usize::MAX)),
|
DimRange::length(&(..=(usize::MAX - 1)), Dyn(usize::MAX)),
|
||||||
Dynamic::new(usize::MAX)
|
Dyn(usize::MAX)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -378,7 +372,7 @@ pub trait MatrixIndexMut<'a, T, R: Dim, C: Dim, S: RawStorageMut<T, R, C>>:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// # Slicing based on ranges
|
/// # Views based on ranges
|
||||||
/// ## Indices to Individual Elements
|
/// ## Indices to Individual Elements
|
||||||
/// ### Two-Dimensional Indices
|
/// ### Two-Dimensional Indices
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -669,7 +663,7 @@ macro_rules! impl_index_pair {
|
||||||
$( $RConstraintType: $RConstraintBound $(<$( $RConstraintBoundParams $( = $REqBound )*),*>)* ,)*
|
$( $RConstraintType: $RConstraintBound $(<$( $RConstraintBoundParams $( = $REqBound )*),*>)* ,)*
|
||||||
$( $CConstraintType: $CConstraintBound $(<$( $CConstraintBoundParams $( = $CEqBound )*),*>)* ),*
|
$( $CConstraintType: $CConstraintBound $(<$( $CConstraintBoundParams $( = $CEqBound )*),*>)* ),*
|
||||||
{
|
{
|
||||||
type Output = MatrixSlice<'a, T, $ROut, $COut, S::RStride, S::CStride>;
|
type Output = MatrixView<'a, T, $ROut, $COut, S::RStride, S::CStride>;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
@ -682,13 +676,13 @@ macro_rules! impl_index_pair {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn get_unchecked(self, matrix: &'a Matrix<T, $R, $C, S>) -> Self::Output {
|
unsafe fn get_unchecked(self, matrix: &'a Matrix<T, $R, $C, S>) -> Self::Output {
|
||||||
use crate::base::SliceStorage;
|
use crate::base::ViewStorage;
|
||||||
|
|
||||||
let (rows, cols) = self;
|
let (rows, cols) = self;
|
||||||
let (nrows, ncols) = matrix.shape_generic();
|
let (nrows, ncols) = matrix.shape_generic();
|
||||||
|
|
||||||
let data =
|
let data =
|
||||||
SliceStorage::new_unchecked(&matrix.data,
|
ViewStorage::new_unchecked(&matrix.data,
|
||||||
(rows.lower(nrows), cols.lower(ncols)),
|
(rows.lower(nrows), cols.lower(ncols)),
|
||||||
(rows.length(nrows), cols.length(ncols)));
|
(rows.length(nrows), cols.length(ncols)));
|
||||||
|
|
||||||
|
@ -705,18 +699,18 @@ macro_rules! impl_index_pair {
|
||||||
$( $RConstraintType: $RConstraintBound $(<$( $RConstraintBoundParams $( = $REqBound )*),*>)* ,)*
|
$( $RConstraintType: $RConstraintBound $(<$( $RConstraintBoundParams $( = $REqBound )*),*>)* ,)*
|
||||||
$( $CConstraintType: $CConstraintBound $(<$( $CConstraintBoundParams $( = $CEqBound )*),*>)* ),*
|
$( $CConstraintType: $CConstraintBound $(<$( $CConstraintBoundParams $( = $CEqBound )*),*>)* ),*
|
||||||
{
|
{
|
||||||
type OutputMut = MatrixSliceMut<'a, T, $ROut, $COut, S::RStride, S::CStride>;
|
type OutputMut = MatrixViewMut<'a, T, $ROut, $COut, S::RStride, S::CStride>;
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn get_unchecked_mut(self, matrix: &'a mut Matrix<T, $R, $C, S>) -> Self::OutputMut {
|
unsafe fn get_unchecked_mut(self, matrix: &'a mut Matrix<T, $R, $C, S>) -> Self::OutputMut {
|
||||||
use crate::base::SliceStorageMut;
|
use crate::base::ViewStorageMut;
|
||||||
|
|
||||||
let (rows, cols) = self;
|
let (rows, cols) = self;
|
||||||
let (nrows, ncols) = matrix.shape_generic();
|
let (nrows, ncols) = matrix.shape_generic();
|
||||||
|
|
||||||
let data =
|
let data =
|
||||||
SliceStorageMut::new_unchecked(&mut matrix.data,
|
ViewStorageMut::new_unchecked(&mut matrix.data,
|
||||||
(rows.lower(nrows), cols.lower(ncols)),
|
(rows.lower(nrows), cols.lower(ncols)),
|
||||||
(rows.length(nrows), cols.length(ncols)));
|
(rows.length(nrows), cols.length(ncols)));
|
||||||
|
|
||||||
|
@ -742,12 +736,12 @@ macro_rules! impl_index_pairs {
|
||||||
impl_index_pairs! {
|
impl_index_pairs! {
|
||||||
index R with {
|
index R with {
|
||||||
[<> usize => U1],
|
[<> usize => U1],
|
||||||
[<> ops::Range<usize> => Dynamic],
|
[<> ops::Range<usize> => Dyn],
|
||||||
[<> ops::RangeFrom<usize> => Dynamic],
|
[<> ops::RangeFrom<usize> => Dyn],
|
||||||
[<> ops::RangeFull => R],
|
[<> ops::RangeFull => R],
|
||||||
[<> ops::RangeInclusive<usize> => Dynamic],
|
[<> ops::RangeInclusive<usize> => Dyn],
|
||||||
[<> ops::RangeTo<usize> => Dynamic],
|
[<> ops::RangeTo<usize> => Dyn],
|
||||||
[<> ops::RangeToInclusive<usize> => Dynamic],
|
[<> ops::RangeToInclusive<usize> => Dyn],
|
||||||
|
|
||||||
[<I: Dim> ops::RangeFrom<I>
|
[<I: Dim> ops::RangeFrom<I>
|
||||||
=> DimDiff<R, I>
|
=> DimDiff<R, I>
|
||||||
|
@ -755,12 +749,12 @@ impl_index_pairs! {
|
||||||
}
|
}
|
||||||
index C with {
|
index C with {
|
||||||
[<> usize => U1],
|
[<> usize => U1],
|
||||||
[<> ops::Range<usize> => Dynamic],
|
[<> ops::Range<usize> => Dyn],
|
||||||
[<> ops::RangeFrom<usize> => Dynamic],
|
[<> ops::RangeFrom<usize> => Dyn],
|
||||||
[<> ops::RangeFull => C],
|
[<> ops::RangeFull => C],
|
||||||
[<> ops::RangeInclusive<usize> => Dynamic],
|
[<> ops::RangeInclusive<usize> => Dyn],
|
||||||
[<> ops::RangeTo<usize> => Dynamic],
|
[<> ops::RangeTo<usize> => Dyn],
|
||||||
[<> ops::RangeToInclusive<usize> => Dynamic],
|
[<> ops::RangeToInclusive<usize> => Dyn],
|
||||||
|
|
||||||
[<J: DimName> ops::RangeFrom<J>
|
[<J: DimName> ops::RangeFrom<J>
|
||||||
=> DimDiff<C, J>
|
=> DimDiff<C, J>
|
||||||
|
|
133
src/base/iter.rs
133
src/base/iter.rs
|
@ -1,12 +1,18 @@
|
||||||
//! Matrix iterators.
|
//! Matrix iterators.
|
||||||
|
|
||||||
|
// only enables the `doc_cfg` feature when
|
||||||
|
// the `docsrs` configuration attribute is defined
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
|
use core::fmt::Debug;
|
||||||
|
use core::ops::Range;
|
||||||
use std::iter::FusedIterator;
|
use std::iter::FusedIterator;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
|
||||||
use crate::base::dimension::{Dim, U1};
|
use crate::base::dimension::{Dim, U1};
|
||||||
use crate::base::storage::{RawStorage, RawStorageMut};
|
use crate::base::storage::{RawStorage, RawStorageMut};
|
||||||
use crate::base::{Matrix, MatrixSlice, MatrixSliceMut, Scalar};
|
use crate::base::{Matrix, MatrixView, MatrixViewMut, Scalar};
|
||||||
|
|
||||||
macro_rules! iterator {
|
macro_rules! iterator {
|
||||||
(struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => {
|
(struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => {
|
||||||
|
@ -193,7 +199,7 @@ impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> RowIter<'a, T, R, C, S>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> Iterator for RowIter<'a, T, R, C, S> {
|
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> Iterator for RowIter<'a, T, R, C, S> {
|
||||||
type Item = MatrixSlice<'a, T, U1, C, S::RStride, S::CStride>;
|
type Item = MatrixView<'a, T, U1, C, S::RStride, S::CStride>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
@ -254,7 +260,7 @@ impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> RowIterMut<'a, T, R,
|
||||||
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Iterator
|
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Iterator
|
||||||
for RowIterMut<'a, T, R, C, S>
|
for RowIterMut<'a, T, R, C, S>
|
||||||
{
|
{
|
||||||
type Item = MatrixSliceMut<'a, T, U1, C, S::RStride, S::CStride>;
|
type Item = MatrixViewMut<'a, T, U1, C, S::RStride, S::CStride>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
@ -288,7 +294,6 @@ impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> ExactSizeIte
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
|
||||||
* Column iterators.
|
* Column iterators.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -296,23 +301,45 @@ impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> ExactSizeIte
|
||||||
/// An iterator through the columns of a matrix.
|
/// An iterator through the columns of a matrix.
|
||||||
pub struct ColumnIter<'a, T, R: Dim, C: Dim, S: RawStorage<T, R, C>> {
|
pub struct ColumnIter<'a, T, R: Dim, C: Dim, S: RawStorage<T, R, C>> {
|
||||||
mat: &'a Matrix<T, R, C, S>,
|
mat: &'a Matrix<T, R, C, S>,
|
||||||
curr: usize,
|
range: Range<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> ColumnIter<'a, T, R, C, S> {
|
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> ColumnIter<'a, T, R, C, S> {
|
||||||
|
/// a new column iterator covering all columns of the matrix
|
||||||
pub(crate) fn new(mat: &'a Matrix<T, R, C, S>) -> Self {
|
pub(crate) fn new(mat: &'a Matrix<T, R, C, S>) -> Self {
|
||||||
ColumnIter { mat, curr: 0 }
|
ColumnIter {
|
||||||
|
mat,
|
||||||
|
range: 0..mat.ncols(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn split_at(self, index: usize) -> (Self, Self) {
|
||||||
|
// SAFETY: this makes sur the generated ranges are valid.
|
||||||
|
let split_pos = (self.range.start + index).min(self.range.end);
|
||||||
|
|
||||||
|
let left_iter = ColumnIter {
|
||||||
|
mat: self.mat,
|
||||||
|
range: self.range.start..split_pos,
|
||||||
|
};
|
||||||
|
|
||||||
|
let right_iter = ColumnIter {
|
||||||
|
mat: self.mat,
|
||||||
|
range: split_pos..self.range.end,
|
||||||
|
};
|
||||||
|
|
||||||
|
(left_iter, right_iter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> Iterator for ColumnIter<'a, T, R, C, S> {
|
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> Iterator for ColumnIter<'a, T, R, C, S> {
|
||||||
type Item = MatrixSlice<'a, T, R, U1, S::RStride, S::CStride>;
|
type Item = MatrixView<'a, T, R, U1, S::RStride, S::CStride>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
if self.curr < self.mat.ncols() {
|
debug_assert!(self.range.start <= self.range.end);
|
||||||
let res = self.mat.column(self.curr);
|
if self.range.start < self.range.end {
|
||||||
self.curr += 1;
|
let res = self.mat.column(self.range.start);
|
||||||
|
self.range.start += 1;
|
||||||
Some(res)
|
Some(res)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -321,15 +348,29 @@ impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> Iterator for ColumnIter
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
(
|
let hint = self.range.len();
|
||||||
self.mat.ncols() - self.curr,
|
(hint, Some(hint))
|
||||||
Some(self.mat.ncols() - self.curr),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn count(self) -> usize {
|
fn count(self) -> usize {
|
||||||
self.mat.ncols() - self.curr
|
self.range.len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> DoubleEndedIterator
|
||||||
|
for ColumnIter<'a, T, R, C, S>
|
||||||
|
{
|
||||||
|
fn next_back(&mut self) -> Option<Self::Item> {
|
||||||
|
debug_assert!(self.range.start <= self.range.end);
|
||||||
|
if !self.range.is_empty() {
|
||||||
|
self.range.end -= 1;
|
||||||
|
debug_assert!(self.range.end < self.mat.ncols());
|
||||||
|
debug_assert!(self.range.end >= self.range.start);
|
||||||
|
Some(self.mat.column(self.range.end))
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +379,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> ExactSizeIterat
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
self.mat.ncols() - self.curr
|
self.range.end - self.range.start
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,19 +387,39 @@ impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> ExactSizeIterat
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ColumnIterMut<'a, T, R: Dim, C: Dim, S: RawStorageMut<T, R, C>> {
|
pub struct ColumnIterMut<'a, T, R: Dim, C: Dim, S: RawStorageMut<T, R, C>> {
|
||||||
mat: *mut Matrix<T, R, C, S>,
|
mat: *mut Matrix<T, R, C, S>,
|
||||||
curr: usize,
|
range: Range<usize>,
|
||||||
phantom: PhantomData<&'a mut Matrix<T, R, C, S>>,
|
phantom: PhantomData<&'a mut Matrix<T, R, C, S>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> ColumnIterMut<'a, T, R, C, S> {
|
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> ColumnIterMut<'a, T, R, C, S> {
|
||||||
pub(crate) fn new(mat: &'a mut Matrix<T, R, C, S>) -> Self {
|
pub(crate) fn new(mat: &'a mut Matrix<T, R, C, S>) -> Self {
|
||||||
|
let range = 0..mat.ncols();
|
||||||
ColumnIterMut {
|
ColumnIterMut {
|
||||||
mat,
|
mat,
|
||||||
curr: 0,
|
range,
|
||||||
phantom: PhantomData,
|
phantom: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn split_at(self, index: usize) -> (Self, Self) {
|
||||||
|
// SAFETY: this makes sur the generated ranges are valid.
|
||||||
|
let split_pos = (self.range.start + index).min(self.range.end);
|
||||||
|
|
||||||
|
let left_iter = ColumnIterMut {
|
||||||
|
mat: self.mat,
|
||||||
|
range: self.range.start..split_pos,
|
||||||
|
phantom: Default::default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let right_iter = ColumnIterMut {
|
||||||
|
mat: self.mat,
|
||||||
|
range: split_pos..self.range.end,
|
||||||
|
phantom: Default::default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
(left_iter, right_iter)
|
||||||
|
}
|
||||||
|
|
||||||
fn ncols(&self) -> usize {
|
fn ncols(&self) -> usize {
|
||||||
unsafe { (*self.mat).ncols() }
|
unsafe { (*self.mat).ncols() }
|
||||||
}
|
}
|
||||||
|
@ -367,13 +428,14 @@ impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> ColumnIterMut<'a, T,
|
||||||
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Iterator
|
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Iterator
|
||||||
for ColumnIterMut<'a, T, R, C, S>
|
for ColumnIterMut<'a, T, R, C, S>
|
||||||
{
|
{
|
||||||
type Item = MatrixSliceMut<'a, T, R, U1, S::RStride, S::CStride>;
|
type Item = MatrixViewMut<'a, T, R, U1, S::RStride, S::CStride>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&'_ mut self) -> Option<Self::Item> {
|
||||||
if self.curr < self.ncols() {
|
debug_assert!(self.range.start <= self.range.end);
|
||||||
let res = unsafe { (*self.mat).column_mut(self.curr) };
|
if self.range.start < self.range.end {
|
||||||
self.curr += 1;
|
let res = unsafe { (*self.mat).column_mut(self.range.start) };
|
||||||
|
self.range.start += 1;
|
||||||
Some(res)
|
Some(res)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -382,12 +444,13 @@ impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Iterator
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
(self.ncols() - self.curr, Some(self.ncols() - self.curr))
|
let hint = self.range.len();
|
||||||
|
(hint, Some(hint))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn count(self) -> usize {
|
fn count(self) -> usize {
|
||||||
self.ncols() - self.curr
|
self.range.len()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -396,6 +459,22 @@ impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> ExactSizeIte
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
self.ncols() - self.curr
|
self.range.len()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> DoubleEndedIterator
|
||||||
|
for ColumnIterMut<'a, T, R, C, S>
|
||||||
|
{
|
||||||
|
fn next_back(&mut self) -> Option<Self::Item> {
|
||||||
|
debug_assert!(self.range.start <= self.range.end);
|
||||||
|
if !self.range.is_empty() {
|
||||||
|
self.range.end -= 1;
|
||||||
|
debug_assert!(self.range.end < self.ncols());
|
||||||
|
debug_assert!(self.range.end >= self.range.start);
|
||||||
|
Some(unsafe { (*self.mat).column_mut(self.range.end) })
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,11 @@ use std::mem;
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use super::rkyv_wrappers::CustomPhantom;
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
use rkyv::{with::With, Archive, Archived};
|
||||||
|
|
||||||
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, Field, SupersetOf};
|
use simba::scalar::{ClosedAdd, ClosedMul, ClosedSub, Field, SupersetOf};
|
||||||
use simba::simd::SimdPartialOrd;
|
use simba::simd::SimdPartialOrd;
|
||||||
|
|
||||||
|
@ -27,7 +32,7 @@ use crate::{ArrayStorage, SMatrix, SimdComplexField, Storage, UninitMatrix};
|
||||||
use crate::storage::IsContiguous;
|
use crate::storage::IsContiguous;
|
||||||
use crate::uninit::{Init, InitStatus, Uninit};
|
use crate::uninit::{Init, InitStatus, Uninit};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use crate::{DMatrix, DVector, Dynamic, RowDVector, VecStorage};
|
use crate::{DMatrix, DVector, Dyn, RowDVector, VecStorage};
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
|
|
||||||
/// A square matrix.
|
/// A square matrix.
|
||||||
|
@ -96,16 +101,17 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
||||||
///
|
///
|
||||||
/// #### Iteration, map, and fold
|
/// #### Iteration, map, and fold
|
||||||
/// - [Iteration on components, rows, and columns <span style="float:right;">`iter`, `column_iter`…</span>](#iteration-on-components-rows-and-columns)
|
/// - [Iteration on components, rows, and columns <span style="float:right;">`iter`, `column_iter`…</span>](#iteration-on-components-rows-and-columns)
|
||||||
|
/// - [Parallel iterators using rayon <span style="float:right;">`par_column_iter`, `par_column_iter_mut`…</span>](#parallel-iterators-using-rayon)
|
||||||
/// - [Elementwise mapping and folding <span style="float:right;">`map`, `fold`, `zip_map`…</span>](#elementwise-mapping-and-folding)
|
/// - [Elementwise mapping and folding <span style="float:right;">`map`, `fold`, `zip_map`…</span>](#elementwise-mapping-and-folding)
|
||||||
/// - [Folding or columns and rows <span style="float:right;">`compress_rows`, `compress_columns`…</span>](#folding-on-columns-and-rows)
|
/// - [Folding or columns and rows <span style="float:right;">`compress_rows`, `compress_columns`…</span>](#folding-on-columns-and-rows)
|
||||||
///
|
///
|
||||||
/// #### Vector and matrix slicing
|
/// #### Vector and matrix views
|
||||||
/// - [Creating matrix slices from `&[T]` <span style="float:right;">`from_slice`, `from_slice_with_strides`…</span>](#creating-matrix-slices-from-t)
|
/// - [Creating matrix views from `&[T]` <span style="float:right;">`from_slice`, `from_slice_with_strides`…</span>](#creating-matrix-views-from-t)
|
||||||
/// - [Creating mutable matrix slices from `&mut [T]` <span style="float:right;">`from_slice_mut`, `from_slice_with_strides_mut`…</span>](#creating-mutable-matrix-slices-from-mut-t)
|
/// - [Creating mutable matrix views from `&mut [T]` <span style="float:right;">`from_slice_mut`, `from_slice_with_strides_mut`…</span>](#creating-mutable-matrix-views-from-mut-t)
|
||||||
/// - [Slicing based on index and length <span style="float:right;">`row`, `columns`, `slice`…</span>](#slicing-based-on-index-and-length)
|
/// - [Views based on index and length <span style="float:right;">`row`, `columns`, `view`…</span>](#views-based-on-index-and-length)
|
||||||
/// - [Mutable slicing based on index and length <span style="float:right;">`row_mut`, `columns_mut`, `slice_mut`…</span>](#mutable-slicing-based-on-index-and-length)
|
/// - [Mutable views based on index and length <span style="float:right;">`row_mut`, `columns_mut`, `view_mut`…</span>](#mutable-views-based-on-index-and-length)
|
||||||
/// - [Slicing based on ranges <span style="float:right;">`rows_range`, `columns_range`…</span>](#slicing-based-on-ranges)
|
/// - [Views based on ranges <span style="float:right;">`rows_range`, `columns_range`…</span>](#views-based-on-ranges)
|
||||||
/// - [Mutable slicing based on ranges <span style="float:right;">`rows_range_mut`, `columns_range_mut`…</span>](#mutable-slicing-based-on-ranges)
|
/// - [Mutable views based on ranges <span style="float:right;">`rows_range_mut`, `columns_range_mut`…</span>](#mutable-views-based-on-ranges)
|
||||||
///
|
///
|
||||||
/// #### In-place modification of a single matrix or vector
|
/// #### In-place modification of a single matrix or vector
|
||||||
/// - [In-place filling <span style="float:right;">`fill`, `fill_diagonal`, `fill_with_identity`…</span>](#in-place-filling)
|
/// - [In-place filling <span style="float:right;">`fill`, `fill_diagonal`, `fill_with_identity`…</span>](#in-place-filling)
|
||||||
|
@ -140,21 +146,29 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
||||||
/// - type-level unsigned integer constants (e.g. `U1024`, `U10000`) from the `typenum::` crate.
|
/// - type-level unsigned integer constants (e.g. `U1024`, `U10000`) from the `typenum::` crate.
|
||||||
/// Using those, you will not get error messages as nice as for numbers smaller than 128 defined on
|
/// Using those, you will not get error messages as nice as for numbers smaller than 128 defined on
|
||||||
/// the `nalgebra::` module.
|
/// the `nalgebra::` module.
|
||||||
/// - the special value `Dynamic` from the `nalgebra::` root module. This indicates that the
|
/// - the special value `Dyn` from the `nalgebra::` root module. This indicates that the
|
||||||
/// specified dimension is not known at compile-time. Note that this will generally imply that the
|
/// specified dimension is not known at compile-time. Note that this will generally imply that the
|
||||||
/// matrix data storage `S` performs a dynamic allocation and contains extra metadata for the
|
/// matrix data storage `S` performs a dynamic allocation and contains extra metadata for the
|
||||||
/// matrix shape.
|
/// matrix shape.
|
||||||
///
|
///
|
||||||
/// Note that mixing `Dynamic` with type-level unsigned integers is allowed. Actually, a
|
/// Note that mixing `Dyn` with type-level unsigned integers is allowed. Actually, a
|
||||||
/// dynamically-sized column vector should be represented as a `Matrix<T, Dynamic, U1, S>` (given
|
/// dynamically-sized column vector should be represented as a `Matrix<T, Dyn, U1, S>` (given
|
||||||
/// some concrete types for `T` and a compatible data storage type `S`).
|
/// some concrete types for `T` and a compatible data storage type `S`).
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Matrix<T::Archived, R, C, S::Archived>",
|
||||||
|
bound(archive = "
|
||||||
|
T: Archive,
|
||||||
|
S: Archive,
|
||||||
|
With<PhantomData<(T, R, C)>, CustomPhantom<(Archived<T>, R, C)>>: Archive<Archived = PhantomData<(Archived<T>, R, C)>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
pub struct Matrix<T, R, C, S> {
|
pub struct Matrix<T, R, C, S> {
|
||||||
/// The data storage that contains all the matrix components. Disappointed?
|
/// The data storage that contains all the matrix components. Disappointed?
|
||||||
|
@ -192,6 +206,7 @@ pub struct Matrix<T, R, C, S> {
|
||||||
// of the `RawStorage` trait. However, because we don't have
|
// of the `RawStorage` trait. However, because we don't have
|
||||||
// specialization, this is not possible because these `T, R, C`
|
// specialization, this is not possible because these `T, R, C`
|
||||||
// allows us to desambiguate a lot of configurations.
|
// allows us to desambiguate a lot of configurations.
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize-no-std", with(CustomPhantom<(T::Archived, R, C)>))]
|
||||||
_phantoms: PhantomData<(T, R, C)>,
|
_phantoms: PhantomData<(T, R, C)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,7 +341,7 @@ impl<T> DMatrix<T> {
|
||||||
///
|
///
|
||||||
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
||||||
/// work in `const fn` contexts.
|
/// work in `const fn` contexts.
|
||||||
pub const fn from_vec_storage(storage: VecStorage<T, Dynamic, Dynamic>) -> Self {
|
pub const fn from_vec_storage(storage: VecStorage<T, Dyn, Dyn>) -> Self {
|
||||||
// This is sound because the dimensions of the matrix and the storage are guaranteed
|
// This is sound because the dimensions of the matrix and the storage are guaranteed
|
||||||
// to be the same
|
// to be the same
|
||||||
unsafe { Self::from_data_statically_unchecked(storage) }
|
unsafe { Self::from_data_statically_unchecked(storage) }
|
||||||
|
@ -341,7 +356,7 @@ impl<T> DVector<T> {
|
||||||
///
|
///
|
||||||
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
||||||
/// work in `const fn` contexts.
|
/// work in `const fn` contexts.
|
||||||
pub const fn from_vec_storage(storage: VecStorage<T, Dynamic, U1>) -> Self {
|
pub const fn from_vec_storage(storage: VecStorage<T, Dyn, U1>) -> Self {
|
||||||
// This is sound because the dimensions of the matrix and the storage are guaranteed
|
// This is sound because the dimensions of the matrix and the storage are guaranteed
|
||||||
// to be the same
|
// to be the same
|
||||||
unsafe { Self::from_data_statically_unchecked(storage) }
|
unsafe { Self::from_data_statically_unchecked(storage) }
|
||||||
|
@ -356,7 +371,7 @@ impl<T> RowDVector<T> {
|
||||||
///
|
///
|
||||||
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
||||||
/// work in `const fn` contexts.
|
/// work in `const fn` contexts.
|
||||||
pub const fn from_vec_storage(storage: VecStorage<T, U1, Dynamic>) -> Self {
|
pub const fn from_vec_storage(storage: VecStorage<T, U1, Dyn>) -> Self {
|
||||||
// This is sound because the dimensions of the matrix and the storage are guaranteed
|
// This is sound because the dimensions of the matrix and the storage are guaranteed
|
||||||
// to be the same
|
// to be the same
|
||||||
unsafe { Self::from_data_statically_unchecked(storage) }
|
unsafe { Self::from_data_statically_unchecked(storage) }
|
||||||
|
@ -402,7 +417,7 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
(nrows.value(), ncols.value())
|
(nrows.value(), ncols.value())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The shape of this matrix wrapped into their representative types (`Const` or `Dynamic`).
|
/// The shape of this matrix wrapped into their representative types (`Const` or `Dyn`).
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn shape_generic(&self) -> (R, C) {
|
pub fn shape_generic(&self) -> (R, C) {
|
||||||
|
@ -443,7 +458,7 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// ```
|
/// ```
|
||||||
/// # use nalgebra::DMatrix;
|
/// # use nalgebra::DMatrix;
|
||||||
/// let mat = DMatrix::<f32>::zeros(10, 10);
|
/// let mat = DMatrix::<f32>::zeros(10, 10);
|
||||||
/// let slice = mat.slice_with_steps((0, 0), (5, 3), (1, 2));
|
/// let view = mat.view_with_steps((0, 0), (5, 3), (1, 2));
|
||||||
/// // The column strides is the number of steps (here 2) multiplied by the corresponding dimension.
|
/// // The column strides is the number of steps (here 2) multiplied by the corresponding dimension.
|
||||||
/// assert_eq!(mat.strides(), (1, 10));
|
/// assert_eq!(mat.strides(), (1, 10));
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -736,6 +751,24 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
crate::convert(self)
|
crate::convert(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Attempts to cast the components of `self` to another type.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
/// ```
|
||||||
|
/// # use nalgebra::Vector3;
|
||||||
|
/// let q = Vector3::new(1.0f64, 2.0, 3.0);
|
||||||
|
/// let q2 = q.try_cast::<i32>();
|
||||||
|
/// assert_eq!(q2, Some(Vector3::new(1, 2, 3)));
|
||||||
|
/// ```
|
||||||
|
pub fn try_cast<T2: Scalar>(self) -> Option<OMatrix<T2, R, C>>
|
||||||
|
where
|
||||||
|
T: Scalar,
|
||||||
|
Self: SupersetOf<OMatrix<T2, R, C>>,
|
||||||
|
DefaultAllocator: Allocator<T2, R, C>,
|
||||||
|
{
|
||||||
|
crate::try_convert(self)
|
||||||
|
}
|
||||||
|
|
||||||
/// Similar to `self.iter().fold(init, f)` except that `init` is replaced by a closure.
|
/// Similar to `self.iter().fold(init, f)` except that `init` is replaced by a closure.
|
||||||
///
|
///
|
||||||
/// The initialization closure is given the first component of this matrix:
|
/// The initialization closure is given the first component of this matrix:
|
||||||
|
@ -1612,7 +1645,7 @@ impl<T: Scalar + Zero + One, D: DimAdd<U1> + IsNotStaticOne, S: RawStorage<T, D,
|
||||||
);
|
);
|
||||||
let dim = DimSum::<D, U1>::from_usize(self.nrows() + 1);
|
let dim = DimSum::<D, U1>::from_usize(self.nrows() + 1);
|
||||||
let mut res = OMatrix::identity_generic(dim, dim);
|
let mut res = OMatrix::identity_generic(dim, dim);
|
||||||
res.generic_slice_mut::<D, D>((0, 0), self.shape_generic())
|
res.generic_view_mut::<D, D>((0, 0), self.shape_generic())
|
||||||
.copy_from(self);
|
.copy_from(self);
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
@ -1640,7 +1673,7 @@ impl<T: Scalar + Zero, D: DimAdd<U1>, S: RawStorage<T, D>> Vector<T, D, S> {
|
||||||
{
|
{
|
||||||
if v[v.len() - 1].is_zero() {
|
if v[v.len() - 1].is_zero() {
|
||||||
let nrows = D::from_usize(v.len() - 1);
|
let nrows = D::from_usize(v.len() - 1);
|
||||||
Some(v.generic_slice((0, 0), (nrows, Const::<1>)).into_owned())
|
Some(v.generic_view((0, 0), (nrows, Const::<1>)).into_owned())
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -1660,7 +1693,7 @@ impl<T: Scalar, D: DimAdd<U1>, S: RawStorage<T, D>> Vector<T, D, S> {
|
||||||
let mut res = Matrix::uninit(hnrows, Const::<1>);
|
let mut res = Matrix::uninit(hnrows, Const::<1>);
|
||||||
// This is basically a copy_from except that we warp the copied
|
// This is basically a copy_from except that we warp the copied
|
||||||
// values into MaybeUninit.
|
// values into MaybeUninit.
|
||||||
res.generic_slice_mut((0, 0), self.shape_generic())
|
res.generic_view_mut((0, 0), self.shape_generic())
|
||||||
.zip_apply(self, |out, e| *out = MaybeUninit::new(e));
|
.zip_apply(self, |out, e| *out = MaybeUninit::new(e));
|
||||||
res[(len, 0)] = MaybeUninit::new(element);
|
res[(len, 0)] = MaybeUninit::new(element);
|
||||||
|
|
||||||
|
|
|
@ -1,955 +0,0 @@
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::ops::{Range, RangeFrom, RangeFull, RangeInclusive, RangeTo};
|
|
||||||
use std::slice;
|
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
|
||||||
use crate::base::default_allocator::DefaultAllocator;
|
|
||||||
use crate::base::dimension::{Const, Dim, DimName, Dynamic, IsNotStaticOne, U1};
|
|
||||||
use crate::base::iter::MatrixIter;
|
|
||||||
use crate::base::storage::{IsContiguous, Owned, RawStorage, RawStorageMut, Storage};
|
|
||||||
use crate::base::{Matrix, Scalar};
|
|
||||||
|
|
||||||
macro_rules! slice_storage_impl(
|
|
||||||
($doc: expr; $Storage: ident as $SRef: ty; $T: ident.$get_addr: ident ($Ptr: ty as $Ref: ty)) => {
|
|
||||||
#[doc = $doc]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct $T<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> {
|
|
||||||
ptr: $Ptr,
|
|
||||||
shape: (R, C),
|
|
||||||
strides: (RStride, CStride),
|
|
||||||
_phantoms: PhantomData<$Ref>,
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<'a, T: Send, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Send
|
|
||||||
for $T<'a, T, R, C, RStride, CStride>
|
|
||||||
{}
|
|
||||||
|
|
||||||
unsafe impl<'a, T: Sync, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Sync
|
|
||||||
for $T<'a, T, R, C, RStride, CStride>
|
|
||||||
{}
|
|
||||||
|
|
||||||
impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> $T<'a, T, R, C, RStride, CStride> {
|
|
||||||
/// Create a new matrix slice without bound checking and from a raw pointer.
|
|
||||||
#[inline]
|
|
||||||
pub unsafe fn from_raw_parts(ptr: $Ptr,
|
|
||||||
shape: (R, C),
|
|
||||||
strides: (RStride, CStride))
|
|
||||||
-> Self
|
|
||||||
where RStride: Dim,
|
|
||||||
CStride: Dim {
|
|
||||||
|
|
||||||
$T {
|
|
||||||
ptr,
|
|
||||||
shape,
|
|
||||||
strides,
|
|
||||||
_phantoms: PhantomData
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dynamic is arbitrary. It's just to be able to call the constructors with `Slice::`
|
|
||||||
impl<'a, T, R: Dim, C: Dim> $T<'a, T, R, C, Dynamic, Dynamic> {
|
|
||||||
/// Create a new matrix slice without bound checking.
|
|
||||||
#[inline]
|
|
||||||
pub unsafe fn new_unchecked<RStor, CStor, S>(storage: $SRef, start: (usize, usize), shape: (R, C))
|
|
||||||
-> $T<'a, T, R, C, S::RStride, S::CStride>
|
|
||||||
where RStor: Dim,
|
|
||||||
CStor: Dim,
|
|
||||||
S: $Storage<T, RStor, CStor> {
|
|
||||||
|
|
||||||
let strides = storage.strides();
|
|
||||||
$T::new_with_strides_unchecked(storage, start, shape, strides)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a new matrix slice without bound checking.
|
|
||||||
#[inline]
|
|
||||||
pub unsafe fn new_with_strides_unchecked<S, RStor, CStor, RStride, CStride>(storage: $SRef,
|
|
||||||
start: (usize, usize),
|
|
||||||
shape: (R, C),
|
|
||||||
strides: (RStride, CStride))
|
|
||||||
-> $T<'a, T, R, C, RStride, CStride>
|
|
||||||
where RStor: Dim,
|
|
||||||
CStor: Dim,
|
|
||||||
S: $Storage<T, RStor, CStor>,
|
|
||||||
RStride: Dim,
|
|
||||||
CStride: Dim {
|
|
||||||
$T::from_raw_parts(storage.$get_addr(start.0, start.1), shape, strides)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl <'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
|
||||||
$T<'a, T, R, C, RStride, CStride>
|
|
||||||
where
|
|
||||||
Self: RawStorage<T, R, C> + IsContiguous
|
|
||||||
{
|
|
||||||
/// Extracts the original slice from this storage
|
|
||||||
pub fn into_slice(self) -> &'a [T] {
|
|
||||||
let (nrows, ncols) = self.shape();
|
|
||||||
if nrows.value() != 0 && ncols.value() != 0 {
|
|
||||||
let sz = self.linear_index(nrows.value() - 1, ncols.value() - 1);
|
|
||||||
unsafe { slice::from_raw_parts(self.ptr, sz + 1) }
|
|
||||||
} else {
|
|
||||||
unsafe { slice::from_raw_parts(self.ptr, 0) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
slice_storage_impl!("A matrix data storage for a matrix slice. Only contains an internal reference \
|
|
||||||
to another matrix data storage.";
|
|
||||||
RawStorage as &'a S; SliceStorage.get_address_unchecked(*const T as &'a T));
|
|
||||||
|
|
||||||
slice_storage_impl!("A mutable matrix data storage for mutable matrix slice. Only contains an \
|
|
||||||
internal mutable reference to another matrix data storage.";
|
|
||||||
RawStorageMut as &'a mut S; SliceStorageMut.get_address_unchecked_mut(*mut T as &'a mut T)
|
|
||||||
);
|
|
||||||
|
|
||||||
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy
|
|
||||||
for SliceStorage<'a, T, R, C, RStride, CStride>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone
|
|
||||||
for SliceStorage<'a, T, R, C, RStride, CStride>
|
|
||||||
{
|
|
||||||
#[inline]
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
Self {
|
|
||||||
ptr: self.ptr,
|
|
||||||
shape: self.shape,
|
|
||||||
strides: self.strides,
|
|
||||||
_phantoms: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
|
||||||
SliceStorageMut<'a, T, R, C, RStride, CStride>
|
|
||||||
where
|
|
||||||
Self: RawStorageMut<T, R, C> + IsContiguous,
|
|
||||||
{
|
|
||||||
/// Extracts the original slice from this storage
|
|
||||||
pub fn into_slice_mut(self) -> &'a mut [T] {
|
|
||||||
let (nrows, ncols) = self.shape();
|
|
||||||
if nrows.value() != 0 && ncols.value() != 0 {
|
|
||||||
let sz = self.linear_index(nrows.value() - 1, ncols.value() - 1);
|
|
||||||
unsafe { slice::from_raw_parts_mut(self.ptr, sz + 1) }
|
|
||||||
} else {
|
|
||||||
unsafe { slice::from_raw_parts_mut(self.ptr, 0) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! storage_impl(
|
|
||||||
($($T: ident),* $(,)*) => {$(
|
|
||||||
unsafe impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> RawStorage<T, R, C>
|
|
||||||
for $T<'a, T, R, C, RStride, CStride> {
|
|
||||||
|
|
||||||
type RStride = RStride;
|
|
||||||
type CStride = CStride;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn ptr(&self) -> *const T {
|
|
||||||
self.ptr
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn shape(&self) -> (R, C) {
|
|
||||||
self.shape
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn strides(&self) -> (Self::RStride, Self::CStride) {
|
|
||||||
self.strides
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn is_contiguous(&self) -> bool {
|
|
||||||
// Common cases that can be deduced at compile-time even if one of the dimensions
|
|
||||||
// is Dynamic.
|
|
||||||
if (RStride::is::<U1>() && C::is::<U1>()) || // Column vector.
|
|
||||||
(CStride::is::<U1>() && R::is::<U1>()) { // Row vector.
|
|
||||||
true
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let (nrows, _) = self.shape();
|
|
||||||
let (srows, scols) = self.strides();
|
|
||||||
|
|
||||||
srows.value() == 1 && scols.value() == nrows.value()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
unsafe fn as_slice_unchecked(&self) -> &[T] {
|
|
||||||
let (nrows, ncols) = self.shape();
|
|
||||||
if nrows.value() != 0 && ncols.value() != 0 {
|
|
||||||
let sz = self.linear_index(nrows.value() - 1, ncols.value() - 1);
|
|
||||||
slice::from_raw_parts(self.ptr, sz + 1)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
slice::from_raw_parts(self.ptr, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Storage<T, R, C>
|
|
||||||
for $T<'a, T, R, C, RStride, CStride> {
|
|
||||||
#[inline]
|
|
||||||
fn into_owned(self) -> Owned<T, R, C>
|
|
||||||
where DefaultAllocator: Allocator<T, R, C> {
|
|
||||||
self.clone_owned()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn clone_owned(&self) -> Owned<T, R, C>
|
|
||||||
where DefaultAllocator: Allocator<T, R, C> {
|
|
||||||
let (nrows, ncols) = self.shape();
|
|
||||||
let it = MatrixIter::new(self).cloned();
|
|
||||||
DefaultAllocator::allocate_from_iterator(nrows, ncols, it)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)*}
|
|
||||||
);
|
|
||||||
|
|
||||||
storage_impl!(SliceStorage, SliceStorageMut);
|
|
||||||
|
|
||||||
unsafe impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> RawStorageMut<T, R, C>
|
|
||||||
for SliceStorageMut<'a, T, R, C, RStride, CStride>
|
|
||||||
{
|
|
||||||
#[inline]
|
|
||||||
fn ptr_mut(&mut self) -> *mut T {
|
|
||||||
self.ptr
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
unsafe fn as_mut_slice_unchecked(&mut self) -> &mut [T] {
|
|
||||||
let (nrows, ncols) = self.shape();
|
|
||||||
if nrows.value() != 0 && ncols.value() != 0 {
|
|
||||||
let sz = self.linear_index(nrows.value() - 1, ncols.value() - 1);
|
|
||||||
slice::from_raw_parts_mut(self.ptr, sz + 1)
|
|
||||||
} else {
|
|
||||||
slice::from_raw_parts_mut(self.ptr, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<'a, T, R: Dim, CStride: Dim> IsContiguous for SliceStorage<'a, T, R, U1, U1, CStride> {}
|
|
||||||
unsafe impl<'a, T, R: Dim, CStride: Dim> IsContiguous
|
|
||||||
for SliceStorageMut<'a, T, R, U1, U1, CStride>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl<'a, T, R: DimName, C: Dim + IsNotStaticOne> IsContiguous
|
|
||||||
for SliceStorage<'a, T, R, C, U1, R>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
unsafe impl<'a, T, R: DimName, C: Dim + IsNotStaticOne> IsContiguous
|
|
||||||
for SliceStorageMut<'a, T, R, C, U1, R>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
|
||||||
#[inline]
|
|
||||||
fn assert_slice_index(
|
|
||||||
&self,
|
|
||||||
start: (usize, usize),
|
|
||||||
shape: (usize, usize),
|
|
||||||
steps: (usize, usize),
|
|
||||||
) {
|
|
||||||
let my_shape = self.shape();
|
|
||||||
// NOTE: we don't do any subtraction to avoid underflow for zero-sized matrices.
|
|
||||||
//
|
|
||||||
// Terms that would have been negative are moved to the other side of the inequality
|
|
||||||
// instead.
|
|
||||||
assert!(
|
|
||||||
start.0 + (steps.0 + 1) * shape.0 <= my_shape.0 + steps.0,
|
|
||||||
"Matrix slicing out of bounds."
|
|
||||||
);
|
|
||||||
assert!(
|
|
||||||
start.1 + (steps.1 + 1) * shape.1 <= my_shape.1 + steps.1,
|
|
||||||
"Matrix slicing out of bounds."
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! matrix_slice_impl(
|
|
||||||
($me: ident: $Me: ty, $MatrixSlice: ident, $SliceStorage: ident, $Storage: ident.$get_addr: ident (), $data: expr;
|
|
||||||
$row: ident,
|
|
||||||
$row_part: ident,
|
|
||||||
$rows: ident,
|
|
||||||
$rows_with_step: ident,
|
|
||||||
$fixed_rows: ident,
|
|
||||||
$fixed_rows_with_step: ident,
|
|
||||||
$rows_generic: ident,
|
|
||||||
$rows_generic_with_step: ident,
|
|
||||||
$column: ident,
|
|
||||||
$column_part: ident,
|
|
||||||
$columns: ident,
|
|
||||||
$columns_with_step: ident,
|
|
||||||
$fixed_columns: ident,
|
|
||||||
$fixed_columns_with_step: ident,
|
|
||||||
$columns_generic: ident,
|
|
||||||
$columns_generic_with_step: ident,
|
|
||||||
$slice: ident,
|
|
||||||
$slice_with_steps: ident,
|
|
||||||
$fixed_slice: ident,
|
|
||||||
$fixed_slice_with_steps: ident,
|
|
||||||
$generic_slice: ident,
|
|
||||||
$generic_slice_with_steps: ident,
|
|
||||||
$rows_range_pair: ident,
|
|
||||||
$columns_range_pair: ident) => {
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Row slicing.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/// Returns a slice containing the i-th row of this matrix.
|
|
||||||
#[inline]
|
|
||||||
pub fn $row($me: $Me, i: usize) -> $MatrixSlice<'_, T, U1, C, S::RStride, S::CStride> {
|
|
||||||
$me.$fixed_rows::<1>(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a slice containing the `n` first elements of the i-th row of this matrix.
|
|
||||||
#[inline]
|
|
||||||
pub fn $row_part($me: $Me, i: usize, n: usize) -> $MatrixSlice<'_, T, U1, Dynamic, S::RStride, S::CStride> {
|
|
||||||
$me.$generic_slice((i, 0), (Const::<1>, Dynamic::new(n)))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix a set of consecutive rows.
|
|
||||||
#[inline]
|
|
||||||
pub fn $rows($me: $Me, first_row: usize, nrows: usize)
|
|
||||||
-> $MatrixSlice<'_, T, Dynamic, C, S::RStride, S::CStride> {
|
|
||||||
|
|
||||||
$me.$rows_generic(first_row, Dynamic::new(nrows))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix a set of consecutive rows regularly skipping `step` rows.
|
|
||||||
#[inline]
|
|
||||||
pub fn $rows_with_step($me: $Me, first_row: usize, nrows: usize, step: usize)
|
|
||||||
-> $MatrixSlice<'_, T, Dynamic, C, Dynamic, S::CStride> {
|
|
||||||
|
|
||||||
$me.$rows_generic_with_step(first_row, Dynamic::new(nrows), step)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts a compile-time number of consecutive rows from this matrix.
|
|
||||||
#[inline]
|
|
||||||
pub fn $fixed_rows<const RSLICE: usize>($me: $Me, first_row: usize)
|
|
||||||
-> $MatrixSlice<'_, T, Const<RSLICE>, C, S::RStride, S::CStride> {
|
|
||||||
|
|
||||||
$me.$rows_generic(first_row, Const::<RSLICE>)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix a compile-time number of rows regularly skipping `step`
|
|
||||||
/// rows.
|
|
||||||
#[inline]
|
|
||||||
pub fn $fixed_rows_with_step<const RSLICE: usize>($me: $Me, first_row: usize, step: usize)
|
|
||||||
-> $MatrixSlice<'_, T, Const<RSLICE>, C, Dynamic, S::CStride> {
|
|
||||||
|
|
||||||
$me.$rows_generic_with_step(first_row, Const::<RSLICE>, step)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix `nrows` rows regularly skipping `step` rows. Both
|
|
||||||
/// argument may or may not be values known at compile-time.
|
|
||||||
#[inline]
|
|
||||||
pub fn $rows_generic<RSlice: Dim>($me: $Me, row_start: usize, nrows: RSlice)
|
|
||||||
-> $MatrixSlice<'_, T, RSlice, C, S::RStride, S::CStride> {
|
|
||||||
|
|
||||||
let my_shape = $me.shape_generic();
|
|
||||||
$me.assert_slice_index((row_start, 0), (nrows.value(), my_shape.1.value()), (0, 0));
|
|
||||||
|
|
||||||
let shape = (nrows, my_shape.1);
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let data = $SliceStorage::new_unchecked($data, (row_start, 0), shape);
|
|
||||||
Matrix::from_data_statically_unchecked(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix `nrows` rows regularly skipping `step` rows. Both
|
|
||||||
/// argument may or may not be values known at compile-time.
|
|
||||||
#[inline]
|
|
||||||
pub fn $rows_generic_with_step<RSlice>($me: $Me, row_start: usize, nrows: RSlice, step: usize)
|
|
||||||
-> $MatrixSlice<'_, T, RSlice, C, Dynamic, S::CStride>
|
|
||||||
where RSlice: Dim {
|
|
||||||
|
|
||||||
let my_shape = $me.shape_generic();
|
|
||||||
let my_strides = $me.data.strides();
|
|
||||||
$me.assert_slice_index((row_start, 0), (nrows.value(), my_shape.1.value()), (step, 0));
|
|
||||||
|
|
||||||
let strides = (Dynamic::new((step + 1) * my_strides.0.value()), my_strides.1);
|
|
||||||
let shape = (nrows, my_shape.1);
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let data = $SliceStorage::new_with_strides_unchecked($data, (row_start, 0), shape, strides);
|
|
||||||
Matrix::from_data_statically_unchecked(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Column slicing.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/// Returns a slice containing the i-th column of this matrix.
|
|
||||||
#[inline]
|
|
||||||
pub fn $column($me: $Me, i: usize) -> $MatrixSlice<'_, T, R, U1, S::RStride, S::CStride> {
|
|
||||||
$me.$fixed_columns::<1>(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns a slice containing the `n` first elements of the i-th column of this matrix.
|
|
||||||
#[inline]
|
|
||||||
pub fn $column_part($me: $Me, i: usize, n: usize) -> $MatrixSlice<'_, T, Dynamic, U1, S::RStride, S::CStride> {
|
|
||||||
$me.$generic_slice((0, i), (Dynamic::new(n), Const::<1>))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix a set of consecutive columns.
|
|
||||||
#[inline]
|
|
||||||
pub fn $columns($me: $Me, first_col: usize, ncols: usize)
|
|
||||||
-> $MatrixSlice<'_, T, R, Dynamic, S::RStride, S::CStride> {
|
|
||||||
|
|
||||||
$me.$columns_generic(first_col, Dynamic::new(ncols))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix a set of consecutive columns regularly skipping `step`
|
|
||||||
/// columns.
|
|
||||||
#[inline]
|
|
||||||
pub fn $columns_with_step($me: $Me, first_col: usize, ncols: usize, step: usize)
|
|
||||||
-> $MatrixSlice<'_, T, R, Dynamic, S::RStride, Dynamic> {
|
|
||||||
|
|
||||||
$me.$columns_generic_with_step(first_col, Dynamic::new(ncols), step)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts a compile-time number of consecutive columns from this matrix.
|
|
||||||
#[inline]
|
|
||||||
pub fn $fixed_columns<const CSLICE: usize>($me: $Me, first_col: usize)
|
|
||||||
-> $MatrixSlice<'_, T, R, Const<CSLICE>, S::RStride, S::CStride> {
|
|
||||||
|
|
||||||
$me.$columns_generic(first_col, Const::<CSLICE>)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix a compile-time number of columns regularly skipping
|
|
||||||
/// `step` columns.
|
|
||||||
#[inline]
|
|
||||||
pub fn $fixed_columns_with_step<const CSLICE: usize>($me: $Me, first_col: usize, step: usize)
|
|
||||||
-> $MatrixSlice<'_, T, R, Const<CSLICE>, S::RStride, Dynamic> {
|
|
||||||
|
|
||||||
$me.$columns_generic_with_step(first_col, Const::<CSLICE>, step)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extracts from this matrix `ncols` columns. The number of columns may or may not be
|
|
||||||
/// known at compile-time.
|
|
||||||
#[inline]
|
|
||||||
pub fn $columns_generic<CSlice: Dim>($me: $Me, first_col: usize, ncols: CSlice)
|
|
||||||
-> $MatrixSlice<'_, T, R, CSlice, S::RStride, S::CStride> {
|
|
||||||
|
|
||||||
let my_shape = $me.shape_generic();
|
|
||||||
$me.assert_slice_index((0, first_col), (my_shape.0.value(), ncols.value()), (0, 0));
|
|
||||||
let shape = (my_shape.0, ncols);
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let data = $SliceStorage::new_unchecked($data, (0, first_col), shape);
|
|
||||||
Matrix::from_data_statically_unchecked(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Extracts from this matrix `ncols` columns skipping `step` columns. Both argument may
|
|
||||||
/// or may not be values known at compile-time.
|
|
||||||
#[inline]
|
|
||||||
pub fn $columns_generic_with_step<CSlice: Dim>($me: $Me, first_col: usize, ncols: CSlice, step: usize)
|
|
||||||
-> $MatrixSlice<'_, T, R, CSlice, S::RStride, Dynamic> {
|
|
||||||
|
|
||||||
let my_shape = $me.shape_generic();
|
|
||||||
let my_strides = $me.data.strides();
|
|
||||||
|
|
||||||
$me.assert_slice_index((0, first_col), (my_shape.0.value(), ncols.value()), (0, step));
|
|
||||||
|
|
||||||
let strides = (my_strides.0, Dynamic::new((step + 1) * my_strides.1.value()));
|
|
||||||
let shape = (my_shape.0, ncols);
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let data = $SliceStorage::new_with_strides_unchecked($data, (0, first_col), shape, strides);
|
|
||||||
Matrix::from_data_statically_unchecked(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* General slicing.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/// Slices this matrix starting at its component `(irow, icol)` and with `(nrows, ncols)`
|
|
||||||
/// consecutive elements.
|
|
||||||
#[inline]
|
|
||||||
pub fn $slice($me: $Me, start: (usize, usize), shape: (usize, usize))
|
|
||||||
-> $MatrixSlice<'_, T, Dynamic, Dynamic, S::RStride, S::CStride> {
|
|
||||||
|
|
||||||
$me.assert_slice_index(start, shape, (0, 0));
|
|
||||||
let shape = (Dynamic::new(shape.0), Dynamic::new(shape.1));
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let data = $SliceStorage::new_unchecked($data, start, shape);
|
|
||||||
Matrix::from_data_statically_unchecked(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// Slices this matrix starting at its component `(start.0, start.1)` and with
|
|
||||||
/// `(shape.0, shape.1)` components. Each row (resp. column) of the sliced matrix is
|
|
||||||
/// separated by `steps.0` (resp. `steps.1`) ignored rows (resp. columns) of the
|
|
||||||
/// original matrix.
|
|
||||||
#[inline]
|
|
||||||
pub fn $slice_with_steps($me: $Me, start: (usize, usize), shape: (usize, usize), steps: (usize, usize))
|
|
||||||
-> $MatrixSlice<'_, T, Dynamic, Dynamic, Dynamic, Dynamic> {
|
|
||||||
let shape = (Dynamic::new(shape.0), Dynamic::new(shape.1));
|
|
||||||
|
|
||||||
$me.$generic_slice_with_steps(start, shape, steps)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Slices this matrix starting at its component `(irow, icol)` and with `(R::dim(),
|
|
||||||
/// CSlice::dim())` consecutive components.
|
|
||||||
#[inline]
|
|
||||||
pub fn $fixed_slice<const RSLICE: usize, const CSLICE: usize>($me: $Me, irow: usize, icol: usize)
|
|
||||||
-> $MatrixSlice<'_, T, Const<RSLICE>, Const<CSLICE>, S::RStride, S::CStride> {
|
|
||||||
|
|
||||||
$me.assert_slice_index((irow, icol), (RSLICE, CSLICE), (0, 0));
|
|
||||||
let shape = (Const::<RSLICE>, Const::<CSLICE>);
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let data = $SliceStorage::new_unchecked($data, (irow, icol), shape);
|
|
||||||
Matrix::from_data_statically_unchecked(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Slices this matrix starting at its component `(start.0, start.1)` and with
|
|
||||||
/// `(RSLICE, CSLICE)` components. Each row (resp. column) of the sliced
|
|
||||||
/// matrix is separated by `steps.0` (resp. `steps.1`) ignored rows (resp. columns) of
|
|
||||||
/// the original matrix.
|
|
||||||
#[inline]
|
|
||||||
pub fn $fixed_slice_with_steps<const RSLICE: usize, const CSLICE: usize>($me: $Me, start: (usize, usize), steps: (usize, usize))
|
|
||||||
-> $MatrixSlice<'_, T, Const<RSLICE>, Const<CSLICE>, Dynamic, Dynamic> {
|
|
||||||
let shape = (Const::<RSLICE>, Const::<CSLICE>);
|
|
||||||
$me.$generic_slice_with_steps(start, shape, steps)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a slice that may or may not have a fixed size and stride.
|
|
||||||
#[inline]
|
|
||||||
pub fn $generic_slice<RSlice, CSlice>($me: $Me, start: (usize, usize), shape: (RSlice, CSlice))
|
|
||||||
-> $MatrixSlice<'_, T, RSlice, CSlice, S::RStride, S::CStride>
|
|
||||||
where RSlice: Dim,
|
|
||||||
CSlice: Dim {
|
|
||||||
|
|
||||||
$me.assert_slice_index(start, (shape.0.value(), shape.1.value()), (0, 0));
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let data = $SliceStorage::new_unchecked($data, start, shape);
|
|
||||||
Matrix::from_data_statically_unchecked(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a slice that may or may not have a fixed size and stride.
|
|
||||||
#[inline]
|
|
||||||
pub fn $generic_slice_with_steps<RSlice, CSlice>($me: $Me,
|
|
||||||
start: (usize, usize),
|
|
||||||
shape: (RSlice, CSlice),
|
|
||||||
steps: (usize, usize))
|
|
||||||
-> $MatrixSlice<'_, T, RSlice, CSlice, Dynamic, Dynamic>
|
|
||||||
where RSlice: Dim,
|
|
||||||
CSlice: Dim {
|
|
||||||
|
|
||||||
$me.assert_slice_index(start, (shape.0.value(), shape.1.value()), steps);
|
|
||||||
|
|
||||||
let my_strides = $me.data.strides();
|
|
||||||
let strides = (Dynamic::new((steps.0 + 1) * my_strides.0.value()),
|
|
||||||
Dynamic::new((steps.1 + 1) * my_strides.1.value()));
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let data = $SliceStorage::new_with_strides_unchecked($data, start, shape, strides);
|
|
||||||
Matrix::from_data_statically_unchecked(data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Splitting.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/// Splits this `NxM` matrix into two parts delimited by two ranges.
|
|
||||||
///
|
|
||||||
/// Panics if the ranges overlap or if the first range is empty.
|
|
||||||
#[inline]
|
|
||||||
pub fn $rows_range_pair<Range1: SliceRange<R>, Range2: SliceRange<R>>($me: $Me, r1: Range1, r2: Range2)
|
|
||||||
-> ($MatrixSlice<'_, T, Range1::Size, C, S::RStride, S::CStride>,
|
|
||||||
$MatrixSlice<'_, T, Range2::Size, C, S::RStride, S::CStride>) {
|
|
||||||
|
|
||||||
let (nrows, ncols) = $me.shape_generic();
|
|
||||||
let strides = $me.data.strides();
|
|
||||||
|
|
||||||
let start1 = r1.begin(nrows);
|
|
||||||
let start2 = r2.begin(nrows);
|
|
||||||
|
|
||||||
let end1 = r1.end(nrows);
|
|
||||||
let end2 = r2.end(nrows);
|
|
||||||
|
|
||||||
let nrows1 = r1.size(nrows);
|
|
||||||
let nrows2 = r2.size(nrows);
|
|
||||||
|
|
||||||
assert!(start2 >= end1 || start1 >= end2, "Rows range pair: the slice ranges must not overlap.");
|
|
||||||
assert!(end2 <= nrows.value(), "Rows range pair: index out of range.");
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let ptr1 = $data.$get_addr(start1, 0);
|
|
||||||
let ptr2 = $data.$get_addr(start2, 0);
|
|
||||||
|
|
||||||
let data1 = $SliceStorage::from_raw_parts(ptr1, (nrows1, ncols), strides);
|
|
||||||
let data2 = $SliceStorage::from_raw_parts(ptr2, (nrows2, ncols), strides);
|
|
||||||
let slice1 = Matrix::from_data_statically_unchecked(data1);
|
|
||||||
let slice2 = Matrix::from_data_statically_unchecked(data2);
|
|
||||||
|
|
||||||
(slice1, slice2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Splits this `NxM` matrix into two parts delimited by two ranges.
|
|
||||||
///
|
|
||||||
/// Panics if the ranges overlap or if the first range is empty.
|
|
||||||
#[inline]
|
|
||||||
pub fn $columns_range_pair<Range1: SliceRange<C>, Range2: SliceRange<C>>($me: $Me, r1: Range1, r2: Range2)
|
|
||||||
-> ($MatrixSlice<'_, T, R, Range1::Size, S::RStride, S::CStride>,
|
|
||||||
$MatrixSlice<'_, T, R, Range2::Size, S::RStride, S::CStride>) {
|
|
||||||
|
|
||||||
let (nrows, ncols) = $me.shape_generic();
|
|
||||||
let strides = $me.data.strides();
|
|
||||||
|
|
||||||
let start1 = r1.begin(ncols);
|
|
||||||
let start2 = r2.begin(ncols);
|
|
||||||
|
|
||||||
let end1 = r1.end(ncols);
|
|
||||||
let end2 = r2.end(ncols);
|
|
||||||
|
|
||||||
let ncols1 = r1.size(ncols);
|
|
||||||
let ncols2 = r2.size(ncols);
|
|
||||||
|
|
||||||
assert!(start2 >= end1 || start1 >= end2, "Columns range pair: the slice ranges must not overlap.");
|
|
||||||
assert!(end2 <= ncols.value(), "Columns range pair: index out of range.");
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let ptr1 = $data.$get_addr(0, start1);
|
|
||||||
let ptr2 = $data.$get_addr(0, start2);
|
|
||||||
|
|
||||||
let data1 = $SliceStorage::from_raw_parts(ptr1, (nrows, ncols1), strides);
|
|
||||||
let data2 = $SliceStorage::from_raw_parts(ptr2, (nrows, ncols2), strides);
|
|
||||||
let slice1 = Matrix::from_data_statically_unchecked(data1);
|
|
||||||
let slice2 = Matrix::from_data_statically_unchecked(data2);
|
|
||||||
|
|
||||||
(slice1, slice2)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
/// A matrix slice.
|
|
||||||
pub type MatrixSlice<'a, T, R, C, RStride = U1, CStride = R> =
|
|
||||||
Matrix<T, R, C, SliceStorage<'a, T, R, C, RStride, CStride>>;
|
|
||||||
/// A mutable matrix slice.
|
|
||||||
pub type MatrixSliceMut<'a, T, R, C, RStride = U1, CStride = R> =
|
|
||||||
Matrix<T, R, C, SliceStorageMut<'a, T, R, C, RStride, CStride>>;
|
|
||||||
|
|
||||||
/// # Slicing based on index and length
|
|
||||||
impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
|
||||||
matrix_slice_impl!(
|
|
||||||
self: &Self, MatrixSlice, SliceStorage, RawStorage.get_address_unchecked(), &self.data;
|
|
||||||
row,
|
|
||||||
row_part,
|
|
||||||
rows,
|
|
||||||
rows_with_step,
|
|
||||||
fixed_rows,
|
|
||||||
fixed_rows_with_step,
|
|
||||||
rows_generic,
|
|
||||||
rows_generic_with_step,
|
|
||||||
column,
|
|
||||||
column_part,
|
|
||||||
columns,
|
|
||||||
columns_with_step,
|
|
||||||
fixed_columns,
|
|
||||||
fixed_columns_with_step,
|
|
||||||
columns_generic,
|
|
||||||
columns_generic_with_step,
|
|
||||||
slice,
|
|
||||||
slice_with_steps,
|
|
||||||
fixed_slice,
|
|
||||||
fixed_slice_with_steps,
|
|
||||||
generic_slice,
|
|
||||||
generic_slice_with_steps,
|
|
||||||
rows_range_pair,
|
|
||||||
columns_range_pair);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// # Mutable slicing based on index and length
|
|
||||||
impl<T, R: Dim, C: Dim, S: RawStorageMut<T, R, C>> Matrix<T, R, C, S> {
|
|
||||||
matrix_slice_impl!(
|
|
||||||
self: &mut Self, MatrixSliceMut, SliceStorageMut, RawStorageMut.get_address_unchecked_mut(), &mut self.data;
|
|
||||||
row_mut,
|
|
||||||
row_part_mut,
|
|
||||||
rows_mut,
|
|
||||||
rows_with_step_mut,
|
|
||||||
fixed_rows_mut,
|
|
||||||
fixed_rows_with_step_mut,
|
|
||||||
rows_generic_mut,
|
|
||||||
rows_generic_with_step_mut,
|
|
||||||
column_mut,
|
|
||||||
column_part_mut,
|
|
||||||
columns_mut,
|
|
||||||
columns_with_step_mut,
|
|
||||||
fixed_columns_mut,
|
|
||||||
fixed_columns_with_step_mut,
|
|
||||||
columns_generic_mut,
|
|
||||||
columns_generic_with_step_mut,
|
|
||||||
slice_mut,
|
|
||||||
slice_with_steps_mut,
|
|
||||||
fixed_slice_mut,
|
|
||||||
fixed_slice_with_steps_mut,
|
|
||||||
generic_slice_mut,
|
|
||||||
generic_slice_with_steps_mut,
|
|
||||||
rows_range_pair_mut,
|
|
||||||
columns_range_pair_mut);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A range with a size that may be known at compile-time.
|
|
||||||
///
|
|
||||||
/// This may be:
|
|
||||||
/// * A single `usize` index, e.g., `4`
|
|
||||||
/// * A left-open range `std::ops::RangeTo`, e.g., `.. 4`
|
|
||||||
/// * A right-open range `std::ops::RangeFrom`, e.g., `4 ..`
|
|
||||||
/// * A full range `std::ops::RangeFull`, e.g., `..`
|
|
||||||
pub trait SliceRange<D: Dim> {
|
|
||||||
/// Type of the range size. May be a type-level integer.
|
|
||||||
type Size: Dim;
|
|
||||||
|
|
||||||
/// The start index of the range.
|
|
||||||
fn begin(&self, shape: D) -> usize;
|
|
||||||
// NOTE: this is the index immediately after the last index.
|
|
||||||
/// The index immediately after the last index inside of the range.
|
|
||||||
fn end(&self, shape: D) -> usize;
|
|
||||||
/// The number of elements of the range, i.e., `self.end - self.begin`.
|
|
||||||
fn size(&self, shape: D) -> Self::Size;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D: Dim> SliceRange<D> for usize {
|
|
||||||
type Size = U1;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn begin(&self, _: D) -> usize {
|
|
||||||
*self
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn end(&self, _: D) -> usize {
|
|
||||||
*self + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn size(&self, _: D) -> Self::Size {
|
|
||||||
Const::<1>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D: Dim> SliceRange<D> for Range<usize> {
|
|
||||||
type Size = Dynamic;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn begin(&self, _: D) -> usize {
|
|
||||||
self.start
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn end(&self, _: D) -> usize {
|
|
||||||
self.end
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn size(&self, _: D) -> Self::Size {
|
|
||||||
Dynamic::new(self.end - self.start)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D: Dim> SliceRange<D> for RangeFrom<usize> {
|
|
||||||
type Size = Dynamic;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn begin(&self, _: D) -> usize {
|
|
||||||
self.start
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn end(&self, dim: D) -> usize {
|
|
||||||
dim.value()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn size(&self, dim: D) -> Self::Size {
|
|
||||||
Dynamic::new(dim.value() - self.start)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D: Dim> SliceRange<D> for RangeTo<usize> {
|
|
||||||
type Size = Dynamic;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn begin(&self, _: D) -> usize {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn end(&self, _: D) -> usize {
|
|
||||||
self.end
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn size(&self, _: D) -> Self::Size {
|
|
||||||
Dynamic::new(self.end)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D: Dim> SliceRange<D> for RangeFull {
|
|
||||||
type Size = D;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn begin(&self, _: D) -> usize {
|
|
||||||
0
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn end(&self, dim: D) -> usize {
|
|
||||||
dim.value()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn size(&self, dim: D) -> Self::Size {
|
|
||||||
dim
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D: Dim> SliceRange<D> for RangeInclusive<usize> {
|
|
||||||
type Size = Dynamic;
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn begin(&self, _: D) -> usize {
|
|
||||||
*self.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn end(&self, _: D) -> usize {
|
|
||||||
*self.end() + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
fn size(&self, _: D) -> Self::Size {
|
|
||||||
Dynamic::new(*self.end() + 1 - *self.start())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: see how much of this overlaps with the general indexing
|
|
||||||
// methods from indexing.rs.
|
|
||||||
impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
|
||||||
/// Slices a sub-matrix containing the rows indexed by the range `rows` and the columns indexed
|
|
||||||
/// by the range `cols`.
|
|
||||||
#[inline]
|
|
||||||
#[must_use]
|
|
||||||
pub fn slice_range<RowRange, ColRange>(
|
|
||||||
&self,
|
|
||||||
rows: RowRange,
|
|
||||||
cols: ColRange,
|
|
||||||
) -> MatrixSlice<'_, T, RowRange::Size, ColRange::Size, S::RStride, S::CStride>
|
|
||||||
where
|
|
||||||
RowRange: SliceRange<R>,
|
|
||||||
ColRange: SliceRange<C>,
|
|
||||||
{
|
|
||||||
let (nrows, ncols) = self.shape_generic();
|
|
||||||
self.generic_slice(
|
|
||||||
(rows.begin(nrows), cols.begin(ncols)),
|
|
||||||
(rows.size(nrows), cols.size(ncols)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Slice containing all the rows indexed by the range `rows`.
|
|
||||||
#[inline]
|
|
||||||
#[must_use]
|
|
||||||
pub fn rows_range<RowRange: SliceRange<R>>(
|
|
||||||
&self,
|
|
||||||
rows: RowRange,
|
|
||||||
) -> MatrixSlice<'_, T, RowRange::Size, C, S::RStride, S::CStride> {
|
|
||||||
self.slice_range(rows, ..)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Slice containing all the columns indexed by the range `rows`.
|
|
||||||
#[inline]
|
|
||||||
#[must_use]
|
|
||||||
pub fn columns_range<ColRange: SliceRange<C>>(
|
|
||||||
&self,
|
|
||||||
cols: ColRange,
|
|
||||||
) -> MatrixSlice<'_, T, R, ColRange::Size, S::RStride, S::CStride> {
|
|
||||||
self.slice_range(.., cols)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: see how much of this overlaps with the general indexing
|
|
||||||
// methods from indexing.rs.
|
|
||||||
impl<T, R: Dim, C: Dim, S: RawStorageMut<T, R, C>> Matrix<T, R, C, S> {
|
|
||||||
/// Slices a mutable sub-matrix containing the rows indexed by the range `rows` and the columns
|
|
||||||
/// indexed by the range `cols`.
|
|
||||||
pub fn slice_range_mut<RowRange, ColRange>(
|
|
||||||
&mut self,
|
|
||||||
rows: RowRange,
|
|
||||||
cols: ColRange,
|
|
||||||
) -> MatrixSliceMut<'_, T, RowRange::Size, ColRange::Size, S::RStride, S::CStride>
|
|
||||||
where
|
|
||||||
RowRange: SliceRange<R>,
|
|
||||||
ColRange: SliceRange<C>,
|
|
||||||
{
|
|
||||||
let (nrows, ncols) = self.shape_generic();
|
|
||||||
self.generic_slice_mut(
|
|
||||||
(rows.begin(nrows), cols.begin(ncols)),
|
|
||||||
(rows.size(nrows), cols.size(ncols)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Slice containing all the rows indexed by the range `rows`.
|
|
||||||
#[inline]
|
|
||||||
pub fn rows_range_mut<RowRange: SliceRange<R>>(
|
|
||||||
&mut self,
|
|
||||||
rows: RowRange,
|
|
||||||
) -> MatrixSliceMut<'_, T, RowRange::Size, C, S::RStride, S::CStride> {
|
|
||||||
self.slice_range_mut(rows, ..)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Slice containing all the columns indexed by the range `cols`.
|
|
||||||
#[inline]
|
|
||||||
pub fn columns_range_mut<ColRange: SliceRange<C>>(
|
|
||||||
&mut self,
|
|
||||||
cols: ColRange,
|
|
||||||
) -> MatrixSliceMut<'_, T, R, ColRange::Size, S::RStride, S::CStride> {
|
|
||||||
self.slice_range_mut(.., cols)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, T, R, C, RStride, CStride> From<MatrixSliceMut<'a, T, R, C, RStride, CStride>>
|
|
||||||
for MatrixSlice<'a, T, R, C, RStride, CStride>
|
|
||||||
where
|
|
||||||
R: Dim,
|
|
||||||
C: Dim,
|
|
||||||
RStride: Dim,
|
|
||||||
CStride: Dim,
|
|
||||||
{
|
|
||||||
fn from(slice_mut: MatrixSliceMut<'a, T, R, C, RStride, CStride>) -> Self {
|
|
||||||
let data = SliceStorage {
|
|
||||||
ptr: slice_mut.data.ptr,
|
|
||||||
shape: slice_mut.data.shape,
|
|
||||||
strides: slice_mut.data.strides,
|
|
||||||
_phantoms: PhantomData,
|
|
||||||
};
|
|
||||||
|
|
||||||
unsafe { Matrix::from_data_statically_unchecked(data) }
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
|
@ -12,18 +12,19 @@ pub mod storage;
|
||||||
|
|
||||||
mod alias;
|
mod alias;
|
||||||
mod alias_slice;
|
mod alias_slice;
|
||||||
|
mod alias_view;
|
||||||
mod array_storage;
|
mod array_storage;
|
||||||
mod cg;
|
mod cg;
|
||||||
mod componentwise;
|
mod componentwise;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod construction;
|
mod construction;
|
||||||
mod construction_slice;
|
mod construction_view;
|
||||||
mod conversion;
|
mod conversion;
|
||||||
mod edition;
|
mod edition;
|
||||||
pub mod indexing;
|
pub mod indexing;
|
||||||
mod matrix;
|
mod matrix;
|
||||||
mod matrix_simba;
|
mod matrix_simba;
|
||||||
mod matrix_slice;
|
mod matrix_view;
|
||||||
mod norm;
|
mod norm;
|
||||||
mod properties;
|
mod properties;
|
||||||
mod scalar;
|
mod scalar;
|
||||||
|
@ -41,6 +42,12 @@ mod min_max;
|
||||||
/// Mechanisms for working with values that may not be initialized.
|
/// Mechanisms for working with values that may not be initialized.
|
||||||
pub mod uninit;
|
pub mod uninit;
|
||||||
|
|
||||||
|
#[cfg(feature = "rayon")]
|
||||||
|
pub mod par_iter;
|
||||||
|
|
||||||
|
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||||
|
mod rkyv_wrappers;
|
||||||
|
|
||||||
pub use self::matrix::*;
|
pub use self::matrix::*;
|
||||||
pub use self::norm::*;
|
pub use self::norm::*;
|
||||||
pub use self::scalar::*;
|
pub use self::scalar::*;
|
||||||
|
@ -51,8 +58,9 @@ pub use self::dimension::*;
|
||||||
|
|
||||||
pub use self::alias::*;
|
pub use self::alias::*;
|
||||||
pub use self::alias_slice::*;
|
pub use self::alias_slice::*;
|
||||||
|
pub use self::alias_view::*;
|
||||||
pub use self::array_storage::*;
|
pub use self::array_storage::*;
|
||||||
pub use self::matrix_slice::*;
|
pub use self::matrix_view::*;
|
||||||
pub use self::storage::*;
|
pub use self::storage::*;
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
pub use self::vec_storage::*;
|
pub use self::vec_storage::*;
|
||||||
|
|
|
@ -11,10 +11,10 @@ use crate::base::blas_uninit::gemm_uninit;
|
||||||
use crate::base::constraint::{
|
use crate::base::constraint::{
|
||||||
AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint,
|
AreMultipliable, DimEq, SameNumberOfColumns, SameNumberOfRows, ShapeConstraint,
|
||||||
};
|
};
|
||||||
use crate::base::dimension::{Dim, DimMul, DimName, DimProd, Dynamic};
|
use crate::base::dimension::{Dim, DimMul, DimName, DimProd, Dyn};
|
||||||
use crate::base::storage::{Storage, StorageMut};
|
use crate::base::storage::{Storage, StorageMut};
|
||||||
use crate::base::uninit::Uninit;
|
use crate::base::uninit::Uninit;
|
||||||
use crate::base::{DefaultAllocator, Matrix, MatrixSum, OMatrix, Scalar, VectorSlice};
|
use crate::base::{DefaultAllocator, Matrix, MatrixSum, OMatrix, Scalar, VectorView};
|
||||||
use crate::storage::IsContiguous;
|
use crate::storage::IsContiguous;
|
||||||
use crate::uninit::{Init, InitStatus};
|
use crate::uninit::{Init, InitStatus};
|
||||||
use crate::{RawStorage, RawStorageMut, SimdComplexField};
|
use crate::{RawStorage, RawStorageMut, SimdComplexField};
|
||||||
|
@ -374,10 +374,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, C: Dim> iter::Sum for OMatrix<T, Dynamic, C>
|
impl<T, C: Dim> iter::Sum for OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
T: Scalar + ClosedAdd + Zero,
|
T: Scalar + ClosedAdd + Zero,
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C>,
|
DefaultAllocator: Allocator<T, Dyn, C>,
|
||||||
{
|
{
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -395,7 +395,7 @@ where
|
||||||
/// # use nalgebra::DMatrix;
|
/// # use nalgebra::DMatrix;
|
||||||
/// iter::empty::<DMatrix<f64>>().sum::<DMatrix<f64>>(); // panics!
|
/// iter::empty::<DMatrix<f64>>().sum::<DMatrix<f64>>(); // panics!
|
||||||
/// ```
|
/// ```
|
||||||
fn sum<I: Iterator<Item = OMatrix<T, Dynamic, C>>>(mut iter: I) -> OMatrix<T, Dynamic, C> {
|
fn sum<I: Iterator<Item = OMatrix<T, Dyn, C>>>(mut iter: I) -> OMatrix<T, Dyn, C> {
|
||||||
if let Some(first) = iter.next() {
|
if let Some(first) = iter.next() {
|
||||||
iter.fold(first, |acc, x| acc + x)
|
iter.fold(first, |acc, x| acc + x)
|
||||||
} else {
|
} else {
|
||||||
|
@ -414,10 +414,10 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T, C: Dim> iter::Sum<&'a OMatrix<T, Dynamic, C>> for OMatrix<T, Dynamic, C>
|
impl<'a, T, C: Dim> iter::Sum<&'a OMatrix<T, Dyn, C>> for OMatrix<T, Dyn, C>
|
||||||
where
|
where
|
||||||
T: Scalar + ClosedAdd + Zero,
|
T: Scalar + ClosedAdd + Zero,
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C>,
|
DefaultAllocator: Allocator<T, Dyn, C>,
|
||||||
{
|
{
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
|
@ -435,7 +435,7 @@ where
|
||||||
/// # use nalgebra::DMatrix;
|
/// # use nalgebra::DMatrix;
|
||||||
/// iter::empty::<&DMatrix<f64>>().sum::<DMatrix<f64>>(); // panics!
|
/// iter::empty::<&DMatrix<f64>>().sum::<DMatrix<f64>>(); // panics!
|
||||||
/// ```
|
/// ```
|
||||||
fn sum<I: Iterator<Item = &'a OMatrix<T, Dynamic, C>>>(mut iter: I) -> OMatrix<T, Dynamic, C> {
|
fn sum<I: Iterator<Item = &'a OMatrix<T, Dyn, C>>>(mut iter: I) -> OMatrix<T, Dyn, C> {
|
||||||
if let Some(first) = iter.next() {
|
if let Some(first) = iter.next() {
|
||||||
iter.fold(first.clone(), |acc, x| acc + x)
|
iter.fold(first.clone(), |acc, x| acc + x)
|
||||||
} else {
|
} else {
|
||||||
|
@ -703,8 +703,8 @@ where
|
||||||
rhs: &Matrix<T, R2, C2, SB>,
|
rhs: &Matrix<T, R2, C2, SB>,
|
||||||
out: &mut Matrix<Status::Value, R3, C3, SC>,
|
out: &mut Matrix<Status::Value, R3, C3, SC>,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&VectorSlice<'_, T, R1, SA::RStride, SA::CStride>,
|
&VectorView<'_, T, R1, SA::RStride, SA::CStride>,
|
||||||
&VectorSlice<'_, T, R2, SB::RStride, SB::CStride>,
|
&VectorView<'_, T, R2, SB::RStride, SB::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) where
|
) where
|
||||||
Status: InitStatus<T>,
|
Status: InitStatus<T>,
|
||||||
|
|
|
@ -0,0 +1,285 @@
|
||||||
|
//! Parallel iterators for matrices compatible with rayon.
|
||||||
|
|
||||||
|
// only enables the `doc_cfg` feature when
|
||||||
|
// the `docsrs` configuration attribute is defined
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
iter::{ColumnIter, ColumnIterMut},
|
||||||
|
Dim, Matrix, MatrixView, MatrixViewMut, RawStorage, RawStorageMut, Scalar, U1,
|
||||||
|
};
|
||||||
|
use rayon::iter::plumbing::Producer;
|
||||||
|
use rayon::{iter::plumbing::bridge, prelude::*};
|
||||||
|
|
||||||
|
/// A rayon parallel iterator over the colums of a matrix. It is created
|
||||||
|
/// using the [`par_column_iter`] method of [`Matrix`].
|
||||||
|
///
|
||||||
|
/// *Only available if compiled with the feature `rayon`.*
|
||||||
|
/// [`par_column_iter`]: crate::Matrix::par_column_iter
|
||||||
|
/// [`Matrix`]: crate::Matrix
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
pub struct ParColumnIter<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> {
|
||||||
|
mat: &'a Matrix<T, R, Cols, S>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> ParColumnIter<'a, T, R, Cols, S> {
|
||||||
|
/// Create a new parallel iterator for the given matrix.
|
||||||
|
fn new(matrix: &'a Matrix<T, R, Cols, S>) -> Self {
|
||||||
|
Self { mat: matrix }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> ParallelIterator
|
||||||
|
for ParColumnIter<'a, T, R, Cols, S>
|
||||||
|
where
|
||||||
|
T: Sync + Send + Scalar,
|
||||||
|
S: Sync,
|
||||||
|
{
|
||||||
|
type Item = MatrixView<'a, T, R, U1, S::RStride, S::CStride>;
|
||||||
|
|
||||||
|
fn drive_unindexed<Consumer>(self, consumer: Consumer) -> Consumer::Result
|
||||||
|
where
|
||||||
|
Consumer: rayon::iter::plumbing::UnindexedConsumer<Self::Item>,
|
||||||
|
{
|
||||||
|
bridge(self, consumer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn opt_len(&self) -> Option<usize> {
|
||||||
|
Some(self.mat.ncols())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
/// *Only available if compiled with the feature `rayon`.*
|
||||||
|
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> IndexedParallelIterator
|
||||||
|
for ParColumnIter<'a, T, R, Cols, S>
|
||||||
|
where
|
||||||
|
T: Send + Sync + Scalar,
|
||||||
|
S: Sync,
|
||||||
|
{
|
||||||
|
fn len(&self) -> usize {
|
||||||
|
self.mat.ncols()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn drive<C: rayon::iter::plumbing::Consumer<Self::Item>>(self, consumer: C) -> C::Result {
|
||||||
|
bridge(self, consumer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_producer<CB: rayon::iter::plumbing::ProducerCallback<Self::Item>>(
|
||||||
|
self,
|
||||||
|
callback: CB,
|
||||||
|
) -> CB::Output {
|
||||||
|
let producer = ColumnProducer(ColumnIter::new(self.mat));
|
||||||
|
callback.callback(producer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
/// A rayon parallel iterator through the mutable columns of a matrix.
|
||||||
|
/// *Only available if compiled with the feature `rayon`.*
|
||||||
|
pub struct ParColumnIterMut<
|
||||||
|
'a,
|
||||||
|
T,
|
||||||
|
R: Dim,
|
||||||
|
Cols: Dim,
|
||||||
|
S: RawStorage<T, R, Cols> + RawStorageMut<T, R, Cols>,
|
||||||
|
> {
|
||||||
|
mat: &'a mut Matrix<T, R, Cols, S>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
/// *only availabe if compiled with the feature `rayon`*
|
||||||
|
impl<'a, T, R, Cols, S> ParColumnIterMut<'a, T, R, Cols, S>
|
||||||
|
where
|
||||||
|
R: Dim,
|
||||||
|
Cols: Dim,
|
||||||
|
S: RawStorage<T, R, Cols> + RawStorageMut<T, R, Cols>,
|
||||||
|
{
|
||||||
|
/// create a new parallel iterator for the given matrix.
|
||||||
|
fn new(mat: &'a mut Matrix<T, R, Cols, S>) -> Self {
|
||||||
|
Self { mat }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
/// *Only available if compiled with the feature `rayon`*
|
||||||
|
impl<'a, T, R, Cols, S> ParallelIterator for ParColumnIterMut<'a, T, R, Cols, S>
|
||||||
|
where
|
||||||
|
R: Dim,
|
||||||
|
Cols: Dim,
|
||||||
|
S: RawStorage<T, R, Cols> + RawStorageMut<T, R, Cols>,
|
||||||
|
T: Send + Sync + Scalar,
|
||||||
|
S: Send + Sync,
|
||||||
|
{
|
||||||
|
type Item = MatrixViewMut<'a, T, R, U1, S::RStride, S::CStride>;
|
||||||
|
fn drive_unindexed<C>(self, consumer: C) -> C::Result
|
||||||
|
where
|
||||||
|
C: rayon::iter::plumbing::UnindexedConsumer<Self::Item>,
|
||||||
|
{
|
||||||
|
bridge(self, consumer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn opt_len(&self) -> Option<usize> {
|
||||||
|
Some(self.mat.ncols())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
/// *Only available if compiled with the feature `rayon`*
|
||||||
|
impl<'a, T, R, Cols, S> IndexedParallelIterator for ParColumnIterMut<'a, T, R, Cols, S>
|
||||||
|
where
|
||||||
|
R: Dim,
|
||||||
|
Cols: Dim,
|
||||||
|
S: RawStorage<T, R, Cols> + RawStorageMut<T, R, Cols>,
|
||||||
|
T: Send + Sync + Scalar,
|
||||||
|
S: Send + Sync,
|
||||||
|
{
|
||||||
|
fn drive<C: rayon::iter::plumbing::Consumer<Self::Item>>(self, consumer: C) -> C::Result {
|
||||||
|
bridge(self, consumer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn len(&self) -> usize {
|
||||||
|
self.mat.ncols()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_producer<CB: rayon::iter::plumbing::ProducerCallback<Self::Item>>(
|
||||||
|
self,
|
||||||
|
callback: CB,
|
||||||
|
) -> CB::Output {
|
||||||
|
let producer = ColumnProducerMut(ColumnIterMut::new(self.mat));
|
||||||
|
callback.callback(producer)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
/// # Parallel iterators using `rayon`
|
||||||
|
/// *Only available if compiled with the feature `rayon`*
|
||||||
|
impl<T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> Matrix<T, R, Cols, S>
|
||||||
|
where
|
||||||
|
T: Send + Sync + Scalar,
|
||||||
|
S: Sync,
|
||||||
|
{
|
||||||
|
/// Iterate through the columns of the matrix in parallel using rayon.
|
||||||
|
/// This iterates over *immutable* references ot the columns of the matrix,
|
||||||
|
/// if *mutable* access to the columns is required, use [`par_column_iter_mut`]
|
||||||
|
/// instead.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
/// Using parallel column iterators to calculate the sum of the maximum
|
||||||
|
/// elements in each column:
|
||||||
|
/// ```
|
||||||
|
/// use nalgebra::{dmatrix, DMatrix};
|
||||||
|
/// use rayon::prelude::*;
|
||||||
|
///
|
||||||
|
/// let matrix : DMatrix<f64> = dmatrix![1.0, 0.0, 5.0;
|
||||||
|
/// 2.0, 4.0, 1.0;
|
||||||
|
/// 3.0, 2.0, 2.0;
|
||||||
|
/// ];
|
||||||
|
/// let sum_of_max :f64 = matrix
|
||||||
|
/// .par_column_iter()
|
||||||
|
/// .map(|col| col.max())
|
||||||
|
/// .sum();
|
||||||
|
///
|
||||||
|
/// assert_eq!(sum_of_max,3.0 + 4.0 + 5.0);
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// [`par_column_iter_mut`]: crate::Matrix::par_column_iter_mut
|
||||||
|
pub fn par_column_iter(&self) -> ParColumnIter<'_, T, R, Cols, S> {
|
||||||
|
ParColumnIter::new(self)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mutably iterate through the columns of this matrix in parallel using rayon.
|
||||||
|
/// Allows mutable access to the columns in parallel using mutable references.
|
||||||
|
/// If mutable access to the columns is not required rather use [`par_column_iter`]
|
||||||
|
/// instead.
|
||||||
|
///
|
||||||
|
/// # Example
|
||||||
|
/// Normalize each column of a matrix with respect to its own maximum value.
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use nalgebra::{dmatrix, DMatrix};
|
||||||
|
/// use rayon::prelude::*;
|
||||||
|
///
|
||||||
|
/// let mut matrix : DMatrix<f64> = dmatrix![
|
||||||
|
/// 2.0, 4.0, 6.0;
|
||||||
|
/// 1.0, 2.0, 3.0;
|
||||||
|
/// ];
|
||||||
|
/// matrix.par_column_iter_mut().for_each(|mut col| col /= col.max());
|
||||||
|
///
|
||||||
|
/// assert_eq!(matrix, dmatrix![1.0, 1.0, 1.0; 0.5, 0.5, 0.5]);
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// [`par_column_iter`]: crate::Matrix::par_column_iter
|
||||||
|
pub fn par_column_iter_mut(&mut self) -> ParColumnIterMut<'_, T, R, Cols, S>
|
||||||
|
where
|
||||||
|
S: RawStorageMut<T, R, Cols>,
|
||||||
|
{
|
||||||
|
ParColumnIterMut::new(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A private helper newtype that wraps the `ColumnIter` and implements
|
||||||
|
/// the rayon `Producer` trait. It's just here so we don't have to make the
|
||||||
|
/// rayon trait part of the public interface of the `ColumnIter`.
|
||||||
|
struct ColumnProducer<'a, T, R: Dim, C: Dim, S: RawStorage<T, R, C>>(ColumnIter<'a, T, R, C, S>);
|
||||||
|
|
||||||
|
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
|
||||||
|
/// *only available if compiled with the feature `rayon`*
|
||||||
|
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> Producer
|
||||||
|
for ColumnProducer<'a, T, R, Cols, S>
|
||||||
|
where
|
||||||
|
T: Send + Sync + Scalar,
|
||||||
|
S: Sync,
|
||||||
|
{
|
||||||
|
type Item = MatrixView<'a, T, R, U1, S::RStride, S::CStride>;
|
||||||
|
type IntoIter = ColumnIter<'a, T, R, Cols, S>;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn split_at(self, index: usize) -> (Self, Self) {
|
||||||
|
// The index is relative to the size of this current iterator.
|
||||||
|
// It will always start at zero so it serves as an offset.
|
||||||
|
let (left_iter, right_iter) = self.0.split_at(index);
|
||||||
|
(Self(left_iter), Self(right_iter))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See `ColumnProducer`. A private wrapper newtype that keeps the Producer
|
||||||
|
/// implementation private
|
||||||
|
struct ColumnProducerMut<'a, T, R: Dim, C: Dim, S: RawStorageMut<T, R, C>>(
|
||||||
|
ColumnIterMut<'a, T, R, C, S>,
|
||||||
|
);
|
||||||
|
|
||||||
|
impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Producer
|
||||||
|
for ColumnProducerMut<'a, T, R, C, S>
|
||||||
|
where
|
||||||
|
T: Send + Sync + Scalar,
|
||||||
|
S: Send + Sync,
|
||||||
|
{
|
||||||
|
type Item = MatrixViewMut<'a, T, R, U1, S::RStride, S::CStride>;
|
||||||
|
type IntoIter = ColumnIterMut<'a, T, R, C, S>;
|
||||||
|
|
||||||
|
fn into_iter(self) -> Self::IntoIter {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn split_at(self, index: usize) -> (Self, Self) {
|
||||||
|
// The index is relative to the size of this current iterator
|
||||||
|
// it will always start at zero so it serves as an offset.
|
||||||
|
let (left_iter, right_iter) = self.0.split_at(index);
|
||||||
|
(Self(left_iter), Self(right_iter))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// this implementation is safe because we are enforcing exclusive access
|
||||||
|
/// to the columns through the active range of the iterator
|
||||||
|
unsafe impl<'a, T: Scalar, R: Dim, C: Dim, S: 'a + RawStorageMut<T, R, C>> Send
|
||||||
|
for ColumnIterMut<'a, T, R, C, S>
|
||||||
|
{
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
//! Wrapper that allows changing the generic type of a PhantomData<T>
|
||||||
|
//!
|
||||||
|
//! Copied from https://github.com/rkyv/rkyv_contrib (MIT-Apache2 licences) which isn’t published yet.
|
||||||
|
|
||||||
|
use rkyv::{
|
||||||
|
with::{ArchiveWith, DeserializeWith, SerializeWith},
|
||||||
|
Fallible,
|
||||||
|
};
|
||||||
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
|
/// A wrapper that allows for changing the generic type of a PhantomData<T>.
|
||||||
|
pub struct CustomPhantom<NT: ?Sized> {
|
||||||
|
_data: PhantomData<*const NT>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<OT: ?Sized, NT: ?Sized> ArchiveWith<PhantomData<OT>> for CustomPhantom<NT> {
|
||||||
|
type Archived = PhantomData<NT>;
|
||||||
|
type Resolver = ();
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
unsafe fn resolve_with(
|
||||||
|
_: &PhantomData<OT>,
|
||||||
|
_: usize,
|
||||||
|
_: Self::Resolver,
|
||||||
|
_: *mut Self::Archived,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<OT: ?Sized, NT: ?Sized, S: Fallible + ?Sized> SerializeWith<PhantomData<OT>, S>
|
||||||
|
for CustomPhantom<NT>
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn serialize_with(_: &PhantomData<OT>, _: &mut S) -> Result<Self::Resolver, S::Error> {
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<OT: ?Sized, NT: ?Sized, D: Fallible + ?Sized>
|
||||||
|
DeserializeWith<PhantomData<NT>, PhantomData<OT>, D> for CustomPhantom<NT>
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn deserialize_with(_: &PhantomData<NT>, _: &mut D) -> Result<PhantomData<OT>, D::Error> {
|
||||||
|
Ok(PhantomData)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::allocator::Allocator;
|
use crate::allocator::Allocator;
|
||||||
use crate::storage::RawStorage;
|
use crate::storage::RawStorage;
|
||||||
use crate::{Const, DefaultAllocator, Dim, Matrix, OVector, RowOVector, Scalar, VectorSlice, U1};
|
use crate::{Const, DefaultAllocator, Dim, Matrix, OVector, RowOVector, Scalar, VectorView, U1};
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use simba::scalar::{ClosedAdd, ClosedMul, Field, SupersetOf};
|
use simba::scalar::{ClosedAdd, ClosedMul, Field, SupersetOf};
|
||||||
use std::mem::MaybeUninit;
|
use std::mem::MaybeUninit;
|
||||||
|
@ -13,7 +13,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn compress_rows(
|
pub fn compress_rows(
|
||||||
&self,
|
&self,
|
||||||
f: impl Fn(VectorSlice<'_, T, R, S::RStride, S::CStride>) -> T,
|
f: impl Fn(VectorView<'_, T, R, S::RStride, S::CStride>) -> T,
|
||||||
) -> RowOVector<T, C>
|
) -> RowOVector<T, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, U1, C>,
|
DefaultAllocator: Allocator<T, U1, C>,
|
||||||
|
@ -41,7 +41,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn compress_rows_tr(
|
pub fn compress_rows_tr(
|
||||||
&self,
|
&self,
|
||||||
f: impl Fn(VectorSlice<'_, T, R, S::RStride, S::CStride>) -> T,
|
f: impl Fn(VectorView<'_, T, R, S::RStride, S::CStride>) -> T,
|
||||||
) -> OVector<T, C>
|
) -> OVector<T, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, C>,
|
DefaultAllocator: Allocator<T, C>,
|
||||||
|
@ -67,7 +67,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
pub fn compress_columns(
|
pub fn compress_columns(
|
||||||
&self,
|
&self,
|
||||||
init: OVector<T, R>,
|
init: OVector<T, R>,
|
||||||
f: impl Fn(&mut OVector<T, R>, VectorSlice<'_, T, R, S::RStride, S::CStride>),
|
f: impl Fn(&mut OVector<T, R>, VectorView<'_, T, R, S::RStride, S::CStride>),
|
||||||
) -> OVector<T, R>
|
) -> OVector<T, R>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, R>,
|
DefaultAllocator: Allocator<T, R>,
|
||||||
|
|
|
@ -122,7 +122,7 @@ pub unsafe trait RawStorage<T, R: Dim, C: Dim = U1>: Sized {
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// The matrix components may not be stored in a contiguous way, depending on the strides.
|
/// The matrix components may not be stored in a contiguous way, depending on the strides.
|
||||||
/// This method is unsafe because this can yield to invalid aliasing when called on some pairs
|
/// This method is unsafe because this can yield to invalid aliasing when called on some pairs
|
||||||
/// of matrix slices originating from the same matrix with strides.
|
/// of matrix views originating from the same matrix with strides.
|
||||||
///
|
///
|
||||||
/// Call the safe alternative `matrix.as_slice()` instead.
|
/// Call the safe alternative `matrix.as_slice()` instead.
|
||||||
unsafe fn as_slice_unchecked(&self) -> &[T];
|
unsafe fn as_slice_unchecked(&self) -> &[T];
|
||||||
|
@ -148,7 +148,7 @@ pub unsafe trait Storage<T, R: Dim, C: Dim = U1>: RawStorage<T, R, C> {
|
||||||
/// contains `MaybeUninit<T>` elements.
|
/// contains `MaybeUninit<T>` elements.
|
||||||
///
|
///
|
||||||
/// Note that a mutable access does not mean that the matrix owns its data. For example, a mutable
|
/// Note that a mutable access does not mean that the matrix owns its data. For example, a mutable
|
||||||
/// matrix slice can provide mutable access to its elements even if it does not own its data (it
|
/// matrix view can provide mutable access to its elements even if it does not own its data (it
|
||||||
/// contains only an internal reference to them).
|
/// contains only an internal reference to them).
|
||||||
pub unsafe trait RawStorageMut<T, R: Dim, C: Dim = U1>: RawStorage<T, R, C> {
|
pub unsafe trait RawStorageMut<T, R: Dim, C: Dim = U1>: RawStorage<T, R, C> {
|
||||||
/// The matrix mutable data pointer.
|
/// The matrix mutable data pointer.
|
||||||
|
|
|
@ -21,11 +21,17 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
||||||
/// in their documentation, read their dedicated pages directly.
|
/// in their documentation, read their dedicated pages directly.
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Hash, Copy)]
|
#[derive(Clone, Hash, Copy)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Unit<T::Archived>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
// #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
// #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
pub struct Unit<T> {
|
pub struct Unit<T> {
|
||||||
pub(crate) value: T,
|
pub(crate) value: T,
|
||||||
|
|
|
@ -4,7 +4,7 @@ use alloc::vec::Vec;
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::constraint::{SameNumberOfRows, ShapeConstraint};
|
use crate::base::constraint::{SameNumberOfRows, ShapeConstraint};
|
||||||
use crate::base::default_allocator::DefaultAllocator;
|
use crate::base::default_allocator::DefaultAllocator;
|
||||||
use crate::base::dimension::{Dim, DimName, Dynamic, U1};
|
use crate::base::dimension::{Dim, DimName, Dyn, U1};
|
||||||
use crate::base::storage::{IsContiguous, Owned, RawStorage, RawStorageMut, ReshapableStorage};
|
use crate::base::storage::{IsContiguous, Owned, RawStorage, RawStorageMut, ReshapableStorage};
|
||||||
use crate::base::{Scalar, Vector};
|
use crate::base::{Scalar, Vector};
|
||||||
|
|
||||||
|
@ -188,13 +188,13 @@ impl<T, R: Dim, C: Dim> From<VecStorage<T, R, C>> for Vec<T> {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Dynamic − Static
|
* Dyn − Static
|
||||||
* Dynamic − Dynamic
|
* Dyn − Dyn
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
unsafe impl<T, C: Dim> RawStorage<T, Dynamic, C> for VecStorage<T, Dynamic, C> {
|
unsafe impl<T, C: Dim> RawStorage<T, Dyn, C> for VecStorage<T, Dyn, C> {
|
||||||
type RStride = U1;
|
type RStride = U1;
|
||||||
type CStride = Dynamic;
|
type CStride = Dyn;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ptr(&self) -> *const T {
|
fn ptr(&self) -> *const T {
|
||||||
|
@ -202,7 +202,7 @@ unsafe impl<T, C: Dim> RawStorage<T, Dynamic, C> for VecStorage<T, Dynamic, C> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn shape(&self) -> (Dynamic, C) {
|
fn shape(&self) -> (Dyn, C) {
|
||||||
(self.nrows, self.ncols)
|
(self.nrows, self.ncols)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,28 +222,28 @@ unsafe impl<T, C: Dim> RawStorage<T, Dynamic, C> for VecStorage<T, Dynamic, C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<T: Scalar, C: Dim> Storage<T, Dynamic, C> for VecStorage<T, Dynamic, C>
|
unsafe impl<T: Scalar, C: Dim> Storage<T, Dyn, C> for VecStorage<T, Dyn, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C, Buffer = Self>,
|
DefaultAllocator: Allocator<T, Dyn, C, Buffer = Self>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_owned(self) -> Owned<T, Dynamic, C>
|
fn into_owned(self) -> Owned<T, Dyn, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C>,
|
DefaultAllocator: Allocator<T, Dyn, C>,
|
||||||
{
|
{
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone_owned(&self) -> Owned<T, Dynamic, C>
|
fn clone_owned(&self) -> Owned<T, Dyn, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, Dynamic, C>,
|
DefaultAllocator: Allocator<T, Dyn, C>,
|
||||||
{
|
{
|
||||||
self.clone()
|
self.clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<T, R: DimName> RawStorage<T, R, Dynamic> for VecStorage<T, R, Dynamic> {
|
unsafe impl<T, R: DimName> RawStorage<T, R, Dyn> for VecStorage<T, R, Dyn> {
|
||||||
type RStride = U1;
|
type RStride = U1;
|
||||||
type CStride = R;
|
type CStride = R;
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ unsafe impl<T, R: DimName> RawStorage<T, R, Dynamic> for VecStorage<T, R, Dynami
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn shape(&self) -> (R, Dynamic) {
|
fn shape(&self) -> (R, Dyn) {
|
||||||
(self.nrows, self.ncols)
|
(self.nrows, self.ncols)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,22 +273,22 @@ unsafe impl<T, R: DimName> RawStorage<T, R, Dynamic> for VecStorage<T, R, Dynami
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<T: Scalar, R: DimName> Storage<T, R, Dynamic> for VecStorage<T, R, Dynamic>
|
unsafe impl<T: Scalar, R: DimName> Storage<T, R, Dyn> for VecStorage<T, R, Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, R, Dynamic, Buffer = Self>,
|
DefaultAllocator: Allocator<T, R, Dyn, Buffer = Self>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into_owned(self) -> Owned<T, R, Dynamic>
|
fn into_owned(self) -> Owned<T, R, Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, R, Dynamic>,
|
DefaultAllocator: Allocator<T, R, Dyn>,
|
||||||
{
|
{
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone_owned(&self) -> Owned<T, R, Dynamic>
|
fn clone_owned(&self) -> Owned<T, R, Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, R, Dynamic>,
|
DefaultAllocator: Allocator<T, R, Dyn>,
|
||||||
{
|
{
|
||||||
self.clone()
|
self.clone()
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ where
|
||||||
* RawStorageMut, ContiguousStorage.
|
* RawStorageMut, ContiguousStorage.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
unsafe impl<T, C: Dim> RawStorageMut<T, Dynamic, C> for VecStorage<T, Dynamic, C> {
|
unsafe impl<T, C: Dim> RawStorageMut<T, Dyn, C> for VecStorage<T, Dyn, C> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ptr_mut(&mut self) -> *mut T {
|
fn ptr_mut(&mut self) -> *mut T {
|
||||||
self.data.as_mut_ptr()
|
self.data.as_mut_ptr()
|
||||||
|
@ -313,15 +313,15 @@ unsafe impl<T, C: Dim> RawStorageMut<T, Dynamic, C> for VecStorage<T, Dynamic, C
|
||||||
|
|
||||||
unsafe impl<T, R: Dim, C: Dim> IsContiguous for VecStorage<T, R, C> {}
|
unsafe impl<T, R: Dim, C: Dim> IsContiguous for VecStorage<T, R, C> {}
|
||||||
|
|
||||||
impl<T, C1, C2> ReshapableStorage<T, Dynamic, C1, Dynamic, C2> for VecStorage<T, Dynamic, C1>
|
impl<T, C1, C2> ReshapableStorage<T, Dyn, C1, Dyn, C2> for VecStorage<T, Dyn, C1>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
C1: Dim,
|
C1: Dim,
|
||||||
C2: Dim,
|
C2: Dim,
|
||||||
{
|
{
|
||||||
type Output = VecStorage<T, Dynamic, C2>;
|
type Output = VecStorage<T, Dyn, C2>;
|
||||||
|
|
||||||
fn reshape_generic(self, nrows: Dynamic, ncols: C2) -> Self::Output {
|
fn reshape_generic(self, nrows: Dyn, ncols: C2) -> Self::Output {
|
||||||
assert_eq!(nrows.value() * ncols.value(), self.data.len());
|
assert_eq!(nrows.value() * ncols.value(), self.data.len());
|
||||||
VecStorage {
|
VecStorage {
|
||||||
data: self.data,
|
data: self.data,
|
||||||
|
@ -331,15 +331,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, C1, R2> ReshapableStorage<T, Dynamic, C1, R2, Dynamic> for VecStorage<T, Dynamic, C1>
|
impl<T, C1, R2> ReshapableStorage<T, Dyn, C1, R2, Dyn> for VecStorage<T, Dyn, C1>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
C1: Dim,
|
C1: Dim,
|
||||||
R2: DimName,
|
R2: DimName,
|
||||||
{
|
{
|
||||||
type Output = VecStorage<T, R2, Dynamic>;
|
type Output = VecStorage<T, R2, Dyn>;
|
||||||
|
|
||||||
fn reshape_generic(self, nrows: R2, ncols: Dynamic) -> Self::Output {
|
fn reshape_generic(self, nrows: R2, ncols: Dyn) -> Self::Output {
|
||||||
assert_eq!(nrows.value() * ncols.value(), self.data.len());
|
assert_eq!(nrows.value() * ncols.value(), self.data.len());
|
||||||
VecStorage {
|
VecStorage {
|
||||||
data: self.data,
|
data: self.data,
|
||||||
|
@ -349,7 +349,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl<T, R: DimName> RawStorageMut<T, R, Dynamic> for VecStorage<T, R, Dynamic> {
|
unsafe impl<T, R: DimName> RawStorageMut<T, R, Dyn> for VecStorage<T, R, Dyn> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn ptr_mut(&mut self) -> *mut T {
|
fn ptr_mut(&mut self) -> *mut T {
|
||||||
self.data.as_mut_ptr()
|
self.data.as_mut_ptr()
|
||||||
|
@ -361,15 +361,15 @@ unsafe impl<T, R: DimName> RawStorageMut<T, R, Dynamic> for VecStorage<T, R, Dyn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, R1, C2> ReshapableStorage<T, R1, Dynamic, Dynamic, C2> for VecStorage<T, R1, Dynamic>
|
impl<T, R1, C2> ReshapableStorage<T, R1, Dyn, Dyn, C2> for VecStorage<T, R1, Dyn>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
R1: DimName,
|
R1: DimName,
|
||||||
C2: Dim,
|
C2: Dim,
|
||||||
{
|
{
|
||||||
type Output = VecStorage<T, Dynamic, C2>;
|
type Output = VecStorage<T, Dyn, C2>;
|
||||||
|
|
||||||
fn reshape_generic(self, nrows: Dynamic, ncols: C2) -> Self::Output {
|
fn reshape_generic(self, nrows: Dyn, ncols: C2) -> Self::Output {
|
||||||
assert_eq!(nrows.value() * ncols.value(), self.data.len());
|
assert_eq!(nrows.value() * ncols.value(), self.data.len());
|
||||||
VecStorage {
|
VecStorage {
|
||||||
data: self.data,
|
data: self.data,
|
||||||
|
@ -379,15 +379,15 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, R1, R2> ReshapableStorage<T, R1, Dynamic, R2, Dynamic> for VecStorage<T, R1, Dynamic>
|
impl<T, R1, R2> ReshapableStorage<T, R1, Dyn, R2, Dyn> for VecStorage<T, R1, Dyn>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
R1: DimName,
|
R1: DimName,
|
||||||
R2: DimName,
|
R2: DimName,
|
||||||
{
|
{
|
||||||
type Output = VecStorage<T, R2, Dynamic>;
|
type Output = VecStorage<T, R2, Dyn>;
|
||||||
|
|
||||||
fn reshape_generic(self, nrows: R2, ncols: Dynamic) -> Self::Output {
|
fn reshape_generic(self, nrows: R2, ncols: Dyn) -> Self::Output {
|
||||||
assert_eq!(nrows.value() * ncols.value(), self.data.len());
|
assert_eq!(nrows.value() * ncols.value(), self.data.len());
|
||||||
VecStorage {
|
VecStorage {
|
||||||
data: self.data,
|
data: self.data,
|
||||||
|
@ -397,7 +397,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, R: Dim> Extend<T> for VecStorage<T, R, Dynamic> {
|
impl<T, R: Dim> Extend<T> for VecStorage<T, R, Dyn> {
|
||||||
/// Extends the number of columns of the `VecStorage` with elements
|
/// Extends the number of columns of the `VecStorage` with elements
|
||||||
/// from the given iterator.
|
/// from the given iterator.
|
||||||
///
|
///
|
||||||
|
@ -407,13 +407,13 @@ impl<T, R: Dim> Extend<T> for VecStorage<T, R, Dynamic> {
|
||||||
/// `VecStorage`.
|
/// `VecStorage`.
|
||||||
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
|
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
|
||||||
self.data.extend(iter);
|
self.data.extend(iter);
|
||||||
self.ncols = Dynamic::new(self.data.len() / self.nrows.value());
|
self.ncols = Dyn(self.data.len() / self.nrows.value());
|
||||||
assert!(self.data.len() % self.nrows.value() == 0,
|
assert!(self.data.len() % self.nrows.value() == 0,
|
||||||
"The number of elements produced by the given iterator was not a multiple of the number of rows.");
|
"The number of elements produced by the given iterator was not a multiple of the number of rows.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: 'a + Copy, R: Dim> Extend<&'a T> for VecStorage<T, R, Dynamic> {
|
impl<'a, T: 'a + Copy, R: Dim> Extend<&'a T> for VecStorage<T, R, Dyn> {
|
||||||
/// Extends the number of columns of the `VecStorage` with elements
|
/// Extends the number of columns of the `VecStorage` with elements
|
||||||
/// from the given iterator.
|
/// from the given iterator.
|
||||||
///
|
///
|
||||||
|
@ -426,7 +426,7 @@ impl<'a, T: 'a + Copy, R: Dim> Extend<&'a T> for VecStorage<T, R, Dynamic> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, R, RV, SV> Extend<Vector<T, RV, SV>> for VecStorage<T, R, Dynamic>
|
impl<T, R, RV, SV> Extend<Vector<T, RV, SV>> for VecStorage<T, R, Dyn>
|
||||||
where
|
where
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
R: Dim,
|
R: Dim,
|
||||||
|
@ -450,15 +450,15 @@ where
|
||||||
assert_eq!(nrows, vector.shape().0);
|
assert_eq!(nrows, vector.shape().0);
|
||||||
self.data.extend(vector.iter().cloned());
|
self.data.extend(vector.iter().cloned());
|
||||||
}
|
}
|
||||||
self.ncols = Dynamic::new(self.data.len() / nrows);
|
self.ncols = Dyn(self.data.len() / nrows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Extend<T> for VecStorage<T, Dynamic, U1> {
|
impl<T> Extend<T> for VecStorage<T, Dyn, U1> {
|
||||||
/// Extends the number of rows of the `VecStorage` with elements
|
/// Extends the number of rows of the `VecStorage` with elements
|
||||||
/// from the given iterator.
|
/// from the given iterator.
|
||||||
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
|
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
|
||||||
self.data.extend(iter);
|
self.data.extend(iter);
|
||||||
self.nrows = Dynamic::new(self.data.len());
|
self.nrows = Dyn(self.data.len());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::base::storage::Owned;
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{Dim, Dynamic};
|
use crate::base::dimension::{Dim, Dyn};
|
||||||
use crate::base::Scalar;
|
use crate::base::Scalar;
|
||||||
use crate::base::{DefaultAllocator, OMatrix};
|
use crate::base::{DefaultAllocator, OMatrix};
|
||||||
use crate::linalg::givens::GivensRotation;
|
use crate::linalg::givens::GivensRotation;
|
||||||
|
@ -12,7 +12,7 @@ use simba::scalar::ComplexField;
|
||||||
|
|
||||||
/// A random orthogonal matrix.
|
/// A random orthogonal matrix.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct RandomOrthogonal<T: Scalar, D: Dim = Dynamic>
|
pub struct RandomOrthogonal<T: Scalar, D: Dim = Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, D, D>,
|
DefaultAllocator: Allocator<T, D, D>,
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::base::storage::Owned;
|
||||||
use quickcheck::{Arbitrary, Gen};
|
use quickcheck::{Arbitrary, Gen};
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{Dim, Dynamic};
|
use crate::base::dimension::{Dim, Dyn};
|
||||||
use crate::base::Scalar;
|
use crate::base::Scalar;
|
||||||
use crate::base::{DefaultAllocator, OMatrix};
|
use crate::base::{DefaultAllocator, OMatrix};
|
||||||
use simba::scalar::ComplexField;
|
use simba::scalar::ComplexField;
|
||||||
|
@ -13,7 +13,7 @@ use crate::debug::RandomOrthogonal;
|
||||||
|
|
||||||
/// A random, well-conditioned, symmetric definite-positive matrix.
|
/// A random, well-conditioned, symmetric definite-positive matrix.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct RandomSDP<T: Scalar, D: Dim = Dynamic>
|
pub struct RandomSDP<T: Scalar, D: Dim = Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, D, D>,
|
DefaultAllocator: Allocator<T, D, D>,
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,11 +40,18 @@ use simba::scalar::{ClosedNeg, RealField};
|
||||||
/// See <https://github.com/dimforge/nalgebra/issues/487>
|
/// See <https://github.com/dimforge/nalgebra/issues/487>
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "DualQuaternion<T::Archived>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
Quaternion<T>: rkyv::Archive<Archived = Quaternion<T::Archived>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
pub struct DualQuaternion<T> {
|
pub struct DualQuaternion<T> {
|
||||||
/// The real component of the quaternion
|
/// The real component of the quaternion
|
||||||
|
|
|
@ -21,6 +21,7 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
||||||
/// A 2D isometry is composed of:
|
/// A 2D isometry is composed of:
|
||||||
/// - A translation part of type [`Translation2`](crate::Translation2)
|
/// - A translation part of type [`Translation2`](crate::Translation2)
|
||||||
/// - A rotation part which can either be a [`UnitComplex`](crate::UnitComplex) or a [`Rotation2`](crate::Rotation2).
|
/// - A rotation part which can either be a [`UnitComplex`](crate::UnitComplex) or a [`Rotation2`](crate::Rotation2).
|
||||||
|
///
|
||||||
/// A 3D isometry is composed of:
|
/// A 3D isometry is composed of:
|
||||||
/// - A translation part of type [`Translation3`](crate::Translation3)
|
/// - A translation part of type [`Translation3`](crate::Translation3)
|
||||||
/// - A rotation part which can either be a [`UnitQuaternion`](crate::UnitQuaternion) or a [`Rotation3`](crate::Rotation3).
|
/// - A rotation part which can either be a [`UnitQuaternion`](crate::UnitQuaternion) or a [`Rotation3`](crate::Rotation3).
|
||||||
|
@ -66,11 +67,19 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
||||||
Owned<T, Const<D>>: Deserialize<'de>,
|
Owned<T, Const<D>>: Deserialize<'de>,
|
||||||
T: Scalar"))
|
T: Scalar"))
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Isometry<T::Archived, R::Archived, D>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
R: rkyv::Archive,
|
||||||
|
Translation<T, D>: rkyv::Archive<Archived = Translation<T::Archived, D>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
pub struct Isometry<T, R, const D: usize> {
|
pub struct Isometry<T, R, const D: usize> {
|
||||||
/// The pure rotational part of this isometry.
|
/// The pure rotational part of this isometry.
|
||||||
pub rotation: R,
|
pub rotation: R,
|
||||||
|
@ -425,7 +434,7 @@ impl<T: SimdRealField, R, const D: usize> Isometry<T, R, D> {
|
||||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||||
{
|
{
|
||||||
let mut res: OMatrix<T, _, _> = crate::convert_ref(&self.rotation);
|
let mut res: OMatrix<T, _, _> = crate::convert_ref(&self.rotation);
|
||||||
res.fixed_slice_mut::<D, 1>(0, D)
|
res.fixed_view_mut::<D, 1>(0, D)
|
||||||
.copy_from(&self.translation.vector);
|
.copy_from(&self.translation.vector);
|
||||||
|
|
||||||
res
|
res
|
||||||
|
|
|
@ -153,8 +153,8 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
||||||
let rot = m.fixed_slice::<D, D>(0, 0);
|
let rot = m.fixed_view::<D, D>(0, 0);
|
||||||
let bottom = m.fixed_slice::<1, D>(D, 0);
|
let bottom = m.fixed_view::<1, D>(D, 0);
|
||||||
|
|
||||||
// Scalar types agree.
|
// Scalar types agree.
|
||||||
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
||||||
|
@ -168,7 +168,7 @@ where
|
||||||
fn from_superset_unchecked(
|
fn from_superset_unchecked(
|
||||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let t = m.fixed_slice::<D, 1>(0, D).into_owned();
|
let t = m.fixed_view::<D, 1>(0, D).into_owned();
|
||||||
let t = Translation {
|
let t = Translation {
|
||||||
vector: crate::convert_unchecked(t),
|
vector: crate::convert_unchecked(t),
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,11 +19,18 @@ use crate::geometry::{Point3, Projective3};
|
||||||
|
|
||||||
/// A 3D orthographic projection stored as a homogeneous 4x4 matrix.
|
/// A 3D orthographic projection stored as a homogeneous 4x4 matrix.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Orthographic3<T::Archived>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
Matrix4<T>: rkyv::Archive<Archived = Matrix4<T::Archived>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Orthographic3<T> {
|
pub struct Orthographic3<T> {
|
||||||
|
|
|
@ -20,11 +20,18 @@ use crate::geometry::{Point3, Projective3};
|
||||||
|
|
||||||
/// A 3D perspective projection stored as a homogeneous 4x4 matrix.
|
/// A 3D perspective projection stored as a homogeneous 4x4 matrix.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Perspective3<T::Archived>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
Matrix4<T>: rkyv::Archive<Archived = Matrix4<T::Archived>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Perspective3<T> {
|
pub struct Perspective3<T> {
|
||||||
|
|
|
@ -36,11 +36,20 @@ use std::mem::MaybeUninit;
|
||||||
/// of said transformations for details.
|
/// of said transformations for details.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "OPoint<T::Archived, D>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
T::Archived: Scalar,
|
||||||
|
OVector<T, D>: rkyv::Archive<Archived = OVector<T::Archived, D>>,
|
||||||
|
DefaultAllocator: Allocator<T::Archived, D>,
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
pub struct OPoint<T: Scalar, D: DimName>
|
pub struct OPoint<T: Scalar, D: DimName>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, D>,
|
DefaultAllocator: Allocator<T, D>,
|
||||||
|
@ -204,7 +213,7 @@ where
|
||||||
let mut res = crate::Matrix::uninit(DimNameSum::<D, U1>::name(), Const::<1>);
|
let mut res = crate::Matrix::uninit(DimNameSum::<D, U1>::name(), Const::<1>);
|
||||||
// This is basically a copy_from except that we warp the copied
|
// This is basically a copy_from except that we warp the copied
|
||||||
// values into MaybeUninit.
|
// values into MaybeUninit.
|
||||||
res.generic_slice_mut((0, 0), self.coords.shape_generic())
|
res.generic_view_mut((0, 0), self.coords.shape_generic())
|
||||||
.zip_apply(&self.coords, |out, e| *out = MaybeUninit::new(e));
|
.zip_apply(&self.coords, |out, e| *out = MaybeUninit::new(e));
|
||||||
res[(len, 0)] = MaybeUninit::new(T::one());
|
res[(len, 0)] = MaybeUninit::new(T::one());
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ where
|
||||||
DefaultAllocator: Allocator<T, DimNameSum<D, U1>>,
|
DefaultAllocator: Allocator<T, DimNameSum<D, U1>>,
|
||||||
{
|
{
|
||||||
if !v[D::dim()].is_zero() {
|
if !v[D::dim()].is_zero() {
|
||||||
let coords = v.generic_slice((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone();
|
let coords = v.generic_view((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone();
|
||||||
Some(Self::from(coords))
|
Some(Self::from(coords))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
|
|
@ -66,7 +66,7 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from_superset_unchecked(v: &OVector<T2, DimNameSum<D, U1>>) -> Self {
|
fn from_superset_unchecked(v: &OVector<T2, DimNameSum<D, U1>>) -> Self {
|
||||||
let coords = v.generic_slice((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone();
|
let coords = v.generic_view((0, 0), (D::name(), Const::<1>)) / v[D::dim()].clone();
|
||||||
Self {
|
Self {
|
||||||
coords: crate::convert_unchecked(coords),
|
coords: crate::convert_unchecked(coords),
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use simba::simd::{SimdBool, SimdOption, SimdRealField};
|
||||||
use crate::base::dimension::{U1, U3, U4};
|
use crate::base::dimension::{U1, U3, U4};
|
||||||
use crate::base::storage::{CStride, RStride};
|
use crate::base::storage::{CStride, RStride};
|
||||||
use crate::base::{
|
use crate::base::{
|
||||||
Matrix3, Matrix4, MatrixSlice, MatrixSliceMut, Normed, Scalar, Unit, Vector3, Vector4,
|
Matrix3, Matrix4, MatrixView, MatrixViewMut, Normed, Scalar, Unit, Vector3, Vector4,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::geometry::{Point3, Rotation};
|
use crate::geometry::{Point3, Rotation};
|
||||||
|
@ -23,11 +23,18 @@ use crate::geometry::{Point3, Rotation};
|
||||||
/// that may be used as a rotation.
|
/// that may be used as a rotation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Quaternion<T::Archived>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
Vector4<T>: rkyv::Archive<Archived = Vector4<T::Archived>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
pub struct Quaternion<T> {
|
pub struct Quaternion<T> {
|
||||||
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
|
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
|
||||||
|
@ -188,7 +195,7 @@ where
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn vector(&self) -> MatrixSlice<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>> {
|
pub fn vector(&self) -> MatrixView<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>> {
|
||||||
self.coords.fixed_rows::<3>(0)
|
self.coords.fixed_rows::<3>(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -581,7 +588,7 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn vector_mut(
|
pub fn vector_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> MatrixSliceMut<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>> {
|
) -> MatrixViewMut<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>> {
|
||||||
self.coords.fixed_rows_mut::<3>(0)
|
self.coords.fixed_rows_mut::<3>(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1320,7 +1327,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The rotation axis and angle in ]0, pi] of this unit quaternion.
|
/// The rotation axis and angle in (0, pi] of this unit quaternion.
|
||||||
///
|
///
|
||||||
/// Returns `None` if the angle is zero.
|
/// Returns `None` if the angle is zero.
|
||||||
///
|
///
|
||||||
|
|
|
@ -49,11 +49,18 @@ use crate::geometry::Point;
|
||||||
/// * [Conversion to a matrix <span style="float:right;">`matrix`, `to_homogeneous`…</span>](#conversion-to-a-matrix)
|
/// * [Conversion to a matrix <span style="float:right;">`matrix`, `to_homogeneous`…</span>](#conversion-to-a-matrix)
|
||||||
///
|
///
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Rotation<T::Archived, D>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
SMatrix<T, D, D>: rkyv::Archive<Archived = SMatrix<T::Archived, D, D>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Rotation<T, const D: usize> {
|
pub struct Rotation<T, const D: usize> {
|
||||||
|
@ -258,7 +265,7 @@ impl<T: Scalar, const D: usize> Rotation<T, D> {
|
||||||
// adding the additional traits `DimAdd` and `IsNotStaticOne`. Maybe
|
// adding the additional traits `DimAdd` and `IsNotStaticOne`. Maybe
|
||||||
// these things will get nicer once specialization lands in Rust.
|
// these things will get nicer once specialization lands in Rust.
|
||||||
let mut res = OMatrix::<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>::identity();
|
let mut res = OMatrix::<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>::identity();
|
||||||
res.fixed_slice_mut::<D, D>(0, 0).copy_from(&self.matrix);
|
res.fixed_view_mut::<D, D>(0, 0).copy_from(&self.matrix);
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,8 +211,8 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
||||||
let rot = m.fixed_slice::<D, D>(0, 0);
|
let rot = m.fixed_view::<D, D>(0, 0);
|
||||||
let bottom = m.fixed_slice::<1, D>(D, 0);
|
let bottom = m.fixed_view::<1, D>(D, 0);
|
||||||
|
|
||||||
// Scalar types agree.
|
// Scalar types agree.
|
||||||
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
||||||
|
@ -226,7 +226,7 @@ where
|
||||||
fn from_superset_unchecked(
|
fn from_superset_unchecked(
|
||||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let r = m.fixed_slice::<D, D>(0, 0);
|
let r = m.fixed_view::<D, D>(0, 0);
|
||||||
Self::from_matrix_unchecked(crate::convert_unchecked(r.into_owned()))
|
Self::from_matrix_unchecked(crate::convert_unchecked(r.into_owned()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -877,7 +877,7 @@ impl<T: SimdRealField> Rotation3<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The rotation axis and angle in ]0, pi] of this rotation matrix.
|
/// The rotation axis and angle in (0, pi] of this rotation matrix.
|
||||||
///
|
///
|
||||||
/// Returns `None` if the angle is zero.
|
/// Returns `None` if the angle is zero.
|
||||||
///
|
///
|
||||||
|
@ -956,13 +956,15 @@ impl<T: SimdRealField> Rotation3<T> {
|
||||||
{
|
{
|
||||||
// Implementation informed by "Computing Euler angles from a rotation matrix", by Gregory G. Slabaugh
|
// Implementation informed by "Computing Euler angles from a rotation matrix", by Gregory G. Slabaugh
|
||||||
// https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.371.6578
|
// https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.371.6578
|
||||||
|
// where roll, pitch, yaw angles are referred to as ψ, θ, ϕ,
|
||||||
if self[(2, 0)].clone().abs() < T::one() {
|
if self[(2, 0)].clone().abs() < T::one() {
|
||||||
let yaw = -self[(2, 0)].clone().asin();
|
let pitch = -self[(2, 0)].clone().asin();
|
||||||
let roll = (self[(2, 1)].clone() / yaw.clone().cos())
|
let theta_cos = pitch.clone().cos();
|
||||||
.atan2(self[(2, 2)].clone() / yaw.clone().cos());
|
let roll = (self[(2, 1)].clone() / theta_cos.clone())
|
||||||
let pitch = (self[(1, 0)].clone() / yaw.clone().cos())
|
.atan2(self[(2, 2)].clone() / theta_cos.clone());
|
||||||
.atan2(self[(0, 0)].clone() / yaw.clone().cos());
|
let yaw =
|
||||||
(roll, yaw, pitch)
|
(self[(1, 0)].clone() / theta_cos.clone()).atan2(self[(0, 0)].clone() / theta_cos);
|
||||||
|
(roll, pitch, yaw)
|
||||||
} else if self[(2, 0)].clone() <= -T::one() {
|
} else if self[(2, 0)].clone() <= -T::one() {
|
||||||
(
|
(
|
||||||
self[(0, 1)].clone().atan2(self[(0, 2)].clone()),
|
self[(0, 1)].clone().atan2(self[(0, 2)].clone()),
|
||||||
|
|
|
@ -17,11 +17,18 @@ use crate::geometry::Point;
|
||||||
|
|
||||||
/// A scale which supports non-uniform scaling.
|
/// A scale which supports non-uniform scaling.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Scale<T::Archived, D>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
SVector<T, D>: rkyv::Archive<Archived = SVector<T::Archived, D>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Scale<T, const D: usize> {
|
pub struct Scale<T, const D: usize> {
|
||||||
|
|
|
@ -102,7 +102,7 @@ where
|
||||||
fn from_superset_unchecked(
|
fn from_superset_unchecked(
|
||||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let v = m.fixed_slice::<D, D>(0, 0).diagonal();
|
let v = m.fixed_view::<D, D>(0, 0).diagonal();
|
||||||
Self {
|
Self {
|
||||||
vector: crate::convert_unchecked(v),
|
vector: crate::convert_unchecked(v),
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,11 +34,19 @@ use crate::geometry::{AbstractRotation, Isometry, Point, Translation};
|
||||||
DefaultAllocator: Allocator<T, Const<D>>,
|
DefaultAllocator: Allocator<T, Const<D>>,
|
||||||
Owned<T, Const<D>>: Deserialize<'de>"))
|
Owned<T, Const<D>>: Deserialize<'de>"))
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Similarity<T::Archived, R::Archived, D>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
R: rkyv::Archive,
|
||||||
|
Isometry<T, R, D>: rkyv::Archive<Archived = Isometry<T::Archived, R::Archived, D>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
pub struct Similarity<T, R, const D: usize> {
|
pub struct Similarity<T, R, const D: usize> {
|
||||||
/// The part of this similarity that does not include the scaling factor.
|
/// The part of this similarity that does not include the scaling factor.
|
||||||
pub isometry: Isometry<T, R, D>,
|
pub isometry: Isometry<T, R, D>,
|
||||||
|
@ -301,7 +309,7 @@ impl<T: SimdRealField, R, const D: usize> Similarity<T, R, D> {
|
||||||
{
|
{
|
||||||
let mut res = self.isometry.to_homogeneous();
|
let mut res = self.isometry.to_homogeneous();
|
||||||
|
|
||||||
for e in res.fixed_slice_mut::<D, D>(0, 0).iter_mut() {
|
for e in res.fixed_view_mut::<D, D>(0, 0).iter_mut() {
|
||||||
*e *= self.scaling.clone()
|
*e *= self.scaling.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
||||||
let mut rot = m.fixed_slice::<D, D>(0, 0).clone_owned();
|
let mut rot = m.fixed_view::<D, D>(0, 0).clone_owned();
|
||||||
if rot
|
if rot
|
||||||
.fixed_columns_mut::<1>(0)
|
.fixed_columns_mut::<1>(0)
|
||||||
.try_normalize_mut(T2::zero())
|
.try_normalize_mut(T2::zero())
|
||||||
|
@ -128,7 +128,7 @@ where
|
||||||
rot.fixed_columns_mut::<1>(2).neg_mut();
|
rot.fixed_columns_mut::<1>(2).neg_mut();
|
||||||
}
|
}
|
||||||
|
|
||||||
let bottom = m.fixed_slice::<1, D>(D, 0);
|
let bottom = m.fixed_view::<1, D>(D, 0);
|
||||||
// Scalar types agree.
|
// Scalar types agree.
|
||||||
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
||||||
// The normalized block part is a rotation.
|
// The normalized block part is a rotation.
|
||||||
|
@ -145,22 +145,22 @@ where
|
||||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut mm = m.clone_owned();
|
let mut mm = m.clone_owned();
|
||||||
let na = mm.fixed_slice_mut::<D, 1>(0, 0).normalize_mut();
|
let na = mm.fixed_view_mut::<D, 1>(0, 0).normalize_mut();
|
||||||
let nb = mm.fixed_slice_mut::<D, 1>(0, 1).normalize_mut();
|
let nb = mm.fixed_view_mut::<D, 1>(0, 1).normalize_mut();
|
||||||
let nc = mm.fixed_slice_mut::<D, 1>(0, 2).normalize_mut();
|
let nc = mm.fixed_view_mut::<D, 1>(0, 2).normalize_mut();
|
||||||
|
|
||||||
let mut scale = (na + nb + nc) / crate::convert(3.0); // We take the mean, for robustness.
|
let mut scale = (na + nb + nc) / crate::convert(3.0); // We take the mean, for robustness.
|
||||||
|
|
||||||
// TODO: could we avoid the explicit computation of the determinant?
|
// TODO: could we avoid the explicit computation of the determinant?
|
||||||
// (its sign is needed to see if the scaling factor is negative).
|
// (its sign is needed to see if the scaling factor is negative).
|
||||||
if mm.fixed_slice::<D, D>(0, 0).determinant() < T2::zero() {
|
if mm.fixed_view::<D, D>(0, 0).determinant() < T2::zero() {
|
||||||
mm.fixed_slice_mut::<D, 1>(0, 0).neg_mut();
|
mm.fixed_view_mut::<D, 1>(0, 0).neg_mut();
|
||||||
mm.fixed_slice_mut::<D, 1>(0, 1).neg_mut();
|
mm.fixed_view_mut::<D, 1>(0, 1).neg_mut();
|
||||||
mm.fixed_slice_mut::<D, 1>(0, 2).neg_mut();
|
mm.fixed_view_mut::<D, 1>(0, 2).neg_mut();
|
||||||
scale = -scale;
|
scale = -scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
let t = m.fixed_slice::<D, 1>(0, D).into_owned();
|
let t = m.fixed_view::<D, 1>(0, D).into_owned();
|
||||||
let t = Translation {
|
let t = Translation {
|
||||||
vector: crate::convert_unchecked(t),
|
vector: crate::convert_unchecked(t),
|
||||||
};
|
};
|
||||||
|
|
|
@ -120,10 +120,10 @@ md_impl_all!(
|
||||||
[ref val] => self * &rhs;
|
[ref val] => self * &rhs;
|
||||||
[val ref] => &self * rhs;
|
[val ref] => &self * rhs;
|
||||||
[ref ref] => {
|
[ref ref] => {
|
||||||
let transform = self.matrix().fixed_slice::<D, D>(0, 0);
|
let transform = self.matrix().fixed_view::<D, D>(0, 0);
|
||||||
|
|
||||||
if C::has_normalizer() {
|
if C::has_normalizer() {
|
||||||
let normalizer = self.matrix().fixed_slice::<1, D>(D, 0);
|
let normalizer = self.matrix().fixed_view::<1, D>(D, 0);
|
||||||
let n = normalizer.tr_dot(rhs);
|
let n = normalizer.tr_dot(rhs);
|
||||||
|
|
||||||
if !n.is_zero() {
|
if !n.is_zero() {
|
||||||
|
@ -148,11 +148,11 @@ md_impl_all!(
|
||||||
[ref val] => self * &rhs;
|
[ref val] => self * &rhs;
|
||||||
[val ref] => &self * rhs;
|
[val ref] => &self * rhs;
|
||||||
[ref ref] => {
|
[ref ref] => {
|
||||||
let transform = self.matrix().fixed_slice::<D, D>(0, 0);
|
let transform = self.matrix().fixed_view::<D, D>(0, 0);
|
||||||
let translation = self.matrix().fixed_slice::<D, 1>(0, D);
|
let translation = self.matrix().fixed_view::<D, 1>(0, D);
|
||||||
|
|
||||||
if C::has_normalizer() {
|
if C::has_normalizer() {
|
||||||
let normalizer = self.matrix().fixed_slice::<1, D>(D, 0);
|
let normalizer = self.matrix().fixed_view::<1, D>(D, 0);
|
||||||
#[allow(clippy::suspicious_arithmetic_impl)]
|
#[allow(clippy::suspicious_arithmetic_impl)]
|
||||||
let n = normalizer.tr_dot(&rhs.coords) + unsafe { self.matrix().get_unchecked((D, D)).clone() };
|
let n = normalizer.tr_dot(&rhs.coords) + unsafe { self.matrix().get_unchecked((D, D)).clone() };
|
||||||
|
|
||||||
|
|
|
@ -17,11 +17,18 @@ use crate::geometry::Point;
|
||||||
|
|
||||||
/// A translation.
|
/// A translation.
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "rkyv-serialize-no-std",
|
feature = "rkyv-serialize-no-std",
|
||||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||||
|
archive(
|
||||||
|
as = "Translation<T::Archived, D>",
|
||||||
|
bound(archive = "
|
||||||
|
T: rkyv::Archive,
|
||||||
|
SVector<T, D>: rkyv::Archive<Archived = SVector<T::Archived, D>>
|
||||||
|
")
|
||||||
|
)
|
||||||
)]
|
)]
|
||||||
|
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Translation<T, const D: usize> {
|
pub struct Translation<T, const D: usize> {
|
||||||
|
@ -147,7 +154,7 @@ impl<T: Scalar, const D: usize> Translation<T, D> {
|
||||||
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
DefaultAllocator: Allocator<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||||
{
|
{
|
||||||
let mut res = OMatrix::<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>::identity();
|
let mut res = OMatrix::<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>::identity();
|
||||||
res.fixed_slice_mut::<D, 1>(0, D).copy_from(&self.vector);
|
res.fixed_view_mut::<D, 1>(0, D).copy_from(&self.vector);
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ where
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
fn is_in_subset(m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>) -> bool {
|
||||||
let id = m.generic_slice((0, 0), (DimNameSum::<Const<D>, U1>::name(), Const::<D>));
|
let id = m.generic_view((0, 0), (DimNameSum::<Const<D>, U1>::name(), Const::<D>));
|
||||||
|
|
||||||
// Scalar types agree.
|
// Scalar types agree.
|
||||||
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
||||||
|
@ -173,7 +173,7 @@ where
|
||||||
fn from_superset_unchecked(
|
fn from_superset_unchecked(
|
||||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let t = m.fixed_slice::<D, 1>(0, D);
|
let t = m.fixed_view::<D, 1>(0, D);
|
||||||
Self {
|
Self {
|
||||||
vector: crate::convert_unchecked(t.into_owned()),
|
vector: crate::convert_unchecked(t.into_owned()),
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ where
|
||||||
Vector1::new(self.angle())
|
Vector1::new(self.angle())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The rotation axis and angle in ]0, pi] of this complex number.
|
/// The rotation axis and angle in (0, pi] of this complex number.
|
||||||
///
|
///
|
||||||
/// This is generally used in the context of generic programming. Using
|
/// This is generally used in the context of generic programming. Using
|
||||||
/// the `.angle()` method instead is more common.
|
/// the `.angle()` method instead is more common.
|
||||||
|
|
17
src/lib.rs
17
src/lib.rs
|
@ -83,20 +83,31 @@ an optimized set of tools for computer graphics and physics. Those features incl
|
||||||
unused_variables,
|
unused_variables,
|
||||||
unused_mut,
|
unused_mut,
|
||||||
unused_parens,
|
unused_parens,
|
||||||
unused_qualifications,
|
|
||||||
rust_2018_idioms,
|
rust_2018_idioms,
|
||||||
rust_2018_compatibility,
|
rust_2018_compatibility,
|
||||||
future_incompatible,
|
future_incompatible,
|
||||||
missing_copy_implementations
|
missing_copy_implementations
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(feature = "rkyv-serialize-no-std", warn(unused_results))] // TODO: deny this once bytecheck stops generating warnings.
|
#![cfg_attr(not(feature = "rkyv-serialize-no-std"), deny(unused_results))] // TODO: deny this globally once bytecheck stops generating unused results.
|
||||||
#![cfg_attr(not(feature = "rkyv-serialize-no-std"), deny(unused_results))]
|
|
||||||
#![doc(
|
#![doc(
|
||||||
html_favicon_url = "https://nalgebra.org/img/favicon.ico",
|
html_favicon_url = "https://nalgebra.org/img/favicon.ico",
|
||||||
html_root_url = "https://docs.rs/nalgebra/0.25.0"
|
html_root_url = "https://docs.rs/nalgebra/0.25.0"
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
|
/// Generates an appropriate deprecation note with a suggestion for replacement.
|
||||||
|
///
|
||||||
|
/// Used for deprecating slice types in various locations throughout the library.
|
||||||
|
/// See #1076 for more information.
|
||||||
|
macro_rules! slice_deprecation_note {
|
||||||
|
($replacement:ident) => {
|
||||||
|
concat!("Use ", stringify!($replacement),
|
||||||
|
r###" instead. See [issue #1076](https://github.com/dimforge/nalgebra/issues/1076) for more information."###)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) use slice_deprecation_note;
|
||||||
|
|
||||||
#[cfg(feature = "rand-no-std")]
|
#[cfg(feature = "rand-no-std")]
|
||||||
extern crate rand_package as rand;
|
extern crate rand_package as rand;
|
||||||
|
|
||||||
|
|
|
@ -202,7 +202,7 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
let start = self.axis_shift();
|
let start = self.axis_shift();
|
||||||
res.slice_mut(start, (d.value() - 1, d.value() - 1))
|
res.view_mut(start, (d.value() - 1, d.value() - 1))
|
||||||
.set_partial_diagonal(
|
.set_partial_diagonal(
|
||||||
self.off_diagonal
|
self.off_diagonal
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -226,11 +226,11 @@ where
|
||||||
let shift = self.axis_shift().0;
|
let shift = self.axis_shift().0;
|
||||||
|
|
||||||
for i in (0..dim - shift).rev() {
|
for i in (0..dim - shift).rev() {
|
||||||
let axis = self.uv.slice_range(i + shift.., i);
|
let axis = self.uv.view_range(i + shift.., i);
|
||||||
// TODO: sometimes, the axis might have a zero magnitude.
|
// TODO: sometimes, the axis might have a zero magnitude.
|
||||||
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
||||||
|
|
||||||
let mut res_rows = res.slice_range_mut(i + shift.., i..);
|
let mut res_rows = res.view_range_mut(i + shift.., i..);
|
||||||
|
|
||||||
let sign = if self.upper_diagonal {
|
let sign = if self.upper_diagonal {
|
||||||
self.diagonal[i].clone().signum()
|
self.diagonal[i].clone().signum()
|
||||||
|
@ -260,13 +260,13 @@ where
|
||||||
let shift = self.axis_shift().1;
|
let shift = self.axis_shift().1;
|
||||||
|
|
||||||
for i in (0..min_nrows_ncols.value() - shift).rev() {
|
for i in (0..min_nrows_ncols.value() - shift).rev() {
|
||||||
let axis = self.uv.slice_range(i, i + shift..);
|
let axis = self.uv.view_range(i, i + shift..);
|
||||||
let mut axis_packed = axis_packed.rows_range_mut(i + shift..);
|
let mut axis_packed = axis_packed.rows_range_mut(i + shift..);
|
||||||
axis_packed.tr_copy_from(&axis);
|
axis_packed.tr_copy_from(&axis);
|
||||||
// TODO: sometimes, the axis might have a zero magnitude.
|
// TODO: sometimes, the axis might have a zero magnitude.
|
||||||
let refl = Reflection::new(Unit::new_unchecked(axis_packed), T::zero());
|
let refl = Reflection::new(Unit::new_unchecked(axis_packed), T::zero());
|
||||||
|
|
||||||
let mut res_rows = res.slice_range_mut(i.., i + shift..);
|
let mut res_rows = res.view_range_mut(i.., i + shift..);
|
||||||
|
|
||||||
let sign = if self.upper_diagonal {
|
let sign = if self.upper_diagonal {
|
||||||
self.off_diagonal[i].clone().signum()
|
self.off_diagonal[i].clone().signum()
|
||||||
|
@ -304,7 +304,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// impl<T: ComplexField, D: DimMin<D, Output = D> + DimSub<Dynamic>> Bidiagonal<T, D, D>
|
// impl<T: ComplexField, D: DimMin<D, Output = D> + DimSub<Dyn>> Bidiagonal<T, D, D>
|
||||||
// where DefaultAllocator: Allocator<T, D, D> +
|
// where DefaultAllocator: Allocator<T, D, D> +
|
||||||
// Allocator<T, D> {
|
// Allocator<T, D> {
|
||||||
// /// Solves the linear system `self * x = b`, where `x` is the unknown to be determined.
|
// /// Solves the linear system `self * x = b`, where `x` is the unknown to be determined.
|
||||||
|
@ -346,7 +346,7 @@ where
|
||||||
// *b.vget_unchecked_mut(i) = coeff;
|
// *b.vget_unchecked_mut(i) = coeff;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// b.rows_range_mut(.. i).axpy(-coeff, &self.uv.slice_range(.. i, i), T::one());
|
// b.rows_range_mut(.. i).axpy(-coeff, &self.uv.view_range(.. i, i), T::one());
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use num::One;
|
use num::{One, Zero};
|
||||||
use simba::scalar::ComplexField;
|
use simba::scalar::ComplexField;
|
||||||
use simba::simd::SimdComplexField;
|
use simba::simd::SimdComplexField;
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ where
|
||||||
*matrix.get_unchecked_mut((j, j)) = denom.clone();
|
*matrix.get_unchecked_mut((j, j)) = denom.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut col = matrix.slice_range_mut(j + 1.., j);
|
let mut col = matrix.view_range_mut(j + 1.., j);
|
||||||
col /= denom;
|
col /= denom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +161,27 @@ where
|
||||||
}
|
}
|
||||||
prod_diag.simd_modulus_squared()
|
prod_diag.simd_modulus_squared()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Computes the natural logarithm of determinant of the decomposed matrix.
|
||||||
|
///
|
||||||
|
/// This method is more robust than `.determinant()` to very small or very
|
||||||
|
/// large determinants since it returns the natural logarithm of the
|
||||||
|
/// determinant rather than the determinant itself.
|
||||||
|
#[must_use]
|
||||||
|
pub fn ln_determinant(&self) -> T::SimdRealField {
|
||||||
|
let dim = self.chol.nrows();
|
||||||
|
let mut sum_diag = T::SimdRealField::zero();
|
||||||
|
for i in 0..dim {
|
||||||
|
sum_diag += unsafe {
|
||||||
|
self.chol
|
||||||
|
.get_unchecked((i, i))
|
||||||
|
.clone()
|
||||||
|
.simd_modulus_squared()
|
||||||
|
.simd_ln()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
sum_diag
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ComplexField, D: Dim> Cholesky<T, D>
|
impl<T: ComplexField, D: Dim> Cholesky<T, D>
|
||||||
|
@ -228,7 +249,7 @@ where
|
||||||
*matrix.get_unchecked_mut((j, j)) = denom.clone();
|
*matrix.get_unchecked_mut((j, j)) = denom.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut col = matrix.slice_range_mut(j + 1.., j);
|
let mut col = matrix.view_range_mut(j + 1.., j);
|
||||||
col /= denom;
|
col /= denom;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -283,17 +304,17 @@ where
|
||||||
self.chol.shape_generic().0.add(Const::<1>),
|
self.chol.shape_generic().0.add(Const::<1>),
|
||||||
self.chol.shape_generic().1.add(Const::<1>),
|
self.chol.shape_generic().1.add(Const::<1>),
|
||||||
);
|
);
|
||||||
chol.slice_range_mut(..j, ..j)
|
chol.view_range_mut(..j, ..j)
|
||||||
.copy_from(&self.chol.slice_range(..j, ..j));
|
.copy_from(&self.chol.view_range(..j, ..j));
|
||||||
chol.slice_range_mut(..j, j + 1..)
|
chol.view_range_mut(..j, j + 1..)
|
||||||
.copy_from(&self.chol.slice_range(..j, j..));
|
.copy_from(&self.chol.view_range(..j, j..));
|
||||||
chol.slice_range_mut(j + 1.., ..j)
|
chol.view_range_mut(j + 1.., ..j)
|
||||||
.copy_from(&self.chol.slice_range(j.., ..j));
|
.copy_from(&self.chol.view_range(j.., ..j));
|
||||||
chol.slice_range_mut(j + 1.., j + 1..)
|
chol.view_range_mut(j + 1.., j + 1..)
|
||||||
.copy_from(&self.chol.slice_range(j.., j..));
|
.copy_from(&self.chol.view_range(j.., j..));
|
||||||
|
|
||||||
// update the jth row
|
// update the jth row
|
||||||
let top_left_corner = self.chol.slice_range(..j, ..j);
|
let top_left_corner = self.chol.view_range(..j, ..j);
|
||||||
|
|
||||||
let col_j = col[j].clone();
|
let col_j = col[j].clone();
|
||||||
let (mut new_rowj_adjoint, mut new_colj) = col.rows_range_pair_mut(..j, j + 1..);
|
let (mut new_rowj_adjoint, mut new_colj) = col.rows_range_pair_mut(..j, j + 1..);
|
||||||
|
@ -302,14 +323,14 @@ where
|
||||||
"Cholesky::insert_column : Unable to solve lower triangular system!"
|
"Cholesky::insert_column : Unable to solve lower triangular system!"
|
||||||
);
|
);
|
||||||
|
|
||||||
new_rowj_adjoint.adjoint_to(&mut chol.slice_range_mut(j, ..j));
|
new_rowj_adjoint.adjoint_to(&mut chol.view_range_mut(j, ..j));
|
||||||
|
|
||||||
// update the center element
|
// update the center element
|
||||||
let center_element = T::sqrt(col_j - T::from_real(new_rowj_adjoint.norm_squared()));
|
let center_element = T::sqrt(col_j - T::from_real(new_rowj_adjoint.norm_squared()));
|
||||||
chol[(j, j)] = center_element.clone();
|
chol[(j, j)] = center_element.clone();
|
||||||
|
|
||||||
// update the jth column
|
// update the jth column
|
||||||
let bottom_left_corner = self.chol.slice_range(j.., ..j);
|
let bottom_left_corner = self.chol.view_range(j.., ..j);
|
||||||
// new_colj = (col_jplus - bottom_left_corner * new_rowj.adjoint()) / center_element;
|
// new_colj = (col_jplus - bottom_left_corner * new_rowj.adjoint()) / center_element;
|
||||||
new_colj.gemm(
|
new_colj.gemm(
|
||||||
-T::one() / center_element.clone(),
|
-T::one() / center_element.clone(),
|
||||||
|
@ -317,10 +338,10 @@ where
|
||||||
&new_rowj_adjoint,
|
&new_rowj_adjoint,
|
||||||
T::one() / center_element,
|
T::one() / center_element,
|
||||||
);
|
);
|
||||||
chol.slice_range_mut(j + 1.., j).copy_from(&new_colj);
|
chol.view_range_mut(j + 1.., j).copy_from(&new_colj);
|
||||||
|
|
||||||
// update the bottom right corner
|
// update the bottom right corner
|
||||||
let mut bottom_right_corner = chol.slice_range_mut(j + 1.., j + 1..);
|
let mut bottom_right_corner = chol.view_range_mut(j + 1.., j + 1..);
|
||||||
Self::xx_rank_one_update(
|
Self::xx_rank_one_update(
|
||||||
&mut bottom_right_corner,
|
&mut bottom_right_corner,
|
||||||
&mut new_colj,
|
&mut new_colj,
|
||||||
|
@ -348,17 +369,17 @@ where
|
||||||
self.chol.shape_generic().0.sub(Const::<1>),
|
self.chol.shape_generic().0.sub(Const::<1>),
|
||||||
self.chol.shape_generic().1.sub(Const::<1>),
|
self.chol.shape_generic().1.sub(Const::<1>),
|
||||||
);
|
);
|
||||||
chol.slice_range_mut(..j, ..j)
|
chol.view_range_mut(..j, ..j)
|
||||||
.copy_from(&self.chol.slice_range(..j, ..j));
|
.copy_from(&self.chol.view_range(..j, ..j));
|
||||||
chol.slice_range_mut(..j, j..)
|
chol.view_range_mut(..j, j..)
|
||||||
.copy_from(&self.chol.slice_range(..j, j + 1..));
|
.copy_from(&self.chol.view_range(..j, j + 1..));
|
||||||
chol.slice_range_mut(j.., ..j)
|
chol.view_range_mut(j.., ..j)
|
||||||
.copy_from(&self.chol.slice_range(j + 1.., ..j));
|
.copy_from(&self.chol.view_range(j + 1.., ..j));
|
||||||
chol.slice_range_mut(j.., j..)
|
chol.view_range_mut(j.., j..)
|
||||||
.copy_from(&self.chol.slice_range(j + 1.., j + 1..));
|
.copy_from(&self.chol.view_range(j + 1.., j + 1..));
|
||||||
|
|
||||||
// updates the bottom right corner
|
// updates the bottom right corner
|
||||||
let mut bottom_right_corner = chol.slice_range_mut(j.., j..);
|
let mut bottom_right_corner = chol.view_range_mut(j.., j..);
|
||||||
let mut workspace = self.chol.column(j).clone_owned();
|
let mut workspace = self.chol.column(j).clone_owned();
|
||||||
let mut old_colj = workspace.rows_range_mut(j + 1..);
|
let mut old_colj = workspace.rows_range_mut(j + 1..);
|
||||||
Self::xx_rank_one_update(&mut bottom_right_corner, &mut old_colj, T::RealField::one());
|
Self::xx_rank_one_update(&mut bottom_right_corner, &mut old_colj, T::RealField::one());
|
||||||
|
@ -370,7 +391,7 @@ where
|
||||||
/// performs a rank one update such that we end up with the decomposition of `M + sigma * (x * x.adjoint())`.
|
/// performs a rank one update such that we end up with the decomposition of `M + sigma * (x * x.adjoint())`.
|
||||||
///
|
///
|
||||||
/// This helper method is called by `rank_one_update` but also `insert_column` and `remove_column`
|
/// This helper method is called by `rank_one_update` but also `insert_column` and `remove_column`
|
||||||
/// where it is used on a square slice of the decomposition
|
/// where it is used on a square view of the decomposition
|
||||||
fn xx_rank_one_update<Dm, Sm, Rx, Sx>(
|
fn xx_rank_one_update<Dm, Sm, Rx, Sx>(
|
||||||
chol: &mut Matrix<T, Dm, Dm, Sm>,
|
chol: &mut Matrix<T, Dm, Dm, Sm>,
|
||||||
x: &mut Vector<T, Rx, Sx>,
|
x: &mut Vector<T, Rx, Sx>,
|
||||||
|
@ -404,7 +425,7 @@ where
|
||||||
beta += sigma_xj2 / diag2;
|
beta += sigma_xj2 / diag2;
|
||||||
// updates the terms of L
|
// updates the terms of L
|
||||||
let mut xjplus = x.rows_range_mut(j + 1..);
|
let mut xjplus = x.rows_range_mut(j + 1..);
|
||||||
let mut col_j = chol.slice_range_mut(j + 1.., j);
|
let mut col_j = chol.view_range_mut(j + 1.., j);
|
||||||
// temp_jplus -= (wj / T::from_real(diag)) * col_j;
|
// temp_jplus -= (wj / T::from_real(diag)) * col_j;
|
||||||
xjplus.axpy(-xj.clone() / T::from_real(diag.clone()), &col_j, T::one());
|
xjplus.axpy(-xj.clone() / T::from_real(diag.clone()), &col_j, T::one());
|
||||||
if gamma != crate::zero::<T::RealField>() {
|
if gamma != crate::zero::<T::RealField>() {
|
||||||
|
|
|
@ -78,7 +78,7 @@ where
|
||||||
let mut diag = Matrix::uninit(min_nrows_ncols, Const::<1>);
|
let mut diag = Matrix::uninit(min_nrows_ncols, Const::<1>);
|
||||||
|
|
||||||
for i in 0..min_nrows_ncols.value() {
|
for i in 0..min_nrows_ncols.value() {
|
||||||
let piv = matrix.slice_range(i.., i..).icamax_full();
|
let piv = matrix.view_range(i.., i..).icamax_full();
|
||||||
let col_piv = piv.1 + i;
|
let col_piv = piv.1 + i;
|
||||||
matrix.swap_columns(i, col_piv);
|
matrix.swap_columns(i, col_piv);
|
||||||
p.append_permutation(i, col_piv);
|
p.append_permutation(i, col_piv);
|
||||||
|
@ -144,11 +144,11 @@ where
|
||||||
let dim = self.diag.len();
|
let dim = self.diag.len();
|
||||||
|
|
||||||
for i in (0..dim).rev() {
|
for i in (0..dim).rev() {
|
||||||
let axis = self.col_piv_qr.slice_range(i.., i);
|
let axis = self.col_piv_qr.view_range(i.., i);
|
||||||
// TODO: sometimes, the axis might have a zero magnitude.
|
// TODO: sometimes, the axis might have a zero magnitude.
|
||||||
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
||||||
|
|
||||||
let mut res_rows = res.slice_range_mut(i.., i..);
|
let mut res_rows = res.view_range_mut(i.., i..);
|
||||||
refl.reflect_with_sign(&mut res_rows, self.diag[i].clone().signum());
|
refl.reflect_with_sign(&mut res_rows, self.diag[i].clone().signum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +191,7 @@ where
|
||||||
let dim = self.diag.len();
|
let dim = self.diag.len();
|
||||||
|
|
||||||
for i in 0..dim {
|
for i in 0..dim {
|
||||||
let axis = self.col_piv_qr.slice_range(i.., i);
|
let axis = self.col_piv_qr.view_range(i.., i);
|
||||||
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
||||||
|
|
||||||
let mut rhs_rows = rhs.rows_range_mut(i..);
|
let mut rhs_rows = rhs.rows_range_mut(i..);
|
||||||
|
@ -281,7 +281,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
b.rows_range_mut(..i)
|
b.rows_range_mut(..i)
|
||||||
.axpy(-coeff, &self.col_piv_qr.slice_range(..i, i), T::one());
|
.axpy(-coeff, &self.col_piv_qr.view_range(..i, i), T::one());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use std::fmt::Display;
|
||||||
use std::ops::MulAssign;
|
use std::ops::MulAssign;
|
||||||
|
|
||||||
use crate::allocator::Allocator;
|
use crate::allocator::Allocator;
|
||||||
use crate::base::dimension::{Dim, DimDiff, DimSub, Dynamic, U1, U2, U3};
|
use crate::base::dimension::{Dim, DimDiff, DimSub, Dyn, U1, U2, U3};
|
||||||
use crate::base::storage::Storage;
|
use crate::base::storage::Storage;
|
||||||
use crate::base::{
|
use crate::base::{
|
||||||
DefaultAllocator, Hessenberg, OMatrix, OVector, SquareMatrix, Unit, Vector2, Vector3,
|
DefaultAllocator, Hessenberg, OMatrix, OVector, SquareMatrix, Unit, Vector2, Vector3,
|
||||||
|
@ -52,8 +52,8 @@ where
|
||||||
|
|
||||||
impl<T: ComplexField, D: Dim> Eigen<T, D>
|
impl<T: ComplexField, D: Dim> Eigen<T, D>
|
||||||
where
|
where
|
||||||
D: DimSub<U1>, // For Hessenberg.
|
D: DimSub<U1>, // For Hessenberg.
|
||||||
ShapeConstraint: DimEq<Dynamic, DimDiff<D, U1>>, // For Hessenberg.
|
ShapeConstraint: DimEq<Dyn, DimDiff<D, U1>>, // For Hessenberg.
|
||||||
DefaultAllocator: Allocator<T, D, DimDiff<D, U1>>
|
DefaultAllocator: Allocator<T, D, DimDiff<D, U1>>
|
||||||
+ Allocator<T, DimDiff<D, U1>>
|
+ Allocator<T, DimDiff<D, U1>>
|
||||||
+ Allocator<T, D, D>
|
+ Allocator<T, D, D>
|
||||||
|
|
|
@ -64,7 +64,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..min_nrows_ncols.value() {
|
for i in 0..min_nrows_ncols.value() {
|
||||||
let piv = matrix.slice_range(i.., i..).icamax_full();
|
let piv = matrix.view_range(i.., i..).icamax_full();
|
||||||
let row_piv = piv.0 + i;
|
let row_piv = piv.0 + i;
|
||||||
let col_piv = piv.1 + i;
|
let col_piv = piv.1 + i;
|
||||||
let diag = matrix[(row_piv, col_piv)].clone();
|
let diag = matrix[(row_piv, col_piv)].clone();
|
||||||
|
|
|
@ -113,7 +113,7 @@ where
|
||||||
let dim = self.hess.nrows();
|
let dim = self.hess.nrows();
|
||||||
self.hess.fill_lower_triangle(T::zero(), 2);
|
self.hess.fill_lower_triangle(T::zero(), 2);
|
||||||
self.hess
|
self.hess
|
||||||
.slice_mut((1, 0), (dim - 1, dim - 1))
|
.view_mut((1, 0), (dim - 1, dim - 1))
|
||||||
.set_partial_diagonal(
|
.set_partial_diagonal(
|
||||||
self.subdiag
|
self.subdiag
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -132,7 +132,7 @@ where
|
||||||
let dim = self.hess.nrows();
|
let dim = self.hess.nrows();
|
||||||
let mut res = self.hess.clone();
|
let mut res = self.hess.clone();
|
||||||
res.fill_lower_triangle(T::zero(), 2);
|
res.fill_lower_triangle(T::zero(), 2);
|
||||||
res.slice_mut((1, 0), (dim - 1, dim - 1))
|
res.view_mut((1, 0), (dim - 1, dim - 1))
|
||||||
.set_partial_diagonal(
|
.set_partial_diagonal(
|
||||||
self.subdiag
|
self.subdiag
|
||||||
.iter()
|
.iter()
|
||||||
|
|
|
@ -128,10 +128,10 @@ where
|
||||||
let mut res = OMatrix::identity_generic(dim, dim);
|
let mut res = OMatrix::identity_generic(dim, dim);
|
||||||
|
|
||||||
for i in (0..dim.value() - 1).rev() {
|
for i in (0..dim.value() - 1).rev() {
|
||||||
let axis = m.slice_range(i + 1.., i);
|
let axis = m.view_range(i + 1.., i);
|
||||||
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
||||||
|
|
||||||
let mut res_rows = res.slice_range_mut(i + 1.., i..);
|
let mut res_rows = res.view_range_mut(i + 1.., i..);
|
||||||
refl.reflect_with_sign(&mut res_rows, signs[i].clone().signum());
|
refl.reflect_with_sign(&mut res_rows, signs[i].clone().signum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,11 @@ use crate::base::{DefaultAllocator, OMatrix, SquareMatrix};
|
||||||
use crate::linalg::lu;
|
use crate::linalg::lu;
|
||||||
|
|
||||||
impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
/// Attempts to invert this matrix.
|
/// Attempts to invert this square matrix.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if `self` isn’t a square matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use = "Did you mean to use try_inverse_mut()?"]
|
#[must_use = "Did you mean to use try_inverse_mut()?"]
|
||||||
pub fn try_inverse(self) -> Option<OMatrix<T, D, D>>
|
pub fn try_inverse(self) -> Option<OMatrix<T, D, D>>
|
||||||
|
@ -25,8 +29,12 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ComplexField, D: Dim, S: StorageMut<T, D, D>> SquareMatrix<T, D, S> {
|
impl<T: ComplexField, D: Dim, S: StorageMut<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
/// Attempts to invert this matrix in-place. Returns `false` and leaves `self` untouched if
|
/// Attempts to invert this square matrix in-place. Returns `false` and leaves `self` untouched if
|
||||||
/// inversion fails.
|
/// inversion fails.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// Panics if `self` isn’t a square matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_inverse_mut(&mut self) -> bool
|
pub fn try_inverse_mut(&mut self) -> bool
|
||||||
where
|
where
|
||||||
|
|
|
@ -64,7 +64,7 @@ where
|
||||||
out.fill_with_identity();
|
out.fill_with_identity();
|
||||||
|
|
||||||
for i in 0..dim {
|
for i in 0..dim {
|
||||||
let piv = matrix.slice_range(i.., i).icamax() + i;
|
let piv = matrix.view_range(i.., i).icamax() + i;
|
||||||
let diag = matrix[(piv, i)].clone();
|
let diag = matrix[(piv, i)].clone();
|
||||||
|
|
||||||
if diag.is_zero() {
|
if diag.is_zero() {
|
||||||
|
@ -100,7 +100,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 0..min_nrows_ncols.value() {
|
for i in 0..min_nrows_ncols.value() {
|
||||||
let piv = matrix.slice_range(i.., i).icamax() + i;
|
let piv = matrix.view_range(i.., i).icamax() + i;
|
||||||
let diag = matrix[(piv, i)].clone();
|
let diag = matrix[(piv, i)].clone();
|
||||||
|
|
||||||
if diag.is_zero() {
|
if diag.is_zero() {
|
||||||
|
@ -338,7 +338,7 @@ where
|
||||||
T: Scalar + Field,
|
T: Scalar + Field,
|
||||||
S: StorageMut<T, R, C>,
|
S: StorageMut<T, R, C>,
|
||||||
{
|
{
|
||||||
let mut submat = matrix.slice_range_mut(i.., i..);
|
let mut submat = matrix.view_range_mut(i.., i..);
|
||||||
|
|
||||||
let inv_diag = T::one() / diag;
|
let inv_diag = T::one() / diag;
|
||||||
|
|
||||||
|
@ -368,7 +368,7 @@ pub fn gauss_step_swap<T, R: Dim, C: Dim, S>(
|
||||||
S: StorageMut<T, R, C>,
|
S: StorageMut<T, R, C>,
|
||||||
{
|
{
|
||||||
let piv = piv - i;
|
let piv = piv - i;
|
||||||
let mut submat = matrix.slice_range_mut(i.., i..);
|
let mut submat = matrix.view_range_mut(i.., i..);
|
||||||
|
|
||||||
let inv_diag = T::one() / diag;
|
let inv_diag = T::one() / diag;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ use simba::scalar::ClosedNeg;
|
||||||
use crate::allocator::Allocator;
|
use crate::allocator::Allocator;
|
||||||
use crate::base::{DefaultAllocator, Matrix, OVector, Scalar};
|
use crate::base::{DefaultAllocator, Matrix, OVector, Scalar};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
use crate::dimension::Dynamic;
|
use crate::dimension::Dyn;
|
||||||
use crate::dimension::{Const, Dim, DimName};
|
use crate::dimension::{Const, Dim, DimName};
|
||||||
use crate::storage::StorageMut;
|
use crate::storage::StorageMut;
|
||||||
|
|
||||||
|
@ -51,14 +51,14 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl PermutationSequence<Dynamic>
|
impl PermutationSequence<Dyn>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<(usize, usize), Dynamic>,
|
DefaultAllocator: Allocator<(usize, usize), Dyn>,
|
||||||
{
|
{
|
||||||
/// Creates a new dynamically-allocated sequence of `n` identity permutations.
|
/// Creates a new dynamically-allocated sequence of `n` identity permutations.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn identity(n: usize) -> Self {
|
pub fn identity(n: usize) -> Self {
|
||||||
Self::identity_generic(Dynamic::new(n))
|
Self::identity_generic(Dyn(n))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -116,11 +116,11 @@ where
|
||||||
let dim = self.diag.len();
|
let dim = self.diag.len();
|
||||||
|
|
||||||
for i in (0..dim).rev() {
|
for i in (0..dim).rev() {
|
||||||
let axis = self.qr.slice_range(i.., i);
|
let axis = self.qr.view_range(i.., i);
|
||||||
// TODO: sometimes, the axis might have a zero magnitude.
|
// TODO: sometimes, the axis might have a zero magnitude.
|
||||||
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
||||||
|
|
||||||
let mut res_rows = res.slice_range_mut(i.., i..);
|
let mut res_rows = res.view_range_mut(i.., i..);
|
||||||
refl.reflect_with_sign(&mut res_rows, self.diag[i].clone().signum());
|
refl.reflect_with_sign(&mut res_rows, self.diag[i].clone().signum());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ where
|
||||||
let dim = self.diag.len();
|
let dim = self.diag.len();
|
||||||
|
|
||||||
for i in 0..dim {
|
for i in 0..dim {
|
||||||
let axis = self.qr.slice_range(i.., i);
|
let axis = self.qr.view_range(i.., i);
|
||||||
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
let refl = Reflection::new(Unit::new_unchecked(axis), T::zero());
|
||||||
|
|
||||||
let mut rhs_rows = rhs.rows_range_mut(i..);
|
let mut rhs_rows = rhs.rows_range_mut(i..);
|
||||||
|
@ -247,7 +247,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
b.rows_range_mut(..i)
|
b.rows_range_mut(..i)
|
||||||
.axpy(-coeff, &self.qr.slice_range(..i, i), T::one());
|
.axpy(-coeff, &self.qr.view_range(..i, i), T::one());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use simba::scalar::{ComplexField, RealField};
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
use crate::allocator::Allocator;
|
use crate::allocator::Allocator;
|
||||||
use crate::base::dimension::{Const, Dim, DimDiff, DimSub, Dynamic, U1, U2};
|
use crate::base::dimension::{Const, Dim, DimDiff, DimSub, Dyn, U1, U2};
|
||||||
use crate::base::storage::Storage;
|
use crate::base::storage::Storage;
|
||||||
use crate::base::{DefaultAllocator, OMatrix, OVector, SquareMatrix, Unit, Vector2, Vector3};
|
use crate::base::{DefaultAllocator, OMatrix, OVector, SquareMatrix, Unit, Vector2, Vector3};
|
||||||
|
|
||||||
|
@ -174,19 +174,18 @@ where
|
||||||
{
|
{
|
||||||
let krows = cmp::min(k + 4, end + 1);
|
let krows = cmp::min(k + 4, end + 1);
|
||||||
let mut work = work.rows_mut(0, krows);
|
let mut work = work.rows_mut(0, krows);
|
||||||
refl.reflect(&mut t.generic_slice_mut(
|
refl.reflect(
|
||||||
(k, k),
|
&mut t.generic_view_mut((k, k), (Const::<3>, Dyn(dim.value() - k))),
|
||||||
(Const::<3>, Dynamic::new(dim.value() - k)),
|
);
|
||||||
));
|
|
||||||
refl.reflect_rows(
|
refl.reflect_rows(
|
||||||
&mut t.generic_slice_mut((0, k), (Dynamic::new(krows), Const::<3>)),
|
&mut t.generic_view_mut((0, k), (Dyn(krows), Const::<3>)),
|
||||||
&mut work,
|
&mut work,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref mut q) = q {
|
if let Some(ref mut q) = q {
|
||||||
refl.reflect_rows(
|
refl.reflect_rows(
|
||||||
&mut q.generic_slice_mut((0, k), (dim, Const::<3>)),
|
&mut q.generic_view_mut((0, k), (dim, Const::<3>)),
|
||||||
work,
|
work,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -211,38 +210,36 @@ where
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut work = work.rows_mut(0, end + 1);
|
let mut work = work.rows_mut(0, end + 1);
|
||||||
refl.reflect(&mut t.generic_slice_mut(
|
refl.reflect(
|
||||||
(m, m),
|
&mut t.generic_view_mut((m, m), (Const::<2>, Dyn(dim.value() - m))),
|
||||||
(Const::<2>, Dynamic::new(dim.value() - m)),
|
);
|
||||||
));
|
|
||||||
refl.reflect_rows(
|
refl.reflect_rows(
|
||||||
&mut t.generic_slice_mut((0, m), (Dynamic::new(end + 1), Const::<2>)),
|
&mut t.generic_view_mut((0, m), (Dyn(end + 1), Const::<2>)),
|
||||||
&mut work,
|
&mut work,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref mut q) = q {
|
if let Some(ref mut q) = q {
|
||||||
refl.reflect_rows(
|
refl.reflect_rows(&mut q.generic_view_mut((0, m), (dim, Const::<2>)), work);
|
||||||
&mut q.generic_slice_mut((0, m), (dim, Const::<2>)),
|
|
||||||
work,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Decouple the 2x2 block if it has real eigenvalues.
|
// Decouple the 2x2 block if it has real eigenvalues.
|
||||||
if let Some(rot) = compute_2x2_basis(&t.fixed_slice::<2, 2>(start, start)) {
|
if let Some(rot) = compute_2x2_basis(&t.fixed_view::<2, 2>(start, start)) {
|
||||||
let inv_rot = rot.inverse();
|
let inv_rot = rot.inverse();
|
||||||
inv_rot.rotate(&mut t.generic_slice_mut(
|
inv_rot.rotate(
|
||||||
(start, start),
|
&mut t.generic_view_mut(
|
||||||
(Const::<2>, Dynamic::new(dim.value() - start)),
|
(start, start),
|
||||||
));
|
(Const::<2>, Dyn(dim.value() - start)),
|
||||||
|
),
|
||||||
|
);
|
||||||
rot.rotate_rows(
|
rot.rotate_rows(
|
||||||
&mut t.generic_slice_mut((0, start), (Dynamic::new(end + 1), Const::<2>)),
|
&mut t.generic_view_mut((0, start), (Dyn(end + 1), Const::<2>)),
|
||||||
);
|
);
|
||||||
t[(end, start)] = T::zero();
|
t[(end, start)] = T::zero();
|
||||||
|
|
||||||
if let Some(ref mut q) = q {
|
if let Some(ref mut q) = q {
|
||||||
rot.rotate_rows(&mut q.generic_slice_mut((0, start), (dim, Const::<2>)));
|
rot.rotate_rows(&mut q.generic_view_mut((0, start), (dim, Const::<2>)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,9 +424,9 @@ where
|
||||||
{
|
{
|
||||||
let dim = m.shape_generic().0;
|
let dim = m.shape_generic().0;
|
||||||
let mut q = None;
|
let mut q = None;
|
||||||
match compute_2x2_basis(&m.fixed_slice::<2, 2>(0, 0)) {
|
match compute_2x2_basis(&m.fixed_view::<2, 2>(0, 0)) {
|
||||||
Some(rot) => {
|
Some(rot) => {
|
||||||
let mut m = m.fixed_slice_mut::<2, 2>(0, 0);
|
let mut m = m.fixed_view_mut::<2, 2>(0, 0);
|
||||||
let inv_rot = rot.inverse();
|
let inv_rot = rot.inverse();
|
||||||
inv_rot.rotate(&mut m);
|
inv_rot.rotate(&mut m);
|
||||||
rot.rotate_rows(&mut m);
|
rot.rotate_rows(&mut m);
|
||||||
|
@ -530,7 +527,7 @@ where
|
||||||
if self.nrows() == 2 {
|
if self.nrows() == 2 {
|
||||||
// TODO: can we avoid this slicing
|
// TODO: can we avoid this slicing
|
||||||
// (which is needed here just to transform D to U2)?
|
// (which is needed here just to transform D to U2)?
|
||||||
let me = self.fixed_slice::<2, 2>(0, 0);
|
let me = self.fixed_view::<2, 2>(0, 0);
|
||||||
return match compute_2x2_eigvals(&me) {
|
return match compute_2x2_eigvals(&me) {
|
||||||
Some((a, b)) => {
|
Some((a, b)) => {
|
||||||
work[0] = a;
|
work[0] = a;
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::base::allocator::Allocator;
|
||||||
use crate::base::constraint::{SameNumberOfRows, ShapeConstraint};
|
use crate::base::constraint::{SameNumberOfRows, ShapeConstraint};
|
||||||
use crate::base::dimension::{Dim, U1};
|
use crate::base::dimension::{Dim, U1};
|
||||||
use crate::base::storage::{Storage, StorageMut};
|
use crate::base::storage::{Storage, StorageMut};
|
||||||
use crate::base::{DVectorSlice, DefaultAllocator, Matrix, OMatrix, SquareMatrix, Vector};
|
use crate::base::{DVectorView, DefaultAllocator, Matrix, OMatrix, SquareMatrix, Vector};
|
||||||
|
|
||||||
impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
/// Computes the solution of the linear system `self . x = b` where `x` is the unknown and only
|
/// Computes the solution of the linear system `self . x = b` where `x` is the unknown and only
|
||||||
|
@ -93,7 +93,7 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
b.rows_range_mut(i + 1..)
|
b.rows_range_mut(i + 1..)
|
||||||
.axpy(-coeff, &self.slice_range(i + 1.., i), T::one());
|
.axpy(-coeff, &self.view_range(i + 1.., i), T::one());
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -125,7 +125,7 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
for i in 0..dim - 1 {
|
for i in 0..dim - 1 {
|
||||||
let coeff = unsafe { bcol.vget_unchecked(i).clone() } / diag.clone();
|
let coeff = unsafe { bcol.vget_unchecked(i).clone() } / diag.clone();
|
||||||
bcol.rows_range_mut(i + 1..)
|
bcol.rows_range_mut(i + 1..)
|
||||||
.axpy(-coeff, &self.slice_range(i + 1.., i), T::one());
|
.axpy(-coeff, &self.view_range(i + 1.., i), T::one());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
b.rows_range_mut(..i)
|
b.rows_range_mut(..i)
|
||||||
.axpy(-coeff, &self.slice_range(..i, i), T::one());
|
.axpy(-coeff, &self.view_range(..i, i), T::one());
|
||||||
}
|
}
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -376,8 +376,8 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
b: &mut Vector<T, R2, S2>,
|
b: &mut Vector<T, R2, S2>,
|
||||||
conjugate: impl Fn(T) -> T,
|
conjugate: impl Fn(T) -> T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
&DVectorView<'_, T, S::RStride, S::CStride>,
|
||||||
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
&DVectorView<'_, T, S2::RStride, S2::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) -> bool
|
) -> bool
|
||||||
where
|
where
|
||||||
|
@ -387,7 +387,7 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
let dim = self.nrows();
|
let dim = self.nrows();
|
||||||
|
|
||||||
for i in (0..dim).rev() {
|
for i in (0..dim).rev() {
|
||||||
let dot = dot(&self.slice_range(i + 1.., i), &b.slice_range(i + 1.., 0));
|
let dot = dot(&self.view_range(i + 1.., i), &b.view_range(i + 1.., 0));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let b_i = b.vget_unchecked_mut(i);
|
let b_i = b.vget_unchecked_mut(i);
|
||||||
|
@ -411,8 +411,8 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
b: &mut Vector<T, R2, S2>,
|
b: &mut Vector<T, R2, S2>,
|
||||||
conjugate: impl Fn(T) -> T,
|
conjugate: impl Fn(T) -> T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
&DVectorView<'_, T, S::RStride, S::CStride>,
|
||||||
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
&DVectorView<'_, T, S2::RStride, S2::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) -> bool
|
) -> bool
|
||||||
where
|
where
|
||||||
|
@ -422,7 +422,7 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
let dim = self.nrows();
|
let dim = self.nrows();
|
||||||
|
|
||||||
for i in 0..dim {
|
for i in 0..dim {
|
||||||
let dot = dot(&self.slice_range(..i, i), &b.slice_range(..i, 0));
|
let dot = dot(&self.view_range(..i, i), &b.view_range(..i, 0));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let b_i = b.vget_unchecked_mut(i);
|
let b_i = b.vget_unchecked_mut(i);
|
||||||
|
@ -514,7 +514,7 @@ impl<T: SimdComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
b.rows_range_mut(i + 1..)
|
b.rows_range_mut(i + 1..)
|
||||||
.axpy(-coeff.clone(), &self.slice_range(i + 1.., i), T::one());
|
.axpy(-coeff.clone(), &self.view_range(i + 1.., i), T::one());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ impl<T: SimdComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
for i in 0..dim - 1 {
|
for i in 0..dim - 1 {
|
||||||
let coeff = unsafe { bcol.vget_unchecked(i).clone() } / diag.clone();
|
let coeff = unsafe { bcol.vget_unchecked(i).clone() } / diag.clone();
|
||||||
bcol.rows_range_mut(i + 1..)
|
bcol.rows_range_mut(i + 1..)
|
||||||
.axpy(-coeff, &self.slice_range(i + 1.., i), T::one());
|
.axpy(-coeff, &self.view_range(i + 1.., i), T::one());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -575,7 +575,7 @@ impl<T: SimdComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
}
|
}
|
||||||
|
|
||||||
b.rows_range_mut(..i)
|
b.rows_range_mut(..i)
|
||||||
.axpy(-coeff, &self.slice_range(..i, i), T::one());
|
.axpy(-coeff, &self.view_range(..i, i), T::one());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -734,8 +734,8 @@ impl<T: SimdComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
b: &mut Vector<T, R2, S2>,
|
b: &mut Vector<T, R2, S2>,
|
||||||
conjugate: impl Fn(T) -> T,
|
conjugate: impl Fn(T) -> T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
&DVectorView<'_, T, S::RStride, S::CStride>,
|
||||||
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
&DVectorView<'_, T, S2::RStride, S2::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) where
|
) where
|
||||||
S2: StorageMut<T, R2, U1>,
|
S2: StorageMut<T, R2, U1>,
|
||||||
|
@ -744,7 +744,7 @@ impl<T: SimdComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
let dim = self.nrows();
|
let dim = self.nrows();
|
||||||
|
|
||||||
for i in (0..dim).rev() {
|
for i in (0..dim).rev() {
|
||||||
let dot = dot(&self.slice_range(i + 1.., i), &b.slice_range(i + 1.., 0));
|
let dot = dot(&self.view_range(i + 1.., i), &b.view_range(i + 1.., 0));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let b_i = b.vget_unchecked_mut(i);
|
let b_i = b.vget_unchecked_mut(i);
|
||||||
|
@ -760,15 +760,15 @@ impl<T: SimdComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||||
b: &mut Vector<T, R2, S2>,
|
b: &mut Vector<T, R2, S2>,
|
||||||
conjugate: impl Fn(T) -> T,
|
conjugate: impl Fn(T) -> T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
&DVectorView<'_, T, S::RStride, S::CStride>,
|
||||||
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
&DVectorView<'_, T, S2::RStride, S2::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) where
|
) where
|
||||||
S2: StorageMut<T, R2, U1>,
|
S2: StorageMut<T, R2, U1>,
|
||||||
ShapeConstraint: SameNumberOfRows<R2, D>,
|
ShapeConstraint: SameNumberOfRows<R2, D>,
|
||||||
{
|
{
|
||||||
for i in 0..self.nrows() {
|
for i in 0..self.nrows() {
|
||||||
let dot = dot(&self.slice_range(..i, i), &b.slice_range(..i, 0));
|
let dot = dot(&self.view_range(..i, i), &b.view_range(..i, 0));
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let b_i = b.vget_unchecked_mut(i);
|
let b_i = b.vget_unchecked_mut(i);
|
||||||
|
|
|
@ -53,11 +53,11 @@
|
||||||
//! with [matrix](fn.matrix.html) as follows:
|
//! with [matrix](fn.matrix.html) as follows:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use nalgebra::{Dynamic, OMatrix, Const};
|
//! use nalgebra::{Dyn, OMatrix, Const};
|
||||||
//! use nalgebra::proptest::matrix;
|
//! use nalgebra::proptest::matrix;
|
||||||
//! use proptest::prelude::*;
|
//! use proptest::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! type MyMatrix = OMatrix<i32, Const::<3>, Dynamic>;
|
//! type MyMatrix = OMatrix<i32, Const::<3>, Dyn>;
|
||||||
//!
|
//!
|
||||||
//! /// Returns a strategy for pairs of matrices with `U3` rows and the same number of
|
//! /// Returns a strategy for pairs of matrices with `U3` rows and the same number of
|
||||||
//! /// columns.
|
//! /// columns.
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
//! If you don't care about the dimensions of matrices, you can write tests like these:
|
//! If you don't care about the dimensions of matrices, you can write tests like these:
|
||||||
//!
|
//!
|
||||||
//! ```
|
//! ```
|
||||||
//! use nalgebra::{DMatrix, DVector, Dynamic, Matrix3, OMatrix, Vector3, U3};
|
//! use nalgebra::{DMatrix, DVector, Dyn, Matrix3, OMatrix, Vector3, U3};
|
||||||
//! use proptest::prelude::*;
|
//! use proptest::prelude::*;
|
||||||
//!
|
//!
|
||||||
//! proptest! {
|
//! proptest! {
|
||||||
|
@ -108,7 +108,7 @@
|
||||||
//! # /*
|
//! # /*
|
||||||
//! #[test]
|
//! #[test]
|
||||||
//! # */
|
//! # */
|
||||||
//! fn test_static_and_mixed(matrix: Matrix3<i32>, matrix2: OMatrix<i32, U3, Dynamic>) {
|
//! fn test_static_and_mixed(matrix: Matrix3<i32>, matrix2: OMatrix<i32, U3, Dyn>) {
|
||||||
//! // Test some property involving these matrices
|
//! // Test some property involving these matrices
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
//! PROPTEST_MAX_SHRINK_ITERS=100000 cargo test my_failing_test
|
//! PROPTEST_MAX_SHRINK_ITERS=100000 cargo test my_failing_test
|
||||||
//! ```
|
//! ```
|
||||||
use crate::allocator::Allocator;
|
use crate::allocator::Allocator;
|
||||||
use crate::{Const, DefaultAllocator, Dim, DimName, Dynamic, OMatrix, Scalar, U1};
|
use crate::{Const, DefaultAllocator, Dim, DimName, Dyn, OMatrix, Scalar, U1};
|
||||||
use proptest::arbitrary::Arbitrary;
|
use proptest::arbitrary::Arbitrary;
|
||||||
use proptest::collection::vec;
|
use proptest::collection::vec;
|
||||||
use proptest::strategy::{BoxedStrategy, Just, NewTree, Strategy, ValueTree};
|
use proptest::strategy::{BoxedStrategy, Just, NewTree, Strategy, ValueTree};
|
||||||
|
@ -167,9 +167,9 @@ pub struct MatrixParameters<NParameters, R, C> {
|
||||||
/// of matrices with `proptest`. In most cases, you do not need to concern yourself with
|
/// of matrices with `proptest`. In most cases, you do not need to concern yourself with
|
||||||
/// `DimRange` directly, as it supports conversion from other types such as `U3` or inclusive
|
/// `DimRange` directly, as it supports conversion from other types such as `U3` or inclusive
|
||||||
/// ranges such as `5 ..= 6`. The latter example corresponds to dimensions from (inclusive)
|
/// ranges such as `5 ..= 6`. The latter example corresponds to dimensions from (inclusive)
|
||||||
/// `Dynamic::new(5)` to `Dynamic::new(6)` (inclusive).
|
/// `Dyn(5)` to `Dyn(6)` (inclusive).
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct DimRange<D = Dynamic>(RangeInclusive<D>);
|
pub struct DimRange<D = Dyn>(RangeInclusive<D>);
|
||||||
|
|
||||||
impl<D: Dim> DimRange<D> {
|
impl<D: Dim> DimRange<D> {
|
||||||
/// The lower bound for dimensions generated.
|
/// The lower bound for dimensions generated.
|
||||||
|
@ -195,9 +195,9 @@ impl<D: Dim> From<RangeInclusive<D>> for DimRange<D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RangeInclusive<usize>> for DimRange<Dynamic> {
|
impl From<RangeInclusive<usize>> for DimRange<Dyn> {
|
||||||
fn from(range: RangeInclusive<usize>) -> Self {
|
fn from(range: RangeInclusive<usize>) -> Self {
|
||||||
DimRange::from(Dynamic::new(*range.start())..=Dynamic::new(*range.end()))
|
DimRange::from(Dyn(*range.start())..=Dyn(*range.end()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,14 +208,14 @@ impl<D: Dim> DimRange<D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<usize> for DimRange<Dynamic> {
|
impl From<usize> for DimRange<Dyn> {
|
||||||
fn from(dim: usize) -> Self {
|
fn from(dim: usize) -> Self {
|
||||||
DimRange::from(Dynamic::new(dim))
|
DimRange::from(Dyn(dim))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The default range used for Dynamic dimensions when generating arbitrary matrices.
|
/// The default range used for Dyn dimensions when generating arbitrary matrices.
|
||||||
fn dynamic_dim_range() -> DimRange<Dynamic> {
|
fn dynamic_dim_range() -> DimRange<Dyn> {
|
||||||
DimRange::from(0..=6)
|
DimRange::from(0..=6)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ fn dynamic_dim_range() -> DimRange<Dynamic> {
|
||||||
/// ## Examples
|
/// ## Examples
|
||||||
/// ```
|
/// ```
|
||||||
/// use nalgebra::proptest::matrix;
|
/// use nalgebra::proptest::matrix;
|
||||||
/// use nalgebra::{OMatrix, Const, Dynamic};
|
/// use nalgebra::{OMatrix, Const, Dyn};
|
||||||
/// use proptest::prelude::*;
|
/// use proptest::prelude::*;
|
||||||
///
|
///
|
||||||
/// proptest! {
|
/// proptest! {
|
||||||
|
@ -234,7 +234,7 @@ fn dynamic_dim_range() -> DimRange<Dynamic> {
|
||||||
/// # */
|
/// # */
|
||||||
/// fn my_test(a in matrix(0 .. 5i32, Const::<3>, 0 ..= 5)) {
|
/// fn my_test(a in matrix(0 .. 5i32, Const::<3>, 0 ..= 5)) {
|
||||||
/// // Let's make sure we've got the correct type first
|
/// // Let's make sure we've got the correct type first
|
||||||
/// let a: OMatrix<_, Const::<3>, Dynamic> = a;
|
/// let a: OMatrix<_, Const::<3>, Dyn> = a;
|
||||||
/// prop_assert!(a.nrows() == 3);
|
/// prop_assert!(a.nrows() == 3);
|
||||||
/// prop_assert!(a.ncols() <= 5);
|
/// prop_assert!(a.ncols() <= 5);
|
||||||
/// prop_assert!(a.iter().all(|x_ij| *x_ij >= 0 && *x_ij < 5));
|
/// prop_assert!(a.iter().all(|x_ij| *x_ij >= 0 && *x_ij < 5));
|
||||||
|
@ -347,7 +347,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<NParameters, R> Default for MatrixParameters<NParameters, R, Dynamic>
|
impl<NParameters, R> Default for MatrixParameters<NParameters, R, Dyn>
|
||||||
where
|
where
|
||||||
NParameters: Default,
|
NParameters: Default,
|
||||||
R: DimName,
|
R: DimName,
|
||||||
|
@ -361,7 +361,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<NParameters, C> Default for MatrixParameters<NParameters, Dynamic, C>
|
impl<NParameters, C> Default for MatrixParameters<NParameters, Dyn, C>
|
||||||
where
|
where
|
||||||
NParameters: Default,
|
NParameters: Default,
|
||||||
C: DimName,
|
C: DimName,
|
||||||
|
@ -375,7 +375,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<NParameters> Default for MatrixParameters<NParameters, Dynamic, Dynamic>
|
impl<NParameters> Default for MatrixParameters<NParameters, Dyn, Dyn>
|
||||||
where
|
where
|
||||||
NParameters: Default,
|
NParameters: Default,
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::slice;
|
||||||
|
|
||||||
use crate::allocator::Allocator;
|
use crate::allocator::Allocator;
|
||||||
use crate::sparse::cs_utils;
|
use crate::sparse::cs_utils;
|
||||||
use crate::{Const, DefaultAllocator, Dim, Dynamic, Matrix, OVector, Scalar, Vector, U1};
|
use crate::{Const, DefaultAllocator, Dim, Dyn, Matrix, OVector, Scalar, Vector, U1};
|
||||||
|
|
||||||
pub struct ColumnEntries<'a, T> {
|
pub struct ColumnEntries<'a, T> {
|
||||||
curr: usize,
|
curr: usize,
|
||||||
|
@ -236,16 +236,16 @@ impl<T: Scalar, R: Dim, C: Dim> CsStorageMut<T, R, C> for CsVecStorage<T, R, C>
|
||||||
pub struct CsSliceStorage<'a, T: Scalar, R: Dim, C: DimAdd<U1>> {
|
pub struct CsSliceStorage<'a, T: Scalar, R: Dim, C: DimAdd<U1>> {
|
||||||
shape: (R, C),
|
shape: (R, C),
|
||||||
p: VectorSlice<usize, DimSum<C, U1>>,
|
p: VectorSlice<usize, DimSum<C, U1>>,
|
||||||
i: VectorSlice<usize, Dynamic>,
|
i: VectorSlice<usize, Dyn>,
|
||||||
vals: VectorSlice<T, Dynamic>,
|
vals: VectorSlice<T, Dyn>,
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
/// A compressed sparse column matrix.
|
/// A compressed sparse column matrix.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct CsMatrix<
|
pub struct CsMatrix<
|
||||||
T: Scalar,
|
T: Scalar,
|
||||||
R: Dim = Dynamic,
|
R: Dim = Dyn,
|
||||||
C: Dim = Dynamic,
|
C: Dim = Dyn,
|
||||||
S: CsStorage<T, R, C> = CsVecStorage<T, R, C>,
|
S: CsStorage<T, R, C> = CsVecStorage<T, R, C>,
|
||||||
> {
|
> {
|
||||||
pub(crate) data: S,
|
pub(crate) data: S,
|
||||||
|
@ -253,7 +253,7 @@ pub struct CsMatrix<
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A column compressed sparse vector.
|
/// A column compressed sparse vector.
|
||||||
pub type CsVector<T, R = Dynamic, S = CsVecStorage<T, R, U1>> = CsMatrix<T, R, U1, S>;
|
pub type CsVector<T, R = Dyn, S = CsVecStorage<T, R, U1>> = CsMatrix<T, R, U1, S>;
|
||||||
|
|
||||||
impl<T: Scalar, R: Dim, C: Dim> CsMatrix<T, R, C>
|
impl<T: Scalar, R: Dim, C: Dim> CsMatrix<T, R, C>
|
||||||
where
|
where
|
||||||
|
@ -342,8 +342,8 @@ impl<T: Scalar + Zero + ClosedAdd> CsMatrix<T> {
|
||||||
vals: Vec<T>,
|
vals: Vec<T>,
|
||||||
) -> Self
|
) -> Self
|
||||||
{
|
{
|
||||||
let nrows = Dynamic::new(nrows);
|
let nrows = Dyn(nrows);
|
||||||
let ncols = Dynamic::new(ncols);
|
let ncols = Dyn(ncols);
|
||||||
let p = DVector::from_data(VecStorage::new(ncols, U1, p));
|
let p = DVector::from_data(VecStorage::new(ncols, U1, p));
|
||||||
Self::from_parts_generic(nrows, ncols, p, i, vals)
|
Self::from_parts_generic(nrows, ncols, p, i, vals)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::allocator::Allocator;
|
||||||
use crate::sparse::cs_utils;
|
use crate::sparse::cs_utils;
|
||||||
use crate::sparse::{CsMatrix, CsStorage};
|
use crate::sparse::{CsMatrix, CsStorage};
|
||||||
use crate::storage::Storage;
|
use crate::storage::Storage;
|
||||||
use crate::{DefaultAllocator, Dim, Dynamic, Matrix, OMatrix, Scalar};
|
use crate::{DefaultAllocator, Dim, Dyn, Matrix, OMatrix, Scalar};
|
||||||
|
|
||||||
impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix<T> {
|
impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix<T> {
|
||||||
/// Creates a column-compressed sparse matrix from a sparse matrix in triplet form.
|
/// Creates a column-compressed sparse matrix from a sparse matrix in triplet form.
|
||||||
|
@ -16,7 +16,7 @@ impl<'a, T: Scalar + Zero + ClosedAdd> CsMatrix<T> {
|
||||||
icols: &[usize],
|
icols: &[usize],
|
||||||
vals: &[T],
|
vals: &[T],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self::from_triplet_generic(Dynamic::new(nrows), Dynamic::new(ncols), irows, icols, vals)
|
Self::from_triplet_generic(Dyn(nrows), Dyn(ncols), irows, icols, vals)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,3 +14,5 @@ mod v019;
|
||||||
mod v020;
|
mod v020;
|
||||||
#[cfg(feature = "glam021")]
|
#[cfg(feature = "glam021")]
|
||||||
mod v021;
|
mod v021;
|
||||||
|
#[cfg(feature = "glam022")]
|
||||||
|
mod v022;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue