summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-05-16 14:13:49 +0200
committerAlberto Ruiz <aruiz@um.es>2014-05-16 14:13:49 +0200
commit51f4cc7b4b301142b8df73568ffaa448f9e6dd50 (patch)
tree7f9b9a26344a23a0d1e3fb6e4105fe968465cd2a
parent1838c4248679b7476bb8716a76171712dc3cd335 (diff)
license changes, reexport modules
-rw-r--r--packages/base/hmatrix-base.cabal4
-rw-r--r--packages/base/src/Data/Packed.hs1
-rw-r--r--packages/base/src/Data/Packed/Development.hs1
-rw-r--r--packages/base/src/Data/Packed/Foreign.hs1
-rw-r--r--packages/base/src/Data/Packed/Internal.hs6
-rw-r--r--packages/base/src/Data/Packed/Matrix.hs5
-rw-r--r--packages/base/src/Data/Packed/Numeric.hs1
-rw-r--r--packages/base/src/Data/Packed/ST.hs2
-rw-r--r--packages/base/src/Data/Packed/Vector.hs5
-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.hs (renamed from packages/hmatrix/src/Numeric/HMatrix.hs)20
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Data.hs (renamed from packages/hmatrix/src/Numeric/HMatrix/Data.hs)16
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Devel.hs (renamed from packages/hmatrix/src/Numeric/HMatrix/Devel.hs)5
-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
-rw-r--r--packages/hmatrix/src/Numeric/Container.hs241
21 files changed, 289 insertions, 89 deletions
diff --git a/packages/base/hmatrix-base.cabal b/packages/base/hmatrix-base.cabal
index 3f12dad..638390a 100644
--- a/packages/base/hmatrix-base.cabal
+++ b/packages/base/hmatrix-base.cabal
@@ -39,10 +39,12 @@ library
39 Numeric.LinearAlgebra.LAPACK 39 Numeric.LinearAlgebra.LAPACK
40 Numeric.LinearAlgebra.Algorithms 40 Numeric.LinearAlgebra.Algorithms
41 Numeric.Container 41 Numeric.Container
42 Numeric.LinearAlgebra
43 Numeric.LinearAlgebra.Util 42 Numeric.LinearAlgebra.Util
44 Numeric.LinearAlgebra.Util.Convolution 43 Numeric.LinearAlgebra.Util.Convolution
45 Data.Packed.IO 44 Data.Packed.IO
45 Numeric.LinearAlgebra.Base
46 Numeric.LinearAlgebra.Devel
47 Numeric.LinearAlgebra.Data
46 48
47 other-modules: Data.Packed.Internal, 49 other-modules: Data.Packed.Internal,
48 Data.Packed.Internal.Common, 50 Data.Packed.Internal.Common,
diff --git a/packages/base/src/Data/Packed.hs b/packages/base/src/Data/Packed.hs
index c66718a..129bd22 100644
--- a/packages/base/src/Data/Packed.hs
+++ b/packages/base/src/Data/Packed.hs
@@ -10,6 +10,7 @@ Types for dense 'Vector' and 'Matrix' of 'Storable' elements.
10 10
11-} 11-}
12----------------------------------------------------------------------------- 12-----------------------------------------------------------------------------
13{-# OPTIONS_HADDOCK hide #-}
13 14
14module Data.Packed ( 15module Data.Packed (
15 -- * Vector 16 -- * Vector
diff --git a/packages/base/src/Data/Packed/Development.hs b/packages/base/src/Data/Packed/Development.hs
index 6dfd551..1efedc9 100644
--- a/packages/base/src/Data/Packed/Development.hs
+++ b/packages/base/src/Data/Packed/Development.hs
@@ -13,6 +13,7 @@
13-- in the @examples\/devel@ folder included in the package. 13-- in the @examples\/devel@ folder included in the package.
14-- 14--
15----------------------------------------------------------------------------- 15-----------------------------------------------------------------------------
16{-# OPTIONS_HADDOCK hide #-}
16 17
17module Data.Packed.Development ( 18module Data.Packed.Development (
18 createVector, createMatrix, 19 createVector, createMatrix,
diff --git a/packages/base/src/Data/Packed/Foreign.hs b/packages/base/src/Data/Packed/Foreign.hs
index efa51ca..1ec3694 100644
--- a/packages/base/src/Data/Packed/Foreign.hs
+++ b/packages/base/src/Data/Packed/Foreign.hs
@@ -6,6 +6,7 @@
6-- @ glUniformMatrix4fv 0 1 (fromIntegral gl_TRUE) \`appMatrix\` perspective 0.01 100 (pi\/2) (4\/3) 6-- @ glUniformMatrix4fv 0 1 (fromIntegral gl_TRUE) \`appMatrix\` perspective 0.01 100 (pi\/2) (4\/3)
7-- @ 7-- @
8-- 8--
9{-# OPTIONS_HADDOCK hide #-}
9module Data.Packed.Foreign 10module Data.Packed.Foreign
10 ( app 11 ( app
11 , appVector, appVectorLen 12 , appVector, appVectorLen
diff --git a/packages/base/src/Data/Packed/Internal.hs b/packages/base/src/Data/Packed/Internal.hs
index 537e51e..59a72fc 100644
--- a/packages/base/src/Data/Packed/Internal.hs
+++ b/packages/base/src/Data/Packed/Internal.hs
@@ -2,11 +2,9 @@
2-- | 2-- |
3-- Module : Data.Packed.Internal 3-- Module : Data.Packed.Internal
4-- Copyright : (c) Alberto Ruiz 2007 4-- Copyright : (c) Alberto Ruiz 2007
5-- License : GPL-style 5-- License : BSD3
6-- 6-- Maintainer : Alberto Ruiz
7-- Maintainer : Alberto Ruiz <aruiz@um.es>
8-- Stability : provisional 7-- Stability : provisional
9-- Portability : portable
10-- 8--
11-- Reexports all internal modules 9-- Reexports all internal modules
12-- 10--
diff --git a/packages/base/src/Data/Packed/Matrix.hs b/packages/base/src/Data/Packed/Matrix.hs
index d94d167..b3be823 100644
--- a/packages/base/src/Data/Packed/Matrix.hs
+++ b/packages/base/src/Data/Packed/Matrix.hs
@@ -8,9 +8,8 @@
8-- | 8-- |
9-- Module : Data.Packed.Matrix 9-- Module : Data.Packed.Matrix
10-- Copyright : (c) Alberto Ruiz 2007-10 10-- Copyright : (c) Alberto Ruiz 2007-10
11-- License : GPL 11-- License : BSD3
12-- 12-- Maintainer : Alberto Ruiz
13-- Maintainer : Alberto Ruiz <aruiz@um.es>
14-- Stability : provisional 13-- Stability : provisional
15-- 14--
16-- A Matrix representation suitable for numerical computations using LAPACK and GSL. 15-- A Matrix representation suitable for numerical computations using LAPACK and GSL.
diff --git a/packages/base/src/Data/Packed/Numeric.hs b/packages/base/src/Data/Packed/Numeric.hs
index 4892089..c13e91d 100644
--- a/packages/base/src/Data/Packed/Numeric.hs
+++ b/packages/base/src/Data/Packed/Numeric.hs
@@ -10,7 +10,6 @@
10-- Module : Data.Packed.Numeric 10-- Module : Data.Packed.Numeric
11-- Copyright : (c) Alberto Ruiz 2010-14 11-- Copyright : (c) Alberto Ruiz 2010-14
12-- License : BSD3 12-- License : BSD3
13--
14-- Maintainer : Alberto Ruiz 13-- Maintainer : Alberto Ruiz
15-- Stability : provisional 14-- Stability : provisional
16-- 15--
diff --git a/packages/base/src/Data/Packed/ST.hs b/packages/base/src/Data/Packed/ST.hs
index dae457c..5c45c7b 100644
--- a/packages/base/src/Data/Packed/ST.hs
+++ b/packages/base/src/Data/Packed/ST.hs
@@ -9,12 +9,12 @@
9-- License : BSD3 9-- License : BSD3
10-- Maintainer : Alberto Ruiz 10-- Maintainer : Alberto Ruiz
11-- Stability : provisional 11-- Stability : provisional
12-- Portability : portable
13-- 12--
14-- In-place manipulation inside the ST monad. 13-- In-place manipulation inside the ST monad.
15-- See examples/inplace.hs in the distribution. 14-- See examples/inplace.hs in the distribution.
16-- 15--
17----------------------------------------------------------------------------- 16-----------------------------------------------------------------------------
17{-# OPTIONS_HADDOCK hide #-}
18 18
19module Data.Packed.ST ( 19module Data.Packed.ST (
20 -- * Mutable Vectors 20 -- * Mutable Vectors
diff --git a/packages/base/src/Data/Packed/Vector.hs b/packages/base/src/Data/Packed/Vector.hs
index a8f6bb1..53fe563 100644
--- a/packages/base/src/Data/Packed/Vector.hs
+++ b/packages/base/src/Data/Packed/Vector.hs
@@ -4,9 +4,8 @@
4-- | 4-- |
5-- Module : Data.Packed.Vector 5-- Module : Data.Packed.Vector
6-- Copyright : (c) Alberto Ruiz 2007-10 6-- Copyright : (c) Alberto Ruiz 2007-10
7-- License : GPL 7-- License : BSD3
8-- 8-- Maintainer : Alberto Ruiz
9-- Maintainer : Alberto Ruiz <aruiz@um.es>
10-- Stability : provisional 9-- Stability : provisional
11-- 10--
12-- 1D arrays suitable for numeric computations using external libraries. 11-- 1D arrays suitable for numeric computations using external libraries.
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/hmatrix/src/Numeric/HMatrix.hs b/packages/base/src/Numeric/LinearAlgebra/Base.hs
index fcd3e02..8aa7846 100644
--- a/packages/hmatrix/src/Numeric/HMatrix.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Base.hs
@@ -1,9 +1,8 @@
1----------------------------------------------------------------------------- 1-----------------------------------------------------------------------------
2{- | 2{- |
3Module : Numeric.HMatrix 3Module : Numeric.LinearAlgebra
4Copyright : (c) Alberto Ruiz 2006-14 4Copyright : (c) Alberto Ruiz 2006-14
5License : GPL 5License : BSD3
6
7Maintainer : Alberto Ruiz 6Maintainer : Alberto Ruiz
8Stability : provisional 7Stability : provisional
9 8
@@ -11,10 +10,10 @@ This module reexports the most common Linear Algebra functions.
11 10
12-} 11-}
13----------------------------------------------------------------------------- 12-----------------------------------------------------------------------------
14module Numeric.HMatrix ( 13module Numeric.LinearAlgebra.Base (
15 14
16 -- * Basic types and data processing 15 -- * Basic types and data processing
17 module Numeric.HMatrix.Data, 16 module Numeric.LinearAlgebra.Data,
18 17
19 -- | The standard numeric classes are defined elementwise: 18 -- | The standard numeric classes are defined elementwise:
20 -- 19 --
@@ -121,19 +120,20 @@ module Numeric.HMatrix (
121 corr, conv, corrMin, corr2, conv2, 120 corr, conv, corrMin, corr2, conv2,
122 121
123 -- * Random arrays 122 -- * Random arrays
124 rand, randn, RandDist(..), randomVector, gaussianSample, uniformSample, 123
124 -- | rand, randn, RandDist(..), randomVector, gaussianSample, uniformSample
125 125
126 -- * Misc 126 -- * Misc
127 meanCov, peps, relativeError, haussholder, optimiseMult, udot 127 meanCov, peps, relativeError, haussholder, optimiseMult, udot
128) where 128) where
129 129
130import Numeric.HMatrix.Data 130import Numeric.LinearAlgebra.Data
131 131
132--import Numeric.Matrix() 132import Numeric.Matrix()
133--import Numeric.Vector() 133import Numeric.Vector()
134import Numeric.Container 134import Numeric.Container
135import Numeric.LinearAlgebra.Algorithms 135import Numeric.LinearAlgebra.Algorithms
136import Numeric.LinearAlgebra.Util 136import Numeric.LinearAlgebra.Util
137import Numeric.Random 137
138 138
139 139
diff --git a/packages/hmatrix/src/Numeric/HMatrix/Data.hs b/packages/base/src/Numeric/LinearAlgebra/Data.hs
index 5d7ce4f..3bc88f9 100644
--- a/packages/hmatrix/src/Numeric/HMatrix/Data.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Data.hs
@@ -1,9 +1,8 @@
1-------------------------------------------------------------------------------- 1--------------------------------------------------------------------------------
2{- | 2{- |
3Module : Numeric.HMatrix.Data 3Module : Numeric.LinearAlgebra.Data
4Copyright : (c) Alberto Ruiz 2014 4Copyright : (c) Alberto Ruiz 2014
5License : GPL 5License : BSD3
6
7Maintainer : Alberto Ruiz 6Maintainer : Alberto Ruiz
8Stability : provisional 7Stability : provisional
9 8
@@ -12,7 +11,7 @@ Basic data processing.
12-} 11-}
13-------------------------------------------------------------------------------- 12--------------------------------------------------------------------------------
14 13
15module Numeric.HMatrix.Data( 14module Numeric.LinearAlgebra.Data(
16 15
17 -- * Vector 16 -- * Vector
18 -- | 1D arrays are storable vectors from the vector package. 17 -- | 1D arrays are storable vectors from the vector package.
@@ -44,10 +43,9 @@ module Numeric.HMatrix.Data(
44 find, maxIndex, minIndex, maxElement, minElement, atIndex, 43 find, maxIndex, minIndex, maxElement, minElement, atIndex,
45 44
46 -- * IO 45 -- * IO
47 disp, dispf, disps, dispcf, latexFormat, format, 46 disp, dispf, disps, dispcf, latexFormat, format, readMatrix,
48 loadMatrix, saveMatrix, fromFile, fileDimensions, 47
49 readMatrix, 48 -- | loadMatrix, saveMatrix, fromFile, fileDimensions, fscanfVector, fprintfVector, freadVector, fwriteVector
50 fscanfVector, fprintfVector, freadVector, fwriteVector,
51 49
52-- * Conversion 50-- * Conversion
53 Convert(..), 51 Convert(..),
@@ -64,7 +62,7 @@ module Numeric.HMatrix.Data(
64import Data.Packed.Vector 62import Data.Packed.Vector
65import Data.Packed.Matrix 63import Data.Packed.Matrix
66import Numeric.Container 64import Numeric.Container
67import Numeric.IO 65import Data.Packed.IO
68import Numeric.LinearAlgebra.Util 66import Numeric.LinearAlgebra.Util
69import Data.Complex 67import Data.Complex
70 68
diff --git a/packages/hmatrix/src/Numeric/HMatrix/Devel.hs b/packages/base/src/Numeric/LinearAlgebra/Devel.hs
index b921f44..c41db2d 100644
--- a/packages/hmatrix/src/Numeric/HMatrix/Devel.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Devel.hs
@@ -2,8 +2,7 @@
2{- | 2{- |
3Module : Numeric.HMatrix.Devel 3Module : Numeric.HMatrix.Devel
4Copyright : (c) Alberto Ruiz 2014 4Copyright : (c) Alberto Ruiz 2014
5License : GPL 5License : BSD3
6
7Maintainer : Alberto Ruiz 6Maintainer : Alberto Ruiz
8Stability : provisional 7Stability : provisional
9 8
@@ -12,7 +11,7 @@ The library can be easily extended using the tools in this module.
12-} 11-}
13-------------------------------------------------------------------------------- 12--------------------------------------------------------------------------------
14 13
15module Numeric.HMatrix.Devel( 14module Numeric.LinearAlgebra.Devel(
16 -- * FFI helpers 15 -- * FFI helpers
17 -- | Sample usage, to upload a perspective matrix to a shader. 16 -- | Sample usage, to upload a perspective matrix to a shader.
18 -- 17 --
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'.
diff --git a/packages/hmatrix/src/Numeric/Container.hs b/packages/hmatrix/src/Numeric/Container.hs
new file mode 100644
index 0000000..146780d
--- /dev/null
+++ b/packages/hmatrix/src/Numeric/Container.hs
@@ -0,0 +1,241 @@
1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE FlexibleContexts #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE MultiParamTypeClasses #-}
5{-# LANGUAGE FunctionalDependencies #-}
6{-# LANGUAGE UndecidableInstances #-}
7
8-----------------------------------------------------------------------------
9-- |
10-- Module : Numeric.Container
11-- Copyright : (c) Alberto Ruiz 2010-14
12-- License : BSD3
13-- Maintainer : Alberto Ruiz
14-- Stability : provisional
15-- Portability : portable
16--
17-- Basic numeric operations on 'Vector' and 'Matrix', including conversion routines.
18--
19-- The 'Container' class is used to define optimized generic functions which work
20-- on 'Vector' and 'Matrix' with real or complex elements.
21--
22-- Some of these functions are also available in the instances of the standard
23-- numeric Haskell classes provided by "Numeric.LinearAlgebra".
24--
25-----------------------------------------------------------------------------
26{-# OPTIONS_HADDOCK hide #-}
27
28module Numeric.Container (
29 -- * Basic functions
30 module Data.Packed,
31 konst, build,
32 linspace,
33 diag, ident,
34 ctrans,
35 -- * Generic operations
36 Container(..),
37 -- * Matrix product
38 Product(..), udot, dot, (◇),
39 Mul(..),
40 Contraction(..),
41 optimiseMult,
42 mXm,mXv,vXm,LSDiv(..),
43 outer, kronecker,
44 -- * Element conversion
45 Convert(..),
46 Complexable(),
47 RealElement(),
48
49 RealOf, ComplexOf, SingleOf, DoubleOf,
50
51 IndexOf,
52 module Data.Complex
53) where
54
55import Data.Packed hiding (stepD, stepF, condD, condF, conjugateC, conjugateQ)
56import Data.Packed.Numeric
57import Data.Complex
58import Numeric.LinearAlgebra.Algorithms(Field,linearSolveSVD)
59import Data.Monoid(Monoid(mconcat))
60
61------------------------------------------------------------------
62
63{- | Creates a real vector containing a range of values:
64
65>>> linspace 5 (-3,7::Double)
66fromList [-3.0,-0.5,2.0,4.5,7.0]@
67
68>>> linspace 5 (8,2+i) :: Vector (Complex Double)
69fromList [8.0 :+ 0.0,6.5 :+ 0.25,5.0 :+ 0.5,3.5 :+ 0.75,2.0 :+ 1.0]
70
71Logarithmic spacing can be defined as follows:
72
73@logspace n (a,b) = 10 ** linspace n (a,b)@
74-}
75linspace :: (Container Vector e) => Int -> (e, e) -> Vector e
76linspace 0 (a,b) = fromList[(a+b)/2]
77linspace n (a,b) = addConstant a $ scale s $ fromList $ map fromIntegral [0 .. n-1]
78 where s = (b-a)/fromIntegral (n-1)
79
80--------------------------------------------------------
81
82class Contraction a b c | a b -> c
83 where
84 infixl 7 <.>
85 {- | Matrix product, matrix vector product, and dot product
86
87Examples:
88
89>>> let a = (3><4) [1..] :: Matrix Double
90>>> let v = fromList [1,0,2,-1] :: Vector Double
91>>> let u = fromList [1,2,3] :: Vector Double
92
93>>> a
94(3><4)
95 [ 1.0, 2.0, 3.0, 4.0
96 , 5.0, 6.0, 7.0, 8.0
97 , 9.0, 10.0, 11.0, 12.0 ]
98
99matrix × matrix:
100
101>>> disp 2 (a <.> trans a)
1023x3
103 30 70 110
104 70 174 278
105110 278 446
106
107matrix × vector:
108
109>>> a <.> v
110fromList [3.0,11.0,19.0]
111
112dot product:
113
114>>> u <.> fromList[3,2,1::Double]
11510
116
117For complex vectors the first argument is conjugated:
118
119>>> fromList [1,i] <.> fromList[2*i+1,3]
1201.0 :+ (-1.0)
121
122>>> fromList [1,i,1-i] <.> complex a
123fromList [10.0 :+ 4.0,12.0 :+ 4.0,14.0 :+ 4.0,16.0 :+ 4.0]
124
125-}
126 (<.>) :: a -> b -> c
127
128
129instance (Product t, Container Vector t) => Contraction (Vector t) (Vector t) t where
130 u <.> v = conj u `udot` v
131
132instance Product t => Contraction (Matrix t) (Vector t) (Vector t) where
133 (<.>) = mXv
134
135instance (Container Vector t, Product t) => Contraction (Vector t) (Matrix t) (Vector t) where
136 (<.>) v m = (conj v) `vXm` m
137
138instance Product t => Contraction (Matrix t) (Matrix t) (Matrix t) where
139 (<.>) = mXm
140
141
142--------------------------------------------------------------------------------
143
144class Mul a b c | a b -> c where
145 infixl 7 <>
146 -- | Matrix-matrix, matrix-vector, and vector-matrix products.
147 (<>) :: Product t => a t -> b t -> c t
148
149instance Mul Matrix Matrix Matrix where
150 (<>) = mXm
151
152instance Mul Matrix Vector Vector where
153 (<>) m v = flatten $ m <> asColumn v
154
155instance Mul Vector Matrix Vector where
156 (<>) v m = flatten $ asRow v <> m
157
158--------------------------------------------------------------------------------
159
160class LSDiv c where
161 infixl 7 <\>
162 -- | least squares solution of a linear system, similar to the \\ operator of Matlab\/Octave (based on linearSolveSVD)
163 (<\>) :: Field t => Matrix t -> c t -> c t
164
165instance LSDiv Vector where
166 m <\> v = flatten (linearSolveSVD m (reshape 1 v))
167
168instance LSDiv Matrix where
169 (<\>) = linearSolveSVD
170
171--------------------------------------------------------------------------------
172
173class Konst e d c | d -> c, c -> d
174 where
175 -- |
176 -- >>> konst 7 3 :: Vector Float
177 -- fromList [7.0,7.0,7.0]
178 --
179 -- >>> konst i (3::Int,4::Int)
180 -- (3><4)
181 -- [ 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0
182 -- , 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0
183 -- , 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0, 0.0 :+ 1.0 ]
184 --
185 konst :: e -> d -> c e
186
187instance Container Vector e => Konst e Int Vector
188 where
189 konst = konst'
190
191instance Container Vector e => Konst e (Int,Int) Matrix
192 where
193 konst = konst'
194
195--------------------------------------------------------------------------------
196
197class Build d f c e | d -> c, c -> d, f -> e, f -> d, f -> c, c e -> f, d e -> f
198 where
199 -- |
200 -- >>> build 5 (**2) :: Vector Double
201 -- fromList [0.0,1.0,4.0,9.0,16.0]
202 --
203 -- Hilbert matrix of order N:
204 --
205 -- >>> let hilb n = build (n,n) (\i j -> 1/(i+j+1)) :: Matrix Double
206 -- >>> putStr . dispf 2 $ hilb 3
207 -- 3x3
208 -- 1.00 0.50 0.33
209 -- 0.50 0.33 0.25
210 -- 0.33 0.25 0.20
211 --
212 build :: d -> f -> c e
213
214instance Container Vector e => Build Int (e -> e) Vector e
215 where
216 build = build'
217
218instance Container Matrix e => Build (Int,Int) (e -> e -> e) Matrix e
219 where
220 build = build'
221
222--------------------------------------------------------------------------------
223
224{- | alternative operator for '(\<.\>)'
225
226x25c7, white diamond
227
228-}
229(◇) :: Contraction a b c => a -> b -> c
230infixl 7 ◇
231(◇) = (<.>)
232
233-- | dot product: @cdot u v = 'udot' ('conj' u) v@
234dot :: (Container Vector t, Product t) => Vector t -> Vector t -> t
235dot u v = udot (conj u) v
236
237--------------------------------------------------------------------------------
238
239optimiseMult :: Monoid (Matrix t) => [Matrix t] -> Matrix t
240optimiseMult = mconcat
241