diff options
-rw-r--r-- | hmatrix.cabal | 4 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Real.hs (renamed from examples/Real.hs) | 29 |
2 files changed, 25 insertions, 8 deletions
diff --git a/hmatrix.cabal b/hmatrix.cabal index 049d4d5..a772746 100644 --- a/hmatrix.cabal +++ b/hmatrix.cabal | |||
@@ -49,7 +49,6 @@ extra-source-files: examples/deriv.hs | |||
49 | examples/devel/ej1/functions.c | 49 | examples/devel/ej1/functions.c |
50 | examples/devel/ej2/wrappers.hs | 50 | examples/devel/ej2/wrappers.hs |
51 | examples/devel/ej2/functions.c | 51 | examples/devel/ej2/functions.c |
52 | examples/Real.hs | ||
53 | examples/vector.hs | 52 | examples/vector.hs |
54 | examples/monadic.hs | 53 | examples/monadic.hs |
55 | examples/bool.hs | 54 | examples/bool.hs |
@@ -87,7 +86,7 @@ library | |||
87 | Build-Depends: base >= 4 && < 5, | 86 | Build-Depends: base >= 4 && < 5, |
88 | array, | 87 | array, |
89 | storable-complex, | 88 | storable-complex, |
90 | process, | 89 | process, random, |
91 | vector >= 0.8, | 90 | vector >= 0.8, |
92 | binary | 91 | binary |
93 | 92 | ||
@@ -111,6 +110,7 @@ library | |||
111 | Numeric.LinearAlgebra, | 110 | Numeric.LinearAlgebra, |
112 | Numeric.LinearAlgebra.LAPACK, | 111 | Numeric.LinearAlgebra.LAPACK, |
113 | Numeric.LinearAlgebra.Algorithms, | 112 | Numeric.LinearAlgebra.Algorithms, |
113 | Numeric.LinearAlgebra.Real, | ||
114 | Graphics.Plot, | 114 | Graphics.Plot, |
115 | Data.Packed.ST, | 115 | Data.Packed.ST, |
116 | Data.Packed.Development | 116 | Data.Packed.Development |
diff --git a/examples/Real.hs b/lib/Numeric/LinearAlgebra/Real.hs index 9083b87..6cba045 100644 --- a/examples/Real.hs +++ b/lib/Numeric/LinearAlgebra/Real.hs | |||
@@ -1,10 +1,21 @@ | |||
1 | ----------------------------------------------------------------------------- | ||
2 | {- | | ||
3 | Module : Numeric.LinearAlgebra.Real | ||
4 | Copyright : (c) Alberto Ruiz 2012 | ||
5 | License : GPL | ||
1 | 6 | ||
2 | -- Alternative interface and utilities for creation of real arrays, useful to work in interactive mode. | 7 | Maintainer : Alberto Ruiz (aruiz at um dot es) |
8 | Stability : provisional | ||
3 | 9 | ||
4 | module Real( | 10 | Additional functions for real arrays. |
5 | module Numeric.LinearAlgebra, | 11 | |
12 | -} | ||
13 | ----------------------------------------------------------------------------- | ||
14 | |||
15 | module Numeric.LinearAlgebra.Real( | ||
6 | (<>), (*>), (<*), (<\>), (\>), | 16 | (<>), (*>), (<*), (<\>), (\>), |
7 | vector, | 17 | vector, |
18 | linspace, | ||
8 | eye, | 19 | eye, |
9 | zeros, ones, | 20 | zeros, ones, |
10 | diagl, | 21 | diagl, |
@@ -14,9 +25,14 @@ module Real( | |||
14 | rand, randn | 25 | rand, randn |
15 | ) where | 26 | ) where |
16 | 27 | ||
17 | import Numeric.LinearAlgebra hiding ((<>), (<\>)) | 28 | import Numeric.LinearAlgebra hiding ((<>), (<\>), linspace) |
29 | import qualified Numeric.LinearAlgebra as LA | ||
18 | import System.Random(randomIO) | 30 | import System.Random(randomIO) |
19 | 31 | ||
32 | linspace :: Int -> (Double,Double) -> Vector Double | ||
33 | linspace = LA.linspace | ||
34 | |||
35 | |||
20 | infixl 7 <> | 36 | infixl 7 <> |
21 | -- | Matrix product ('multiply') | 37 | -- | Matrix product ('multiply') |
22 | (<>) :: Field t => Matrix t -> Matrix t -> Matrix t | 38 | (<>) :: Field t => Matrix t -> Matrix t -> Matrix t |
@@ -95,15 +111,16 @@ infixl 8 & | |||
95 | a & b = fromBlocks [[a,b]] | 111 | a & b = fromBlocks [[a,b]] |
96 | 112 | ||
97 | -- | Vertical concatenation of real matrices. | 113 | -- | Vertical concatenation of real matrices. |
98 | infixl 7 // | ||
99 | (//) :: Matrix Double -> Matrix Double -> Matrix Double | 114 | (//) :: Matrix Double -> Matrix Double -> Matrix Double |
115 | infixl 7 // | ||
100 | a // b = fromBlocks [[a],[b]] | 116 | a // b = fromBlocks [[a],[b]] |
101 | 117 | ||
118 | |||
102 | -- | Real block matrix from a rectangular list of lists. | 119 | -- | Real block matrix from a rectangular list of lists. |
103 | blocks :: [[Matrix Double]] -> Matrix Double | 120 | blocks :: [[Matrix Double]] -> Matrix Double |
104 | blocks = fromBlocks | 121 | blocks = fromBlocks |
105 | 122 | ||
106 | -- | A real matrix with a single row, create from a list of elements. | 123 | -- | A real matrix with a single row, created from a list of elements. |
107 | row :: [Double] -> Matrix Double | 124 | row :: [Double] -> Matrix Double |
108 | row = asRow . vector | 125 | row = asRow . vector |
109 | 126 | ||