Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Monoid action \(f: x \rightarrow ax + b\).
- Use
Mat2x2
if inverse operations are required, or if it's necessary to store the monoid length in the acted monoid (V2
).
Since: 1.0.0.0
Affine1
Monoid action \(f: x \rightarrow ax + b\).
- Use
Mat2x2
if inverse operations are required, or if it's necessary to store the monoid length in the acted monoid (V2
).
Composition and dual
The affine transformation acts as a left monoid action: \(f_2 (f_1 v) = (f_2 \circ f_1) v\). To
apply the leftmost transformation first in a segment tree, wrap Affine1
in Data.Monoid.Dual
.
Example
>>>
import AtCoder.Extra.Monoid (SegAct(..), Affine1(..))
>>>
import AtCoder.LazySegTree qualified as LST
>>>
seg <- LST.build @_ @(Affine1 Int) @(Sum Int) $ VU.generate 3 Sum -- [0, 1, 2]
>>>
LST.applyIn seg 0 3 $ Affine1 (2, 1) -- [1, 3, 5]
>>>
getSum <$> LST.allProd seg
9
Since: 1.0.0.0
Affine1 (Affine1Repr a) |
Instances
type Affine1Repr a = (a, a) Source #
Constructors
new :: a -> a -> Affine1 a Source #
\(O(1)\) Creates a one-dimensional affine transformation: \(f: x \rightarrow a \times x + b\).
Since: 1.0.0.0
unAffine1 :: Affine1 a -> Affine1Repr a Source #
\(O(1)\) Retrieves the two components of Affine1
.
Since: 1.1.0.0