| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
AtCoder.Extra.Monoid.Affine1
Contents
Description
Range add monoid action for \([l, r)\) intervals: \(f: x \rightarrow ax + b\).
Since: 1.0.0.0
Synopsis
- newtype Affine1 a = Affine1 (Affine1Repr a)
- type Affine1Repr a = (a, a)
- new :: a -> a -> Affine1 a
- act :: Num a => Affine1 a -> a -> a
Affine1
Range add monoid action for \([l, r)\) intervals: \(f: x \rightarrow ax + b\).
Composition and dual
Semigroup for Affine1 is implemented like function composition, and rightmost affine
transformation is applied first: \((f_1 \circ f_2) v := f_1 (f_2(v))\). If you need foldr
of \([f_l, f_{l+1}, .., f_r)\) on a segment tree, be sure to wrap Affine1 in
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 seg9
Since: 1.0.0.0
Constructors
| Affine1 (Affine1Repr a) |
Instances
type Affine1Repr a = (a, a) Source #