vectors: no traits
This commit is contained in:
parent
bc29cd9848
commit
5cb98ee29f
21
fixed_wide_vectors/Cargo.lock
generated
21
fixed_wide_vectors/Cargo.lock
generated
@ -2,6 +2,12 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "arrayvec"
|
||||||
|
version = "0.7.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bnum"
|
name = "bnum"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
@ -12,25 +18,20 @@ checksum = "3e31ea183f6ee62ac8b8a8cf7feddd766317adfb13ff469de57ce033efd6a790"
|
|||||||
name = "fixed_wide"
|
name = "fixed_wide"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"arrayvec",
|
||||||
"bnum",
|
"bnum",
|
||||||
"fixed_wide_traits",
|
"paste",
|
||||||
"typenum",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fixed_wide_traits"
|
|
||||||
version = "0.1.0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fixed_wide_vectors"
|
name = "fixed_wide_vectors"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fixed_wide",
|
"fixed_wide",
|
||||||
"fixed_wide_traits",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "typenum"
|
name = "paste"
|
||||||
version = "1.17.0"
|
version = "1.0.15"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||||
|
@ -4,11 +4,8 @@ version = "0.1.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default=["fixed_wide_traits"]
|
default=["fixed_wide"]
|
||||||
fixed_wide_traits=["dep:fixed_wide_traits"]
|
fixed_wide=["dep:fixed_wide"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fixed_wide_traits = { version = "0.1.0", path = "../fixed_wide_traits", optional = true }
|
fixed_wide = { version = "0.1.0", path = "../fixed_wide", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
fixed_wide = { version = "0.1.0", path = "../fixed_wide" }
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#[cfg(feature="fixed_wide_traits")]
|
#[cfg(feature="fixed_wide")]
|
||||||
pub mod wide;
|
pub mod fixed_wide;
|
||||||
|
|
||||||
pub mod vector;
|
pub mod vector;
|
||||||
pub mod matrix;
|
pub mod matrix;
|
||||||
|
@ -242,7 +242,7 @@ macro_rules! impl_vector {
|
|||||||
$crate::impl_vector_operator!( $struct { $($field), + }, BitXor, bitxor, Self );
|
$crate::impl_vector_operator!( $struct { $($field), + }, BitXor, bitxor, Self );
|
||||||
|
|
||||||
// Impl floating-point based methods
|
// Impl floating-point based methods
|
||||||
#[cfg(feature="fixed_wide_traits")]
|
#[cfg(feature="fixed_wide")]
|
||||||
$crate::impl_wide_vector_operations!( $struct { $($field), + }, $size );
|
$crate::impl_wide_vector_operations!( $struct { $($field), + }, $size );
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
use fixed_wide_traits::wide::WideMul;
|
|
||||||
use fixed_wide_traits::wide::WideDot;
|
|
||||||
|
|
||||||
use crate::{Vector2,Vector3,Matrix3};
|
use crate::{Vector2,Vector3,Matrix3};
|
||||||
|
|
||||||
type Planar64=fixed_wide::types::I32F32;
|
type Planar64=fixed_wide::types::I32F32;
|
||||||
@ -11,9 +8,9 @@ type Planar64Wide3=fixed_wide::types::I256F256;
|
|||||||
#[test]
|
#[test]
|
||||||
fn wide_vec3(){
|
fn wide_vec3(){
|
||||||
let v=Vector3::from_value(Planar64::from(3));
|
let v=Vector3::from_value(Planar64::from(3));
|
||||||
let v1=v.wide_mul(v);
|
let v1=v.wide_mul_1_1(v);
|
||||||
let v2=v1.wide_mul(v1);
|
let v2=v1.wide_mul_2_2(v1);
|
||||||
let v3=v2.wide_mul(v2);
|
let v3=v2.wide_mul_4_4(v2);
|
||||||
|
|
||||||
assert_eq!(v3,Vector3::from_value(Planar64Wide3::from(3i128.pow(8))));
|
assert_eq!(v3,Vector3::from_value(Planar64Wide3::from(3i128.pow(8))));
|
||||||
}
|
}
|
||||||
@ -21,9 +18,9 @@ fn wide_vec3(){
|
|||||||
#[test]
|
#[test]
|
||||||
fn wide_vec3_dot(){
|
fn wide_vec3_dot(){
|
||||||
let v=Vector3::from_value(Planar64::from(3));
|
let v=Vector3::from_value(Planar64::from(3));
|
||||||
let v1=v.wide_mul(v);
|
let v1=v.wide_mul_1_1(v);
|
||||||
let v2=v1.wide_mul(v1);
|
let v2=v1.wide_mul_2_2(v1);
|
||||||
let v3=v2.wide_dot(v2);
|
let v3=v2.wide_dot_4_4(v2);
|
||||||
|
|
||||||
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
||||||
}
|
}
|
||||||
@ -31,8 +28,8 @@ fn wide_vec3_dot(){
|
|||||||
#[test]
|
#[test]
|
||||||
fn wide_vec3_length_squared(){
|
fn wide_vec3_length_squared(){
|
||||||
let v=Vector3::from_value(Planar64::from(3));
|
let v=Vector3::from_value(Planar64::from(3));
|
||||||
let v1=v.wide_mul(v);
|
let v1=v.wide_mul_1_1(v);
|
||||||
let v2=v1.wide_mul(v1);
|
let v2=v1.wide_mul_2_2(v1);
|
||||||
let v3=v2.wide_length_squared();
|
let v3=v2.wide_length_squared();
|
||||||
|
|
||||||
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
assert_eq!(v3,Planar64Wide3::from(3i128.pow(8)*3));
|
||||||
@ -43,7 +40,7 @@ fn wide_vec_of_vec_dot(){
|
|||||||
let vv=Vector3::<Vector2<_>>::from_value_2d(Planar64::from(3));
|
let vv=Vector3::<Vector2<_>>::from_value_2d(Planar64::from(3));
|
||||||
// do the dot product of the inner vectors multiplied component wise
|
// 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
|
// 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))));
|
assert_eq!(vv_dot,Vector2::from_value(Planar64Wide1::from(3i128.pow(3))));
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
@ -51,6 +48,6 @@ fn wide_matrix_dot(){
|
|||||||
let m=Matrix3::<Vector3<_>>::from_value_2d(Planar64::from(3));
|
let m=Matrix3::<Vector3<_>>::from_value_2d(Planar64::from(3));
|
||||||
//normal matrix product
|
//normal matrix product
|
||||||
todo!()
|
todo!()
|
||||||
//let m_dot=m.wide_dot(m);
|
//let m_dot=m.wide_dot_1_1(m);
|
||||||
//assert_eq!(m_dot,Matrix3::<Vector3<_>>::from_value_2d(Planar64Wide1::from(3i128.pow(2))));
|
//assert_eq!(m_dot,Matrix3::<Vector3<_>>::from_value_2d(Planar64Wide1::from(3i128.pow(2))));
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
mod tests;
|
mod tests;
|
||||||
|
|
||||||
|
|
||||||
#[cfg(feature="fixed_wide_traits")]
|
#[cfg(feature="fixed_wide")]
|
||||||
mod fixed_wide_traits;
|
mod fixed_wide;
|
||||||
|
Loading…
Reference in New Issue
Block a user