You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, in my code, I implement the new type idiom to avoid unit-errors.
eg (simplified):
I have a type Metersf32, a type Secondsf32 and along the operations I implement is Div between the two which outputs MetersPerSecondf32.
My specific cases are:
I implement Div<Typef32> for Typedf32 with Output = f32. Here I want to divide one Array1 of Typedf32 by Typedf32 and I can use map to do it but I cannot use Array1's Div implementation.
cannot divide `ArrayBase<OwnedRepr<Typedf32>, Dim<[usize; 1]>>` by `Typedf32`
I implement Mul<f32> for Typedf32 with Output Typedf32, Add<Typedf32> for Typedf32 with Output = Typedf32 and AddAssign for Typedf32. Here I want to do dot product between the two. Again I need to use iter, zip, fold and implement my custom dot-product, and cannot use Array1's Dot implementation.
dot: method cannot be called due to unsatisfied trait bounds
pub struct ArrayBase<S, D>: doesn't satisfy `_: Dot<_>`
Are such use-cases supported and I am missing some trait implementations? eg. the above Div, Mul, Add traits for the references of my types too? Is such a thing even possible, or may be possible in the future?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello, in my code, I implement the new type idiom to avoid unit-errors.
eg (simplified):
I have a type
Metersf32
, a typeSecondsf32
and along the operations I implement isDiv
between the two which outputsMetersPerSecondf32
.My specific cases are:
Div<Typef32> for Typedf32
withOutput = f32
. Here I want to divide oneArray1
ofTypedf32
byTypedf32
and I can use map to do it but I cannot useArray1
's Div implementation.Mul<f32> for Typedf32
withOutput Typedf32
,Add<Typedf32> for Typedf32
withOutput = Typedf32
and AddAssign forTypedf32
. Here I want to do dot product between the two. Again I need to use iter, zip, fold and implement my custom dot-product, and cannot useArray1
's Dot implementation.Are such use-cases supported and I am missing some trait implementations? eg. the above
Div
,Mul
,Add
traits for the references of my types too? Is such a thing even possible, or may be possible in the future?Beta Was this translation helpful? Give feedback.
All reactions