Numeric.LinearAlgebra.Linear
 Portability uses ffi Stability provisional Maintainer Alberto Ruiz (aruiz at um dot es)
Description
Basic optimized operations on vectors and matrices.
Synopsis
class Container c e => Linear c e where
 scale :: e -> c e -> c e addConstant :: e -> c e -> c e add :: c e -> c e -> c e sub :: c e -> c e -> c e mul :: c e -> c e -> c e divide :: c e -> c e -> c e scaleRecip :: e -> c e -> c e equal :: c e -> c e -> Bool
multiply :: Element a => Matrix a -> Matrix a -> Matrix a
dot :: Element t => Vector t -> Vector t -> t
outer :: Element t => Vector t -> Vector t -> Matrix t
kronecker :: Element t => Matrix t -> Matrix t -> Matrix t
Documentation
 class Container c e => Linear c e where Source
A generic interface for vectors and matrices to a few element-by-element functions in Numeric.GSL.Vector.
Methods
 scale :: e -> c e -> c e Source
 addConstant :: e -> c e -> c e Source
 add :: c e -> c e -> c e Source
 sub :: c e -> c e -> c e Source
 mul :: c e -> c e -> c e Source
element by element multiplication
 divide :: c e -> c e -> c e Source
element by element division
 scaleRecip :: e -> c e -> c e Source
scale the element by element reciprocal of the object: scaleRecip 2 (fromList [5,i]) == 2 |> [0.4 :+ 0.0,0.0 :+ (-2.0)]
 equal :: c e -> c e -> Bool Source
Instances
 Linear Vector Double Linear Vector Double Linear Matrix Double Linear Matrix Double Linear Vector (Complex Double) Linear Vector (Complex Double) Linear Matrix (Complex Double) Linear Matrix (Complex Double)
 multiply :: Element a => Matrix a -> Matrix a -> Matrix a Source
matrix product
 dot :: Element t => Vector t -> Vector t -> t Source
euclidean inner product
 outer :: Element t => Vector t -> Vector t -> Matrix t Source

Outer product of two vectors.

```> fromList [1,2,3] `outer` fromList [5,2,3]
(3><3)
[  5.0, 2.0, 3.0
, 10.0, 4.0, 6.0
, 15.0, 6.0, 9.0 ]```
 kronecker :: Element t => Matrix t -> Matrix t -> Matrix t Source

Kronecker product of two matrices.

```m1=(2><3)
[ 1.0,  2.0, 0.0
, 0.0, -1.0, 3.0 ]
m2=(4><3)
[  1.0,  2.0,  3.0
,  4.0,  5.0,  6.0
,  7.0,  8.0,  9.0
, 10.0, 11.0, 12.0 ]```
```> kronecker m1 m2
(8><9)
[  1.0,  2.0,  3.0,   2.0,   4.0,   6.0,  0.0,  0.0,  0.0
,  4.0,  5.0,  6.0,   8.0,  10.0,  12.0,  0.0,  0.0,  0.0
,  7.0,  8.0,  9.0,  14.0,  16.0,  18.0,  0.0,  0.0,  0.0
, 10.0, 11.0, 12.0,  20.0,  22.0,  24.0,  0.0,  0.0,  0.0
,  0.0,  0.0,  0.0,  -1.0,  -2.0,  -3.0,  3.0,  6.0,  9.0
,  0.0,  0.0,  0.0,  -4.0,  -5.0,  -6.0, 12.0, 15.0, 18.0
,  0.0,  0.0,  0.0,  -7.0,  -8.0,  -9.0, 21.0, 24.0, 27.0
,  0.0,  0.0,  0.0, -10.0, -11.0, -12.0, 30.0, 33.0, 36.0 ]```