Add From<[...; .]> impls for all SIMD geometric sructures up to the isometry (excluded).
This commit is contained in:
parent
b1857e6a36
commit
b3f347e45e
|
@ -9,6 +9,8 @@ use generic_array::ArrayLength;
|
||||||
use std::ops::Mul;
|
use std::ops::Mul;
|
||||||
use typenum::Prod;
|
use typenum::Prod;
|
||||||
|
|
||||||
|
use simba::simd::{PrimitiveSimdValue, SimdValue};
|
||||||
|
|
||||||
use crate::base::allocator::{Allocator, SameShapeAllocator};
|
use crate::base::allocator::{Allocator, SameShapeAllocator};
|
||||||
use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
|
use crate::base::constraint::{SameNumberOfColumns, SameNumberOfRows, ShapeConstraint};
|
||||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||||
|
@ -576,3 +578,108 @@ impl<'a, N: Scalar + Copy> From<&'a mut [N]> for DVectorSliceMut<'a, N> {
|
||||||
Self::from_slice(slice, slice.len())
|
Self::from_slice(slice, slice.len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[MatrixMN<N::Element, R, C>; 2]>
|
||||||
|
for MatrixMN<N, R, C>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 2]>,
|
||||||
|
N::Element: Scalar + SimdValue,
|
||||||
|
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [MatrixMN<N::Element, R, C>; 2]) -> Self {
|
||||||
|
let (nrows, ncols) = arr[0].data.shape();
|
||||||
|
|
||||||
|
Self::from_fn_generic(nrows, ncols, |i, j| {
|
||||||
|
[
|
||||||
|
arr[0][(i, j)].inlined_clone(),
|
||||||
|
arr[1][(i, j)].inlined_clone(),
|
||||||
|
]
|
||||||
|
.into()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[MatrixMN<N::Element, R, C>; 4]>
|
||||||
|
for MatrixMN<N, R, C>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 4]>,
|
||||||
|
N::Element: Scalar + SimdValue,
|
||||||
|
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [MatrixMN<N::Element, R, C>; 4]) -> Self {
|
||||||
|
let (nrows, ncols) = arr[0].data.shape();
|
||||||
|
|
||||||
|
Self::from_fn_generic(nrows, ncols, |i, j| {
|
||||||
|
[
|
||||||
|
arr[0][(i, j)].inlined_clone(),
|
||||||
|
arr[1][(i, j)].inlined_clone(),
|
||||||
|
arr[2][(i, j)].inlined_clone(),
|
||||||
|
arr[3][(i, j)].inlined_clone(),
|
||||||
|
]
|
||||||
|
.into()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[MatrixMN<N::Element, R, C>; 8]>
|
||||||
|
for MatrixMN<N, R, C>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 8]>,
|
||||||
|
N::Element: Scalar + SimdValue,
|
||||||
|
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [MatrixMN<N::Element, R, C>; 8]) -> Self {
|
||||||
|
let (nrows, ncols) = arr[0].data.shape();
|
||||||
|
|
||||||
|
Self::from_fn_generic(nrows, ncols, |i, j| {
|
||||||
|
[
|
||||||
|
arr[0][(i, j)].inlined_clone(),
|
||||||
|
arr[1][(i, j)].inlined_clone(),
|
||||||
|
arr[2][(i, j)].inlined_clone(),
|
||||||
|
arr[3][(i, j)].inlined_clone(),
|
||||||
|
arr[4][(i, j)].inlined_clone(),
|
||||||
|
arr[5][(i, j)].inlined_clone(),
|
||||||
|
arr[6][(i, j)].inlined_clone(),
|
||||||
|
arr[7][(i, j)].inlined_clone(),
|
||||||
|
]
|
||||||
|
.into()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue, R: Dim, C: Dim> From<[MatrixMN<N::Element, R, C>; 16]>
|
||||||
|
for MatrixMN<N, R, C>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 16]>,
|
||||||
|
N::Element: Scalar + SimdValue,
|
||||||
|
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
|
||||||
|
{
|
||||||
|
fn from(arr: [MatrixMN<N::Element, R, C>; 16]) -> Self {
|
||||||
|
let (nrows, ncols) = arr[0].data.shape();
|
||||||
|
|
||||||
|
Self::from_fn_generic(nrows, ncols, |i, j| {
|
||||||
|
[
|
||||||
|
arr[0][(i, j)].inlined_clone(),
|
||||||
|
arr[1][(i, j)].inlined_clone(),
|
||||||
|
arr[2][(i, j)].inlined_clone(),
|
||||||
|
arr[3][(i, j)].inlined_clone(),
|
||||||
|
arr[4][(i, j)].inlined_clone(),
|
||||||
|
arr[5][(i, j)].inlined_clone(),
|
||||||
|
arr[6][(i, j)].inlined_clone(),
|
||||||
|
arr[7][(i, j)].inlined_clone(),
|
||||||
|
arr[8][(i, j)].inlined_clone(),
|
||||||
|
arr[9][(i, j)].inlined_clone(),
|
||||||
|
arr[10][(i, j)].inlined_clone(),
|
||||||
|
arr[11][(i, j)].inlined_clone(),
|
||||||
|
arr[12][(i, j)].inlined_clone(),
|
||||||
|
arr[13][(i, j)].inlined_clone(),
|
||||||
|
arr[14][(i, j)].inlined_clone(),
|
||||||
|
arr[15][(i, j)].inlined_clone(),
|
||||||
|
]
|
||||||
|
.into()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -9,7 +9,9 @@ use serde::{Deserialize, Deserializer, Serialize, Serializer};
|
||||||
#[cfg(feature = "abomonation-serialize")]
|
#[cfg(feature = "abomonation-serialize")]
|
||||||
use abomonation::Abomonation;
|
use abomonation::Abomonation;
|
||||||
|
|
||||||
use crate::{RealField, SimdComplexField, SimdRealField};
|
use crate::allocator::Allocator;
|
||||||
|
use crate::base::DefaultAllocator;
|
||||||
|
use crate::{Dim, MatrixMN, RealField, Scalar, SimdComplexField, SimdRealField};
|
||||||
|
|
||||||
/// A wrapper that ensures the underlying algebraic entity has a unit norm.
|
/// A wrapper that ensures the underlying algebraic entity has a unit norm.
|
||||||
///
|
///
|
||||||
|
@ -240,3 +242,92 @@ impl<T> Deref for Unit<T> {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { mem::transmute(self) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NOTE: we can't use a generic implementation for `Unit<T>` because
|
||||||
|
// num_complex::Complex does not implement `From[Complex<...>...]` (and can't
|
||||||
|
// because of the orphan rules).
|
||||||
|
impl<N: Scalar + simba::simd::PrimitiveSimdValue, R: Dim, C: Dim>
|
||||||
|
From<[Unit<MatrixMN<N::Element, R, C>>; 2]> for Unit<MatrixMN<N, R, C>>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 2]>,
|
||||||
|
N::Element: Scalar,
|
||||||
|
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Unit<MatrixMN<N::Element, R, C>>; 2]) -> Self {
|
||||||
|
Self::new_unchecked(MatrixMN::from([
|
||||||
|
arr[0].clone().into_inner(),
|
||||||
|
arr[1].clone().into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + simba::simd::PrimitiveSimdValue, R: Dim, C: Dim>
|
||||||
|
From<[Unit<MatrixMN<N::Element, R, C>>; 4]> for Unit<MatrixMN<N, R, C>>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 4]>,
|
||||||
|
N::Element: Scalar,
|
||||||
|
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Unit<MatrixMN<N::Element, R, C>>; 4]) -> Self {
|
||||||
|
Self::new_unchecked(MatrixMN::from([
|
||||||
|
arr[0].clone().into_inner(),
|
||||||
|
arr[1].clone().into_inner(),
|
||||||
|
arr[2].clone().into_inner(),
|
||||||
|
arr[3].clone().into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + simba::simd::PrimitiveSimdValue, R: Dim, C: Dim>
|
||||||
|
From<[Unit<MatrixMN<N::Element, R, C>>; 8]> for Unit<MatrixMN<N, R, C>>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 8]>,
|
||||||
|
N::Element: Scalar,
|
||||||
|
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Unit<MatrixMN<N::Element, R, C>>; 8]) -> Self {
|
||||||
|
Self::new_unchecked(MatrixMN::from([
|
||||||
|
arr[0].clone().into_inner(),
|
||||||
|
arr[1].clone().into_inner(),
|
||||||
|
arr[2].clone().into_inner(),
|
||||||
|
arr[3].clone().into_inner(),
|
||||||
|
arr[4].clone().into_inner(),
|
||||||
|
arr[5].clone().into_inner(),
|
||||||
|
arr[6].clone().into_inner(),
|
||||||
|
arr[7].clone().into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + simba::simd::PrimitiveSimdValue, R: Dim, C: Dim>
|
||||||
|
From<[Unit<MatrixMN<N::Element, R, C>>; 16]> for Unit<MatrixMN<N, R, C>>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 16]>,
|
||||||
|
N::Element: Scalar,
|
||||||
|
DefaultAllocator: Allocator<N, R, C> + Allocator<N::Element, R, C>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Unit<MatrixMN<N::Element, R, C>>; 16]) -> Self {
|
||||||
|
Self::new_unchecked(MatrixMN::from([
|
||||||
|
arr[0].clone().into_inner(),
|
||||||
|
arr[1].clone().into_inner(),
|
||||||
|
arr[2].clone().into_inner(),
|
||||||
|
arr[3].clone().into_inner(),
|
||||||
|
arr[4].clone().into_inner(),
|
||||||
|
arr[5].clone().into_inner(),
|
||||||
|
arr[6].clone().into_inner(),
|
||||||
|
arr[7].clone().into_inner(),
|
||||||
|
arr[8].clone().into_inner(),
|
||||||
|
arr[9].clone().into_inner(),
|
||||||
|
arr[10].clone().into_inner(),
|
||||||
|
arr[11].clone().into_inner(),
|
||||||
|
arr[12].clone().into_inner(),
|
||||||
|
arr[13].clone().into_inner(),
|
||||||
|
arr[14].clone().into_inner(),
|
||||||
|
arr[15].clone().into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
||||||
use simba::simd::SimdRealField;
|
use simba::simd::{PrimitiveSimdValue, SimdRealField, SimdValue};
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1};
|
use crate::base::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1};
|
||||||
|
@ -162,3 +162,21 @@ where
|
||||||
iso.to_homogeneous()
|
iso.to_homogeneous()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//impl<N: Scalar + PrimitiveSimdValue, D: DimName, R> From<[Isometry<N::Element, D, R>; 2]>
|
||||||
|
// for Rotation<N, D>
|
||||||
|
//where
|
||||||
|
// N: From<[<N as SimdValue>::Element; 2]>,
|
||||||
|
// R: From<[R::Element; 2]>,
|
||||||
|
// N::Element: Scalar + Copy,
|
||||||
|
// R::Element: Scalar + Copy,
|
||||||
|
// DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
//{
|
||||||
|
// #[inline]
|
||||||
|
// fn from(arr: [Isometry<N::Element, D, R>; 2]) -> Self {
|
||||||
|
// Self::from_parts(MatrixN::from([
|
||||||
|
// arr[0].clone().into_inner(),
|
||||||
|
// arr[1].clone().into_inner(),
|
||||||
|
// ]))
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
use simba::scalar::{ClosedDiv, SubsetOf, SupersetOf};
|
use simba::scalar::{ClosedDiv, SubsetOf, SupersetOf};
|
||||||
|
use simba::simd::{PrimitiveSimdValue, SimdValue};
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
||||||
|
@ -149,3 +150,90 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
Point { coords }
|
Point { coords }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue, D: DimName> From<[Point<N::Element, D>; 2]>
|
||||||
|
for Point<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 2]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
<DefaultAllocator as Allocator<N::Element, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Point<N::Element, D>; 2]) -> Self {
|
||||||
|
Self::from(VectorN::from([arr[0].coords, arr[1].coords]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue, D: DimName> From<[Point<N::Element, D>; 4]>
|
||||||
|
for Point<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 4]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
<DefaultAllocator as Allocator<N::Element, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Point<N::Element, D>; 4]) -> Self {
|
||||||
|
Self::from(VectorN::from([
|
||||||
|
arr[0].coords,
|
||||||
|
arr[1].coords,
|
||||||
|
arr[2].coords,
|
||||||
|
arr[3].coords,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue, D: DimName> From<[Point<N::Element, D>; 8]>
|
||||||
|
for Point<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 8]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
<DefaultAllocator as Allocator<N::Element, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Point<N::Element, D>; 8]) -> Self {
|
||||||
|
Self::from(VectorN::from([
|
||||||
|
arr[0].coords,
|
||||||
|
arr[1].coords,
|
||||||
|
arr[2].coords,
|
||||||
|
arr[3].coords,
|
||||||
|
arr[4].coords,
|
||||||
|
arr[5].coords,
|
||||||
|
arr[6].coords,
|
||||||
|
arr[7].coords,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue, D: DimName> From<[Point<N::Element, D>; 16]>
|
||||||
|
for Point<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 16]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
<DefaultAllocator as Allocator<N::Element, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Point<N::Element, D>; 16]) -> Self {
|
||||||
|
Self::from(VectorN::from([
|
||||||
|
arr[0].coords,
|
||||||
|
arr[1].coords,
|
||||||
|
arr[2].coords,
|
||||||
|
arr[3].coords,
|
||||||
|
arr[4].coords,
|
||||||
|
arr[5].coords,
|
||||||
|
arr[6].coords,
|
||||||
|
arr[7].coords,
|
||||||
|
arr[8].coords,
|
||||||
|
arr[9].coords,
|
||||||
|
arr[10].coords,
|
||||||
|
arr[11].coords,
|
||||||
|
arr[12].coords,
|
||||||
|
arr[13].coords,
|
||||||
|
arr[14].coords,
|
||||||
|
arr[15].coords,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -68,9 +68,9 @@ impl<N: SimdRealField + hash::Hash> hash::Hash for Quaternion<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> Copy for Quaternion<N> {}
|
impl<N: Scalar + Copy + SimdValue> Copy for Quaternion<N> {}
|
||||||
|
|
||||||
impl<N: SimdRealField> Clone for Quaternion<N> {
|
impl<N: Scalar + SimdValue> Clone for Quaternion<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
Self::from(self.coords.clone())
|
Self::from(self.coords.clone())
|
||||||
|
|
|
@ -10,16 +10,16 @@ use rand::distributions::{Distribution, OpenClosed01, Standard};
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
||||||
use simba::scalar::RealField;
|
use simba::scalar::RealField;
|
||||||
use simba::simd::SimdBool;
|
use simba::simd::{SimdBool, SimdValue};
|
||||||
|
|
||||||
use crate::base::dimension::U3;
|
use crate::base::dimension::U3;
|
||||||
use crate::base::storage::Storage;
|
use crate::base::storage::Storage;
|
||||||
use crate::base::{Matrix3, Matrix4, Unit, Vector, Vector3, Vector4};
|
use crate::base::{Matrix3, Matrix4, Unit, Vector, Vector3, Vector4};
|
||||||
use crate::SimdRealField;
|
use crate::{Scalar, SimdRealField};
|
||||||
|
|
||||||
use crate::geometry::{Quaternion, Rotation3, UnitQuaternion};
|
use crate::geometry::{Quaternion, Rotation3, UnitQuaternion};
|
||||||
|
|
||||||
impl<N: SimdRealField> Quaternion<N> {
|
impl<N: Scalar + SimdValue> Quaternion<N> {
|
||||||
/// Creates a quaternion from a 4D vector. The quaternion scalar part corresponds to the `w`
|
/// Creates a quaternion from a 4D vector. The quaternion scalar part corresponds to the `w`
|
||||||
/// vector component.
|
/// vector component.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -45,7 +45,9 @@ impl<N: SimdRealField> Quaternion<N> {
|
||||||
pub fn new(w: N, i: N, j: N, k: N) -> Self {
|
pub fn new(w: N, i: N, j: N, k: N) -> Self {
|
||||||
Self::from(Vector4::new(i, j, k, w))
|
Self::from(Vector4::new(i, j, k, w))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: SimdRealField> Quaternion<N> {
|
||||||
/// Constructs a pure quaternion.
|
/// Constructs a pure quaternion.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_imag(vector: Vector3<N>) -> Self {
|
pub fn from_imag(vector: Vector3<N>) -> Self {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use num::Zero;
|
use num::Zero;
|
||||||
|
|
||||||
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
||||||
use simba::simd::{SimdRealField, SimdValue};
|
use simba::simd::{PrimitiveSimdValue, SimdRealField, SimdValue};
|
||||||
|
|
||||||
#[cfg(feature = "mint")]
|
#[cfg(feature = "mint")]
|
||||||
use mint;
|
use mint;
|
||||||
|
@ -260,3 +260,157 @@ impl<N: Scalar + SimdValue> From<Vector4<N>> for Quaternion<N> {
|
||||||
Self { coords }
|
Self { coords }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue> From<[Quaternion<N::Element>; 2]> for Quaternion<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 2]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Quaternion<N::Element>; 2]) -> Self {
|
||||||
|
Self::from(Vector4::from([arr[0].coords, arr[1].coords]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue> From<[Quaternion<N::Element>; 4]> for Quaternion<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 4]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Quaternion<N::Element>; 4]) -> Self {
|
||||||
|
Self::from(Vector4::from([
|
||||||
|
arr[0].coords,
|
||||||
|
arr[1].coords,
|
||||||
|
arr[2].coords,
|
||||||
|
arr[3].coords,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue> From<[Quaternion<N::Element>; 8]> for Quaternion<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 8]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Quaternion<N::Element>; 8]) -> Self {
|
||||||
|
Self::from(Vector4::from([
|
||||||
|
arr[0].coords,
|
||||||
|
arr[1].coords,
|
||||||
|
arr[2].coords,
|
||||||
|
arr[3].coords,
|
||||||
|
arr[4].coords,
|
||||||
|
arr[5].coords,
|
||||||
|
arr[6].coords,
|
||||||
|
arr[7].coords,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue> From<[Quaternion<N::Element>; 16]> for Quaternion<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 16]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Quaternion<N::Element>; 16]) -> Self {
|
||||||
|
Self::from(Vector4::from([
|
||||||
|
arr[0].coords,
|
||||||
|
arr[1].coords,
|
||||||
|
arr[2].coords,
|
||||||
|
arr[3].coords,
|
||||||
|
arr[4].coords,
|
||||||
|
arr[5].coords,
|
||||||
|
arr[6].coords,
|
||||||
|
arr[7].coords,
|
||||||
|
arr[8].coords,
|
||||||
|
arr[9].coords,
|
||||||
|
arr[10].coords,
|
||||||
|
arr[11].coords,
|
||||||
|
arr[12].coords,
|
||||||
|
arr[13].coords,
|
||||||
|
arr[14].coords,
|
||||||
|
arr[15].coords,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<N::Element>; 2]>
|
||||||
|
for UnitQuaternion<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 2]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [UnitQuaternion<N::Element>; 2]) -> Self {
|
||||||
|
Self::new_unchecked(Quaternion::from([arr[0].into_inner(), arr[1].into_inner()]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<N::Element>; 4]>
|
||||||
|
for UnitQuaternion<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 4]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [UnitQuaternion<N::Element>; 4]) -> Self {
|
||||||
|
Self::new_unchecked(Quaternion::from([
|
||||||
|
arr[0].into_inner(),
|
||||||
|
arr[1].into_inner(),
|
||||||
|
arr[2].into_inner(),
|
||||||
|
arr[3].into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<N::Element>; 8]>
|
||||||
|
for UnitQuaternion<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 8]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [UnitQuaternion<N::Element>; 8]) -> Self {
|
||||||
|
Self::new_unchecked(Quaternion::from([
|
||||||
|
arr[0].into_inner(),
|
||||||
|
arr[1].into_inner(),
|
||||||
|
arr[2].into_inner(),
|
||||||
|
arr[3].into_inner(),
|
||||||
|
arr[4].into_inner(),
|
||||||
|
arr[5].into_inner(),
|
||||||
|
arr[6].into_inner(),
|
||||||
|
arr[7].into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitQuaternion<N::Element>; 16]>
|
||||||
|
for UnitQuaternion<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 16]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [UnitQuaternion<N::Element>; 16]) -> Self {
|
||||||
|
Self::new_unchecked(Quaternion::from([
|
||||||
|
arr[0].into_inner(),
|
||||||
|
arr[1].into_inner(),
|
||||||
|
arr[2].into_inner(),
|
||||||
|
arr[3].into_inner(),
|
||||||
|
arr[4].into_inner(),
|
||||||
|
arr[5].into_inner(),
|
||||||
|
arr[6].into_inner(),
|
||||||
|
arr[7].into_inner(),
|
||||||
|
arr[8].into_inner(),
|
||||||
|
arr[9].into_inner(),
|
||||||
|
arr[10].into_inner(),
|
||||||
|
arr[11].into_inner(),
|
||||||
|
arr[12].into_inner(),
|
||||||
|
arr[13].into_inner(),
|
||||||
|
arr[14].into_inner(),
|
||||||
|
arr[15].into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::ops::{Deref, DerefMut};
|
use std::ops::{Deref, DerefMut};
|
||||||
|
|
||||||
use simba::simd::SimdRealField;
|
use simba::simd::SimdValue;
|
||||||
|
|
||||||
use crate::base::coordinates::IJKW;
|
use crate::base::coordinates::IJKW;
|
||||||
|
use crate::Scalar;
|
||||||
|
|
||||||
use crate::geometry::Quaternion;
|
use crate::geometry::Quaternion;
|
||||||
|
|
||||||
impl<N: SimdRealField> Deref for Quaternion<N> {
|
impl<N: Scalar + SimdValue> Deref for Quaternion<N> {
|
||||||
type Target = IJKW<N>;
|
type Target = IJKW<N>;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -16,7 +17,7 @@ impl<N: SimdRealField> Deref for Quaternion<N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<N: SimdRealField> DerefMut for Quaternion<N> {
|
impl<N: Scalar + SimdValue> DerefMut for Quaternion<N> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
unsafe { mem::transmute(self) }
|
unsafe { mem::transmute(self) }
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use num::Zero;
|
use num::Zero;
|
||||||
|
|
||||||
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
||||||
|
use simba::simd::{PrimitiveSimdValue, SimdValue};
|
||||||
|
|
||||||
#[cfg(feature = "mint")]
|
#[cfg(feature = "mint")]
|
||||||
use mint;
|
use mint;
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1};
|
use crate::base::dimension::{DimMin, DimName, DimNameAdd, DimNameSum, U1};
|
||||||
use crate::base::{DefaultAllocator, Matrix2, Matrix3, Matrix4, MatrixN};
|
use crate::base::{DefaultAllocator, Matrix2, Matrix3, Matrix4, MatrixN, Scalar};
|
||||||
|
|
||||||
use crate::geometry::{
|
use crate::geometry::{
|
||||||
AbstractRotation, Isometry, Rotation, Rotation2, Rotation3, Similarity, SuperTCategoryOf,
|
AbstractRotation, Isometry, Rotation, Rotation2, Rotation3, Similarity, SuperTCategoryOf,
|
||||||
|
@ -243,3 +244,89 @@ impl<N: RealField> From<Rotation3<N>> for Matrix3<N> {
|
||||||
q.into_inner()
|
q.into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue, D: DimName> From<[Rotation<N::Element, D>; 2]>
|
||||||
|
for Rotation<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 2]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D, D> + Allocator<N::Element, D, D>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Rotation<N::Element, D>; 2]) -> Self {
|
||||||
|
Self::from_matrix_unchecked(MatrixN::from([
|
||||||
|
arr[0].clone().into_inner(),
|
||||||
|
arr[1].clone().into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue, D: DimName> From<[Rotation<N::Element, D>; 4]>
|
||||||
|
for Rotation<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 4]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D, D> + Allocator<N::Element, D, D>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Rotation<N::Element, D>; 4]) -> Self {
|
||||||
|
Self::from_matrix_unchecked(MatrixN::from([
|
||||||
|
arr[0].clone().into_inner(),
|
||||||
|
arr[1].clone().into_inner(),
|
||||||
|
arr[2].clone().into_inner(),
|
||||||
|
arr[3].clone().into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue, D: DimName> From<[Rotation<N::Element, D>; 8]>
|
||||||
|
for Rotation<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 8]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D, D> + Allocator<N::Element, D, D>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Rotation<N::Element, D>; 8]) -> Self {
|
||||||
|
Self::from_matrix_unchecked(MatrixN::from([
|
||||||
|
arr[0].clone().into_inner(),
|
||||||
|
arr[1].clone().into_inner(),
|
||||||
|
arr[2].clone().into_inner(),
|
||||||
|
arr[3].clone().into_inner(),
|
||||||
|
arr[4].clone().into_inner(),
|
||||||
|
arr[5].clone().into_inner(),
|
||||||
|
arr[6].clone().into_inner(),
|
||||||
|
arr[7].clone().into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + PrimitiveSimdValue, D: DimName> From<[Rotation<N::Element, D>; 16]>
|
||||||
|
for Rotation<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as SimdValue>::Element; 16]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D, D> + Allocator<N::Element, D, D>,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Rotation<N::Element, D>; 16]) -> Self {
|
||||||
|
Self::from_matrix_unchecked(MatrixN::from([
|
||||||
|
arr[0].clone().into_inner(),
|
||||||
|
arr[1].clone().into_inner(),
|
||||||
|
arr[2].clone().into_inner(),
|
||||||
|
arr[3].clone().into_inner(),
|
||||||
|
arr[4].clone().into_inner(),
|
||||||
|
arr[5].clone().into_inner(),
|
||||||
|
arr[6].clone().into_inner(),
|
||||||
|
arr[7].clone().into_inner(),
|
||||||
|
arr[8].clone().into_inner(),
|
||||||
|
arr[9].clone().into_inner(),
|
||||||
|
arr[10].clone().into_inner(),
|
||||||
|
arr[11].clone().into_inner(),
|
||||||
|
arr[12].clone().into_inner(),
|
||||||
|
arr[13].clone().into_inner(),
|
||||||
|
arr[14].clone().into_inner(),
|
||||||
|
arr[15].clone().into_inner(),
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use num::{One, Zero};
|
use num::{One, Zero};
|
||||||
|
|
||||||
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
||||||
|
use simba::simd::PrimitiveSimdValue;
|
||||||
|
|
||||||
use crate::base::allocator::Allocator;
|
use crate::base::allocator::Allocator;
|
||||||
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
use crate::base::dimension::{DimName, DimNameAdd, DimNameSum, U1};
|
||||||
|
@ -173,3 +174,90 @@ where DefaultAllocator: Allocator<N, D>
|
||||||
Translation { vector }
|
Translation { vector }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue, D: DimName> From<[Translation<N::Element, D>; 2]>
|
||||||
|
for Translation<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 2]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
<DefaultAllocator as Allocator<N::Element, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Translation<N::Element, D>; 2]) -> Self {
|
||||||
|
Self::from(VectorN::from([arr[0].vector, arr[1].vector]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue, D: DimName> From<[Translation<N::Element, D>; 4]>
|
||||||
|
for Translation<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 4]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
<DefaultAllocator as Allocator<N::Element, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Translation<N::Element, D>; 4]) -> Self {
|
||||||
|
Self::from(VectorN::from([
|
||||||
|
arr[0].vector,
|
||||||
|
arr[1].vector,
|
||||||
|
arr[2].vector,
|
||||||
|
arr[3].vector,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue, D: DimName> From<[Translation<N::Element, D>; 8]>
|
||||||
|
for Translation<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 8]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
<DefaultAllocator as Allocator<N::Element, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Translation<N::Element, D>; 8]) -> Self {
|
||||||
|
Self::from(VectorN::from([
|
||||||
|
arr[0].vector,
|
||||||
|
arr[1].vector,
|
||||||
|
arr[2].vector,
|
||||||
|
arr[3].vector,
|
||||||
|
arr[4].vector,
|
||||||
|
arr[5].vector,
|
||||||
|
arr[6].vector,
|
||||||
|
arr[7].vector,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue, D: DimName> From<[Translation<N::Element, D>; 16]>
|
||||||
|
for Translation<N, D>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 16]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
DefaultAllocator: Allocator<N, D> + Allocator<N::Element, D>,
|
||||||
|
<DefaultAllocator as Allocator<N::Element, D>>::Buffer: Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [Translation<N::Element, D>; 16]) -> Self {
|
||||||
|
Self::from(VectorN::from([
|
||||||
|
arr[0].vector,
|
||||||
|
arr[1].vector,
|
||||||
|
arr[2].vector,
|
||||||
|
arr[3].vector,
|
||||||
|
arr[4].vector,
|
||||||
|
arr[5].vector,
|
||||||
|
arr[6].vector,
|
||||||
|
arr[7].vector,
|
||||||
|
arr[8].vector,
|
||||||
|
arr[9].vector,
|
||||||
|
arr[10].vector,
|
||||||
|
arr[11].vector,
|
||||||
|
arr[12].vector,
|
||||||
|
arr[13].vector,
|
||||||
|
arr[14].vector,
|
||||||
|
arr[15].vector,
|
||||||
|
]))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -2,10 +2,10 @@ use num::Zero;
|
||||||
use num_complex::Complex;
|
use num_complex::Complex;
|
||||||
|
|
||||||
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
use simba::scalar::{RealField, SubsetOf, SupersetOf};
|
||||||
use simba::simd::SimdRealField;
|
use simba::simd::{PrimitiveSimdValue, SimdRealField, SimdValue};
|
||||||
|
|
||||||
use crate::base::dimension::U2;
|
use crate::base::dimension::U2;
|
||||||
use crate::base::{Matrix2, Matrix3};
|
use crate::base::{Matrix2, Matrix3, Scalar};
|
||||||
use crate::geometry::{
|
use crate::geometry::{
|
||||||
AbstractRotation, Isometry, Rotation2, Similarity, SuperTCategoryOf, TAffine, Transform,
|
AbstractRotation, Isometry, Rotation2, Similarity, SuperTCategoryOf, TAffine, Transform,
|
||||||
Translation, UnitComplex,
|
Translation, UnitComplex,
|
||||||
|
@ -189,3 +189,73 @@ where N::Element: SimdRealField
|
||||||
q.to_rotation_matrix().into_inner()
|
q.to_rotation_matrix().into_inner()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitComplex<N::Element>; 2]> for UnitComplex<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 2]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [UnitComplex<N::Element>; 2]) -> Self {
|
||||||
|
Self::new_unchecked(Complex {
|
||||||
|
re: N::from([arr[0].re, arr[1].re]),
|
||||||
|
im: N::from([arr[0].im, arr[1].im]),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitComplex<N::Element>; 4]> for UnitComplex<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 4]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [UnitComplex<N::Element>; 4]) -> Self {
|
||||||
|
Self::new_unchecked(Complex {
|
||||||
|
re: N::from([arr[0].re, arr[1].re, arr[2].re, arr[3].re]),
|
||||||
|
im: N::from([arr[0].im, arr[1].im, arr[2].im, arr[3].im]),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitComplex<N::Element>; 8]> for UnitComplex<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 8]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [UnitComplex<N::Element>; 8]) -> Self {
|
||||||
|
Self::new_unchecked(Complex {
|
||||||
|
re: N::from([
|
||||||
|
arr[0].re, arr[1].re, arr[2].re, arr[3].re, arr[4].re, arr[5].re, arr[6].re,
|
||||||
|
arr[7].re,
|
||||||
|
]),
|
||||||
|
im: N::from([
|
||||||
|
arr[0].im, arr[1].im, arr[2].im, arr[3].im, arr[4].im, arr[5].im, arr[6].im,
|
||||||
|
arr[7].im,
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<N: Scalar + Copy + PrimitiveSimdValue> From<[UnitComplex<N::Element>; 16]> for UnitComplex<N>
|
||||||
|
where
|
||||||
|
N: From<[<N as simba::simd::SimdValue>::Element; 16]>,
|
||||||
|
N::Element: Scalar + Copy,
|
||||||
|
{
|
||||||
|
#[inline]
|
||||||
|
fn from(arr: [UnitComplex<N::Element>; 16]) -> Self {
|
||||||
|
Self::new_unchecked(Complex {
|
||||||
|
re: N::from([
|
||||||
|
arr[0].re, arr[1].re, arr[2].re, arr[3].re, arr[4].re, arr[5].re, arr[6].re,
|
||||||
|
arr[7].re, arr[8].re, arr[9].re, arr[10].re, arr[11].re, arr[12].re, arr[13].re,
|
||||||
|
arr[14].re, arr[15].re,
|
||||||
|
]),
|
||||||
|
im: N::from([
|
||||||
|
arr[0].im, arr[1].im, arr[2].im, arr[3].im, arr[4].im, arr[5].im, arr[6].im,
|
||||||
|
arr[7].im, arr[8].im, arr[9].im, arr[10].im, arr[11].im, arr[12].im, arr[13].im,
|
||||||
|
arr[14].im, arr[15].im,
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue