Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
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)=(m2∘m1)v.
Since: 1.1.0.0
Synopsis
- data Matrix a = Matrix {}
- new :: (HasCallStack, Unbox a) => Int -> Int -> Vector a -> Matrix a
- zero :: (Unbox a, Num a) => Int -> Matrix a
- ident :: (Unbox a, Num a) => Int -> Matrix a
- diag :: (Unbox a, Num a) => Int -> Vector a -> Matrix a
- map :: (Unbox a, Unbox b) => (a -> b) -> Matrix a -> Matrix b
- mulToCol :: (Num a, Unbox a) => Matrix a -> Col a -> Col a
- mul :: (Num e, Unbox e) => Matrix e -> Matrix e -> Matrix e
- mulMod :: Int -> Matrix Int -> Matrix Int -> Matrix Int
- mulMint :: forall a. KnownNat a => Matrix (ModInt a) -> Matrix (ModInt a) -> Matrix (ModInt a)
- pow :: Int -> Matrix Int -> Matrix Int
- powMod :: Int -> Int -> Matrix Int -> Matrix Int
- powMint :: forall m. KnownNat m => Int -> Matrix (ModInt m) -> Matrix (ModInt m)
Matrix
A simple HxW matrix backed by a vector, mainly for binary exponention.
The matrix is a left semigroup action: m2(m1v)=(m2∘m1)v.
Since: 1.1.0.0
Constructors
Matrix | |
Constructors
new :: (HasCallStack, Unbox a) => Int -> Int -> Vector a -> Matrix a Source #
O(hw) Creates an HxW 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 #