From 59d5e6f53aaf52106cc71e17570a0be76e098552 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Mon, 21 Dec 2015 07:24:56 +1100 Subject: [PATCH 1/3] Implement most assignment operators --- .travis.yml | 2 +- Cargo.toml | 3 +++ src/angle.rs | 15 +++++++++++++++ src/lib.rs | 2 ++ src/macros.rs | 12 ++++++++++++ src/matrix.rs | 18 ++++++++++++++++++ src/point.rs | 14 ++++++++++++-- src/quaternion.rs | 12 ++++++++++++ src/vector.rs | 30 ++++++++++++++++++++++++++++++ 9 files changed, 105 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dcd2e3c..151ca2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ sudo: false language: rust rust: - # - nightly + - nightly - beta - stable diff --git a/Cargo.toml b/Cargo.toml index 46e91aa..416f953 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,9 @@ keywords = ["gamedev", "math", "matrix", "vector", "quaternion"] [lib] name = "cgmath" +[features] +unstable = [] + [dependencies.rustc-serialize] rustc_serialize = "0.3" diff --git a/src/angle.rs b/src/angle.rs index be6afc3..0858817 100644 --- a/src/angle.rs +++ b/src/angle.rs @@ -179,6 +179,15 @@ macro_rules! impl_angle { impl_operator!( Rem<$Angle > for $Angle { fn rem(lhs, rhs) -> $Angle { $Angle::new(lhs.s % rhs.s) } }); + impl_assignment_operator!( AddAssign<$Angle > for $Angle { + fn add_assign(&mut self, other) { self.s + other.s; } + }); + impl_assignment_operator!( SubAssign<$Angle > for $Angle { + fn sub_assign(&mut self, other) { self.s - other.s; } + }); + impl_assignment_operator!( RemAssign<$Angle > for $Angle { + fn rem_assign(&mut self, other) { self.s % other.s; } + }); impl_operator!( Mul for $Angle { fn mul(lhs, scalar) -> $Angle { $Angle::new(lhs.s * scalar) } @@ -186,6 +195,12 @@ macro_rules! impl_angle { impl_operator!( Div for $Angle { fn div(lhs, scalar) -> $Angle { $Angle::new(lhs.s / scalar) } }); + impl_assignment_operator!( MulAssign for $Angle { + fn mul_assign(&mut self, scalar) { self.s * scalar; } + }); + impl_assignment_operator!( DivAssign for $Angle { + fn div_assign(&mut self, scalar) { self.s / scalar; } + }); impl ApproxEq for $Angle { type Epsilon = S; diff --git a/src/lib.rs b/src/lib.rs index d957cd8..87b9e8d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -27,6 +27,8 @@ //! `look_at`, `from_angle`, `from_euler`, and `from_axis_angle` methods. //! These are provided for convenience. +#![cfg_attr(feature = "unstable", feature(augmented_assignments, op_assign_traits))] + extern crate num as rust_num; extern crate rustc_serialize; extern crate rand; diff --git a/src/macros.rs b/src/macros.rs index 2a468f7..ed2223a 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -97,6 +97,18 @@ macro_rules! impl_operator { }; } +macro_rules! impl_assignment_operator { + (<$S:ident: $Constraint:ident> $Op:ident<$Rhs:ty> for $Lhs:ty { + fn $op:ident(&mut $lhs:ident, $rhs:ident) $body:block + }) => { + #[cfg(feature = "unstable")] + impl<$S: $Constraint + $Op<$S>> $Op<$Rhs> for $Lhs { + #[inline] + fn $op(&mut $lhs, $rhs: $Rhs) $body + } + }; +} + macro_rules! fold_array { (&$method:ident, { $x:expr, $y:expr }) => { $x.$method(&$y) }; (&$method:ident, { $x:expr, $y:expr, $z:expr }) => { $x.$method(&$y).$method(&$z) }; diff --git a/src/matrix.rs b/src/matrix.rs index 8970614..dbff62d 100644 --- a/src/matrix.rs +++ b/src/matrix.rs @@ -266,6 +266,7 @@ pub trait Matrix where Self: Add, Self: Sub, + Self: Neg, Self: Mul<::Element, Output = Self>, Self: Div<::Element, Output = Self>, @@ -830,6 +831,15 @@ macro_rules! impl_operators { impl_operator!( Rem for $MatrixN { fn rem(matrix, scalar) -> $MatrixN { $MatrixN { $($field: matrix.$field % scalar),+ } } }); + impl_assignment_operator!( MulAssign for $MatrixN { + fn mul_assign(&mut self, scalar) { $(self.$field *= scalar);+ } + }); + impl_assignment_operator!( DivAssign for $MatrixN { + fn div_assign(&mut self, scalar) { $(self.$field /= scalar);+ } + }); + impl_assignment_operator!( RemAssign for $MatrixN { + fn rem_assign(&mut self, scalar) { $(self.$field %= scalar);+ } + }); impl_operator!( Add<$MatrixN > for $MatrixN { fn add(lhs, rhs) -> $MatrixN { $MatrixN { $($field: lhs.$field + rhs.$field),+ } } @@ -837,6 +847,14 @@ macro_rules! impl_operators { impl_operator!( Sub<$MatrixN > for $MatrixN { fn sub(lhs, rhs) -> $MatrixN { $MatrixN { $($field: lhs.$field - rhs.$field),+ } } }); + #[cfg(feature = "unstable")] + impl> AddAssign<$MatrixN> for $MatrixN { + fn add_assign(&mut self, other: $MatrixN) { $(self.$field += other.$field);+ } + } + #[cfg(feature = "unstable")] + impl> SubAssign<$MatrixN> for $MatrixN { + fn sub_assign(&mut self, other: $MatrixN) { $(self.$field -= other.$field);+ } + } impl_operator!( Mul<$VectorN > for $MatrixN { fn mul(matrix, vector) -> $VectorN { $VectorN::new($(matrix.row($row_index).dot(vector.clone())),+) } diff --git a/src/point.rs b/src/point.rs index 419864f..1acd820 100644 --- a/src/point.rs +++ b/src/point.rs @@ -145,6 +145,9 @@ macro_rules! impl_point { impl_operator!( Add<$VectorN > for $PointN { fn add(lhs, rhs) -> $PointN { $PointN::new($(lhs.$field + rhs.$field),+) } }); + impl_assignment_operator!( AddAssign<$VectorN > for $PointN { + fn add_assign(&mut self, vector) { $(self.$field += vector.$field);+ } + }); impl_operator!( Sub<$PointN > for $PointN { fn sub(lhs, rhs) -> $VectorN { $VectorN::new($(lhs.$field - rhs.$field),+) } @@ -153,14 +156,21 @@ macro_rules! impl_point { impl_operator!( Mul for $PointN { fn mul(point, scalar) -> $PointN { $PointN::new($(point.$field * scalar),+) } }); - impl_operator!( Div for $PointN { fn div(point, scalar) -> $PointN { $PointN::new($(point.$field / scalar),+) } }); - impl_operator!( Rem for $PointN { fn rem(point, scalar) -> $PointN { $PointN::new($(point.$field % scalar),+) } }); + impl_assignment_operator!( MulAssign for $PointN { + fn mul_assign(&mut self, scalar) { $(self.$field *= scalar);+ } + }); + impl_assignment_operator!( DivAssign for $PointN { + fn div_assign(&mut self, scalar) { $(self.$field /= scalar);+ } + }); + impl_assignment_operator!( RemAssign for $PointN { + fn rem_assign(&mut self, scalar) { $(self.$field %= scalar);+ } + }); impl_index_operators!($PointN, $n, S, usize); impl_index_operators!($PointN, $n, [S], Range); diff --git a/src/quaternion.rs b/src/quaternion.rs index 54e2630..2c895d9 100644 --- a/src/quaternion.rs +++ b/src/quaternion.rs @@ -119,12 +119,18 @@ impl_operator!( Mul for Quaternion { Quaternion::from_sv(lhs.s * rhs, lhs.v * rhs) } }); +impl_assignment_operator!( MulAssign for Quaternion { + fn mul_assign(&mut self, scalar) { self.s *= scalar; self.v *= scalar; } +}); impl_operator!( Div for Quaternion { fn div(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s / rhs, lhs.v / rhs) } }); +impl_assignment_operator!( DivAssign for Quaternion { + fn div_assign(&mut self, scalar) { self.s /= scalar; self.v /= scalar; } +}); impl_operator!( Mul > for Quaternion { fn mul(lhs, rhs) -> Vector3 {{ @@ -140,12 +146,18 @@ impl_operator!( Add > for Quaternion { Quaternion::from_sv(lhs.s + rhs.s, lhs.v + rhs.v) } }); +impl_assignment_operator!( AddAssign > for Quaternion { + fn add_assign(&mut self, other) { self.s += other.s; self.v += other.v; } +}); impl_operator!( Sub > for Quaternion { fn sub(lhs, rhs) -> Quaternion { Quaternion::from_sv(lhs.s - rhs.s, lhs.v - rhs.v) } }); +impl_assignment_operator!( SubAssign > for Quaternion { + fn sub_assign(&mut self, other) { self.s -= other.s; self.v -= other.v; } +}); impl_operator!( Mul > for Quaternion { fn mul(lhs, rhs) -> Quaternion { diff --git a/src/vector.rs b/src/vector.rs index 6cf2c5d..8d287a3 100644 --- a/src/vector.rs +++ b/src/vector.rs @@ -218,6 +218,12 @@ macro_rules! impl_vector { impl_operator!( Add<$VectorN > for $VectorN { fn add(lhs, rhs) -> $VectorN { $VectorN::new($(lhs.$field + rhs.$field),+) } }); + impl_assignment_operator!( AddAssign for $VectorN { + fn add_assign(&mut self, scalar) { $(self.$field += scalar);+ } + }); + impl_assignment_operator!( AddAssign<$VectorN > for $VectorN { + fn add_assign(&mut self, other) { $(self.$field += other.$field);+ } + }); impl_operator!( Sub for $VectorN { fn sub(vector, scalar) -> $VectorN { $VectorN::new($(vector.$field - scalar),+) } @@ -225,6 +231,12 @@ macro_rules! impl_vector { impl_operator!( Sub<$VectorN > for $VectorN { fn sub(lhs, rhs) -> $VectorN { $VectorN::new($(lhs.$field - rhs.$field),+) } }); + impl_assignment_operator!( SubAssign for $VectorN { + fn sub_assign(&mut self, scalar) { $(self.$field -= scalar);+ } + }); + impl_assignment_operator!( SubAssign<$VectorN > for $VectorN { + fn sub_assign(&mut self, other) { $(self.$field -= other.$field);+ } + }); impl_operator!( Mul for $VectorN { fn mul(vector, scalar) -> $VectorN { $VectorN::new($(vector.$field * scalar),+) } @@ -232,6 +244,12 @@ macro_rules! impl_vector { impl_operator!( Mul<$VectorN > for $VectorN { fn mul(lhs, rhs) -> $VectorN { $VectorN::new($(lhs.$field * rhs.$field),+) } }); + impl_assignment_operator!( MulAssign for $VectorN { + fn mul_assign(&mut self, scalar) { $(self.$field *= scalar);+ } + }); + impl_assignment_operator!( MulAssign<$VectorN > for $VectorN { + fn mul_assign(&mut self, other) { $(self.$field *= other.$field);+ } + }); impl_operator!( Div for $VectorN { fn div(vector, scalar) -> $VectorN { $VectorN::new($(vector.$field / scalar),+) } @@ -239,6 +257,12 @@ macro_rules! impl_vector { impl_operator!( Div<$VectorN > for $VectorN { fn div(lhs, rhs) -> $VectorN { $VectorN::new($(lhs.$field / rhs.$field),+) } }); + impl_assignment_operator!( DivAssign for $VectorN { + fn div_assign(&mut self, scalar) { $(self.$field /= scalar);+ } + }); + impl_assignment_operator!( DivAssign<$VectorN > for $VectorN { + fn div_assign(&mut self, other) { $(self.$field /= other.$field);+ } + }); impl_operator!( Rem for $VectorN { fn rem(vector, scalar) -> $VectorN { $VectorN::new($(vector.$field % scalar),+) } @@ -246,6 +270,12 @@ macro_rules! impl_vector { impl_operator!( Rem<$VectorN > for $VectorN { fn rem(lhs, rhs) -> $VectorN { $VectorN::new($(lhs.$field % rhs.$field),+) } }); + impl_assignment_operator!( RemAssign for $VectorN { + fn rem_assign(&mut self, scalar) { $(self.$field %= scalar);+ } + }); + impl_assignment_operator!( RemAssign<$VectorN > for $VectorN { + fn rem_assign(&mut self, other) { $(self.$field %= other.$field);+ } + }); impl_index_operators!($VectorN, $n, S, usize); impl_index_operators!($VectorN, $n, [S], Range); From ef34770a4baedee0a43ccb963bff9f5b97d5b3a7 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 22 Dec 2015 22:37:56 +1100 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb8e4f8..3111e9d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). parameters. - Weaken type constraints on `perspective` function to take an `Into>`. - Add `Angle::new` for constructing angles from a unitless scalar. +- Implement assignment operators for nightly builds, enabled by the `"unstable"` + feature. ### Changed - `Vector`, `Matrix`, `Point`, and `Angle` are now constrained to require @@ -44,9 +46,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). `Vector::from_value(1.0)`. - Remove operator methods from `Vector`, `Matrix`, `Point`, and `Angle` traits in favor of operator overloading. -- Remove `*_self` methods from `Vector`, `Matrix`, `Point`, and `Angle`. These - were of little performance benefit, and assignment operator overloading will - be coming soon! +- Remove `*_self` methods from `Vector`, `Matrix`, `Point`, and `Angle`. The + operator methods can be used via the unstable assignment operators. - Remove `#[derive(Hash)]` from `Deg` and `Rad`. This could never really be used these types, because they expect to be given a `BaseFloat` under normal circumstances. From 4c8fc61e230ab6e848ee40d9f93c76904d085666 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Tue, 22 Dec 2015 22:55:59 +1100 Subject: [PATCH 3/3] Fix benchmarks --- benches/common/macros.rs | 41 ++++++++------------------------ benches/construction.rs | 2 +- benches/mat.rs | 38 +++++++++++++++--------------- benches/quat.rs | 14 ++++++----- benches/vec.rs | 50 +++++++++++++++++++++------------------- 5 files changed, 64 insertions(+), 81 deletions(-) diff --git a/benches/common/macros.rs b/benches/common/macros.rs index 84f6bc2..54eac6d 100644 --- a/benches/common/macros.rs +++ b/benches/common/macros.rs @@ -13,30 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -macro_rules! bench_binop( - ($name: ident, $t1: ty, $t2: ty, $binop: ident) => { - #[bench] - fn $name(bh: &mut Bencher) { - const LEN: usize = 1 << 13; - - let mut rng = IsaacRng::new_unseeded(); - - let elems1: Vec<$t1> = (0..LEN).map(|_| rng.gen::<$t1>()).collect(); - let elems2: Vec<$t2> = (0..LEN).map(|_| rng.gen::<$t2>()).collect(); - let mut i = 0; - - bh.iter(|| { - i = (i + 1) & (LEN - 1); - - unsafe { - test::black_box(elems1.get_unchecked(i).$binop(elems2.get_unchecked(i))) - } - }) - } - } -); - -macro_rules! bench_binop_deref( +macro_rules! bench_binop { ($name: ident, $t1: ty, $t2: ty, $binop: ident) => { #[bench] fn $name(bh: &mut Bencher) { @@ -56,10 +33,10 @@ macro_rules! bench_binop_deref( } }) } - } -); + }; +} -macro_rules! bench_unop( +macro_rules! bench_unop { ($name: ident, $t: ty, $unop: ident) => { #[bench] fn $name(bh: &mut Bencher) { @@ -78,10 +55,10 @@ macro_rules! bench_unop( } }) } - } -); + }; +} -macro_rules! bench_construction( +macro_rules! bench_construction { ($name: ident, $t: ty, $constructor: path [ $($args: ident: $types: ty),+ ]) => { #[bench] fn $name(bh: &mut Bencher) { @@ -101,5 +78,5 @@ macro_rules! bench_construction( } }) } - } -); + }; +} diff --git a/benches/construction.rs b/benches/construction.rs index c0ed7c9..c49c08d 100644 --- a/benches/construction.rs +++ b/benches/construction.rs @@ -39,7 +39,7 @@ fn bench_from_axis_angle>(bh: &mut Bencher) { i = (i + 1) & (LEN - 1); unsafe { - let res: T = Rotation3::from_axis_angle(axis.get_unchecked(i), *angle.get_unchecked(i)); + let res: T = Rotation3::from_axis_angle(*axis.get_unchecked(i), *angle.get_unchecked(i)); test::black_box(res) } }) diff --git a/benches/mat.rs b/benches/mat.rs index 225b98d..f472be2 100644 --- a/benches/mat.rs +++ b/benches/mat.rs @@ -20,35 +20,37 @@ extern crate test; extern crate cgmath; use rand::{IsaacRng, Rng}; +use std::ops::*; use test::Bencher; + use cgmath::*; #[path="common/macros.rs"] #[macro_use] mod macros; -bench_binop!(_bench_matrix2_mul_m, Matrix2, Matrix2, mul_m); -bench_binop!(_bench_matrix3_mul_m, Matrix3, Matrix3, mul_m); -bench_binop!(_bench_matrix4_mul_m, Matrix4, Matrix4, mul_m); +bench_binop!(_bench_matrix2_mul_m, Matrix2, Matrix2, mul); +bench_binop!(_bench_matrix3_mul_m, Matrix3, Matrix3, mul); +bench_binop!(_bench_matrix4_mul_m, Matrix4, Matrix4, mul); -bench_binop!(_bench_matrix2_add_m, Matrix2, Matrix2, add_m); -bench_binop!(_bench_matrix3_add_m, Matrix3, Matrix3, add_m); -bench_binop!(_bench_matrix4_add_m, Matrix4, Matrix4, add_m); +bench_binop!(_bench_matrix2_add_m, Matrix2, Matrix2, add); +bench_binop!(_bench_matrix3_add_m, Matrix3, Matrix3, add); +bench_binop!(_bench_matrix4_add_m, Matrix4, Matrix4, add); -bench_binop!(_bench_matrix2_sub_m, Matrix2, Matrix2, sub_m); -bench_binop!(_bench_matrix3_sub_m, Matrix3, Matrix3, sub_m); -bench_binop!(_bench_matrix4_sub_m, Matrix4, Matrix4, sub_m); +bench_binop!(_bench_matrix2_sub_m, Matrix2, Matrix2, sub); +bench_binop!(_bench_matrix3_sub_m, Matrix3, Matrix3, sub); +bench_binop!(_bench_matrix4_sub_m, Matrix4, Matrix4, sub); -bench_binop!(_bench_matrix2_mul_v, Matrix2, Vector2, mul_v); -bench_binop!(_bench_matrix3_mul_v, Matrix3, Vector3, mul_v); -bench_binop!(_bench_matrix4_mul_v, Matrix4, Vector4, mul_v); +bench_binop!(_bench_matrix2_mul_v, Matrix2, Vector2, mul); +bench_binop!(_bench_matrix3_mul_v, Matrix3, Vector3, mul); +bench_binop!(_bench_matrix4_mul_v, Matrix4, Vector4, mul); -bench_binop_deref!(_bench_matrix2_mul_s, Matrix2, f32, mul_s); -bench_binop_deref!(_bench_matrix3_mul_s, Matrix3, f32, mul_s); -bench_binop_deref!(_bench_matrix4_mul_s, Matrix4, f32, mul_s); +bench_binop!(_bench_matrix2_mul_s, Matrix2, f32, mul); +bench_binop!(_bench_matrix3_mul_s, Matrix3, f32, mul); +bench_binop!(_bench_matrix4_mul_s, Matrix4, f32, mul); -bench_binop_deref!(_bench_matrix2_div_s, Matrix2, f32, div_s); -bench_binop_deref!(_bench_matrix3_div_s, Matrix3, f32, div_s); -bench_binop_deref!(_bench_matrix4_div_s, Matrix4, f32, div_s); +bench_binop!(_bench_matrix2_div_s, Matrix2, f32, div); +bench_binop!(_bench_matrix3_div_s, Matrix3, f32, div); +bench_binop!(_bench_matrix4_div_s, Matrix4, f32, div); bench_unop!(_bench_matrix2_invert, Matrix2, invert); bench_unop!(_bench_matrix3_invert, Matrix3, invert); diff --git a/benches/quat.rs b/benches/quat.rs index 1993609..81b4f9e 100644 --- a/benches/quat.rs +++ b/benches/quat.rs @@ -20,18 +20,20 @@ extern crate test; extern crate cgmath; use rand::{IsaacRng, Rng}; +use std::ops::*; use test::Bencher; + use cgmath::*; #[path="common/macros.rs"] #[macro_use] mod macros; -bench_binop!(_bench_quat_add_q, Quaternion, Quaternion, add_q); -bench_binop!(_bench_quat_sub_q, Quaternion, Quaternion, sub_q); -bench_binop!(_bench_quat_mul_q, Quaternion, Quaternion, mul_q); -bench_binop!(_bench_quat_mul_v, Quaternion, Vector3, mul_v); -bench_binop_deref!(_bench_quat_mul_s, Quaternion, f32, mul_s); -bench_binop_deref!(_bench_quat_div_s, Quaternion, f32, div_s); +bench_binop!(_bench_quat_add_q, Quaternion, Quaternion, add); +bench_binop!(_bench_quat_sub_q, Quaternion, Quaternion, sub); +bench_binop!(_bench_quat_mul_q, Quaternion, Quaternion, mul); +bench_binop!(_bench_quat_mul_v, Quaternion, Vector3, mul); +bench_binop!(_bench_quat_mul_s, Quaternion, f32, mul); +bench_binop!(_bench_quat_div_s, Quaternion, f32, div); bench_unop!(_bench_quat_invert, Quaternion, invert); bench_unop!(_bench_quat_conjugate, Quaternion, conjugate); bench_unop!(_bench_quat_normalize, Quaternion, normalize); diff --git a/benches/vec.rs b/benches/vec.rs index 028fa30..d1739cf 100644 --- a/benches/vec.rs +++ b/benches/vec.rs @@ -20,43 +20,45 @@ extern crate test; extern crate cgmath; use rand::{IsaacRng, Rng}; +use std::ops::*; use test::Bencher; + use cgmath::*; #[path="common/macros.rs"] #[macro_use] mod macros; -bench_binop!(_bench_vector2_add_v, Vector2, Vector2, add_v); -bench_binop!(_bench_vector3_add_v, Vector3, Vector3, add_v); -bench_binop!(_bench_vector4_add_v, Vector4, Vector4, add_v); +bench_binop!(_bench_vector2_add_v, Vector2, Vector2, add); +bench_binop!(_bench_vector3_add_v, Vector3, Vector3, add); +bench_binop!(_bench_vector4_add_v, Vector4, Vector4, add); -bench_binop!(_bench_vector2_sub_v, Vector2, Vector2, sub_v); -bench_binop!(_bench_vector3_sub_v, Vector3, Vector3, sub_v); -bench_binop!(_bench_vector4_sub_v, Vector4, Vector4, sub_v); +bench_binop!(_bench_vector2_sub_v, Vector2, Vector2, sub); +bench_binop!(_bench_vector3_sub_v, Vector3, Vector3, sub); +bench_binop!(_bench_vector4_sub_v, Vector4, Vector4, sub); -bench_binop!(_bench_vector2_mul_v, Vector2, Vector2, mul_v); -bench_binop!(_bench_vector3_mul_v, Vector3, Vector3, mul_v); -bench_binop!(_bench_vector4_mul_v, Vector4, Vector4, mul_v); +bench_binop!(_bench_vector2_mul_v, Vector2, Vector2, mul); +bench_binop!(_bench_vector3_mul_v, Vector3, Vector3, mul); +bench_binop!(_bench_vector4_mul_v, Vector4, Vector4, mul); -bench_binop!(_bench_vector2_div_v, Vector2, Vector2, div_v); -bench_binop!(_bench_vector3_div_v, Vector3, Vector3, div_v); -bench_binop!(_bench_vector4_div_v, Vector4, Vector4, div_v); +bench_binop!(_bench_vector2_div_v, Vector2, Vector2, div); +bench_binop!(_bench_vector3_div_v, Vector3, Vector3, div); +bench_binop!(_bench_vector4_div_v, Vector4, Vector4, div); -bench_binop_deref!(_bench_vector2_add_s, Vector2, f32, add_s); -bench_binop_deref!(_bench_vector3_add_s, Vector3, f32, add_s); -bench_binop_deref!(_bench_vector4_add_s, Vector4, f32, add_s); +bench_binop!(_bench_vector2_add_s, Vector2, f32, add); +bench_binop!(_bench_vector3_add_s, Vector3, f32, add); +bench_binop!(_bench_vector4_add_s, Vector4, f32, add); -bench_binop_deref!(_bench_vector2_sub_s, Vector2, f32, sub_s); -bench_binop_deref!(_bench_vector3_sub_s, Vector3, f32, sub_s); -bench_binop_deref!(_bench_vector4_sub_s, Vector4, f32, sub_s); +bench_binop!(_bench_vector2_sub_s, Vector2, f32, sub); +bench_binop!(_bench_vector3_sub_s, Vector3, f32, sub); +bench_binop!(_bench_vector4_sub_s, Vector4, f32, sub); -bench_binop_deref!(_bench_vector2_mul_s, Vector2, f32, mul_s); -bench_binop_deref!(_bench_vector3_mul_s, Vector3, f32, mul_s); -bench_binop_deref!(_bench_vector4_mul_s, Vector4, f32, mul_s); +bench_binop!(_bench_vector2_mul_s, Vector2, f32, mul); +bench_binop!(_bench_vector3_mul_s, Vector3, f32, mul); +bench_binop!(_bench_vector4_mul_s, Vector4, f32, mul); -bench_binop_deref!(_bench_vector2_div_s, Vector2, f32, div_s); -bench_binop_deref!(_bench_vector3_div_s, Vector3, f32, div_s); -bench_binop_deref!(_bench_vector4_div_s, Vector4, f32, div_s); +bench_binop!(_bench_vector2_div_s, Vector2, f32, div); +bench_binop!(_bench_vector3_div_s, Vector3, f32, div); +bench_binop!(_bench_vector4_div_s, Vector4, f32, div); bench_binop!(_bench_vector2_dot, Vector2, Vector2, dot);