summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra.hs
blob: 9e9151e435e25b584cbf566593744eb2396b5c49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
-----------------------------------------------------------------------------
{- |
Module      :  Numeric.LinearAlgebra
Copyright   :  (c) Alberto Ruiz 2006-14
License     :  BSD3
Maintainer  :  Alberto Ruiz
Stability   :  provisional

-}
-----------------------------------------------------------------------------
module Numeric.LinearAlgebra (

    -- * Basic types and data processing    
    module Numeric.LinearAlgebra.Data,
    
    -- * Arithmetic and numeric classes
    -- |
    -- The standard numeric classes are defined elementwise:
    --
    -- >>> fromList [1,2,3] * fromList [3,0,-2 :: Double]
    -- fromList [3.0,0.0,-6.0]
    -- 
    -- >>> (3><3) [1..9] * ident 3 :: Matrix Double
    -- (3><3)
    --  [ 1.0, 0.0, 0.0
    --  , 0.0, 5.0, 0.0
    --  , 0.0, 0.0, 9.0 ]
    --
    -- In arithmetic operations single-element vectors and matrices
    -- (created from numeric literals or using 'scalar') automatically
    -- expand to match the dimensions of the other operand:
    -- 
    -- >>> 5 + 2*ident 3 :: Matrix Double
    -- (3><3)
    --  [ 7.0, 5.0, 5.0
    --  , 5.0, 7.0, 5.0
    --  , 5.0, 5.0, 7.0 ]
    --

    -- * Matrix product
    (<.>),

    -- | The overloaded multiplication operators may need type annotations to remove
    -- ambiguity. In those cases we can also use the specific functions 'mXm', 'mXv', and 'dot'.
    --
    -- The matrix x matrix product is also implemented in the "Data.Monoid" instance, where
    -- single-element matrices (created from numeric literals or using 'scalar')
    -- are used for scaling.
    --
    -- >>> let m = (2><3)[1..] :: Matrix Double
    -- >>> m <> 2 <> diagl[0.5,1,0]
    -- (2><3)
    -- [ 1.0,  4.0, 0.0
    -- , 4.0, 10.0, 0.0 ]
    --
    -- 'mconcat' uses 'optimiseMult' to get the optimal association order.

     
    -- * Other products
    outer, kronecker, cross,
    scale,
    sumElements, prodElements, absSum,
    
    -- * Linear Systems
    (<\>),
    linearSolve,
    linearSolveLS,
    linearSolveSVD,
    luSolve,
    cholSolve,
    cgSolve,
    
    -- * Inverse and pseudoinverse
    inv, pinv, pinvTol,

    -- * Determinant and rank
    rcond, rank, ranksv, 
    det, invlndet,
    
    -- * Singular value decomposition
    svd,
    fullSVD,
    thinSVD,
    compactSVD,
    singularValues,
    leftSV, rightSV,
    
    -- * Eigensystems
    eig, eigSH, eigSH',
    eigenvalues, eigenvaluesSH, eigenvaluesSH',
    geigSH',

    -- * QR
    qr, rq, qrRaw, qrgr,

    -- * Cholesky
    chol, cholSH, mbCholSH,

    -- * Hessenberg
    hess,

    -- * Schur
    schur,

    -- * LU
    lu, luPacked,
    
    -- * Matrix functions
    expm,
    sqrtm,
    matFunc,

    -- * Nullspace
    nullspacePrec,
    nullVector,
    nullspaceSVD,
    null1, null1sym,
    
    orth,

    -- * Norms
    norm1, norm2, normInf, pnorm, NormType(..),

    -- * Correlation and convolution
    corr, conv, corrMin, corr2, conv2,

    -- * Random arrays

    RandDist(..), randomVector, rand, randn, gaussianSample, uniformSample,
    
    -- * Misc
    meanCov, peps, relativeError, haussholder, optimiseMult, dot, udot, mXm, mXv, smXv, (<>), (◇), Seed, checkT,
    -- * Auxiliary classes
    Element, Container, Product, Contraction, LSDiv,
    Complexable(), RealElement(),
    RealOf, ComplexOf, SingleOf, DoubleOf,
    IndexOf,
    Field, Normed,
    CGMat, Transposable

) where

import Numeric.LinearAlgebra.Data

import Numeric.Matrix()
import Numeric.Vector()
import Numeric.Container
import Numeric.LinearAlgebra.Algorithms
import Numeric.LinearAlgebra.Util
import Numeric.LinearAlgebra.Random
import Numeric.Sparse(smXv)
import Numeric.LinearAlgebra.Util.CG(cgSolve)
import Numeric.LinearAlgebra.Util.CG(CGMat)