-
Notifications
You must be signed in to change notification settings - Fork 150
Open
Description
I am creating a library where I would like to abstract math over scalar (f32
) or packed SIMD types (f32x8
) as defined in RFC 2366.
For example, I would like to express:
fn kernel<F>(a: F, b: F) -> F
where
F: Float,
{
(a - b) * (a - b)
}
And then call either kernel(1.0, 2.0)
or kernel(f32x8::splat(1.0), f32x8::splat(2.0))
, depending on what data structure I am operating with.
As part of that I was looking into num-traits
, in particular I was about to create a num-packed
crate, that implements Num
& friends for RFC 2366 packed types.
The problem, however, is that many traits such as Integer
, Float
, Signed
, ... not only provide f(Self) -> Self
mathematical functions, but also f(Self) -> bool
utilities, such as is_even
or integer_decode
, which do not directly make sense anymore.
Two questions:
- Do you think it would be feasible to either split out these utility functions into separate traits, or generalize them to be compatible with packed types?
- More generally, does
num-packed
make sense as an addition tonum
, or am I on the wrong path?
goertzenator and IndigoLily
Metadata
Metadata
Assignees
Labels
No labels