toy-lib-0.1.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.BinaryLifting

Description

Type class-based binary lifting with caches. Prefer Stimes module if it's one-shot. Actually, BinaryLifting makes almost no sense.

Binary lifting is a technique for calculating nth power of a semigroup element in a (big) constant time, or applying them to their semigroup action target.

The i-th element of the underlying vector of BinaryLifting stores \(s^{2^i}\), with which we can construct any of \(s^i\) ((0 <= i < 2^63)) in a big (63) constant time.

Synopsis

Documentation

cacheBLU :: (Semigroup a, Unbox a) => a -> Vector a #

\(O(W(\diamond))\)

cacheBLV :: Semigroup a => a -> Vector a #

\(O(W(\diamond))\)

stimesBL :: (Semigroup a, Vector v a) => v a -> Int -> a -> a #

\(O((\diamond) \cdot \mathit{popCount}(n))\)

mtimesBL :: (Monoid a, Vector v a) => v a -> Int -> a #

\(O({(\diamond)} \cdot \mathit{popCount}(n))\)

sactBL :: (SemigroupAction a b, Vector v a) => v a -> Int -> b -> b #

\(O(\mathit{sact} \cdot \mathit{popCount}(n))\) Performs semigroup action based on the binary lifting table.

Product

Permutation

newtype Permutation #

Semigroup action of permutation.

Constructors

Permutation (Vector Int) 

Instances

Instances details
Semigroup Permutation # 
Instance details

Defined in Data.BinaryLifting

SemigroupAction Permutation Int #

Int as target

Instance details

Defined in Data.BinaryLifting

Methods

sact :: Permutation -> Int -> Int #

SemigroupAction Permutation (Vector Int) #

U.Vector Int as target

Instance details

Defined in Data.BinaryLifting

idPermutation :: Int -> Permutation #

Creates identity Permutation of length n.

unPermutation :: Permutation -> Vector Int #

Creates identity Permutation of length n.

IndexMap

newtype IndexMap #

Semigroup action of G.!.

Constructors

IndexMap (Vector Int) 

Instances

Instances details
Semigroup IndexMap # 
Instance details

Defined in Data.BinaryLifting

SemigroupAction IndexMap Int #

Int as target

Instance details

Defined in Data.BinaryLifting

Methods

sact :: IndexMap -> Int -> Int #

unIndexMap :: IndexMap -> Vector Int #

Creates identity Permutation of length n.

idIndexMap :: Int -> IndexMap #

Creates identity Permutation of length n.

IndexMapWithAction: Transition + Semigroup

newtype IndexMapWithAction a #

Transition + semigroup concatanation. LCA is based on this.

Typical problems (Permutation)

Typical problems (IndexMapWithAction)

c.f. LCA.

Constructors

IndexMapWithAction (Vector (Int, a)) 

Instances

Instances details
(Unbox a, Semigroup a) => Semigroup (IndexMapWithAction a) # 
Instance details

Defined in Data.BinaryLifting

(Show a, Unbox a) => Show (IndexMapWithAction a) # 
Instance details

Defined in Data.BinaryLifting

(Unbox a, Eq a) => Eq (IndexMapWithAction a) # 
Instance details

Defined in Data.BinaryLifting

Unbox a => SemigroupAction (IndexMapWithAction a) Int #

Int as target

Instance details

Defined in Data.BinaryLifting

Methods

sact :: IndexMapWithAction a -> Int -> Int #

(Unbox a, SemigroupAction a b) => SemigroupAction (IndexMapWithAction a) (Int, b) #

b as target

Instance details

Defined in Data.BinaryLifting

Methods

sact :: IndexMapWithAction a -> (Int, b) -> (Int, b) #

idIndexMapWithAction :: Unbox a => Int -> a -> IndexMapWithAction a #

The identity element of IndexMapWithAction.

Orphan instances

SemigroupAction (Product Int) Int # 
Instance details

Methods

sact :: Product Int -> Int -> Int #