statistics-dirichlet-0.6.1: Functions for working with Dirichlet densities and mixtures on vectors.

Portability portable experimental felipe.lessa@gmail.com Safe-Infered

Math.Statistics.Dirichlet.Matrix

Contents

Description

Implement matrices using plain `Vector`s with data stored in row-major order (i.e. the first elements correspond to the first row).

Synopsis

# Basic

data Matrix Source

A matrix.

Constructors

 M FieldsmRows :: !Int mCols :: !Int mData :: !(Vector Double)

Instances

 Eq Matrix Ord Matrix Show Matrix

size :: Matrix -> (Int, Int)Source

Size of the matrix.

(!) :: Matrix -> (Int, Int) -> DoubleSource

Element at position.

# Constructing

replicate :: (Int, Int) -> Double -> MatrixSource

A matrix where all elements are of the same value.

A matrix where all rows are of the same value.

fromVector :: (Vector v (w Double), Vector w Double) => v (w Double) -> MatrixSource

Creates a matrix from a vector of vectors. It *is not* verified that the vectors have the right length.

fromVectorT :: (Vector v (w Double), Vector w Double) => v (w Double) -> MatrixSource

Creates a matrix from a vector of vectors. The vectors are transposed, so `fromVectorT` is the same as ```transpose . fromVector```. It *is* verified that the vectors have the right length.

# Rows

O(rows) Rows of the matrix. Each element takes O(1) time and storage.

O(1) `m !!! i` is the `i`-th row of the matrix.

# Columns

O(rows*cols) Columns of the matrix. Each element takes O(rows) time and storage.

O(rows) `m col i` is the `i`-th column of the matrix.

# Maps and zips

rzipWith :: (Int -> Vector Double -> Vector Double -> Vector Double) -> Matrix -> Matrix -> MatrixSource

`rzipWith f m n` is a matrix with the same number of rows as `m`. The `i`-th row is obtained by applying `f` to the `i`-th rows of `m` and `n`.