hmatrix-0.15.2.1: Linear algebra and numerical computation

Copyright(c) Alberto Ruiz 2013
LicenseGPL
MaintainerAlberto Ruiz (aruiz at um dot es)
Stabilityprovisional
Safe HaskellNone
LanguageHaskell98

Numeric.LinearAlgebra.Util

Contents

Description

 

Synopsis

Convenience functions

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

(rows &&& cols)

disp :: Int -> Matrix Double -> IO () Source

show a matrix with given number of digits after the decimal point

zeros Source

Arguments

:: Int

rows

-> Int

columns

-> Matrix Double 

a real matrix of zeros

ones Source

Arguments

:: Int

rows

-> Int

columns

-> Matrix Double 

a real matrix of ones

diagl :: [Double] -> Matrix Double Source

create a real diagonal matrix from a list

row :: [Double] -> Matrix Double Source

create a single row real matrix from a list

col :: [Double] -> Matrix Double Source

create a single column real matrix from a list

(&) :: Vector Double -> Vector Double -> Vector Double infixl 3 Source

concatenation of real vectors

(!) :: Matrix Double -> Matrix Double -> Matrix Double infixl 3 Source

horizontal concatenation of real matrices

(¦) :: Matrix Double -> Matrix Double -> Matrix Double infixl 3 Source

(00A6) horizontal concatenation of real matrices

(#) :: Matrix Double -> Matrix Double -> Matrix Double infixl 2 Source

vertical concatenation of real matrices

(?) :: Element t => Matrix t -> [Int] -> Matrix t infixl 9 Source

extract selected rows

¿ :: Element t => Matrix t -> [Int] -> Matrix t infixl 9 Source

(00BF) extract selected columns

rand :: Int -> Int -> IO (Matrix Double) Source

pseudorandom matrix with uniform elements between 0 and 1

randn :: Int -> Int -> IO (Matrix Double) Source

pseudorandom matrix with normal elements

cross :: Vector Double -> Vector Double -> Vector Double Source

cross product (for three-element real vectors)

norm :: Vector Double -> Double Source

2-norm of real vector

unitary :: Vector Double -> Vector Double Source

Obtains a vector in the same direction with 2-norm=1

mt :: Matrix Double -> Matrix Double Source

trans . inv

pairwiseD2 :: Matrix Double -> Matrix Double -> Matrix Double Source

Matrix of pairwise squared distances of row vectors (using the matrix product trick in blog.smola.org)

rowOuters :: Matrix Double -> Matrix Double -> Matrix Double Source

outer products of rows

null1 :: Matrix Double -> Vector Double Source

solution of overconstrained homogeneous linear system

null1sym :: Matrix Double -> Vector Double Source

solution of overconstrained homogeneous symmetric linear system

Convolution

1D

corr Source

Arguments

:: Product t 
=> Vector t

kernel

-> Vector t

source

-> Vector t 

correlation

>>> corr (fromList[1,2,3]) (fromList [1..10])
fromList [14.0,20.0,26.0,32.0,38.0,44.0,50.0,56.0]

conv :: (Product t, Num t) => Vector t -> Vector t -> Vector t Source

convolution (corr with reversed kernel and padded input, equivalent to polynomial product)

>>> conv (fromList[1,1]) (fromList [-1,1])
fromList [-1.0,0.0,1.0]

corrMin :: (Container Vector t, RealElement t, Product t) => Vector t -> Vector t -> Vector t Source

similar to corr, using min instead of (*)

2D

corr2 :: Product a => Matrix a -> Matrix a -> Matrix a Source

2D correlation

conv2 :: (Num a, Product a) => Matrix a -> Matrix a -> Matrix a Source

2D convolution

separable :: Element t => (Vector t -> Vector t) -> Matrix t -> Matrix t Source

matrix computation implemented as separated vector operations by rows and columns.

Tools for the Kronecker product

(see A. Fusiello, A matter of notation: Several uses of the Kronecker product in 3d computer vision, Pattern Recognition Letters 28 (15) (2007) 2127-2132)

vec (a <> x <> b) == (trans b ` kronecker ` a) <> vec x

vec :: Element t => Matrix t -> Vector t Source

stacking of columns

vech :: Element t => Matrix t -> Vector t Source

half-vectorization (of the lower triangular part)

dup :: (Num t, Num (Vector t), Element t) => Int -> Matrix t Source

duplication matrix (dup k <> vech m == vec m, for symmetric m of dim k)

vtrans :: Element t => Int -> Matrix t -> Matrix t Source

generalized "vector" transposition: vtrans 1 == trans, and vtrans (rows m) m == asColumn (vec m)