summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--THANKS2
-rw-r--r--examples/fitting.hs24
-rw-r--r--hmatrix.cabal7
-rw-r--r--lib/Data/Packed/Matrix.hs6
4 files changed, 32 insertions, 7 deletions
diff --git a/THANKS b/THANKS
index 0132938..f3fb949 100644
--- a/THANKS
+++ b/THANKS
@@ -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
3import Numeric.GSL.Fitting
4import Numeric.LinearAlgebra
5
6xs = map return [0 .. 39]
7sigma = 0.1
8ys = map return $ toList $ fromList (map (head . expModel [5,0.1,1]) xs)
9 + scalar sigma * (randomVector 0 Gaussian 40)
10
11dat :: [([Double],([Double],Double))]
12
13dat = zip xs (zip ys (repeat sigma))
14
15expModel [a,lambda,b] [t] = [a * exp (-lambda * t) + b]
16
17expModelDer [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
21main = 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 @@
1Name: hmatrix 1Name: hmatrix
2Version: 0.12.0.1 2Version: 0.12.0.2
3License: GPL 3License: GPL
4License-file: LICENSE 4License-file: LICENSE
5Author: Alberto Ruiz 5Author: Alberto Ruiz
@@ -216,9 +216,8 @@ library
216 extra-lib-dirs: 216 extra-lib-dirs:
217 217
218source-repository head 218source-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
206Example: 206Example:
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
268Hilbert matrix of order N: 268Hilbert 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-}
273buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a 273buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a