forked from M-Labs/nalgebra
Merge branch 'dev' into ub3
This commit is contained in:
commit
d34fed45bc
@ -119,4 +119,4 @@ lto = true
|
|||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
# Enable certain features when building docs for docs.rs
|
# Enable certain features when building docs for docs.rs
|
||||||
features = [ "proptest-support", "compare", "macros" ]
|
features = [ "proptest-support", "compare", "macros", "rand" ]
|
||||||
|
2
clippy.toml
Normal file
2
clippy.toml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
too-many-arguments-threshold = 8
|
||||||
|
type-complexity-threshold = 675
|
@ -320,7 +320,7 @@ pub type DMat4x4 = Matrix4<f64>;
|
|||||||
pub type Mat2 = Matrix2<f32>;
|
pub type Mat2 = Matrix2<f32>;
|
||||||
/// A 2x2 matrix with `f32` components.
|
/// A 2x2 matrix with `f32` components.
|
||||||
pub type Mat2x2 = Matrix2<f32>;
|
pub type Mat2x2 = Matrix2<f32>;
|
||||||
/// A 2x2 matrix with `f32` components.
|
/// A 2x3 matrix with `f32` components.
|
||||||
pub type Mat2x3 = Matrix2x3<f32>;
|
pub type Mat2x3 = Matrix2x3<f32>;
|
||||||
/// A 2x4 matrix with `f32` components.
|
/// A 2x4 matrix with `f32` components.
|
||||||
pub type Mat2x4 = Matrix2x4<f32>;
|
pub type Mat2x4 = Matrix2x4<f32>;
|
||||||
|
@ -110,6 +110,16 @@
|
|||||||
and keep in mind it is possible to convert, e.g., an `Isometry3` to a `Mat4` and vice-versa (see the [conversions section](#conversions)).
|
and keep in mind it is possible to convert, e.g., an `Isometry3` to a `Mat4` and vice-versa (see the [conversions section](#conversions)).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#![deny(
|
||||||
|
nonstandard_style,
|
||||||
|
unused,
|
||||||
|
missing_docs,
|
||||||
|
rust_2018_idioms,
|
||||||
|
rust_2018_compatibility,
|
||||||
|
future_incompatible,
|
||||||
|
missing_copy_implementations,
|
||||||
|
missing_debug_implementations
|
||||||
|
)]
|
||||||
#![doc(html_favicon_url = "https://nalgebra.org/img/favicon.ico")]
|
#![doc(html_favicon_url = "https://nalgebra.org/img/favicon.ico")]
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ where
|
|||||||
);
|
);
|
||||||
lapack_panic!(info);
|
lapack_panic!(info);
|
||||||
|
|
||||||
Self { h: m, tau: tau }
|
Self { h: m, tau }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes the hessenberg matrix of this decomposition.
|
/// Computes the hessenberg matrix of this decomposition.
|
||||||
|
@ -61,7 +61,7 @@ where
|
|||||||
unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1).assume_init() };
|
unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1).assume_init() };
|
||||||
|
|
||||||
if nrows.value() == 0 || ncols.value() == 0 {
|
if nrows.value() == 0 || ncols.value() == 0 {
|
||||||
return Self { qr: m, tau: tau };
|
return Self { qr: m, tau };
|
||||||
}
|
}
|
||||||
|
|
||||||
let lwork = T::xgeqrf_work_size(
|
let lwork = T::xgeqrf_work_size(
|
||||||
@ -86,7 +86,7 @@ where
|
|||||||
&mut info,
|
&mut info,
|
||||||
);
|
);
|
||||||
|
|
||||||
Self { qr: m, tau: tau }
|
Self { qr: m, tau }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the upper trapezoidal submatrix `R` of this decomposition.
|
/// Retrieves the upper trapezoidal submatrix `R` of this decomposition.
|
||||||
|
@ -125,7 +125,7 @@ where
|
|||||||
re: wr,
|
re: wr,
|
||||||
im: wi,
|
im: wi,
|
||||||
t: m,
|
t: m,
|
||||||
q: q,
|
q,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,18 @@
|
|||||||
//! This crate is not intended for direct consumption. Instead, the macros are re-exported by
|
//! This crate is not intended for direct consumption. Instead, the macros are re-exported by
|
||||||
//! `nalgebra` if the `macros` feature is enabled (enabled by default).
|
//! `nalgebra` if the `macros` feature is enabled (enabled by default).
|
||||||
|
|
||||||
extern crate proc_macro;
|
#![deny(
|
||||||
|
nonstandard_style,
|
||||||
|
unused,
|
||||||
|
missing_docs,
|
||||||
|
rust_2018_idioms,
|
||||||
|
rust_2018_compatibility,
|
||||||
|
future_incompatible,
|
||||||
|
missing_copy_implementations,
|
||||||
|
missing_debug_implementations,
|
||||||
|
clippy::all,
|
||||||
|
clippy::pedantic
|
||||||
|
)]
|
||||||
|
|
||||||
use proc_macro::TokenStream;
|
use proc_macro::TokenStream;
|
||||||
use quote::{quote, ToTokens, TokenStreamExt};
|
use quote::{quote, ToTokens, TokenStreamExt};
|
||||||
@ -60,7 +71,7 @@ impl Matrix {
|
|||||||
type MatrixRowSyntax = Punctuated<Expr, Token![,]>;
|
type MatrixRowSyntax = Punctuated<Expr, Token![,]>;
|
||||||
|
|
||||||
impl Parse for Matrix {
|
impl Parse for Matrix {
|
||||||
fn parse(input: ParseStream) -> Result<Self> {
|
fn parse(input: ParseStream<'_>) -> Result<Self> {
|
||||||
let mut rows = Vec::new();
|
let mut rows = Vec::new();
|
||||||
let mut ncols = None;
|
let mut ncols = None;
|
||||||
|
|
||||||
@ -205,7 +216,7 @@ impl Vector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for Vector {
|
impl Parse for Vector {
|
||||||
fn parse(input: ParseStream) -> Result<Self> {
|
fn parse(input: ParseStream<'_>) -> Result<Self> {
|
||||||
// The syntax of a vector is just the syntax of a single matrix row
|
// The syntax of a vector is just the syntax of a single matrix row
|
||||||
if input.is_empty() {
|
if input.is_empty() {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
@ -116,7 +116,7 @@ impl<T> CsMatrix<T> {
|
|||||||
/// Returns an entry for the given major/minor indices, or `None` if the indices are out
|
/// Returns an entry for the given major/minor indices, or `None` if the indices are out
|
||||||
/// of bounds.
|
/// of bounds.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry(&self, major_index: usize, minor_index: usize) -> Option<SparseEntry<T>> {
|
pub fn get_entry(&self, major_index: usize, minor_index: usize) -> Option<SparseEntry<'_, T>> {
|
||||||
let row_range = self.get_index_range(major_index)?;
|
let row_range = self.get_index_range(major_index)?;
|
||||||
let (_, minor_indices, values) = self.cs_data();
|
let (_, minor_indices, values) = self.cs_data();
|
||||||
let minor_indices = &minor_indices[row_range.clone()];
|
let minor_indices = &minor_indices[row_range.clone()];
|
||||||
@ -135,7 +135,7 @@ impl<T> CsMatrix<T> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
major_index: usize,
|
major_index: usize,
|
||||||
minor_index: usize,
|
minor_index: usize,
|
||||||
) -> Option<SparseEntryMut<T>> {
|
) -> Option<SparseEntryMut<'_, T>> {
|
||||||
let row_range = self.get_index_range(major_index)?;
|
let row_range = self.get_index_range(major_index)?;
|
||||||
let minor_dim = self.pattern().minor_dim();
|
let minor_dim = self.pattern().minor_dim();
|
||||||
let (_, minor_indices, values) = self.cs_data_mut();
|
let (_, minor_indices, values) = self.cs_data_mut();
|
||||||
@ -145,7 +145,7 @@ impl<T> CsMatrix<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_lane(&self, index: usize) -> Option<CsLane<T>> {
|
pub fn get_lane(&self, index: usize) -> Option<CsLane<'_, T>> {
|
||||||
let range = self.get_index_range(index)?;
|
let range = self.get_index_range(index)?;
|
||||||
let (_, minor_indices, values) = self.cs_data();
|
let (_, minor_indices, values) = self.cs_data();
|
||||||
Some(CsLane {
|
Some(CsLane {
|
||||||
@ -157,7 +157,7 @@ impl<T> CsMatrix<T> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_lane_mut(&mut self, index: usize) -> Option<CsLaneMut<T>> {
|
pub fn get_lane_mut(&mut self, index: usize) -> Option<CsLaneMut<'_, T>> {
|
||||||
let range = self.get_index_range(index)?;
|
let range = self.get_index_range(index)?;
|
||||||
let minor_dim = self.pattern().minor_dim();
|
let minor_dim = self.pattern().minor_dim();
|
||||||
let (_, minor_indices, values) = self.cs_data_mut();
|
let (_, minor_indices, values) = self.cs_data_mut();
|
||||||
@ -169,12 +169,12 @@ impl<T> CsMatrix<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn lane_iter(&self) -> CsLaneIter<T> {
|
pub fn lane_iter(&self) -> CsLaneIter<'_, T> {
|
||||||
CsLaneIter::new(self.pattern(), self.values())
|
CsLaneIter::new(self.pattern(), self.values())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn lane_iter_mut(&mut self) -> CsLaneIterMut<T> {
|
pub fn lane_iter_mut(&mut self) -> CsLaneIterMut<'_, T> {
|
||||||
CsLaneIterMut::new(&self.sparsity_pattern, &mut self.values)
|
CsLaneIterMut::new(&self.sparsity_pattern, &mut self.values)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ macro_rules! impl_cs_lane_common_methods {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry(&self, global_col_index: usize) -> Option<SparseEntry<T>> {
|
pub fn get_entry(&self, global_col_index: usize) -> Option<SparseEntry<'_, T>> {
|
||||||
get_entry_from_slices(
|
get_entry_from_slices(
|
||||||
self.minor_dim,
|
self.minor_dim,
|
||||||
self.minor_indices,
|
self.minor_indices,
|
||||||
@ -431,7 +431,7 @@ impl<'a, T> CsLaneMut<'a, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry_mut(&mut self, global_minor_index: usize) -> Option<SparseEntryMut<T>> {
|
pub fn get_entry_mut(&mut self, global_minor_index: usize) -> Option<SparseEntryMut<'_, T>> {
|
||||||
get_mut_entry_from_slices(
|
get_mut_entry_from_slices(
|
||||||
self.minor_dim,
|
self.minor_dim,
|
||||||
self.minor_indices,
|
self.minor_indices,
|
||||||
|
@ -260,7 +260,7 @@ impl<T> CscMatrix<T> {
|
|||||||
/// let triplets: Vec<_> = csc.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
/// let triplets: Vec<_> = csc.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
||||||
/// assert_eq!(triplets, vec![(0, 0, 1), (2, 0, 3), (1, 1, 2), (0, 2, 4)]);
|
/// assert_eq!(triplets, vec![(0, 0, 1), (2, 0, 3), (1, 1, 2), (0, 2, 4)]);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn triplet_iter(&self) -> CscTripletIter<T> {
|
pub fn triplet_iter(&self) -> CscTripletIter<'_, T> {
|
||||||
CscTripletIter {
|
CscTripletIter {
|
||||||
pattern_iter: self.pattern().entries(),
|
pattern_iter: self.pattern().entries(),
|
||||||
values_iter: self.values().iter(),
|
values_iter: self.values().iter(),
|
||||||
@ -290,7 +290,7 @@ impl<T> CscMatrix<T> {
|
|||||||
/// let triplets: Vec<_> = csc.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
/// let triplets: Vec<_> = csc.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
||||||
/// assert_eq!(triplets, vec![(0, 0, 1), (2, 0, 0), (1, 1, 2), (0, 2, 4)]);
|
/// assert_eq!(triplets, vec![(0, 0, 1), (2, 0, 0), (1, 1, 2), (0, 2, 4)]);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn triplet_iter_mut(&mut self) -> CscTripletIterMut<T> {
|
pub fn triplet_iter_mut(&mut self) -> CscTripletIterMut<'_, T> {
|
||||||
let (pattern, values) = self.cs.pattern_and_values_mut();
|
let (pattern, values) = self.cs.pattern_and_values_mut();
|
||||||
CscTripletIterMut {
|
CscTripletIterMut {
|
||||||
pattern_iter: pattern.entries(),
|
pattern_iter: pattern.entries(),
|
||||||
@ -305,7 +305,7 @@ impl<T> CscMatrix<T> {
|
|||||||
/// Panics if column index is out of bounds.
|
/// Panics if column index is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn col(&self, index: usize) -> CscCol<T> {
|
pub fn col(&self, index: usize) -> CscCol<'_, T> {
|
||||||
self.get_col(index).expect("Row index must be in bounds")
|
self.get_col(index).expect("Row index must be in bounds")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ impl<T> CscMatrix<T> {
|
|||||||
/// ------
|
/// ------
|
||||||
/// Panics if column index is out of bounds.
|
/// Panics if column index is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn col_mut(&mut self, index: usize) -> CscColMut<T> {
|
pub fn col_mut(&mut self, index: usize) -> CscColMut<'_, T> {
|
||||||
self.get_col_mut(index)
|
self.get_col_mut(index)
|
||||||
.expect("Row index must be in bounds")
|
.expect("Row index must be in bounds")
|
||||||
}
|
}
|
||||||
@ -323,26 +323,26 @@ impl<T> CscMatrix<T> {
|
|||||||
/// Return the column at the given column index, or `None` if out of bounds.
|
/// Return the column at the given column index, or `None` if out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_col(&self, index: usize) -> Option<CscCol<T>> {
|
pub fn get_col(&self, index: usize) -> Option<CscCol<'_, T>> {
|
||||||
self.cs.get_lane(index).map(|lane| CscCol { lane })
|
self.cs.get_lane(index).map(|lane| CscCol { lane })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mutable column access for the given column index, or `None` if out of bounds.
|
/// Mutable column access for the given column index, or `None` if out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_col_mut(&mut self, index: usize) -> Option<CscColMut<T>> {
|
pub fn get_col_mut(&mut self, index: usize) -> Option<CscColMut<'_, T>> {
|
||||||
self.cs.get_lane_mut(index).map(|lane| CscColMut { lane })
|
self.cs.get_lane_mut(index).map(|lane| CscColMut { lane })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator over columns in the matrix.
|
/// An iterator over columns in the matrix.
|
||||||
pub fn col_iter(&self) -> CscColIter<T> {
|
pub fn col_iter(&self) -> CscColIter<'_, T> {
|
||||||
CscColIter {
|
CscColIter {
|
||||||
lane_iter: CsLaneIter::new(self.pattern(), self.values()),
|
lane_iter: CsLaneIter::new(self.pattern(), self.values()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A mutable iterator over columns in the matrix.
|
/// A mutable iterator over columns in the matrix.
|
||||||
pub fn col_iter_mut(&mut self) -> CscColIterMut<T> {
|
pub fn col_iter_mut(&mut self) -> CscColIterMut<'_, T> {
|
||||||
let (pattern, values) = self.cs.pattern_and_values_mut();
|
let (pattern, values) = self.cs.pattern_and_values_mut();
|
||||||
CscColIterMut {
|
CscColIterMut {
|
||||||
lane_iter: CsLaneIterMut::new(pattern, values),
|
lane_iter: CsLaneIterMut::new(pattern, values),
|
||||||
@ -408,7 +408,7 @@ impl<T> CscMatrix<T> {
|
|||||||
/// Each call to this function incurs the cost of a binary search among the explicitly
|
/// Each call to this function incurs the cost of a binary search among the explicitly
|
||||||
/// stored row entries for the given column.
|
/// stored row entries for the given column.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry(&self, row_index: usize, col_index: usize) -> Option<SparseEntry<T>> {
|
pub fn get_entry(&self, row_index: usize, col_index: usize) -> Option<SparseEntry<'_, T>> {
|
||||||
self.cs.get_entry(col_index, row_index)
|
self.cs.get_entry(col_index, row_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -421,7 +421,7 @@ impl<T> CscMatrix<T> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
row_index: usize,
|
row_index: usize,
|
||||||
col_index: usize,
|
col_index: usize,
|
||||||
) -> Option<SparseEntryMut<T>> {
|
) -> Option<SparseEntryMut<'_, T>> {
|
||||||
self.cs.get_entry_mut(col_index, row_index)
|
self.cs.get_entry_mut(col_index, row_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ impl<T> CscMatrix<T> {
|
|||||||
/// ------
|
/// ------
|
||||||
/// Panics if `row_index` or `col_index` is out of bounds.
|
/// Panics if `row_index` or `col_index` is out of bounds.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn index_entry(&self, row_index: usize, col_index: usize) -> SparseEntry<T> {
|
pub fn index_entry(&self, row_index: usize, col_index: usize) -> SparseEntry<'_, T> {
|
||||||
self.get_entry(row_index, col_index)
|
self.get_entry(row_index, col_index)
|
||||||
.expect("Out of bounds matrix indices encountered")
|
.expect("Out of bounds matrix indices encountered")
|
||||||
}
|
}
|
||||||
@ -447,7 +447,7 @@ impl<T> CscMatrix<T> {
|
|||||||
/// Panics
|
/// Panics
|
||||||
/// ------
|
/// ------
|
||||||
/// Panics if `row_index` or `col_index` is out of bounds.
|
/// Panics if `row_index` or `col_index` is out of bounds.
|
||||||
pub fn index_entry_mut(&mut self, row_index: usize, col_index: usize) -> SparseEntryMut<T> {
|
pub fn index_entry_mut(&mut self, row_index: usize, col_index: usize) -> SparseEntryMut<'_, T> {
|
||||||
self.get_entry_mut(row_index, col_index)
|
self.get_entry_mut(row_index, col_index)
|
||||||
.expect("Out of bounds matrix indices encountered")
|
.expect("Out of bounds matrix indices encountered")
|
||||||
}
|
}
|
||||||
@ -666,7 +666,7 @@ macro_rules! impl_csc_col_common_methods {
|
|||||||
/// Each call to this function incurs the cost of a binary search among the explicitly
|
/// Each call to this function incurs the cost of a binary search among the explicitly
|
||||||
/// stored row entries.
|
/// stored row entries.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry(&self, global_row_index: usize) -> Option<SparseEntry<T>> {
|
pub fn get_entry(&self, global_row_index: usize) -> Option<SparseEntry<'_, T>> {
|
||||||
self.lane.get_entry(global_row_index)
|
self.lane.get_entry(global_row_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -693,7 +693,7 @@ impl<'a, T> CscColMut<'a, T> {
|
|||||||
|
|
||||||
/// Returns a mutable entry for the given global row index.
|
/// Returns a mutable entry for the given global row index.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry_mut(&mut self, global_row_index: usize) -> Option<SparseEntryMut<T>> {
|
pub fn get_entry_mut(&mut self, global_row_index: usize) -> Option<SparseEntryMut<'_, T>> {
|
||||||
self.lane.get_entry_mut(global_row_index)
|
self.lane.get_entry_mut(global_row_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ impl<T> CsrMatrix<T> {
|
|||||||
/// let triplets: Vec<_> = csr.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
/// let triplets: Vec<_> = csr.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
||||||
/// assert_eq!(triplets, vec![(0, 0, 1), (0, 2, 2), (1, 1, 3), (2, 0, 4)]);
|
/// assert_eq!(triplets, vec![(0, 0, 1), (0, 2, 2), (1, 1, 3), (2, 0, 4)]);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn triplet_iter(&self) -> CsrTripletIter<T> {
|
pub fn triplet_iter(&self) -> CsrTripletIter<'_, T> {
|
||||||
CsrTripletIter {
|
CsrTripletIter {
|
||||||
pattern_iter: self.pattern().entries(),
|
pattern_iter: self.pattern().entries(),
|
||||||
values_iter: self.values().iter(),
|
values_iter: self.values().iter(),
|
||||||
@ -292,7 +292,7 @@ impl<T> CsrMatrix<T> {
|
|||||||
/// let triplets: Vec<_> = csr.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
/// let triplets: Vec<_> = csr.triplet_iter().map(|(i, j, v)| (i, j, *v)).collect();
|
||||||
/// assert_eq!(triplets, vec![(0, 0, 1), (0, 2, 2), (1, 1, 3), (2, 0, 0)]);
|
/// assert_eq!(triplets, vec![(0, 0, 1), (0, 2, 2), (1, 1, 3), (2, 0, 0)]);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn triplet_iter_mut(&mut self) -> CsrTripletIterMut<T> {
|
pub fn triplet_iter_mut(&mut self) -> CsrTripletIterMut<'_, T> {
|
||||||
let (pattern, values) = self.cs.pattern_and_values_mut();
|
let (pattern, values) = self.cs.pattern_and_values_mut();
|
||||||
CsrTripletIterMut {
|
CsrTripletIterMut {
|
||||||
pattern_iter: pattern.entries(),
|
pattern_iter: pattern.entries(),
|
||||||
@ -307,7 +307,7 @@ impl<T> CsrMatrix<T> {
|
|||||||
/// Panics if row index is out of bounds.
|
/// Panics if row index is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn row(&self, index: usize) -> CsrRow<T> {
|
pub fn row(&self, index: usize) -> CsrRow<'_, T> {
|
||||||
self.get_row(index).expect("Row index must be in bounds")
|
self.get_row(index).expect("Row index must be in bounds")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,7 +317,7 @@ impl<T> CsrMatrix<T> {
|
|||||||
/// ------
|
/// ------
|
||||||
/// Panics if row index is out of bounds.
|
/// Panics if row index is out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn row_mut(&mut self, index: usize) -> CsrRowMut<T> {
|
pub fn row_mut(&mut self, index: usize) -> CsrRowMut<'_, T> {
|
||||||
self.get_row_mut(index)
|
self.get_row_mut(index)
|
||||||
.expect("Row index must be in bounds")
|
.expect("Row index must be in bounds")
|
||||||
}
|
}
|
||||||
@ -325,26 +325,26 @@ impl<T> CsrMatrix<T> {
|
|||||||
/// Return the row at the given row index, or `None` if out of bounds.
|
/// Return the row at the given row index, or `None` if out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_row(&self, index: usize) -> Option<CsrRow<T>> {
|
pub fn get_row(&self, index: usize) -> Option<CsrRow<'_, T>> {
|
||||||
self.cs.get_lane(index).map(|lane| CsrRow { lane })
|
self.cs.get_lane(index).map(|lane| CsrRow { lane })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mutable row access for the given row index, or `None` if out of bounds.
|
/// Mutable row access for the given row index, or `None` if out of bounds.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_row_mut(&mut self, index: usize) -> Option<CsrRowMut<T>> {
|
pub fn get_row_mut(&mut self, index: usize) -> Option<CsrRowMut<'_, T>> {
|
||||||
self.cs.get_lane_mut(index).map(|lane| CsrRowMut { lane })
|
self.cs.get_lane_mut(index).map(|lane| CsrRowMut { lane })
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator over rows in the matrix.
|
/// An iterator over rows in the matrix.
|
||||||
pub fn row_iter(&self) -> CsrRowIter<T> {
|
pub fn row_iter(&self) -> CsrRowIter<'_, T> {
|
||||||
CsrRowIter {
|
CsrRowIter {
|
||||||
lane_iter: CsLaneIter::new(self.pattern(), self.values()),
|
lane_iter: CsLaneIter::new(self.pattern(), self.values()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A mutable iterator over rows in the matrix.
|
/// A mutable iterator over rows in the matrix.
|
||||||
pub fn row_iter_mut(&mut self) -> CsrRowIterMut<T> {
|
pub fn row_iter_mut(&mut self) -> CsrRowIterMut<'_, T> {
|
||||||
let (pattern, values) = self.cs.pattern_and_values_mut();
|
let (pattern, values) = self.cs.pattern_and_values_mut();
|
||||||
CsrRowIterMut {
|
CsrRowIterMut {
|
||||||
lane_iter: CsLaneIterMut::new(pattern, values),
|
lane_iter: CsLaneIterMut::new(pattern, values),
|
||||||
@ -410,7 +410,7 @@ impl<T> CsrMatrix<T> {
|
|||||||
/// Each call to this function incurs the cost of a binary search among the explicitly
|
/// Each call to this function incurs the cost of a binary search among the explicitly
|
||||||
/// stored column entries for the given row.
|
/// stored column entries for the given row.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry(&self, row_index: usize, col_index: usize) -> Option<SparseEntry<T>> {
|
pub fn get_entry(&self, row_index: usize, col_index: usize) -> Option<SparseEntry<'_, T>> {
|
||||||
self.cs.get_entry(row_index, col_index)
|
self.cs.get_entry(row_index, col_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +423,7 @@ impl<T> CsrMatrix<T> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
row_index: usize,
|
row_index: usize,
|
||||||
col_index: usize,
|
col_index: usize,
|
||||||
) -> Option<SparseEntryMut<T>> {
|
) -> Option<SparseEntryMut<'_, T>> {
|
||||||
self.cs.get_entry_mut(row_index, col_index)
|
self.cs.get_entry_mut(row_index, col_index)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,7 +436,7 @@ impl<T> CsrMatrix<T> {
|
|||||||
/// ------
|
/// ------
|
||||||
/// Panics if `row_index` or `col_index` is out of bounds.
|
/// Panics if `row_index` or `col_index` is out of bounds.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn index_entry(&self, row_index: usize, col_index: usize) -> SparseEntry<T> {
|
pub fn index_entry(&self, row_index: usize, col_index: usize) -> SparseEntry<'_, T> {
|
||||||
self.get_entry(row_index, col_index)
|
self.get_entry(row_index, col_index)
|
||||||
.expect("Out of bounds matrix indices encountered")
|
.expect("Out of bounds matrix indices encountered")
|
||||||
}
|
}
|
||||||
@ -449,7 +449,7 @@ impl<T> CsrMatrix<T> {
|
|||||||
/// Panics
|
/// Panics
|
||||||
/// ------
|
/// ------
|
||||||
/// Panics if `row_index` or `col_index` is out of bounds.
|
/// Panics if `row_index` or `col_index` is out of bounds.
|
||||||
pub fn index_entry_mut(&mut self, row_index: usize, col_index: usize) -> SparseEntryMut<T> {
|
pub fn index_entry_mut(&mut self, row_index: usize, col_index: usize) -> SparseEntryMut<'_, T> {
|
||||||
self.get_entry_mut(row_index, col_index)
|
self.get_entry_mut(row_index, col_index)
|
||||||
.expect("Out of bounds matrix indices encountered")
|
.expect("Out of bounds matrix indices encountered")
|
||||||
}
|
}
|
||||||
@ -667,7 +667,7 @@ macro_rules! impl_csr_row_common_methods {
|
|||||||
/// stored column entries.
|
/// stored column entries.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry(&self, global_col_index: usize) -> Option<SparseEntry<T>> {
|
pub fn get_entry(&self, global_col_index: usize) -> Option<SparseEntry<'_, T>> {
|
||||||
self.lane.get_entry(global_col_index)
|
self.lane.get_entry(global_col_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,7 +697,7 @@ impl<'a, T> CsrRowMut<'a, T> {
|
|||||||
/// Returns a mutable entry for the given global column index.
|
/// Returns a mutable entry for the given global column index.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn get_entry_mut(&mut self, global_col_index: usize) -> Option<SparseEntryMut<T>> {
|
pub fn get_entry_mut(&mut self, global_col_index: usize) -> Option<SparseEntryMut<'_, T>> {
|
||||||
self.lane.get_entry_mut(global_col_index)
|
self.lane.get_entry_mut(global_col_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,7 +72,7 @@ pub struct CscCholesky<T> {
|
|||||||
work_c: Vec<usize>,
|
work_c: Vec<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, Clone)]
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
/// Possible errors produced by the Cholesky factorization.
|
/// Possible errors produced by the Cholesky factorization.
|
||||||
pub enum CholeskyError {
|
pub enum CholeskyError {
|
||||||
|
@ -131,12 +131,15 @@
|
|||||||
//! assert_matrix_eq!(y, y_expected, comp = abs, tol = 1e-9);
|
//! assert_matrix_eq!(y, y_expected, comp = abs, tol = 1e-9);
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
#![deny(non_camel_case_types)]
|
#![deny(
|
||||||
#![deny(unused_parens)]
|
nonstandard_style,
|
||||||
#![deny(non_upper_case_globals)]
|
unused,
|
||||||
#![deny(unused_qualifications)]
|
missing_docs,
|
||||||
#![deny(unused_results)]
|
rust_2018_idioms,
|
||||||
#![deny(missing_docs)]
|
rust_2018_compatibility,
|
||||||
|
future_incompatible,
|
||||||
|
missing_copy_implementations
|
||||||
|
)]
|
||||||
|
|
||||||
pub extern crate nalgebra as na;
|
pub extern crate nalgebra as na;
|
||||||
pub mod convert;
|
pub mod convert;
|
||||||
@ -190,7 +193,7 @@ impl SparseFormatError {
|
|||||||
|
|
||||||
/// The type of format error described by a [SparseFormatError](struct.SparseFormatError.html).
|
/// The type of format error described by a [SparseFormatError](struct.SparseFormatError.html).
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum SparseFormatErrorKind {
|
pub enum SparseFormatErrorKind {
|
||||||
/// Indicates that the index data associated with the format contains at least one index
|
/// Indicates that the index data associated with the format contains at least one index
|
||||||
/// out of bounds.
|
/// out of bounds.
|
||||||
@ -208,7 +211,7 @@ pub enum SparseFormatErrorKind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for SparseFormatError {
|
impl fmt::Display for SparseFormatError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}", self.error)
|
write!(f, "{}", self.error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ macro_rules! impl_matrix_for_csr_csc {
|
|||||||
self.ncols()
|
self.ncols()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn access(&self) -> Access<T> {
|
fn access(&self) -> Access<'_, T> {
|
||||||
Access::Sparse(self)
|
Access::Sparse(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ impl<T: Clone> matrixcompare_core::Matrix<T> for CooMatrix<T> {
|
|||||||
self.ncols()
|
self.ncols()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn access(&self) -> Access<T> {
|
fn access(&self) -> Access<'_, T> {
|
||||||
Access::Sparse(self)
|
Access::Sparse(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,10 +131,10 @@ where
|
|||||||
/// the transposed operation must be specified for the CSC matrix.
|
/// the transposed operation must be specified for the CSC matrix.
|
||||||
pub fn spmm_cs_dense<T>(
|
pub fn spmm_cs_dense<T>(
|
||||||
beta: T,
|
beta: T,
|
||||||
mut c: DMatrixSliceMut<T>,
|
mut c: DMatrixSliceMut<'_, T>,
|
||||||
alpha: T,
|
alpha: T,
|
||||||
a: Op<&CsMatrix<T>>,
|
a: Op<&CsMatrix<T>>,
|
||||||
b: Op<DMatrixSlice<T>>,
|
b: Op<DMatrixSlice<'_, T>>,
|
||||||
) where
|
) where
|
||||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||||
{
|
{
|
||||||
|
@ -27,10 +27,10 @@ pub fn spmm_csc_dense<'a, T>(
|
|||||||
|
|
||||||
fn spmm_csc_dense_<T>(
|
fn spmm_csc_dense_<T>(
|
||||||
beta: T,
|
beta: T,
|
||||||
c: DMatrixSliceMut<T>,
|
c: DMatrixSliceMut<'_, T>,
|
||||||
alpha: T,
|
alpha: T,
|
||||||
a: Op<&CscMatrix<T>>,
|
a: Op<&CscMatrix<T>>,
|
||||||
b: Op<DMatrixSlice<T>>,
|
b: Op<DMatrixSlice<'_, T>>,
|
||||||
) where
|
) where
|
||||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||||
{
|
{
|
||||||
@ -147,7 +147,7 @@ pub fn spsolve_csc_lower_triangular<'a, T: RealField>(
|
|||||||
|
|
||||||
fn spsolve_csc_lower_triangular_no_transpose<T: RealField>(
|
fn spsolve_csc_lower_triangular_no_transpose<T: RealField>(
|
||||||
l: &CscMatrix<T>,
|
l: &CscMatrix<T>,
|
||||||
b: DMatrixSliceMut<T>,
|
b: DMatrixSliceMut<'_, T>,
|
||||||
) -> Result<(), OperationError> {
|
) -> Result<(), OperationError> {
|
||||||
let mut x = b;
|
let mut x = b;
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ fn spsolve_encountered_zero_diagonal() -> Result<(), OperationError> {
|
|||||||
|
|
||||||
fn spsolve_csc_lower_triangular_transpose<T: RealField>(
|
fn spsolve_csc_lower_triangular_transpose<T: RealField>(
|
||||||
l: &CscMatrix<T>,
|
l: &CscMatrix<T>,
|
||||||
b: DMatrixSliceMut<T>,
|
b: DMatrixSliceMut<'_, T>,
|
||||||
) -> Result<(), OperationError> {
|
) -> Result<(), OperationError> {
|
||||||
let mut x = b;
|
let mut x = b;
|
||||||
|
|
||||||
|
@ -22,10 +22,10 @@ pub fn spmm_csr_dense<'a, T>(
|
|||||||
|
|
||||||
fn spmm_csr_dense_<T>(
|
fn spmm_csr_dense_<T>(
|
||||||
beta: T,
|
beta: T,
|
||||||
c: DMatrixSliceMut<T>,
|
c: DMatrixSliceMut<'_, T>,
|
||||||
alpha: T,
|
alpha: T,
|
||||||
a: Op<&CsrMatrix<T>>,
|
a: Op<&CsrMatrix<T>>,
|
||||||
b: Op<DMatrixSlice<T>>,
|
b: Op<DMatrixSlice<'_, T>>,
|
||||||
) where
|
) where
|
||||||
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
T: Scalar + ClosedAdd + ClosedMul + Zero + One,
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ pub struct OperationError {
|
|||||||
|
|
||||||
/// The different kinds of operation errors that may occur.
|
/// The different kinds of operation errors that may occur.
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub enum OperationErrorKind {
|
pub enum OperationErrorKind {
|
||||||
/// Indicates that one or more sparsity patterns involved in the operation violate the
|
/// Indicates that one or more sparsity patterns involved in the operation violate the
|
||||||
/// expectations of the routine.
|
/// expectations of the routine.
|
||||||
|
@ -205,7 +205,7 @@ impl SparsityPattern {
|
|||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn entries(&self) -> SparsityPatternIter {
|
pub fn entries(&self) -> SparsityPatternIter<'_> {
|
||||||
SparsityPatternIter::from_pattern(self)
|
SparsityPatternIter::from_pattern(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ impl SparsityPattern {
|
|||||||
|
|
||||||
/// Error type for `SparsityPattern` format errors.
|
/// Error type for `SparsityPattern` format errors.
|
||||||
#[non_exhaustive]
|
#[non_exhaustive]
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum SparsityPatternFormatError {
|
pub enum SparsityPatternFormatError {
|
||||||
/// Indicates an invalid number of offsets.
|
/// Indicates an invalid number of offsets.
|
||||||
///
|
///
|
||||||
|
@ -0,0 +1,3 @@
|
|||||||
|
edition = "2018"
|
||||||
|
use_try_shorthand = true
|
||||||
|
use_field_init_shorthand = true
|
@ -48,7 +48,7 @@ where
|
|||||||
|
|
||||||
impl<T: Debug, const R: usize, const C: usize> Debug for ArrayStorage<T, R, C> {
|
impl<T: Debug, const R: usize, const C: usize> Debug for ArrayStorage<T, R, C> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn fmt(&self, fmt: &mut Formatter) -> fmt::Result {
|
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
|
||||||
self.0.fmt(fmt)
|
self.0.fmt(fmt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ where
|
|||||||
{
|
{
|
||||||
type Value = ArrayStorage<T, R, C>;
|
type Value = ArrayStorage<T, R, C>;
|
||||||
|
|
||||||
fn expecting(&self, formatter: &mut Formatter) -> fmt::Result {
|
fn expecting(&self, formatter: &mut Formatter<'_>) -> fmt::Result {
|
||||||
formatter.write_str("a matrix array")
|
formatter.write_str("a matrix array")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -441,8 +441,8 @@ where
|
|||||||
x: &Vector<T, D3, SC>,
|
x: &Vector<T, D3, SC>,
|
||||||
beta: T,
|
beta: T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<T, SB::RStride, SB::CStride>,
|
&DVectorSlice<'_, T, SB::RStride, SB::CStride>,
|
||||||
&DVectorSlice<T, SC::RStride, SC::CStride>,
|
&DVectorSlice<'_, T, SC::RStride, SC::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) where
|
) where
|
||||||
T: One,
|
T: One,
|
||||||
@ -605,7 +605,7 @@ where
|
|||||||
a: &Matrix<T, R2, C2, SB>,
|
a: &Matrix<T, R2, C2, SB>,
|
||||||
x: &Vector<T, D3, SC>,
|
x: &Vector<T, D3, SC>,
|
||||||
beta: T,
|
beta: T,
|
||||||
dot: impl Fn(&VectorSlice<T, R2, SB::RStride, SB::CStride>, &Vector<T, D3, SC>) -> T,
|
dot: impl Fn(&VectorSlice<'_, T, R2, SB::RStride, SB::CStride>, &Vector<T, D3, SC>) -> T,
|
||||||
) where
|
) where
|
||||||
T: One,
|
T: One,
|
||||||
SB: Storage<T, R2, C2>,
|
SB: Storage<T, R2, C2>,
|
||||||
|
@ -79,7 +79,7 @@ impl<T: RealField> Matrix3<T> {
|
|||||||
|
|
||||||
/// Creates a new homogeneous matrix that applies a scaling factor for each dimension with respect to point.
|
/// Creates a new homogeneous matrix that applies a scaling factor for each dimension with respect to point.
|
||||||
///
|
///
|
||||||
/// Can be used to implement "zoom_to" functionality.
|
/// Can be used to implement `zoom_to` functionality.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new_nonuniform_scaling_wrt_point(scaling: &Vector2<T>, pt: &Point2<T>) -> Self {
|
pub fn new_nonuniform_scaling_wrt_point(scaling: &Vector2<T>, pt: &Point2<T>) -> Self {
|
||||||
let zero = T::zero();
|
let zero = T::zero();
|
||||||
@ -119,7 +119,7 @@ impl<T: RealField> Matrix4<T> {
|
|||||||
|
|
||||||
/// Creates a new homogeneous matrix that applies a scaling factor for each dimension with respect to point.
|
/// Creates a new homogeneous matrix that applies a scaling factor for each dimension with respect to point.
|
||||||
///
|
///
|
||||||
/// Can be used to implement "zoom_to" functionality.
|
/// Can be used to implement `zoom_to` functionality.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new_nonuniform_scaling_wrt_point(scaling: &Vector3<T>, pt: &Point3<T>) -> Self {
|
pub fn new_nonuniform_scaling_wrt_point(scaling: &Vector3<T>, pt: &Point3<T>) -> Self {
|
||||||
let zero = T::zero();
|
let zero = T::zero();
|
||||||
@ -187,7 +187,7 @@ impl<T: RealField> Matrix4<T> {
|
|||||||
IsometryMatrix3::face_towards(eye, target, up).to_homogeneous()
|
IsometryMatrix3::face_towards(eye, target, up).to_homogeneous()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated: Use [Matrix4::face_towards] instead.
|
/// Deprecated: Use [`Matrix4::face_towards`] instead.
|
||||||
#[deprecated(note = "renamed to `face_towards`")]
|
#[deprecated(note = "renamed to `face_towards`")]
|
||||||
pub fn new_observer_frame(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self {
|
pub fn new_observer_frame(eye: &Point3<T>, target: &Point3<T>, up: &Vector3<T>) -> Self {
|
||||||
Matrix4::face_towards(eye, target, up)
|
Matrix4::face_towards(eye, target, up)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
use crate::base::dimension::{Dim, DimName, Dynamic};
|
use crate::base::dimension::{Dim, DimName, Dynamic};
|
||||||
|
|
||||||
/// A type used in `where` clauses for enforcing constraints.
|
/// A type used in `where` clauses for enforcing constraints.
|
||||||
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct ShapeConstraint;
|
pub struct ShapeConstraint;
|
||||||
|
|
||||||
/// Constraints `C1` and `R2` to be equivalent.
|
/// Constraints `C1` and `R2` to be equivalent.
|
||||||
|
@ -938,19 +938,19 @@ macro_rules! transpose_array(
|
|||||||
[$([$a]),*]
|
[$([$a]),*]
|
||||||
};
|
};
|
||||||
[$($a: ident),*; $($b: ident),*;] => {
|
[$($a: ident),*; $($b: ident),*;] => {
|
||||||
[$([$a, $b]),*];
|
[$([$a, $b]),*]
|
||||||
};
|
};
|
||||||
[$($a: ident),*; $($b: ident),*; $($c: ident),*;] => {
|
[$($a: ident),*; $($b: ident),*; $($c: ident),*;] => {
|
||||||
[$([$a, $b, $c]),*];
|
[$([$a, $b, $c]),*]
|
||||||
};
|
};
|
||||||
[$($a: ident),*; $($b: ident),*; $($c: ident),*; $($d: ident),*;] => {
|
[$($a: ident),*; $($b: ident),*; $($c: ident),*; $($d: ident),*;] => {
|
||||||
[$([$a, $b, $c, $d]),*];
|
[$([$a, $b, $c, $d]),*]
|
||||||
};
|
};
|
||||||
[$($a: ident),*; $($b: ident),*; $($c: ident),*; $($d: ident),*; $($e: ident),*;] => {
|
[$($a: ident),*; $($b: ident),*; $($c: ident),*; $($d: ident),*; $($e: ident),*;] => {
|
||||||
[$([$a, $b, $c, $d, $e]),*];
|
[$([$a, $b, $c, $d, $e]),*]
|
||||||
};
|
};
|
||||||
[$($a: ident),*; $($b: ident),*; $($c: ident),*; $($d: ident),*; $($e: ident),*; $($f: ident),*;] => {
|
[$($a: ident),*; $($b: ident),*; $($c: ident),*; $($d: ident),*; $($e: ident),*; $($f: ident),*;] => {
|
||||||
[$([$a, $b, $c, $d, $e, $f]),*];
|
[$([$a, $b, $c, $d, $e, $f]),*]
|
||||||
};
|
};
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ use crate::U1;
|
|||||||
/// This struct is useless on its own. Instead, it's used in trait
|
/// This struct is useless on its own. Instead, it's used in trait
|
||||||
/// An allocator based on `GenericArray` and `VecStorage` for statically-sized and dynamically-sized
|
/// An allocator based on `GenericArray` and `VecStorage` for statically-sized and dynamically-sized
|
||||||
/// matrices respectively.
|
/// matrices respectively.
|
||||||
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct DefaultAllocator;
|
pub struct DefaultAllocator;
|
||||||
|
|
||||||
// Static - Static
|
// Static - Static
|
||||||
|
@ -178,7 +178,7 @@ iterator!(struct MatrixIterMut for StorageMut.ptr_mut -> *mut T, &'a mut T, &'a
|
|||||||
* Row iterators.
|
* Row iterators.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
/// An iterator through the rows of a matrix.
|
/// An iterator through the rows of a matrix.
|
||||||
pub struct RowIter<'a, T, R: Dim, C: Dim, S: Storage<T, R, C>> {
|
pub struct RowIter<'a, T, R: Dim, C: Dim, S: Storage<T, R, C>> {
|
||||||
mat: &'a Matrix<T, R, C, S>,
|
mat: &'a Matrix<T, R, C, S>,
|
||||||
@ -288,7 +288,7 @@ impl<'a, T, R: Dim, C: Dim, S: 'a + StorageMut<T, R, C>> ExactSizeIterator
|
|||||||
* Column iterators.
|
* Column iterators.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#[derive(Clone)]
|
#[derive(Clone, Debug)]
|
||||||
/// An iterator through the columns of a matrix.
|
/// An iterator through the columns of a matrix.
|
||||||
pub struct ColumnIter<'a, T, R: Dim, C: Dim, S: Storage<T, R, C>> {
|
pub struct ColumnIter<'a, T, R: Dim, C: Dim, S: Storage<T, R, C>> {
|
||||||
mat: &'a Matrix<T, R, C, S>,
|
mat: &'a Matrix<T, R, C, S>,
|
||||||
|
@ -252,7 +252,7 @@ impl<T: Clone, R: Dim, C: Dim, S: Storage<T, R, C>> matrixcompare_core::Matrix<T
|
|||||||
self.ncols()
|
self.ncols()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn access(&self) -> matrixcompare_core::Access<T> {
|
fn access(&self) -> matrixcompare_core::Access<'_, T> {
|
||||||
matrixcompare_core::Access::Dense(self)
|
matrixcompare_core::Access::Dense(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -431,7 +431,7 @@ impl<T, R: Dim, C: Dim, S> Matrix<MaybeUninit<T>, R, C, S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T, const R: usize, const C: usize> SMatrix<T, R, C> {
|
impl<T, const R: usize, const C: usize> SMatrix<T, R, C> {
|
||||||
/// Creates a new statically-allocated matrix from the given [ArrayStorage].
|
/// Creates a new statically-allocated matrix from the given [`ArrayStorage`].
|
||||||
///
|
///
|
||||||
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
||||||
/// work in `const fn` contexts.
|
/// work in `const fn` contexts.
|
||||||
@ -447,7 +447,7 @@ impl<T, const R: usize, const C: usize> SMatrix<T, R, C> {
|
|||||||
// `from_data` const fn compatible
|
// `from_data` const fn compatible
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T> DMatrix<T> {
|
impl<T> DMatrix<T> {
|
||||||
/// Creates a new heap-allocated matrix from the given [VecStorage].
|
/// Creates a new heap-allocated matrix from the given [`VecStorage`].
|
||||||
///
|
///
|
||||||
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
||||||
/// work in `const fn` contexts.
|
/// work in `const fn` contexts.
|
||||||
@ -462,7 +462,7 @@ impl<T> DMatrix<T> {
|
|||||||
// `from_data` const fn compatible
|
// `from_data` const fn compatible
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
impl<T> DVector<T> {
|
impl<T> DVector<T> {
|
||||||
/// Creates a new heap-allocated matrix from the given [VecStorage].
|
/// Creates a new heap-allocated matrix from the given [`VecStorage`].
|
||||||
///
|
///
|
||||||
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
/// This method exists primarily as a workaround for the fact that `from_data` can not
|
||||||
/// work in `const fn` contexts.
|
/// work in `const fn` contexts.
|
||||||
@ -1129,7 +1129,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
/// assert_eq!(*it.next().unwrap(), 23);
|
/// assert_eq!(*it.next().unwrap(), 23);
|
||||||
/// assert!(it.next().is_none());
|
/// assert!(it.next().is_none());
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter(&self) -> MatrixIter<T, R, C, S> {
|
pub fn iter(&self) -> MatrixIter<'_, T, R, C, S> {
|
||||||
MatrixIter::new(&self.data)
|
MatrixIter::new(&self.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1145,7 +1145,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn row_iter(&self) -> RowIter<T, R, C, S> {
|
pub fn row_iter(&self) -> RowIter<'_, T, R, C, S> {
|
||||||
RowIter::new(self)
|
RowIter::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1160,13 +1160,13 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn column_iter(&self) -> ColumnIter<T, R, C, S> {
|
pub fn column_iter(&self) -> ColumnIter<'_, T, R, C, S> {
|
||||||
ColumnIter::new(self)
|
ColumnIter::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mutably iterates through this matrix coordinates.
|
/// Mutably iterates through this matrix coordinates.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn iter_mut(&mut self) -> MatrixIterMut<T, R, C, S>
|
pub fn iter_mut(&mut self) -> MatrixIterMut<'_, T, R, C, S>
|
||||||
where
|
where
|
||||||
S: StorageMut<T, R, C>,
|
S: StorageMut<T, R, C>,
|
||||||
{
|
{
|
||||||
@ -1189,7 +1189,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
/// assert_eq!(a, expected);
|
/// assert_eq!(a, expected);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn row_iter_mut(&mut self) -> RowIterMut<T, R, C, S>
|
pub fn row_iter_mut(&mut self) -> RowIterMut<'_, T, R, C, S>
|
||||||
where
|
where
|
||||||
S: StorageMut<T, R, C>,
|
S: StorageMut<T, R, C>,
|
||||||
{
|
{
|
||||||
@ -1212,7 +1212,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
/// assert_eq!(a, expected);
|
/// assert_eq!(a, expected);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn column_iter_mut(&mut self) -> ColumnIterMut<T, R, C, S>
|
pub fn column_iter_mut(&mut self) -> ColumnIterMut<'_, T, R, C, S>
|
||||||
where
|
where
|
||||||
S: StorageMut<T, R, C>,
|
S: StorageMut<T, R, C>,
|
||||||
{
|
{
|
||||||
@ -2038,9 +2038,9 @@ macro_rules! impl_fmt {
|
|||||||
T: Scalar + $trait,
|
T: Scalar + $trait,
|
||||||
S: Storage<T, R, C>,
|
S: Storage<T, R, C>,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
fn val_width<T: Scalar + $trait>(val: &T, f: &mut fmt::Formatter) -> usize {
|
fn val_width<T: Scalar + $trait>(val: &T, f: &mut fmt::Formatter<'_>) -> usize {
|
||||||
match f.precision() {
|
match f.precision() {
|
||||||
Some(precision) => format!($fmt_str_with_precision, val, precision)
|
Some(precision) => format!($fmt_str_with_precision, val, precision)
|
||||||
.chars()
|
.chars()
|
||||||
@ -2050,7 +2050,7 @@ macro_rules! impl_fmt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "std"))]
|
#[cfg(not(feature = "std"))]
|
||||||
fn val_width<T: Scalar + $trait>(_: &T, _: &mut fmt::Formatter) -> usize {
|
fn val_width<T: Scalar + $trait>(_: &T, _: &mut fmt::Formatter<'_>) -> usize {
|
||||||
4
|
4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,20 +354,20 @@ macro_rules! matrix_slice_impl(
|
|||||||
*/
|
*/
|
||||||
/// Returns a slice containing the i-th row of this matrix.
|
/// Returns a slice containing the i-th row of this matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $row($me: $Me, i: usize) -> $MatrixSlice<T, U1, C, S::RStride, S::CStride> {
|
pub fn $row($me: $Me, i: usize) -> $MatrixSlice<'_, T, U1, C, S::RStride, S::CStride> {
|
||||||
$me.$fixed_rows::<1>(i)
|
$me.$fixed_rows::<1>(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a slice containing the `n` first elements of the i-th row of this matrix.
|
/// Returns a slice containing the `n` first elements of the i-th row of this matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $row_part($me: $Me, i: usize, n: usize) -> $MatrixSlice<T, U1, Dynamic, S::RStride, S::CStride> {
|
pub fn $row_part($me: $Me, i: usize, n: usize) -> $MatrixSlice<'_, T, U1, Dynamic, S::RStride, S::CStride> {
|
||||||
$me.$generic_slice((i, 0), (Const::<1>, Dynamic::new(n)))
|
$me.$generic_slice((i, 0), (Const::<1>, Dynamic::new(n)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extracts from this matrix a set of consecutive rows.
|
/// Extracts from this matrix a set of consecutive rows.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $rows($me: $Me, first_row: usize, nrows: usize)
|
pub fn $rows($me: $Me, first_row: usize, nrows: usize)
|
||||||
-> $MatrixSlice<T, Dynamic, C, S::RStride, S::CStride> {
|
-> $MatrixSlice<'_, T, Dynamic, C, S::RStride, S::CStride> {
|
||||||
|
|
||||||
$me.$rows_generic(first_row, Dynamic::new(nrows))
|
$me.$rows_generic(first_row, Dynamic::new(nrows))
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// Extracts from this matrix a set of consecutive rows regularly skipping `step` rows.
|
/// Extracts from this matrix a set of consecutive rows regularly skipping `step` rows.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $rows_with_step($me: $Me, first_row: usize, nrows: usize, step: usize)
|
pub fn $rows_with_step($me: $Me, first_row: usize, nrows: usize, step: usize)
|
||||||
-> $MatrixSlice<T, Dynamic, C, Dynamic, S::CStride> {
|
-> $MatrixSlice<'_, T, Dynamic, C, Dynamic, S::CStride> {
|
||||||
|
|
||||||
$me.$rows_generic_with_step(first_row, Dynamic::new(nrows), step)
|
$me.$rows_generic_with_step(first_row, Dynamic::new(nrows), step)
|
||||||
}
|
}
|
||||||
@ -383,7 +383,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// Extracts a compile-time number of consecutive rows from this matrix.
|
/// Extracts a compile-time number of consecutive rows from this matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $fixed_rows<const RSLICE: usize>($me: $Me, first_row: usize)
|
pub fn $fixed_rows<const RSLICE: usize>($me: $Me, first_row: usize)
|
||||||
-> $MatrixSlice<T, Const<RSLICE>, C, S::RStride, S::CStride> {
|
-> $MatrixSlice<'_, T, Const<RSLICE>, C, S::RStride, S::CStride> {
|
||||||
|
|
||||||
$me.$rows_generic(first_row, Const::<RSLICE>)
|
$me.$rows_generic(first_row, Const::<RSLICE>)
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// rows.
|
/// rows.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $fixed_rows_with_step<const RSLICE: usize>($me: $Me, first_row: usize, step: usize)
|
pub fn $fixed_rows_with_step<const RSLICE: usize>($me: $Me, first_row: usize, step: usize)
|
||||||
-> $MatrixSlice<T, Const<RSLICE>, C, Dynamic, S::CStride> {
|
-> $MatrixSlice<'_, T, Const<RSLICE>, C, Dynamic, S::CStride> {
|
||||||
|
|
||||||
$me.$rows_generic_with_step(first_row, Const::<RSLICE>, step)
|
$me.$rows_generic_with_step(first_row, Const::<RSLICE>, step)
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// argument may or may not be values known at compile-time.
|
/// argument may or may not be values known at compile-time.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $rows_generic<RSlice: Dim>($me: $Me, row_start: usize, nrows: RSlice)
|
pub fn $rows_generic<RSlice: Dim>($me: $Me, row_start: usize, nrows: RSlice)
|
||||||
-> $MatrixSlice<T, RSlice, C, S::RStride, S::CStride> {
|
-> $MatrixSlice<'_, T, RSlice, C, S::RStride, S::CStride> {
|
||||||
|
|
||||||
let my_shape = $me.data.shape();
|
let my_shape = $me.data.shape();
|
||||||
$me.assert_slice_index((row_start, 0), (nrows.value(), my_shape.1.value()), (0, 0));
|
$me.assert_slice_index((row_start, 0), (nrows.value(), my_shape.1.value()), (0, 0));
|
||||||
@ -418,7 +418,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// argument may or may not be values known at compile-time.
|
/// argument may or may not be values known at compile-time.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $rows_generic_with_step<RSlice>($me: $Me, row_start: usize, nrows: RSlice, step: usize)
|
pub fn $rows_generic_with_step<RSlice>($me: $Me, row_start: usize, nrows: RSlice, step: usize)
|
||||||
-> $MatrixSlice<T, RSlice, C, Dynamic, S::CStride>
|
-> $MatrixSlice<'_, T, RSlice, C, Dynamic, S::CStride>
|
||||||
where RSlice: Dim {
|
where RSlice: Dim {
|
||||||
|
|
||||||
let my_shape = $me.data.shape();
|
let my_shape = $me.data.shape();
|
||||||
@ -441,20 +441,20 @@ macro_rules! matrix_slice_impl(
|
|||||||
*/
|
*/
|
||||||
/// Returns a slice containing the i-th column of this matrix.
|
/// Returns a slice containing the i-th column of this matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $column($me: $Me, i: usize) -> $MatrixSlice<T, R, U1, S::RStride, S::CStride> {
|
pub fn $column($me: $Me, i: usize) -> $MatrixSlice<'_, T, R, U1, S::RStride, S::CStride> {
|
||||||
$me.$fixed_columns::<1>(i)
|
$me.$fixed_columns::<1>(i)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a slice containing the `n` first elements of the i-th column of this matrix.
|
/// Returns a slice containing the `n` first elements of the i-th column of this matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $column_part($me: $Me, i: usize, n: usize) -> $MatrixSlice<T, Dynamic, U1, S::RStride, S::CStride> {
|
pub fn $column_part($me: $Me, i: usize, n: usize) -> $MatrixSlice<'_, T, Dynamic, U1, S::RStride, S::CStride> {
|
||||||
$me.$generic_slice((0, i), (Dynamic::new(n), Const::<1>))
|
$me.$generic_slice((0, i), (Dynamic::new(n), Const::<1>))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extracts from this matrix a set of consecutive columns.
|
/// Extracts from this matrix a set of consecutive columns.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $columns($me: $Me, first_col: usize, ncols: usize)
|
pub fn $columns($me: $Me, first_col: usize, ncols: usize)
|
||||||
-> $MatrixSlice<T, R, Dynamic, S::RStride, S::CStride> {
|
-> $MatrixSlice<'_, T, R, Dynamic, S::RStride, S::CStride> {
|
||||||
|
|
||||||
$me.$columns_generic(first_col, Dynamic::new(ncols))
|
$me.$columns_generic(first_col, Dynamic::new(ncols))
|
||||||
}
|
}
|
||||||
@ -463,7 +463,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// columns.
|
/// columns.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $columns_with_step($me: $Me, first_col: usize, ncols: usize, step: usize)
|
pub fn $columns_with_step($me: $Me, first_col: usize, ncols: usize, step: usize)
|
||||||
-> $MatrixSlice<T, R, Dynamic, S::RStride, Dynamic> {
|
-> $MatrixSlice<'_, T, R, Dynamic, S::RStride, Dynamic> {
|
||||||
|
|
||||||
$me.$columns_generic_with_step(first_col, Dynamic::new(ncols), step)
|
$me.$columns_generic_with_step(first_col, Dynamic::new(ncols), step)
|
||||||
}
|
}
|
||||||
@ -471,7 +471,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// Extracts a compile-time number of consecutive columns from this matrix.
|
/// Extracts a compile-time number of consecutive columns from this matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $fixed_columns<const CSLICE: usize>($me: $Me, first_col: usize)
|
pub fn $fixed_columns<const CSLICE: usize>($me: $Me, first_col: usize)
|
||||||
-> $MatrixSlice<T, R, Const<CSLICE>, S::RStride, S::CStride> {
|
-> $MatrixSlice<'_, T, R, Const<CSLICE>, S::RStride, S::CStride> {
|
||||||
|
|
||||||
$me.$columns_generic(first_col, Const::<CSLICE>)
|
$me.$columns_generic(first_col, Const::<CSLICE>)
|
||||||
}
|
}
|
||||||
@ -480,7 +480,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// `step` columns.
|
/// `step` columns.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $fixed_columns_with_step<const CSLICE: usize>($me: $Me, first_col: usize, step: usize)
|
pub fn $fixed_columns_with_step<const CSLICE: usize>($me: $Me, first_col: usize, step: usize)
|
||||||
-> $MatrixSlice<T, R, Const<CSLICE>, S::RStride, Dynamic> {
|
-> $MatrixSlice<'_, T, R, Const<CSLICE>, S::RStride, Dynamic> {
|
||||||
|
|
||||||
$me.$columns_generic_with_step(first_col, Const::<CSLICE>, step)
|
$me.$columns_generic_with_step(first_col, Const::<CSLICE>, step)
|
||||||
}
|
}
|
||||||
@ -489,7 +489,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// known at compile-time.
|
/// known at compile-time.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $columns_generic<CSlice: Dim>($me: $Me, first_col: usize, ncols: CSlice)
|
pub fn $columns_generic<CSlice: Dim>($me: $Me, first_col: usize, ncols: CSlice)
|
||||||
-> $MatrixSlice<T, R, CSlice, S::RStride, S::CStride> {
|
-> $MatrixSlice<'_, T, R, CSlice, S::RStride, S::CStride> {
|
||||||
|
|
||||||
let my_shape = $me.data.shape();
|
let my_shape = $me.data.shape();
|
||||||
$me.assert_slice_index((0, first_col), (my_shape.0.value(), ncols.value()), (0, 0));
|
$me.assert_slice_index((0, first_col), (my_shape.0.value(), ncols.value()), (0, 0));
|
||||||
@ -505,7 +505,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// or may not be values known at compile-time.
|
/// or may not be values known at compile-time.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $columns_generic_with_step<CSlice: Dim>($me: $Me, first_col: usize, ncols: CSlice, step: usize)
|
pub fn $columns_generic_with_step<CSlice: Dim>($me: $Me, first_col: usize, ncols: CSlice, step: usize)
|
||||||
-> $MatrixSlice<T, R, CSlice, S::RStride, Dynamic> {
|
-> $MatrixSlice<'_, T, R, CSlice, S::RStride, Dynamic> {
|
||||||
|
|
||||||
let my_shape = $me.data.shape();
|
let my_shape = $me.data.shape();
|
||||||
let my_strides = $me.data.strides();
|
let my_strides = $me.data.strides();
|
||||||
@ -530,7 +530,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// consecutive elements.
|
/// consecutive elements.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $slice($me: $Me, start: (usize, usize), shape: (usize, usize))
|
pub fn $slice($me: $Me, start: (usize, usize), shape: (usize, usize))
|
||||||
-> $MatrixSlice<T, Dynamic, Dynamic, S::RStride, S::CStride> {
|
-> $MatrixSlice<'_, T, Dynamic, Dynamic, S::RStride, S::CStride> {
|
||||||
|
|
||||||
$me.assert_slice_index(start, shape, (0, 0));
|
$me.assert_slice_index(start, shape, (0, 0));
|
||||||
let shape = (Dynamic::new(shape.0), Dynamic::new(shape.1));
|
let shape = (Dynamic::new(shape.0), Dynamic::new(shape.1));
|
||||||
@ -547,7 +547,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// original matrix.
|
/// original matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $slice_with_steps($me: $Me, start: (usize, usize), shape: (usize, usize), steps: (usize, usize))
|
pub fn $slice_with_steps($me: $Me, start: (usize, usize), shape: (usize, usize), steps: (usize, usize))
|
||||||
-> $MatrixSlice<T, Dynamic, Dynamic, Dynamic, Dynamic> {
|
-> $MatrixSlice<'_, T, Dynamic, Dynamic, Dynamic, Dynamic> {
|
||||||
let shape = (Dynamic::new(shape.0), Dynamic::new(shape.1));
|
let shape = (Dynamic::new(shape.0), Dynamic::new(shape.1));
|
||||||
|
|
||||||
$me.$generic_slice_with_steps(start, shape, steps)
|
$me.$generic_slice_with_steps(start, shape, steps)
|
||||||
@ -557,7 +557,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// CSlice::dim())` consecutive components.
|
/// CSlice::dim())` consecutive components.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $fixed_slice<const RSLICE: usize, const CSLICE: usize>($me: $Me, irow: usize, icol: usize)
|
pub fn $fixed_slice<const RSLICE: usize, const CSLICE: usize>($me: $Me, irow: usize, icol: usize)
|
||||||
-> $MatrixSlice<T, Const<RSLICE>, Const<CSLICE>, S::RStride, S::CStride> {
|
-> $MatrixSlice<'_, T, Const<RSLICE>, Const<CSLICE>, S::RStride, S::CStride> {
|
||||||
|
|
||||||
$me.assert_slice_index((irow, icol), (RSLICE, CSLICE), (0, 0));
|
$me.assert_slice_index((irow, icol), (RSLICE, CSLICE), (0, 0));
|
||||||
let shape = (Const::<RSLICE>, Const::<CSLICE>);
|
let shape = (Const::<RSLICE>, Const::<CSLICE>);
|
||||||
@ -574,7 +574,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
/// the original matrix.
|
/// the original matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $fixed_slice_with_steps<const RSLICE: usize, const CSLICE: usize>($me: $Me, start: (usize, usize), steps: (usize, usize))
|
pub fn $fixed_slice_with_steps<const RSLICE: usize, const CSLICE: usize>($me: $Me, start: (usize, usize), steps: (usize, usize))
|
||||||
-> $MatrixSlice<T, Const<RSLICE>, Const<CSLICE>, Dynamic, Dynamic> {
|
-> $MatrixSlice<'_, T, Const<RSLICE>, Const<CSLICE>, Dynamic, Dynamic> {
|
||||||
let shape = (Const::<RSLICE>, Const::<CSLICE>);
|
let shape = (Const::<RSLICE>, Const::<CSLICE>);
|
||||||
$me.$generic_slice_with_steps(start, shape, steps)
|
$me.$generic_slice_with_steps(start, shape, steps)
|
||||||
}
|
}
|
||||||
@ -598,7 +598,7 @@ macro_rules! matrix_slice_impl(
|
|||||||
start: (usize, usize),
|
start: (usize, usize),
|
||||||
shape: (RSlice, CSlice),
|
shape: (RSlice, CSlice),
|
||||||
steps: (usize, usize))
|
steps: (usize, usize))
|
||||||
-> $MatrixSlice<T, RSlice, CSlice, Dynamic, Dynamic>
|
-> $MatrixSlice<'_, T, RSlice, CSlice, Dynamic, Dynamic>
|
||||||
where RSlice: Dim,
|
where RSlice: Dim,
|
||||||
CSlice: Dim {
|
CSlice: Dim {
|
||||||
|
|
||||||
@ -625,13 +625,13 @@ macro_rules! matrix_slice_impl(
|
|||||||
* Splitting.
|
* Splitting.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/// Splits this NxM matrix into two parts delimited by two ranges.
|
/// Splits this `NxM` matrix into two parts delimited by two ranges.
|
||||||
///
|
///
|
||||||
/// Panics if the ranges overlap or if the first range is empty.
|
/// Panics if the ranges overlap or if the first range is empty.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $rows_range_pair<Range1: SliceRange<R>, Range2: SliceRange<R>>($me: $Me, r1: Range1, r2: Range2)
|
pub fn $rows_range_pair<Range1: SliceRange<R>, Range2: SliceRange<R>>($me: $Me, r1: Range1, r2: Range2)
|
||||||
-> ($MatrixSlice<T, Range1::Size, C, S::RStride, S::CStride>,
|
-> ($MatrixSlice<'_, T, Range1::Size, C, S::RStride, S::CStride>,
|
||||||
$MatrixSlice<T, Range2::Size, C, S::RStride, S::CStride>) {
|
$MatrixSlice<'_, T, Range2::Size, C, S::RStride, S::CStride>) {
|
||||||
|
|
||||||
let (nrows, ncols) = $me.data.shape();
|
let (nrows, ncols) = $me.data.shape();
|
||||||
let strides = $me.data.strides();
|
let strides = $me.data.strides();
|
||||||
@ -661,13 +661,13 @@ macro_rules! matrix_slice_impl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Splits this NxM matrix into two parts delimited by two ranges.
|
/// Splits this `NxM` matrix into two parts delimited by two ranges.
|
||||||
///
|
///
|
||||||
/// Panics if the ranges overlap or if the first range is empty.
|
/// Panics if the ranges overlap or if the first range is empty.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn $columns_range_pair<Range1: SliceRange<C>, Range2: SliceRange<C>>($me: $Me, r1: Range1, r2: Range2)
|
pub fn $columns_range_pair<Range1: SliceRange<C>, Range2: SliceRange<C>>($me: $Me, r1: Range1, r2: Range2)
|
||||||
-> ($MatrixSlice<T, R, Range1::Size, S::RStride, S::CStride>,
|
-> ($MatrixSlice<'_, T, R, Range1::Size, S::RStride, S::CStride>,
|
||||||
$MatrixSlice<T, R, Range2::Size, S::RStride, S::CStride>) {
|
$MatrixSlice<'_, T, R, Range2::Size, S::RStride, S::CStride>) {
|
||||||
|
|
||||||
let (nrows, ncols) = $me.data.shape();
|
let (nrows, ncols) = $me.data.shape();
|
||||||
let strides = $me.data.strides();
|
let strides = $me.data.strides();
|
||||||
@ -931,7 +931,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
&self,
|
&self,
|
||||||
rows: RowRange,
|
rows: RowRange,
|
||||||
cols: ColRange,
|
cols: ColRange,
|
||||||
) -> MatrixSlice<T, RowRange::Size, ColRange::Size, S::RStride, S::CStride>
|
) -> MatrixSlice<'_, T, RowRange::Size, ColRange::Size, S::RStride, S::CStride>
|
||||||
where
|
where
|
||||||
RowRange: SliceRange<R>,
|
RowRange: SliceRange<R>,
|
||||||
ColRange: SliceRange<C>,
|
ColRange: SliceRange<C>,
|
||||||
@ -949,7 +949,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
pub fn rows_range<RowRange: SliceRange<R>>(
|
pub fn rows_range<RowRange: SliceRange<R>>(
|
||||||
&self,
|
&self,
|
||||||
rows: RowRange,
|
rows: RowRange,
|
||||||
) -> MatrixSlice<T, RowRange::Size, C, S::RStride, S::CStride> {
|
) -> MatrixSlice<'_, T, RowRange::Size, C, S::RStride, S::CStride> {
|
||||||
self.slice_range(rows, ..)
|
self.slice_range(rows, ..)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -959,7 +959,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
pub fn columns_range<ColRange: SliceRange<C>>(
|
pub fn columns_range<ColRange: SliceRange<C>>(
|
||||||
&self,
|
&self,
|
||||||
cols: ColRange,
|
cols: ColRange,
|
||||||
) -> MatrixSlice<T, R, ColRange::Size, S::RStride, S::CStride> {
|
) -> MatrixSlice<'_, T, R, ColRange::Size, S::RStride, S::CStride> {
|
||||||
self.slice_range(.., cols)
|
self.slice_range(.., cols)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -973,7 +973,7 @@ impl<T, R: Dim, C: Dim, S: StorageMut<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
rows: RowRange,
|
rows: RowRange,
|
||||||
cols: ColRange,
|
cols: ColRange,
|
||||||
) -> MatrixSliceMut<T, RowRange::Size, ColRange::Size, S::RStride, S::CStride>
|
) -> MatrixSliceMut<'_, T, RowRange::Size, ColRange::Size, S::RStride, S::CStride>
|
||||||
where
|
where
|
||||||
RowRange: SliceRange<R>,
|
RowRange: SliceRange<R>,
|
||||||
ColRange: SliceRange<C>,
|
ColRange: SliceRange<C>,
|
||||||
@ -990,7 +990,7 @@ impl<T, R: Dim, C: Dim, S: StorageMut<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
pub fn rows_range_mut<RowRange: SliceRange<R>>(
|
pub fn rows_range_mut<RowRange: SliceRange<R>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
rows: RowRange,
|
rows: RowRange,
|
||||||
) -> MatrixSliceMut<T, RowRange::Size, C, S::RStride, S::CStride> {
|
) -> MatrixSliceMut<'_, T, RowRange::Size, C, S::RStride, S::CStride> {
|
||||||
self.slice_range_mut(rows, ..)
|
self.slice_range_mut(rows, ..)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -999,7 +999,7 @@ impl<T, R: Dim, C: Dim, S: StorageMut<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
pub fn columns_range_mut<ColRange: SliceRange<C>>(
|
pub fn columns_range_mut<ColRange: SliceRange<C>>(
|
||||||
&mut self,
|
&mut self,
|
||||||
cols: ColRange,
|
cols: ColRange,
|
||||||
) -> MatrixSliceMut<T, R, ColRange::Size, S::RStride, S::CStride> {
|
) -> MatrixSliceMut<'_, T, R, ColRange::Size, S::RStride, S::CStride> {
|
||||||
self.slice_range_mut(.., cols)
|
self.slice_range_mut(.., cols)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,10 +40,13 @@ pub trait Norm<T: SimdComplexField> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Euclidean norm.
|
/// Euclidean norm.
|
||||||
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct EuclideanNorm;
|
pub struct EuclideanNorm;
|
||||||
/// Lp norm.
|
/// Lp norm.
|
||||||
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct LpNorm(pub i32);
|
pub struct LpNorm(pub i32);
|
||||||
/// L-infinite norm aka. Chebytchev norm aka. uniform norm aka. suppremum norm.
|
/// L-infinite norm aka. Chebytchev norm aka. uniform norm aka. suppremum norm.
|
||||||
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct UniformNorm;
|
pub struct UniformNorm;
|
||||||
|
|
||||||
impl<T: SimdComplexField> Norm<T> for EuclideanNorm {
|
impl<T: SimdComplexField> Norm<T> for EuclideanNorm {
|
||||||
|
@ -706,8 +706,8 @@ where
|
|||||||
rhs: &Matrix<T, R2, C2, SB>,
|
rhs: &Matrix<T, R2, C2, SB>,
|
||||||
out: &mut Matrix<MaybeUninit<T>, R3, C3, SC>,
|
out: &mut Matrix<MaybeUninit<T>, R3, C3, SC>,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&VectorSlice<T, R1, SA::RStride, SA::CStride>,
|
&VectorSlice<'_, T, R1, SA::RStride, SA::CStride>,
|
||||||
&VectorSlice<T, R2, SB::RStride, SB::CStride>,
|
&VectorSlice<'_, T, R2, SB::RStride, SB::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) where
|
) where
|
||||||
SB: Storage<T, R2, C2>,
|
SB: Storage<T, R2, C2>,
|
||||||
|
@ -14,7 +14,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn compress_rows(
|
pub fn compress_rows(
|
||||||
&self,
|
&self,
|
||||||
f: impl Fn(VectorSlice<T, R, S::RStride, S::CStride>) -> T,
|
f: impl Fn(VectorSlice<'_, T, R, S::RStride, S::CStride>) -> T,
|
||||||
) -> RowOVector<T, C>
|
) -> RowOVector<T, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, U1, C>,
|
DefaultAllocator: Allocator<T, U1, C>,
|
||||||
@ -40,7 +40,7 @@ impl<T, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn compress_rows_tr(
|
pub fn compress_rows_tr(
|
||||||
&self,
|
&self,
|
||||||
f: impl Fn(VectorSlice<T, R, S::RStride, S::CStride>) -> T,
|
f: impl Fn(VectorSlice<'_, T, R, S::RStride, S::CStride>) -> T,
|
||||||
) -> OVector<T, C>
|
) -> OVector<T, C>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, C>,
|
DefaultAllocator: Allocator<T, C>,
|
||||||
|
@ -238,7 +238,7 @@ impl<T> Unit<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the underlying value.
|
/// Retrieves the underlying value.
|
||||||
/// Deprecated: use [Unit::into_inner] instead.
|
/// Deprecated: use [`Unit::into_inner`] instead.
|
||||||
#[deprecated(note = "use `.into_inner()` instead")]
|
#[deprecated(note = "use `.into_inner()` instead")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn unwrap(self) -> T {
|
pub fn unwrap(self) -> T {
|
||||||
|
@ -78,7 +78,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[deprecated(note = "renamed to `VecStorage`")]
|
#[deprecated(note = "renamed to `VecStorage`")]
|
||||||
/// Renamed to [VecStorage].
|
/// Renamed to [`VecStorage`].
|
||||||
pub type MatrixVec<T, R, C> = VecStorage<T, R, C>;
|
pub type MatrixVec<T, R, C> = VecStorage<T, R, C>;
|
||||||
|
|
||||||
impl<T, R: Dim, C: Dim> VecStorage<T, R, C> {
|
impl<T, R: Dim, C: Dim> VecStorage<T, R, C> {
|
||||||
|
@ -16,7 +16,7 @@ use simba::scalar::RealField;
|
|||||||
///
|
///
|
||||||
/// # Indexing
|
/// # Indexing
|
||||||
///
|
///
|
||||||
/// DualQuaternions are stored as \[..real, ..dual\].
|
/// `DualQuaternions` are stored as \[..real, ..dual\].
|
||||||
/// Both of the quaternion components are laid out in `i, j, k, w` order.
|
/// Both of the quaternion components are laid out in `i, j, k, w` order.
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
@ -36,7 +36,7 @@ use simba::scalar::RealField;
|
|||||||
/// NOTE:
|
/// NOTE:
|
||||||
/// As of December 2020, dual quaternion support is a work in progress.
|
/// As of December 2020, dual quaternion support is a work in progress.
|
||||||
/// If a feature that you need is missing, feel free to open an issue or a PR.
|
/// If a feature that you need is missing, feel free to open an issue or a PR.
|
||||||
/// See https://github.com/dimforge/nalgebra/issues/487
|
/// See <https://github.com/dimforge/nalgebra/issues/487>
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct DualQuaternion<T> {
|
pub struct DualQuaternion<T> {
|
||||||
@ -250,6 +250,22 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T> bytemuck::Zeroable for DualQuaternion<T>
|
||||||
|
where
|
||||||
|
T: Scalar + bytemuck::Zeroable,
|
||||||
|
Quaternion<T>: bytemuck::Zeroable,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T> bytemuck::Pod for DualQuaternion<T>
|
||||||
|
where
|
||||||
|
T: Scalar + bytemuck::Pod,
|
||||||
|
Quaternion<T>: bytemuck::Pod,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
impl<T: Serialize> Serialize for DualQuaternion<T> {
|
impl<T: Serialize> Serialize for DualQuaternion<T> {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
|
||||||
@ -897,7 +913,7 @@ impl<T: RealField> Default for UnitDualQuaternion<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: RealField + fmt::Display> fmt::Display for UnitDualQuaternion<T> {
|
impl<T: RealField + fmt::Display> fmt::Display for UnitDualQuaternion<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if let Some(axis) = self.rotation().axis() {
|
if let Some(axis) = self.rotation().axis() {
|
||||||
let axis = axis.into_inner();
|
let axis = axis.into_inner();
|
||||||
write!(
|
write!(
|
||||||
|
@ -634,7 +634,7 @@ impl<T: Scalar + fmt::Display, R, const D: usize> fmt::Display for Isometry<T, R
|
|||||||
where
|
where
|
||||||
R: fmt::Display,
|
R: fmt::Display,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let precision = f.precision().unwrap_or(3);
|
let precision = f.precision().unwrap_or(3);
|
||||||
|
|
||||||
writeln!(f, "Isometry {{")?;
|
writeln!(f, "Isometry {{")?;
|
||||||
|
@ -308,7 +308,7 @@ macro_rules! look_at_isometry_construction_impl(
|
|||||||
$RotId::face_towards(&(target - eye), up))
|
$RotId::face_towards(&(target - eye), up))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated: Use [Isometry::face_towards] instead.
|
/// Deprecated: Use [`Isometry::face_towards`] instead.
|
||||||
#[deprecated(note="renamed to `face_towards`")]
|
#[deprecated(note="renamed to `face_towards`")]
|
||||||
pub fn new_observer_frame(eye: &Point3<T>,
|
pub fn new_observer_frame(eye: &Point3<T>,
|
||||||
target: &Point3<T>,
|
target: &Point3<T>,
|
||||||
|
@ -73,6 +73,7 @@ mod transform_ops;
|
|||||||
mod transform_simba;
|
mod transform_simba;
|
||||||
|
|
||||||
mod reflection;
|
mod reflection;
|
||||||
|
mod reflection_alias;
|
||||||
|
|
||||||
mod orthographic;
|
mod orthographic;
|
||||||
mod perspective;
|
mod perspective;
|
||||||
@ -104,6 +105,7 @@ pub use self::transform::*;
|
|||||||
pub use self::transform_alias::*;
|
pub use self::transform_alias::*;
|
||||||
|
|
||||||
pub use self::reflection::*;
|
pub use self::reflection::*;
|
||||||
|
pub use self::reflection_alias::*;
|
||||||
|
|
||||||
pub use self::orthographic::Orthographic3;
|
pub use self::orthographic::Orthographic3;
|
||||||
pub use self::perspective::Perspective3;
|
pub use self::perspective::Perspective3;
|
||||||
|
@ -47,6 +47,22 @@ impl<T: PartialEq> PartialEq for Orthographic3<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T> bytemuck::Zeroable for Orthographic3<T>
|
||||||
|
where
|
||||||
|
T: RealField + bytemuck::Zeroable,
|
||||||
|
Matrix4<T>: bytemuck::Zeroable,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T> bytemuck::Pod for Orthographic3<T>
|
||||||
|
where
|
||||||
|
T: RealField + bytemuck::Pod,
|
||||||
|
Matrix4<T>: bytemuck::Pod,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
impl<T: Serialize> Serialize for Orthographic3<T> {
|
impl<T: Serialize> Serialize for Orthographic3<T> {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@ -81,7 +97,7 @@ impl<T> Orthographic3<T> {
|
|||||||
/// # use nalgebra::{Orthographic3, Point3};
|
/// # use nalgebra::{Orthographic3, Point3};
|
||||||
/// let proj = Orthographic3::new(1.0, 10.0, 2.0, 20.0, 0.1, 1000.0);
|
/// let proj = Orthographic3::new(1.0, 10.0, 2.0, 20.0, 0.1, 1000.0);
|
||||||
/// // Check this projection actually transforms the view cuboid into the double-unit cube.
|
/// // Check this projection actually transforms the view cuboid into the double-unit cube.
|
||||||
/// // See https://www.nalgebra.org/projections/#orthographic-projection for more details.
|
/// // See https://www.nalgebra.org/docs/user_guide/projections#orthographic-projection for more details.
|
||||||
/// let p1 = Point3::new(1.0, 2.0, -0.1);
|
/// let p1 = Point3::new(1.0, 2.0, -0.1);
|
||||||
/// let p2 = Point3::new(1.0, 2.0, -1000.0);
|
/// let p2 = Point3::new(1.0, 2.0, -1000.0);
|
||||||
/// let p3 = Point3::new(1.0, 20.0, -0.1);
|
/// let p3 = Point3::new(1.0, 20.0, -0.1);
|
||||||
@ -128,28 +144,6 @@ impl<T> Orthographic3<T> {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps the given matrix to interpret it as a 3D orthographic matrix.
|
|
||||||
///
|
|
||||||
/// It is not checked whether or not the given matrix actually represents an orthographic
|
|
||||||
/// projection.
|
|
||||||
///
|
|
||||||
/// # Example
|
|
||||||
/// ```
|
|
||||||
/// # use nalgebra::{Orthographic3, Point3, Matrix4};
|
|
||||||
/// let mat = Matrix4::new(
|
|
||||||
/// 2.0 / 9.0, 0.0, 0.0, -11.0 / 9.0,
|
|
||||||
/// 0.0, 2.0 / 18.0, 0.0, -22.0 / 18.0,
|
|
||||||
/// 0.0, 0.0, -2.0 / 999.9, -1000.1 / 999.9,
|
|
||||||
/// 0.0, 0.0, 0.0, 1.0
|
|
||||||
/// );
|
|
||||||
/// let proj = Orthographic3::from_matrix_unchecked(mat);
|
|
||||||
/// assert_eq!(proj, Orthographic3::new(1.0, 10.0, 2.0, 20.0, 0.1, 1000.0));
|
|
||||||
/// ```
|
|
||||||
#[inline]
|
|
||||||
pub fn from_matrix_unchecked(matrix: Matrix4<T>) -> Self {
|
|
||||||
Self { matrix }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a new orthographic projection matrix from an aspect ratio and the vertical field of view.
|
/// Creates a new orthographic projection matrix from an aspect ratio and the vertical field of view.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_fov(aspect: T, vfov: T, znear: T, zfar: T) -> Self
|
pub fn from_fov(aspect: T, vfov: T, znear: T, zfar: T) -> Self
|
||||||
@ -311,7 +305,7 @@ impl<T> Orthographic3<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the underlying homogeneous matrix.
|
/// Retrieves the underlying homogeneous matrix.
|
||||||
/// Deprecated: Use [Orthographic3::into_inner] instead.
|
/// Deprecated: Use [`Orthographic3::into_inner`] instead.
|
||||||
#[deprecated(note = "use `.into_inner()` instead")]
|
#[deprecated(note = "use `.into_inner()` instead")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn unwrap(self) -> Matrix4<T> {
|
pub fn unwrap(self) -> Matrix4<T> {
|
||||||
|
@ -19,6 +19,7 @@ use crate::base::{Matrix4, Vector, Vector3};
|
|||||||
use crate::geometry::{Point3, Projective3};
|
use crate::geometry::{Point3, Projective3};
|
||||||
|
|
||||||
/// A 3D perspective projection stored as a homogeneous 4x4 matrix.
|
/// A 3D perspective projection stored as a homogeneous 4x4 matrix.
|
||||||
|
#[repr(C)]
|
||||||
pub struct Perspective3<T> {
|
pub struct Perspective3<T> {
|
||||||
matrix: Matrix4<T>,
|
matrix: Matrix4<T>,
|
||||||
}
|
}
|
||||||
@ -45,6 +46,22 @@ impl<T: RealField> PartialEq for Perspective3<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T> bytemuck::Zeroable for Perspective3<T>
|
||||||
|
where
|
||||||
|
T: RealField + bytemuck::Zeroable,
|
||||||
|
Matrix4<T>: bytemuck::Zeroable,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T> bytemuck::Pod for Perspective3<T>
|
||||||
|
where
|
||||||
|
T: RealField + bytemuck::Pod,
|
||||||
|
Matrix4<T>: bytemuck::Pod,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
impl<T: RealField + Serialize> Serialize for Perspective3<T> {
|
impl<T: RealField + Serialize> Serialize for Perspective3<T> {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@ -67,6 +84,17 @@ impl<'a, T: RealField + Deserialize<'a>> Deserialize<'a> for Perspective3<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Perspective3<T> {
|
||||||
|
/// Wraps the given matrix to interpret it as a 3D perspective matrix.
|
||||||
|
///
|
||||||
|
/// It is not checked whether or not the given matrix actually represents a perspective
|
||||||
|
/// projection.
|
||||||
|
#[inline]
|
||||||
|
pub const fn from_matrix_unchecked(matrix: Matrix4<T>) -> Self {
|
||||||
|
Self { matrix }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: RealField> Perspective3<T> {
|
impl<T: RealField> Perspective3<T> {
|
||||||
/// Creates a new perspective matrix from the aspect ratio, y field of view, and near/far planes.
|
/// Creates a new perspective matrix from the aspect ratio, y field of view, and near/far planes.
|
||||||
pub fn new(aspect: T, fovy: T, znear: T, zfar: T) -> Self {
|
pub fn new(aspect: T, fovy: T, znear: T, zfar: T) -> Self {
|
||||||
@ -92,15 +120,6 @@ impl<T: RealField> Perspective3<T> {
|
|||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps the given matrix to interpret it as a 3D perspective matrix.
|
|
||||||
///
|
|
||||||
/// It is not checked whether or not the given matrix actually represents a perspective
|
|
||||||
/// projection.
|
|
||||||
#[inline]
|
|
||||||
pub fn from_matrix_unchecked(matrix: Matrix4<T>) -> Self {
|
|
||||||
Self { matrix }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retrieves the inverse of the underlying homogeneous matrix.
|
/// Retrieves the inverse of the underlying homogeneous matrix.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -157,7 +176,7 @@ impl<T: RealField> Perspective3<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the underlying homogeneous matrix.
|
/// Retrieves the underlying homogeneous matrix.
|
||||||
/// Deprecated: Use [Perspective3::into_inner] instead.
|
/// Deprecated: Use [`Perspective3::into_inner`] instead.
|
||||||
#[deprecated(note = "use `.into_inner()` instead")]
|
#[deprecated(note = "use `.into_inner()` instead")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn unwrap(self) -> Matrix4<T> {
|
pub fn unwrap(self) -> Matrix4<T> {
|
||||||
|
@ -25,7 +25,7 @@ use crate::Scalar;
|
|||||||
|
|
||||||
/// A point in an euclidean space.
|
/// A point in an euclidean space.
|
||||||
///
|
///
|
||||||
/// The difference between a point and a vector is only semantic. See [the user guide](https://www.nalgebra.org/points_and_transformations/)
|
/// The difference between a point and a vector is only semantic. See [the user guide](https://www.nalgebra.org/docs/user_guide/points_and_transformations)
|
||||||
/// for details on the distinction. The most notable difference that vectors ignore translations.
|
/// for details on the distinction. The most notable difference that vectors ignore translations.
|
||||||
/// In particular, an [`Isometry2`](crate::Isometry2) or [`Isometry3`](crate::Isometry3) will
|
/// In particular, an [`Isometry2`](crate::Isometry2) or [`Isometry3`](crate::Isometry3) will
|
||||||
/// transform points by applying a rotation and a translation on them. However, these isometries
|
/// transform points by applying a rotation and a translation on them. However, these isometries
|
||||||
@ -501,7 +501,7 @@ impl<T: fmt::Display, D: DimName> fmt::Display for OPoint<T, D>
|
|||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, D>,
|
DefaultAllocator: Allocator<T, D>,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{{")?;
|
write!(f, "{{")?;
|
||||||
|
|
||||||
let mut it = self.coords.iter();
|
let mut it = self.coords.iter();
|
||||||
|
@ -241,7 +241,7 @@ where
|
|||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn vector(&self) -> MatrixSlice<T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>> {
|
pub fn vector(&self) -> MatrixSlice<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>> {
|
||||||
self.coords.fixed_rows::<3>(0)
|
self.coords.fixed_rows::<3>(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -633,7 +633,7 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
pub fn vector_mut(
|
pub fn vector_mut(
|
||||||
&mut self,
|
&mut self,
|
||||||
) -> MatrixSliceMut<T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>> {
|
) -> MatrixSliceMut<'_, T, U3, U1, RStride<T, U4, U1>, CStride<T, U4, U1>> {
|
||||||
self.coords.fixed_rows_mut::<3>(0)
|
self.coords.fixed_rows_mut::<3>(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1692,7 +1692,7 @@ impl<T: RealField> Default for UnitQuaternion<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: RealField + fmt::Display> fmt::Display for UnitQuaternion<T> {
|
impl<T: RealField + fmt::Display> fmt::Display for UnitQuaternion<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
if let Some(axis) = self.axis() {
|
if let Some(axis) = self.axis() {
|
||||||
let axis = axis.into_inner();
|
let axis = axis.into_inner();
|
||||||
write!(
|
write!(
|
||||||
|
@ -591,7 +591,7 @@ where
|
|||||||
Self::from_rotation_matrix(&Rotation3::face_towards(dir, up))
|
Self::from_rotation_matrix(&Rotation3::face_towards(dir, up))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated: Use [UnitQuaternion::face_towards] instead.
|
/// Deprecated: Use [`UnitQuaternion::face_towards`] instead.
|
||||||
#[deprecated(note = "renamed to `face_towards`")]
|
#[deprecated(note = "renamed to `face_towards`")]
|
||||||
pub fn new_observer_frames<SB, SC>(dir: &Vector<T, U3, SB>, up: &Vector<T, U3, SC>) -> Self
|
pub fn new_observer_frames<SB, SC>(dir: &Vector<T, U3, SB>, up: &Vector<T, U3, SC>) -> Self
|
||||||
where
|
where
|
||||||
@ -785,7 +785,7 @@ where
|
|||||||
Self::new_eps(axisangle, eps)
|
Self::new_eps(axisangle, eps)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create the mean unit quaternion from a data structure implementing IntoIterator
|
/// Create the mean unit quaternion from a data structure implementing `IntoIterator`
|
||||||
/// returning unit quaternions.
|
/// returning unit quaternions.
|
||||||
///
|
///
|
||||||
/// The method will panic if the iterator does not return any quaternions.
|
/// The method will panic if the iterator does not return any quaternions.
|
||||||
@ -894,9 +894,9 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[cfg(feature = "rand")]
|
#[cfg(feature = "rand")]
|
||||||
mod tests {
|
mod tests {
|
||||||
extern crate rand_xorshift;
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use rand::SeedableRng;
|
use rand::SeedableRng;
|
||||||
|
use rand_xorshift;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn random_unit_quats_are_unit() {
|
fn random_unit_quats_are_unit() {
|
||||||
|
@ -24,7 +24,7 @@ impl<T: ComplexField, S: Storage<T, Const<D>>, const D: usize> Reflection<T, Con
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: ComplexField, D: Dim, S: Storage<T, D>> Reflection<T, D, S> {
|
impl<T: ComplexField, D: Dim, S: Storage<T, D>> Reflection<T, D, S> {
|
||||||
/// Creates a new reflection wrt the plane orthogonal to the given axis and bias.
|
/// Creates a new reflection wrt. the plane orthogonal to the given axis and bias.
|
||||||
///
|
///
|
||||||
/// The bias is the position of the plane on the axis. In particular, a bias equal to zero
|
/// The bias is the position of the plane on the axis. In particular, a bias equal to zero
|
||||||
/// represents a plane that passes through the origin.
|
/// represents a plane that passes through the origin.
|
||||||
@ -35,12 +35,21 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D>> Reflection<T, D, S> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The reflexion axis.
|
/// The reflection axis.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn axis(&self) -> &Vector<T, D, S> {
|
pub fn axis(&self) -> &Vector<T, D, S> {
|
||||||
&self.axis
|
&self.axis
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The reflection bias.
|
||||||
|
///
|
||||||
|
/// The bias is the position of the plane on the axis. In particular, a bias equal to zero
|
||||||
|
/// represents a plane that passes through the origin.
|
||||||
|
#[must_use]
|
||||||
|
pub fn bias(&self) -> T {
|
||||||
|
self.bias
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: naming convention: reflect_to, reflect_assign ?
|
// TODO: naming convention: reflect_to, reflect_assign ?
|
||||||
/// Applies the reflection to the columns of `rhs`.
|
/// Applies the reflection to the columns of `rhs`.
|
||||||
pub fn reflect<R2: Dim, C2: Dim, S2>(&self, rhs: &mut Matrix<T, R2, C2, S2>)
|
pub fn reflect<R2: Dim, C2: Dim, S2>(&self, rhs: &mut Matrix<T, R2, C2, S2>)
|
||||||
|
21
src/geometry/reflection_alias.rs
Normal file
21
src/geometry/reflection_alias.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use crate::base::ArrayStorage;
|
||||||
|
use crate::geometry::Reflection;
|
||||||
|
use crate::Const;
|
||||||
|
|
||||||
|
/// A 1-dimensional reflection.
|
||||||
|
pub type Reflection1<T> = Reflection<T, Const<1>, ArrayStorage<T, 1, 1>>;
|
||||||
|
|
||||||
|
/// A 2-dimensional reflection.
|
||||||
|
pub type Reflection2<T> = Reflection<T, Const<2>, ArrayStorage<T, 2, 1>>;
|
||||||
|
|
||||||
|
/// A 3-dimensional reflection.
|
||||||
|
pub type Reflection3<T> = Reflection<T, Const<3>, ArrayStorage<T, 3, 1>>;
|
||||||
|
|
||||||
|
/// A 4-dimensional reflection.
|
||||||
|
pub type Reflection4<T> = Reflection<T, Const<4>, ArrayStorage<T, 4, 1>>;
|
||||||
|
|
||||||
|
/// A 5-dimensional reflection.
|
||||||
|
pub type Reflection5<T> = Reflection<T, Const<5>, ArrayStorage<T, 5, 1>>;
|
||||||
|
|
||||||
|
/// A 6-dimensional reflection.
|
||||||
|
pub type Reflection6<T> = Reflection<T, Const<6>, ArrayStorage<T, 6, 1>>;
|
@ -81,6 +81,22 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T, const D: usize> bytemuck::Zeroable for Rotation<T, D>
|
||||||
|
where
|
||||||
|
T: Scalar + bytemuck::Zeroable,
|
||||||
|
SMatrix<T, D, D>: bytemuck::Zeroable,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T, const D: usize> bytemuck::Pod for Rotation<T, D>
|
||||||
|
where
|
||||||
|
T: Scalar + bytemuck::Pod,
|
||||||
|
SMatrix<T, D, D>: bytemuck::Pod,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
impl<T, const D: usize> Abomonation for Rotation<T, D>
|
impl<T, const D: usize> Abomonation for Rotation<T, D>
|
||||||
where
|
where
|
||||||
@ -130,7 +146,7 @@ where
|
|||||||
impl<T, const D: usize> Rotation<T, D> {
|
impl<T, const D: usize> Rotation<T, D> {
|
||||||
/// Creates a new rotation from the given square matrix.
|
/// Creates a new rotation from the given square matrix.
|
||||||
///
|
///
|
||||||
/// The matrix squareness is checked but not its orthonormality.
|
/// The matrix orthonormality is not checked.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
@ -151,12 +167,7 @@ impl<T, const D: usize> Rotation<T, D> {
|
|||||||
/// assert_eq!(*rot.matrix(), mat);
|
/// assert_eq!(*rot.matrix(), mat);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_matrix_unchecked(matrix: SMatrix<T, D, D>) -> Self {
|
pub const fn from_matrix_unchecked(matrix: SMatrix<T, D, D>) -> Self {
|
||||||
assert!(
|
|
||||||
matrix.is_square(),
|
|
||||||
"Unable to create a rotation from a non-square matrix."
|
|
||||||
);
|
|
||||||
|
|
||||||
Self { matrix }
|
Self { matrix }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +241,7 @@ impl<T, const D: usize> Rotation<T, D> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Unwraps the underlying matrix.
|
/// Unwraps the underlying matrix.
|
||||||
/// Deprecated: Use [Rotation::into_inner] instead.
|
/// Deprecated: Use [`Rotation::into_inner`] instead.
|
||||||
#[deprecated(note = "use `.into_inner()` instead")]
|
#[deprecated(note = "use `.into_inner()` instead")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn unwrap(self) -> SMatrix<T, D, D> {
|
pub fn unwrap(self) -> SMatrix<T, D, D> {
|
||||||
@ -562,7 +573,7 @@ impl<T, const D: usize> fmt::Display for Rotation<T, D>
|
|||||||
where
|
where
|
||||||
T: RealField + fmt::Display,
|
T: RealField + fmt::Display,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let precision = f.precision().unwrap_or(3);
|
let precision = f.precision().unwrap_or(3);
|
||||||
|
|
||||||
writeln!(f, "Rotation matrix {{")?;
|
writeln!(f, "Rotation matrix {{")?;
|
||||||
|
@ -483,7 +483,7 @@ where
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated: Use [Rotation3::face_towards] instead.
|
/// Deprecated: Use [`Rotation3::face_towards`] instead.
|
||||||
#[deprecated(note = "renamed to `face_towards`")]
|
#[deprecated(note = "renamed to `face_towards`")]
|
||||||
pub fn new_observer_frames<SB, SC>(dir: &Vector<T, U3, SB>, up: &Vector<T, U3, SC>) -> Self
|
pub fn new_observer_frames<SB, SC>(dir: &Vector<T, U3, SB>, up: &Vector<T, U3, SC>) -> Self
|
||||||
where
|
where
|
||||||
|
@ -428,7 +428,7 @@ where
|
|||||||
T: RealField + fmt::Display,
|
T: RealField + fmt::Display,
|
||||||
R: AbstractRotation<T, D> + fmt::Display,
|
R: AbstractRotation<T, D> + fmt::Display,
|
||||||
{
|
{
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let precision = f.precision().unwrap_or(3);
|
let precision = f.precision().unwrap_or(3);
|
||||||
|
|
||||||
writeln!(f, "Similarity {{")?;
|
writeln!(f, "Similarity {{")?;
|
||||||
|
@ -306,7 +306,7 @@ macro_rules! similarity_construction_impl(
|
|||||||
Self::from_isometry(Isometry::<_, $Rot<T>, 3>::face_towards(eye, target, up), scaling)
|
Self::from_isometry(Isometry::<_, $Rot<T>, 3>::face_towards(eye, target, up), scaling)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Deprecated: Use [SimilarityMatrix3::face_towards] instead.
|
/// Deprecated: Use [`SimilarityMatrix3::face_towards`] instead.
|
||||||
#[deprecated(note="renamed to `face_towards`")]
|
#[deprecated(note="renamed to `face_towards`")]
|
||||||
pub fn new_observer_frames(eye: &Point3<T>,
|
pub fn new_observer_frames(eye: &Point3<T>,
|
||||||
target: &Point3<T>,
|
target: &Point3<T>,
|
||||||
|
@ -300,7 +300,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the underlying matrix.
|
/// Retrieves the underlying matrix.
|
||||||
/// Deprecated: Use [Transform::into_inner] instead.
|
/// Deprecated: Use [`Transform::into_inner`] instead.
|
||||||
#[deprecated(note = "use `.into_inner()` instead")]
|
#[deprecated(note = "use `.into_inner()` instead")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn unwrap(self) -> OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>> {
|
pub fn unwrap(self) -> OMatrix<T, DimNameSum<Const<D>, U1>, DimNameSum<Const<D>, U1>> {
|
||||||
|
@ -13,7 +13,7 @@ use crate::storage::InnerOwned;
|
|||||||
|
|
||||||
use crate::geometry::{
|
use crate::geometry::{
|
||||||
Isometry, Point, Rotation, Similarity, SubTCategoryOf, SuperTCategoryOf, TAffine, TCategory,
|
Isometry, Point, Rotation, Similarity, SubTCategoryOf, SuperTCategoryOf, TAffine, TCategory,
|
||||||
TCategoryMul, TGeneral, TProjective, Transform, Translation, UnitQuaternion,
|
TCategoryMul, TGeneral, TProjective, Transform, Translation, UnitComplex, UnitQuaternion,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -31,7 +31,7 @@ use crate::geometry::{
|
|||||||
* Transform × Similarity
|
* Transform × Similarity
|
||||||
* Transform × Transform
|
* Transform × Transform
|
||||||
* Transform × UnitQuaternion
|
* Transform × UnitQuaternion
|
||||||
* TODO: Transform × UnitComplex
|
* Transform × UnitComplex
|
||||||
* Transform × Translation
|
* Transform × Translation
|
||||||
* Transform × Vector
|
* Transform × Vector
|
||||||
* Transform × Point
|
* Transform × Point
|
||||||
@ -41,7 +41,7 @@ use crate::geometry::{
|
|||||||
* Similarity × Transform
|
* Similarity × Transform
|
||||||
* Translation × Transform
|
* Translation × Transform
|
||||||
* UnitQuaternion × Transform
|
* UnitQuaternion × Transform
|
||||||
* TODO: UnitComplex × Transform
|
* UnitComplex × Transform
|
||||||
*
|
*
|
||||||
* TODO: Transform ÷ Isometry
|
* TODO: Transform ÷ Isometry
|
||||||
* Transform ÷ Rotation
|
* Transform ÷ Rotation
|
||||||
@ -66,7 +66,7 @@ use crate::geometry::{
|
|||||||
* Transform ×= Isometry
|
* Transform ×= Isometry
|
||||||
* Transform ×= Rotation
|
* Transform ×= Rotation
|
||||||
* Transform ×= UnitQuaternion
|
* Transform ×= UnitQuaternion
|
||||||
* TODO: Transform ×= UnitComplex
|
* Transform ×= UnitComplex
|
||||||
* Transform ×= Translation
|
* Transform ×= Translation
|
||||||
*
|
*
|
||||||
* Transform ÷= Transform
|
* Transform ÷= Transform
|
||||||
@ -74,7 +74,7 @@ use crate::geometry::{
|
|||||||
* TODO: Transform ÷= Isometry
|
* TODO: Transform ÷= Isometry
|
||||||
* Transform ÷= Rotation
|
* Transform ÷= Rotation
|
||||||
* Transform ÷= UnitQuaternion
|
* Transform ÷= UnitQuaternion
|
||||||
* TODO: Transform ÷= UnitComplex
|
* Transform ÷= UnitComplex
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -226,6 +226,20 @@ md_impl_all!(
|
|||||||
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Transform × UnitComplex
|
||||||
|
md_impl_all!(
|
||||||
|
Mul, mul where T: RealField;
|
||||||
|
(U3, U3), (U2, U1)
|
||||||
|
const;
|
||||||
|
for C;
|
||||||
|
where C: TCategoryMul<TAffine>;
|
||||||
|
self: Transform<T, C, 2>, rhs: UnitComplex<T>, Output = Transform<T, C::Representative, 2>;
|
||||||
|
[val val] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
||||||
|
[ref val] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
||||||
|
[val ref] => Self::Output::from_matrix_unchecked(self.into_inner() * rhs.to_homogeneous());
|
||||||
|
[ref ref] => Self::Output::from_matrix_unchecked(self.matrix() * rhs.to_homogeneous());
|
||||||
|
);
|
||||||
|
|
||||||
// UnitQuaternion × Transform
|
// UnitQuaternion × Transform
|
||||||
md_impl_all!(
|
md_impl_all!(
|
||||||
Mul, mul where T: RealField;
|
Mul, mul where T: RealField;
|
||||||
@ -240,6 +254,20 @@ md_impl_all!(
|
|||||||
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// UnitComplex × Transform
|
||||||
|
md_impl_all!(
|
||||||
|
Mul, mul where T: RealField;
|
||||||
|
(U2, U1), (U3, U3)
|
||||||
|
const;
|
||||||
|
for C;
|
||||||
|
where C: TCategoryMul<TAffine>;
|
||||||
|
self: UnitComplex<T>, rhs: Transform<T, C, 2>, Output = Transform<T, C::Representative, 2>;
|
||||||
|
[val val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner());
|
||||||
|
[ref val] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.into_inner());
|
||||||
|
[val ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
||||||
|
[ref ref] => Self::Output::from_matrix_unchecked(self.to_homogeneous() * rhs.matrix());
|
||||||
|
);
|
||||||
|
|
||||||
// Transform × Isometry
|
// Transform × Isometry
|
||||||
md_impl_all!(
|
md_impl_all!(
|
||||||
Mul, mul where T: RealField;
|
Mul, mul where T: RealField;
|
||||||
@ -581,6 +609,18 @@ md_assign_impl_all!(
|
|||||||
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Transform ×= UnitComplex
|
||||||
|
md_assign_impl_all!(
|
||||||
|
MulAssign, mul_assign where T: RealField;
|
||||||
|
(U3, U3), (U2, U1)
|
||||||
|
const;
|
||||||
|
for C;
|
||||||
|
where C: TCategory;
|
||||||
|
self: Transform<T, C, 2>, rhs: UnitComplex<T>;
|
||||||
|
[val] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
||||||
|
[ref] => *self.matrix_mut_unchecked() *= rhs.to_homogeneous();
|
||||||
|
);
|
||||||
|
|
||||||
// Transform ÷= Transform
|
// Transform ÷= Transform
|
||||||
md_assign_impl_all!(
|
md_assign_impl_all!(
|
||||||
DivAssign, div_assign where T: RealField;
|
DivAssign, div_assign where T: RealField;
|
||||||
@ -653,3 +693,15 @@ md_assign_impl_all!(
|
|||||||
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
||||||
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Transform ÷= UnitComplex
|
||||||
|
md_assign_impl_all!(
|
||||||
|
DivAssign, div_assign where T: RealField;
|
||||||
|
(U3, U3), (U2, U1)
|
||||||
|
const;
|
||||||
|
for C;
|
||||||
|
where C: TCategory;
|
||||||
|
self: Transform<T, C, 2>, rhs: UnitComplex<T>;
|
||||||
|
[val] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
||||||
|
[ref] => #[allow(clippy::suspicious_op_assign_impl)] { *self *= rhs.inverse() };
|
||||||
|
);
|
||||||
|
@ -50,6 +50,22 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T, const D: usize> bytemuck::Zeroable for Translation<T, D>
|
||||||
|
where
|
||||||
|
T: Scalar + bytemuck::Zeroable,
|
||||||
|
SVector<T, D>: bytemuck::Zeroable,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "bytemuck")]
|
||||||
|
unsafe impl<T, const D: usize> bytemuck::Pod for Translation<T, D>
|
||||||
|
where
|
||||||
|
T: Scalar + bytemuck::Pod,
|
||||||
|
SVector<T, D>: bytemuck::Pod,
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
impl<T, const D: usize> Abomonation for Translation<T, D>
|
impl<T, const D: usize> Abomonation for Translation<T, D>
|
||||||
where
|
where
|
||||||
@ -331,7 +347,7 @@ where
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
impl<T: Scalar + fmt::Display, const D: usize> fmt::Display for Translation<T, D> {
|
impl<T: Scalar + fmt::Display, const D: usize> fmt::Display for Translation<T, D> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
let precision = f.precision().unwrap_or(3);
|
let precision = f.precision().unwrap_or(3);
|
||||||
|
|
||||||
writeln!(f, "Translation {{")?;
|
writeln!(f, "Translation {{")?;
|
||||||
|
@ -412,7 +412,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: RealField + fmt::Display> fmt::Display for UnitComplex<T> {
|
impl<T: RealField + fmt::Display> fmt::Display for UnitComplex<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "UnitComplex angle: {}", self.angle())
|
write!(f, "UnitComplex angle: {}", self.angle())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
89
src/lib.rs
89
src/lib.rs
@ -1,4 +1,3 @@
|
|||||||
#![allow(clippy::type_complexity)]
|
|
||||||
/*!
|
/*!
|
||||||
# nalgebra
|
# nalgebra
|
||||||
|
|
||||||
@ -72,16 +71,18 @@ an optimized set of tools for computer graphics and physics. Those features incl
|
|||||||
* Insertion and removal of rows of columns of a matrix.
|
* Insertion and removal of rows of columns of a matrix.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #![feature(plugin)]
|
#![allow(unused_variables, unused_mut)]
|
||||||
//
|
#![deny(
|
||||||
// #![plugin(clippy)]
|
nonstandard_style,
|
||||||
|
unused_parens,
|
||||||
#![deny(non_camel_case_types)]
|
unused_qualifications,
|
||||||
#![deny(unused_parens)]
|
unused_results,
|
||||||
#![deny(non_upper_case_globals)]
|
missing_docs,
|
||||||
#![deny(unused_qualifications)]
|
rust_2018_idioms,
|
||||||
#![deny(unused_results)]
|
rust_2018_compatibility,
|
||||||
#![deny(missing_docs)]
|
future_incompatible,
|
||||||
|
missing_copy_implementations
|
||||||
|
)]
|
||||||
#![doc(
|
#![doc(
|
||||||
html_favicon_url = "https://nalgebra.org/img/favicon.ico",
|
html_favicon_url = "https://nalgebra.org/img/favicon.ico",
|
||||||
html_root_url = "https://docs.rs/nalgebra/0.25.0"
|
html_root_url = "https://docs.rs/nalgebra/0.25.0"
|
||||||
@ -245,7 +246,7 @@ pub fn min<T: Ord>(a: T, b: T) -> T {
|
|||||||
|
|
||||||
/// The absolute value of `a`.
|
/// The absolute value of `a`.
|
||||||
///
|
///
|
||||||
/// Deprecated: Use [Matrix::abs] or [RealField::abs] instead.
|
/// Deprecated: Use [`Matrix::abs`] or [`RealField::abs`] instead.
|
||||||
#[deprecated(note = "use the inherent method `Matrix::abs` or `RealField::abs` instead")]
|
#[deprecated(note = "use the inherent method `Matrix::abs` or `RealField::abs` instead")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn abs<T: Signed>(a: &T) -> T {
|
pub fn abs<T: Signed>(a: &T) -> T {
|
||||||
@ -384,7 +385,7 @@ pub fn partial_sort2<'a, T: PartialOrd>(a: &'a T, b: &'a T) -> Option<(&'a T, &'
|
|||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [distance](fn.distance.html)
|
/// * [distance](fn.distance.html)
|
||||||
/// * [distance_squared](fn.distance_squared.html)
|
/// * [`distance_squared`](fn.distance_squared.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn center<T: SimdComplexField, const D: usize>(
|
pub fn center<T: SimdComplexField, const D: usize>(
|
||||||
p1: &Point<T, D>,
|
p1: &Point<T, D>,
|
||||||
@ -398,7 +399,7 @@ pub fn center<T: SimdComplexField, const D: usize>(
|
|||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [center](fn.center.html)
|
/// * [center](fn.center.html)
|
||||||
/// * [distance_squared](fn.distance_squared.html)
|
/// * [`distance_squared`](fn.distance_squared.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn distance<T: SimdComplexField, const D: usize>(
|
pub fn distance<T: SimdComplexField, const D: usize>(
|
||||||
p1: &Point<T, D>,
|
p1: &Point<T, D>,
|
||||||
@ -430,11 +431,11 @@ pub fn distance_squared<T: SimdComplexField, const D: usize>(
|
|||||||
///
|
///
|
||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [convert_ref](fn.convert_ref.html)
|
/// * [`convert_ref`](fn.convert_ref.html)
|
||||||
/// * [convert_ref_unchecked](fn.convert_ref_unchecked.html)
|
/// * [`convert_ref_unchecked`](fn.convert_ref_unchecked.html)
|
||||||
/// * [is_convertible](../nalgebra/fn.is_convertible.html)
|
/// * [`is_convertible`](../nalgebra/fn.is_convertible.html)
|
||||||
/// * [try_convert](fn.try_convert.html)
|
/// * [`try_convert`](fn.try_convert.html)
|
||||||
/// * [try_convert_ref](fn.try_convert_ref.html)
|
/// * [`try_convert_ref`](fn.try_convert_ref.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn convert<From, To: SupersetOf<From>>(t: From) -> To {
|
pub fn convert<From, To: SupersetOf<From>>(t: From) -> To {
|
||||||
To::from_subset(&t)
|
To::from_subset(&t)
|
||||||
@ -447,10 +448,10 @@ pub fn convert<From, To: SupersetOf<From>>(t: From) -> To {
|
|||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [convert](fn.convert.html)
|
/// * [convert](fn.convert.html)
|
||||||
/// * [convert_ref](fn.convert_ref.html)
|
/// * [`convert_ref`](fn.convert_ref.html)
|
||||||
/// * [convert_ref_unchecked](fn.convert_ref_unchecked.html)
|
/// * [`convert_ref_unchecked`](fn.convert_ref_unchecked.html)
|
||||||
/// * [is_convertible](../nalgebra/fn.is_convertible.html)
|
/// * [`is_convertible`](../nalgebra/fn.is_convertible.html)
|
||||||
/// * [try_convert_ref](fn.try_convert_ref.html)
|
/// * [`try_convert_ref`](fn.try_convert_ref.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_convert<From: SupersetOf<To>, To>(t: From) -> Option<To> {
|
pub fn try_convert<From: SupersetOf<To>, To>(t: From) -> Option<To> {
|
||||||
t.to_subset()
|
t.to_subset()
|
||||||
@ -462,10 +463,10 @@ pub fn try_convert<From: SupersetOf<To>, To>(t: From) -> Option<To> {
|
|||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [convert](fn.convert.html)
|
/// * [convert](fn.convert.html)
|
||||||
/// * [convert_ref](fn.convert_ref.html)
|
/// * [`convert_ref`](fn.convert_ref.html)
|
||||||
/// * [convert_ref_unchecked](fn.convert_ref_unchecked.html)
|
/// * [`convert_ref_unchecked`](fn.convert_ref_unchecked.html)
|
||||||
/// * [try_convert](fn.try_convert.html)
|
/// * [`try_convert`](fn.try_convert.html)
|
||||||
/// * [try_convert_ref](fn.try_convert_ref.html)
|
/// * [`try_convert_ref`](fn.try_convert_ref.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn is_convertible<From: SupersetOf<To>, To>(t: &From) -> bool {
|
pub fn is_convertible<From: SupersetOf<To>, To>(t: &From) -> bool {
|
||||||
t.is_in_subset()
|
t.is_in_subset()
|
||||||
@ -477,11 +478,11 @@ pub fn is_convertible<From: SupersetOf<To>, To>(t: &From) -> bool {
|
|||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [convert](fn.convert.html)
|
/// * [convert](fn.convert.html)
|
||||||
/// * [convert_ref](fn.convert_ref.html)
|
/// * [`convert_ref`](fn.convert_ref.html)
|
||||||
/// * [convert_ref_unchecked](fn.convert_ref_unchecked.html)
|
/// * [`convert_ref_unchecked`](fn.convert_ref_unchecked.html)
|
||||||
/// * [is_convertible](../nalgebra/fn.is_convertible.html)
|
/// * [`is_convertible`](../nalgebra/fn.is_convertible.html)
|
||||||
/// * [try_convert](fn.try_convert.html)
|
/// * [`try_convert`](fn.try_convert.html)
|
||||||
/// * [try_convert_ref](fn.try_convert_ref.html)
|
/// * [`try_convert_ref`](fn.try_convert_ref.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn convert_unchecked<From: SupersetOf<To>, To>(t: From) -> To {
|
pub fn convert_unchecked<From: SupersetOf<To>, To>(t: From) -> To {
|
||||||
t.to_subset_unchecked()
|
t.to_subset_unchecked()
|
||||||
@ -492,10 +493,10 @@ pub fn convert_unchecked<From: SupersetOf<To>, To>(t: From) -> To {
|
|||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [convert](fn.convert.html)
|
/// * [convert](fn.convert.html)
|
||||||
/// * [convert_ref_unchecked](fn.convert_ref_unchecked.html)
|
/// * [`convert_ref_unchecked`](fn.convert_ref_unchecked.html)
|
||||||
/// * [is_convertible](../nalgebra/fn.is_convertible.html)
|
/// * [`is_convertible`](../nalgebra/fn.is_convertible.html)
|
||||||
/// * [try_convert](fn.try_convert.html)
|
/// * [`try_convert`](fn.try_convert.html)
|
||||||
/// * [try_convert_ref](fn.try_convert_ref.html)
|
/// * [`try_convert_ref`](fn.try_convert_ref.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn convert_ref<From, To: SupersetOf<From>>(t: &From) -> To {
|
pub fn convert_ref<From, To: SupersetOf<From>>(t: &From) -> To {
|
||||||
To::from_subset(t)
|
To::from_subset(t)
|
||||||
@ -506,10 +507,10 @@ pub fn convert_ref<From, To: SupersetOf<From>>(t: &From) -> To {
|
|||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [convert](fn.convert.html)
|
/// * [convert](fn.convert.html)
|
||||||
/// * [convert_ref](fn.convert_ref.html)
|
/// * [`convert_ref`](fn.convert_ref.html)
|
||||||
/// * [convert_ref_unchecked](fn.convert_ref_unchecked.html)
|
/// * [`convert_ref_unchecked`](fn.convert_ref_unchecked.html)
|
||||||
/// * [is_convertible](../nalgebra/fn.is_convertible.html)
|
/// * [`is_convertible`](../nalgebra/fn.is_convertible.html)
|
||||||
/// * [try_convert](fn.try_convert.html)
|
/// * [`try_convert`](fn.try_convert.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn try_convert_ref<From: SupersetOf<To>, To>(t: &From) -> Option<To> {
|
pub fn try_convert_ref<From: SupersetOf<To>, To>(t: &From) -> Option<To> {
|
||||||
t.to_subset()
|
t.to_subset()
|
||||||
@ -521,10 +522,10 @@ pub fn try_convert_ref<From: SupersetOf<To>, To>(t: &From) -> Option<To> {
|
|||||||
/// # See also:
|
/// # See also:
|
||||||
///
|
///
|
||||||
/// * [convert](fn.convert.html)
|
/// * [convert](fn.convert.html)
|
||||||
/// * [convert_ref](fn.convert_ref.html)
|
/// * [`convert_ref`](fn.convert_ref.html)
|
||||||
/// * [is_convertible](../nalgebra/fn.is_convertible.html)
|
/// * [`is_convertible`](../nalgebra/fn.is_convertible.html)
|
||||||
/// * [try_convert](fn.try_convert.html)
|
/// * [`try_convert`](fn.try_convert.html)
|
||||||
/// * [try_convert_ref](fn.try_convert_ref.html)
|
/// * [`try_convert_ref`](fn.try_convert_ref.html)
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn convert_ref_unchecked<From: SupersetOf<To>, To>(t: &From) -> To {
|
pub fn convert_ref_unchecked<From: SupersetOf<To>, To>(t: &From) -> To {
|
||||||
t.to_subset_unchecked()
|
t.to_subset_unchecked()
|
||||||
|
@ -11,7 +11,7 @@ use crate::base::{Const, DefaultAllocator, OMatrix, OVector};
|
|||||||
/// Applies in-place a modified Parlett and Reinsch matrix balancing with 2-norm to the matrix and returns
|
/// Applies in-place a modified Parlett and Reinsch matrix balancing with 2-norm to the matrix and returns
|
||||||
/// the corresponding diagonal transformation.
|
/// the corresponding diagonal transformation.
|
||||||
///
|
///
|
||||||
/// See https://arxiv.org/pdf/1401.5766.pdf
|
/// See <https://arxiv.org/pdf/1401.5766.pdf>
|
||||||
pub fn balance_parlett_reinsch<T: RealField, D: Dim>(matrix: &mut OMatrix<T, D, D>) -> OVector<T, D>
|
pub fn balance_parlett_reinsch<T: RealField, D: Dim>(matrix: &mut OMatrix<T, D, D>) -> OVector<T, D>
|
||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
|
DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
|
||||||
|
@ -77,7 +77,7 @@ where
|
|||||||
+ Allocator<T, DimMinimum<R, C>>
|
+ Allocator<T, DimMinimum<R, C>>
|
||||||
+ Allocator<(usize, usize), DimMinimum<R, C>>,
|
+ Allocator<(usize, usize), DimMinimum<R, C>>,
|
||||||
{
|
{
|
||||||
/// Computes the ColPivQR decomposition using householder reflections.
|
/// Computes the `ColPivQR` decomposition using householder reflections.
|
||||||
pub fn new(mut matrix: OMatrix<T, R, C>) -> Self {
|
pub fn new(mut matrix: OMatrix<T, R, C>) -> Self {
|
||||||
let (nrows, ncols) = matrix.data.shape();
|
let (nrows, ncols) = matrix.data.shape();
|
||||||
let min_nrows_ncols = nrows.min(ncols);
|
let min_nrows_ncols = nrows.min(ncols);
|
||||||
|
@ -23,7 +23,7 @@ use crate::linalg::Hessenberg;
|
|||||||
|
|
||||||
/// Schur decomposition of a square matrix.
|
/// Schur decomposition of a square matrix.
|
||||||
///
|
///
|
||||||
/// If this is a real matrix, this will be a RealField Schur decomposition.
|
/// If this is a real matrix, this will be a `RealField` Schur decomposition.
|
||||||
#[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde-serialize-no-std", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
feature = "serde-serialize-no-std",
|
feature = "serde-serialize-no-std",
|
||||||
|
@ -376,8 +376,8 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
|||||||
b: &mut Vector<T, R2, S2>,
|
b: &mut Vector<T, R2, S2>,
|
||||||
conjugate: impl Fn(T) -> T,
|
conjugate: impl Fn(T) -> T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<T, S::RStride, S::CStride>,
|
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
||||||
&DVectorSlice<T, S2::RStride, S2::CStride>,
|
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) -> bool
|
) -> bool
|
||||||
where
|
where
|
||||||
@ -411,8 +411,8 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
|||||||
b: &mut Vector<T, R2, S2>,
|
b: &mut Vector<T, R2, S2>,
|
||||||
conjugate: impl Fn(T) -> T,
|
conjugate: impl Fn(T) -> T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<T, S::RStride, S::CStride>,
|
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
||||||
&DVectorSlice<T, S2::RStride, S2::CStride>,
|
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) -> bool
|
) -> bool
|
||||||
where
|
where
|
||||||
@ -734,8 +734,8 @@ impl<T: SimdComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
|||||||
b: &mut Vector<T, R2, S2>,
|
b: &mut Vector<T, R2, S2>,
|
||||||
conjugate: impl Fn(T) -> T,
|
conjugate: impl Fn(T) -> T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<T, S::RStride, S::CStride>,
|
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
||||||
&DVectorSlice<T, S2::RStride, S2::CStride>,
|
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) where
|
) where
|
||||||
S2: StorageMut<T, R2, U1>,
|
S2: StorageMut<T, R2, U1>,
|
||||||
@ -760,8 +760,8 @@ impl<T: SimdComplexField, D: Dim, S: Storage<T, D, D>> SquareMatrix<T, D, S> {
|
|||||||
b: &mut Vector<T, R2, S2>,
|
b: &mut Vector<T, R2, S2>,
|
||||||
conjugate: impl Fn(T) -> T,
|
conjugate: impl Fn(T) -> T,
|
||||||
dot: impl Fn(
|
dot: impl Fn(
|
||||||
&DVectorSlice<T, S::RStride, S::CStride>,
|
&DVectorSlice<'_, T, S::RStride, S::CStride>,
|
||||||
&DVectorSlice<T, S2::RStride, S2::CStride>,
|
&DVectorSlice<'_, T, S2::RStride, S2::CStride>,
|
||||||
) -> T,
|
) -> T,
|
||||||
) where
|
) where
|
||||||
S2: StorageMut<T, R2, U1>,
|
S2: StorageMut<T, R2, U1>,
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
//!
|
//!
|
||||||
//! **This module is only available when the `proptest-support` feature is enabled in `nalgebra`**.
|
//! **This module is only available when the `proptest-support` feature is enabled in `nalgebra`**.
|
||||||
//!
|
//!
|
||||||
//! `proptest` is a library for *property-based testing*. While similar to QuickCheck,
|
//! `proptest` is a library for *property-based testing*. While similar to `QuickCheck`,
|
||||||
//! which may be more familiar to some users, it has a more sophisticated design that
|
//! which may be more familiar to some users, it has a more sophisticated design that
|
||||||
//! provides users with automatic invariant-preserving shrinking. This means that when using
|
//! provides users with automatic invariant-preserving shrinking. This means that when using
|
||||||
//! `proptest`, you rarely need to write your own shrinkers - which is usually very difficult -
|
//! `proptest`, you rarely need to write your own shrinkers - which is usually very difficult -
|
||||||
//! and can instead get this "for free". Moreover, `proptest` does not rely on a canonical
|
//! and can instead get this "for free". Moreover, `proptest` does not rely on a canonical
|
||||||
//! `Arbitrary` trait implementation like QuickCheck, though it does also provide this. For
|
//! `Arbitrary` trait implementation like `QuickCheck`, though it does also provide this. For
|
||||||
//! more information, check out the [proptest docs](https://docs.rs/proptest/0.10.1/proptest/)
|
//! more information, check out the [proptest docs](https://docs.rs/proptest/0.10.1/proptest/)
|
||||||
//! and the [proptest book](https://altsysrq.github.io/proptest-book/intro.html).
|
//! and the [proptest book](https://altsysrq.github.io/proptest-book/intro.html).
|
||||||
//!
|
//!
|
||||||
@ -314,7 +314,7 @@ where
|
|||||||
/// with length in the provided range.
|
/// with length in the provided range.
|
||||||
///
|
///
|
||||||
/// This is a convenience function for calling
|
/// This is a convenience function for calling
|
||||||
/// [matrix(value_strategy, length, U1)](fn.matrix.html) and should
|
/// [`matrix(value_strategy, length, U1)`](fn.matrix.html) and should
|
||||||
/// be used when you only want to generate column vectors, as it's simpler and makes the intent
|
/// be used when you only want to generate column vectors, as it's simpler and makes the intent
|
||||||
/// clear.
|
/// clear.
|
||||||
pub fn vector<D, ScalarStrategy>(
|
pub fn vector<D, ScalarStrategy>(
|
||||||
|
@ -46,7 +46,7 @@ impl<'a, T: Clone> Iterator for ColumnEntries<'a, T> {
|
|||||||
pub trait CsStorageIter<'a, T, R, C = U1> {
|
pub trait CsStorageIter<'a, T, R, C = U1> {
|
||||||
/// Iterator through all the rows of a specific columns.
|
/// Iterator through all the rows of a specific columns.
|
||||||
///
|
///
|
||||||
/// The elements are given as a tuple (row_index, value).
|
/// The elements are given as a tuple (`row_index`, value).
|
||||||
type ColumnEntries: Iterator<Item = (usize, T)>;
|
type ColumnEntries: Iterator<Item = (usize, T)>;
|
||||||
/// Iterator through the row indices of a specific column.
|
/// Iterator through the row indices of a specific column.
|
||||||
type ColumnRowIndices: Iterator<Item = usize>;
|
type ColumnRowIndices: Iterator<Item = usize>;
|
||||||
@ -63,7 +63,7 @@ pub trait CsStorageIterMut<'a, T: 'a, R, C = U1> {
|
|||||||
type ValuesMut: Iterator<Item = &'a mut T>;
|
type ValuesMut: Iterator<Item = &'a mut T>;
|
||||||
/// Mutable iterator through all the rows of a specific columns.
|
/// Mutable iterator through all the rows of a specific columns.
|
||||||
///
|
///
|
||||||
/// The elements are given as a tuple (row_index, value).
|
/// The elements are given as a tuple (`row_index`, value).
|
||||||
type ColumnEntriesMut: Iterator<Item = (usize, &'a mut T)>;
|
type ColumnEntriesMut: Iterator<Item = (usize, &'a mut T)>;
|
||||||
|
|
||||||
/// A mutable iterator through the values buffer of the sparse matrix.
|
/// A mutable iterator through the values buffer of the sparse matrix.
|
||||||
|
6
src/third_party/alga/alga_isometry.rs
vendored
6
src/third_party/alga/alga_isometry.rs
vendored
@ -120,7 +120,7 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn decompose(&self) -> (Self::Translation, R, Id, R) {
|
fn decompose(&self) -> (Self::Translation, R, Id, R) {
|
||||||
(
|
(
|
||||||
self.translation.clone(),
|
self.translation,
|
||||||
self.rotation.clone(),
|
self.rotation.clone(),
|
||||||
Id::new(),
|
Id::new(),
|
||||||
<R as AbstractRotation<T, D>>::identity(),
|
<R as AbstractRotation<T, D>>::identity(),
|
||||||
@ -145,7 +145,7 @@ where
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn prepend_rotation(&self, r: &Self::Rotation) -> Self {
|
fn prepend_rotation(&self, r: &Self::Rotation) -> Self {
|
||||||
Isometry::from_parts(self.translation.clone(), self.rotation.prepend_rotation(r))
|
Isometry::from_parts(self.translation, self.rotation.prepend_rotation(r))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -175,7 +175,7 @@ where
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn translation(&self) -> Translation<T, D> {
|
fn translation(&self) -> Translation<T, D> {
|
||||||
self.translation.clone()
|
self.translation
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
12
src/third_party/alga/alga_rotation.rs
vendored
12
src/third_party/alga/alga_rotation.rs
vendored
@ -105,17 +105,17 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> AffineTransformati
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn decompose(&self) -> (Id, Self, Id, Self) {
|
fn decompose(&self) -> (Id, Self, Id, Self) {
|
||||||
(Id::new(), self.clone(), Id::new(), Self::identity())
|
(Id::new(), *self, Id::new(), Self::identity())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn append_translation(&self, _: &Self::Translation) -> Self {
|
fn append_translation(&self, _: &Self::Translation) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn prepend_translation(&self, _: &Self::Translation) -> Self {
|
fn prepend_translation(&self, _: &Self::Translation) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -130,12 +130,12 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> AffineTransformati
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn append_scaling(&self, _: &Self::NonUniformScaling) -> Self {
|
fn append_scaling(&self, _: &Self::NonUniformScaling) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn prepend_scaling(&self, _: &Self::NonUniformScaling) -> Self {
|
fn prepend_scaling(&self, _: &Self::NonUniformScaling) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +151,7 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> Similarity<Point<T
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn rotation(&self) -> Self {
|
fn rotation(&self) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
2
src/third_party/alga/alga_similarity.rs
vendored
2
src/third_party/alga/alga_similarity.rs
vendored
@ -117,7 +117,7 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn decompose(&self) -> (Translation<T, D>, R, T, R) {
|
fn decompose(&self) -> (Translation<T, D>, R, T, R) {
|
||||||
(
|
(
|
||||||
self.isometry.translation.clone(),
|
self.isometry.translation,
|
||||||
self.isometry.rotation.clone(),
|
self.isometry.rotation.clone(),
|
||||||
self.scaling(),
|
self.scaling(),
|
||||||
<R as AbstractRotation<T, D>>::identity(),
|
<R as AbstractRotation<T, D>>::identity(),
|
||||||
|
12
src/third_party/alga/alga_translation.rs
vendored
12
src/third_party/alga/alga_translation.rs
vendored
@ -106,7 +106,7 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> AffineTransformati
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn decompose(&self) -> (Self, Id, Id, Id) {
|
fn decompose(&self) -> (Self, Id, Id, Id) {
|
||||||
(self.clone(), Id::new(), Id::new(), Id::new())
|
(*self, Id::new(), Id::new(), Id::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -121,22 +121,22 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> AffineTransformati
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn append_rotation(&self, _: &Self::Rotation) -> Self {
|
fn append_rotation(&self, _: &Self::Rotation) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn prepend_rotation(&self, _: &Self::Rotation) -> Self {
|
fn prepend_rotation(&self, _: &Self::Rotation) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn append_scaling(&self, _: &Self::NonUniformScaling) -> Self {
|
fn append_scaling(&self, _: &Self::NonUniformScaling) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn prepend_scaling(&self, _: &Self::NonUniformScaling) -> Self {
|
fn prepend_scaling(&self, _: &Self::NonUniformScaling) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> Similarity<Point<T
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn translation(&self) -> Self {
|
fn translation(&self) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user