From 5cb98ee29f21f7f78c16369625630f05fc1bebf7 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Mon, 2 Sep 2024 17:41:54 -0700 Subject: [PATCH] vectors: no traits --- fixed_wide_vectors/Cargo.lock | 21 +++++++++-------- fixed_wide_vectors/Cargo.toml | 9 +++----- .../src/macros/{wide.rs => fixed_wide.rs} | 0 fixed_wide_vectors/src/macros/mod.rs | 4 ++-- fixed_wide_vectors/src/macros/vector.rs | 2 +- .../{fixed_wide_traits.rs => fixed_wide.rs} | 23 ++++++++----------- fixed_wide_vectors/src/tests/mod.rs | 4 ++-- 7 files changed, 29 insertions(+), 34 deletions(-) rename fixed_wide_vectors/src/macros/{wide.rs => fixed_wide.rs} (100%) rename fixed_wide_vectors/src/tests/{fixed_wide_traits.rs => fixed_wide.rs} (79%) diff --git a/fixed_wide_vectors/Cargo.lock b/fixed_wide_vectors/Cargo.lock index a0a650c..5bb2156 100644 --- a/fixed_wide_vectors/Cargo.lock +++ b/fixed_wide_vectors/Cargo.lock @@ -2,6 +2,12 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + [[package]] name = "bnum" version = "0.11.0" @@ -12,25 +18,20 @@ checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790" name = "fixed_wide" version = "0.1.0" dependencies = [ + "arrayvec", "bnum", - "fixed_wide_traits", - "typenum", + "paste", ] -[[package]] -name = "fixed_wide_traits" -version = "0.1.0" - [[package]] name = "fixed_wide_vectors" version = "0.1.0" dependencies = [ "fixed_wide", - "fixed_wide_traits", ] [[package]] -name = "typenum" -version = "1.17.0" +name = "paste" +version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" diff --git a/fixed_wide_vectors/Cargo.toml b/fixed_wide_vectors/Cargo.toml index 55d64c0..a3dad29 100644 --- a/fixed_wide_vectors/Cargo.toml +++ b/fixed_wide_vectors/Cargo.toml @@ -4,11 +4,8 @@ version = "0.1.0" edition = "2021" [features] -default=["fixed_wide_traits"] -fixed_wide_traits=["dep:fixed_wide_traits"] +default=["fixed_wide"] +fixed_wide=["dep:fixed_wide"] [dependencies] -fixed_wide_traits = { version = "0.1.0", path = "../fixed_wide_traits", optional = true } - -[dev-dependencies] -fixed_wide = { version = "0.1.0", path = "../fixed_wide" } +fixed_wide = { version = "0.1.0", path = "../fixed_wide", optional = true } diff --git a/fixed_wide_vectors/src/macros/wide.rs b/fixed_wide_vectors/src/macros/fixed_wide.rs similarity index 100% rename from fixed_wide_vectors/src/macros/wide.rs rename to fixed_wide_vectors/src/macros/fixed_wide.rs diff --git a/fixed_wide_vectors/src/macros/mod.rs b/fixed_wide_vectors/src/macros/mod.rs index dff0bf0..9dfc914 100644 --- a/fixed_wide_vectors/src/macros/mod.rs +++ b/fixed_wide_vectors/src/macros/mod.rs @@ -1,5 +1,5 @@ -#[cfg(feature="fixed_wide_traits")] -pub mod wide; +#[cfg(feature="fixed_wide")] +pub mod fixed_wide; pub mod vector; pub mod matrix; diff --git a/fixed_wide_vectors/src/macros/vector.rs b/fixed_wide_vectors/src/macros/vector.rs index 3af837a..a68d0d7 100644 --- a/fixed_wide_vectors/src/macros/vector.rs +++ b/fixed_wide_vectors/src/macros/vector.rs @@ -242,7 +242,7 @@ macro_rules! impl_vector { $crate::impl_vector_operator!( $struct { $($field), + }, BitXor, bitxor, Self ); // Impl floating-point based methods - #[cfg(feature="fixed_wide_traits")] + #[cfg(feature="fixed_wide")] $crate::impl_wide_vector_operations!( $struct { $($field), + }, $size ); }; } diff --git a/fixed_wide_vectors/src/tests/fixed_wide_traits.rs b/fixed_wide_vectors/src/tests/fixed_wide.rs similarity index 79% rename from fixed_wide_vectors/src/tests/fixed_wide_traits.rs rename to fixed_wide_vectors/src/tests/fixed_wide.rs index 73a0a1b..99a72d6 100644 --- a/fixed_wide_vectors/src/tests/fixed_wide_traits.rs +++ b/fixed_wide_vectors/src/tests/fixed_wide.rs @@ -1,6 +1,3 @@ -use fixed_wide_traits::wide::WideMul; -use fixed_wide_traits::wide::WideDot; - use crate::{Vector2,Vector3,Matrix3}; type Planar64=fixed_wide::types::I32F32; @@ -11,9 +8,9 @@ type Planar64Wide3=fixed_wide::types::I256F256; #[test] fn wide_vec3(){ let v=Vector3::from_value(Planar64::from(3)); - let v1=v.wide_mul(v); - let v2=v1.wide_mul(v1); - let v3=v2.wide_mul(v2); + let v1=v.wide_mul_1_1(v); + let v2=v1.wide_mul_2_2(v1); + let v3=v2.wide_mul_4_4(v2); assert_eq!(v3,Vector3::from_value(Planar64Wide3::from(3i128.pow(8)))); } @@ -21,9 +18,9 @@ fn wide_vec3(){ #[test] fn wide_vec3_dot(){ let v=Vector3::from_value(Planar64::from(3)); - let v1=v.wide_mul(v); - let v2=v1.wide_mul(v1); - let v3=v2.wide_dot(v2); + let v1=v.wide_mul_1_1(v); + let v2=v1.wide_mul_2_2(v1); + let v3=v2.wide_dot_4_4(v2); assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3)); } @@ -31,8 +28,8 @@ fn wide_vec3_dot(){ #[test] fn wide_vec3_length_squared(){ let v=Vector3::from_value(Planar64::from(3)); - let v1=v.wide_mul(v); - let v2=v1.wide_mul(v1); + let v1=v.wide_mul_1_1(v); + let v2=v1.wide_mul_2_2(v1); let v3=v2.wide_length_squared(); assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3)); @@ -43,7 +40,7 @@ fn wide_vec_of_vec_dot(){ let vv=Vector3::>::from_value_2d(Planar64::from(3)); // do the dot product of the inner vectors multiplied component wise // this lowers the rank of the data structure and is kind of a weird operation lol - let vv_dot=vv.wide_dot(vv); + let vv_dot=vv.wide_dot_1_1(vv); assert_eq!(vv_dot,Vector2::from_value(Planar64Wide1::from(3i128.pow(3)))); } #[test] @@ -51,6 +48,6 @@ fn wide_matrix_dot(){ let m=Matrix3::>::from_value_2d(Planar64::from(3)); //normal matrix product todo!() - //let m_dot=m.wide_dot(m); + //let m_dot=m.wide_dot_1_1(m); //assert_eq!(m_dot,Matrix3::>::from_value_2d(Planar64Wide1::from(3i128.pow(2)))); } diff --git a/fixed_wide_vectors/src/tests/mod.rs b/fixed_wide_vectors/src/tests/mod.rs index 36de35f..67fb0b3 100644 --- a/fixed_wide_vectors/src/tests/mod.rs +++ b/fixed_wide_vectors/src/tests/mod.rs @@ -1,5 +1,5 @@ mod tests; -#[cfg(feature="fixed_wide_traits")] -mod fixed_wide_traits; +#[cfg(feature="fixed_wide")] +mod fixed_wide;