Fix most clippy warnings
This commit is contained in:
parent
38add0b00d
commit
281b140365
|
@ -278,6 +278,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
fn array_axcpy<T>(
|
fn array_axcpy<T>(
|
||||||
y: &mut [T],
|
y: &mut [T],
|
||||||
a: T,
|
a: T,
|
||||||
|
@ -334,6 +335,7 @@ where
|
||||||
/// assert_eq!(vec1, Vector3::new(6.0, 12.0, 18.0));
|
/// assert_eq!(vec1, Vector3::new(6.0, 12.0, 18.0));
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[allow(clippy::many_single_char_names)]
|
||||||
pub fn axcpy<D2: Dim, SB>(&mut self, a: T, x: &Vector<T, D2, SB>, c: T, b: T)
|
pub fn axcpy<D2: Dim, SB>(&mut self, a: T, x: &Vector<T, D2, SB>, c: T, b: T)
|
||||||
where
|
where
|
||||||
SB: Storage<T, D2>,
|
SB: Storage<T, D2>,
|
||||||
|
|
|
@ -906,6 +906,7 @@ macro_rules! componentwise_constructors_impl(
|
||||||
impl<T> Matrix<T, Const<$R>, Const<$C>, ArrayStorage<T, $R, $C>> {
|
impl<T> Matrix<T, Const<$R>, Const<$C>, ArrayStorage<T, $R, $C>> {
|
||||||
/// Initializes this matrix from its components.
|
/// Initializes this matrix from its components.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
pub const fn new($($($args: T),*),*) -> Self {
|
pub const fn new($($($args: T),*),*) -> Self {
|
||||||
unsafe {
|
unsafe {
|
||||||
Self::from_data_statically_unchecked(
|
Self::from_data_statically_unchecked(
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use simba::scalar::{SubsetOf, SupersetOf};
|
use simba::scalar::{SubsetOf, SupersetOf};
|
||||||
use std::convert::{AsMut, AsRef, From, Into};
|
use std::convert::{AsMut, AsRef, From, Into};
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
use simba::simd::{PrimitiveSimdValue, SimdValue};
|
use simba::simd::{PrimitiveSimdValue, SimdValue};
|
||||||
|
|
||||||
|
@ -110,11 +109,11 @@ impl<T: Scalar, const D: usize> From<[T; D]> for SVector<T, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scalar, const D: usize> Into<[T; D]> for SVector<T, D> {
|
impl<T: Scalar, const D: usize> From<SVector<T, D>> for [T; D] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> [T; D] {
|
fn from(vec: SVector<T, D>) -> Self {
|
||||||
// TODO: unfortunately, we must clone because we can move out of an array.
|
// TODO: unfortunately, we must clone because we can move out of an array.
|
||||||
self.data.0[0].clone()
|
vec.data.0[0].clone()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,13 +127,13 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scalar, const D: usize> Into<[T; D]> for RowSVector<T, D>
|
impl<T: Scalar, const D: usize> From<RowSVector<T, D>> for [T; D]
|
||||||
where
|
where
|
||||||
Const<D>: IsNotStaticOne,
|
Const<D>: IsNotStaticOne,
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> [T; D] {
|
fn from(vec: RowSVector<T, D>) -> [T; D] {
|
||||||
self.transpose().into()
|
vec.transpose().into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +145,7 @@ macro_rules! impl_from_into_asref_1D(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_ref(&self) -> &[T; $SZ] {
|
fn as_ref(&self) -> &[T; $SZ] {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.data.ptr())
|
&*(self.data.ptr() as *const [T; $SZ])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,7 +156,7 @@ macro_rules! impl_from_into_asref_1D(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut(&mut self) -> &mut [T; $SZ] {
|
fn as_mut(&mut self) -> &mut [T; $SZ] {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.data.ptr_mut())
|
&mut *(self.data.ptr_mut() as *mut [T; $SZ])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,10 +185,10 @@ impl<T: Scalar, const R: usize, const C: usize> From<[[T; R]; C]> for SMatrix<T,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scalar, const R: usize, const C: usize> Into<[[T; R]; C]> for SMatrix<T, R, C> {
|
impl<T: Scalar, const R: usize, const C: usize> From<SMatrix<T, R, C>> for [[T; R]; C] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> [[T; R]; C] {
|
fn from(vec: SMatrix<T, R, C>) -> Self {
|
||||||
self.data.0
|
vec.data.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +199,7 @@ macro_rules! impl_from_into_asref_2D(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_ref(&self) -> &[[T; $SZRows]; $SZCols] {
|
fn as_ref(&self) -> &[[T; $SZRows]; $SZCols] {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.data.ptr())
|
&*(self.data.ptr() as *const [[T; $SZRows]; $SZCols])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,7 +209,7 @@ macro_rules! impl_from_into_asref_2D(
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut(&mut self) -> &mut [[T; $SZRows]; $SZCols] {
|
fn as_mut(&mut self) -> &mut [[T; $SZRows]; $SZCols] {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.data.ptr_mut())
|
&mut *(self.data.ptr_mut() as *mut [[T; $SZRows]; $SZCols])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -427,21 +426,21 @@ impl<'a, T: Scalar> From<Vec<T>> for DVector<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorage<T, R, C>> Into<&'a [T]>
|
impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorage<T, R, C>>
|
||||||
for &'a Matrix<T, R, C, S>
|
From<&'a Matrix<T, R, C, S>> for &'a [T]
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> &'a [T] {
|
fn from(matrix: &'a Matrix<T, R, C, S>) -> Self {
|
||||||
self.as_slice()
|
matrix.as_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorageMut<T, R, C>> Into<&'a mut [T]>
|
impl<'a, T: Scalar + Copy, R: Dim, C: Dim, S: ContiguousStorageMut<T, R, C>>
|
||||||
for &'a mut Matrix<T, R, C, S>
|
From<&'a mut Matrix<T, R, C, S>> for &'a mut [T]
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> &'a mut [T] {
|
fn from(matrix: &'a mut Matrix<T, R, C, S>) -> Self {
|
||||||
self.as_mut_slice()
|
matrix.as_mut_slice()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
//! components using their names. For example, if `v` is a 3D vector, one can write `v.z` instead
|
//! components using their names. For example, if `v` is a 3D vector, one can write `v.z` instead
|
||||||
//! of `v[2]`.
|
//! of `v[2]`.
|
||||||
|
|
||||||
use std::mem;
|
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
use crate::base::dimension::{U1, U2, U3, U4, U5, U6};
|
use crate::base::dimension::{U1, U2, U3, U4, U5, U6};
|
||||||
|
@ -38,7 +37,7 @@ macro_rules! deref_impl(
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
unsafe { mem::transmute(self.data.ptr()) }
|
unsafe { &*(self.data.ptr() as *const Self::Target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +45,7 @@ macro_rules! deref_impl(
|
||||||
where S: ContiguousStorageMut<T, $R, $C> {
|
where S: ContiguousStorageMut<T, $R, $C> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
unsafe { mem::transmute(self.data.ptr_mut()) }
|
unsafe { &mut *(self.data.ptr_mut() as *mut Self::Target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,6 +96,10 @@ macro_rules! iterator {
|
||||||
let stride = self.strides.0.value();
|
let stride = self.strides.0.value();
|
||||||
self.ptr = self.ptr.add(stride);
|
self.ptr = self.ptr.add(stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We want either `& *last` or `&mut *last` here, depending
|
||||||
|
// on the mutability of `$Ref`.
|
||||||
|
#[allow(clippy::transmute_ptr_to_ref)]
|
||||||
Some(mem::transmute(old))
|
Some(mem::transmute(old))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,13 +143,13 @@ macro_rules! iterator {
|
||||||
let inner_remaining = self.size % inner_size;
|
let inner_remaining = self.size % inner_size;
|
||||||
|
|
||||||
// Compute pointer to last element
|
// Compute pointer to last element
|
||||||
let last = self.ptr.offset(
|
let last = self
|
||||||
(outer_remaining * outer_stride + inner_remaining * inner_stride)
|
.ptr
|
||||||
as isize,
|
.add((outer_remaining * outer_stride + inner_remaining * inner_stride));
|
||||||
);
|
|
||||||
|
|
||||||
// We want either `& *last` or `&mut *last` here, depending
|
// We want either `& *last` or `&mut *last` here, depending
|
||||||
// on the mutability of `$Ref`.
|
// on the mutability of `$Ref`.
|
||||||
|
#[allow(clippy::transmute_ptr_to_ref)]
|
||||||
Some(mem::transmute(last))
|
Some(mem::transmute(last))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,6 +567,7 @@ impl<T: Scalar, R: Dim, C: Dim, S: Storage<T, R, C>> Matrix<T, R, C, S> {
|
||||||
/// Tests whether `self` and `rhs` are exactly equal.
|
/// Tests whether `self` and `rhs` are exactly equal.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[allow(clippy::should_implement_trait)]
|
||||||
pub fn eq<R2, C2, SB>(&self, other: &Matrix<T, R2, C2, SB>) -> bool
|
pub fn eq<R2, C2, SB>(&self, other: &Matrix<T, R2, C2, SB>) -> bool
|
||||||
where
|
where
|
||||||
T: PartialEq,
|
T: PartialEq,
|
||||||
|
|
|
@ -529,7 +529,7 @@ macro_rules! left_scalar_mul_impl(
|
||||||
|
|
||||||
// for rhs in res.iter_mut() {
|
// for rhs in res.iter_mut() {
|
||||||
for rhs in res.as_mut_slice().iter_mut() {
|
for rhs in res.as_mut_slice().iter_mut() {
|
||||||
*rhs = self * *rhs
|
*rhs *= self
|
||||||
}
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use std::io::{Result as IOResult, Write};
|
use std::io::{Result as IOResult, Write};
|
||||||
use std::mem;
|
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
|
@ -228,8 +227,8 @@ impl<T> Unit<T> {
|
||||||
|
|
||||||
/// Wraps the given reference, assuming it is already normalized.
|
/// Wraps the given reference, assuming it is already normalized.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_ref_unchecked<'a>(value: &'a T) -> &'a Self {
|
pub fn from_ref_unchecked(value: &T) -> &Self {
|
||||||
unsafe { mem::transmute(value) }
|
unsafe { &*(value as *const T as *const Self) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves the underlying value.
|
/// Retrieves the underlying value.
|
||||||
|
@ -332,7 +331,7 @@ impl<T> Deref for Unit<T> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref(&self) -> &T {
|
fn deref(&self) -> &T {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &*(self as *const Self as *const T) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -143,9 +143,9 @@ impl<T, R: Dim, C: Dim> VecStorage<T, R, C> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, R: Dim, C: Dim> Into<Vec<T>> for VecStorage<T, R, C> {
|
impl<T, R: Dim, C: Dim> From<VecStorage<T, R, C>> for Vec<T> {
|
||||||
fn into(self) -> Vec<T> {
|
fn from(vec: VecStorage<T, R, C>) -> Self {
|
||||||
self.data
|
vec.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// The macros break if the references are taken out, for some reason.
|
||||||
|
#![allow(clippy::op_ref)]
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
Isometry3, Matrix4, Normed, OVector, Point3, Quaternion, Scalar, SimdRealField, Translation3,
|
Isometry3, Matrix4, Normed, OVector, Point3, Quaternion, Scalar, SimdRealField, Translation3,
|
||||||
Unit, UnitQuaternion, Vector3, Zero, U8,
|
Unit, UnitQuaternion, Vector3, Zero, U8,
|
||||||
|
@ -273,7 +276,7 @@ where
|
||||||
|
|
||||||
impl<T: RealField> DualQuaternion<T> {
|
impl<T: RealField> DualQuaternion<T> {
|
||||||
fn to_vector(&self) -> OVector<T, U8> {
|
fn to_vector(&self) -> OVector<T, U8> {
|
||||||
self.as_ref().clone().into()
|
(*self.as_ref()).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -618,9 +621,9 @@ where
|
||||||
let other = {
|
let other = {
|
||||||
let dot_product = self.as_ref().real.coords.dot(&other.as_ref().real.coords);
|
let dot_product = self.as_ref().real.coords.dot(&other.as_ref().real.coords);
|
||||||
if dot_product < T::zero() {
|
if dot_product < T::zero() {
|
||||||
-other.clone()
|
-*other
|
||||||
} else {
|
} else {
|
||||||
other.clone()
|
*other
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -186,9 +186,9 @@ where
|
||||||
pub fn from_parts(translation: Translation3<T>, rotation: UnitQuaternion<T>) -> Self {
|
pub fn from_parts(translation: Translation3<T>, rotation: UnitQuaternion<T>) -> Self {
|
||||||
let half: T = crate::convert(0.5f64);
|
let half: T = crate::convert(0.5f64);
|
||||||
UnitDualQuaternion::new_unchecked(DualQuaternion {
|
UnitDualQuaternion::new_unchecked(DualQuaternion {
|
||||||
real: rotation.clone().into_inner(),
|
real: rotation.into_inner(),
|
||||||
dual: Quaternion::from_parts(T::zero(), translation.vector)
|
dual: Quaternion::from_parts(T::zero(), translation.vector)
|
||||||
* rotation.clone().into_inner()
|
* rotation.into_inner()
|
||||||
* half,
|
* half,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// The macros break if the references are taken out, for some reason.
|
||||||
|
#![allow(clippy::op_ref)]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file provides:
|
* This file provides:
|
||||||
*
|
*
|
||||||
|
@ -49,7 +52,6 @@ use crate::{
|
||||||
DualQuaternion, Isometry3, Point, Point3, Quaternion, SimdRealField, Translation3, Unit,
|
DualQuaternion, Isometry3, Point, Point3, Quaternion, SimdRealField, Translation3, Unit,
|
||||||
UnitDualQuaternion, UnitQuaternion, Vector, Vector3, U3,
|
UnitDualQuaternion, UnitQuaternion, Vector, Vector3, U3,
|
||||||
};
|
};
|
||||||
use std::mem;
|
|
||||||
use std::ops::{
|
use std::ops::{
|
||||||
Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign,
|
Add, AddAssign, Div, DivAssign, Index, IndexMut, Mul, MulAssign, Neg, Sub, SubAssign,
|
||||||
};
|
};
|
||||||
|
@ -57,14 +59,14 @@ use std::ops::{
|
||||||
impl<T: SimdRealField> AsRef<[T; 8]> for DualQuaternion<T> {
|
impl<T: SimdRealField> AsRef<[T; 8]> for DualQuaternion<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_ref(&self) -> &[T; 8] {
|
fn as_ref(&self) -> &[T; 8] {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &*(self as *const Self as *const [T; 8]) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: SimdRealField> AsMut<[T; 8]> for DualQuaternion<T> {
|
impl<T: SimdRealField> AsMut<[T; 8]> for DualQuaternion<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_mut(&mut self) -> &mut [T; 8] {
|
fn as_mut(&mut self) -> &mut [T; 8] {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &mut *(self as *mut Self as *mut [T; 8]) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,7 +566,7 @@ dual_quaternion_op_impl!(
|
||||||
(U4, U1), (U3, U1);
|
(U4, U1), (U3, U1);
|
||||||
self: &'a UnitDualQuaternion<T>, rhs: &'b Translation3<T>,
|
self: &'a UnitDualQuaternion<T>, rhs: &'b Translation3<T>,
|
||||||
Output = UnitDualQuaternion<T> => U3, U1;
|
Output = UnitDualQuaternion<T> => U3, U1;
|
||||||
self * UnitDualQuaternion::<T>::from_parts(rhs.clone(), UnitQuaternion::identity());
|
self * UnitDualQuaternion::<T>::from_parts(*rhs, UnitQuaternion::identity());
|
||||||
'a, 'b);
|
'a, 'b);
|
||||||
|
|
||||||
dual_quaternion_op_impl!(
|
dual_quaternion_op_impl!(
|
||||||
|
@ -580,7 +582,7 @@ dual_quaternion_op_impl!(
|
||||||
(U4, U1), (U3, U3);
|
(U4, U1), (U3, U3);
|
||||||
self: UnitDualQuaternion<T>, rhs: &'b Translation3<T>,
|
self: UnitDualQuaternion<T>, rhs: &'b Translation3<T>,
|
||||||
Output = UnitDualQuaternion<T> => U3, U1;
|
Output = UnitDualQuaternion<T> => U3, U1;
|
||||||
self * UnitDualQuaternion::<T>::from_parts(rhs.clone(), UnitQuaternion::identity());
|
self * UnitDualQuaternion::<T>::from_parts(*rhs, UnitQuaternion::identity());
|
||||||
'b);
|
'b);
|
||||||
|
|
||||||
dual_quaternion_op_impl!(
|
dual_quaternion_op_impl!(
|
||||||
|
@ -632,7 +634,7 @@ dual_quaternion_op_impl!(
|
||||||
(U3, U1), (U4, U1);
|
(U3, U1), (U4, U1);
|
||||||
self: &'b Translation3<T>, rhs: &'a UnitDualQuaternion<T>,
|
self: &'b Translation3<T>, rhs: &'a UnitDualQuaternion<T>,
|
||||||
Output = UnitDualQuaternion<T> => U3, U1;
|
Output = UnitDualQuaternion<T> => U3, U1;
|
||||||
UnitDualQuaternion::<T>::from_parts(self.clone(), UnitQuaternion::identity()) * rhs;
|
UnitDualQuaternion::<T>::from_parts(*self, UnitQuaternion::identity()) * rhs;
|
||||||
'a, 'b);
|
'a, 'b);
|
||||||
|
|
||||||
dual_quaternion_op_impl!(
|
dual_quaternion_op_impl!(
|
||||||
|
@ -640,7 +642,7 @@ dual_quaternion_op_impl!(
|
||||||
(U3, U1), (U4, U1);
|
(U3, U1), (U4, U1);
|
||||||
self: &'a Translation3<T>, rhs: UnitDualQuaternion<T>,
|
self: &'a Translation3<T>, rhs: UnitDualQuaternion<T>,
|
||||||
Output = UnitDualQuaternion<T> => U3, U1;
|
Output = UnitDualQuaternion<T> => U3, U1;
|
||||||
UnitDualQuaternion::<T>::from_parts(self.clone(), UnitQuaternion::identity()) * rhs;
|
UnitDualQuaternion::<T>::from_parts(*self, UnitQuaternion::identity()) * rhs;
|
||||||
'a);
|
'a);
|
||||||
|
|
||||||
dual_quaternion_op_impl!(
|
dual_quaternion_op_impl!(
|
||||||
|
@ -664,7 +666,7 @@ dual_quaternion_op_impl!(
|
||||||
(U3, U1), (U4, U1);
|
(U3, U1), (U4, U1);
|
||||||
self: &'b Translation3<T>, rhs: &'a UnitDualQuaternion<T>,
|
self: &'b Translation3<T>, rhs: &'a UnitDualQuaternion<T>,
|
||||||
Output = UnitDualQuaternion<T> => U3, U1;
|
Output = UnitDualQuaternion<T> => U3, U1;
|
||||||
UnitDualQuaternion::<T>::from_parts(self.clone(), UnitQuaternion::identity()) / rhs;
|
UnitDualQuaternion::<T>::from_parts(*self, UnitQuaternion::identity()) / rhs;
|
||||||
'a, 'b);
|
'a, 'b);
|
||||||
|
|
||||||
dual_quaternion_op_impl!(
|
dual_quaternion_op_impl!(
|
||||||
|
@ -672,7 +674,7 @@ dual_quaternion_op_impl!(
|
||||||
(U3, U1), (U4, U1);
|
(U3, U1), (U4, U1);
|
||||||
self: &'a Translation3<T>, rhs: UnitDualQuaternion<T>,
|
self: &'a Translation3<T>, rhs: UnitDualQuaternion<T>,
|
||||||
Output = UnitDualQuaternion<T> => U3, U1;
|
Output = UnitDualQuaternion<T> => U3, U1;
|
||||||
UnitDualQuaternion::<T>::from_parts(self.clone(), UnitQuaternion::identity()) / rhs;
|
UnitDualQuaternion::<T>::from_parts(*self, UnitQuaternion::identity()) / rhs;
|
||||||
'a);
|
'a);
|
||||||
|
|
||||||
dual_quaternion_op_impl!(
|
dual_quaternion_op_impl!(
|
||||||
|
@ -860,7 +862,7 @@ dual_quaternion_op_impl!(
|
||||||
Output = Point3<T> => U3, U1;
|
Output = Point3<T> => U3, U1;
|
||||||
{
|
{
|
||||||
let two: T = crate::convert(2.0f64);
|
let two: T = crate::convert(2.0f64);
|
||||||
let q_point = Quaternion::from_parts(T::zero(), rhs.coords.clone());
|
let q_point = Quaternion::from_parts(T::zero(), rhs.coords);
|
||||||
Point::from(
|
Point::from(
|
||||||
((self.as_ref().real * q_point + self.as_ref().dual * two) * self.as_ref().real.conjugate())
|
((self.as_ref().real * q_point + self.as_ref().dual * two) * self.as_ref().real.conjugate())
|
||||||
.vector()
|
.vector()
|
||||||
|
@ -1115,7 +1117,7 @@ dual_quaternion_op_impl!(
|
||||||
MulAssign, mul_assign;
|
MulAssign, mul_assign;
|
||||||
(U4, U1), (U4, U1);
|
(U4, U1), (U4, U1);
|
||||||
self: UnitDualQuaternion<T>, rhs: &'b UnitQuaternion<T>;
|
self: UnitDualQuaternion<T>, rhs: &'b UnitQuaternion<T>;
|
||||||
*self *= rhs.clone(); 'b);
|
*self *= *rhs; 'b);
|
||||||
|
|
||||||
// UnitDualQuaternion ÷= UnitQuaternion
|
// UnitDualQuaternion ÷= UnitQuaternion
|
||||||
dual_quaternion_op_impl!(
|
dual_quaternion_op_impl!(
|
||||||
|
@ -1151,7 +1153,7 @@ dual_quaternion_op_impl!(
|
||||||
MulAssign, mul_assign;
|
MulAssign, mul_assign;
|
||||||
(U4, U1), (U4, U1);
|
(U4, U1), (U4, U1);
|
||||||
self: UnitDualQuaternion<T>, rhs: &'b Translation3<T>;
|
self: UnitDualQuaternion<T>, rhs: &'b Translation3<T>;
|
||||||
*self *= rhs.clone(); 'b);
|
*self *= *rhs; 'b);
|
||||||
|
|
||||||
// UnitDualQuaternion ÷= Translation3
|
// UnitDualQuaternion ÷= Translation3
|
||||||
dual_quaternion_op_impl!(
|
dual_quaternion_op_impl!(
|
||||||
|
|
|
@ -270,7 +270,7 @@ where
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn inv_mul(&self, rhs: &Isometry<T, R, D>) -> Self {
|
pub fn inv_mul(&self, rhs: &Isometry<T, R, D>) -> Self {
|
||||||
let inv_rot1 = self.rotation.inverse();
|
let inv_rot1 = self.rotation.inverse();
|
||||||
let tr_12 = rhs.translation.vector.clone() - self.translation.vector.clone();
|
let tr_12 = rhs.translation.vector - self.translation.vector;
|
||||||
Isometry::from_parts(
|
Isometry::from_parts(
|
||||||
inv_rot1.transform_vector(&tr_12).into(),
|
inv_rot1.transform_vector(&tr_12).into(),
|
||||||
inv_rot1 * rhs.rotation.clone(),
|
inv_rot1 * rhs.rotation.clone(),
|
||||||
|
@ -435,7 +435,7 @@ where
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn inverse_transform_point(&self, pt: &Point<T, D>) -> Point<T, D> {
|
pub fn inverse_transform_point(&self, pt: &Point<T, D>) -> Point<T, D> {
|
||||||
self.rotation
|
self.rotation
|
||||||
.inverse_transform_point(&(pt - &self.translation.vector))
|
.inverse_transform_point(&(pt - self.translation.vector))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Transform the given vector by the inverse of this isometry, ignoring the
|
/// Transform the given vector by the inverse of this isometry, ignoring the
|
||||||
|
|
|
@ -239,7 +239,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Isometry<T::Element, R::Element, D>; 2]) -> Self {
|
fn from(arr: [Isometry<T::Element, R::Element, D>; 2]) -> Self {
|
||||||
let tra = Translation::from([arr[0].translation.clone(), arr[1].translation.clone()]);
|
let tra = Translation::from([arr[0].translation, arr[1].translation]);
|
||||||
let rot = R::from([arr[0].rotation, arr[0].rotation]);
|
let rot = R::from([arr[0].rotation, arr[0].rotation]);
|
||||||
|
|
||||||
Self::from_parts(tra, rot)
|
Self::from_parts(tra, rot)
|
||||||
|
@ -258,10 +258,10 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Isometry<T::Element, R::Element, D>; 4]) -> Self {
|
fn from(arr: [Isometry<T::Element, R::Element, D>; 4]) -> Self {
|
||||||
let tra = Translation::from([
|
let tra = Translation::from([
|
||||||
arr[0].translation.clone(),
|
arr[0].translation,
|
||||||
arr[1].translation.clone(),
|
arr[1].translation,
|
||||||
arr[2].translation.clone(),
|
arr[2].translation,
|
||||||
arr[3].translation.clone(),
|
arr[3].translation,
|
||||||
]);
|
]);
|
||||||
let rot = R::from([
|
let rot = R::from([
|
||||||
arr[0].rotation,
|
arr[0].rotation,
|
||||||
|
@ -286,14 +286,14 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Isometry<T::Element, R::Element, D>; 8]) -> Self {
|
fn from(arr: [Isometry<T::Element, R::Element, D>; 8]) -> Self {
|
||||||
let tra = Translation::from([
|
let tra = Translation::from([
|
||||||
arr[0].translation.clone(),
|
arr[0].translation,
|
||||||
arr[1].translation.clone(),
|
arr[1].translation,
|
||||||
arr[2].translation.clone(),
|
arr[2].translation,
|
||||||
arr[3].translation.clone(),
|
arr[3].translation,
|
||||||
arr[4].translation.clone(),
|
arr[4].translation,
|
||||||
arr[5].translation.clone(),
|
arr[5].translation,
|
||||||
arr[6].translation.clone(),
|
arr[6].translation,
|
||||||
arr[7].translation.clone(),
|
arr[7].translation,
|
||||||
]);
|
]);
|
||||||
let rot = R::from([
|
let rot = R::from([
|
||||||
arr[0].rotation,
|
arr[0].rotation,
|
||||||
|
@ -322,22 +322,22 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Isometry<T::Element, R::Element, D>; 16]) -> Self {
|
fn from(arr: [Isometry<T::Element, R::Element, D>; 16]) -> Self {
|
||||||
let tra = Translation::from([
|
let tra = Translation::from([
|
||||||
arr[0].translation.clone(),
|
arr[0].translation,
|
||||||
arr[1].translation.clone(),
|
arr[1].translation,
|
||||||
arr[2].translation.clone(),
|
arr[2].translation,
|
||||||
arr[3].translation.clone(),
|
arr[3].translation,
|
||||||
arr[4].translation.clone(),
|
arr[4].translation,
|
||||||
arr[5].translation.clone(),
|
arr[5].translation,
|
||||||
arr[6].translation.clone(),
|
arr[6].translation,
|
||||||
arr[7].translation.clone(),
|
arr[7].translation,
|
||||||
arr[8].translation.clone(),
|
arr[8].translation,
|
||||||
arr[9].translation.clone(),
|
arr[9].translation,
|
||||||
arr[10].translation.clone(),
|
arr[10].translation,
|
||||||
arr[11].translation.clone(),
|
arr[11].translation,
|
||||||
arr[12].translation.clone(),
|
arr[12].translation,
|
||||||
arr[13].translation.clone(),
|
arr[13].translation,
|
||||||
arr[14].translation.clone(),
|
arr[14].translation,
|
||||||
arr[15].translation.clone(),
|
arr[15].translation,
|
||||||
]);
|
]);
|
||||||
let rot = R::from([
|
let rot = R::from([
|
||||||
arr[0].rotation,
|
arr[0].rotation,
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// The macros break if the references are taken out, for some reason.
|
||||||
|
#![allow(clippy::op_ref)]
|
||||||
|
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use std::ops::{Div, DivAssign, Mul, MulAssign};
|
use std::ops::{Div, DivAssign, Mul, MulAssign};
|
||||||
|
|
||||||
|
@ -198,7 +201,7 @@ md_assign_impl_all!(
|
||||||
const D; for; where;
|
const D; for; where;
|
||||||
self: Isometry<T, Rotation<T, D>, D>, rhs: Rotation<T, D>;
|
self: Isometry<T, Rotation<T, D>, D>, rhs: Rotation<T, D>;
|
||||||
[val] => self.rotation *= rhs;
|
[val] => self.rotation *= rhs;
|
||||||
[ref] => self.rotation *= rhs.clone();
|
[ref] => self.rotation *= *rhs;
|
||||||
);
|
);
|
||||||
|
|
||||||
md_assign_impl_all!(
|
md_assign_impl_all!(
|
||||||
|
@ -365,9 +368,9 @@ isometry_from_composition_impl_all!(
|
||||||
D;
|
D;
|
||||||
self: Rotation<T, D>, right: Translation<T, D>, Output = Isometry<T, Rotation<T, D>, D>;
|
self: Rotation<T, D>, right: Translation<T, D>, Output = Isometry<T, Rotation<T, D>, D>;
|
||||||
[val val] => Isometry::from_parts(Translation::from(&self * right.vector), self);
|
[val val] => Isometry::from_parts(Translation::from(&self * right.vector), self);
|
||||||
[ref val] => Isometry::from_parts(Translation::from(self * right.vector), self.clone());
|
[ref val] => Isometry::from_parts(Translation::from(self * right.vector), *self);
|
||||||
[val ref] => Isometry::from_parts(Translation::from(&self * &right.vector), self);
|
[val ref] => Isometry::from_parts(Translation::from(&self * &right.vector), self);
|
||||||
[ref ref] => Isometry::from_parts(Translation::from(self * &right.vector), self.clone());
|
[ref ref] => Isometry::from_parts(Translation::from(self * &right.vector), *self);
|
||||||
);
|
);
|
||||||
|
|
||||||
// UnitQuaternion × Translation
|
// UnitQuaternion × Translation
|
||||||
|
@ -389,9 +392,9 @@ isometry_from_composition_impl_all!(
|
||||||
self: Isometry<T, Rotation<T, D>, D>, rhs: Rotation<T, D>,
|
self: Isometry<T, Rotation<T, D>, D>, rhs: Rotation<T, D>,
|
||||||
Output = Isometry<T, Rotation<T, D>, D>;
|
Output = Isometry<T, Rotation<T, D>, D>;
|
||||||
[val val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
[val val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
||||||
[ref val] => Isometry::from_parts(self.translation.clone(), self.rotation.clone() * rhs); // TODO: do not clone.
|
[ref val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
||||||
[val ref] => Isometry::from_parts(self.translation, self.rotation * rhs.clone());
|
[val ref] => Isometry::from_parts(self.translation, self.rotation * *rhs);
|
||||||
[ref ref] => Isometry::from_parts(self.translation.clone(), self.rotation.clone() * rhs.clone());
|
[ref ref] => Isometry::from_parts(self.translation, self.rotation * *rhs);
|
||||||
);
|
);
|
||||||
|
|
||||||
// Rotation × Isometry
|
// Rotation × Isometry
|
||||||
|
@ -416,9 +419,9 @@ isometry_from_composition_impl_all!(
|
||||||
self: Isometry<T, Rotation<T, D>, D>, rhs: Rotation<T, D>,
|
self: Isometry<T, Rotation<T, D>, D>, rhs: Rotation<T, D>,
|
||||||
Output = Isometry<T, Rotation<T, D>, D>;
|
Output = Isometry<T, Rotation<T, D>, D>;
|
||||||
[val val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
[val val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
||||||
[ref val] => Isometry::from_parts(self.translation.clone(), self.rotation.clone() / rhs); // TODO: do not clone.
|
[ref val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
||||||
[val ref] => Isometry::from_parts(self.translation, self.rotation / rhs.clone());
|
[val ref] => Isometry::from_parts(self.translation, self.rotation / *rhs);
|
||||||
[ref ref] => Isometry::from_parts(self.translation.clone(), self.rotation.clone() / rhs.clone());
|
[ref ref] => Isometry::from_parts(self.translation, self.rotation / *rhs);
|
||||||
);
|
);
|
||||||
|
|
||||||
// Rotation ÷ Isometry
|
// Rotation ÷ Isometry
|
||||||
|
@ -441,9 +444,9 @@ isometry_from_composition_impl_all!(
|
||||||
self: Isometry<T, UnitQuaternion<T>, 3>, rhs: UnitQuaternion<T>,
|
self: Isometry<T, UnitQuaternion<T>, 3>, rhs: UnitQuaternion<T>,
|
||||||
Output = Isometry<T, UnitQuaternion<T>, 3>;
|
Output = Isometry<T, UnitQuaternion<T>, 3>;
|
||||||
[val val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
[val val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
||||||
[ref val] => Isometry::from_parts(self.translation.clone(), self.rotation * rhs); // TODO: do not clone.
|
[ref val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
||||||
[val ref] => Isometry::from_parts(self.translation, self.rotation * *rhs);
|
[val ref] => Isometry::from_parts(self.translation, self.rotation * *rhs);
|
||||||
[ref ref] => Isometry::from_parts(self.translation.clone(), self.rotation * *rhs);
|
[ref ref] => Isometry::from_parts(self.translation, self.rotation * *rhs);
|
||||||
);
|
);
|
||||||
|
|
||||||
// UnitQuaternion × Isometry
|
// UnitQuaternion × Isometry
|
||||||
|
@ -468,9 +471,9 @@ isometry_from_composition_impl_all!(
|
||||||
self: Isometry<T, UnitQuaternion<T>, 3>, rhs: UnitQuaternion<T>,
|
self: Isometry<T, UnitQuaternion<T>, 3>, rhs: UnitQuaternion<T>,
|
||||||
Output = Isometry<T, UnitQuaternion<T>, 3>;
|
Output = Isometry<T, UnitQuaternion<T>, 3>;
|
||||||
[val val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
[val val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
||||||
[ref val] => Isometry::from_parts(self.translation.clone(), self.rotation / rhs); // TODO: do not clone.
|
[ref val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
||||||
[val ref] => Isometry::from_parts(self.translation, self.rotation / *rhs);
|
[val ref] => Isometry::from_parts(self.translation, self.rotation / *rhs);
|
||||||
[ref ref] => Isometry::from_parts(self.translation.clone(), self.rotation / *rhs);
|
[ref ref] => Isometry::from_parts(self.translation, self.rotation / *rhs);
|
||||||
);
|
);
|
||||||
|
|
||||||
// UnitQuaternion ÷ Isometry
|
// UnitQuaternion ÷ Isometry
|
||||||
|
@ -492,9 +495,9 @@ isometry_from_composition_impl_all!(
|
||||||
D;
|
D;
|
||||||
self: Translation<T, D>, right: Rotation<T, D>, Output = Isometry<T, Rotation<T, D>, D>;
|
self: Translation<T, D>, right: Rotation<T, D>, Output = Isometry<T, Rotation<T, D>, D>;
|
||||||
[val val] => Isometry::from_parts(self, right);
|
[val val] => Isometry::from_parts(self, right);
|
||||||
[ref val] => Isometry::from_parts(self.clone(), right);
|
[ref val] => Isometry::from_parts(*self, right);
|
||||||
[val ref] => Isometry::from_parts(self, right.clone());
|
[val ref] => Isometry::from_parts(self, *right);
|
||||||
[ref ref] => Isometry::from_parts(self.clone(), right.clone());
|
[ref ref] => Isometry::from_parts(*self, *right);
|
||||||
);
|
);
|
||||||
|
|
||||||
// Translation × UnitQuaternion
|
// Translation × UnitQuaternion
|
||||||
|
@ -503,9 +506,9 @@ isometry_from_composition_impl_all!(
|
||||||
;
|
;
|
||||||
self: Translation<T, 3>, right: UnitQuaternion<T>, Output = Isometry<T, UnitQuaternion<T>, 3>;
|
self: Translation<T, 3>, right: UnitQuaternion<T>, Output = Isometry<T, UnitQuaternion<T>, 3>;
|
||||||
[val val] => Isometry::from_parts(self, right);
|
[val val] => Isometry::from_parts(self, right);
|
||||||
[ref val] => Isometry::from_parts(self.clone(), right);
|
[ref val] => Isometry::from_parts(*self, right);
|
||||||
[val ref] => Isometry::from_parts(self, *right);
|
[val ref] => Isometry::from_parts(self, *right);
|
||||||
[ref ref] => Isometry::from_parts(self.clone(), *right);
|
[ref ref] => Isometry::from_parts(*self, *right);
|
||||||
);
|
);
|
||||||
|
|
||||||
// Isometry × UnitComplex
|
// Isometry × UnitComplex
|
||||||
|
@ -515,9 +518,9 @@ isometry_from_composition_impl_all!(
|
||||||
self: Isometry<T, UnitComplex<T>, 2>, rhs: UnitComplex<T>,
|
self: Isometry<T, UnitComplex<T>, 2>, rhs: UnitComplex<T>,
|
||||||
Output = Isometry<T, UnitComplex<T>, 2>;
|
Output = Isometry<T, UnitComplex<T>, 2>;
|
||||||
[val val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
[val val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
||||||
[ref val] => Isometry::from_parts(self.translation.clone(), self.rotation * rhs); // TODO: do not clone.
|
[ref val] => Isometry::from_parts(self.translation, self.rotation * rhs);
|
||||||
[val ref] => Isometry::from_parts(self.translation, self.rotation * *rhs);
|
[val ref] => Isometry::from_parts(self.translation, self.rotation * *rhs);
|
||||||
[ref ref] => Isometry::from_parts(self.translation.clone(), self.rotation * *rhs);
|
[ref ref] => Isometry::from_parts(self.translation, self.rotation * *rhs);
|
||||||
);
|
);
|
||||||
|
|
||||||
// Isometry ÷ UnitComplex
|
// Isometry ÷ UnitComplex
|
||||||
|
@ -527,7 +530,7 @@ isometry_from_composition_impl_all!(
|
||||||
self: Isometry<T, UnitComplex<T>, 2>, rhs: UnitComplex<T>,
|
self: Isometry<T, UnitComplex<T>, 2>, rhs: UnitComplex<T>,
|
||||||
Output = Isometry<T, UnitComplex<T>, 2>;
|
Output = Isometry<T, UnitComplex<T>, 2>;
|
||||||
[val val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
[val val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
||||||
[ref val] => Isometry::from_parts(self.translation.clone(), self.rotation / rhs); // TODO: do not clone.
|
[ref val] => Isometry::from_parts(self.translation, self.rotation / rhs);
|
||||||
[val ref] => Isometry::from_parts(self.translation, self.rotation / *rhs);
|
[val ref] => Isometry::from_parts(self.translation, self.rotation / *rhs);
|
||||||
[ref ref] => Isometry::from_parts(self.translation.clone(), self.rotation / *rhs);
|
[ref ref] => Isometry::from_parts(self.translation, self.rotation / *rhs);
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,7 +8,6 @@ use rand::{
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
use simba::scalar::RealField;
|
use simba::scalar::RealField;
|
||||||
|
|
||||||
|
@ -258,7 +257,7 @@ impl<T: RealField> Orthographic3<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn as_projective(&self) -> &Projective3<T> {
|
pub fn as_projective(&self) -> &Projective3<T> {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &*(self as *const Orthographic3<T> as *const Projective3<T>) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This transformation seen as a `Projective3`.
|
/// This transformation seen as a `Projective3`.
|
||||||
|
|
|
@ -9,7 +9,6 @@ use rand::{
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
use simba::scalar::RealField;
|
use simba::scalar::RealField;
|
||||||
|
|
||||||
|
@ -140,7 +139,7 @@ impl<T: RealField> Perspective3<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn as_projective(&self) -> &Projective3<T> {
|
pub fn as_projective(&self) -> &Projective3<T> {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &*(self as *const Perspective3<T> as *const Projective3<T>) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This transformation seen as a `Projective3`.
|
/// This transformation seen as a `Projective3`.
|
||||||
|
@ -256,8 +255,9 @@ impl<T: RealField> Perspective3<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn set_fovy(&mut self, fovy: T) {
|
pub fn set_fovy(&mut self, fovy: T) {
|
||||||
let old_m22 = self.matrix[(1, 1)];
|
let old_m22 = self.matrix[(1, 1)];
|
||||||
self.matrix[(1, 1)] = T::one() / (fovy / crate::convert(2.0)).tan();
|
let new_m22 = T::one() / (fovy / crate::convert(2.0)).tan();
|
||||||
self.matrix[(0, 0)] = self.matrix[(0, 0)] * (self.matrix[(1, 1)] / old_m22);
|
self.matrix[(1, 1)] = new_m22;
|
||||||
|
self.matrix[(0, 0)] *= new_m22 / old_m22;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates this perspective matrix with a new near plane offset of the view frustum.
|
/// Updates this perspective matrix with a new near plane offset of the view frustum.
|
||||||
|
|
|
@ -90,10 +90,10 @@ impl<T: Scalar, const D: usize> From<[T; D]> for Point<T, D> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scalar, const D: usize> Into<[T; D]> for Point<T, D> {
|
impl<T: Scalar, const D: usize> From<Point<T, D>> for [T; D] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> [T; D] {
|
fn from(p: Point<T, D>) -> Self {
|
||||||
self.coords.into()
|
p.coords.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::mem;
|
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
use simba::simd::SimdValue;
|
use simba::simd::SimdValue;
|
||||||
|
@ -13,13 +12,13 @@ impl<T: Scalar + SimdValue> Deref for Quaternion<T> {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &*(self as *const Self as *const Self::Target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scalar + SimdValue> DerefMut for Quaternion<T> {
|
impl<T: Scalar + SimdValue> DerefMut for Quaternion<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &mut *(self as *mut Self as *mut Self::Target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// The macros break if the references are taken out, for some reason.
|
||||||
|
#![allow(clippy::op_ref)]
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file provides:
|
* This file provides:
|
||||||
* ===================
|
* ===================
|
||||||
|
|
|
@ -267,10 +267,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Rotation<T::Element, D>; 2]) -> Self {
|
fn from(arr: [Rotation<T::Element, D>; 2]) -> Self {
|
||||||
Self::from_matrix_unchecked(OMatrix::from([
|
Self::from_matrix_unchecked(OMatrix::from([arr[0].into_inner(), arr[1].into_inner()]))
|
||||||
arr[0].clone().into_inner(),
|
|
||||||
arr[1].clone().into_inner(),
|
|
||||||
]))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -283,10 +280,10 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Rotation<T::Element, D>; 4]) -> Self {
|
fn from(arr: [Rotation<T::Element, D>; 4]) -> Self {
|
||||||
Self::from_matrix_unchecked(OMatrix::from([
|
Self::from_matrix_unchecked(OMatrix::from([
|
||||||
arr[0].clone().into_inner(),
|
arr[0].into_inner(),
|
||||||
arr[1].clone().into_inner(),
|
arr[1].into_inner(),
|
||||||
arr[2].clone().into_inner(),
|
arr[2].into_inner(),
|
||||||
arr[3].clone().into_inner(),
|
arr[3].into_inner(),
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,14 +297,14 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Rotation<T::Element, D>; 8]) -> Self {
|
fn from(arr: [Rotation<T::Element, D>; 8]) -> Self {
|
||||||
Self::from_matrix_unchecked(OMatrix::from([
|
Self::from_matrix_unchecked(OMatrix::from([
|
||||||
arr[0].clone().into_inner(),
|
arr[0].into_inner(),
|
||||||
arr[1].clone().into_inner(),
|
arr[1].into_inner(),
|
||||||
arr[2].clone().into_inner(),
|
arr[2].into_inner(),
|
||||||
arr[3].clone().into_inner(),
|
arr[3].into_inner(),
|
||||||
arr[4].clone().into_inner(),
|
arr[4].into_inner(),
|
||||||
arr[5].clone().into_inner(),
|
arr[5].into_inner(),
|
||||||
arr[6].clone().into_inner(),
|
arr[6].into_inner(),
|
||||||
arr[7].clone().into_inner(),
|
arr[7].into_inner(),
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,22 +318,22 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Rotation<T::Element, D>; 16]) -> Self {
|
fn from(arr: [Rotation<T::Element, D>; 16]) -> Self {
|
||||||
Self::from_matrix_unchecked(OMatrix::from([
|
Self::from_matrix_unchecked(OMatrix::from([
|
||||||
arr[0].clone().into_inner(),
|
arr[0].into_inner(),
|
||||||
arr[1].clone().into_inner(),
|
arr[1].into_inner(),
|
||||||
arr[2].clone().into_inner(),
|
arr[2].into_inner(),
|
||||||
arr[3].clone().into_inner(),
|
arr[3].into_inner(),
|
||||||
arr[4].clone().into_inner(),
|
arr[4].into_inner(),
|
||||||
arr[5].clone().into_inner(),
|
arr[5].into_inner(),
|
||||||
arr[6].clone().into_inner(),
|
arr[6].into_inner(),
|
||||||
arr[7].clone().into_inner(),
|
arr[7].into_inner(),
|
||||||
arr[8].clone().into_inner(),
|
arr[8].into_inner(),
|
||||||
arr[9].clone().into_inner(),
|
arr[9].into_inner(),
|
||||||
arr[10].clone().into_inner(),
|
arr[10].into_inner(),
|
||||||
arr[11].clone().into_inner(),
|
arr[11].into_inner(),
|
||||||
arr[12].clone().into_inner(),
|
arr[12].into_inner(),
|
||||||
arr[13].clone().into_inner(),
|
arr[13].into_inner(),
|
||||||
arr[14].clone().into_inner(),
|
arr[14].into_inner(),
|
||||||
arr[15].clone().into_inner(),
|
arr[15].into_inner(),
|
||||||
]))
|
]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -857,11 +857,7 @@ impl<T: SimdRealField> Rotation3<T> {
|
||||||
where
|
where
|
||||||
T: RealField,
|
T: RealField,
|
||||||
{
|
{
|
||||||
if let Some(axis) = self.axis() {
|
self.axis().map(|axis| (axis, self.angle()))
|
||||||
Some((axis, self.angle()))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The rotation angle needed to make `self` and `other` coincide.
|
/// The rotation angle needed to make `self` and `other` coincide.
|
||||||
|
|
|
@ -178,7 +178,7 @@ where
|
||||||
);
|
);
|
||||||
|
|
||||||
Self::from_parts(
|
Self::from_parts(
|
||||||
Translation::from(&self.isometry.translation.vector * scaling),
|
Translation::from(self.isometry.translation.vector * scaling),
|
||||||
self.isometry.rotation.clone(),
|
self.isometry.rotation.clone(),
|
||||||
self.scaling * scaling,
|
self.scaling * scaling,
|
||||||
)
|
)
|
||||||
|
|
|
@ -197,7 +197,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Similarity<T::Element, R::Element, D>; 2]) -> Self {
|
fn from(arr: [Similarity<T::Element, R::Element, D>; 2]) -> Self {
|
||||||
let iso = Isometry::from([arr[0].isometry.clone(), arr[1].isometry.clone()]);
|
let iso = Isometry::from([arr[0].isometry, arr[1].isometry]);
|
||||||
let scale = T::from([arr[0].scaling(), arr[1].scaling()]);
|
let scale = T::from([arr[0].scaling(), arr[1].scaling()]);
|
||||||
|
|
||||||
Self::from_isometry(iso, scale)
|
Self::from_isometry(iso, scale)
|
||||||
|
@ -216,10 +216,10 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Similarity<T::Element, R::Element, D>; 4]) -> Self {
|
fn from(arr: [Similarity<T::Element, R::Element, D>; 4]) -> Self {
|
||||||
let iso = Isometry::from([
|
let iso = Isometry::from([
|
||||||
arr[0].isometry.clone(),
|
arr[0].isometry,
|
||||||
arr[1].isometry.clone(),
|
arr[1].isometry,
|
||||||
arr[2].isometry.clone(),
|
arr[2].isometry,
|
||||||
arr[3].isometry.clone(),
|
arr[3].isometry,
|
||||||
]);
|
]);
|
||||||
let scale = T::from([
|
let scale = T::from([
|
||||||
arr[0].scaling(),
|
arr[0].scaling(),
|
||||||
|
@ -244,14 +244,14 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Similarity<T::Element, R::Element, D>; 8]) -> Self {
|
fn from(arr: [Similarity<T::Element, R::Element, D>; 8]) -> Self {
|
||||||
let iso = Isometry::from([
|
let iso = Isometry::from([
|
||||||
arr[0].isometry.clone(),
|
arr[0].isometry,
|
||||||
arr[1].isometry.clone(),
|
arr[1].isometry,
|
||||||
arr[2].isometry.clone(),
|
arr[2].isometry,
|
||||||
arr[3].isometry.clone(),
|
arr[3].isometry,
|
||||||
arr[4].isometry.clone(),
|
arr[4].isometry,
|
||||||
arr[5].isometry.clone(),
|
arr[5].isometry,
|
||||||
arr[6].isometry.clone(),
|
arr[6].isometry,
|
||||||
arr[7].isometry.clone(),
|
arr[7].isometry,
|
||||||
]);
|
]);
|
||||||
let scale = T::from([
|
let scale = T::from([
|
||||||
arr[0].scaling(),
|
arr[0].scaling(),
|
||||||
|
@ -280,22 +280,22 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(arr: [Similarity<T::Element, R::Element, D>; 16]) -> Self {
|
fn from(arr: [Similarity<T::Element, R::Element, D>; 16]) -> Self {
|
||||||
let iso = Isometry::from([
|
let iso = Isometry::from([
|
||||||
arr[0].isometry.clone(),
|
arr[0].isometry,
|
||||||
arr[1].isometry.clone(),
|
arr[1].isometry,
|
||||||
arr[2].isometry.clone(),
|
arr[2].isometry,
|
||||||
arr[3].isometry.clone(),
|
arr[3].isometry,
|
||||||
arr[4].isometry.clone(),
|
arr[4].isometry,
|
||||||
arr[5].isometry.clone(),
|
arr[5].isometry,
|
||||||
arr[6].isometry.clone(),
|
arr[6].isometry,
|
||||||
arr[7].isometry.clone(),
|
arr[7].isometry,
|
||||||
arr[8].isometry.clone(),
|
arr[8].isometry,
|
||||||
arr[9].isometry.clone(),
|
arr[9].isometry,
|
||||||
arr[10].isometry.clone(),
|
arr[10].isometry,
|
||||||
arr[11].isometry.clone(),
|
arr[11].isometry,
|
||||||
arr[12].isometry.clone(),
|
arr[12].isometry,
|
||||||
arr[13].isometry.clone(),
|
arr[13].isometry,
|
||||||
arr[14].isometry.clone(),
|
arr[14].isometry,
|
||||||
arr[15].isometry.clone(),
|
arr[15].isometry,
|
||||||
]);
|
]);
|
||||||
let scale = T::from([
|
let scale = T::from([
|
||||||
arr[0].scaling(),
|
arr[0].scaling(),
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// The macros break if the references are taken out, for some reason.
|
||||||
|
#![allow(clippy::op_ref)]
|
||||||
|
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use std::ops::{Div, DivAssign, Mul, MulAssign};
|
use std::ops::{Div, DivAssign, Mul, MulAssign};
|
||||||
|
|
||||||
|
@ -219,7 +222,7 @@ md_assign_impl_all!(
|
||||||
const D; for; where;
|
const D; for; where;
|
||||||
self: Similarity<T, Rotation<T, D>, D>, rhs: Rotation<T, D>;
|
self: Similarity<T, Rotation<T, D>, D>, rhs: Rotation<T, D>;
|
||||||
[val] => self.isometry.rotation *= rhs;
|
[val] => self.isometry.rotation *= rhs;
|
||||||
[ref] => self.isometry.rotation *= rhs.clone();
|
[ref] => self.isometry.rotation *= *rhs;
|
||||||
);
|
);
|
||||||
|
|
||||||
md_assign_impl_all!(
|
md_assign_impl_all!(
|
||||||
|
|
|
@ -399,11 +399,9 @@ where
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use = "Did you mean to use try_inverse_mut()?"]
|
#[must_use = "Did you mean to use try_inverse_mut()?"]
|
||||||
pub fn try_inverse(self) -> Option<Transform<T, C, D>> {
|
pub fn try_inverse(self) -> Option<Transform<T, C, D>> {
|
||||||
if let Some(m) = self.matrix.try_inverse() {
|
self.matrix
|
||||||
Some(Transform::from_matrix_unchecked(m))
|
.try_inverse()
|
||||||
} else {
|
.map(Transform::from_matrix_unchecked)
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inverts this transformation. Use `.try_inverse` if this transform has the `TGeneral`
|
/// Inverts this transformation. Use `.try_inverse` if this transform has the `TGeneral`
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// The macros break if the references are taken out, for some reason.
|
||||||
|
#![allow(clippy::op_ref)]
|
||||||
|
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use std::ops::{Div, DivAssign, Index, IndexMut, Mul, MulAssign};
|
use std::ops::{Div, DivAssign, Index, IndexMut, Mul, MulAssign};
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scalar + Copy, const D: usize> Copy for Translation<T, D> where Owned<T, Const<D>>: Copy {}
|
impl<T: Scalar + Copy, const D: usize> Copy for Translation<T, D> {}
|
||||||
|
|
||||||
impl<T: Scalar, const D: usize> Clone for Translation<T, D>
|
impl<T: Scalar, const D: usize> Clone for Translation<T, D>
|
||||||
where
|
where
|
||||||
|
|
|
@ -77,7 +77,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn to_superset(&self) -> UnitDualQuaternion<T2> {
|
fn to_superset(&self) -> UnitDualQuaternion<T2> {
|
||||||
let dq = UnitDualQuaternion::<T1>::from_parts(self.clone(), UnitQuaternion::identity());
|
let dq = UnitDualQuaternion::<T1>::from_parts(*self, UnitQuaternion::identity());
|
||||||
dq.to_superset()
|
dq.to_superset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,16 +212,14 @@ impl<T: Scalar, const D: usize> From<[T; D]> for Translation<T, D> {
|
||||||
impl<T: Scalar, const D: usize> From<Point<T, D>> for Translation<T, D> {
|
impl<T: Scalar, const D: usize> From<Point<T, D>> for Translation<T, D> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn from(pt: Point<T, D>) -> Self {
|
fn from(pt: Point<T, D>) -> Self {
|
||||||
Translation {
|
Translation { vector: pt.coords }
|
||||||
vector: pt.coords.into(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scalar, const D: usize> Into<[T; D]> for Translation<T, D> {
|
impl<T: Scalar, const D: usize> From<Translation<T, D>> for [T; D] {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn into(self) -> [T; D] {
|
fn from(t: Translation<T, D>) -> Self {
|
||||||
self.vector.into()
|
t.vector.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
use std::mem;
|
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
use crate::base::coordinates::{X, XY, XYZ, XYZW, XYZWA, XYZWAB};
|
use crate::base::coordinates::{X, XY, XYZ, XYZW, XYZWA, XYZWAB};
|
||||||
|
@ -19,15 +18,14 @@ macro_rules! deref_impl(
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &*(self as *const Translation<T, $D> as *const Self::Target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Scalar> DerefMut for Translation<T, $D>
|
impl<T: Scalar> DerefMut for Translation<T, $D> {
|
||||||
{
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { &mut *(self as *mut Translation<T, $D> as *mut Self::Target) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
// The macros break if the references are taken out, for some reason.
|
||||||
|
#![allow(clippy::op_ref)]
|
||||||
|
|
||||||
use std::ops::{Div, DivAssign, Mul, MulAssign};
|
use std::ops::{Div, DivAssign, Mul, MulAssign};
|
||||||
|
|
||||||
use crate::base::storage::Storage;
|
use crate::base::storage::Storage;
|
||||||
|
@ -314,10 +317,10 @@ complex_op_impl_all!(
|
||||||
;
|
;
|
||||||
self: Translation<T, 2>, right: UnitComplex<T>,
|
self: Translation<T, 2>, right: UnitComplex<T>,
|
||||||
Output = Isometry<T, UnitComplex<T>, 2>;
|
Output = Isometry<T, UnitComplex<T>, 2>;
|
||||||
[val val] => Isometry::from_parts(self, right);
|
[val val] => Isometry::from_parts(self, right);
|
||||||
[ref val] => Isometry::from_parts(self.clone(), right);
|
[ref val] => Isometry::from_parts(*self, right);
|
||||||
[val ref] => Isometry::from_parts(self, *right);
|
[val ref] => Isometry::from_parts(self, *right);
|
||||||
[ref ref] => Isometry::from_parts(self.clone(), *right);
|
[ref ref] => Isometry::from_parts(*self, *right);
|
||||||
);
|
);
|
||||||
|
|
||||||
// UnitComplex ×= UnitComplex
|
// UnitComplex ×= UnitComplex
|
||||||
|
@ -327,7 +330,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_assign(&mut self, rhs: UnitComplex<T>) {
|
fn mul_assign(&mut self, rhs: UnitComplex<T>) {
|
||||||
*self = &*self * rhs
|
*self = *self * rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +340,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_assign(&mut self, rhs: &'b UnitComplex<T>) {
|
fn mul_assign(&mut self, rhs: &'b UnitComplex<T>) {
|
||||||
*self = &*self * rhs
|
*self = *self * rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +351,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn div_assign(&mut self, rhs: UnitComplex<T>) {
|
fn div_assign(&mut self, rhs: UnitComplex<T>) {
|
||||||
*self = &*self / rhs
|
*self = *self / rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,7 +361,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn div_assign(&mut self, rhs: &'b UnitComplex<T>) {
|
fn div_assign(&mut self, rhs: &'b UnitComplex<T>) {
|
||||||
*self = &*self / rhs
|
*self = *self / rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,7 +372,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_assign(&mut self, rhs: Rotation<T, 2>) {
|
fn mul_assign(&mut self, rhs: Rotation<T, 2>) {
|
||||||
*self = &*self * rhs
|
*self = *self * rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +382,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn mul_assign(&mut self, rhs: &'b Rotation<T, 2>) {
|
fn mul_assign(&mut self, rhs: &'b Rotation<T, 2>) {
|
||||||
*self = &*self * rhs
|
*self = *self * rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -390,7 +393,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn div_assign(&mut self, rhs: Rotation<T, 2>) {
|
fn div_assign(&mut self, rhs: Rotation<T, 2>) {
|
||||||
*self = &*self / rhs
|
*self = *self / rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,7 +403,7 @@ where
|
||||||
{
|
{
|
||||||
#[inline]
|
#[inline]
|
||||||
fn div_assign(&mut self, rhs: &'b Rotation<T, 2>) {
|
fn div_assign(&mut self, rhs: &'b Rotation<T, 2>) {
|
||||||
*self = &*self / rhs
|
*self = *self / rhs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
15
src/lib.rs
15
src/lib.rs
|
@ -1,3 +1,4 @@
|
||||||
|
#![allow(clippy::type_complexity)]
|
||||||
/*!
|
/*!
|
||||||
# nalgebra
|
# nalgebra
|
||||||
|
|
||||||
|
@ -199,19 +200,15 @@ where
|
||||||
while val < min {
|
while val < min {
|
||||||
val += width
|
val += width
|
||||||
}
|
}
|
||||||
|
|
||||||
val
|
|
||||||
} else if val > max {
|
} else if val > max {
|
||||||
val -= width;
|
val -= width;
|
||||||
|
|
||||||
while val > max {
|
while val > max {
|
||||||
val -= width
|
val -= width
|
||||||
}
|
}
|
||||||
|
|
||||||
val
|
|
||||||
} else {
|
|
||||||
val
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a reference to the input value clamped to the interval `[min, max]`.
|
/// Returns a reference to the input value clamped to the interval `[min, max]`.
|
||||||
|
@ -393,7 +390,7 @@ pub fn center<T: SimdComplexField, const D: usize>(
|
||||||
p1: &Point<T, D>,
|
p1: &Point<T, D>,
|
||||||
p2: &Point<T, D>,
|
p2: &Point<T, D>,
|
||||||
) -> Point<T, D> {
|
) -> Point<T, D> {
|
||||||
((&p1.coords + &p2.coords) * convert::<_, T>(0.5)).into()
|
((p1.coords + p2.coords) * convert::<_, T>(0.5)).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The distance between two points.
|
/// The distance between two points.
|
||||||
|
@ -407,7 +404,7 @@ pub fn distance<T: SimdComplexField, const D: usize>(
|
||||||
p1: &Point<T, D>,
|
p1: &Point<T, D>,
|
||||||
p2: &Point<T, D>,
|
p2: &Point<T, D>,
|
||||||
) -> T::SimdRealField {
|
) -> T::SimdRealField {
|
||||||
(&p2.coords - &p1.coords).norm()
|
(p2.coords - p1.coords).norm()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The squared distance between two points.
|
/// The squared distance between two points.
|
||||||
|
@ -421,7 +418,7 @@ pub fn distance_squared<T: SimdComplexField, const D: usize>(
|
||||||
p1: &Point<T, D>,
|
p1: &Point<T, D>,
|
||||||
p2: &Point<T, D>,
|
p2: &Point<T, D>,
|
||||||
) -> T::SimdRealField {
|
) -> T::SimdRealField {
|
||||||
(&p2.coords - &p1.coords).norm_squared()
|
(p2.coords - p1.coords).norm_squared()
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -8,17 +8,17 @@ use crate::base::dimension::Dim;
|
||||||
use crate::base::storage::Storage;
|
use crate::base::storage::Storage;
|
||||||
use crate::base::{Const, DefaultAllocator, OMatrix, OVector};
|
use crate::base::{Const, DefaultAllocator, OMatrix, OVector};
|
||||||
|
|
||||||
/// Applies in-place a modified Parlett and Reinsch matrix balancing with 2-norm to the matrix `m` 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>(m: &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>,
|
||||||
{
|
{
|
||||||
assert!(m.is_square(), "Unable to balance a non-square matrix.");
|
assert!(matrix.is_square(), "Unable to balance a non-square matrix.");
|
||||||
|
|
||||||
let dim = m.data.shape().0;
|
let dim = matrix.data.shape().0;
|
||||||
let radix: T = crate::convert(2.0f64);
|
let radix: T = crate::convert(2.0f64);
|
||||||
let mut d = OVector::from_element_generic(dim, Const::<1>, T::one());
|
let mut d = OVector::from_element_generic(dim, Const::<1>, T::one());
|
||||||
|
|
||||||
|
@ -28,36 +28,37 @@ where
|
||||||
converged = true;
|
converged = true;
|
||||||
|
|
||||||
for i in 0..dim.value() {
|
for i in 0..dim.value() {
|
||||||
let mut c = m.column(i).norm_squared();
|
let mut n_col = matrix.column(i).norm_squared();
|
||||||
let mut r = m.row(i).norm_squared();
|
let mut n_row = matrix.row(i).norm_squared();
|
||||||
let mut f = T::one();
|
let mut f = T::one();
|
||||||
|
|
||||||
let s = c + r;
|
let s = n_col + n_row;
|
||||||
c = c.sqrt();
|
n_col = n_col.sqrt();
|
||||||
r = r.sqrt();
|
n_row = n_row.sqrt();
|
||||||
|
|
||||||
if c.is_zero() || r.is_zero() {
|
if n_col.is_zero() || n_row.is_zero() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
while c < r / radix {
|
while n_col < n_row / radix {
|
||||||
c *= radix;
|
n_col *= radix;
|
||||||
r /= radix;
|
n_row /= radix;
|
||||||
f *= radix;
|
f *= radix;
|
||||||
}
|
}
|
||||||
|
|
||||||
while c >= r * radix {
|
while n_col >= n_row * radix {
|
||||||
c /= radix;
|
n_col /= radix;
|
||||||
r *= radix;
|
n_row *= radix;
|
||||||
f /= radix;
|
f /= radix;
|
||||||
}
|
}
|
||||||
|
|
||||||
let eps: T = crate::convert(0.95);
|
let eps: T = crate::convert(0.95);
|
||||||
if c * c + r * r < eps * s {
|
#[allow(clippy::suspicious_operation_groupings)]
|
||||||
|
if n_col * n_col + n_row * n_row < eps * s {
|
||||||
converged = false;
|
converged = false;
|
||||||
d[i] *= f;
|
d[i] *= f;
|
||||||
m.column_mut(i).mul_assign(f);
|
matrix.column_mut(i).mul_assign(f);
|
||||||
m.row_mut(i).div_assign(f);
|
matrix.row_mut(i).div_assign(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,31 +442,31 @@ where
|
||||||
return self.map(|v| v.exp());
|
return self.map(|v| v.exp());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut h = ExpmPadeHelper::new(self.clone(), true);
|
let mut helper = ExpmPadeHelper::new(self.clone(), true);
|
||||||
|
|
||||||
let eta_1 = T::RealField::max(h.d4_loose(), h.d6_loose());
|
let eta_1 = T::RealField::max(helper.d4_loose(), helper.d6_loose());
|
||||||
if eta_1 < convert(1.495_585_217_958_292e-2) && ell(&h.a, 3) == 0 {
|
if eta_1 < convert(1.495_585_217_958_292e-2) && ell(&helper.a, 3) == 0 {
|
||||||
let (u, v) = h.pade3();
|
let (u, v) = helper.pade3();
|
||||||
return solve_p_q(u, v);
|
return solve_p_q(u, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
let eta_2 = T::RealField::max(h.d4_tight(), h.d6_loose());
|
let eta_2 = T::RealField::max(helper.d4_tight(), helper.d6_loose());
|
||||||
if eta_2 < convert(2.539_398_330_063_230e-1) && ell(&h.a, 5) == 0 {
|
if eta_2 < convert(2.539_398_330_063_23e-1) && ell(&helper.a, 5) == 0 {
|
||||||
let (u, v) = h.pade5();
|
let (u, v) = helper.pade5();
|
||||||
return solve_p_q(u, v);
|
return solve_p_q(u, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
let eta_3 = T::RealField::max(h.d6_tight(), h.d8_loose());
|
let eta_3 = T::RealField::max(helper.d6_tight(), helper.d8_loose());
|
||||||
if eta_3 < convert(9.504_178_996_162_932e-1) && ell(&h.a, 7) == 0 {
|
if eta_3 < convert(9.504_178_996_162_932e-1) && ell(&helper.a, 7) == 0 {
|
||||||
let (u, v) = h.pade7();
|
let (u, v) = helper.pade7();
|
||||||
return solve_p_q(u, v);
|
return solve_p_q(u, v);
|
||||||
}
|
}
|
||||||
if eta_3 < convert(2.097_847_961_257_068e+0) && ell(&h.a, 9) == 0 {
|
if eta_3 < convert(2.097_847_961_257_068e0) && ell(&helper.a, 9) == 0 {
|
||||||
let (u, v) = h.pade9();
|
let (u, v) = helper.pade9();
|
||||||
return solve_p_q(u, v);
|
return solve_p_q(u, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
let eta_4 = T::RealField::max(h.d8_loose(), h.d10_loose());
|
let eta_4 = T::RealField::max(helper.d8_loose(), helper.d10_loose());
|
||||||
let eta_5 = T::RealField::min(eta_3, eta_4);
|
let eta_5 = T::RealField::min(eta_3, eta_4);
|
||||||
let theta_13 = convert(4.25);
|
let theta_13 = convert(4.25);
|
||||||
|
|
||||||
|
@ -482,9 +482,12 @@ where
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
s += ell(&(&h.a * convert::<f64, T>(2.0_f64.powf(-(s as f64)))), 13);
|
s += ell(
|
||||||
|
&(&helper.a * convert::<f64, T>(2.0_f64.powf(-(s as f64)))),
|
||||||
|
13,
|
||||||
|
);
|
||||||
|
|
||||||
let (u, v) = h.pade13_scaled(s);
|
let (u, v) = helper.pade13_scaled(s);
|
||||||
let mut x = solve_p_q(u, v);
|
let mut x = solve_p_q(u, v);
|
||||||
|
|
||||||
for _ in 0..s {
|
for _ in 0..s {
|
||||||
|
|
|
@ -31,10 +31,8 @@ where
|
||||||
|
|
||||||
// If e is negative, we compute the inverse matrix, then raise it to the
|
// If e is negative, we compute the inverse matrix, then raise it to the
|
||||||
// power of -e.
|
// power of -e.
|
||||||
if e < zero {
|
if e < zero && !self.try_inverse_mut() {
|
||||||
if !self.try_inverse_mut() {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let one = I::one();
|
let one = I::one();
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#![allow(clippy::suspicious_operation_groupings)]
|
||||||
#[cfg(feature = "serde-serialize-no-std")]
|
#[cfg(feature = "serde-serialize-no-std")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|
|
@ -121,11 +121,15 @@ where
|
||||||
matrix.unscale_mut(m_amax);
|
matrix.unscale_mut(m_amax);
|
||||||
}
|
}
|
||||||
|
|
||||||
let b = Bidiagonal::new(matrix);
|
let bi_matrix = Bidiagonal::new(matrix);
|
||||||
let mut u = if compute_u { Some(b.u()) } else { None };
|
let mut u = if compute_u { Some(bi_matrix.u()) } else { None };
|
||||||
let mut v_t = if compute_v { Some(b.v_t()) } else { None };
|
let mut v_t = if compute_v {
|
||||||
let mut diagonal = b.diagonal();
|
Some(bi_matrix.v_t())
|
||||||
let mut off_diagonal = b.off_diagonal();
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
let mut diagonal = bi_matrix.diagonal();
|
||||||
|
let mut off_diagonal = bi_matrix.off_diagonal();
|
||||||
|
|
||||||
let mut niter = 0;
|
let mut niter = 0;
|
||||||
let (mut start, mut end) = Self::delimit_subproblem(
|
let (mut start, mut end) = Self::delimit_subproblem(
|
||||||
|
@ -133,7 +137,7 @@ where
|
||||||
&mut off_diagonal,
|
&mut off_diagonal,
|
||||||
&mut u,
|
&mut u,
|
||||||
&mut v_t,
|
&mut v_t,
|
||||||
b.is_upper_diagonal(),
|
bi_matrix.is_upper_diagonal(),
|
||||||
dim - 1,
|
dim - 1,
|
||||||
eps,
|
eps,
|
||||||
);
|
);
|
||||||
|
@ -142,6 +146,7 @@ where
|
||||||
let subdim = end - start + 1;
|
let subdim = end - start + 1;
|
||||||
|
|
||||||
// Solve the subproblem.
|
// Solve the subproblem.
|
||||||
|
#[allow(clippy::comparison_chain)]
|
||||||
if subdim > 2 {
|
if subdim > 2 {
|
||||||
let m = end - 1;
|
let m = end - 1;
|
||||||
let n = end;
|
let n = end;
|
||||||
|
@ -201,7 +206,7 @@ where
|
||||||
subm[(0, 0)] = norm2;
|
subm[(0, 0)] = norm2;
|
||||||
|
|
||||||
if let Some(ref mut v_t) = v_t {
|
if let Some(ref mut v_t) = v_t {
|
||||||
if b.is_upper_diagonal() {
|
if bi_matrix.is_upper_diagonal() {
|
||||||
rot1.rotate(&mut v_t.fixed_rows_mut::<2>(k));
|
rot1.rotate(&mut v_t.fixed_rows_mut::<2>(k));
|
||||||
} else {
|
} else {
|
||||||
rot2.rotate(&mut v_t.fixed_rows_mut::<2>(k));
|
rot2.rotate(&mut v_t.fixed_rows_mut::<2>(k));
|
||||||
|
@ -209,7 +214,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref mut u) = u {
|
if let Some(ref mut u) = u {
|
||||||
if b.is_upper_diagonal() {
|
if bi_matrix.is_upper_diagonal() {
|
||||||
rot2.inverse().rotate_rows(&mut u.fixed_columns_mut::<2>(k));
|
rot2.inverse().rotate_rows(&mut u.fixed_columns_mut::<2>(k));
|
||||||
} else {
|
} else {
|
||||||
rot1.inverse().rotate_rows(&mut u.fixed_columns_mut::<2>(k));
|
rot1.inverse().rotate_rows(&mut u.fixed_columns_mut::<2>(k));
|
||||||
|
@ -236,8 +241,10 @@ where
|
||||||
diagonal[start],
|
diagonal[start],
|
||||||
off_diagonal[start],
|
off_diagonal[start],
|
||||||
diagonal[start + 1],
|
diagonal[start + 1],
|
||||||
compute_u && b.is_upper_diagonal() || compute_v && !b.is_upper_diagonal(),
|
compute_u && bi_matrix.is_upper_diagonal()
|
||||||
compute_v && b.is_upper_diagonal() || compute_u && !b.is_upper_diagonal(),
|
|| compute_v && !bi_matrix.is_upper_diagonal(),
|
||||||
|
compute_v && bi_matrix.is_upper_diagonal()
|
||||||
|
|| compute_u && !bi_matrix.is_upper_diagonal(),
|
||||||
);
|
);
|
||||||
let u2 = u2.map(|u2| GivensRotation::new_unchecked(u2.c(), T::from_real(u2.s())));
|
let u2 = u2.map(|u2| GivensRotation::new_unchecked(u2.c(), T::from_real(u2.s())));
|
||||||
let v2 = v2.map(|v2| GivensRotation::new_unchecked(v2.c(), T::from_real(v2.s())));
|
let v2 = v2.map(|v2| GivensRotation::new_unchecked(v2.c(), T::from_real(v2.s())));
|
||||||
|
@ -247,7 +254,7 @@ where
|
||||||
off_diagonal[start] = T::RealField::zero();
|
off_diagonal[start] = T::RealField::zero();
|
||||||
|
|
||||||
if let Some(ref mut u) = u {
|
if let Some(ref mut u) = u {
|
||||||
let rot = if b.is_upper_diagonal() {
|
let rot = if bi_matrix.is_upper_diagonal() {
|
||||||
u2.unwrap()
|
u2.unwrap()
|
||||||
} else {
|
} else {
|
||||||
v2.unwrap()
|
v2.unwrap()
|
||||||
|
@ -256,7 +263,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref mut v_t) = v_t {
|
if let Some(ref mut v_t) = v_t {
|
||||||
let rot = if b.is_upper_diagonal() {
|
let rot = if bi_matrix.is_upper_diagonal() {
|
||||||
v2.unwrap()
|
v2.unwrap()
|
||||||
} else {
|
} else {
|
||||||
u2.unwrap()
|
u2.unwrap()
|
||||||
|
@ -273,7 +280,7 @@ where
|
||||||
&mut off_diagonal,
|
&mut off_diagonal,
|
||||||
&mut u,
|
&mut u,
|
||||||
&mut v_t,
|
&mut v_t,
|
||||||
b.is_upper_diagonal(),
|
bi_matrix.is_upper_diagonal(),
|
||||||
end,
|
end,
|
||||||
eps,
|
eps,
|
||||||
);
|
);
|
||||||
|
|
|
@ -87,7 +87,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_decompose(
|
fn do_decompose(
|
||||||
mut m: OMatrix<T, D, D>,
|
mut matrix: OMatrix<T, D, D>,
|
||||||
eigenvectors: bool,
|
eigenvectors: bool,
|
||||||
eps: T::RealField,
|
eps: T::RealField,
|
||||||
max_niter: usize,
|
max_niter: usize,
|
||||||
|
@ -97,33 +97,33 @@ where
|
||||||
DefaultAllocator: Allocator<T, DimDiff<D, U1>> + Allocator<T::RealField, DimDiff<D, U1>>,
|
DefaultAllocator: Allocator<T, DimDiff<D, U1>> + Allocator<T::RealField, DimDiff<D, U1>>,
|
||||||
{
|
{
|
||||||
assert!(
|
assert!(
|
||||||
m.is_square(),
|
matrix.is_square(),
|
||||||
"Unable to compute the eigendecomposition of a non-square matrix."
|
"Unable to compute the eigendecomposition of a non-square matrix."
|
||||||
);
|
);
|
||||||
let dim = m.nrows();
|
let dim = matrix.nrows();
|
||||||
let m_amax = m.camax();
|
let m_amax = matrix.camax();
|
||||||
|
|
||||||
if !m_amax.is_zero() {
|
if !m_amax.is_zero() {
|
||||||
m.unscale_mut(m_amax);
|
matrix.unscale_mut(m_amax);
|
||||||
}
|
}
|
||||||
|
|
||||||
let (mut q, mut diag, mut off_diag);
|
let (mut q_mat, mut diag, mut off_diag);
|
||||||
|
|
||||||
if eigenvectors {
|
if eigenvectors {
|
||||||
let res = SymmetricTridiagonal::new(m).unpack();
|
let res = SymmetricTridiagonal::new(matrix).unpack();
|
||||||
q = Some(res.0);
|
q_mat = Some(res.0);
|
||||||
diag = res.1;
|
diag = res.1;
|
||||||
off_diag = res.2;
|
off_diag = res.2;
|
||||||
} else {
|
} else {
|
||||||
let res = SymmetricTridiagonal::new(m).unpack_tridiagonal();
|
let res = SymmetricTridiagonal::new(matrix).unpack_tridiagonal();
|
||||||
q = None;
|
q_mat = None;
|
||||||
diag = res.0;
|
diag = res.0;
|
||||||
off_diag = res.1;
|
off_diag = res.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if dim == 1 {
|
if dim == 1 {
|
||||||
diag.scale_mut(m_amax);
|
diag.scale_mut(m_amax);
|
||||||
return Some((diag, q));
|
return Some((diag, q_mat));
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut niter = 0;
|
let mut niter = 0;
|
||||||
|
@ -132,11 +132,12 @@ where
|
||||||
while end != start {
|
while end != start {
|
||||||
let subdim = end - start + 1;
|
let subdim = end - start + 1;
|
||||||
|
|
||||||
|
#[allow(clippy::comparison_chain)]
|
||||||
if subdim > 2 {
|
if subdim > 2 {
|
||||||
let m = end - 1;
|
let m = end - 1;
|
||||||
let n = end;
|
let n = end;
|
||||||
|
|
||||||
let mut v = Vector2::new(
|
let mut vec = Vector2::new(
|
||||||
diag[start] - wilkinson_shift(diag[m], diag[n], off_diag[m]),
|
diag[start] - wilkinson_shift(diag[m], diag[n], off_diag[m]),
|
||||||
off_diag[start],
|
off_diag[start],
|
||||||
);
|
);
|
||||||
|
@ -144,7 +145,7 @@ where
|
||||||
for i in start..n {
|
for i in start..n {
|
||||||
let j = i + 1;
|
let j = i + 1;
|
||||||
|
|
||||||
if let Some((rot, norm)) = GivensRotation::cancel_y(&v) {
|
if let Some((rot, norm)) = GivensRotation::cancel_y(&vec) {
|
||||||
if i > start {
|
if i > start {
|
||||||
// Not the first iteration.
|
// Not the first iteration.
|
||||||
off_diag[i - 1] = norm;
|
off_diag[i - 1] = norm;
|
||||||
|
@ -165,12 +166,12 @@ where
|
||||||
off_diag[i] = cs * (mii - mjj) + mij * (cc - ss);
|
off_diag[i] = cs * (mii - mjj) + mij * (cc - ss);
|
||||||
|
|
||||||
if i != n - 1 {
|
if i != n - 1 {
|
||||||
v.x = off_diag[i];
|
vec.x = off_diag[i];
|
||||||
v.y = -rot.s() * off_diag[i + 1];
|
vec.y = -rot.s() * off_diag[i + 1];
|
||||||
off_diag[i + 1] *= rot.c();
|
off_diag[i + 1] *= rot.c();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref mut q) = q {
|
if let Some(ref mut q) = q_mat {
|
||||||
let rot = GivensRotation::new_unchecked(rot.c(), T::from_real(rot.s()));
|
let rot = GivensRotation::new_unchecked(rot.c(), T::from_real(rot.s()));
|
||||||
rot.inverse().rotate_rows(&mut q.fixed_columns_mut::<2>(i));
|
rot.inverse().rotate_rows(&mut q.fixed_columns_mut::<2>(i));
|
||||||
}
|
}
|
||||||
|
@ -195,7 +196,7 @@ where
|
||||||
diag[start] = eigvals[0];
|
diag[start] = eigvals[0];
|
||||||
diag[start + 1] = eigvals[1];
|
diag[start + 1] = eigvals[1];
|
||||||
|
|
||||||
if let Some(ref mut q) = q {
|
if let Some(ref mut q) = q_mat {
|
||||||
if let Some((rot, _)) = GivensRotation::try_new(basis.x, basis.y, eps) {
|
if let Some((rot, _)) = GivensRotation::try_new(basis.x, basis.y, eps) {
|
||||||
let rot = GivensRotation::new_unchecked(rot.c(), T::from_real(rot.s()));
|
let rot = GivensRotation::new_unchecked(rot.c(), T::from_real(rot.s()));
|
||||||
rot.rotate_rows(&mut q.fixed_columns_mut::<2>(start));
|
rot.rotate_rows(&mut q.fixed_columns_mut::<2>(start));
|
||||||
|
@ -219,7 +220,7 @@ where
|
||||||
|
|
||||||
diag.scale_mut(m_amax);
|
diag.scale_mut(m_amax);
|
||||||
|
|
||||||
Some((diag, q))
|
Some((diag, q_mat))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delimit_subproblem(
|
fn delimit_subproblem(
|
||||||
|
|
|
@ -26,18 +26,20 @@ fn convolve_same_check() {
|
||||||
// Panic Tests
|
// Panic Tests
|
||||||
// These really only apply to dynamic sized vectors
|
// These really only apply to dynamic sized vectors
|
||||||
assert!(panic::catch_unwind(|| {
|
assert!(panic::catch_unwind(|| {
|
||||||
DVector::from_vec(vec![1.0, 2.0])
|
let _ = DVector::from_vec(vec![1.0, 2.0])
|
||||||
.convolve_same(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]));
|
.convolve_same(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]));
|
||||||
})
|
})
|
||||||
.is_err());
|
.is_err());
|
||||||
|
|
||||||
assert!(panic::catch_unwind(|| {
|
assert!(panic::catch_unwind(|| {
|
||||||
DVector::<f32>::from_vec(vec![]).convolve_same(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]));
|
let _ = DVector::<f32>::from_vec(vec![])
|
||||||
|
.convolve_same(DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]));
|
||||||
})
|
})
|
||||||
.is_err());
|
.is_err());
|
||||||
|
|
||||||
assert!(panic::catch_unwind(|| {
|
assert!(panic::catch_unwind(|| {
|
||||||
DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0]).convolve_same(DVector::<f32>::from_vec(vec![]));
|
let _ = DVector::from_vec(vec![1.0, 2.0, 3.0, 4.0])
|
||||||
|
.convolve_same(DVector::<f32>::from_vec(vec![]));
|
||||||
})
|
})
|
||||||
.is_err());
|
.is_err());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue