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

Portabilityportable
Stabilityexperimental
Maintainerfelipe.lessa@gmail.com
Safe HaskellSafe-Infered

Math.Statistics.Dirichlet.Matrix

Contents

Description

Implement matrices using plain Vectors 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 

Fields

mRows :: !Int
 
mCols :: !Int
 
mData :: !(Vector Double)
 

Instances

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.

replicateRows :: Int -> Vector Double -> MatrixSource

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

rows :: Matrix -> Vector (Vector Double)Source

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

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

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

Columns

cols :: Matrix -> Vector (Vector Double)Source

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

col :: Matrix -> Int -> Vector DoubleSource

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.

Other