Processing math: 100%
ac-library-hs-1.1.0.0: Data structures and algorithms
Safe HaskellSafe-Inferred
LanguageGHC2021

AtCoder.Extra.Semigroup.Matrix

Description

A simple HxW matrix backed by a vector, mainly for binary exponention.

The matrix is a left semigroup action: m2(m1v)=(m2m1)v.

Since: 1.1.0.0

Synopsis

Matrix

data Matrix a Source #

A simple HxW matrix backed by a vector, mainly for binary exponention.

The matrix is a left semigroup action: m2(m1v)=(m2m1)v.

Since: 1.1.0.0

Constructors

Matrix 

Fields

Instances

Instances details
(Num a, Unbox a) => Semigroup (Matrix a) Source #

Since: 1.1.0.0

Instance details

Defined in AtCoder.Extra.Semigroup.Matrix

Methods

(<>) :: Matrix a -> Matrix a -> Matrix a #

sconcat :: NonEmpty (Matrix a) -> Matrix a #

stimes :: Integral b => b -> Matrix a -> Matrix a #

(Show a, Unbox a) => Show (Matrix a) Source #

Since: 1.1.0.0

Instance details

Defined in AtCoder.Extra.Semigroup.Matrix

Methods

showsPrec :: Int -> Matrix a -> ShowS #

show :: Matrix a -> String #

showList :: [Matrix a] -> ShowS #

(Unbox a, Eq a) => Eq (Matrix a) Source #

Since: 1.1.0.0

Instance details

Defined in AtCoder.Extra.Semigroup.Matrix

Methods

(==) :: Matrix a -> Matrix a -> Bool #

(/=) :: Matrix a -> Matrix a -> Bool #

Constructors

new :: (HasCallStack, Unbox a) => Int -> Int -> Vector a -> Matrix a Source #

O(hw) Creates an HxW matrix.

Since: 1.1.0.0

zero :: (Unbox a, Num a) => Int -> Matrix a Source #

O(n2) Creates an NxN zero matrix.

Since: 1.1.0.0

ident :: (Unbox a, Num a) => Int -> Matrix a Source #

O(n2) Creates an NxN identity matrix.

Since: 1.1.0.0

diag :: (Unbox a, Num a) => Int -> Vector a -> Matrix a Source #

O(n2) Creates an NxN diagonal matrix.

Since: 1.1.0.0

Mapping

map :: (Unbox a, Unbox b) => (a -> b) -> Matrix a -> Matrix b Source #

O(n2) Maps the Matrix.

Since: 1.1.0.0

Multiplications

mulToCol :: (Num a, Unbox a) => Matrix a -> Col a -> Col a Source #

O(hw) Multiplies HxW matrix to a Hx1 column vector.

Since: 1.1.0.0

mul :: (Num e, Unbox e) => Matrix e -> Matrix e -> Matrix e Source #

O(h1Kw2) Multiplies H1xK matrix to a KxW2 matrix.

Since: 1.1.0.0

mulMod :: Int -> Matrix Int -> Matrix Int -> Matrix Int Source #

O(h1w2K) Multiplies H1xK matrix to a KxW2 matrix, taking the mod.

Since: 1.1.0.0

mulMint :: forall a. KnownNat a => Matrix (ModInt a) -> Matrix (ModInt a) -> Matrix (ModInt a) Source #

O(h1w2K) mul specialized to ModInt.

Since: 1.1.0.0

Powers

pow :: Int -> Matrix Int -> Matrix Int Source #

O(wn3) Calculates Mk.

Since: 1.1.0.0

powMod :: Int -> Int -> Matrix Int -> Matrix Int Source #

O(wn3) Calculates Mk, taking the mod.

Since: 1.1.0.0

powMint :: forall m. KnownNat m => Int -> Matrix (ModInt m) -> Matrix (ModInt m) Source #

O(wn3) Calculates Mk, specialized to ModInt.

Since: 1.1.0.0