diff options
Diffstat (limited to 'examples/tests.hs')
-rw-r--r-- | examples/tests.hs | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/examples/tests.hs b/examples/tests.hs index f352b71..dcc3cbf 100644 --- a/examples/tests.hs +++ b/examples/tests.hs | |||
@@ -7,25 +7,14 @@ | |||
7 | ----------------------------------------------------------------------------- | 7 | ----------------------------------------------------------------------------- |
8 | 8 | ||
9 | import Data.Packed.Internal((>|<), fdat, cdat, multiply', multiplyG, MatrixOrder(..)) | 9 | import Data.Packed.Internal((>|<), fdat, cdat, multiply', multiplyG, MatrixOrder(..)) |
10 | import Data.Packed.Vector | 10 | import GSL hiding (sin,cos,exp,choose) |
11 | import Data.Packed.Matrix | 11 | import LinearAlgebra hiding ((<>)) |
12 | import GSL.Vector | ||
13 | import GSL.Integration | ||
14 | import GSL.Differentiation | ||
15 | import GSL.Special hiding (choose, multiply, exp) | ||
16 | import GSL.Fourier | ||
17 | import GSL.Polynomials | ||
18 | import LAPACK | ||
19 | import Test.QuickCheck | 12 | import Test.QuickCheck |
20 | import Test.HUnit hiding ((~:)) | 13 | import Test.HUnit hiding ((~:)) |
21 | import Complex | 14 | |
22 | import LinearAlgebra.Algorithms | ||
23 | import LinearAlgebra.Linear hiding ((<>)) | ||
24 | import GSL.Matrix | ||
25 | import GSLHaskell hiding ((<>),constant) | ||
26 | 15 | ||
27 | dist :: (Normed t, Num t) => t -> t -> Double | 16 | dist :: (Normed t, Num t) => t -> t -> Double |
28 | dist a b = norm (a-b) | 17 | dist a b = pnorm Infinity (a-b) |
29 | 18 | ||
30 | infixl 4 |~| | 19 | infixl 4 |~| |
31 | a |~| b = a :~8~: b | 20 | a |~| b = a :~8~: b |
@@ -280,15 +269,17 @@ integrateTest = assertBool "integrate" (abs (volSphere 2.5 - 4/3*pi*2.5^3) < eps | |||
280 | 269 | ||
281 | --------------------------------------------------------------------- | 270 | --------------------------------------------------------------------- |
282 | 271 | ||
283 | arit1 u = vectorMapValR PowVS 2 (vectorMapR Sin u) | 272 | arit1 u = sin u ^ 2 + cos u ^ 2 |~| 1 |
284 | `add` vectorMapValR PowVS 2 (vectorMapR Cos u) | 273 | where _ = u :: Vector Double |
285 | |~| constant 1 (dim u) | ||
286 | 274 | ||
287 | arit2 u = (vectorMapR Cos u) `mul` (vectorMapR Tan u) | 275 | arit2 u = sin u ** 2 + cos u ** 2 |~| 1 |
288 | |~| vectorMapR Sin u | 276 | where _ = u :: Vector Double |
289 | 277 | ||
278 | arit3 u = cos u * tan u |~| sin u | ||
279 | where _ = u :: Vector Double | ||
290 | 280 | ||
291 | -- arit3 (PairV u v) = | 281 | arit4 u = (cos u * tan u) :~6~: sin u |
282 | where _ = u :: Vector (Complex Double) | ||
292 | 283 | ||
293 | --------------------------------------------------------------------- | 284 | --------------------------------------------------------------------- |
294 | 285 | ||
@@ -347,6 +338,8 @@ main = do | |||
347 | putStrLn "--------- VEC OPER ------" | 338 | putStrLn "--------- VEC OPER ------" |
348 | quickCheck arit1 | 339 | quickCheck arit1 |
349 | quickCheck arit2 | 340 | quickCheck arit2 |
341 | quickCheck arit3 | ||
342 | quickCheck arit4 | ||
350 | putStrLn "--------- GSL ------" | 343 | putStrLn "--------- GSL ------" |
351 | runTestTT tests | 344 | runTestTT tests |
352 | quickCheck $ \v -> ifft (fft v) |~| v | 345 | quickCheck $ \v -> ifft (fft v) |~| v |