dense-linear-algebra-0.1.0.0: Simple and incomplete pure haskell implementation of linear algebra

Statistics.Matrix

Description

Basic matrix operations.

There isn't a widely used matrix package for Haskell yet, so we implement the necessary minimum here.

Synopsis

# Data types

data Matrix Source #

Two-dimensional matrix, stored in row-major order.

Constructors

 Matrix Fieldsrows :: !IntRows of matrix.cols :: !IntColumns of matrix._vector :: !VectorMatrix data.
Instances
 Source # Instance detailsDefined in Statistics.Matrix.Types Methods(==) :: Matrix -> Matrix -> Bool #(/=) :: Matrix -> Matrix -> Bool # Source # Instance detailsDefined in Statistics.Matrix.Types MethodsshowsPrec :: Int -> Matrix -> ShowS #showList :: [Matrix] -> ShowS #

# Conversion fromto listsvectors

Arguments

 :: Int Number of rows. -> Int Number of columns. -> Vector Double Flat list of values, in row-major order. -> Matrix

Convert from a row-major vector.

Arguments

 :: Int Number of rows. -> Int Number of columns. -> [Double] Flat list of values, in row-major order. -> Matrix

Convert from a row-major list.

fromRowLists :: [[Double]] -> Matrix Source #

create a matrix from a list of lists, as rows

fromRows :: [Vector] -> Matrix Source #

create a matrix from a list of vectors, as rows

fromColumns :: [Vector] -> Matrix Source #

create a matrix from a list of vectors, as columns

Convert to a row-major flat vector.

toList :: Matrix -> [Double] Source #

Convert to a row-major flat list.

toRows :: Matrix -> [Vector] Source #

Convert to a list of vectors, as rows

toColumns :: Matrix -> [Vector] Source #

Convert to a list of vectors, as columns

toRowLists :: Matrix -> [[Double]] Source #

Convert to a list of lists, as rows

# Other

Arguments

 :: Int Number of rows -> Int Number of columns -> (Int -> Int -> Double) Function which takes row and column as argument. -> Matrix

Generate matrix using function

Arguments

 :: Int Number of rows and columns -> (Int -> Int -> Double) Function which takes row and column as argument. It must be symmetric in arguments: f i j == f j i -> Matrix

Generate symmetric square matrix using function

Create the square identity matrix with given dimensions.

Create a square matrix with given diagonal, other entries default to 0

dimension :: Matrix -> (Int, Int) Source #

Return the dimensions of this matrix, as a (row,column) pair.

Element in the center of matrix (not corrected for exponent).

Matrix-matrix multiplication. Matrices must be of compatible sizes (note: not checked).

Matrix-vector multiplication.

Raise matrix to nth power. Power must be positive (/note: not checked).

Calculate the Euclidean norm of a vector.

Return the given column.

Return the given row.

map :: (Double -> Double) -> Matrix -> Matrix Source #

Apply function to every element of matrix

for :: Monad m => Int -> Int -> (Int -> m ()) -> m () Source #

Simple for loop. Counts from start to end-1.

Arguments

 :: Matrix -> Int Row. -> Int Column. -> Double

Indicate whether any element of the matrix is NaN.

bounds :: (Vector -> Int -> r) -> Matrix -> Int -> Int -> r Source #

Given row and column numbers, calculate the offset into the flat row-major vector.

unsafeBounds :: (Vector -> Int -> r) -> Matrix -> Int -> Int -> r Source #

Given row and column numbers, calculate the offset into the flat row-major vector, without checking.