haar_lib/algebra/
affine.rs1pub use crate::algebra::traits::*;
3pub use crate::num::one_zero::*;
4use std::ops::{Add, Mul};
5
6#[derive(Clone, Copy, Default, Debug, PartialEq, Eq)]
8pub struct Affine<T>(pub T, pub T);
9
10impl<T> Set for Affine<T> {}
11
12impl<T: Add<Output = T> + Mul<Output = T> + Copy> BinaryOp for Affine<T> {
13 fn op(self, b: Self) -> Self {
14 Self(self.0 * b.0, self.0 * b.1 + self.1)
15 }
16}
17
18impl<T: One + Zero + Copy> Identity for Affine<T> {
19 fn id() -> Self {
20 Self(T::one(), T::zero())
21 }
22}
23
24impl<T> Associative for Affine<T> {}