HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

  • Packagematrices-0.5.0
  • Exports70
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceGeneric.hs

Immutable Matrix

1 declaration
datadata Matrix (v :: Type -> Type) a
#

Row-major matrix supporting efficient slice.

Constructors

Instances8Matrix, Eq, Read, Show, Generic, NFData, …

Accessors

0 declarations

length information

valuerows :: Matrix m v a => m v a -> Int
#

Derived methods

Return the number of rows

valuecols :: Matrix m v a => m v a -> Int
#

Return the number of columns

Indexing

methodtakeDiag :: m v a -> v a
#

Extract the diagonal. Default algorithm is O(min(m,n) * O(unsafeIndex)).

Construction

8 declarations
valuematrix
  1. :: Matrix m v a
  2. => Int

    number of columns

  3. -> [a]

    row list

  4. -> m v a
#

O(m*n) Matrix construction

valuefromLists :: Matrix m v a => [[a]] -> m v a
#

O(m*n) Create matrix from list of lists, it doesn't check if the list of list is a valid matrix

valuefromRows :: Matrix m v a => [v a] -> m v a
#

O(m*n) Create matrix from rows

Conversions

5 declarations
methodflatten :: m v a -> v a
#

Default algorithm is O((m*n) * O(unsafeIndex)).

valuetoRows :: Matrix m v a => m v a -> [v a]
#

O(m) Return the rows

valuetoList :: Matrix m v a => m v a -> [a]
#

O(m*n) Create a list by concatenating rows

valuetoLists :: Matrix m v a => m v a -> [[a]]
#

O(m*n) List of lists

Different matrix types

10 declarations
valuediag
  1. :: (Num a, Vector v a, Foldable t)
  2. => t a

    diagonal

  3. -> Matrix v a
#

O(m*n) Create a square matrix with given diagonal, other entries default to 0

valuediagRect
  1. :: (Vector v a, Foldable t)
  2. => a

    default value

  3. -> (Int, Int)
  4. -> t a

    diagonal

  5. -> Matrix v a
#

O(m*n) Create a rectangular matrix with default values and given diagonal

Mapping

2 declarations

Monadic mapping

6 declarations
valueimapM_
  1. :: (Vector v a, Monad m)
  2. => (Int, Int) -> a -> m b
  3. -> Matrix v a
  4. -> m ()
#

O(m*n) Apply the monadic action to every element and its index, ignoring the results.

Zipping

15 declarations

Monadic Zipping

2 declarations

Unzipping

5 declarations

Monadic sequencing

3 declarations

Mutable matrix

5 declarations