Merge pull request #407 from brendanzab/sum-product-cleanups
Sum and Product cleanups
This commit is contained in:
commit
1bd0cb285e
11 changed files with 109 additions and 68 deletions
15
src/angle.rs
15
src/angle.rs
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::f64;
|
use std::f64;
|
||||||
|
use std::iter;
|
||||||
use std::ops::*;
|
use std::ops::*;
|
||||||
|
|
||||||
use rand::{Rand, Rng};
|
use rand::{Rand, Rng};
|
||||||
|
@ -72,6 +73,20 @@ macro_rules! impl_angle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<S: BaseFloat> iter::Sum<$Angle<S>> for $Angle<S> {
|
||||||
|
#[inline]
|
||||||
|
fn sum<I: Iterator<Item=$Angle<S>>>(iter: I) -> $Angle<S> {
|
||||||
|
iter.fold($Angle::zero(), Add::add)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, S: 'a + BaseFloat> iter::Sum<&'a $Angle<S>> for $Angle<S> {
|
||||||
|
#[inline]
|
||||||
|
fn sum<I: Iterator<Item=&'a $Angle<S>>>(iter: I) -> $Angle<S> {
|
||||||
|
iter.fold($Angle::zero(), Add::add)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> Angle for $Angle<S> {
|
impl<S: BaseFloat> Angle for $Angle<S> {
|
||||||
type Unitless = S;
|
type Unitless = S;
|
||||||
|
|
||||||
|
|
|
@ -968,31 +968,31 @@ macro_rules! impl_matrix {
|
||||||
fn sub_assign(&mut self, other: $MatrixN<S>) { $(self.$field -= other.$field);+ }
|
fn sub_assign(&mut self, other: $MatrixN<S>) { $(self.$field -= other.$field);+ }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> iter::Sum for $MatrixN<S> {
|
impl<S: BaseFloat> iter::Sum<$MatrixN<S>> for $MatrixN<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sum<I: Iterator<Item=Self>>(iter: I) -> Self {
|
fn sum<I: Iterator<Item=$MatrixN<S>>>(iter: I) -> $MatrixN<S> {
|
||||||
iter.fold(Self::zero(), Add::add)
|
iter.fold($MatrixN::zero(), Add::add)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: 'a + BaseFloat> iter::Sum<&'a Self> for $MatrixN<S> {
|
impl<'a, S: 'a + BaseFloat> iter::Sum<&'a $MatrixN<S>> for $MatrixN<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sum<I: Iterator<Item=&'a Self>>(iter: I) -> Self {
|
fn sum<I: Iterator<Item=&'a $MatrixN<S>>>(iter: I) -> $MatrixN<S> {
|
||||||
iter.fold(Self::zero(), Add::add)
|
iter.fold($MatrixN::zero(), Add::add)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> iter::Product for $MatrixN<S> {
|
impl<S: BaseFloat> iter::Product for $MatrixN<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn product<I: Iterator<Item=Self>>(iter: I) -> Self {
|
fn product<I: Iterator<Item=$MatrixN<S>>>(iter: I) -> $MatrixN<S> {
|
||||||
iter.fold(Self::identity(), Mul::mul)
|
iter.fold($MatrixN::identity(), Mul::mul)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: 'a + BaseFloat> iter::Product<&'a Self> for $MatrixN<S> {
|
impl<'a, S: 'a + BaseFloat> iter::Product<&'a $MatrixN<S>> for $MatrixN<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn product<I: Iterator<Item=&'a Self>>(iter: I) -> Self {
|
fn product<I: Iterator<Item=&'a $MatrixN<S>>>(iter: I) -> $MatrixN<S> {
|
||||||
iter.fold(Self::identity(), Mul::mul)
|
iter.fold($MatrixN::identity(), Mul::mul)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -188,31 +188,31 @@ impl<S: BaseFloat> One for Quaternion<S> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> iter::Sum for Quaternion<S> {
|
impl<S: BaseFloat> iter::Sum<Quaternion<S>> for Quaternion<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sum<I: Iterator<Item=Self>>(iter: I) -> Self {
|
fn sum<I: Iterator<Item=Quaternion<S>>>(iter: I) -> Quaternion<S> {
|
||||||
iter.fold(Self::zero(), Add::add)
|
iter.fold(Quaternion::<S>::zero(), Add::add)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: 'a + BaseFloat> iter::Sum<&'a Self> for Quaternion<S> {
|
impl<'a, S: 'a + BaseFloat> iter::Sum<&'a Quaternion<S>> for Quaternion<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sum<I: Iterator<Item=&'a Self>>(iter: I) -> Self {
|
fn sum<I: Iterator<Item=&'a Quaternion<S>>>(iter: I) -> Quaternion<S> {
|
||||||
iter.fold(Self::zero(), Add::add)
|
iter.fold(Quaternion::<S>::zero(), Add::add)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> iter::Product for Quaternion<S> {
|
impl<S: BaseFloat> iter::Product<Quaternion<S>> for Quaternion<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn product<I: Iterator<Item=Self>>(iter: I) -> Self {
|
fn product<I: Iterator<Item=Quaternion<S>>>(iter: I) -> Quaternion<S> {
|
||||||
iter.fold(Self::one(), Mul::mul)
|
iter.fold(Quaternion::<S>::one(), Mul::mul)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: 'a + BaseFloat> iter::Product<&'a Self> for Quaternion<S> {
|
impl<'a, S: 'a + BaseFloat> iter::Product<&'a Quaternion<S>> for Quaternion<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn product<I: Iterator<Item=&'a Self>>(iter: I) -> Self {
|
fn product<I: Iterator<Item=&'a Quaternion<S>>>(iter: I) -> Quaternion<S> {
|
||||||
iter.fold(Self::one(), Mul::mul)
|
iter.fold(Quaternion::<S>::one(), Mul::mul)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -159,17 +159,17 @@ impl<S: BaseFloat> From<Basis2<S>> for Matrix2<S> {
|
||||||
fn from(b: Basis2<S>) -> Matrix2<S> { b.mat }
|
fn from(b: Basis2<S>) -> Matrix2<S> { b.mat }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> iter::Product for Basis2<S> {
|
impl<S: BaseFloat> iter::Product<Basis2<S>> for Basis2<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn product<I: Iterator<Item=Self>>(iter: I) -> Self {
|
fn product<I: Iterator<Item=Basis2<S>>>(iter: I) -> Basis2<S> {
|
||||||
iter.fold(Basis2 { mat: Matrix2::identity() }, Mul::mul)
|
iter.fold(Basis2::one(), Mul::mul)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: 'a + BaseFloat> iter::Product<&'a Self> for Basis2<S> {
|
impl<'a, S: 'a + BaseFloat> iter::Product<&'a Basis2<S>> for Basis2<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn product<I: Iterator<Item=&'a Self>>(iter: I) -> Self {
|
fn product<I: Iterator<Item=&'a Basis2<S>>>(iter: I) -> Basis2<S> {
|
||||||
iter.fold(Basis2 { mat: Matrix2::identity() }, Mul::mul)
|
iter.fold(Basis2::one(), Mul::mul)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,17 +279,17 @@ impl<S: BaseFloat> From<Basis3<S>> for Quaternion<S> {
|
||||||
fn from(b: Basis3<S>) -> Quaternion<S> { b.mat.into() }
|
fn from(b: Basis3<S>) -> Quaternion<S> { b.mat.into() }
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseFloat> iter::Product for Basis3<S> {
|
impl<S: BaseFloat> iter::Product<Basis3<S>> for Basis3<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn product<I: Iterator<Item=Self>>(iter: I) -> Self {
|
fn product<I: Iterator<Item=Basis3<S>>>(iter: I) -> Basis3<S> {
|
||||||
iter.fold(Basis3 { mat: Matrix3::identity() }, Mul::mul)
|
iter.fold(Basis3::one(), Mul::mul)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: 'a + BaseFloat> iter::Product<&'a Self> for Basis3<S> {
|
impl<'a, S: 'a + BaseFloat> iter::Product<&'a Basis3<S>> for Basis3<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn product<I: Iterator<Item=&'a Self>>(iter: I) -> Self {
|
fn product<I: Iterator<Item=&'a Basis3<S>>>(iter: I) -> Basis3<S> {
|
||||||
iter.fold(Basis3 { mat: Matrix3::identity() }, Mul::mul)
|
iter.fold(Basis3::one(), Mul::mul)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,10 +154,10 @@ pub trait ElementWise<Rhs = Self> {
|
||||||
/// ```
|
/// ```
|
||||||
pub trait VectorSpace: Copy + Clone where
|
pub trait VectorSpace: Copy + Clone where
|
||||||
Self: Zero,
|
Self: Zero,
|
||||||
Self: iter::Sum<Self>,
|
|
||||||
|
|
||||||
Self: Add<Self, Output = Self>,
|
Self: Add<Self, Output = Self>,
|
||||||
Self: Sub<Self, Output = Self>,
|
Self: Sub<Self, Output = Self>,
|
||||||
|
Self: iter::Sum<Self>,
|
||||||
|
|
||||||
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
|
// FIXME: Ugly type signatures - blocked by rust-lang/rust#24092
|
||||||
Self: Mul<<Self as VectorSpace>::Scalar, Output = Self>,
|
Self: Mul<<Self as VectorSpace>::Scalar, Output = Self>,
|
||||||
|
@ -457,7 +457,7 @@ pub trait SquareMatrix where
|
||||||
Self::Scalar: BaseFloat,
|
Self::Scalar: BaseFloat,
|
||||||
|
|
||||||
Self: One,
|
Self: One,
|
||||||
Self: iter::Product,
|
Self: iter::Product<Self>,
|
||||||
|
|
||||||
Self: Matrix<
|
Self: Matrix<
|
||||||
// FIXME: Can be cleaned up once equality constraints in where clauses are implemented
|
// FIXME: Can be cleaned up once equality constraints in where clauses are implemented
|
||||||
|
@ -551,6 +551,8 @@ pub trait Angle where
|
||||||
Self: Mul<<Self as Angle>::Unitless, Output = Self>,
|
Self: Mul<<Self as Angle>::Unitless, Output = Self>,
|
||||||
Self: Div<Self, Output = <Self as Angle>::Unitless>,
|
Self: Div<Self, Output = <Self as Angle>::Unitless>,
|
||||||
Self: Div<<Self as Angle>::Unitless, Output = Self>,
|
Self: Div<<Self as Angle>::Unitless, Output = Self>,
|
||||||
|
|
||||||
|
Self: iter::Sum,
|
||||||
{
|
{
|
||||||
type Unitless: BaseFloat;
|
type Unitless: BaseFloat;
|
||||||
|
|
||||||
|
|
|
@ -164,17 +164,17 @@ macro_rules! impl_vector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<S: BaseNum> iter::Sum for $VectorN<S> {
|
impl<S: BaseNum> iter::Sum<$VectorN<S>> for $VectorN<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sum<I: Iterator<Item=Self>>(iter: I) -> Self {
|
fn sum<I: Iterator<Item=$VectorN<S>>>(iter: I) -> $VectorN<S> {
|
||||||
iter.fold(Self::zero(), Add::add)
|
iter.fold($VectorN::zero(), Add::add)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, S: 'a + BaseNum> iter::Sum<&'a Self> for $VectorN<S> {
|
impl<'a, S: 'a + BaseNum> iter::Sum<&'a $VectorN<S>> for $VectorN<S> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn sum<I: Iterator<Item=&'a Self>>(iter: I) -> Self {
|
fn sum<I: Iterator<Item=&'a $VectorN<S>>>(iter: I) -> $VectorN<S> {
|
||||||
iter.fold(Self::zero(), Add::add)
|
iter.fold($VectorN::zero(), Add::add)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ extern crate cgmath;
|
||||||
use cgmath::{Rad, Deg};
|
use cgmath::{Rad, Deg};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn conv() {
|
fn test_conv() {
|
||||||
let angle: Rad<_> = Deg(-5.0f64).into();
|
let angle: Rad<_> = Deg(-5.0f64).into();
|
||||||
let angle: Deg<_> = angle.into();
|
let angle: Deg<_> = angle.into();
|
||||||
assert_ulps_eq!(&angle, &Deg(-5.0f64));
|
assert_ulps_eq!(&angle, &Deg(-5.0f64));
|
||||||
|
@ -37,3 +37,23 @@ fn conv() {
|
||||||
let angle: Rad<_> = angle.into();
|
let angle: Rad<_> = angle.into();
|
||||||
assert_ulps_eq!(&angle, &Rad(30.0f64));
|
assert_ulps_eq!(&angle, &Rad(30.0f64));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod rad {
|
||||||
|
use cgmath::Rad;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_iter_sum() {
|
||||||
|
assert_eq!(Rad(2.0) + Rad(3.0) + Rad(4.0), [Rad(2.0), Rad(3.0), Rad(4.0)].iter().sum());
|
||||||
|
assert_eq!(Rad(2.0) + Rad(3.0) + Rad(4.0), [Rad(2.0), Rad(3.0), Rad(4.0)].iter().cloned().sum());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mod deg {
|
||||||
|
use cgmath::Deg;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_iter_sum() {
|
||||||
|
assert_eq!(Deg(2.0) + Deg(3.0) + Deg(4.0), [Deg(2.0), Deg(3.0), Deg(4.0)].iter().sum());
|
||||||
|
assert_eq!(Deg(2.0) + Deg(3.0) + Deg(4.0), [Deg(2.0), Deg(3.0), Deg(4.0)].iter().cloned().sum());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate approx;
|
extern crate approx;
|
||||||
#[macro_use]
|
|
||||||
extern crate cgmath;
|
extern crate cgmath;
|
||||||
|
|
||||||
pub mod matrix2 {
|
pub mod matrix2 {
|
||||||
|
@ -98,14 +97,14 @@ pub mod matrix2 {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sum_matrix() {
|
fn test_sum_matrix() {
|
||||||
let res: Matrix2<f64> = [A, B, C].iter().sum();
|
assert_eq!(A + B + C, [A, B, C].iter().sum());
|
||||||
assert_eq!(res, A + B + C);
|
assert_eq!(A + B + C, [A, B, C].iter().cloned().sum());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_product_matrix() {
|
fn test_product_matrix() {
|
||||||
let res: Matrix2<f64> = [A, B, C].iter().product();
|
assert_eq!(A * B * C, [A, B, C].iter().product());
|
||||||
assert_eq!(res, A * B * C);
|
assert_eq!(A * B * C, [A, B, C].iter().cloned().product());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -272,14 +271,14 @@ pub mod matrix3 {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sum_matrix() {
|
fn test_sum_matrix() {
|
||||||
let res: Matrix3<f64> = [A, B, C, D].iter().sum();
|
assert_eq!(A + B + C + D, [A, B, C, D].iter().sum());
|
||||||
assert_eq!(res, A + B + C + D);
|
assert_eq!(A + B + C + D, [A, B, C, D].iter().cloned().sum());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_product_matrix() {
|
fn test_product_matrix() {
|
||||||
let res: Matrix3<f64> = [A, B, C, D].iter().product();
|
assert_eq!(A * B * C * D, [A, B, C, D].iter().product());
|
||||||
assert_eq!(res, A * B * C * D);
|
assert_eq!(A * B * C * D, [A, B, C, D].iter().cloned().product());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -641,14 +640,14 @@ pub mod matrix4 {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sum_matrix() {
|
fn test_sum_matrix() {
|
||||||
let res: Matrix4<f64> = [A, B, C, D].iter().sum();
|
assert_eq!(A + B + C + D, [A, B, C, D].iter().sum());
|
||||||
assert_eq!(res, A + B + C + D);
|
assert_eq!(A + B + C + D, [A, B, C, D].iter().cloned().sum());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_product_matrix() {
|
fn test_product_matrix() {
|
||||||
let res: Matrix4<f64> = [A, B, C, D].iter().product();
|
assert_eq!(A * B * C * D, [A, B, C, D].iter().product());
|
||||||
assert_eq!(res, A * B * C * D);
|
assert_eq!(A * B * C * D, [A, B, C, D].iter().cloned().product());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate approx;
|
extern crate approx;
|
||||||
#[macro_use]
|
|
||||||
extern crate cgmath;
|
extern crate cgmath;
|
||||||
|
|
||||||
macro_rules! impl_test_mul {
|
macro_rules! impl_test_mul {
|
||||||
|
@ -53,14 +52,24 @@ mod operators {
|
||||||
impl_test_div!(2.0f32, Quaternion::from(Euler { x: Rad(1f32), y: Rad(1f32), z: Rad(1f32) }));
|
impl_test_div!(2.0f32, Quaternion::from(Euler { x: Rad(1f32), y: Rad(1f32), z: Rad(1f32) }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_iter_sum() {
|
||||||
|
let q1 = Quaternion::from(Euler { x: Rad(2f32), y: Rad(1f32), z: Rad(1f32) });
|
||||||
|
let q2 = Quaternion::from(Euler { x: Rad(1f32), y: Rad(2f32), z: Rad(1f32) });
|
||||||
|
let q3 = Quaternion::from(Euler { x: Rad(1f32), y: Rad(1f32), z: Rad(2f32) });
|
||||||
|
|
||||||
|
assert_eq!(q1 + q2 + q3, [q1, q2, q3].iter().sum());
|
||||||
|
assert_eq!(q1 + q2 + q3, [q1, q2, q3].iter().cloned().sum());
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iter_product() {
|
fn test_iter_product() {
|
||||||
let q1 = Quaternion::from(Euler { x: Rad(2f32), y: Rad(1f32), z: Rad(1f32) });
|
let q1 = Quaternion::from(Euler { x: Rad(2f32), y: Rad(1f32), z: Rad(1f32) });
|
||||||
let q2 = Quaternion::from(Euler { x: Rad(1f32), y: Rad(2f32), z: Rad(1f32) });
|
let q2 = Quaternion::from(Euler { x: Rad(1f32), y: Rad(2f32), z: Rad(1f32) });
|
||||||
let q3 = Quaternion::from(Euler { x: Rad(1f32), y: Rad(1f32), z: Rad(2f32) });
|
let q3 = Quaternion::from(Euler { x: Rad(1f32), y: Rad(1f32), z: Rad(2f32) });
|
||||||
|
|
||||||
let res: Quaternion<f32> = [q1, q2, q3].iter().product();
|
assert_eq!(q1 * q2 * q3, [q1, q2, q3].iter().product());
|
||||||
assert_eq!(res, q1 * q2 * q3);
|
assert_eq!(q1 * q2 * q3, [q1, q2, q3].iter().cloned().product());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate approx;
|
extern crate approx;
|
||||||
#[macro_use]
|
|
||||||
extern crate cgmath;
|
extern crate cgmath;
|
||||||
|
|
||||||
use cgmath::*;
|
use cgmath::*;
|
||||||
|
@ -90,9 +89,8 @@ macro_rules! impl_test_rem {
|
||||||
|
|
||||||
macro_rules! impl_test_iter_sum {
|
macro_rules! impl_test_iter_sum {
|
||||||
($VectorN:ident { $($field:ident),+ }, $ty:ty, $s:expr, $v:expr) => (
|
($VectorN:ident { $($field:ident),+ }, $ty:ty, $s:expr, $v:expr) => (
|
||||||
let res: $VectorN<$ty> = iter::repeat($v).take($s as usize).sum();
|
assert_eq!($VectorN::new($($v.$field * $s),+),
|
||||||
assert_eq!(res,
|
iter::repeat($v).take($s as usize).sum());
|
||||||
$VectorN::new($($v.$field * $s),+));
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate approx;
|
extern crate approx;
|
||||||
#[macro_use]
|
|
||||||
extern crate cgmath;
|
extern crate cgmath;
|
||||||
|
|
||||||
use cgmath::*;
|
use cgmath::*;
|
||||||
|
@ -168,7 +167,6 @@ mod test_magnitude {
|
||||||
assert_relative_eq!(a.sqrt_element_wide().recip_element_wide(), Vector4::new(1f32, 1f32/2f32, 1f32/3f32, 1f32/4f32), max_relative = 0.005f32);
|
assert_relative_eq!(a.sqrt_element_wide().recip_element_wide(), Vector4::new(1f32, 1f32/2f32, 1f32/3f32, 1f32/4f32), max_relative = 0.005f32);
|
||||||
assert_relative_eq!(a.rsqrt_element_wide(), Vector4::new(1f32, 1f32/2f32, 1f32/3f32, 1f32/4f32), max_relative= 0.005f32);
|
assert_relative_eq!(a.rsqrt_element_wide(), Vector4::new(1f32, 1f32/2f32, 1f32/3f32, 1f32/4f32), max_relative= 0.005f32);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue