summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Numeric')
-rw-r--r--packages/base/src/Numeric/Container.hs6
-rw-r--r--packages/base/src/Numeric/LinearAlgebra.hs30
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Algorithms.hs9
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Base.hs139
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Data.hs68
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Devel.hs68
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/LAPACK.hs1
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util.hs5
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs7
-rw-r--r--packages/base/src/Numeric/Matrix.hs7
-rw-r--r--packages/base/src/Numeric/Vector.hs5
11 files changed, 291 insertions, 54 deletions
diff --git a/packages/base/src/Numeric/Container.hs b/packages/base/src/Numeric/Container.hs
index b7d3b80..240e5f5 100644
--- a/packages/base/src/Numeric/Container.hs
+++ b/packages/base/src/Numeric/Container.hs
@@ -9,11 +9,9 @@
9-- | 9-- |
10-- Module : Numeric.Container 10-- Module : Numeric.Container
11-- Copyright : (c) Alberto Ruiz 2010-14 11-- Copyright : (c) Alberto Ruiz 2010-14
12-- License : GPL 12-- License : BSD3
13-- 13-- Maintainer : Alberto Ruiz
14-- Maintainer : Alberto Ruiz <aruiz@um.es>
15-- Stability : provisional 14-- Stability : provisional
16-- Portability : portable
17-- 15--
18-- Basic numeric operations on 'Vector' and 'Matrix', including conversion routines. 16-- Basic numeric operations on 'Vector' and 'Matrix', including conversion routines.
19-- 17--
diff --git a/packages/base/src/Numeric/LinearAlgebra.hs b/packages/base/src/Numeric/LinearAlgebra.hs
deleted file mode 100644
index 1db860c..0000000
--- a/packages/base/src/Numeric/LinearAlgebra.hs
+++ /dev/null
@@ -1,30 +0,0 @@
1-----------------------------------------------------------------------------
2{- |
3Module : Numeric.LinearAlgebra
4Copyright : (c) Alberto Ruiz 2006-10
5License : GPL-style
6
7Maintainer : Alberto Ruiz (aruiz at um dot es)
8Stability : provisional
9Portability : uses ffi
10
11This module reexports all normally required functions for Linear Algebra applications.
12
13It also provides instances of standard classes 'Show', 'Read', 'Eq',
14'Num', 'Fractional', and 'Floating' for 'Vector' and 'Matrix'.
15In arithmetic operations one-component vectors and matrices automatically
16expand to match the dimensions of the other operand.
17
18-}
19-----------------------------------------------------------------------------
20{-# OPTIONS_HADDOCK hide #-}
21
22module Numeric.LinearAlgebra (
23 module Numeric.Container,
24 module Numeric.LinearAlgebra.Algorithms
25) where
26
27import Numeric.Container
28import Numeric.LinearAlgebra.Algorithms
29import Numeric.Matrix()
30import Numeric.Vector()
diff --git a/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs b/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
index 6f40683..92761be 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Algorithms.hs
@@ -7,12 +7,10 @@
7----------------------------------------------------------------------------- 7-----------------------------------------------------------------------------
8{- | 8{- |
9Module : Numeric.LinearAlgebra.Algorithms 9Module : Numeric.LinearAlgebra.Algorithms
10Copyright : (c) Alberto Ruiz 2006-9 10Copyright : (c) Alberto Ruiz 2006-14
11License : GPL-style 11License : BSD3
12 12Maintainer : Alberto Ruiz
13Maintainer : Alberto Ruiz (aruiz at um dot es)
14Stability : provisional 13Stability : provisional
15Portability : uses ffi
16 14
17High level generic interface to common matrix computations. 15High level generic interface to common matrix computations.
18 16
@@ -20,6 +18,7 @@ Specific functions for particular base types can also be explicitly
20imported from "Numeric.LinearAlgebra.LAPACK". 18imported from "Numeric.LinearAlgebra.LAPACK".
21 19
22-} 20-}
21{-# OPTIONS_HADDOCK hide #-}
23----------------------------------------------------------------------------- 22-----------------------------------------------------------------------------
24 23
25module Numeric.LinearAlgebra.Algorithms ( 24module Numeric.LinearAlgebra.Algorithms (
diff --git a/packages/base/src/Numeric/LinearAlgebra/Base.hs b/packages/base/src/Numeric/LinearAlgebra/Base.hs
new file mode 100644
index 0000000..8aa7846
--- /dev/null
+++ b/packages/base/src/Numeric/LinearAlgebra/Base.hs
@@ -0,0 +1,139 @@
1-----------------------------------------------------------------------------
2{- |
3Module : Numeric.LinearAlgebra
4Copyright : (c) Alberto Ruiz 2006-14
5License : BSD3
6Maintainer : Alberto Ruiz
7Stability : provisional
8
9This module reexports the most common Linear Algebra functions.
10
11-}
12-----------------------------------------------------------------------------
13module Numeric.LinearAlgebra.Base (
14
15 -- * Basic types and data processing
16 module Numeric.LinearAlgebra.Data,
17
18 -- | The standard numeric classes are defined elementwise:
19 --
20 -- >>> fromList [1,2,3] * fromList [3,0,-2 :: Double]
21 -- fromList [3.0,0.0,-6.0]
22 --
23 -- >>> (3><3) [1..9] * ident 3 :: Matrix Double
24 -- (3><3)
25 -- [ 1.0, 0.0, 0.0
26 -- , 0.0, 5.0, 0.0
27 -- , 0.0, 0.0, 9.0 ]
28 --
29 -- In arithmetic operations single-element vectors and matrices
30 -- (created from numeric literals or using 'scalar') automatically
31 -- expand to match the dimensions of the other operand:
32 --
33 -- >>> 5 + 2*ident 3 :: Matrix Double
34 -- (3><3)
35 -- [ 7.0, 5.0, 5.0
36 -- , 5.0, 7.0, 5.0
37 -- , 5.0, 5.0, 7.0 ]
38 --
39
40 -- * Products
41 (<.>),
42
43 -- | The matrix product is also implemented in the "Data.Monoid" instance for Matrix, where
44 -- single-element matrices (created from numeric literals or using 'scalar')
45 -- are used for scaling.
46 --
47 -- >>> let m = (2><3)[1..] :: Matrix Double
48 -- >>> m <> 2 <> diagl[0.5,1,0]
49 -- (2><3)
50 -- [ 1.0, 4.0, 0.0
51 -- , 4.0, 10.0, 0.0 ]
52 --
53 -- mconcat uses 'optimiseMult' to get the optimal association order.
54
55 (◇),
56 outer, kronecker, cross,
57 scale,
58 sumElements, prodElements, absSum,
59
60 -- * Linear Systems
61 (<\>),
62 linearSolve,
63 linearSolveLS,
64 linearSolveSVD,
65 luSolve,
66 cholSolve,
67
68 -- * Inverse and pseudoinverse
69 inv, pinv, pinvTol,
70
71 -- * Determinant and rank
72 rcond, rank, ranksv,
73 det, invlndet,
74
75 -- * Singular value decomposition
76 svd,
77 fullSVD,
78 thinSVD,
79 compactSVD,
80 singularValues,
81 leftSV, rightSV,
82
83 -- * Eigensystems
84 eig, eigSH, eigSH',
85 eigenvalues, eigenvaluesSH, eigenvaluesSH',
86 geigSH',
87
88 -- * QR
89 qr, rq, qrRaw, qrgr,
90
91 -- * Cholesky
92 chol, cholSH, mbCholSH,
93
94 -- * Hessenberg
95 hess,
96
97 -- * Schur
98 schur,
99
100 -- * LU
101 lu, luPacked,
102
103 -- * Matrix functions
104 expm,
105 sqrtm,
106 matFunc,
107
108 -- * Nullspace
109 nullspacePrec,
110 nullVector,
111 nullspaceSVD,
112 null1, null1sym,
113
114 orth,
115
116 -- * Norms
117 norm1, norm2, normInf, pnorm, NormType(..),
118
119 -- * Correlation and Convolution
120 corr, conv, corrMin, corr2, conv2,
121
122 -- * Random arrays
123
124 -- | rand, randn, RandDist(..), randomVector, gaussianSample, uniformSample
125
126 -- * Misc
127 meanCov, peps, relativeError, haussholder, optimiseMult, udot
128) where
129
130import Numeric.LinearAlgebra.Data
131
132import Numeric.Matrix()
133import Numeric.Vector()
134import Numeric.Container
135import Numeric.LinearAlgebra.Algorithms
136import Numeric.LinearAlgebra.Util
137
138
139
diff --git a/packages/base/src/Numeric/LinearAlgebra/Data.hs b/packages/base/src/Numeric/LinearAlgebra/Data.hs
new file mode 100644
index 0000000..3bc88f9
--- /dev/null
+++ b/packages/base/src/Numeric/LinearAlgebra/Data.hs
@@ -0,0 +1,68 @@
1--------------------------------------------------------------------------------
2{- |
3Module : Numeric.LinearAlgebra.Data
4Copyright : (c) Alberto Ruiz 2014
5License : BSD3
6Maintainer : Alberto Ruiz
7Stability : provisional
8
9Basic data processing.
10
11-}
12--------------------------------------------------------------------------------
13
14module Numeric.LinearAlgebra.Data(
15
16 -- * Vector
17 -- | 1D arrays are storable vectors from the vector package.
18
19 Vector, (|>), dim, (@>),
20
21 -- * Matrix
22 Matrix, (><), size, (@@>), trans, ctrans,
23
24 -- * Construction
25 scalar, konst, build, assoc, accum, linspace, -- ones, zeros,
26
27 -- * Diagonal
28 ident, diag, diagl, diagRect, takeDiag,
29
30 -- * Data manipulation
31 fromList, toList, subVector, takesV, vjoin,
32 flatten, reshape, asRow, asColumn, row, col,
33 fromRows, toRows, fromColumns, toColumns, fromLists, toLists, fromArray2D,
34 takeRows, dropRows, takeColumns, dropColumns, subMatrix, (?), (¿), fliprl, flipud,
35
36 -- * Block matrix
37 fromBlocks, (¦), (——), diagBlock, repmat, toBlocks, toBlocksEvery,
38
39 -- * Mapping functions
40 conj, cmap, step, cond,
41
42 -- * Find elements
43 find, maxIndex, minIndex, maxElement, minElement, atIndex,
44
45 -- * IO
46 disp, dispf, disps, dispcf, latexFormat, format, readMatrix,
47
48 -- | loadMatrix, saveMatrix, fromFile, fileDimensions, fscanfVector, fprintfVector, freadVector, fwriteVector
49
50-- * Conversion
51 Convert(..),
52
53 -- * Misc
54 arctan2,
55 rows, cols,
56 separable,
57
58 module Data.Complex
59
60) where
61
62import Data.Packed.Vector
63import Data.Packed.Matrix
64import Numeric.Container
65import Data.Packed.IO
66import Numeric.LinearAlgebra.Util
67import Data.Complex
68
diff --git a/packages/base/src/Numeric/LinearAlgebra/Devel.hs b/packages/base/src/Numeric/LinearAlgebra/Devel.hs
new file mode 100644
index 0000000..c41db2d
--- /dev/null
+++ b/packages/base/src/Numeric/LinearAlgebra/Devel.hs
@@ -0,0 +1,68 @@
1--------------------------------------------------------------------------------
2{- |
3Module : Numeric.HMatrix.Devel
4Copyright : (c) Alberto Ruiz 2014
5License : BSD3
6Maintainer : Alberto Ruiz
7Stability : provisional
8
9The library can be easily extended using the tools in this module.
10
11-}
12--------------------------------------------------------------------------------
13
14module Numeric.LinearAlgebra.Devel(
15 -- * FFI helpers
16 -- | Sample usage, to upload a perspective matrix to a shader.
17 --
18 -- @ glUniformMatrix4fv 0 1 (fromIntegral gl_TRUE) \`appMatrix\` perspective 0.01 100 (pi\/2) (4\/3)
19 -- @
20 module Data.Packed.Foreign,
21
22 -- * FFI tools
23 -- | Illustrative usage examples can be found
24 -- in the @examples\/devel@ folder included in the package.
25 module Data.Packed.Development,
26
27 -- * ST
28 -- | In-place manipulation inside the ST monad.
29 -- See examples\/inplace.hs in the distribution.
30
31 -- ** Mutable Vectors
32 STVector, newVector, thawVector, freezeVector, runSTVector,
33 readVector, writeVector, modifyVector, liftSTVector,
34 -- ** Mutable Matrices
35 STMatrix, newMatrix, thawMatrix, freezeMatrix, runSTMatrix,
36 readMatrix, writeMatrix, modifyMatrix, liftSTMatrix,
37 -- ** Unsafe functions
38 newUndefinedVector,
39 unsafeReadVector, unsafeWriteVector,
40 unsafeThawVector, unsafeFreezeVector,
41 newUndefinedMatrix,
42 unsafeReadMatrix, unsafeWriteMatrix,
43 unsafeThawMatrix, unsafeFreezeMatrix,
44
45 -- * Special maps and zips
46 mapVectorWithIndex, zipVector, zipVectorWith, unzipVector, unzipVectorWith,
47 mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_,
48 foldLoop, foldVector, foldVectorG, foldVectorWithIndex,
49 mapMatrixWithIndex, mapMatrixWithIndexM, mapMatrixWithIndexM_,
50 liftMatrix, liftMatrix2, liftMatrix2Auto,
51
52 -- * Auxiliary classes
53 Element, Container, Product, Contraction, LSDiv,
54 Complexable(), RealElement(),
55 RealOf, ComplexOf, SingleOf, DoubleOf,
56 IndexOf,
57 Field, Normed
58) where
59
60import Data.Packed.Foreign
61import Data.Packed.Development
62import Data.Packed.ST
63import Numeric.Container(Container,Contraction,LSDiv,Product,
64 Complexable(),RealElement(),
65 RealOf, ComplexOf, SingleOf, DoubleOf, IndexOf)
66import Data.Packed
67import Numeric.LinearAlgebra.Algorithms(Field,Normed)
68
diff --git a/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs b/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
index 9cb67d4..40fef45 100644
--- a/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/LAPACK.hs
@@ -3,7 +3,6 @@
3-- Module : Numeric.LinearAlgebra.LAPACK 3-- Module : Numeric.LinearAlgebra.LAPACK
4-- Copyright : (c) Alberto Ruiz 2006-14 4-- Copyright : (c) Alberto Ruiz 2006-14
5-- License : BSD3 5-- License : BSD3
6--
7-- Maintainer : Alberto Ruiz 6-- Maintainer : Alberto Ruiz
8-- Stability : provisional 7-- Stability : provisional
9-- 8--
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs
index 533c54b..f0470ab 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs
@@ -3,9 +3,8 @@
3{- | 3{- |
4Module : Numeric.LinearAlgebra.Util 4Module : Numeric.LinearAlgebra.Util
5Copyright : (c) Alberto Ruiz 2013 5Copyright : (c) Alberto Ruiz 2013
6License : GPL 6License : BSD3
7 7Maintainer : Alberto Ruiz
8Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional 8Stability : provisional
10 9
11-} 10-}
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs b/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs
index d04c46b..1775f14 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util/Convolution.hs
@@ -3,9 +3,8 @@
3{- | 3{- |
4Module : Numeric.LinearAlgebra.Util.Convolution 4Module : Numeric.LinearAlgebra.Util.Convolution
5Copyright : (c) Alberto Ruiz 2012 5Copyright : (c) Alberto Ruiz 2012
6License : GPL 6License : BSD3
7 7Maintainer : Alberto Ruiz
8Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional 8Stability : provisional
10 9
11-} 10-}
@@ -17,7 +16,7 @@ module Numeric.LinearAlgebra.Util.Convolution(
17 corr2, conv2, separable 16 corr2, conv2, separable
18) where 17) where
19 18
20import Numeric.LinearAlgebra 19import Numeric.Container
21 20
22 21
23vectSS :: Element t => Int -> Vector t -> Matrix t 22vectSS :: Element t => Int -> Vector t -> Matrix t
diff --git a/packages/base/src/Numeric/Matrix.hs b/packages/base/src/Numeric/Matrix.hs
index 3478aae..962ee84 100644
--- a/packages/base/src/Numeric/Matrix.hs
+++ b/packages/base/src/Numeric/Matrix.hs
@@ -7,12 +7,11 @@
7----------------------------------------------------------------------------- 7-----------------------------------------------------------------------------
8-- | 8-- |
9-- Module : Numeric.Matrix 9-- Module : Numeric.Matrix
10-- Copyright : (c) Alberto Ruiz 2010 10-- Copyright : (c) Alberto Ruiz 2014
11-- License : GPL-style 11-- License : BSD3
12-- 12--
13-- Maintainer : Alberto Ruiz <aruiz@um.es> 13-- Maintainer : Alberto Ruiz
14-- Stability : provisional 14-- Stability : provisional
15-- Portability : portable
16-- 15--
17-- Provides instances of standard classes 'Show', 'Read', 'Eq', 16-- Provides instances of standard classes 'Show', 'Read', 'Eq',
18-- 'Num', 'Fractional', and 'Floating' for 'Matrix'. 17-- 'Num', 'Fractional', and 'Floating' for 'Matrix'.
diff --git a/packages/base/src/Numeric/Vector.hs b/packages/base/src/Numeric/Vector.hs
index 2769cd9..3a425f5 100644
--- a/packages/base/src/Numeric/Vector.hs
+++ b/packages/base/src/Numeric/Vector.hs
@@ -7,11 +7,10 @@
7-- | 7-- |
8-- Module : Numeric.Vector 8-- Module : Numeric.Vector
9-- Copyright : (c) Alberto Ruiz 2011 9-- Copyright : (c) Alberto Ruiz 2011
10-- License : GPL-style 10-- License : BSD3
11-- 11--
12-- Maintainer : Alberto Ruiz <aruiz@um.es> 12-- Maintainer : Alberto Ruiz
13-- Stability : provisional 13-- Stability : provisional
14-- Portability : portable
15-- 14--
16-- Provides instances of standard classes 'Show', 'Read', 'Eq', 15-- Provides instances of standard classes 'Show', 'Read', 'Eq',
17-- 'Num', 'Fractional', and 'Floating' for 'Vector'. 16-- 'Num', 'Fractional', and 'Floating' for 'Vector'.