hmatrix-0.15.2.1: Linear algebra and numerical computation

Stability provisional Alberto Ruiz (aruiz at um dot es) None

Numeric.LinearAlgebra.Util

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

Arguments

 :: Int rows -> Int columns -> Matrix Double

a real matrix of zeros

Arguments

 :: Int rows -> Int columns -> Matrix Double

a real matrix of ones

diagl :: [Double] -> Matrix DoubleSource

create a real diagonal matrix from a list

row :: [Double] -> Matrix DoubleSource

create a single row real matrix from a list

col :: [Double] -> Matrix DoubleSource

create a single column real matrix from a list

concatenation of real vectors

horizontal concatenation of real matrices

(00A6) horizontal concatenation of real matrices

vertical concatenation of real matrices

(?) :: Element t => Matrix t -> [Int] -> Matrix tSource

extract selected rows

¿ :: Element t => Matrix t -> [Int] -> Matrix tSource

(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 product (for three-element real vectors)

2-norm of real vector

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

trans . inv

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

outer products of rows

solution of overconstrained homogeneous linear system

solution of overconstrained homogeneous symmetric linear system

# Convolution

## 1D

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 tSource

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 tSource

similar to `corr`, using `min` instead of (*)

## 2D

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

2D correlation

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

2D convolution

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

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 tSource

stacking of columns

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

half-vectorization (of the lower triangular part)

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

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

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

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