forked from M-Labs/nalgebra
Merge branch 'dev' into dev-zyanshep
This commit is contained in:
commit
cce66c3abf
8
.github/workflows/nalgebra-ci-build.yml
vendored
8
.github/workflows/nalgebra-ci-build.yml
vendored
@ -61,7 +61,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- 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;
|
||||
test-nalgebra-glm:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@ -137,3 +137,9 @@ jobs:
|
||||
- run: cargo build --no-default-features --features cuda --target=nvptx64-nvidia-cuda
|
||||
env:
|
||||
CUDA_ARCH: "350"
|
||||
docs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Generate documentation
|
||||
run: cargo doc
|
||||
|
40
CHANGELOG.md
40
CHANGELOG.md
@ -4,6 +4,46 @@ documented here.
|
||||
|
||||
This project adheres to [Semantic Versioning](https://semver.org/).
|
||||
|
||||
|
||||
## [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)
|
||||
|
||||
### Modified
|
||||
- Use `#[inline]` on the `Dim` implementation for `Const` to improve opt-level 1 performance.
|
||||
- Make the `Point::new` constructions const-fn.
|
||||
|
||||
### Added
|
||||
- Add `UnitVector::cast` to change the underlying scalar type.
|
||||
|
||||
|
||||
## [0.31.1] (31 July 2022)
|
||||
|
||||
### Modified
|
||||
- Improve performances of multiplication of two sparse matrices.
|
||||
|
||||
### Added
|
||||
- Add `Matrix::from_row_iterator` to build a matrix from an iterator yielding components in row-major order.
|
||||
- Add support for conversion from/to types of `glam` 0.21.
|
||||
- `nalgebra-sparse`: add support for the matrix-market export of sparse matrices.
|
||||
- `nalgebra-lapack`: add a `GE` for solving the generalized eigenvalues problem.
|
||||
|
||||
### Fixed
|
||||
- Fix `Rotation3::from_matrix` and `UnitQuaternion::from_matrix` when the input matrix is already a valid
|
||||
rotation matrix.
|
||||
|
||||
## [0.31.0] (30 Apr. 2022)
|
||||
|
||||
### Breaking changes
|
||||
|
11
Cargo.toml
11
Cargo.toml
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "nalgebra"
|
||||
version = "0.31.0"
|
||||
version = "0.31.4"
|
||||
authors = [ "Sébastien Crozet <developer@crozet.re>" ]
|
||||
|
||||
description = "General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices."
|
||||
@ -44,6 +44,8 @@ convert-glam017 = [ "glam017" ]
|
||||
convert-glam018 = [ "glam018" ]
|
||||
convert-glam019 = [ "glam019" ]
|
||||
convert-glam020 = [ "glam020" ]
|
||||
convert-glam021 = [ "glam021" ]
|
||||
convert-glam022 = [ "glam022" ]
|
||||
|
||||
# Serialization
|
||||
## To use serde in a #[no-std] environment, enable the
|
||||
@ -65,6 +67,7 @@ rand = [ "rand-no-std", "rand-package/std", "rand-package/std_rng", "rand
|
||||
arbitrary = [ "quickcheck" ]
|
||||
proptest-support = [ "proptest" ]
|
||||
slow-tests = []
|
||||
rkyv-safe-deser = [ "rkyv-serialize", "rkyv/validation" ]
|
||||
|
||||
[dependencies]
|
||||
nalgebra-macros = { version = "0.1", path = "nalgebra-macros", optional = true }
|
||||
@ -96,6 +99,8 @@ glam017 = { package = "glam", version = "0.17", optional = true }
|
||||
glam018 = { package = "glam", version = "0.18", optional = true }
|
||||
glam019 = { package = "glam", version = "0.19", optional = true }
|
||||
glam020 = { package = "glam", version = "0.20", 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 }
|
||||
|
||||
|
||||
@ -131,8 +136,8 @@ required-features = ["rand"]
|
||||
lto = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
# Enable certain features when building docs for docs.rs
|
||||
features = [ "proptest-support", "compare", "macros", "rand" ]
|
||||
# Enable all the features when building the docs on docs.rs
|
||||
all-features = true
|
||||
|
||||
[patch.crates-io]
|
||||
num-complex = { git = "https://github.com/zyansheep/num-complex" }
|
@ -53,7 +53,7 @@ fn mat_div_scalar(b: &mut criterion::Criterion) {
|
||||
b.bench_function("mat_div_scalar", move |bh| {
|
||||
bh.iter(|| {
|
||||
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
|
||||
})
|
||||
});
|
||||
|
@ -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.
|
||||
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)
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ pub fn proj2d<T: Number>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ pub fn proj<T: Number>(m: &TMat4<T>, normal: &TVec3<T>) -> TMat4<T> {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ pub fn reflect2d<T: RealNumber>(m: &TMat3<T>, normal: &TVec2<T>) -> TMat3<T> {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ pub fn reflect<T: RealNumber>(m: &TMat4<T>, normal: &TVec3<T>) -> TMat4<T> {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "nalgebra-lapack"
|
||||
version = "0.22.0"
|
||||
version = "0.23.0"
|
||||
authors = [ "Sébastien Crozet <developer@crozet.re>", "Andrew Straw <strawman@astraw.com>" ]
|
||||
|
||||
description = "Matrix decompositions using nalgebra matrices and Lapack bindings."
|
||||
@ -44,3 +44,4 @@ proptest = { version = "1", default-features = false, features = ["std"] }
|
||||
quickcheck = "1"
|
||||
approx = "0.5"
|
||||
rand = "0.8"
|
||||
|
||||
|
@ -7,13 +7,12 @@ use num_complex::Complex;
|
||||
use simba::scalar::RealField;
|
||||
|
||||
use crate::ComplexHelper;
|
||||
use na::allocator::Allocator;
|
||||
use na::dimension::{Const, Dim};
|
||||
use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar};
|
||||
use na::{allocator::Allocator, DefaultAllocator, Matrix, OMatrix, OVector, Scalar};
|
||||
|
||||
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",
|
||||
@ -36,8 +35,10 @@ pub struct Eigen<T: Scalar, D: Dim>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
|
||||
{
|
||||
/// The eigenvalues of the decomposed matrix.
|
||||
pub eigenvalues: OVector<T, D>,
|
||||
/// The real parts of eigenvalues of the decomposed matrix.
|
||||
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.
|
||||
pub eigenvectors: Option<OMatrix<T, D, D>>,
|
||||
/// The left eigenvectors of the decomposed matrix.
|
||||
@ -69,8 +70,8 @@ where
|
||||
"Unable to compute the eigenvalue decomposition of a non-square matrix."
|
||||
);
|
||||
|
||||
let ljob = if left_eigenvectors { b'V' } else { b'T' };
|
||||
let rjob = if eigenvectors { b'V' } else { b'T' };
|
||||
let ljob = if left_eigenvectors { b'V' } else { b'N' };
|
||||
let rjob = if eigenvectors { b'V' } else { b'N' };
|
||||
|
||||
let (nrows, ncols) = m.shape_generic();
|
||||
let n = nrows.value();
|
||||
@ -104,213 +105,232 @@ where
|
||||
lapack_check!(info);
|
||||
|
||||
let mut work = vec![T::zero(); lwork as usize];
|
||||
|
||||
match (left_eigenvectors, eigenvectors) {
|
||||
(true, true) => {
|
||||
// TODO: avoid the initializations?
|
||||
let mut vl = Matrix::zeros_generic(nrows, ncols);
|
||||
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 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,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
};
|
||||
|
||||
/// 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];
|
||||
let vl_ref = vl
|
||||
.as_mut()
|
||||
.map(|m| m.as_mut_slice())
|
||||
.unwrap_or(&mut placeholder1);
|
||||
let vr_ref = vr
|
||||
.as_mut()
|
||||
.map(|m| m.as_mut_slice())
|
||||
.unwrap_or(&mut placeholder2);
|
||||
|
||||
T::xgeev(
|
||||
b'T',
|
||||
b'T',
|
||||
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,
|
||||
vl_ref,
|
||||
if left_eigenvectors { n as i32 } else { 1 },
|
||||
vr_ref,
|
||||
if eigenvectors { n as i32 } else { 1 },
|
||||
&mut work,
|
||||
lwork,
|
||||
&mut info,
|
||||
);
|
||||
lapack_panic!(info);
|
||||
lapack_check!(info);
|
||||
|
||||
let mut res = Matrix::zeros_generic(nrows, Const::<1>);
|
||||
|
||||
for i in 0..res.len() {
|
||||
res[i] = Complex::new(wr[i].clone(), wi[i].clone());
|
||||
Some(Self {
|
||||
eigenvalues_re: wr,
|
||||
eigenvalues_im: wi,
|
||||
left_eigenvectors: vl,
|
||||
eigenvectors: vr,
|
||||
})
|
||||
}
|
||||
|
||||
res
|
||||
/// Returns `true` if all the eigenvalues are real.
|
||||
pub fn eigenvalues_are_real(&self) -> bool {
|
||||
self.eigenvalues_im.iter().all(|e| e.is_zero())
|
||||
}
|
||||
|
||||
/// The determinant of the decomposed matrix.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn determinant(&self) -> T {
|
||||
let mut det = T::one();
|
||||
for e in self.eigenvalues.iter() {
|
||||
det *= e.clone();
|
||||
pub fn determinant(&self) -> Complex<T> {
|
||||
let mut det: Complex<T> = na::one();
|
||||
for (re, im) in self.eigenvalues_re.iter().zip(self.eigenvalues_im.iter()) {
|
||||
det *= Complex::new(re.clone(), im.clone());
|
||||
}
|
||||
|
||||
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
|
||||
.qr
|
||||
.generic_slice((0, 0), (nrows, min_nrows_ncols))
|
||||
.generic_view((0, 0), (nrows, min_nrows_ncols))
|
||||
.into_owned();
|
||||
|
||||
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 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));
|
||||
|
||||
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 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);
|
||||
|
||||
for i in 0 .. min_nrows_ncols.value() {
|
||||
|
@ -58,8 +58,8 @@ proptest! {
|
||||
let sol1 = chol.solve(&b1).unwrap();
|
||||
let sol2 = chol.solve(&b2).unwrap();
|
||||
|
||||
prop_assert!(relative_eq!(m * sol1, b1, epsilon = 1.0e-7));
|
||||
prop_assert!(relative_eq!(m * sol2, b2, 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-4));
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,7 +84,7 @@ proptest! {
|
||||
let id1 = &m * &m1;
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
47
nalgebra-lapack/tests/linalg/complex_eigen.rs
Normal file
47
nalgebra-lapack/tests/linalg/complex_eigen.rs
Normal file
@ -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_sol2 = lup.solve_transpose(&b2).unwrap();
|
||||
|
||||
prop_assert!(relative_eq!(&m * sol1, b1, epsilon = 1.0e-7));
|
||||
prop_assert!(relative_eq!(&m * sol2, b2, epsilon = 1.0e-7));
|
||||
prop_assert!(relative_eq!(m.transpose() * tr_sol1, b1, epsilon = 1.0e-7));
|
||||
prop_assert!(relative_eq!(m.transpose() * tr_sol2, b2, 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-5));
|
||||
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-5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -68,10 +68,10 @@ proptest! {
|
||||
let tr_sol1 = lup.solve_transpose(&b1).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 * sol2, b2, epsilon = 1.0e-7));
|
||||
prop_assert!(relative_eq!(m.transpose() * tr_sol1, b1, epsilon = 1.0e-7));
|
||||
prop_assert!(relative_eq!(m.transpose() * tr_sol2, b2, 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-5));
|
||||
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-5));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1,4 +1,5 @@
|
||||
mod cholesky;
|
||||
mod complex_eigen;
|
||||
mod generalized_eigenvalues;
|
||||
mod lu;
|
||||
mod qr;
|
||||
|
@ -13,30 +13,36 @@ proptest! {
|
||||
let m = DMatrix::<f64>::new_random(n, n);
|
||||
|
||||
if let Some(eig) = Eigen::new(m.clone(), true, true) {
|
||||
let eigvals = DMatrix::from_diagonal(&eig.eigenvalues);
|
||||
// TODO: test the complex case too.
|
||||
if eig.eigenvalues_are_real() {
|
||||
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 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_left_eigvectors, scaled_left_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-5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eigensystem_static(m in matrix4()) {
|
||||
if let Some(eig) = Eigen::new(m, true, true) {
|
||||
let eigvals = Matrix4::from_diagonal(&eig.eigenvalues);
|
||||
// TODO: test the complex case too.
|
||||
if eig.eigenvalues_are_real() {
|
||||
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 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_left_eigvectors, scaled_left_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-5));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,14 +11,17 @@ proptest! {
|
||||
let n = cmp::max(1, cmp::min(n, 10));
|
||||
let m = DMatrix::<f64>::new_random(n, n);
|
||||
|
||||
let (vecs, vals) = Schur::new(m.clone()).unpack();
|
||||
|
||||
prop_assert!(relative_eq!(&vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7))
|
||||
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-5))
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schur_static(m in matrix4()) {
|
||||
let (vecs, vals) = Schur::new(m.clone()).unpack();
|
||||
prop_assert!(relative_eq!(vecs * vals * vecs.transpose(), m, epsilon = 1.0e-7))
|
||||
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-5))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "nalgebra-sparse"
|
||||
version = "0.7.0"
|
||||
version = "0.8.0"
|
||||
authors = [ "Andreas Longva", "Sébastien Crozet <developer@crozet.re>" ]
|
||||
edition = "2018"
|
||||
description = "Sparse matrix computation based on nalgebra."
|
||||
|
@ -170,6 +170,16 @@ impl<T> CooMatrix<T> {
|
||||
.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.
|
||||
///
|
||||
/// This increase the capacities of triplet holding arrays by reserving more space to avoid
|
||||
@ -211,6 +221,13 @@ impl<T> CooMatrix<T> {
|
||||
self.values.push(v);
|
||||
}
|
||||
|
||||
/// Clear all triplets from the matrix.
|
||||
pub fn clear_triplets(&mut self) {
|
||||
self.col_indices.clear();
|
||||
self.row_indices.clear();
|
||||
self.values.clear();
|
||||
}
|
||||
|
||||
/// The number of rows in the matrix.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
|
@ -24,6 +24,7 @@ use std::slice::{Iter, IterMut};
|
||||
/// # Usage
|
||||
///
|
||||
/// ```
|
||||
/// use nalgebra_sparse::coo::CooMatrix;
|
||||
/// use nalgebra_sparse::csc::CscMatrix;
|
||||
/// use nalgebra::{DMatrix, Matrix3x4};
|
||||
/// 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
|
||||
/// // way to construct a CSC matrix is to first incrementally construct a COO matrix,
|
||||
/// // 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);
|
||||
///
|
||||
/// // Alternatively, a CSC matrix can be constructed directly from raw CSC data.
|
||||
|
@ -25,6 +25,7 @@ use std::slice::{Iter, IterMut};
|
||||
/// # Usage
|
||||
///
|
||||
/// ```
|
||||
/// use nalgebra_sparse::coo::CooMatrix;
|
||||
/// use nalgebra_sparse::csr::CsrMatrix;
|
||||
/// use nalgebra::{DMatrix, Matrix3x4};
|
||||
/// 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
|
||||
/// // way to construct a CSR matrix is to first incrementally construct a COO matrix,
|
||||
/// // 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);
|
||||
///
|
||||
/// // 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::pattern::SparsityPattern;
|
||||
use core::{iter, mem};
|
||||
use nalgebra::{DMatrix, DMatrixSlice, DMatrixSliceMut, RealField};
|
||||
use nalgebra::{DMatrix, DMatrixView, DMatrixViewMut, RealField};
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
/// A symbolic sparse Cholesky factorization of a CSC matrix.
|
||||
@ -264,7 +264,7 @@ impl<T: RealField> CscCholesky<T> {
|
||||
///
|
||||
/// Panics if `B` is not square.
|
||||
#[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 mut output = b.clone_owned();
|
||||
self.solve_mut(&mut output);
|
||||
@ -278,7 +278,7 @@ impl<T: RealField> CscCholesky<T> {
|
||||
/// # Panics
|
||||
///
|
||||
/// 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,\
|
||||
then the triangular solve should never fail";
|
||||
// Solve LY = B
|
||||
|
@ -143,8 +143,6 @@
|
||||
)]
|
||||
|
||||
pub extern crate nalgebra as na;
|
||||
#[cfg(feature = "io")]
|
||||
extern crate pest;
|
||||
#[macro_use]
|
||||
#[cfg(feature = "io")]
|
||||
extern crate pest_derive;
|
||||
|
@ -2,7 +2,7 @@ use crate::cs::CsMatrix;
|
||||
use crate::ops::serial::{OperationError, OperationErrorKind};
|
||||
use crate::ops::Op;
|
||||
use crate::SparseEntryMut;
|
||||
use nalgebra::{ClosedAdd, ClosedMul, DMatrixSlice, DMatrixSliceMut, Scalar};
|
||||
use nalgebra::{ClosedAdd, ClosedMul, DMatrixView, DMatrixViewMut, Scalar};
|
||||
use num_traits::{One, Zero};
|
||||
|
||||
fn spmm_cs_unexpected_entry() -> OperationError {
|
||||
@ -176,10 +176,10 @@ where
|
||||
/// the transposed operation must be specified for the CSC matrix.
|
||||
pub fn spmm_cs_dense<T>(
|
||||
beta: T,
|
||||
mut c: DMatrixSliceMut<'_, T>,
|
||||
mut c: DMatrixViewMut<'_, T>,
|
||||
alpha: T,
|
||||
a: Op<&CsMatrix<T>>,
|
||||
b: Op<DMatrixSlice<'_, T>>,
|
||||
b: Op<DMatrixView<'_, T>>,
|
||||
) where
|
||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ use crate::ops::serial::cs::{
|
||||
};
|
||||
use crate::ops::serial::{OperationError, OperationErrorKind};
|
||||
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 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.
|
||||
pub fn spmm_csc_dense<'a, T>(
|
||||
beta: T,
|
||||
c: impl Into<DMatrixSliceMut<'a, T>>,
|
||||
c: impl Into<DMatrixViewMut<'a, T>>,
|
||||
alpha: T,
|
||||
a: Op<&CscMatrix<T>>,
|
||||
b: Op<impl Into<DMatrixSlice<'a, T>>>,
|
||||
b: Op<impl Into<DMatrixView<'a, T>>>,
|
||||
) where
|
||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||
{
|
||||
@ -29,10 +29,10 @@ pub fn spmm_csc_dense<'a, T>(
|
||||
|
||||
fn spmm_csc_dense_<T>(
|
||||
beta: T,
|
||||
c: DMatrixSliceMut<'_, T>,
|
||||
c: DMatrixViewMut<'_, T>,
|
||||
alpha: T,
|
||||
a: Op<&CscMatrix<T>>,
|
||||
b: Op<DMatrixSlice<'_, T>>,
|
||||
b: Op<DMatrixView<'_, T>>,
|
||||
) where
|
||||
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.
|
||||
pub fn spsolve_csc_lower_triangular<'a, T: RealField>(
|
||||
l: Op<&CscMatrix<T>>,
|
||||
b: impl Into<DMatrixSliceMut<'a, T>>,
|
||||
b: impl Into<DMatrixViewMut<'a, T>>,
|
||||
) -> Result<(), OperationError> {
|
||||
let b = b.into();
|
||||
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>(
|
||||
l: &CscMatrix<T>,
|
||||
b: DMatrixSliceMut<'_, T>,
|
||||
b: DMatrixViewMut<'_, T>,
|
||||
) -> Result<(), OperationError> {
|
||||
let mut x = b;
|
||||
|
||||
@ -253,7 +253,7 @@ fn spsolve_encountered_zero_diagonal() -> Result<(), OperationError> {
|
||||
|
||||
fn spsolve_csc_lower_triangular_transpose<T: RealField>(
|
||||
l: &CscMatrix<T>,
|
||||
b: DMatrixSliceMut<'_, T>,
|
||||
b: DMatrixViewMut<'_, T>,
|
||||
) -> Result<(), OperationError> {
|
||||
let mut x = b;
|
||||
|
||||
|
@ -4,17 +4,17 @@ use crate::ops::serial::cs::{
|
||||
};
|
||||
use crate::ops::serial::OperationError;
|
||||
use crate::ops::Op;
|
||||
use nalgebra::{ClosedAdd, ClosedMul, DMatrixSlice, DMatrixSliceMut, Scalar};
|
||||
use nalgebra::{ClosedAdd, ClosedMul, DMatrixView, DMatrixViewMut, Scalar};
|
||||
use num_traits::{One, Zero};
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// Sparse-dense matrix-matrix multiplication `C <- beta * C + alpha * op(A) * op(B)`.
|
||||
pub fn spmm_csr_dense<'a, T>(
|
||||
beta: T,
|
||||
c: impl Into<DMatrixSliceMut<'a, T>>,
|
||||
c: impl Into<DMatrixViewMut<'a, T>>,
|
||||
alpha: T,
|
||||
a: Op<&CsrMatrix<T>>,
|
||||
b: Op<impl Into<DMatrixSlice<'a, T>>>,
|
||||
b: Op<impl Into<DMatrixView<'a, T>>>,
|
||||
) where
|
||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||
{
|
||||
@ -24,10 +24,10 @@ pub fn spmm_csr_dense<'a, T>(
|
||||
|
||||
fn spmm_csr_dense_<T>(
|
||||
beta: T,
|
||||
c: DMatrixSliceMut<'_, T>,
|
||||
c: DMatrixViewMut<'_, T>,
|
||||
alpha: T,
|
||||
a: Op<&CsrMatrix<T>>,
|
||||
b: Op<DMatrixSlice<'_, T>>,
|
||||
b: Op<DMatrixView<'_, T>>,
|
||||
) where
|
||||
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]
|
||||
fn coo_try_from_triplets_reports_out_of_bounds_indices() {
|
||||
{
|
||||
@ -226,6 +260,29 @@ fn coo_push_valid_entries() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coo_clear_triplets_valid_entries() {
|
||||
let mut coo = CooMatrix::new(3, 3);
|
||||
|
||||
coo.push(0, 0, 1);
|
||||
coo.push(0, 0, 2);
|
||||
coo.push(2, 2, 3);
|
||||
assert_eq!(
|
||||
coo.triplet_iter().collect::<Vec<_>>(),
|
||||
vec![(0, 0, &1), (0, 0, &2), (2, 2, &3)]
|
||||
);
|
||||
coo.clear_triplets();
|
||||
assert_eq!(coo.triplet_iter().collect::<Vec<_>>(), vec![]);
|
||||
// making sure everyhting works after clearing
|
||||
coo.push(0, 0, 1);
|
||||
coo.push(0, 0, 2);
|
||||
coo.push(2, 2, 3);
|
||||
assert_eq!(
|
||||
coo.triplet_iter().collect::<Vec<_>>(),
|
||||
vec![(0, 0, &1), (0, 0, &2), (2, 2, &3)]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coo_push_out_of_bounds_entries() {
|
||||
{
|
||||
@ -291,8 +348,8 @@ fn coo_push_matrix_valid_entries() {
|
||||
// Works with sliced
|
||||
{
|
||||
let source = nalgebra::SMatrix::<i32, 2, 2>::new(6, 7, 8, 9);
|
||||
let sliced = source.fixed_slice::<2, 1>(0, 0);
|
||||
coo.push_matrix(1, 0, &sliced);
|
||||
let view = source.fixed_view::<2, 1>(0, 0);
|
||||
coo.push_matrix(1, 0, &view);
|
||||
|
||||
assert_eq!(
|
||||
coo.triplet_iter().collect::<Vec<_>>(),
|
||||
|
@ -14,7 +14,7 @@ use nalgebra_sparse::pattern::SparsityPattern;
|
||||
use nalgebra_sparse::proptest::{csc, csr, sparsity_pattern};
|
||||
|
||||
use nalgebra::proptest::{matrix, vector};
|
||||
use nalgebra::{DMatrix, DMatrixSlice, DMatrixSliceMut, Scalar};
|
||||
use nalgebra::{DMatrix, DMatrixView, DMatrixViewMut, Scalar};
|
||||
|
||||
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
|
||||
fn dense_gemm<'a>(
|
||||
beta: i32,
|
||||
c: impl Into<DMatrixSliceMut<'a, i32>>,
|
||||
c: impl Into<DMatrixViewMut<'a, i32>>,
|
||||
alpha: i32,
|
||||
a: Op<impl Into<DMatrixSlice<'a, i32>>>,
|
||||
b: Op<impl Into<DMatrixSlice<'a, i32>>>,
|
||||
a: Op<impl Into<DMatrixView<'a, i32>>>,
|
||||
b: Op<impl Into<DMatrixView<'a, i32>>>,
|
||||
) {
|
||||
let mut c = c.into();
|
||||
let a = a.convert();
|
||||
|
@ -1,6 +1,7 @@
|
||||
use crate::base::dimension::{Dynamic, 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::slice_deprecation_note;
|
||||
|
||||
/*
|
||||
*
|
||||
@ -13,286 +14,345 @@ use crate::base::{Const, Matrix};
|
||||
/// 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.**
|
||||
#[deprecated = slice_deprecation_note!(SMatrixView)]
|
||||
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.
|
||||
///
|
||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||
#[deprecated = slice_deprecation_note!(DMatrixView)]
|
||||
pub type DMatrixSlice<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, Dynamic, SliceStorage<'a, T, Dynamic, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, Dynamic, ViewStorage<'a, T, Dynamic, Dynamic, RStride, CStride>>;
|
||||
|
||||
/// 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.**
|
||||
#[deprecated = slice_deprecation_note!(MatrixView1)]
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
#[deprecated = slice_deprecation_note!(MatrixView1xX)]
|
||||
pub type MatrixSlice1xX<'a, T, RStride = U1, CStride = U1> =
|
||||
Matrix<T, U1, Dynamic, SliceStorage<'a, T, U1, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U1, Dynamic, ViewStorage<'a, T, U1, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U2, Dynamic, SliceStorage<'a, T, U2, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U2, Dynamic, ViewStorage<'a, T, U2, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U3, Dynamic, SliceStorage<'a, T, U3, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U3, Dynamic, ViewStorage<'a, T, U3, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U4, Dynamic, SliceStorage<'a, T, U4, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U4, Dynamic, ViewStorage<'a, T, U4, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U5, Dynamic, SliceStorage<'a, T, U5, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U5, Dynamic, ViewStorage<'a, T, U5, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U6, Dynamic, SliceStorage<'a, T, U6, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U6, Dynamic, ViewStorage<'a, T, U6, Dynamic, RStride, CStride>>;
|
||||
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 1 column.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewXx1)]
|
||||
pub type MatrixSliceXx1<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U1, SliceStorage<'a, T, Dynamic, U1, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U1, ViewStorage<'a, T, Dynamic, U1, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 2 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewXx2)]
|
||||
pub type MatrixSliceXx2<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U2, SliceStorage<'a, T, Dynamic, U2, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U2, ViewStorage<'a, T, Dynamic, U2, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 3 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewXx3)]
|
||||
pub type MatrixSliceXx3<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U3, SliceStorage<'a, T, Dynamic, U3, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U3, ViewStorage<'a, T, Dynamic, U3, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 4 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewXx4)]
|
||||
pub type MatrixSliceXx4<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U4, SliceStorage<'a, T, Dynamic, U4, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U4, ViewStorage<'a, T, Dynamic, U4, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 5 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewXx5)]
|
||||
pub type MatrixSliceXx5<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U5, SliceStorage<'a, T, Dynamic, U5, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U5, ViewStorage<'a, T, Dynamic, U5, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 6 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewXx6)]
|
||||
pub type MatrixSliceXx6<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U6, SliceStorage<'a, T, Dynamic, U6, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U6, ViewStorage<'a, T, Dynamic, U6, RStride, CStride>>;
|
||||
|
||||
/// 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.**
|
||||
#[deprecated = slice_deprecation_note!(VectorView)]
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
#[deprecated = slice_deprecation_note!(DVectorView)]
|
||||
pub type DVectorSlice<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U1, SliceStorage<'a, T, Dynamic, U1, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U1, ViewStorage<'a, T, Dynamic, U1, RStride, CStride>>;
|
||||
|
||||
/// 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.**
|
||||
#[deprecated = slice_deprecation_note!(VectorView1)]
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||
#[deprecated = slice_deprecation_note!(DMatrixViewMut)]
|
||||
pub type DMatrixSliceMut<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, Dynamic, SliceStorageMut<'a, T, Dynamic, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, Dynamic, ViewStorageMut<'a, T, Dynamic, Dynamic, RStride, CStride>>;
|
||||
|
||||
/// 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.**
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewMut1)]
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewMut1xX)]
|
||||
pub type MatrixSliceMut1xX<'a, T, RStride = U1, CStride = U1> =
|
||||
Matrix<T, U1, Dynamic, SliceStorageMut<'a, T, U1, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U1, Dynamic, ViewStorageMut<'a, T, U1, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U2, Dynamic, SliceStorageMut<'a, T, U2, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U2, Dynamic, ViewStorageMut<'a, T, U2, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U3, Dynamic, SliceStorageMut<'a, T, U3, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U3, Dynamic, ViewStorageMut<'a, T, U3, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U4, Dynamic, SliceStorageMut<'a, T, U4, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U4, Dynamic, ViewStorageMut<'a, T, U4, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U5, Dynamic, SliceStorageMut<'a, T, U5, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U5, Dynamic, ViewStorageMut<'a, T, U5, Dynamic, RStride, CStride>>;
|
||||
/// 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> =
|
||||
Matrix<T, U6, Dynamic, SliceStorageMut<'a, T, U6, Dynamic, RStride, CStride>>;
|
||||
Matrix<T, U6, Dynamic, ViewStorageMut<'a, T, U6, Dynamic, RStride, CStride>>;
|
||||
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 1 column.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewMutXx1)]
|
||||
pub type MatrixSliceMutXx1<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U1, SliceStorageMut<'a, T, Dynamic, U1, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U1, ViewStorageMut<'a, T, Dynamic, U1, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 2 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewMutXx2)]
|
||||
pub type MatrixSliceMutXx2<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U2, SliceStorageMut<'a, T, Dynamic, U2, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U2, ViewStorageMut<'a, T, Dynamic, U2, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 3 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewMutXx3)]
|
||||
pub type MatrixSliceMutXx3<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U3, SliceStorageMut<'a, T, Dynamic, U3, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U3, ViewStorageMut<'a, T, Dynamic, U3, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 4 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewMutXx4)]
|
||||
pub type MatrixSliceMutXx4<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U4, SliceStorageMut<'a, T, Dynamic, U4, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U4, ViewStorageMut<'a, T, Dynamic, U4, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 5 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewMutXx5)]
|
||||
pub type MatrixSliceMutXx5<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U5, SliceStorageMut<'a, T, Dynamic, U5, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U5, ViewStorageMut<'a, T, Dynamic, U5, RStride, CStride>>;
|
||||
/// A column-major matrix slice with a number of rows chosen at runtime and 6 columns.
|
||||
#[deprecated = slice_deprecation_note!(MatrixViewMutXx6)]
|
||||
pub type MatrixSliceMutXx6<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U6, SliceStorageMut<'a, T, Dynamic, U6, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U6, ViewStorageMut<'a, T, Dynamic, U6, RStride, CStride>>;
|
||||
|
||||
/// 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.**
|
||||
#[deprecated = slice_deprecation_note!(VectorViewMut)]
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **Because this is an alias, not all its methods are listed here. See the [`Matrix`](crate::base::Matrix) type too.**
|
||||
#[deprecated = slice_deprecation_note!(DVectorViewMut)]
|
||||
pub type DVectorSliceMut<'a, T, RStride = U1, CStride = Dynamic> =
|
||||
Matrix<T, Dynamic, U1, SliceStorageMut<'a, T, Dynamic, U1, RStride, CStride>>;
|
||||
Matrix<T, Dynamic, U1, ViewStorageMut<'a, T, Dynamic, U1, RStride, CStride>>;
|
||||
|
||||
/// 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.**
|
||||
#[deprecated = slice_deprecation_note!(VectorViewMut1)]
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
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.
|
||||
///
|
||||
/// **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> =
|
||||
Matrix<T, U6, U1, SliceStorageMut<'a, T, U6, U1, RStride, CStride>>;
|
||||
Matrix<T, U6, U1, ViewStorageMut<'a, T, U6, U1, RStride, CStride>>;
|
||||
|
589
src/base/alias_view.rs
Normal file
589
src/base/alias_view.rs
Normal file
@ -0,0 +1,589 @@
|
||||
use crate::base::dimension::{Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, Dynamic, ViewStorage<'a, T, Dynamic, Dynamic, 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, Dynamic, ViewStorage<'a, T, U1, Dynamic, 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, Dynamic, ViewStorage<'a, T, U2, Dynamic, 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, Dynamic, ViewStorage<'a, T, U3, Dynamic, 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, Dynamic, ViewStorage<'a, T, U4, Dynamic, 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, Dynamic, ViewStorage<'a, T, U5, Dynamic, 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, Dynamic, ViewStorage<'a, T, U6, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U1, ViewStorage<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U2, ViewStorage<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U3, ViewStorage<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U4, ViewStorage<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U5, ViewStorage<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U6, ViewStorage<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U1, ViewStorage<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, Dynamic, ViewStorageMut<'a, T, Dynamic, Dynamic, 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, Dynamic, ViewStorageMut<'a, T, U1, Dynamic, 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, Dynamic, ViewStorageMut<'a, T, U2, Dynamic, 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, Dynamic, ViewStorageMut<'a, T, U3, Dynamic, 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, Dynamic, ViewStorageMut<'a, T, U4, Dynamic, 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, Dynamic, ViewStorageMut<'a, T, U5, Dynamic, 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, Dynamic, ViewStorageMut<'a, T, U6, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U1, ViewStorageMut<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U2, ViewStorageMut<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U3, ViewStorageMut<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U4, ViewStorageMut<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U5, ViewStorageMut<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U6, ViewStorageMut<'a, T, Dynamic, 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 = Dynamic> =
|
||||
Matrix<T, Dynamic, U1, ViewStorageMut<'a, T, Dynamic, 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>>;
|
@ -41,6 +41,41 @@ pub trait Allocator<T, R: Dim, C: Dim = U1>: Any + Sized {
|
||||
ncols: C,
|
||||
iter: I,
|
||||
) -> Self::Buffer;
|
||||
|
||||
#[inline]
|
||||
/// Allocates a buffer initialized with the content of the given row-major order iterator.
|
||||
fn allocate_from_row_iterator<I: IntoIterator<Item = T>>(
|
||||
nrows: R,
|
||||
ncols: C,
|
||||
iter: I,
|
||||
) -> Self::Buffer {
|
||||
let mut res = Self::allocate_uninit(nrows, ncols);
|
||||
let mut count = 0;
|
||||
|
||||
unsafe {
|
||||
// OK because the allocated buffer is guaranteed to be contiguous.
|
||||
let res_ptr = res.as_mut_slice_unchecked();
|
||||
|
||||
for (k, e) in iter
|
||||
.into_iter()
|
||||
.take(ncols.value() * nrows.value())
|
||||
.enumerate()
|
||||
{
|
||||
let i = k / ncols.value();
|
||||
let j = k % ncols.value();
|
||||
// result[(i, j)] = e;
|
||||
*res_ptr.get_unchecked_mut(i + j * nrows.value()) = MaybeUninit::new(e);
|
||||
count += 1;
|
||||
}
|
||||
|
||||
assert!(
|
||||
count == nrows.value() * ncols.value(),
|
||||
"Matrix init. from row iterator: iterator not long enough."
|
||||
);
|
||||
|
||||
<Self as Allocator<T, R, C>>::assume_init(res)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A matrix reallocator. Changes the size of the memory buffer that initially contains (`RFrom` ×
|
||||
|
@ -27,7 +27,6 @@ use std::mem;
|
||||
/// A array-based statically sized matrix data storage.
|
||||
#[repr(transparent)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -39,6 +38,10 @@ use std::mem;
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct ArrayStorage<T, const R: usize, const C: usize>(pub [[T; R]; C]);
|
||||
|
||||
|
@ -11,7 +11,7 @@ use crate::base::dimension::{Const, Dim, Dynamic, U1, U2, U3, U4};
|
||||
use crate::base::storage::{Storage, StorageMut};
|
||||
use crate::base::uninit::Init;
|
||||
use crate::base::{
|
||||
DVectorSlice, DefaultAllocator, Matrix, Scalar, SquareMatrix, Vector, VectorSlice,
|
||||
DVectorView, DefaultAllocator, Matrix, Scalar, SquareMatrix, Vector, VectorView,
|
||||
};
|
||||
|
||||
/// # Dot/scalar product
|
||||
@ -363,8 +363,8 @@ where
|
||||
x: &Vector<T, D3, SC>,
|
||||
beta: T,
|
||||
dot: impl Fn(
|
||||
&DVectorSlice<'_, T, SB::RStride, SB::CStride>,
|
||||
&DVectorSlice<'_, T, SC::RStride, SC::CStride>,
|
||||
&DVectorView<'_, T, SB::RStride, SB::CStride>,
|
||||
&DVectorView<'_, T, SC::RStride, SC::CStride>,
|
||||
) -> T,
|
||||
) where
|
||||
T: One,
|
||||
@ -393,7 +393,7 @@ where
|
||||
let col2 = a.column(0);
|
||||
let val = unsafe { x.vget_unchecked(0).clone() };
|
||||
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 {
|
||||
let col2 = a.column(j);
|
||||
@ -506,7 +506,7 @@ where
|
||||
a: &Matrix<T, R2, C2, SB>,
|
||||
x: &Vector<T, D3, SC>,
|
||||
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
|
||||
T: One,
|
||||
SB: Storage<T, R2, C2>,
|
||||
@ -892,7 +892,7 @@ where
|
||||
let val = unsafe { conjugate(y.vget_unchecked(j).clone()) };
|
||||
let subdim = Dynamic::new(dim1 - j);
|
||||
// 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,
|
||||
&x.rows_range(j..),
|
||||
beta.clone(),
|
||||
|
@ -59,7 +59,7 @@ where
|
||||
SB: Storage<T, DimNameDiff<D, U1>>,
|
||||
{
|
||||
let mut res = Self::identity();
|
||||
res.generic_slice_mut(
|
||||
res.generic_view_mut(
|
||||
(0, D::dim() - 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>>,
|
||||
{
|
||||
let scale = self
|
||||
.generic_slice(
|
||||
.generic_view(
|
||||
(D::dim() - 1, 0),
|
||||
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
||||
)
|
||||
.tr_dot(shift);
|
||||
let post_translation = self.generic_slice(
|
||||
let post_translation = self.generic_view(
|
||||
(0, 0),
|
||||
(DimNameDiff::<D, U1>::name(), DimNameDiff::<D, U1>::name()),
|
||||
) * shift;
|
||||
|
||||
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),
|
||||
(DimNameDiff::<D, U1>::name(), Const::<1>),
|
||||
);
|
||||
@ -415,11 +415,11 @@ where
|
||||
&self,
|
||||
v: &OVector<T, DimNameDiff<D, U1>>,
|
||||
) -> OVector<T, DimNameDiff<D, U1>> {
|
||||
let transform = self.generic_slice(
|
||||
let transform = self.generic_view(
|
||||
(0, 0),
|
||||
(DimNameDiff::<D, U1>::name(), DimNameDiff::<D, U1>::name()),
|
||||
);
|
||||
let normalizer = self.generic_slice(
|
||||
let normalizer = self.generic_view(
|
||||
(D::dim() - 1, 0),
|
||||
(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.
|
||||
#[inline]
|
||||
pub fn transform_point(&self, pt: &Point<T, 2>) -> Point<T, 2> {
|
||||
let transform = self.fixed_slice::<2, 2>(0, 0);
|
||||
let translation = self.fixed_slice::<2, 1>(0, 2);
|
||||
let normalizer = self.fixed_slice::<1, 2>(2, 0);
|
||||
let transform = self.fixed_view::<2, 2>(0, 0);
|
||||
let translation = self.fixed_view::<2, 1>(0, 2);
|
||||
let normalizer = self.fixed_view::<1, 2>(2, 0);
|
||||
let n = normalizer.tr_dot(&pt.coords) + unsafe { self.get_unchecked((2, 2)).clone() };
|
||||
|
||||
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.
|
||||
#[inline]
|
||||
pub fn transform_point(&self, pt: &Point<T, 3>) -> Point<T, 3> {
|
||||
let transform = self.fixed_slice::<3, 3>(0, 0);
|
||||
let translation = self.fixed_slice::<3, 1>(0, 3);
|
||||
let normalizer = self.fixed_slice::<1, 3>(3, 0);
|
||||
let transform = self.fixed_view::<3, 3>(0, 0);
|
||||
let translation = self.fixed_view::<3, 1>(0, 3);
|
||||
let normalizer = self.fixed_view::<1, 3>(3, 0);
|
||||
let n = normalizer.tr_dot(&pt.coords) + unsafe { self.get_unchecked((3, 3)).clone() };
|
||||
|
||||
if !n.is_zero() {
|
||||
|
@ -86,6 +86,17 @@ where
|
||||
Self::from_data(DefaultAllocator::allocate_from_iterator(nrows, ncols, iter))
|
||||
}
|
||||
|
||||
/// Creates a matrix with all its elements filled by an row-major order iterator.
|
||||
#[inline]
|
||||
pub fn from_row_iterator_generic<I>(nrows: R, ncols: C, iter: I) -> Self
|
||||
where
|
||||
I: IntoIterator<Item = T>,
|
||||
{
|
||||
Self::from_data(DefaultAllocator::allocate_from_row_iterator(
|
||||
nrows, ncols, iter,
|
||||
))
|
||||
}
|
||||
|
||||
/// Creates a matrix with its elements filled with the components provided by a slice in
|
||||
/// row-major order.
|
||||
///
|
||||
@ -479,6 +490,36 @@ macro_rules! impl_constructors(
|
||||
Self::from_iterator_generic($($gargs, )* iter)
|
||||
}
|
||||
|
||||
/// Creates a matrix or vector with all its elements filled by a row-major iterator.
|
||||
///
|
||||
/// The output matrix is filled row-by-row.
|
||||
///
|
||||
/// ## Example
|
||||
/// ```
|
||||
/// # use nalgebra::{Matrix2x3, Vector3, DVector, DMatrix};
|
||||
/// # use std::iter;
|
||||
///
|
||||
/// let v = Vector3::from_row_iterator((0..3).into_iter());
|
||||
/// // The additional argument represents the vector dimension.
|
||||
/// let dv = DVector::from_row_iterator(3, (0..3).into_iter());
|
||||
/// let m = Matrix2x3::from_row_iterator((0..6).into_iter());
|
||||
/// // The two additional arguments represent the matrix dimensions.
|
||||
/// let dm = DMatrix::from_row_iterator(2, 3, (0..6).into_iter());
|
||||
///
|
||||
/// // For Vectors from_row_iterator is identical to from_iterator
|
||||
/// assert!(v.x == 0 && v.y == 1 && v.z == 2);
|
||||
/// assert!(dv[0] == 0 && dv[1] == 1 && dv[2] == 2);
|
||||
/// assert!(m.m11 == 0 && m.m12 == 1 && m.m13 == 2 &&
|
||||
/// m.m21 == 3 && m.m22 == 4 && m.m23 == 5);
|
||||
/// assert!(dm[(0, 0)] == 0 && dm[(0, 1)] == 1 && dm[(0, 2)] == 2 &&
|
||||
/// dm[(1, 0)] == 3 && dm[(1, 1)] == 4 && dm[(1, 2)] == 5);
|
||||
/// ```
|
||||
#[inline]
|
||||
pub fn from_row_iterator<I>($($args: usize,)* iter: I) -> Self
|
||||
where I: IntoIterator<Item = T> {
|
||||
Self::from_row_iterator_generic($($gargs, )* iter)
|
||||
}
|
||||
|
||||
/// Creates a matrix or vector filled with the results of a function applied to each of its
|
||||
/// component coordinates.
|
||||
///
|
||||
|
@ -1,14 +1,14 @@
|
||||
use crate::base::dimension::{Const, Dim, DimName, Dynamic};
|
||||
use crate::base::matrix_slice::{SliceStorage, SliceStorageMut};
|
||||
use crate::base::{MatrixSlice, MatrixSliceMutMN, Scalar};
|
||||
use crate::base::matrix_view::{ViewStorage, ViewStorageMut};
|
||||
use crate::base::{MatrixView, MatrixViewMut, Scalar};
|
||||
|
||||
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>
|
||||
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
|
||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||
@ -22,7 +22,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||
rstride: RStride,
|
||||
cstride: CStride,
|
||||
) -> Self {
|
||||
let data = SliceStorage::from_raw_parts(
|
||||
let data = ViewStorage::from_raw_parts(
|
||||
data.as_ptr().add(start),
|
||||
(nrows, ncols),
|
||||
(rstride, cstride),
|
||||
@ -30,7 +30,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||
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.
|
||||
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
||||
@ -48,7 +48,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||
assert!(
|
||||
data.len() + cstride.value() + rstride.value()
|
||||
>= ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
||||
"Matrix slice: input data buffer to small."
|
||||
"Matrix view: input data buffer too small."
|
||||
);
|
||||
|
||||
unsafe {
|
||||
@ -57,8 +57,8 @@ 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> {
|
||||
/// Creates, without bound-checking, a matrix slice from an array and with dimensions specified by generic types instances.
|
||||
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixView<'a, T, R, C> {
|
||||
/// Creates, without bound-checking, a matrix view from an array and with dimensions specified by generic types instances.
|
||||
///
|
||||
/// # Safety
|
||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||
@ -75,7 +75,7 @@ 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.
|
||||
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
||||
@ -87,8 +87,8 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSlice<'a, T, R, C> {
|
||||
|
||||
macro_rules! impl_constructors(
|
||||
($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => {
|
||||
impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixSlice<'a, T, $($Dims),*> {
|
||||
/// Creates a new matrix slice from the given data array.
|
||||
impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixView<'a, T, $($Dims),*> {
|
||||
/// Creates a new matrix view from the given data array.
|
||||
///
|
||||
/// Panics if `data` does not contain enough elements.
|
||||
#[inline]
|
||||
@ -96,15 +96,15 @@ macro_rules! impl_constructors(
|
||||
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]
|
||||
pub unsafe fn from_slice_unchecked(data: &'a [T], start: usize, $($args: usize),*) -> Self {
|
||||
Self::from_slice_generic_unchecked(data, start, $($gargs),*)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixSlice<'a, T, $($Dims,)* Dynamic, Dynamic> {
|
||||
/// Creates a new matrix slice with the specified strides from the given data array.
|
||||
impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixView<'a, T, $($Dims,)* Dynamic, Dynamic> {
|
||||
/// Creates a new matrix view with the specified strides from the given data array.
|
||||
///
|
||||
/// Panics if `data` does not contain enough elements.
|
||||
#[inline]
|
||||
@ -112,7 +112,7 @@ macro_rules! impl_constructors(
|
||||
Self::from_slice_with_strides_generic(data, $($gargs,)* Dynamic::new(rstride), Dynamic::new(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]
|
||||
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))
|
||||
@ -142,11 +142,11 @@ impl_constructors!(Dynamic, Dynamic;
|
||||
Dynamic::new(nrows), Dynamic::new(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>
|
||||
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
|
||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||
@ -160,7 +160,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||
rstride: RStride,
|
||||
cstride: CStride,
|
||||
) -> Self {
|
||||
let data = SliceStorageMut::from_raw_parts(
|
||||
let data = ViewStorageMut::from_raw_parts(
|
||||
data.as_mut_ptr().add(start),
|
||||
(nrows, ncols),
|
||||
(rstride, cstride),
|
||||
@ -168,7 +168,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||
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.
|
||||
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
||||
@ -186,7 +186,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
||||
assert!(
|
||||
data.len() + cstride.value() + rstride.value()
|
||||
>= ncols.value() * cstride.value() + nrows.value() * rstride.value() + 1,
|
||||
"Matrix slice: input data buffer to small."
|
||||
"Matrix view: input data buffer too small."
|
||||
);
|
||||
|
||||
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 {
|
||||
@ -217,8 +217,8 @@ 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> {
|
||||
/// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions specified by generic types instances.
|
||||
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixViewMut<'a, T, R, C> {
|
||||
/// Creates, without bound-checking, a mutable matrix view from an array and with dimensions specified by generic types instances.
|
||||
///
|
||||
/// # Safety
|
||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||
@ -235,7 +235,7 @@ 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.
|
||||
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
||||
@ -247,8 +247,8 @@ impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, T, R, C> {
|
||||
|
||||
macro_rules! impl_constructors_mut(
|
||||
($($Dims: ty),*; $(=> $DimIdent: ident: $DimBound: ident),*; $($gargs: expr),*; $($args: ident),*) => {
|
||||
impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixSliceMutMN<'a, T, $($Dims),*> {
|
||||
/// Creates a new mutable matrix slice from the given data array.
|
||||
impl<'a, T: Scalar, $($DimIdent: $DimBound),*> MatrixViewMut<'a, T, $($Dims),*> {
|
||||
/// Creates a new mutable matrix view from the given data array.
|
||||
///
|
||||
/// Panics if `data` does not contain enough elements.
|
||||
#[inline]
|
||||
@ -256,15 +256,15 @@ macro_rules! impl_constructors_mut(
|
||||
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]
|
||||
pub unsafe fn from_slice_unchecked(data: &'a mut [T], start: usize, $($args: usize),*) -> Self {
|
||||
Self::from_slice_generic_unchecked(data, start, $($gargs),*)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixSliceMutMN<'a, T, $($Dims,)* Dynamic, Dynamic> {
|
||||
/// Creates a new mutable matrix slice with the specified strides from the given data array.
|
||||
impl<'a, T: Scalar, $($DimIdent: $DimBound, )*> MatrixViewMut<'a, T, $($Dims,)* Dynamic, Dynamic> {
|
||||
/// Creates a new mutable matrix view with the specified strides from the given data array.
|
||||
///
|
||||
/// Panics if `data` does not contain enough elements.
|
||||
#[inline]
|
||||
@ -273,7 +273,7 @@ macro_rules! impl_constructors_mut(
|
||||
data, $($gargs,)* Dynamic::new(rstride), Dynamic::new(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]
|
||||
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(
|
@ -16,14 +16,14 @@ use crate::base::dimension::{
|
||||
use crate::base::iter::{MatrixIter, MatrixIterMut};
|
||||
use crate::base::storage::{IsContiguous, RawStorage, RawStorageMut};
|
||||
use crate::base::{
|
||||
ArrayStorage, DVectorSlice, DVectorSliceMut, DefaultAllocator, Matrix, MatrixSlice,
|
||||
MatrixSliceMut, OMatrix, Scalar,
|
||||
ArrayStorage, DVectorView, DVectorViewMut, DefaultAllocator, Matrix, MatrixView, MatrixViewMut,
|
||||
OMatrix, Scalar,
|
||||
};
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
use crate::base::{DVector, RowDVector, VecStorage};
|
||||
use crate::base::{SliceStorage, SliceStorageMut};
|
||||
use crate::base::{ViewStorage, ViewStorageMut};
|
||||
use crate::constraint::DimEq;
|
||||
use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector, VectorSlice, VectorSliceMut};
|
||||
use crate::{IsNotStaticOne, RowSVector, SMatrix, SVector, VectorView, VectorViewMut};
|
||||
use std::mem::MaybeUninit;
|
||||
|
||||
// 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>
|
||||
From<VectorSlice<'a, T, Const<D>, RStride, CStride>> for [T; D]
|
||||
From<VectorView<'a, T, Const<D>, RStride, CStride>> for [T; D]
|
||||
{
|
||||
#[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()
|
||||
}
|
||||
}
|
||||
|
||||
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]
|
||||
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()
|
||||
}
|
||||
}
|
||||
@ -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>
|
||||
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]
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
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]
|
||||
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()
|
||||
}
|
||||
}
|
||||
@ -289,20 +289,20 @@ impl_from_into_asref_borrow_2D!(
|
||||
);
|
||||
|
||||
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>>
|
||||
where
|
||||
T: Scalar,
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
{
|
||||
fn from(matrix_slice: MatrixSlice<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||
matrix_slice.into_owned()
|
||||
fn from(matrix_view: MatrixView<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||
matrix_view.into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[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, Dynamic, C, RStride, CStride>>
|
||||
for Matrix<T, Dynamic, C, VecStorage<T, Dynamic, C>>
|
||||
where
|
||||
T: Scalar,
|
||||
@ -310,13 +310,13 @@ where
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
{
|
||||
fn from(matrix_slice: MatrixSlice<'a, T, Dynamic, C, RStride, CStride>) -> Self {
|
||||
matrix_slice.into_owned()
|
||||
fn from(matrix_view: MatrixView<'a, T, Dynamic, C, RStride, CStride>) -> Self {
|
||||
matrix_view.into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[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, Dynamic, RStride, CStride>>
|
||||
for Matrix<T, R, Dynamic, VecStorage<T, R, Dynamic>>
|
||||
where
|
||||
T: Scalar,
|
||||
@ -324,26 +324,26 @@ where
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
{
|
||||
fn from(matrix_slice: MatrixSlice<'a, T, R, Dynamic, RStride, CStride>) -> Self {
|
||||
matrix_slice.into_owned()
|
||||
fn from(matrix_view: MatrixView<'a, T, R, Dynamic, RStride, CStride>) -> Self {
|
||||
matrix_view.into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
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>>
|
||||
where
|
||||
T: Scalar,
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
{
|
||||
fn from(matrix_slice: MatrixSliceMut<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||
matrix_slice.into_owned()
|
||||
fn from(matrix_view: MatrixViewMut<'a, T, Const<R>, Const<C>, RStride, CStride>) -> Self {
|
||||
matrix_view.into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[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, Dynamic, C, RStride, CStride>>
|
||||
for Matrix<T, Dynamic, C, VecStorage<T, Dynamic, C>>
|
||||
where
|
||||
T: Scalar,
|
||||
@ -351,13 +351,13 @@ where
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
{
|
||||
fn from(matrix_slice: MatrixSliceMut<'a, T, Dynamic, C, RStride, CStride>) -> Self {
|
||||
matrix_slice.into_owned()
|
||||
fn from(matrix_view: MatrixViewMut<'a, T, Dynamic, C, RStride, CStride>) -> Self {
|
||||
matrix_view.into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
#[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, Dynamic, RStride, CStride>>
|
||||
for Matrix<T, R, Dynamic, VecStorage<T, R, Dynamic>>
|
||||
where
|
||||
T: Scalar,
|
||||
@ -365,116 +365,107 @@ where
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
{
|
||||
fn from(matrix_slice: MatrixSliceMut<'a, T, R, Dynamic, RStride, CStride>) -> Self {
|
||||
matrix_slice.into_owned()
|
||||
fn from(matrix_view: MatrixViewMut<'a, T, R, Dynamic, RStride, CStride>) -> Self {
|
||||
matrix_view.into_owned()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a Matrix<T, R, C, S>>
|
||||
for MatrixSlice<'a, T, RSlice, CSlice, RStride, CStride>
|
||||
impl<'a, T, R, C, RView, CView, RStride, CStride, S> From<&'a Matrix<T, R, C, S>>
|
||||
for MatrixView<'a, T, RView, CView, RStride, CStride>
|
||||
where
|
||||
T: Scalar,
|
||||
R: Dim,
|
||||
C: Dim,
|
||||
RSlice: Dim,
|
||||
CSlice: Dim,
|
||||
RView: Dim,
|
||||
CView: Dim,
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
S: RawStorage<T, R, C>,
|
||||
ShapeConstraint: DimEq<R, RSlice>
|
||||
+ DimEq<C, CSlice>
|
||||
+ DimEq<RStride, S::RStride>
|
||||
+ DimEq<CStride, S::CStride>,
|
||||
ShapeConstraint:
|
||||
DimEq<R, RView> + DimEq<C, CView> + DimEq<RStride, S::RStride> + DimEq<CStride, S::CStride>,
|
||||
{
|
||||
fn from(m: &'a Matrix<T, R, C, S>) -> Self {
|
||||
let (row, col) = m.shape_generic();
|
||||
let row_slice = RSlice::from_usize(row.value());
|
||||
let col_slice = CSlice::from_usize(col.value());
|
||||
let rows_result = RView::from_usize(row.value());
|
||||
let cols_result = CView::from_usize(col.value());
|
||||
|
||||
let (rstride, cstride) = m.strides();
|
||||
|
||||
let rstride_slice = RStride::from_usize(rstride);
|
||||
let cstride_slice = CStride::from_usize(cstride);
|
||||
let rstride_result = RStride::from_usize(rstride);
|
||||
let cstride_result = CStride::from_usize(cstride);
|
||||
|
||||
unsafe {
|
||||
let data = SliceStorage::from_raw_parts(
|
||||
let data = ViewStorage::from_raw_parts(
|
||||
m.data.ptr(),
|
||||
(row_slice, col_slice),
|
||||
(rstride_slice, cstride_slice),
|
||||
(rows_result, cols_result),
|
||||
(rstride_result, cstride_result),
|
||||
);
|
||||
Matrix::from_data_statically_unchecked(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a mut Matrix<T, R, C, S>>
|
||||
for MatrixSlice<'a, T, RSlice, CSlice, RStride, CStride>
|
||||
impl<'a, T, R, C, RView, CView, RStride, CStride, S> From<&'a mut Matrix<T, R, C, S>>
|
||||
for MatrixView<'a, T, RView, CView, RStride, CStride>
|
||||
where
|
||||
T: Scalar,
|
||||
R: Dim,
|
||||
C: Dim,
|
||||
RSlice: Dim,
|
||||
CSlice: Dim,
|
||||
RView: Dim,
|
||||
CView: Dim,
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
S: RawStorage<T, R, C>,
|
||||
ShapeConstraint: DimEq<R, RSlice>
|
||||
+ DimEq<C, CSlice>
|
||||
+ DimEq<RStride, S::RStride>
|
||||
+ DimEq<CStride, S::CStride>,
|
||||
ShapeConstraint:
|
||||
DimEq<R, RView> + DimEq<C, CView> + DimEq<RStride, S::RStride> + DimEq<CStride, S::CStride>,
|
||||
{
|
||||
fn from(m: &'a mut Matrix<T, R, C, S>) -> Self {
|
||||
let (row, col) = m.shape_generic();
|
||||
let row_slice = RSlice::from_usize(row.value());
|
||||
let col_slice = CSlice::from_usize(col.value());
|
||||
let rows_result = RView::from_usize(row.value());
|
||||
let cols_result = CView::from_usize(col.value());
|
||||
|
||||
let (rstride, cstride) = m.strides();
|
||||
|
||||
let rstride_slice = RStride::from_usize(rstride);
|
||||
let cstride_slice = CStride::from_usize(cstride);
|
||||
let rstride_result = RStride::from_usize(rstride);
|
||||
let cstride_result = CStride::from_usize(cstride);
|
||||
|
||||
unsafe {
|
||||
let data = SliceStorage::from_raw_parts(
|
||||
let data = ViewStorage::from_raw_parts(
|
||||
m.data.ptr(),
|
||||
(row_slice, col_slice),
|
||||
(rstride_slice, cstride_slice),
|
||||
(rows_result, cols_result),
|
||||
(rstride_result, cstride_result),
|
||||
);
|
||||
Matrix::from_data_statically_unchecked(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, R, C, RSlice, CSlice, RStride, CStride, S> From<&'a mut Matrix<T, R, C, S>>
|
||||
for MatrixSliceMut<'a, T, RSlice, CSlice, RStride, CStride>
|
||||
impl<'a, T, R, C, RView, CView, RStride, CStride, S> From<&'a mut Matrix<T, R, C, S>>
|
||||
for MatrixViewMut<'a, T, RView, CView, RStride, CStride>
|
||||
where
|
||||
T: Scalar,
|
||||
R: Dim,
|
||||
C: Dim,
|
||||
RSlice: Dim,
|
||||
CSlice: Dim,
|
||||
RView: Dim,
|
||||
CView: Dim,
|
||||
RStride: Dim,
|
||||
CStride: Dim,
|
||||
S: RawStorageMut<T, R, C>,
|
||||
ShapeConstraint: DimEq<R, RSlice>
|
||||
+ DimEq<C, CSlice>
|
||||
+ DimEq<RStride, S::RStride>
|
||||
+ DimEq<CStride, S::CStride>,
|
||||
ShapeConstraint:
|
||||
DimEq<R, RView> + DimEq<C, CView> + DimEq<RStride, S::RStride> + DimEq<CStride, S::CStride>,
|
||||
{
|
||||
fn from(m: &'a mut Matrix<T, R, C, S>) -> Self {
|
||||
let (row, col) = m.shape_generic();
|
||||
let row_slice = RSlice::from_usize(row.value());
|
||||
let col_slice = CSlice::from_usize(col.value());
|
||||
let rows_result = RView::from_usize(row.value());
|
||||
let cols_result = CView::from_usize(col.value());
|
||||
|
||||
let (rstride, cstride) = m.strides();
|
||||
|
||||
let rstride_slice = RStride::from_usize(rstride);
|
||||
let cstride_slice = CStride::from_usize(cstride);
|
||||
let rstride_result = RStride::from_usize(rstride);
|
||||
let cstride_result = CStride::from_usize(cstride);
|
||||
|
||||
unsafe {
|
||||
let data = SliceStorageMut::from_raw_parts(
|
||||
let data = ViewStorageMut::from_raw_parts(
|
||||
m.data.ptr_mut(),
|
||||
(row_slice, col_slice),
|
||||
(rstride_slice, cstride_slice),
|
||||
(rows_result, cols_result),
|
||||
(rstride_result, cstride_result),
|
||||
);
|
||||
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]
|
||||
fn from(slice: &'a [T]) -> Self {
|
||||
Self::from_slice(slice, slice.len())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Scalar> From<DVectorSlice<'a, T>> for &'a [T] {
|
||||
fn from(vec: DVectorSlice<'a, T>) -> &'a [T] {
|
||||
impl<'a, T: Scalar> From<DVectorView<'a, T>> for &'a [T] {
|
||||
fn from(vec: DVectorView<'a, T>) -> &'a [T] {
|
||||
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]
|
||||
fn from(slice: &'a mut [T]) -> Self {
|
||||
Self::from_slice(slice, slice.len())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T: Scalar> From<DVectorSliceMut<'a, T>> for &'a mut [T] {
|
||||
fn from(vec: DVectorSliceMut<'a, T>) -> &'a mut [T] {
|
||||
impl<'a, T: Scalar> From<DVectorViewMut<'a, T>> for &'a mut [T] {
|
||||
fn from(vec: DVectorViewMut<'a, T>) -> &'a mut [T] {
|
||||
vec.data.into_slice_mut()
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ use std::mem::{ManuallyDrop, MaybeUninit};
|
||||
* Allocator.
|
||||
*
|
||||
*/
|
||||
/// An allocator based on `GenericArray` and `VecStorage` for statically-sized and dynamically-sized
|
||||
/// An allocator based on [`ArrayStorage`] and [`VecStorage`] for statically-sized and dynamically-sized
|
||||
/// matrices respectively.
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct DefaultAllocator;
|
||||
|
@ -13,6 +13,14 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||
|
||||
/// Dim of dynamically-sized algebraic entities.
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
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))]
|
||||
pub struct Dynamic {
|
||||
value: usize,
|
||||
@ -198,6 +206,14 @@ dim_ops!(
|
||||
);
|
||||
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
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))]
|
||||
pub struct Const<const R: usize>;
|
||||
|
||||
@ -242,14 +258,17 @@ pub trait ToTypenum {
|
||||
}
|
||||
|
||||
unsafe impl<const T: usize> Dim for Const<T> {
|
||||
#[inline]
|
||||
fn try_to_usize() -> Option<usize> {
|
||||
Some(T)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn value(&self) -> usize {
|
||||
T
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn from_usize(dim: usize) -> Self {
|
||||
assert_eq!(dim, T);
|
||||
Self
|
||||
|
@ -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 {
|
||||
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()));
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
use crate::base::storage::{RawStorage, RawStorageMut};
|
||||
use crate::base::{
|
||||
Const, Dim, DimDiff, DimName, DimSub, Dynamic, Matrix, MatrixSlice, MatrixSliceMut, Scalar, U1,
|
||||
Const, Dim, DimDiff, DimName, DimSub, Dynamic, Matrix, MatrixView, MatrixViewMut, Scalar, U1,
|
||||
};
|
||||
|
||||
use std::ops;
|
||||
@ -378,7 +378,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
|
||||
/// ### Two-Dimensional Indices
|
||||
/// ```
|
||||
@ -669,7 +669,7 @@ macro_rules! impl_index_pair {
|
||||
$( $RConstraintType: $RConstraintBound $(<$( $RConstraintBoundParams $( = $REqBound )*),*>)* ,)*
|
||||
$( $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)]
|
||||
#[inline(always)]
|
||||
@ -682,13 +682,13 @@ macro_rules! impl_index_pair {
|
||||
#[doc(hidden)]
|
||||
#[inline(always)]
|
||||
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 (nrows, ncols) = matrix.shape_generic();
|
||||
|
||||
let data =
|
||||
SliceStorage::new_unchecked(&matrix.data,
|
||||
ViewStorage::new_unchecked(&matrix.data,
|
||||
(rows.lower(nrows), cols.lower(ncols)),
|
||||
(rows.length(nrows), cols.length(ncols)));
|
||||
|
||||
@ -705,18 +705,18 @@ macro_rules! impl_index_pair {
|
||||
$( $RConstraintType: $RConstraintBound $(<$( $RConstraintBoundParams $( = $REqBound )*),*>)* ,)*
|
||||
$( $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)]
|
||||
#[inline(always)]
|
||||
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 (nrows, ncols) = matrix.shape_generic();
|
||||
|
||||
let data =
|
||||
SliceStorageMut::new_unchecked(&mut matrix.data,
|
||||
ViewStorageMut::new_unchecked(&mut matrix.data,
|
||||
(rows.lower(nrows), cols.lower(ncols)),
|
||||
(rows.length(nrows), cols.length(ncols)));
|
||||
|
||||
|
@ -6,7 +6,7 @@ use std::mem;
|
||||
|
||||
use crate::base::dimension::{Dim, U1};
|
||||
use crate::base::storage::{RawStorage, RawStorageMut};
|
||||
use crate::base::{Matrix, MatrixSlice, MatrixSliceMut, Scalar};
|
||||
use crate::base::{Matrix, MatrixView, MatrixViewMut, Scalar};
|
||||
|
||||
macro_rules! iterator {
|
||||
(struct $Name:ident for $Storage:ident.$ptr: ident -> $Ptr:ty, $Ref:ty, $SRef: ty) => {
|
||||
@ -193,7 +193,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> {
|
||||
type Item = MatrixSlice<'a, T, U1, C, S::RStride, S::CStride>;
|
||||
type Item = MatrixView<'a, T, U1, C, S::RStride, S::CStride>;
|
||||
|
||||
#[inline]
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
@ -254,7 +254,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
|
||||
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]
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
@ -306,7 +306,7 @@ impl<'a, T, R: Dim, C: Dim, S: 'a + RawStorage<T, R, C>> ColumnIter<'a, T, R, C,
|
||||
}
|
||||
|
||||
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]
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
@ -367,7 +367,7 @@ 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
|
||||
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]
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
|
@ -104,13 +104,13 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
||||
/// - [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)
|
||||
///
|
||||
/// #### Vector and matrix slicing
|
||||
/// - [Creating matrix slices from `&[T]` <span style="float:right;">`from_slice`, `from_slice_with_strides`…</span>](#creating-matrix-slices-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)
|
||||
/// - [Slicing based on index and length <span style="float:right;">`row`, `columns`, `slice`…</span>](#slicing-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)
|
||||
/// - [Slicing based on ranges <span style="float:right;">`rows_range`, `columns_range`…</span>](#slicing-based-on-ranges)
|
||||
/// - [Mutable slicing based on ranges <span style="float:right;">`rows_range_mut`, `columns_range_mut`…</span>](#mutable-slicing-based-on-ranges)
|
||||
/// #### Vector and matrix views
|
||||
/// - [Creating matrix views from `&[T]` <span style="float:right;">`from_slice`, `from_slice_with_strides`…</span>](#creating-matrix-views-from-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)
|
||||
/// - [Views based on index and length <span style="float:right;">`row`, `columns`, `view`…</span>](#views-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)
|
||||
/// - [Views based on ranges <span style="float:right;">`rows_range`, `columns_range`…</span>](#views-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 filling <span style="float:right;">`fill`, `fill_diagonal`, `fill_with_identity`…</span>](#in-place-filling)
|
||||
@ -155,7 +155,6 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
||||
/// some concrete types for `T` and a compatible data storage type `S`).
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -168,6 +167,10 @@ pub type MatrixCross<T, R1, C1, R2, C2> =
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Matrix<T, R, C, S> {
|
||||
/// The data storage that contains all the matrix components. Disappointed?
|
||||
@ -457,7 +460,7 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
||||
/// ```
|
||||
/// # use nalgebra::DMatrix;
|
||||
/// 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.
|
||||
/// assert_eq!(mat.strides(), (1, 10));
|
||||
/// ```
|
||||
@ -750,6 +753,24 @@ impl<T, R: Dim, C: Dim, S: RawStorage<T, R, C>> Matrix<T, R, C, S> {
|
||||
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.
|
||||
///
|
||||
/// The initialization closure is given the first component of this matrix:
|
||||
@ -1626,7 +1647,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 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);
|
||||
res
|
||||
}
|
||||
@ -1654,7 +1675,7 @@ impl<T: Scalar + Zero, D: DimAdd<U1>, S: RawStorage<T, D>> Vector<T, D, S> {
|
||||
{
|
||||
if v[v.len() - 1].is_zero() {
|
||||
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 {
|
||||
None
|
||||
}
|
||||
@ -1674,7 +1695,7 @@ impl<T: Scalar, D: DimAdd<U1>, S: RawStorage<T, D>> Vector<T, D, S> {
|
||||
let mut res = Matrix::uninit(hnrows, Const::<1>);
|
||||
// This is basically a copy_from except that we warp the copied
|
||||
// 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));
|
||||
res[(len, 0)] = MaybeUninit::new(element);
|
||||
|
||||
@ -2200,3 +2221,28 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, D, S> Unit<Vector<T, D, S>>
|
||||
where
|
||||
T: Scalar,
|
||||
D: Dim,
|
||||
S: RawStorage<T, D, U1>,
|
||||
{
|
||||
/// Cast the components of `self` to another type.
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// # use nalgebra::Vector3;
|
||||
/// let v = Vector3::<f64>::y_axis();
|
||||
/// let v2 = v.cast::<f32>();
|
||||
/// assert_eq!(v2, Vector3::<f32>::y_axis());
|
||||
/// ```
|
||||
pub fn cast<T2: Scalar>(self) -> Unit<OVector<T2, D>>
|
||||
where
|
||||
T: Scalar,
|
||||
OVector<T2, D>: SupersetOf<Vector<T, D, S>>,
|
||||
DefaultAllocator: Allocator<T2, D, U1>,
|
||||
{
|
||||
Unit::new_unchecked(crate::convert_ref(self.as_ref()))
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,18 +12,19 @@ pub mod storage;
|
||||
|
||||
mod alias;
|
||||
mod alias_slice;
|
||||
mod alias_view;
|
||||
mod array_storage;
|
||||
mod cg;
|
||||
mod componentwise;
|
||||
#[macro_use]
|
||||
mod construction;
|
||||
mod construction_slice;
|
||||
mod construction_view;
|
||||
mod conversion;
|
||||
mod edition;
|
||||
pub mod indexing;
|
||||
mod matrix;
|
||||
mod matrix_simba;
|
||||
mod matrix_slice;
|
||||
mod matrix_view;
|
||||
mod norm;
|
||||
mod properties;
|
||||
mod scalar;
|
||||
@ -51,8 +52,9 @@ pub use self::dimension::*;
|
||||
|
||||
pub use self::alias::*;
|
||||
pub use self::alias_slice::*;
|
||||
pub use self::alias_view::*;
|
||||
pub use self::array_storage::*;
|
||||
pub use self::matrix_slice::*;
|
||||
pub use self::matrix_view::*;
|
||||
pub use self::storage::*;
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
pub use self::vec_storage::*;
|
||||
|
@ -14,7 +14,7 @@ use crate::base::constraint::{
|
||||
use crate::base::dimension::{Dim, DimMul, DimName, DimProd, Dynamic};
|
||||
use crate::base::storage::{Storage, StorageMut};
|
||||
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::uninit::{Init, InitStatus};
|
||||
use crate::{RawStorage, RawStorageMut, SimdComplexField};
|
||||
@ -703,8 +703,8 @@ where
|
||||
rhs: &Matrix<T, R2, C2, SB>,
|
||||
out: &mut Matrix<Status::Value, R3, C3, SC>,
|
||||
dot: impl Fn(
|
||||
&VectorSlice<'_, T, R1, SA::RStride, SA::CStride>,
|
||||
&VectorSlice<'_, T, R2, SB::RStride, SB::CStride>,
|
||||
&VectorView<'_, T, R1, SA::RStride, SA::CStride>,
|
||||
&VectorView<'_, T, R2, SB::RStride, SB::CStride>,
|
||||
) -> T,
|
||||
) where
|
||||
Status: InitStatus<T>,
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::allocator::Allocator;
|
||||
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 simba::scalar::{ClosedAdd, ClosedMul, Field, SupersetOf};
|
||||
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]
|
||||
pub fn compress_rows(
|
||||
&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>
|
||||
where
|
||||
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]
|
||||
pub fn compress_rows_tr(
|
||||
&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>
|
||||
where
|
||||
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(
|
||||
&self,
|
||||
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>
|
||||
where
|
||||
DefaultAllocator: Allocator<T, R>,
|
||||
|
@ -122,7 +122,7 @@ pub unsafe trait RawStorage<T, R: Dim, C: Dim = U1>: Sized {
|
||||
/// # Safety
|
||||
/// 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
|
||||
/// 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.
|
||||
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.
|
||||
///
|
||||
/// 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).
|
||||
pub unsafe trait RawStorageMut<T, R: Dim, C: Dim = U1>: RawStorage<T, R, C> {
|
||||
/// The matrix mutable data pointer.
|
||||
|
@ -21,7 +21,6 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
||||
/// in their documentation, read their dedicated pages directly.
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Hash, Copy)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -32,6 +31,10 @@ use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealF
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
// #[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Unit<T> {
|
||||
pub(crate) value: T,
|
||||
|
@ -40,7 +40,6 @@ use simba::scalar::{ClosedNeg, RealField};
|
||||
/// See <https://github.com/dimforge/nalgebra/issues/487>
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -52,6 +51,10 @@ use simba::scalar::{ClosedNeg, RealField};
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct DualQuaternion<T> {
|
||||
/// The real component of the quaternion
|
||||
|
@ -21,6 +21,7 @@ use crate::geometry::{AbstractRotation, Point, Translation};
|
||||
/// A 2D isometry is composed of:
|
||||
/// - 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 3D isometry is composed of:
|
||||
/// - A translation part of type [`Translation3`](crate::Translation3)
|
||||
/// - A rotation part which can either be a [`UnitQuaternion`](crate::UnitQuaternion) or a [`Rotation3`](crate::Rotation3).
|
||||
@ -433,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>>,
|
||||
{
|
||||
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);
|
||||
|
||||
res
|
||||
|
@ -153,8 +153,8 @@ where
|
||||
|
||||
#[inline]
|
||||
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 bottom = m.fixed_slice::<1, D>(D, 0);
|
||||
let rot = m.fixed_view::<D, D>(0, 0);
|
||||
let bottom = m.fixed_view::<1, D>(D, 0);
|
||||
|
||||
// Scalar types agree.
|
||||
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
||||
@ -168,7 +168,7 @@ where
|
||||
fn from_superset_unchecked(
|
||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
) -> 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 {
|
||||
vector: crate::convert_unchecked(t),
|
||||
};
|
||||
|
@ -19,7 +19,6 @@ use crate::geometry::{Point3, Projective3};
|
||||
|
||||
/// A 3D orthographic projection stored as a homogeneous 4x4 matrix.
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -31,6 +30,10 @@ use crate::geometry::{Point3, Projective3};
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Orthographic3<T> {
|
||||
|
@ -20,7 +20,6 @@ use crate::geometry::{Point3, Projective3};
|
||||
|
||||
/// A 3D perspective projection stored as a homogeneous 4x4 matrix.
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -32,6 +31,10 @@ use crate::geometry::{Point3, Projective3};
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Perspective3<T> {
|
||||
|
@ -213,7 +213,7 @@ where
|
||||
let mut res = crate::Matrix::uninit(DimNameSum::<D, U1>::name(), Const::<1>);
|
||||
// This is basically a copy_from except that we warp the copied
|
||||
// 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));
|
||||
res[(len, 0)] = MaybeUninit::new(T::one());
|
||||
|
||||
|
@ -113,7 +113,7 @@ where
|
||||
DefaultAllocator: Allocator<T, DimNameSum<D, U1>>,
|
||||
{
|
||||
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))
|
||||
} else {
|
||||
None
|
||||
@ -202,6 +202,24 @@ impl<T: Scalar> Point1<T> {
|
||||
/// assert_eq!(p.x, 1.0);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[cfg(not(feature = "cuda"))]
|
||||
pub const fn new(x: T) -> Self {
|
||||
Point {
|
||||
coords: Vector1::new(x),
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes this point from its components.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// # use nalgebra::Point1;
|
||||
/// let p = Point1::new(1.0);
|
||||
/// assert_eq!(p.x, 1.0);
|
||||
/// ```
|
||||
#[inline]
|
||||
#[cfg(feature = "cuda")]
|
||||
pub fn new(x: T) -> Self {
|
||||
Point {
|
||||
coords: Vector1::new(x),
|
||||
@ -216,6 +234,19 @@ macro_rules! componentwise_constructors_impl(
|
||||
#[doc = $doc]
|
||||
#[doc = "```"]
|
||||
#[inline]
|
||||
#[cfg(not(feature = "cuda"))]
|
||||
pub const fn new($($args: T),*) -> Self {
|
||||
Point { coords: $Vector::new($($args),*) }
|
||||
}
|
||||
|
||||
// TODO: always let new be const once CUDA updates its supported
|
||||
// nightly version to something more recent.
|
||||
#[doc = "Initializes this point from its components."]
|
||||
#[doc = "# Example\n```"]
|
||||
#[doc = $doc]
|
||||
#[doc = "```"]
|
||||
#[inline]
|
||||
#[cfg(feature = "cuda")]
|
||||
pub fn new($($args: T),*) -> Self {
|
||||
Point { coords: $Vector::new($($args),*) }
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ where
|
||||
|
||||
#[inline]
|
||||
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 {
|
||||
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::storage::{CStride, RStride};
|
||||
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};
|
||||
@ -23,7 +23,6 @@ use crate::geometry::{Point3, Rotation};
|
||||
/// that may be used as a rotation.
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -35,6 +34,10 @@ use crate::geometry::{Point3, Rotation};
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
pub struct Quaternion<T> {
|
||||
/// This quaternion as a 4D vector of coordinates in the `[ x, y, z, w ]` storage order.
|
||||
@ -195,7 +198,7 @@ where
|
||||
/// ```
|
||||
#[inline]
|
||||
#[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)
|
||||
}
|
||||
|
||||
@ -588,7 +591,7 @@ where
|
||||
#[inline]
|
||||
pub fn vector_mut(
|
||||
&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)
|
||||
}
|
||||
|
||||
@ -1327,7 +1330,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.
|
||||
///
|
||||
|
@ -49,7 +49,6 @@ use crate::geometry::Point;
|
||||
/// * [Conversion to a matrix <span style="float:right;">`matrix`, `to_homogeneous`…</span>](#conversion-to-a-matrix)
|
||||
///
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -61,6 +60,10 @@ use crate::geometry::Point;
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Rotation<T, const D: usize> {
|
||||
@ -265,7 +268,7 @@ impl<T: Scalar, const D: usize> Rotation<T, D> {
|
||||
// adding the additional traits `DimAdd` and `IsNotStaticOne`. Maybe
|
||||
// these things will get nicer once specialization lands in Rust.
|
||||
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
|
||||
}
|
||||
|
@ -211,8 +211,8 @@ where
|
||||
|
||||
#[inline]
|
||||
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 bottom = m.fixed_slice::<1, D>(D, 0);
|
||||
let rot = m.fixed_view::<D, D>(0, 0);
|
||||
let bottom = m.fixed_view::<1, D>(D, 0);
|
||||
|
||||
// Scalar types agree.
|
||||
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
||||
@ -226,7 +226,7 @@ where
|
||||
fn from_superset_unchecked(
|
||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
) -> 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()))
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,9 @@ use std::ops::Neg;
|
||||
|
||||
use crate::base::dimension::{U1, U2, U3};
|
||||
use crate::base::storage::Storage;
|
||||
use crate::base::{Matrix2, Matrix3, SMatrix, SVector, Unit, Vector, Vector1, Vector2, Vector3};
|
||||
use crate::base::{
|
||||
Matrix2, Matrix3, SMatrix, SVector, Unit, UnitVector3, Vector, Vector1, Vector2, Vector3,
|
||||
};
|
||||
|
||||
use crate::geometry::{Rotation2, Rotation3, UnitComplex, UnitQuaternion};
|
||||
|
||||
@ -730,9 +732,12 @@ where
|
||||
T: RealField,
|
||||
{
|
||||
if max_iter == 0 {
|
||||
max_iter = usize::max_value();
|
||||
max_iter = usize::MAX;
|
||||
}
|
||||
|
||||
// Using sqrt(eps) ensures we perturb with something larger than eps; clamp to eps to handle the case of eps > 1.0
|
||||
let eps_disturbance = eps.clone().sqrt().max(eps.clone() * eps.clone());
|
||||
let mut perturbation_axes = Vector3::x_axis();
|
||||
let mut rot = guess.into_inner();
|
||||
|
||||
for _ in 0..max_iter {
|
||||
@ -748,10 +753,36 @@ where
|
||||
if let Some((axis, angle)) = Unit::try_new_and_get(axisangle, eps.clone()) {
|
||||
rot = Rotation3::from_axis_angle(&axis, angle) * rot;
|
||||
} else {
|
||||
// Check if stuck in a maximum w.r.t. the norm (m - rot).norm()
|
||||
let mut perturbed = rot.clone();
|
||||
let norm_squared = (m - &rot).norm_squared();
|
||||
let mut new_norm_squared: T;
|
||||
|
||||
// Perturb until the new norm is significantly different
|
||||
loop {
|
||||
perturbed *=
|
||||
Rotation3::from_axis_angle(&perturbation_axes, eps_disturbance.clone());
|
||||
new_norm_squared = (m - &perturbed).norm_squared();
|
||||
if abs_diff_ne!(
|
||||
norm_squared,
|
||||
new_norm_squared,
|
||||
epsilon = T::default_epsilon()
|
||||
) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If new norm is larger, it's a minimum
|
||||
if norm_squared < new_norm_squared {
|
||||
break;
|
||||
}
|
||||
|
||||
// If not, continue from perturbed rotation, but use a different axes for the next perturbation
|
||||
perturbation_axes = UnitVector3::new_unchecked(perturbation_axes.yzx());
|
||||
rot = perturbed;
|
||||
}
|
||||
}
|
||||
|
||||
Self::from_matrix_unchecked(rot)
|
||||
}
|
||||
|
||||
@ -846,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.
|
||||
///
|
||||
|
@ -17,7 +17,6 @@ use crate::geometry::Point;
|
||||
|
||||
/// A scale which supports non-uniform scaling.
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -29,6 +28,10 @@ use crate::geometry::Point;
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Scale<T, const D: usize> {
|
||||
|
@ -102,7 +102,7 @@ where
|
||||
fn from_superset_unchecked(
|
||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
) -> Self {
|
||||
let v = m.fixed_slice::<D, D>(0, 0).diagonal();
|
||||
let v = m.fixed_view::<D, D>(0, 0).diagonal();
|
||||
Self {
|
||||
vector: crate::convert_unchecked(v),
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ impl<T: SimdRealField, R, const D: usize> Similarity<T, R, D> {
|
||||
{
|
||||
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()
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ where
|
||||
|
||||
#[inline]
|
||||
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
|
||||
.fixed_columns_mut::<1>(0)
|
||||
.try_normalize_mut(T2::zero())
|
||||
@ -128,7 +128,7 @@ where
|
||||
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.
|
||||
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
||||
// The normalized block part is a rotation.
|
||||
@ -145,22 +145,22 @@ where
|
||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
) -> Self {
|
||||
let mut mm = m.clone_owned();
|
||||
let na = mm.fixed_slice_mut::<D, 1>(0, 0).normalize_mut();
|
||||
let nb = mm.fixed_slice_mut::<D, 1>(0, 1).normalize_mut();
|
||||
let nc = mm.fixed_slice_mut::<D, 1>(0, 2).normalize_mut();
|
||||
let na = mm.fixed_view_mut::<D, 1>(0, 0).normalize_mut();
|
||||
let nb = mm.fixed_view_mut::<D, 1>(0, 1).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.
|
||||
|
||||
// TODO: could we avoid the explicit computation of the determinant?
|
||||
// (its sign is needed to see if the scaling factor is negative).
|
||||
if mm.fixed_slice::<D, D>(0, 0).determinant() < T2::zero() {
|
||||
mm.fixed_slice_mut::<D, 1>(0, 0).neg_mut();
|
||||
mm.fixed_slice_mut::<D, 1>(0, 1).neg_mut();
|
||||
mm.fixed_slice_mut::<D, 1>(0, 2).neg_mut();
|
||||
if mm.fixed_view::<D, D>(0, 0).determinant() < T2::zero() {
|
||||
mm.fixed_view_mut::<D, 1>(0, 0).neg_mut();
|
||||
mm.fixed_view_mut::<D, 1>(0, 1).neg_mut();
|
||||
mm.fixed_view_mut::<D, 1>(0, 2).neg_mut();
|
||||
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 {
|
||||
vector: crate::convert_unchecked(t),
|
||||
};
|
||||
|
@ -120,10 +120,10 @@ md_impl_all!(
|
||||
[ref val] => self * &rhs;
|
||||
[val ref] => &self * rhs;
|
||||
[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() {
|
||||
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);
|
||||
|
||||
if !n.is_zero() {
|
||||
@ -148,11 +148,11 @@ md_impl_all!(
|
||||
[ref val] => self * &rhs;
|
||||
[val ref] => &self * rhs;
|
||||
[ref ref] => {
|
||||
let transform = self.matrix().fixed_slice::<D, D>(0, 0);
|
||||
let translation = self.matrix().fixed_slice::<D, 1>(0, D);
|
||||
let transform = self.matrix().fixed_view::<D, D>(0, 0);
|
||||
let translation = self.matrix().fixed_view::<D, 1>(0, D);
|
||||
|
||||
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)]
|
||||
let n = normalizer.tr_dot(&rhs.coords) + unsafe { self.matrix().get_unchecked((D, D)).clone() };
|
||||
|
||||
|
@ -17,7 +17,6 @@ use crate::geometry::Point;
|
||||
|
||||
/// A translation.
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "rkyv-serialize", derive(bytecheck::CheckBytes))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize-no-std",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize),
|
||||
@ -29,6 +28,10 @@ use crate::geometry::Point;
|
||||
")
|
||||
)
|
||||
)]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv-serialize",
|
||||
archive_attr(derive(bytecheck::CheckBytes))
|
||||
)]
|
||||
#[cfg_attr(feature = "cuda", derive(cust_core::DeviceCopy))]
|
||||
#[derive(Copy, Clone)]
|
||||
pub struct Translation<T, const D: usize> {
|
||||
@ -154,7 +157,7 @@ impl<T: Scalar, const D: usize> Translation<T, D> {
|
||||
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();
|
||||
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
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ where
|
||||
|
||||
#[inline]
|
||||
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.
|
||||
m.iter().all(|e| SupersetOf::<T1>::is_in_subset(e)) &&
|
||||
@ -173,7 +173,7 @@ where
|
||||
fn from_superset_unchecked(
|
||||
m: &OMatrix<T2, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>>,
|
||||
) -> Self {
|
||||
let t = m.fixed_slice::<D, 1>(0, D);
|
||||
let t = m.fixed_view::<D, 1>(0, D);
|
||||
Self {
|
||||
vector: crate::convert_unchecked(t.into_owned()),
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ where
|
||||
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
|
||||
/// the `.angle()` method instead is more common.
|
||||
|
@ -131,10 +131,11 @@ where
|
||||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// #[macro_use] extern crate approx;
|
||||
/// # use nalgebra::UnitComplex;
|
||||
/// let c = UnitComplex::new(1.0f64);
|
||||
/// let c2 = c.cast::<f32>();
|
||||
/// assert_eq!(c2, UnitComplex::new(1.0f32));
|
||||
/// assert_relative_eq!(c2, UnitComplex::new(1.0f32));
|
||||
/// ```
|
||||
pub fn cast<To: Scalar>(self) -> UnitComplex<To>
|
||||
where
|
||||
|
59
src/lib.rs
59
src/lib.rs
@ -46,28 +46,34 @@ fn main() {
|
||||
**nalgebra** is meant to be a general-purpose, low-dimensional, linear algebra library, with
|
||||
an optimized set of tools for computer graphics and physics. Those features include:
|
||||
|
||||
* A single parametrizable type `Matrix` for vectors, (square or rectangular) matrices, and slices
|
||||
with dimensions known either at compile-time (using type-level integers) or at runtime.
|
||||
* A single parametrizable type [`Matrix`](Matrix) for vectors, (square or rectangular) matrices, and
|
||||
slices with dimensions known either at compile-time (using type-level integers) or at runtime.
|
||||
* Matrices and vectors with compile-time sizes are statically allocated while dynamic ones are
|
||||
allocated on the heap.
|
||||
* Convenient aliases for low-dimensional matrices and vectors: `Vector1` to `Vector6` and
|
||||
`Matrix1x1` to `Matrix6x6`, including rectangular matrices like `Matrix2x5`.
|
||||
* Points sizes known at compile time, and convenience aliases: `Point1` to `Point6`.
|
||||
* Translation (seen as a transformation that composes by multiplication): `Translation2`,
|
||||
`Translation3`.
|
||||
* Rotation matrices: `Rotation2`, `Rotation3`.
|
||||
* Quaternions: `Quaternion`, `UnitQuaternion` (for 3D rotation).
|
||||
* Unit complex numbers can be used for 2D rotation: `UnitComplex`.
|
||||
* Algebraic entities with a norm equal to one: `Unit<T>`, e.g., `Unit<Vector3<f32>>`.
|
||||
* Isometries (translation ⨯ rotation): `Isometry2`, `Isometry3`
|
||||
* Similarity transformations (translation ⨯ rotation ⨯ uniform scale): `Similarity2`, `Similarity3`.
|
||||
* Affine transformations stored as a homogeneous matrix: `Affine2`, `Affine3`.
|
||||
* Projective (i.e. invertible) transformations stored as a homogeneous matrix: `Projective2`,
|
||||
`Projective3`.
|
||||
* Convenient aliases for low-dimensional matrices and vectors: [`Vector1`](Vector1) to
|
||||
[`Vector6`](Vector6) and [`Matrix1x1`](Matrix1) to [`Matrix6x6`](Matrix6), including rectangular
|
||||
matrices like [`Matrix2x5`](Matrix2x5).
|
||||
* Points sizes known at compile time, and convenience aliases: [`Point1`](Point1) to
|
||||
[`Point6`](Point6).
|
||||
* Translation (seen as a transformation that composes by multiplication):
|
||||
[`Translation2`](Translation2), [`Translation3`](Translation3).
|
||||
* Rotation matrices: [`Rotation2`](Rotation2), [`Rotation3`](Rotation3).
|
||||
* Quaternions: [`Quaternion`](Quaternion), [`UnitQuaternion`](UnitQuaternion) (for 3D rotation).
|
||||
* Unit complex numbers can be used for 2D rotation: [`UnitComplex`](UnitComplex).
|
||||
* Algebraic entities with a norm equal to one: [`Unit<T>`](Unit), e.g., `Unit<Vector3<f32>>`.
|
||||
* Isometries (translation ⨯ rotation): [`Isometry2`](Isometry2), [`Isometry3`](Isometry3)
|
||||
* Similarity transformations (translation ⨯ rotation ⨯ uniform scale):
|
||||
[`Similarity2`](Similarity2), [`Similarity3`](Similarity3).
|
||||
* Affine transformations stored as a homogeneous matrix:
|
||||
[`Affine2`](Affine2), [`Affine3`](Affine3).
|
||||
* Projective (i.e. invertible) transformations stored as a homogeneous matrix:
|
||||
[`Projective2`](Projective2), [`Projective3`](Projective3).
|
||||
* General transformations that does not have to be invertible, stored as a homogeneous matrix:
|
||||
`Transform2`, `Transform3`.
|
||||
* 3D projections for computer graphics: `Perspective3`, `Orthographic3`.
|
||||
* Matrix factorizations: `Cholesky`, `QR`, `LU`, `FullPivLU`, `SVD`, `Schur`, `Hessenberg`, `SymmetricEigen`.
|
||||
[`Transform2`](Transform2), [`Transform3`](Transform3).
|
||||
* 3D projections for computer graphics: [`Perspective3`](Perspective3),
|
||||
[`Orthographic3`](Orthographic3).
|
||||
* Matrix factorizations: [`Cholesky`](Cholesky), [`QR`](QR), [`LU`](LU), [`FullPivLU`](FullPivLU),
|
||||
[`SVD`](SVD), [`Schur`](Schur), [`Hessenberg`](Hessenberg), [`SymmetricEigen`](SymmetricEigen).
|
||||
* Insertion and removal of rows of columns of a matrix.
|
||||
*/
|
||||
|
||||
@ -94,6 +100,19 @@ an optimized set of tools for computer graphics and physics. Those features incl
|
||||
)]
|
||||
#![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")]
|
||||
extern crate rand_package as rand;
|
||||
|
||||
@ -112,8 +131,6 @@ extern crate alloc;
|
||||
#[cfg(not(feature = "std"))]
|
||||
extern crate core as std;
|
||||
|
||||
#[cfg(feature = "io")]
|
||||
extern crate pest;
|
||||
#[macro_use]
|
||||
#[cfg(feature = "io")]
|
||||
extern crate pest_derive;
|
||||
|
@ -202,7 +202,7 @@ where
|
||||
);
|
||||
|
||||
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(
|
||||
self.off_diagonal
|
||||
.iter()
|
||||
@ -226,11 +226,11 @@ where
|
||||
let shift = self.axis_shift().0;
|
||||
|
||||
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.
|
||||
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 {
|
||||
self.diagonal[i].clone().signum()
|
||||
@ -260,13 +260,13 @@ where
|
||||
let shift = self.axis_shift().1;
|
||||
|
||||
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..);
|
||||
axis_packed.tr_copy_from(&axis);
|
||||
// TODO: sometimes, the axis might have a zero magnitude.
|
||||
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 {
|
||||
self.off_diagonal[i].clone().signum()
|
||||
@ -346,7 +346,7 @@ where
|
||||
// *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());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
@ -67,7 +67,7 @@ where
|
||||
*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;
|
||||
}
|
||||
|
||||
@ -228,7 +228,7 @@ where
|
||||
*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;
|
||||
continue;
|
||||
}
|
||||
@ -283,17 +283,17 @@ where
|
||||
self.chol.shape_generic().0.add(Const::<1>),
|
||||
self.chol.shape_generic().1.add(Const::<1>),
|
||||
);
|
||||
chol.slice_range_mut(..j, ..j)
|
||||
.copy_from(&self.chol.slice_range(..j, ..j));
|
||||
chol.slice_range_mut(..j, j + 1..)
|
||||
.copy_from(&self.chol.slice_range(..j, j..));
|
||||
chol.slice_range_mut(j + 1.., ..j)
|
||||
.copy_from(&self.chol.slice_range(j.., ..j));
|
||||
chol.slice_range_mut(j + 1.., j + 1..)
|
||||
.copy_from(&self.chol.slice_range(j.., j..));
|
||||
chol.view_range_mut(..j, ..j)
|
||||
.copy_from(&self.chol.view_range(..j, ..j));
|
||||
chol.view_range_mut(..j, j + 1..)
|
||||
.copy_from(&self.chol.view_range(..j, j..));
|
||||
chol.view_range_mut(j + 1.., ..j)
|
||||
.copy_from(&self.chol.view_range(j.., ..j));
|
||||
chol.view_range_mut(j + 1.., j + 1..)
|
||||
.copy_from(&self.chol.view_range(j.., j..));
|
||||
|
||||
// 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 (mut new_rowj_adjoint, mut new_colj) = col.rows_range_pair_mut(..j, j + 1..);
|
||||
@ -302,14 +302,14 @@ where
|
||||
"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
|
||||
let center_element = T::sqrt(col_j - T::from_real(new_rowj_adjoint.norm_squared()));
|
||||
chol[(j, j)] = center_element.clone();
|
||||
|
||||
// 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.gemm(
|
||||
-T::one() / center_element.clone(),
|
||||
@ -317,10 +317,10 @@ where
|
||||
&new_rowj_adjoint,
|
||||
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
|
||||
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(
|
||||
&mut bottom_right_corner,
|
||||
&mut new_colj,
|
||||
@ -348,17 +348,17 @@ where
|
||||
self.chol.shape_generic().0.sub(Const::<1>),
|
||||
self.chol.shape_generic().1.sub(Const::<1>),
|
||||
);
|
||||
chol.slice_range_mut(..j, ..j)
|
||||
.copy_from(&self.chol.slice_range(..j, ..j));
|
||||
chol.slice_range_mut(..j, j..)
|
||||
.copy_from(&self.chol.slice_range(..j, j + 1..));
|
||||
chol.slice_range_mut(j.., ..j)
|
||||
.copy_from(&self.chol.slice_range(j + 1.., ..j));
|
||||
chol.slice_range_mut(j.., j..)
|
||||
.copy_from(&self.chol.slice_range(j + 1.., j + 1..));
|
||||
chol.view_range_mut(..j, ..j)
|
||||
.copy_from(&self.chol.view_range(..j, ..j));
|
||||
chol.view_range_mut(..j, j..)
|
||||
.copy_from(&self.chol.view_range(..j, j + 1..));
|
||||
chol.view_range_mut(j.., ..j)
|
||||
.copy_from(&self.chol.view_range(j + 1.., ..j));
|
||||
chol.view_range_mut(j.., j..)
|
||||
.copy_from(&self.chol.view_range(j + 1.., j + 1..));
|
||||
|
||||
// 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 old_colj = workspace.rows_range_mut(j + 1..);
|
||||
Self::xx_rank_one_update(&mut bottom_right_corner, &mut old_colj, T::RealField::one());
|
||||
@ -370,7 +370,7 @@ where
|
||||
/// 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`
|
||||
/// 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>(
|
||||
chol: &mut Matrix<T, Dm, Dm, Sm>,
|
||||
x: &mut Vector<T, Rx, Sx>,
|
||||
@ -404,7 +404,7 @@ where
|
||||
beta += sigma_xj2 / diag2;
|
||||
// updates the terms of L
|
||||
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;
|
||||
xjplus.axpy(-xj.clone() / T::from_real(diag.clone()), &col_j, T::one());
|
||||
if gamma != crate::zero::<T::RealField>() {
|
||||
|
@ -78,7 +78,7 @@ where
|
||||
let mut diag = Matrix::uninit(min_nrows_ncols, Const::<1>);
|
||||
|
||||
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;
|
||||
matrix.swap_columns(i, col_piv);
|
||||
p.append_permutation(i, col_piv);
|
||||
@ -144,11 +144,11 @@ where
|
||||
let dim = self.diag.len();
|
||||
|
||||
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.
|
||||
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());
|
||||
}
|
||||
|
||||
@ -191,7 +191,7 @@ where
|
||||
let dim = self.diag.len();
|
||||
|
||||
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 mut rhs_rows = rhs.rows_range_mut(i..);
|
||||
@ -281,7 +281,7 @@ where
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ where
|
||||
}
|
||||
|
||||
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 col_piv = piv.1 + i;
|
||||
let diag = matrix[(row_piv, col_piv)].clone();
|
||||
|
@ -113,7 +113,7 @@ where
|
||||
let dim = self.hess.nrows();
|
||||
self.hess.fill_lower_triangle(T::zero(), 2);
|
||||
self.hess
|
||||
.slice_mut((1, 0), (dim - 1, dim - 1))
|
||||
.view_mut((1, 0), (dim - 1, dim - 1))
|
||||
.set_partial_diagonal(
|
||||
self.subdiag
|
||||
.iter()
|
||||
@ -132,7 +132,7 @@ where
|
||||
let dim = self.hess.nrows();
|
||||
let mut res = self.hess.clone();
|
||||
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(
|
||||
self.subdiag
|
||||
.iter()
|
||||
|
@ -128,10 +128,10 @@ where
|
||||
let mut res = OMatrix::identity_generic(dim, dim);
|
||||
|
||||
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 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());
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ where
|
||||
out.fill_with_identity();
|
||||
|
||||
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();
|
||||
|
||||
if diag.is_zero() {
|
||||
@ -100,7 +100,7 @@ where
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if diag.is_zero() {
|
||||
@ -338,7 +338,7 @@ where
|
||||
T: Scalar + Field,
|
||||
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;
|
||||
|
||||
@ -368,7 +368,7 @@ pub fn gauss_step_swap<T, R: Dim, C: Dim, S>(
|
||||
S: StorageMut<T, R, C>,
|
||||
{
|
||||
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;
|
||||
|
||||
|
@ -116,11 +116,11 @@ where
|
||||
let dim = self.diag.len();
|
||||
|
||||
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.
|
||||
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());
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ where
|
||||
let dim = self.diag.len();
|
||||
|
||||
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 mut rhs_rows = rhs.rows_range_mut(i..);
|
||||
@ -247,7 +247,7 @@ where
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,19 +174,19 @@ where
|
||||
{
|
||||
let krows = cmp::min(k + 4, end + 1);
|
||||
let mut work = work.rows_mut(0, krows);
|
||||
refl.reflect(&mut t.generic_slice_mut(
|
||||
refl.reflect(&mut t.generic_view_mut(
|
||||
(k, k),
|
||||
(Const::<3>, Dynamic::new(dim.value() - k)),
|
||||
));
|
||||
refl.reflect_rows(
|
||||
&mut t.generic_slice_mut((0, k), (Dynamic::new(krows), Const::<3>)),
|
||||
&mut t.generic_view_mut((0, k), (Dynamic::new(krows), Const::<3>)),
|
||||
&mut work,
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(ref mut q) = q {
|
||||
refl.reflect_rows(
|
||||
&mut q.generic_slice_mut((0, k), (dim, Const::<3>)),
|
||||
&mut q.generic_view_mut((0, k), (dim, Const::<3>)),
|
||||
work,
|
||||
);
|
||||
}
|
||||
@ -211,38 +211,37 @@ where
|
||||
|
||||
{
|
||||
let mut work = work.rows_mut(0, end + 1);
|
||||
refl.reflect(&mut t.generic_slice_mut(
|
||||
refl.reflect(
|
||||
&mut t.generic_view_mut(
|
||||
(m, m),
|
||||
(Const::<2>, Dynamic::new(dim.value() - m)),
|
||||
));
|
||||
),
|
||||
);
|
||||
refl.reflect_rows(
|
||||
&mut t.generic_slice_mut((0, m), (Dynamic::new(end + 1), Const::<2>)),
|
||||
&mut t.generic_view_mut((0, m), (Dynamic::new(end + 1), Const::<2>)),
|
||||
&mut work,
|
||||
);
|
||||
}
|
||||
|
||||
if let Some(ref mut q) = q {
|
||||
refl.reflect_rows(
|
||||
&mut q.generic_slice_mut((0, m), (dim, Const::<2>)),
|
||||
work,
|
||||
);
|
||||
refl.reflect_rows(&mut q.generic_view_mut((0, m), (dim, Const::<2>)), work);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 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();
|
||||
inv_rot.rotate(&mut t.generic_slice_mut(
|
||||
inv_rot.rotate(&mut t.generic_view_mut(
|
||||
(start, start),
|
||||
(Const::<2>, Dynamic::new(dim.value() - start)),
|
||||
));
|
||||
rot.rotate_rows(
|
||||
&mut t.generic_slice_mut((0, start), (Dynamic::new(end + 1), Const::<2>)),
|
||||
&mut t.generic_view_mut((0, start), (Dynamic::new(end + 1), Const::<2>)),
|
||||
);
|
||||
t[(end, start)] = T::zero();
|
||||
|
||||
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 +426,9 @@ where
|
||||
{
|
||||
let dim = m.shape_generic().0;
|
||||
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) => {
|
||||
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();
|
||||
inv_rot.rotate(&mut m);
|
||||
rot.rotate_rows(&mut m);
|
||||
@ -530,7 +529,7 @@ where
|
||||
if self.nrows() == 2 {
|
||||
// TODO: can we avoid this slicing
|
||||
// (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) {
|
||||
Some((a, b)) => {
|
||||
work[0] = a;
|
||||
|
@ -5,7 +5,7 @@ use crate::base::allocator::Allocator;
|
||||
use crate::base::constraint::{SameNumberOfRows, ShapeConstraint};
|
||||
use crate::base::dimension::{Dim, U1};
|
||||
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> {
|
||||
/// 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..)
|
||||
.axpy(-coeff, &self.slice_range(i + 1.., i), T::one());
|
||||
.axpy(-coeff, &self.view_range(i + 1.., i), T::one());
|
||||
}
|
||||
|
||||
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 {
|
||||
let coeff = unsafe { bcol.vget_unchecked(i).clone() } / diag.clone();
|
||||
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)
|
||||
.axpy(-coeff, &self.slice_range(..i, i), T::one());
|
||||
.axpy(-coeff, &self.view_range(..i, i), T::one());
|
||||
}
|
||||
|
||||
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>,
|
||||
conjugate: impl Fn(T) -> T,
|
||||
dot: impl Fn(
|
||||
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
||||
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
||||
&DVectorView<'_, T, S::RStride, S::CStride>,
|
||||
&DVectorView<'_, T, S2::RStride, S2::CStride>,
|
||||
) -> T,
|
||||
) -> bool
|
||||
where
|
||||
@ -387,7 +387,7 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||
let dim = self.nrows();
|
||||
|
||||
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 {
|
||||
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>,
|
||||
conjugate: impl Fn(T) -> T,
|
||||
dot: impl Fn(
|
||||
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
||||
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
||||
&DVectorView<'_, T, S::RStride, S::CStride>,
|
||||
&DVectorView<'_, T, S2::RStride, S2::CStride>,
|
||||
) -> T,
|
||||
) -> bool
|
||||
where
|
||||
@ -422,7 +422,7 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
||||
let dim = self.nrows();
|
||||
|
||||
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 {
|
||||
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..)
|
||||
.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 {
|
||||
let coeff = unsafe { bcol.vget_unchecked(i).clone() } / diag.clone();
|
||||
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)
|
||||
.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>,
|
||||
conjugate: impl Fn(T) -> T,
|
||||
dot: impl Fn(
|
||||
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
||||
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
||||
&DVectorView<'_, T, S::RStride, S::CStride>,
|
||||
&DVectorView<'_, T, S2::RStride, S2::CStride>,
|
||||
) -> T,
|
||||
) where
|
||||
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();
|
||||
|
||||
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 {
|
||||
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>,
|
||||
conjugate: impl Fn(T) -> T,
|
||||
dot: impl Fn(
|
||||
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
||||
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
||||
&DVectorView<'_, T, S::RStride, S::CStride>,
|
||||
&DVectorView<'_, T, S2::RStride, S2::CStride>,
|
||||
) -> T,
|
||||
) where
|
||||
S2: StorageMut<T, R2, U1>,
|
||||
ShapeConstraint: SameNumberOfRows<R2, D>,
|
||||
{
|
||||
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 {
|
||||
let b_i = b.vget_unchecked_mut(i);
|
||||
|
6
src/third_party/glam/common/glam_matrix.rs
vendored
6
src/third_party/glam/common/glam_matrix.rs
vendored
@ -14,7 +14,7 @@ macro_rules! impl_vec_conversion(
|
||||
impl From<$Vec2> for Vector2<$N> {
|
||||
#[inline]
|
||||
fn from(e: $Vec2) -> Vector2<$N> {
|
||||
(*e.as_ref()).into()
|
||||
<[$N;2]>::from(e).into()
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ macro_rules! impl_vec_conversion(
|
||||
impl From<$Vec3> for Vector3<$N> {
|
||||
#[inline]
|
||||
fn from(e: $Vec3) -> Vector3<$N> {
|
||||
(*e.as_ref()).into()
|
||||
<[$N;3]>::from(e).into()
|
||||
}
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ macro_rules! impl_vec_conversion(
|
||||
impl From<$Vec4> for Vector4<$N> {
|
||||
#[inline]
|
||||
fn from(e: $Vec4) -> Vector4<$N> {
|
||||
(*e.as_ref()).into()
|
||||
<[$N;4]>::from(e).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
6
src/third_party/glam/common/glam_point.rs
vendored
6
src/third_party/glam/common/glam_point.rs
vendored
@ -9,7 +9,7 @@ macro_rules! impl_point_conversion(
|
||||
impl From<$Vec2> for Point2<$N> {
|
||||
#[inline]
|
||||
fn from(e: $Vec2) -> Point2<$N> {
|
||||
(*e.as_ref()).into()
|
||||
<[$N;2]>::from(e).into()
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,7 @@ macro_rules! impl_point_conversion(
|
||||
impl From<$Vec3> for Point3<$N> {
|
||||
#[inline]
|
||||
fn from(e: $Vec3) -> Point3<$N> {
|
||||
(*e.as_ref()).into()
|
||||
<[$N;3]>::from(e).into()
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ macro_rules! impl_point_conversion(
|
||||
impl From<$Vec4> for Point4<$N> {
|
||||
#[inline]
|
||||
fn from(e: $Vec4) -> Point4<$N> {
|
||||
(*e.as_ref()).into()
|
||||
<[$N;4]>::from(e).into()
|
||||
}
|
||||
}
|
||||
|
||||
|
4
src/third_party/glam/mod.rs
vendored
4
src/third_party/glam/mod.rs
vendored
@ -12,3 +12,7 @@ mod v018;
|
||||
mod v019;
|
||||
#[cfg(feature = "glam020")]
|
||||
mod v020;
|
||||
#[cfg(feature = "glam021")]
|
||||
mod v021;
|
||||
#[cfg(feature = "glam022")]
|
||||
mod v022;
|
||||
|
18
src/third_party/glam/v021/mod.rs
vendored
Normal file
18
src/third_party/glam/v021/mod.rs
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#[path = "../common/glam_isometry.rs"]
|
||||
mod glam_isometry;
|
||||
#[path = "../common/glam_matrix.rs"]
|
||||
mod glam_matrix;
|
||||
#[path = "../common/glam_point.rs"]
|
||||
mod glam_point;
|
||||
#[path = "../common/glam_quaternion.rs"]
|
||||
mod glam_quaternion;
|
||||
#[path = "../common/glam_rotation.rs"]
|
||||
mod glam_rotation;
|
||||
#[path = "../common/glam_similarity.rs"]
|
||||
mod glam_similarity;
|
||||
#[path = "../common/glam_translation.rs"]
|
||||
mod glam_translation;
|
||||
#[path = "../common/glam_unit_complex.rs"]
|
||||
mod glam_unit_complex;
|
||||
|
||||
pub(self) use glam021 as glam;
|
18
src/third_party/glam/v022/mod.rs
vendored
Normal file
18
src/third_party/glam/v022/mod.rs
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
#[path = "../common/glam_isometry.rs"]
|
||||
mod glam_isometry;
|
||||
#[path = "../common/glam_matrix.rs"]
|
||||
mod glam_matrix;
|
||||
#[path = "../common/glam_point.rs"]
|
||||
mod glam_point;
|
||||
#[path = "../common/glam_quaternion.rs"]
|
||||
mod glam_quaternion;
|
||||
#[path = "../common/glam_rotation.rs"]
|
||||
mod glam_rotation;
|
||||
#[path = "../common/glam_similarity.rs"]
|
||||
mod glam_similarity;
|
||||
#[path = "../common/glam_translation.rs"]
|
||||
mod glam_translation;
|
||||
#[path = "../common/glam_unit_complex.rs"]
|
||||
mod glam_unit_complex;
|
||||
|
||||
pub(self) use glam022 as glam;
|
@ -7,7 +7,7 @@ use na::{
|
||||
RowVector5, RowVector6, Similarity3, Transform3, UnitQuaternion, Vector1, Vector2, Vector3,
|
||||
Vector4, Vector5, Vector6,
|
||||
};
|
||||
use na::{DMatrix, DMatrixSlice, DMatrixSliceMut, MatrixSlice, MatrixSliceMut};
|
||||
use na::{DMatrix, DMatrixView, DMatrixViewMut, MatrixView, MatrixViewMut};
|
||||
use na::{U1, U3, U4};
|
||||
|
||||
use crate::proptest::*;
|
||||
@ -266,24 +266,24 @@ fn matrix_slice_from_matrix_ref() {
|
||||
// Note: these have to be macros, and not functions, because the input type is different
|
||||
// across the different tests. Moreover, the output type depends on the stride of the input,
|
||||
// which is different for static and dynamic matrices.
|
||||
macro_rules! dynamic_slice {
|
||||
macro_rules! dynamic_view {
|
||||
($mref:expr) => {
|
||||
DMatrixSlice::<_>::from($mref)
|
||||
DMatrixView::<_>::from($mref)
|
||||
};
|
||||
}
|
||||
macro_rules! dynamic_slice_mut {
|
||||
macro_rules! dynamic_view_mut {
|
||||
($mref:expr) => {
|
||||
DMatrixSliceMut::<_>::from($mref)
|
||||
DMatrixViewMut::<_>::from($mref)
|
||||
};
|
||||
}
|
||||
macro_rules! fixed_slice {
|
||||
macro_rules! fixed_view {
|
||||
($mref:expr) => {
|
||||
MatrixSlice::<_, U3, U4, U1, U3>::from($mref)
|
||||
MatrixView::<_, U3, U4, U1, U3>::from($mref)
|
||||
};
|
||||
}
|
||||
macro_rules! fixed_slice_mut {
|
||||
macro_rules! fixed_view_mut {
|
||||
($mref:expr) => {
|
||||
MatrixSliceMut::<_, U3, U4, U1, U3>::from($mref)
|
||||
MatrixViewMut::<_, U3, U4, U1, U3>::from($mref)
|
||||
};
|
||||
}
|
||||
|
||||
@ -291,66 +291,66 @@ fn matrix_slice_from_matrix_ref() {
|
||||
// Self and RHS. See issue #674. Once this is implemented, we can remove `into_owned`
|
||||
// from the below tests.
|
||||
|
||||
// Construct slices from reference to a
|
||||
// Construct views from reference to a
|
||||
{
|
||||
assert_eq!(a, fixed_slice!(&a).into_owned());
|
||||
assert_eq!(d, dynamic_slice!(&a).into_owned());
|
||||
assert_eq!(a, fixed_view!(&a).into_owned());
|
||||
assert_eq!(d, dynamic_view!(&a).into_owned());
|
||||
}
|
||||
|
||||
// Construct slices from mutable reference to a
|
||||
// Construct views from mutable reference to a
|
||||
{
|
||||
let mut a_clone = a.clone();
|
||||
assert_eq!(a, fixed_slice!(&mut a_clone).into_owned());
|
||||
assert_eq!(d, dynamic_slice!(&mut a_clone).into_owned());
|
||||
assert_eq!(a, fixed_view!(&mut a_clone).into_owned());
|
||||
assert_eq!(d, dynamic_view!(&mut a_clone).into_owned());
|
||||
}
|
||||
|
||||
// Construct mutable slices from mutable reference to a
|
||||
{
|
||||
let mut a_clone = a.clone();
|
||||
assert_eq!(a, fixed_slice_mut!(&mut a_clone).into_owned());
|
||||
assert_eq!(d, dynamic_slice_mut!(&mut a_clone).into_owned());
|
||||
assert_eq!(a, fixed_view_mut!(&mut a_clone).into_owned());
|
||||
assert_eq!(d, dynamic_view_mut!(&mut a_clone).into_owned());
|
||||
}
|
||||
|
||||
// Construct slices from reference to d
|
||||
{
|
||||
assert_eq!(a, fixed_slice!(&d).into_owned());
|
||||
assert_eq!(d, dynamic_slice!(&d).into_owned());
|
||||
assert_eq!(a, fixed_view!(&d).into_owned());
|
||||
assert_eq!(d, dynamic_view!(&d).into_owned());
|
||||
}
|
||||
|
||||
// Construct slices from mutable reference to d
|
||||
{
|
||||
let mut d_clone = a.clone();
|
||||
assert_eq!(a, fixed_slice!(&mut d_clone).into_owned());
|
||||
assert_eq!(d, dynamic_slice!(&mut d_clone).into_owned());
|
||||
assert_eq!(a, fixed_view!(&mut d_clone).into_owned());
|
||||
assert_eq!(d, dynamic_view!(&mut d_clone).into_owned());
|
||||
}
|
||||
|
||||
// Construct mutable slices from mutable reference to d
|
||||
{
|
||||
let mut d_clone = d.clone();
|
||||
assert_eq!(a, fixed_slice_mut!(&mut d_clone).into_owned());
|
||||
assert_eq!(d, dynamic_slice_mut!(&mut d_clone).into_owned());
|
||||
assert_eq!(a, fixed_view_mut!(&mut d_clone).into_owned());
|
||||
assert_eq!(d, dynamic_view_mut!(&mut d_clone).into_owned());
|
||||
}
|
||||
|
||||
// Construct slices from a slice of a
|
||||
{
|
||||
let mut a_slice = fixed_slice!(&a);
|
||||
assert_eq!(a, fixed_slice!(&a_slice).into_owned());
|
||||
assert_eq!(a, fixed_slice!(&mut a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_slice!(&a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_slice!(&mut a_slice).into_owned());
|
||||
let mut a_slice = fixed_view!(&a);
|
||||
assert_eq!(a, fixed_view!(&a_slice).into_owned());
|
||||
assert_eq!(a, fixed_view!(&mut a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_view!(&a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_view!(&mut a_slice).into_owned());
|
||||
}
|
||||
|
||||
// Construct slices from a slice mut of a
|
||||
{
|
||||
// Need a clone of a here, so that we can both have a mutable borrow and compare equality
|
||||
let mut a_clone = a.clone();
|
||||
let mut a_slice = fixed_slice_mut!(&mut a_clone);
|
||||
let mut a_slice = fixed_view_mut!(&mut a_clone);
|
||||
|
||||
assert_eq!(a, fixed_slice!(&a_slice).into_owned());
|
||||
assert_eq!(a, fixed_slice!(&mut a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_slice!(&a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_slice!(&mut a_slice).into_owned());
|
||||
assert_eq!(a, fixed_slice_mut!(&mut a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_slice_mut!(&mut a_slice).into_owned());
|
||||
assert_eq!(a, fixed_view!(&a_slice).into_owned());
|
||||
assert_eq!(a, fixed_view!(&mut a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_view!(&a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_view!(&mut a_slice).into_owned());
|
||||
assert_eq!(a, fixed_view_mut!(&mut a_slice).into_owned());
|
||||
assert_eq!(d, dynamic_view_mut!(&mut a_slice).into_owned());
|
||||
}
|
||||
}
|
||||
|
@ -1066,43 +1066,43 @@ fn partial_eq_different_types() {
|
||||
let static_mat = Matrix2x4::new(1, 2, 3, 4, 5, 6, 7, 8);
|
||||
|
||||
let mut typenum_static_mat = OMatrix::<u8, Const<1024>, Const<4>>::zeros();
|
||||
let mut slice = typenum_static_mat.slice_mut((0, 0), (2, 4));
|
||||
slice += static_mat;
|
||||
let mut view = typenum_static_mat.view_mut((0, 0), (2, 4));
|
||||
view += static_mat;
|
||||
|
||||
let fslice_of_dmat = dynamic_mat.fixed_slice::<2, 2>(0, 0);
|
||||
let dslice_of_dmat = dynamic_mat.slice((0, 0), (2, 2));
|
||||
let fslice_of_smat = static_mat.fixed_slice::<2, 2>(0, 0);
|
||||
let dslice_of_smat = static_mat.slice((0, 0), (2, 2));
|
||||
let fview_of_dmat = dynamic_mat.fixed_view::<2, 2>(0, 0);
|
||||
let dview_of_dmat = dynamic_mat.view((0, 0), (2, 2));
|
||||
let fview_of_smat = static_mat.fixed_view::<2, 2>(0, 0);
|
||||
let dview_of_smat = static_mat.view((0, 0), (2, 2));
|
||||
|
||||
assert_eq!(dynamic_mat, static_mat);
|
||||
assert_eq!(static_mat, dynamic_mat);
|
||||
|
||||
assert_eq!(dynamic_mat, slice);
|
||||
assert_eq!(slice, dynamic_mat);
|
||||
assert_eq!(dynamic_mat, view);
|
||||
assert_eq!(view, dynamic_mat);
|
||||
|
||||
assert_eq!(static_mat, slice);
|
||||
assert_eq!(slice, static_mat);
|
||||
assert_eq!(static_mat, view);
|
||||
assert_eq!(view, static_mat);
|
||||
|
||||
assert_eq!(fslice_of_dmat, dslice_of_dmat);
|
||||
assert_eq!(dslice_of_dmat, fslice_of_dmat);
|
||||
assert_eq!(fview_of_dmat, dview_of_dmat);
|
||||
assert_eq!(dview_of_dmat, fview_of_dmat);
|
||||
|
||||
assert_eq!(fslice_of_dmat, fslice_of_smat);
|
||||
assert_eq!(fslice_of_smat, fslice_of_dmat);
|
||||
assert_eq!(fview_of_dmat, fview_of_smat);
|
||||
assert_eq!(fview_of_smat, fview_of_dmat);
|
||||
|
||||
assert_eq!(fslice_of_dmat, dslice_of_smat);
|
||||
assert_eq!(dslice_of_smat, fslice_of_dmat);
|
||||
assert_eq!(fview_of_dmat, dview_of_smat);
|
||||
assert_eq!(dview_of_smat, fview_of_dmat);
|
||||
|
||||
assert_eq!(dslice_of_dmat, fslice_of_smat);
|
||||
assert_eq!(fslice_of_smat, dslice_of_dmat);
|
||||
assert_eq!(dview_of_dmat, fview_of_smat);
|
||||
assert_eq!(fview_of_smat, dview_of_dmat);
|
||||
|
||||
assert_eq!(dslice_of_dmat, dslice_of_smat);
|
||||
assert_eq!(dslice_of_smat, dslice_of_dmat);
|
||||
assert_eq!(dview_of_dmat, dview_of_smat);
|
||||
assert_eq!(dview_of_smat, dview_of_dmat);
|
||||
|
||||
assert_eq!(fslice_of_smat, dslice_of_smat);
|
||||
assert_eq!(dslice_of_smat, fslice_of_smat);
|
||||
assert_eq!(fview_of_smat, dview_of_smat);
|
||||
assert_eq!(dview_of_smat, fview_of_smat);
|
||||
|
||||
assert_ne!(dynamic_mat, dslice_of_smat);
|
||||
assert_ne!(dslice_of_smat, dynamic_mat);
|
||||
assert_ne!(dynamic_mat, dview_of_smat);
|
||||
assert_ne!(dview_of_smat, dynamic_mat);
|
||||
|
||||
// TODO - implement those comparisons
|
||||
// assert_ne!(static_mat, typenum_static_mat);
|
||||
|
@ -1,22 +1,22 @@
|
||||
#![allow(non_snake_case)]
|
||||
|
||||
use na::{
|
||||
DMatrix, DMatrixSlice, DMatrixSliceMut, Matrix2, Matrix2x3, Matrix2x4, Matrix2x6, Matrix3,
|
||||
Matrix3x2, Matrix3x4, Matrix4x2, Matrix6x2, MatrixSlice2, MatrixSlice2x3, MatrixSlice2xX,
|
||||
MatrixSlice3, MatrixSlice3x2, MatrixSliceMut2, MatrixSliceMut2x3, MatrixSliceMut2xX,
|
||||
MatrixSliceMut3, MatrixSliceMut3x2, MatrixSliceMutXx3, MatrixSliceXx3, RowVector4, Vector3,
|
||||
DMatrix, DMatrixView, DMatrixViewMut, Matrix2, Matrix2x3, Matrix2x4, Matrix2x6, Matrix3,
|
||||
Matrix3x2, Matrix3x4, Matrix4x2, Matrix6x2, MatrixView2, MatrixView2x3, MatrixView2xX,
|
||||
MatrixView3, MatrixView3x2, MatrixViewMut2, MatrixViewMut2x3, MatrixViewMut2xX, MatrixViewMut3,
|
||||
MatrixViewMut3x2, MatrixViewMutXx3, MatrixViewXx3, RowVector4, Vector3,
|
||||
};
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn nested_fixed_slices() {
|
||||
fn nested_fixed_views() {
|
||||
let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
||||
21.0, 22.0, 23.0, 24.0,
|
||||
31.0, 32.0, 33.0, 34.0);
|
||||
|
||||
let s1 = a.fixed_slice::<3, 3>(0, 1); // Simple slice.
|
||||
let s2 = s1.fixed_slice::<2, 2>(1, 1); // Slice of slice.
|
||||
let s3 = s1.fixed_slice_with_steps::<2, 2>((0, 0), (1, 1)); // Slice of slice with steps.
|
||||
let s1 = a.fixed_view::<3, 3>(0, 1); // Simple view.
|
||||
let s2 = s1.fixed_view::<2, 2>(1, 1); // View of view.
|
||||
let s3 = s1.fixed_view_with_steps::<2, 2>((0, 0), (1, 1)); // View of view with steps.
|
||||
|
||||
let expected_owned_s1 = Matrix3::new(12.0, 13.0, 14.0,
|
||||
22.0, 23.0, 24.0,
|
||||
@ -35,14 +35,14 @@ fn nested_fixed_slices() {
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn nested_slices() {
|
||||
fn nested_views() {
|
||||
let a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
||||
21.0, 22.0, 23.0, 24.0,
|
||||
31.0, 32.0, 33.0, 34.0);
|
||||
|
||||
let s1 = a.slice((0, 1), (3, 3));
|
||||
let s2 = s1.slice((1, 1), (2, 2));
|
||||
let s3 = s1.slice_with_steps((0, 0), (2, 2), (1, 1));
|
||||
let s1 = a.view((0, 1), (3, 3));
|
||||
let s2 = s1.view((1, 1), (2, 2));
|
||||
let s3 = s1.view_with_steps((0, 0), (2, 2), (1, 1));
|
||||
|
||||
let expected_owned_s1 = DMatrix::from_row_slice(3, 3, &[ 12.0, 13.0, 14.0,
|
||||
22.0, 23.0, 24.0,
|
||||
@ -61,14 +61,14 @@ fn nested_slices() {
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn slice_mut() {
|
||||
fn view_mut() {
|
||||
let mut a = Matrix3x4::new(11.0, 12.0, 13.0, 14.0,
|
||||
21.0, 22.0, 23.0, 24.0,
|
||||
31.0, 32.0, 33.0, 34.0);
|
||||
|
||||
{
|
||||
// We modify `a` through the mutable slice.
|
||||
let mut s1 = a.slice_with_steps_mut((0, 1), (2, 2), (1, 1));
|
||||
// We modify `a` through the mutable view.
|
||||
let mut s1 = a.view_with_steps_mut((0, 1), (2, 2), (1, 1));
|
||||
s1.fill(0.0);
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ fn slice_mut() {
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn nested_row_slices() {
|
||||
fn nested_row_views() {
|
||||
let a = Matrix6x2::new(11.0, 12.0,
|
||||
21.0, 22.0,
|
||||
31.0, 32.0,
|
||||
@ -105,7 +105,7 @@ fn nested_row_slices() {
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn row_slice_mut() {
|
||||
fn row_view_mut() {
|
||||
let mut a = Matrix6x2::new(11.0, 12.0,
|
||||
21.0, 22.0,
|
||||
31.0, 32.0,
|
||||
@ -113,7 +113,7 @@ fn row_slice_mut() {
|
||||
51.0, 52.0,
|
||||
61.0, 62.0);
|
||||
{
|
||||
// We modify `a` through the mutable slice.
|
||||
// We modify `a` through the mutable view.
|
||||
let mut s1 = a.rows_with_step_mut(1, 3, 1);
|
||||
s1.fill(0.0);
|
||||
}
|
||||
@ -130,7 +130,7 @@ fn row_slice_mut() {
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn nested_col_slices() {
|
||||
fn nested_col_views() {
|
||||
let a = Matrix2x6::new(11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
||||
21.0, 22.0, 23.0, 24.0, 25.0, 26.0);
|
||||
let s1 = a.fixed_columns::<4>(1);
|
||||
@ -148,12 +148,12 @@ fn nested_col_slices() {
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn col_slice_mut() {
|
||||
fn col_view_mut() {
|
||||
let mut a = Matrix2x6::new(11.0, 12.0, 13.0, 14.0, 15.0, 16.0,
|
||||
21.0, 22.0, 23.0, 24.0, 25.0, 26.0);
|
||||
|
||||
{
|
||||
// We modify `a` through the mutable slice.
|
||||
// We modify `a` through the mutable view.
|
||||
let mut s1 = a.columns_with_step_mut(1, 3, 1);
|
||||
s1.fill(0.0);
|
||||
}
|
||||
@ -203,7 +203,7 @@ fn columns_range_pair() {
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn new_slice() {
|
||||
fn new_from_slice() {
|
||||
let data = [ 1.0, 2.0, 3.0, 4.0,
|
||||
5.0, 6.0, 7.0, 8.0,
|
||||
9.0, 10.0, 11.0, 12.0 ];
|
||||
@ -214,13 +214,13 @@ fn new_slice() {
|
||||
let expected3x2 = Matrix3x2::from_column_slice(&data);
|
||||
|
||||
{
|
||||
let m2 = MatrixSlice2::from_slice(&data);
|
||||
let m3 = MatrixSlice3::from_slice(&data);
|
||||
let m2x3 = MatrixSlice2x3::from_slice(&data);
|
||||
let m3x2 = MatrixSlice3x2::from_slice(&data);
|
||||
let m2xX = MatrixSlice2xX::from_slice(&data, 3);
|
||||
let mXx3 = MatrixSliceXx3::from_slice(&data, 2);
|
||||
let mXxX = DMatrixSlice::from_slice(&data, 2, 3);
|
||||
let m2 = MatrixView2::from_slice(&data);
|
||||
let m3 = MatrixView3::from_slice(&data);
|
||||
let m2x3 = MatrixView2x3::from_slice(&data);
|
||||
let m3x2 = MatrixView3x2::from_slice(&data);
|
||||
let m2xX = MatrixView2xX::from_slice(&data, 3);
|
||||
let mXx3 = MatrixViewXx3::from_slice(&data, 2);
|
||||
let mXxX = DMatrixView::from_slice(&data, 2, 3);
|
||||
|
||||
assert!(m2.eq(&expected2));
|
||||
assert!(m3.eq(&expected3));
|
||||
@ -234,7 +234,7 @@ fn new_slice() {
|
||||
|
||||
#[test]
|
||||
#[rustfmt::skip]
|
||||
fn new_slice_mut() {
|
||||
fn new_from_slice_mut() {
|
||||
let data = [ 1.0, 2.0, 3.0, 4.0,
|
||||
5.0, 6.0, 7.0, 8.0,
|
||||
9.0, 10.0, 11.0, 12.0 ];
|
||||
@ -252,31 +252,31 @@ fn new_slice_mut() {
|
||||
9.0, 10.0, 11.0, 12.0 ];
|
||||
|
||||
let mut data_mut = data.clone();
|
||||
MatrixSliceMut2::from_slice(&mut data_mut).fill(0.0);
|
||||
MatrixViewMut2::from_slice(&mut data_mut).fill(0.0);
|
||||
assert!(data_mut == expected2);
|
||||
|
||||
let mut data_mut = data.clone();
|
||||
MatrixSliceMut3::from_slice(&mut data_mut).fill(0.0);
|
||||
MatrixViewMut3::from_slice(&mut data_mut).fill(0.0);
|
||||
assert!(data_mut == expected3);
|
||||
|
||||
let mut data_mut = data.clone();
|
||||
MatrixSliceMut2x3::from_slice(&mut data_mut).fill(0.0);
|
||||
MatrixViewMut2x3::from_slice(&mut data_mut).fill(0.0);
|
||||
assert!(data_mut == expected2x3);
|
||||
|
||||
let mut data_mut = data.clone();
|
||||
MatrixSliceMut3x2::from_slice(&mut data_mut).fill(0.0);
|
||||
MatrixViewMut3x2::from_slice(&mut data_mut).fill(0.0);
|
||||
assert!(data_mut == expected3x2);
|
||||
|
||||
let mut data_mut = data.clone();
|
||||
MatrixSliceMut2xX::from_slice(&mut data_mut, 3).fill(0.0);
|
||||
MatrixViewMut2xX::from_slice(&mut data_mut, 3).fill(0.0);
|
||||
assert!(data_mut == expected2x3);
|
||||
|
||||
let mut data_mut = data.clone();
|
||||
MatrixSliceMutXx3::from_slice(&mut data_mut, 2).fill(0.0);
|
||||
MatrixViewMutXx3::from_slice(&mut data_mut, 2).fill(0.0);
|
||||
assert!(data_mut == expected2x3);
|
||||
|
||||
let mut data_mut = data.clone();
|
||||
DMatrixSliceMut::from_slice(&mut data_mut, 2, 3).fill(0.0);
|
||||
DMatrixViewMut::from_slice(&mut data_mut, 2, 3).fill(0.0);
|
||||
assert!(data_mut == expected2x3);
|
||||
}
|
||||
|
||||
@ -324,14 +324,14 @@ fn columns_with_step_out_of_bounds() {
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn slice_out_of_bounds() {
|
||||
fn view_out_of_bounds() {
|
||||
let a = Matrix3x4::<f32>::zeros();
|
||||
a.slice((1, 2), (3, 1));
|
||||
a.view((1, 2), (3, 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn slice_with_steps_out_of_bounds() {
|
||||
fn view_with_steps_out_of_bounds() {
|
||||
let a = Matrix3x4::<f32>::zeros();
|
||||
a.slice_with_steps((1, 2), (2, 2), (0, 1));
|
||||
a.view_with_steps((1, 2), (2, 2), (0, 1));
|
||||
}
|
@ -4,9 +4,10 @@ mod conversion;
|
||||
mod edition;
|
||||
mod empty;
|
||||
mod matrix;
|
||||
mod matrix_slice;
|
||||
mod matrix_view;
|
||||
#[cfg(feature = "mint")]
|
||||
mod mint;
|
||||
#[cfg(feature = "rkyv-serialize-no-std")]
|
||||
mod rkyv;
|
||||
mod serde;
|
||||
|
||||
|
@ -1,4 +1,7 @@
|
||||
use na::{Quaternion, RealField, UnitQuaternion, Vector2, Vector3};
|
||||
use na::{
|
||||
Matrix3, Quaternion, RealField, Rotation3, UnitQuaternion, UnitVector3, Vector2, Vector3,
|
||||
};
|
||||
use std::f64::consts::PI;
|
||||
|
||||
#[test]
|
||||
fn angle_2() {
|
||||
@ -16,6 +19,58 @@ fn angle_3() {
|
||||
assert_eq!(a.angle(&b), 0.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn from_rotation_matrix() {
|
||||
// Test degenerate case when from_matrix gets stuck in Identity rotation
|
||||
let identity =
|
||||
Rotation3::from_matrix(&Matrix3::new(1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0));
|
||||
assert_relative_eq!(identity, &Rotation3::identity(), epsilon = 0.001);
|
||||
let rotated_z =
|
||||
Rotation3::from_matrix(&Matrix3::new(1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, -1.0));
|
||||
assert_relative_eq!(
|
||||
rotated_z,
|
||||
&Rotation3::from_axis_angle(&UnitVector3::new_unchecked(Vector3::new(1.0, 0.0, 0.0)), PI),
|
||||
epsilon = 0.001
|
||||
);
|
||||
// Test that issue 627 is fixed
|
||||
let m_627 = Matrix3::<f64>::new(-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0);
|
||||
assert_relative_ne!(identity, Rotation3::from_matrix(&m_627), epsilon = 0.01);
|
||||
assert_relative_eq!(
|
||||
Rotation3::from_matrix_unchecked(m_627.clone()),
|
||||
Rotation3::from_matrix(&m_627),
|
||||
epsilon = 0.001
|
||||
);
|
||||
// Test that issue 1078 is fixed
|
||||
let m_1078 = Matrix3::<f64>::new(0.0, 0.0, 1.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0);
|
||||
assert_relative_ne!(identity, Rotation3::from_matrix(&m_1078), epsilon = 0.01);
|
||||
assert_relative_eq!(
|
||||
Rotation3::from_matrix_unchecked(m_1078.clone()),
|
||||
Rotation3::from_matrix(&m_1078),
|
||||
epsilon = 0.001
|
||||
);
|
||||
// Additional test cases for eps >= 1.0
|
||||
assert_relative_ne!(
|
||||
identity,
|
||||
Rotation3::from_matrix_eps(&m_627, 1.2, 0, Rotation3::identity()),
|
||||
epsilon = 0.6
|
||||
);
|
||||
assert_relative_eq!(
|
||||
Rotation3::from_matrix_unchecked(m_627.clone()),
|
||||
Rotation3::from_matrix_eps(&m_627, 1.2, 0, Rotation3::identity()),
|
||||
epsilon = 0.6
|
||||
);
|
||||
assert_relative_ne!(
|
||||
identity,
|
||||
Rotation3::from_matrix_eps(&m_1078, 1.0, 0, Rotation3::identity()),
|
||||
epsilon = 0.1
|
||||
);
|
||||
assert_relative_eq!(
|
||||
Rotation3::from_matrix_unchecked(m_1078.clone()),
|
||||
Rotation3::from_matrix_eps(&m_1078, 1.0, 0, Rotation3::identity()),
|
||||
epsilon = 0.1
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn quaternion_euler_angles_issue_494() {
|
||||
let quat = UnitQuaternion::from_quaternion(Quaternion::new(
|
||||
|
Loading…
Reference in New Issue
Block a user