wip fixed wide
This commit is contained in:
parent
e375173625
commit
41cdd03b1b
1
fixed_wide_vectors/Cargo.lock
generated
1
fixed_wide_vectors/Cargo.lock
generated
@ -28,6 +28,7 @@ name = "fixed_wide_vectors"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fixed_wide",
|
"fixed_wide",
|
||||||
|
"paste",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -6,7 +6,8 @@ edition = "2021"
|
|||||||
[features]
|
[features]
|
||||||
default=["fixed_wide","named-fields"]
|
default=["fixed_wide","named-fields"]
|
||||||
named-fields=[]
|
named-fields=[]
|
||||||
fixed_wide=["dep:fixed_wide"]
|
fixed_wide=["dep:fixed_wide","dep:paste"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
fixed_wide = { version = "0.1.0", path = "../fixed_wide", optional = true }
|
fixed_wide = { version = "0.1.0", path = "../fixed_wide", optional = true }
|
||||||
|
paste = { version = "1.0.15", optional = true }
|
||||||
|
@ -1 +1,36 @@
|
|||||||
|
#[doc(hidden)]
|
||||||
|
#[macro_export(local_inner_macros)]
|
||||||
|
macro_rules! impl_wide_vector_operations_2arg_not_const_generic {
|
||||||
|
(
|
||||||
|
($lhs:expr, $rhs:expr)
|
||||||
|
) => {
|
||||||
|
impl<const N:usize> Vector<N,fixed_wide::fixed::Fixed<{$lhs},{$lhs*32}>>{
|
||||||
|
paste::item!{
|
||||||
|
#[inline]
|
||||||
|
pub fn [<wide_mul_ $lhs _ $rhs>](self,rhs:Vector<N,fixed_wide::fixed::Fixed<{$rhs},{$rhs*32}>>)->Vector<N,fixed_wide::fixed::Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>>{
|
||||||
|
self.array.map_zip(|(a,b)|a.[<wide_mul_ $lhs _ $rhs>](b))
|
||||||
|
}
|
||||||
|
#[inline]
|
||||||
|
pub fn [<wide_dot_ $lhs _ $rhs>](self,rhs:Vector<N,fixed_wide::fixed::Fixed<{$rhs},{$rhs*32}>>)->fixed_wide::fixed::Fixed<{$lhs+$rhs},{($lhs+$rhs)*32}>{
|
||||||
|
self.array.into_iter().zip(rhs.array).map(|(a,b)|a.[<wide_mul_ $lhs _ $rhs>](b)).sum()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[doc(hidden)]
|
||||||
|
#[macro_export(local_inner_macros)]
|
||||||
|
macro_rules! impl_wide_vector_operations_1arg_not_const_generic {
|
||||||
|
(
|
||||||
|
$n:expr
|
||||||
|
) => {
|
||||||
|
impl $struct<fixed_wide::fixed::Fixed<{$n},{$n*32}>>{
|
||||||
|
paste::item!{
|
||||||
|
#[inline]
|
||||||
|
pub fn wide_length_squared(&self)->fixed_wide::fixed::Fixed<{$n*2},{$n*2*32}>{
|
||||||
|
self.array.into_iter().map(|t|t.[<wide_mul_ $n _ $n>](t)).sum()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user