diff options
-rw-r--r-- | THANKS | 2 | ||||
-rw-r--r-- | examples/fitting.hs | 24 | ||||
-rw-r--r-- | hmatrix.cabal | 7 | ||||
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 6 |
4 files changed, 32 insertions, 7 deletions
@@ -103,3 +103,5 @@ module reorganization, monadic mapVectorM, and many other improvements. | |||
103 | - Tom Nielsen discovered a problem in Config.hs, exposed by link problems | 103 | - Tom Nielsen discovered a problem in Config.hs, exposed by link problems |
104 | in Ubuntu 11.10 beta. | 104 | in Ubuntu 11.10 beta. |
105 | 105 | ||
106 | - Daniel Fischer reported some Haddock markup errors. | ||
107 | |||
diff --git a/examples/fitting.hs b/examples/fitting.hs new file mode 100644 index 0000000..a8f6b1c --- /dev/null +++ b/examples/fitting.hs | |||
@@ -0,0 +1,24 @@ | |||
1 | -- nonlinear least-squares fitting | ||
2 | |||
3 | import Numeric.GSL.Fitting | ||
4 | import Numeric.LinearAlgebra | ||
5 | |||
6 | xs = map return [0 .. 39] | ||
7 | sigma = 0.1 | ||
8 | ys = map return $ toList $ fromList (map (head . expModel [5,0.1,1]) xs) | ||
9 | + scalar sigma * (randomVector 0 Gaussian 40) | ||
10 | |||
11 | dat :: [([Double],([Double],Double))] | ||
12 | |||
13 | dat = zip xs (zip ys (repeat sigma)) | ||
14 | |||
15 | expModel [a,lambda,b] [t] = [a * exp (-lambda * t) + b] | ||
16 | |||
17 | expModelDer [a,lambda,b] [t] = [[exp (-lambda * t), -t * a * exp(-lambda*t) , 1]] | ||
18 | |||
19 | (sol,path) = fitModelScaled 1E-4 1E-4 20 (expModel, expModelDer) dat [1,0,0] | ||
20 | |||
21 | main = do | ||
22 | print dat | ||
23 | print path | ||
24 | print sol | ||
diff --git a/hmatrix.cabal b/hmatrix.cabal index 51ed4dd..576a6df 100644 --- a/hmatrix.cabal +++ b/hmatrix.cabal | |||
@@ -1,5 +1,5 @@ | |||
1 | Name: hmatrix | 1 | Name: hmatrix |
2 | Version: 0.12.0.1 | 2 | Version: 0.12.0.2 |
3 | License: GPL | 3 | License: GPL |
4 | License-file: LICENSE | 4 | License-file: LICENSE |
5 | Author: Alberto Ruiz | 5 | Author: Alberto Ruiz |
@@ -216,9 +216,8 @@ library | |||
216 | extra-lib-dirs: | 216 | extra-lib-dirs: |
217 | 217 | ||
218 | source-repository head | 218 | source-repository head |
219 | type: darcs | 219 | type: git |
220 | location: http://patch-tag.com/r/aruiz/hmatrix | 220 | location: https://github.com/AlbertoRuiz/hmatrix |
221 | -- location: http://code.haskell.org/hmatrix | ||
222 | 221 | ||
223 | -- Test-Suite tests | 222 | -- Test-Suite tests |
224 | -- type: exitcode-stdio-1.0 | 223 | -- type: exitcode-stdio-1.0 |
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 27fa36c..ca96c50 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -205,7 +205,7 @@ safely be used with lists that are too long (like infinite lists). | |||
205 | 205 | ||
206 | Example: | 206 | Example: |
207 | 207 | ||
208 | @\> (2>|<3)[1..] | 208 | @\> (2><3)[1..] |
209 | (2><3) | 209 | (2><3) |
210 | [ 1.0, 2.0, 3.0 | 210 | [ 1.0, 2.0, 3.0 |
211 | , 4.0, 5.0, 6.0 ]@ | 211 | , 4.0, 5.0, 6.0 ]@ |
@@ -259,7 +259,7 @@ asColumn v = reshape 1 v | |||
259 | {- | creates a Matrix of the specified size using the supplied function to | 259 | {- | creates a Matrix of the specified size using the supplied function to |
260 | to map the row\/column position to the value at that row\/column position. | 260 | to map the row\/column position to the value at that row\/column position. |
261 | 261 | ||
262 | @> buildMatrix 3 4 (\ (r,c) -> fromIntegral r * fromIntegral c) | 262 | @> buildMatrix 3 4 (\\(r,c) -> fromIntegral r * fromIntegral c) |
263 | (3><4) | 263 | (3><4) |
264 | [ 0.0, 0.0, 0.0, 0.0, 0.0 | 264 | [ 0.0, 0.0, 0.0, 0.0, 0.0 |
265 | , 0.0, 1.0, 2.0, 3.0, 4.0 | 265 | , 0.0, 1.0, 2.0, 3.0, 4.0 |
@@ -267,7 +267,7 @@ asColumn v = reshape 1 v | |||
267 | 267 | ||
268 | Hilbert matrix of order N: | 268 | Hilbert matrix of order N: |
269 | 269 | ||
270 | @hilb n = buildMatrix n n (\(i,j)->1/(fromIntegral i + fromIntegral j +1))@ | 270 | @hilb n = buildMatrix n n (\\(i,j)->1/(fromIntegral i + fromIntegral j +1))@ |
271 | 271 | ||
272 | -} | 272 | -} |
273 | buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a | 273 | buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a |