forked from M-Labs/nalgebra
commit
b10711e66e
@ -40,6 +40,7 @@ pub trait Reallocator<T: Scalar, RFrom: Dim, CFrom: Dim, RTo: Dim, CTo: Dim>:
|
|||||||
/// Reallocates a buffer of shape `(RTo, CTo)`, possibly reusing a previously allocated buffer
|
/// Reallocates a buffer of shape `(RTo, CTo)`, possibly reusing a previously allocated buffer
|
||||||
/// `buf`. Data stored by `buf` are linearly copied to the output:
|
/// `buf`. Data stored by `buf` are linearly copied to the output:
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// * The copy is performed as if both were just arrays (without a matrix structure).
|
/// * The copy is performed as if both were just arrays (without a matrix structure).
|
||||||
/// * If `buf` is larger than the output size, then extra elements of `buf` are truncated.
|
/// * If `buf` is larger than the output size, then extra elements of `buf` are truncated.
|
||||||
/// * If `buf` is smaller than the output size, then extra elements of the output are left
|
/// * If `buf` is smaller than the output size, then extra elements of the output are left
|
||||||
|
@ -286,11 +286,7 @@ where
|
|||||||
unsafe fn exhume<'a, 'b>(&'a mut self, mut bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
|
unsafe fn exhume<'a, 'b>(&'a mut self, mut bytes: &'b mut [u8]) -> Option<&'b mut [u8]> {
|
||||||
for element in self.as_mut_slice() {
|
for element in self.as_mut_slice() {
|
||||||
let temp = bytes;
|
let temp = bytes;
|
||||||
bytes = if let Some(remainder) = element.exhume(temp) {
|
bytes = element.exhume(temp)?
|
||||||
remainder
|
|
||||||
} else {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Some(bytes)
|
Some(bytes)
|
||||||
}
|
}
|
||||||
@ -327,7 +323,7 @@ mod rkyv_impl {
|
|||||||
for ArrayStorage<T, R, C>
|
for ArrayStorage<T, R, C>
|
||||||
{
|
{
|
||||||
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
|
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
|
||||||
Ok(self.0.serialize(serializer)?)
|
self.0.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,12 +1388,12 @@ where
|
|||||||
{
|
{
|
||||||
work.gemv(T::one(), mid, &rhs.column(0), T::zero());
|
work.gemv(T::one(), mid, &rhs.column(0), T::zero());
|
||||||
self.column_mut(0)
|
self.column_mut(0)
|
||||||
.gemv_tr(alpha.inlined_clone(), &rhs, work, beta.inlined_clone());
|
.gemv_tr(alpha.inlined_clone(), rhs, work, beta.inlined_clone());
|
||||||
|
|
||||||
for j in 1..rhs.ncols() {
|
for j in 1..rhs.ncols() {
|
||||||
work.gemv(T::one(), mid, &rhs.column(j), T::zero());
|
work.gemv(T::one(), mid, &rhs.column(j), T::zero());
|
||||||
self.column_mut(j)
|
self.column_mut(j)
|
||||||
.gemv_tr(alpha.inlined_clone(), &rhs, work, beta.inlined_clone());
|
.gemv_tr(alpha.inlined_clone(), rhs, work, beta.inlined_clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -386,7 +386,7 @@ impl<T: Scalar + Zero + One + ClosedMul + ClosedAdd, D: DimName, S: Storage<T, D
|
|||||||
(D::dim() - 1, 0),
|
(D::dim() - 1, 0),
|
||||||
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
||||||
)
|
)
|
||||||
.tr_dot(&shift);
|
.tr_dot(shift);
|
||||||
let post_translation = self.generic_slice(
|
let post_translation = self.generic_slice(
|
||||||
(0, 0),
|
(0, 0),
|
||||||
(DimNameDiff::<D, U1>::name(), DimNameDiff::<D, U1>::name()),
|
(DimNameDiff::<D, U1>::name(), DimNameDiff::<D, U1>::name()),
|
||||||
@ -423,7 +423,7 @@ where
|
|||||||
(D::dim() - 1, 0),
|
(D::dim() - 1, 0),
|
||||||
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
(Const::<1>, DimNameDiff::<D, U1>::name()),
|
||||||
);
|
);
|
||||||
let n = normalizer.tr_dot(&v);
|
let n = normalizer.tr_dot(v);
|
||||||
|
|
||||||
if !n.is_zero() {
|
if !n.is_zero() {
|
||||||
return transform * (v / n);
|
return transform * (v / n);
|
||||||
|
@ -53,7 +53,10 @@ impl<T: Scalar, R: Dim, C: Dim> OMatrix<T, R, C>
|
|||||||
where
|
where
|
||||||
DefaultAllocator: Allocator<T, R, C>,
|
DefaultAllocator: Allocator<T, R, C>,
|
||||||
{
|
{
|
||||||
/// Creates a new uninitialized matrix. If the matrix has a compile-time dimension, this panics
|
/// Creates a new uninitialized matrix.
|
||||||
|
///
|
||||||
|
/// # Safety
|
||||||
|
/// If the matrix has a compile-time dimension, this panics
|
||||||
/// if `nrows != R::to_usize()` or `ncols != C::to_usize()`.
|
/// if `nrows != R::to_usize()` or `ncols != C::to_usize()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn new_uninitialized_generic(nrows: R, ncols: C) -> mem::MaybeUninit<Self> {
|
pub unsafe fn new_uninitialized_generic(nrows: R, ncols: C) -> mem::MaybeUninit<Self> {
|
||||||
@ -827,7 +830,7 @@ where
|
|||||||
Standard: Distribution<T>,
|
Standard: Distribution<T>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> OMatrix<T, R, C> {
|
fn sample<G: Rng + ?Sized>(&self, rng: &mut G) -> OMatrix<T, R, C> {
|
||||||
let nrows = R::try_to_usize().unwrap_or_else(|| rng.gen_range(0..10));
|
let nrows = R::try_to_usize().unwrap_or_else(|| rng.gen_range(0..10));
|
||||||
let ncols = C::try_to_usize().unwrap_or_else(|| rng.gen_range(0..10));
|
let ncols = C::try_to_usize().unwrap_or_else(|| rng.gen_range(0..10));
|
||||||
|
|
||||||
@ -864,7 +867,7 @@ where
|
|||||||
{
|
{
|
||||||
/// Generate a uniformly distributed random unit vector.
|
/// Generate a uniformly distributed random unit vector.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Unit<OVector<T, D>> {
|
fn sample<G: Rng + ?Sized>(&self, rng: &mut G) -> Unit<OVector<T, D>> {
|
||||||
Unit::new_normalize(OVector::from_distribution_generic(
|
Unit::new_normalize(OVector::from_distribution_generic(
|
||||||
D::name(),
|
D::name(),
|
||||||
Const::<1>,
|
Const::<1>,
|
||||||
|
@ -10,6 +10,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
|||||||
{
|
{
|
||||||
/// Creates, without bound-checking, a matrix slice from an array and with dimensions and strides specified by generic types instances.
|
/// Creates, without bound-checking, a matrix slice from an array and with dimensions and strides specified by generic types instances.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||||
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -59,6 +60,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
|||||||
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSlice<'a, T, R, C> {
|
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSlice<'a, T, R, C> {
|
||||||
/// Creates, without bound-checking, a matrix slice from an array and with dimensions specified by generic types instances.
|
/// Creates, without bound-checking, a matrix slice from an array and with dimensions specified by generic types instances.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||||
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -146,6 +148,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
|||||||
{
|
{
|
||||||
/// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions and strides specified by generic types instances.
|
/// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions and strides specified by generic types instances.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||||
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R`, `C`, `RStride`, `CStride` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -217,6 +220,7 @@ impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim>
|
|||||||
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, T, R, C> {
|
impl<'a, T: Scalar, R: Dim, C: Dim> MatrixSliceMutMN<'a, T, R, C> {
|
||||||
/// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions specified by generic types instances.
|
/// Creates, without bound-checking, a mutable matrix slice from an array and with dimensions specified by generic types instances.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
/// This method is unsafe because the input data array is not checked to contain enough elements.
|
||||||
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
/// The generic types `R` and `C` can either be type-level integers or integers wrapped with `Dynamic::new()`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -587,6 +587,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
|
|
||||||
/// Inserts `ninsert.value()` columns starting at the `i-th` place of this matrix.
|
/// Inserts `ninsert.value()` columns starting at the `i-th` place of this matrix.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// The added column values are not initialized.
|
/// The added column values are not initialized.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn insert_columns_generic_uninitialized<D>(
|
pub unsafe fn insert_columns_generic_uninitialized<D>(
|
||||||
@ -668,6 +669,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
|||||||
|
|
||||||
/// Inserts `ninsert.value()` rows at the `i-th` place of this matrix.
|
/// Inserts `ninsert.value()` rows at the `i-th` place of this matrix.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// The added rows values are not initialized.
|
/// The added rows values are not initialized.
|
||||||
/// This is the generic implementation of `.insert_rows(...)` and
|
/// This is the generic implementation of `.insert_rows(...)` and
|
||||||
/// `.insert_fixed_rows(...)` which have nicer API interfaces.
|
/// `.insert_fixed_rows(...)` which have nicer API interfaces.
|
||||||
|
@ -336,7 +336,7 @@ mod rkyv_impl {
|
|||||||
for Matrix<T, R, C, S>
|
for Matrix<T, R, C, S>
|
||||||
{
|
{
|
||||||
fn serialize(&self, serializer: &mut _S) -> Result<Self::Resolver, _S::Error> {
|
fn serialize(&self, serializer: &mut _S) -> Result<Self::Resolver, _S::Error> {
|
||||||
Ok(self.data.serialize(serializer)?)
|
self.data.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1581,7 +1581,7 @@ impl<T: Scalar + Zero + One, D: DimAdd<U1> + IsNotStaticOne, S: Storage<T, D, D>
|
|||||||
let dim = DimSum::<D, U1>::from_usize(self.nrows() + 1);
|
let dim = DimSum::<D, U1>::from_usize(self.nrows() + 1);
|
||||||
let mut res = OMatrix::identity_generic(dim, dim);
|
let mut res = OMatrix::identity_generic(dim, dim);
|
||||||
res.generic_slice_mut::<D, D>((0, 0), self.data.shape())
|
res.generic_slice_mut::<D, D>((0, 0), self.data.shape())
|
||||||
.copy_from(&self);
|
.copy_from(self);
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,7 @@ pub unsafe trait Storage<T: Scalar, R: Dim, C: Dim = U1>: Debug + Sized {
|
|||||||
|
|
||||||
/// Indicates whether this data buffer stores its elements contiguously.
|
/// Indicates whether this data buffer stores its elements contiguously.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// This method is unsafe because unsafe code relies on this properties to performe
|
/// This method is unsafe because unsafe code relies on this properties to performe
|
||||||
/// some low-lever optimizations.
|
/// some low-lever optimizations.
|
||||||
unsafe fn is_contiguous(&self) -> bool;
|
unsafe fn is_contiguous(&self) -> bool;
|
||||||
|
@ -95,7 +95,7 @@ mod rkyv_impl {
|
|||||||
|
|
||||||
impl<T: Serialize<S>, S: Fallible + ?Sized> Serialize<S> for Unit<T> {
|
impl<T: Serialize<S>, S: Fallible + ?Sized> Serialize<S> for Unit<T> {
|
||||||
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
|
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
|
||||||
Ok(self.value.serialize(serializer)?)
|
self.value.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,6 +102,7 @@ impl<T, R: Dim, C: Dim> VecStorage<T, R, C> {
|
|||||||
|
|
||||||
/// The underlying mutable data storage.
|
/// The underlying mutable data storage.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// This is unsafe because this may cause UB if the size of the vector is changed
|
/// This is unsafe because this may cause UB if the size of the vector is changed
|
||||||
/// by the user.
|
/// by the user.
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -111,6 +112,7 @@ impl<T, R: Dim, C: Dim> VecStorage<T, R, C> {
|
|||||||
|
|
||||||
/// Resizes the underlying mutable data storage and unwraps it.
|
/// Resizes the underlying mutable data storage and unwraps it.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// If `sz` is larger than the current size, additional elements are uninitialized.
|
/// If `sz` is larger than the current size, additional elements are uninitialized.
|
||||||
/// If `sz` is smaller than the current size, additional elements are truncated.
|
/// If `sz` is smaller than the current size, additional elements are truncated.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -86,7 +86,7 @@ where
|
|||||||
Standard: Distribution<T> + Distribution<R>,
|
Standard: Distribution<T> + Distribution<R>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Isometry<T, R, D> {
|
fn sample<G: Rng + ?Sized>(&self, rng: &mut G) -> Isometry<T, R, D> {
|
||||||
Isometry::from_parts(rng.gen(), rng.gen())
|
Isometry::from_parts(rng.gen(), rng.gen())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,7 +288,7 @@ where
|
|||||||
Standard: Distribution<T>,
|
Standard: Distribution<T>,
|
||||||
{
|
{
|
||||||
/// Generate an arbitrary random variate for testing purposes.
|
/// Generate an arbitrary random variate for testing purposes.
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, r: &'a mut R) -> Perspective3<T> {
|
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> Perspective3<T> {
|
||||||
use crate::base::helper;
|
use crate::base::helper;
|
||||||
let znear = r.gen();
|
let znear = r.gen();
|
||||||
let zfar = helper::reject_rand(r, |&x: &T| !(x - znear).is_zero());
|
let zfar = helper::reject_rand(r, |&x: &T| !(x - znear).is_zero());
|
||||||
|
@ -139,7 +139,7 @@ mod rkyv_impl {
|
|||||||
|
|
||||||
impl<T: Serialize<S>, S: Fallible + ?Sized> Serialize<S> for Quaternion<T> {
|
impl<T: Serialize<S>, S: Fallible + ?Sized> Serialize<S> for Quaternion<T> {
|
||||||
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
|
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
|
||||||
Ok(self.coords.serialize(serializer)?)
|
self.coords.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ where
|
|||||||
Standard: Distribution<T>,
|
Standard: Distribution<T>,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Quaternion<T> {
|
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Quaternion<T> {
|
||||||
Quaternion::new(rng.gen(), rng.gen(), rng.gen(), rng.gen())
|
Quaternion::new(rng.gen(), rng.gen(), rng.gen(), rng.gen())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -535,10 +535,10 @@ where
|
|||||||
SC: Storage<T, U3>,
|
SC: Storage<T, U3>,
|
||||||
{
|
{
|
||||||
// TODO: code duplication with Rotation.
|
// TODO: code duplication with Rotation.
|
||||||
let c = na.cross(&nb);
|
let c = na.cross(nb);
|
||||||
|
|
||||||
if let Some(axis) = Unit::try_new(c, T::default_epsilon()) {
|
if let Some(axis) = Unit::try_new(c, T::default_epsilon()) {
|
||||||
let cos = na.dot(&nb);
|
let cos = na.dot(nb);
|
||||||
|
|
||||||
// The cosinus may be out of [-1, 1] because of inaccuracies.
|
// The cosinus may be out of [-1, 1] because of inaccuracies.
|
||||||
if cos <= -T::one() {
|
if cos <= -T::one() {
|
||||||
@ -548,7 +548,7 @@ where
|
|||||||
} else {
|
} else {
|
||||||
Some(Self::from_axis_angle(&axis, cos.acos() * s))
|
Some(Self::from_axis_angle(&axis, cos.acos() * s))
|
||||||
}
|
}
|
||||||
} else if na.dot(&nb) < T::zero() {
|
} else if na.dot(nb) < T::zero() {
|
||||||
// PI
|
// PI
|
||||||
//
|
//
|
||||||
// The rotation axis is undefined but the angle not zero. This is not a
|
// The rotation axis is undefined but the angle not zero. This is not a
|
||||||
@ -860,7 +860,7 @@ where
|
|||||||
{
|
{
|
||||||
/// Generate a uniformly distributed random rotation quaternion.
|
/// Generate a uniformly distributed random rotation quaternion.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> UnitQuaternion<T> {
|
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> UnitQuaternion<T> {
|
||||||
// Ken Shoemake's Subgroup Algorithm
|
// Ken Shoemake's Subgroup Algorithm
|
||||||
// Uniform random rotations.
|
// Uniform random rotations.
|
||||||
// In D. Kirk, editor, Graphics Gems III, pages 124-132. Academic, New York, 1992.
|
// In D. Kirk, editor, Graphics Gems III, pages 124-132. Academic, New York, 1992.
|
||||||
|
@ -90,7 +90,7 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D>> Reflection<T, D, S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let m_two: T = crate::convert(-2.0f64);
|
let m_two: T = crate::convert(-2.0f64);
|
||||||
lhs.gerc(m_two, &work, &self.axis, T::one());
|
lhs.gerc(m_two, work, &self.axis, T::one());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Applies the reflection to the rows of `lhs`.
|
/// Applies the reflection to the rows of `lhs`.
|
||||||
@ -111,6 +111,6 @@ impl<T: ComplexField, D: Dim, S: Storage<T, D>> Reflection<T, D, S> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let m_two = sign.scale(crate::convert(-2.0f64));
|
let m_two = sign.scale(crate::convert(-2.0f64));
|
||||||
lhs.gerc(m_two, &work, &self.axis, sign);
|
lhs.gerc(m_two, work, &self.axis, sign);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ where
|
|||||||
{
|
{
|
||||||
/// Generate a uniformly distributed random rotation.
|
/// Generate a uniformly distributed random rotation.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, R: Rng + ?Sized>(&self, rng: &'a mut R) -> Rotation2<T> {
|
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Rotation2<T> {
|
||||||
let twopi = Uniform::new(T::zero(), T::simd_two_pi());
|
let twopi = Uniform::new(T::zero(), T::simd_two_pi());
|
||||||
Rotation2::new(rng.sample(twopi))
|
Rotation2::new(rng.sample(twopi))
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ md_impl_all!(
|
|||||||
|
|
||||||
if C::has_normalizer() {
|
if C::has_normalizer() {
|
||||||
let normalizer = self.matrix().fixed_slice::<1, D>(D, 0);
|
let normalizer = self.matrix().fixed_slice::<1, D>(D, 0);
|
||||||
let n = normalizer.tr_dot(&rhs);
|
let n = normalizer.tr_dot(rhs);
|
||||||
|
|
||||||
if !n.is_zero() {
|
if !n.is_zero() {
|
||||||
return transform * (rhs / n);
|
return transform * (rhs / n);
|
||||||
|
@ -123,7 +123,7 @@ mod rkyv_impl {
|
|||||||
|
|
||||||
impl<T: Serialize<S>, S: Fallible + ?Sized, const D: usize> Serialize<S> for Translation<T, D> {
|
impl<T: Serialize<S>, S: Fallible + ?Sized, const D: usize> Serialize<S> for Translation<T, D> {
|
||||||
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
|
fn serialize(&self, serializer: &mut S) -> Result<Self::Resolver, S::Error> {
|
||||||
Ok(self.vector.serialize(serializer)?)
|
self.vector.serialize(serializer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ where
|
|||||||
{
|
{
|
||||||
/// Generate an arbitrary random variate for testing purposes.
|
/// Generate an arbitrary random variate for testing purposes.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sample<'a, G: Rng + ?Sized>(&self, rng: &'a mut G) -> Translation<T, D> {
|
fn sample<G: Rng + ?Sized>(&self, rng: &mut G) -> Translation<T, D> {
|
||||||
Translation::from(rng.gen::<SVector<T, D>>())
|
Translation::from(rng.gen::<SVector<T, D>>())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -383,8 +383,8 @@ where
|
|||||||
SB: Storage<T, U2>,
|
SB: Storage<T, U2>,
|
||||||
SC: Storage<T, U2>,
|
SC: Storage<T, U2>,
|
||||||
{
|
{
|
||||||
let sang = na.perp(&nb);
|
let sang = na.perp(nb);
|
||||||
let cang = na.dot(&nb);
|
let cang = na.dot(nb);
|
||||||
|
|
||||||
Self::from_angle(sang.simd_atan2(cang) * s)
|
Self::from_angle(sang.simd_atan2(cang) * s)
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ pub fn clear_row_unchecked<T: ComplexField, R: Dim, C: Dim>(
|
|||||||
reflection_norm.signum().conjugate(),
|
reflection_norm.signum().conjugate(),
|
||||||
);
|
);
|
||||||
top.columns_range_mut(irow + shift..)
|
top.columns_range_mut(irow + shift..)
|
||||||
.tr_copy_from(&refl.axis());
|
.tr_copy_from(refl.axis());
|
||||||
} else {
|
} else {
|
||||||
top.columns_range_mut(irow + shift..).tr_copy_from(&axis);
|
top.columns_range_mut(irow + shift..).tr_copy_from(&axis);
|
||||||
}
|
}
|
||||||
|
@ -80,10 +80,12 @@ pub trait CsStorage<T, R, C = U1>: for<'a> CsStorageIter<'a, T, R, C> {
|
|||||||
fn shape(&self) -> (R, C);
|
fn shape(&self) -> (R, C);
|
||||||
/// Retrieve the i-th row index of the underlying row index buffer.
|
/// Retrieve the i-th row index of the underlying row index buffer.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// No bound-checking is performed.
|
/// No bound-checking is performed.
|
||||||
unsafe fn row_index_unchecked(&self, i: usize) -> usize;
|
unsafe fn row_index_unchecked(&self, i: usize) -> usize;
|
||||||
/// The i-th value on the contiguous value buffer of this storage.
|
/// The i-th value on the contiguous value buffer of this storage.
|
||||||
///
|
///
|
||||||
|
/// # Safety
|
||||||
/// No bound-checking is performed.
|
/// No bound-checking is performed.
|
||||||
unsafe fn get_value_unchecked(&self, i: usize) -> &T;
|
unsafe fn get_value_unchecked(&self, i: usize) -> &T;
|
||||||
/// The i-th value on the contiguous value buffer of this storage.
|
/// The i-th value on the contiguous value buffer of this storage.
|
||||||
@ -155,7 +157,7 @@ where
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn column_row_indices(&'a self, j: usize) -> Self::ColumnRowIndices {
|
fn column_row_indices(&'a self, j: usize) -> Self::ColumnRowIndices {
|
||||||
let rng = self.column_range(j);
|
let rng = self.column_range(j);
|
||||||
self.i[rng.clone()].iter().cloned()
|
self.i[rng].iter().cloned()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,7 +491,7 @@ where
|
|||||||
|
|
||||||
// Sort the index vector.
|
// Sort the index vector.
|
||||||
let range = self.data.column_range(j);
|
let range = self.data.column_range(j);
|
||||||
self.data.i[range.clone()].sort();
|
self.data.i[range.clone()].sort_unstable();
|
||||||
|
|
||||||
// Permute the values too.
|
// Permute the values too.
|
||||||
for (i, irow) in range.clone().zip(self.data.i[range].iter().cloned()) {
|
for (i, irow) in range.clone().zip(self.data.i[range].iter().cloned()) {
|
||||||
|
@ -271,7 +271,7 @@ where
|
|||||||
|
|
||||||
// Keep the output sorted.
|
// Keep the output sorted.
|
||||||
let range = res.data.p[j]..nz;
|
let range = res.data.p[j]..nz;
|
||||||
res.data.i[range.clone()].sort();
|
res.data.i[range.clone()].sort_unstable();
|
||||||
|
|
||||||
for p in range {
|
for p in range {
|
||||||
res.data.vals[p] = workspace[res.data.i[p]].inlined_clone()
|
res.data.vals[p] = workspace[res.data.i[p]].inlined_clone()
|
||||||
|
@ -63,7 +63,7 @@ impl<T: RealField, D: Dim, S: CsStorage<T, D, D>> CsMatrix<T, D, D, S> {
|
|||||||
let mut column = self.data.column_entries(j);
|
let mut column = self.data.column_entries(j);
|
||||||
let mut diag_found = false;
|
let mut diag_found = false;
|
||||||
|
|
||||||
while let Some((i, val)) = column.next() {
|
for (i, val) in &mut column {
|
||||||
if i == j {
|
if i == j {
|
||||||
if val.is_zero() {
|
if val.is_zero() {
|
||||||
return false;
|
return false;
|
||||||
@ -109,7 +109,7 @@ impl<T: RealField, D: Dim, S: CsStorage<T, D, D>> CsMatrix<T, D, D, S> {
|
|||||||
let mut column = self.data.column_entries(j);
|
let mut column = self.data.column_entries(j);
|
||||||
let mut diag = None;
|
let mut diag = None;
|
||||||
|
|
||||||
while let Some((i, val)) = column.next() {
|
for (i, val) in &mut column {
|
||||||
if i == j {
|
if i == j {
|
||||||
if val.is_zero() {
|
if val.is_zero() {
|
||||||
return false;
|
return false;
|
||||||
@ -151,7 +151,7 @@ impl<T: RealField, D: Dim, S: CsStorage<T, D, D>> CsMatrix<T, D, D, S> {
|
|||||||
// We don't compute a postordered reach here because it will be sorted after anyway.
|
// We don't compute a postordered reach here because it will be sorted after anyway.
|
||||||
self.lower_triangular_reach(b, &mut reach);
|
self.lower_triangular_reach(b, &mut reach);
|
||||||
// We sort the reach so the result matrix has sorted indices.
|
// We sort the reach so the result matrix has sorted indices.
|
||||||
reach.sort();
|
reach.sort_unstable();
|
||||||
let mut workspace =
|
let mut workspace =
|
||||||
unsafe { crate::unimplemented_or_uninitialized_generic!(b.data.shape().0, Const::<1>) };
|
unsafe { crate::unimplemented_or_uninitialized_generic!(b.data.shape().0, Const::<1>) };
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ impl<T: RealField, D: Dim, S: CsStorage<T, D, D>> CsMatrix<T, D, D, S> {
|
|||||||
let mut column = self.data.column_entries(j);
|
let mut column = self.data.column_entries(j);
|
||||||
let mut diag_found = false;
|
let mut diag_found = false;
|
||||||
|
|
||||||
while let Some((i, val)) = column.next() {
|
for (i, val) in &mut column {
|
||||||
if i == j {
|
if i == j {
|
||||||
if val.is_zero() {
|
if val.is_zero() {
|
||||||
break;
|
break;
|
||||||
|
8
src/third_party/alga/alga_dual_quaternion.rs
vendored
8
src/third_party/alga/alga_dual_quaternion.rs
vendored
@ -267,12 +267,12 @@ impl<T: RealField + simba::scalar::RealField> AffineTransformation<Point3<T>>
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn append_translation(&self, translation: &Self::Translation) -> Self {
|
fn append_translation(&self, translation: &Self::Translation) -> Self {
|
||||||
self * Self::from_parts(translation.clone(), UnitQuaternion::identity())
|
self * Self::from_parts(*translation, UnitQuaternion::identity())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn prepend_translation(&self, translation: &Self::Translation) -> Self {
|
fn prepend_translation(&self, translation: &Self::Translation) -> Self {
|
||||||
Self::from_parts(translation.clone(), UnitQuaternion::identity()) * self
|
Self::from_parts(*translation, UnitQuaternion::identity()) * self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -287,12 +287,12 @@ impl<T: RealField + simba::scalar::RealField> AffineTransformation<Point3<T>>
|
|||||||
|
|
||||||
#[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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
src/third_party/alga/alga_matrix.rs
vendored
6
src/third_party/alga/alga_matrix.rs
vendored
@ -272,12 +272,12 @@ where
|
|||||||
|
|
||||||
match Self::dimension() {
|
match Self::dimension() {
|
||||||
1 => {
|
1 => {
|
||||||
if vs.len() == 0 {
|
if vs.is_empty() {
|
||||||
let _ = f(&Self::canonical_basis_element(0));
|
let _ = f(&Self::canonical_basis_element(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
2 => {
|
2 => {
|
||||||
if vs.len() == 0 {
|
if vs.is_empty() {
|
||||||
let _ = f(&Self::canonical_basis_element(0))
|
let _ = f(&Self::canonical_basis_element(0))
|
||||||
&& f(&Self::canonical_basis_element(1));
|
&& f(&Self::canonical_basis_element(1));
|
||||||
} else if vs.len() == 1 {
|
} else if vs.len() == 1 {
|
||||||
@ -290,7 +290,7 @@ where
|
|||||||
// Otherwise, nothing.
|
// Otherwise, nothing.
|
||||||
}
|
}
|
||||||
3 => {
|
3 => {
|
||||||
if vs.len() == 0 {
|
if vs.is_empty() {
|
||||||
let _ = f(&Self::canonical_basis_element(0))
|
let _ = f(&Self::canonical_basis_element(0))
|
||||||
&& f(&Self::canonical_basis_element(1))
|
&& f(&Self::canonical_basis_element(1))
|
||||||
&& f(&Self::canonical_basis_element(2));
|
&& f(&Self::canonical_basis_element(2));
|
||||||
|
2
src/third_party/alga/alga_point.rs
vendored
2
src/third_party/alga/alga_point.rs
vendored
@ -23,7 +23,7 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> EuclideanSpace for
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn coordinates(&self) -> Self::Coordinates {
|
fn coordinates(&self) -> Self::Coordinates {
|
||||||
self.coords.clone()
|
self.coords
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
18
src/third_party/alga/alga_quaternion.rs
vendored
18
src/third_party/alga/alga_quaternion.rs
vendored
@ -144,11 +144,7 @@ impl<T: RealField + simba::scalar::RealField> NormedSpace for Quaternion<T> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn try_normalize(&self, min_norm: T) -> Option<Self> {
|
fn try_normalize(&self, min_norm: T) -> Option<Self> {
|
||||||
if let Some(v) = self.coords.try_normalize(min_norm) {
|
self.coords.try_normalize(min_norm).map(Self::from)
|
||||||
Some(Self::from(v))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -234,17 +230,17 @@ impl<T: RealField + simba::scalar::RealField> AffineTransformation<Point3<T>>
|
|||||||
|
|
||||||
#[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]
|
||||||
@ -259,12 +255,12 @@ impl<T: RealField + simba::scalar::RealField> AffineTransformation<Point3<T>>
|
|||||||
|
|
||||||
#[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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +274,7 @@ impl<T: RealField + simba::scalar::RealField> Similarity<Point3<T>> for UnitQuat
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn rotation(&self) -> Self {
|
fn rotation(&self) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
8
src/third_party/alga/alga_translation.rs
vendored
8
src/third_party/alga/alga_translation.rs
vendored
@ -79,7 +79,7 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> Transformation<Poi
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn transform_vector(&self, v: &SVector<T, D>) -> SVector<T, D> {
|
fn transform_vector(&self, v: &SVector<T, D>) -> SVector<T, D> {
|
||||||
v.clone()
|
*v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> ProjectiveTransfor
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn inverse_transform_vector(&self, v: &SVector<T, D>) -> SVector<T, D> {
|
fn inverse_transform_vector(&self, v: &SVector<T, D>) -> SVector<T, D> {
|
||||||
v.clone()
|
*v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> AlgaTranslation<Po
|
|||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_vector(&self) -> SVector<T, D> {
|
fn to_vector(&self) -> SVector<T, D> {
|
||||||
self.vector.clone()
|
self.vector
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
@ -186,7 +186,7 @@ impl<T: RealField + simba::scalar::RealField, const D: usize> AlgaTranslation<Po
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn powf(&self, n: T) -> Option<Self> {
|
fn powf(&self, n: T) -> Option<Self> {
|
||||||
Some(Self::from(&self.vector * n))
|
Some(Self::from(self.vector * n))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
12
src/third_party/alga/alga_unit_complex.rs
vendored
12
src/third_party/alga/alga_unit_complex.rs
vendored
@ -90,17 +90,17 @@ impl<T: RealField + simba::scalar::RealField> AffineTransformation<Point2<T>> fo
|
|||||||
|
|
||||||
#[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]
|
||||||
@ -115,12 +115,12 @@ impl<T: RealField + simba::scalar::RealField> AffineTransformation<Point2<T>> fo
|
|||||||
|
|
||||||
#[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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ impl<T: RealField + simba::scalar::RealField> Similarity<Point2<T>> for UnitComp
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn rotation(&self) -> Self {
|
fn rotation(&self) -> Self {
|
||||||
self.clone()
|
*self
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
Loading…
Reference in New Issue
Block a user