diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-09-19 08:59:32 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-09-19 08:59:32 +0000 |
commit | f39ad090513e48fc2cbaf421c8b39fa3ca12a221 (patch) | |
tree | b42f3b473034a301f11e25d82b902be2ce39db4f /examples | |
parent | e34d5566b9abfd235ce210f9f9909b23d52bd138 (diff) |
minor changes
Diffstat (limited to 'examples')
-rw-r--r-- | examples/oldtests.hs | 5 | ||||
-rw-r--r-- | examples/tests.hs | 35 |
2 files changed, 17 insertions, 23 deletions
diff --git a/examples/oldtests.hs b/examples/oldtests.hs index f60f4e2..7d4701c 100644 --- a/examples/oldtests.hs +++ b/examples/oldtests.hs | |||
@@ -1,5 +1,6 @@ | |||
1 | import Test.HUnit | 1 | import Test.HUnit |
2 | import GSLHaskell | 2 | import LinearAlgebra |
3 | import GSL hiding (exp) | ||
3 | import System.Random(randomRs,mkStdGen) | 4 | import System.Random(randomRs,mkStdGen) |
4 | 5 | ||
5 | realMatrix = fromLists :: [[Double]] -> Matrix Double | 6 | realMatrix = fromLists :: [[Double]] -> Matrix Double |
@@ -8,7 +9,7 @@ realVector = fromList :: [Double] -> Vector Double | |||
8 | 9 | ||
9 | 10 | ||
10 | infixl 2 =~= | 11 | infixl 2 =~= |
11 | a =~= b = pnorm 1 (flatten (a - b)) < 1E-6 | 12 | a =~= b = pnorm PNorm1 (flatten (a - b)) < 1E-6 |
12 | 13 | ||
13 | randomMatrix seed (n,m) = reshape m $ realVector $ take (n*m) $ randomRs (-100,100) $ mkStdGen seed | 14 | randomMatrix seed (n,m) = reshape m $ realVector $ take (n*m) $ randomRs (-100,100) $ mkStdGen seed |
14 | 15 | ||
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 |