diff options
-rw-r--r-- | CHANGES.md | 2 | ||||
-rw-r--r-- | THANKS.md | 4 | ||||
-rw-r--r-- | examples/integrate.hs | 11 |
3 files changed, 15 insertions, 2 deletions
@@ -1,6 +1,8 @@ | |||
1 | 0.15.0.0 | 1 | 0.15.0.0 |
2 | -------- | 2 | -------- |
3 | 3 | ||
4 | - Data.Packed.Foreign (additional FFI helpers) | ||
5 | |||
4 | - diagBlock | 6 | - diagBlock |
5 | 7 | ||
6 | - NFData instance of Matrix | 8 | - NFData instance of Matrix |
@@ -122,3 +122,7 @@ module reorganization, monadic mapVectorM, and many other improvements. | |||
122 | 122 | ||
123 | - Alex Lang implemented uniRoot and uniRootJ for one-dimensional root-finding. | 123 | - Alex Lang implemented uniRoot and uniRootJ for one-dimensional root-finding. |
124 | 124 | ||
125 | - Mike Ledger contributed alternative FFI helpers for matrix interoperation with C | ||
126 | |||
127 | - Stephen J. Barr suggested flipping argument order in the double integral example | ||
128 | |||
diff --git a/examples/integrate.hs b/examples/integrate.hs index 10f0269..3a03da6 100644 --- a/examples/integrate.hs +++ b/examples/integrate.hs | |||
@@ -4,14 +4,21 @@ import Numeric.GSL | |||
4 | quad f a b = fst $ integrateQAGS 1E-9 100 f a b | 4 | quad f a b = fst $ integrateQAGS 1E-9 100 f a b |
5 | 5 | ||
6 | -- A multiple integral can be easily defined using partial application | 6 | -- A multiple integral can be easily defined using partial application |
7 | quad2 f a b g1 g2 = quad h a b | 7 | quad2 f y1 y2 g1 g2 = quad h y1 y2 |
8 | where h x = quad (f x) (g1 x) (g2 x) | 8 | where |
9 | h y = quad (flip f y) (g1 y) (g2 y) | ||
9 | 10 | ||
10 | volSphere r = 8 * quad2 (\x y -> sqrt (r*r-x*x-y*y)) | 11 | volSphere r = 8 * quad2 (\x y -> sqrt (r*r-x*x-y*y)) |
11 | 0 r (const 0) (\x->sqrt (r*r-x*x)) | 12 | 0 r (const 0) (\x->sqrt (r*r-x*x)) |
12 | 13 | ||
14 | -- wikipedia example | ||
15 | exw = quad2 f 7 10 (const 11) (const 14) | ||
16 | where | ||
17 | f x y = x**2 + 4*y | ||
18 | |||
13 | main = do | 19 | main = do |
14 | print $ quad (\x -> 4/(x^2+1)) 0 1 | 20 | print $ quad (\x -> 4/(x^2+1)) 0 1 |
15 | print pi | 21 | print pi |
16 | print $ volSphere 2.5 | 22 | print $ volSphere 2.5 |
17 | print $ 4/3*pi*2.5**3 | 23 | print $ 4/3*pi*2.5**3 |
24 | print $ exw | ||