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 | |
parent | e34d5566b9abfd235ce210f9f9909b23d52bd138 (diff) |
minor changes
-rw-r--r-- | examples/oldtests.hs | 5 | ||||
-rw-r--r-- | examples/tests.hs | 35 | ||||
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 2 | ||||
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 4 | ||||
-rw-r--r-- | lib/GSL/gsl-aux.c | 2 | ||||
-rw-r--r-- | lib/LinearAlgebra/Interface.hs | 2 |
6 files changed, 22 insertions, 28 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 |
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 951cec6..63ebddf 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -349,7 +349,7 @@ foreign import ccall safe "aux.h constantC" | |||
349 | @> constant 2 7 | 349 | @> constant 2 7 |
350 | 7 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@ | 350 | 7 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@ |
351 | -} | 351 | -} |
352 | constant :: Double -> Int -> Vector Double | 352 | constant :: Field a => a -> Int -> Vector a |
353 | constant = constantD | 353 | constant = constantD |
354 | 354 | ||
355 | -------------------------------------------------------------------------- | 355 | -------------------------------------------------------------------------- |
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index 5a4b919..404fde7 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -27,7 +27,7 @@ module Data.Packed.Matrix ( | |||
27 | subMatrix, takeRows, dropRows, takeColumns, dropColumns, | 27 | subMatrix, takeRows, dropRows, takeColumns, dropColumns, |
28 | ident, diag, diagRect, takeDiag, | 28 | ident, diag, diagRect, takeDiag, |
29 | liftMatrix, liftMatrix2, | 29 | liftMatrix, liftMatrix2, |
30 | dispR, readMatrix, fromArray2D | 30 | format, dispR, readMatrix, fromArray2D |
31 | ) where | 31 | ) where |
32 | 32 | ||
33 | import Data.Packed.Internal | 33 | import Data.Packed.Internal |
@@ -95,7 +95,7 @@ takeDiag :: (Field t) => Matrix t -> Vector t | |||
95 | takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] | 95 | takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] |
96 | 96 | ||
97 | -- | creates the identity matrix of given dimension | 97 | -- | creates the identity matrix of given dimension |
98 | ident :: Int -> Matrix Double | 98 | ident :: Field a => Int -> Matrix a |
99 | ident n = diag (constant 1 n) | 99 | ident n = diag (constant 1 n) |
100 | 100 | ||
101 | ------------------------------------------------------------ | 101 | ------------------------------------------------------------ |
diff --git a/lib/GSL/gsl-aux.c b/lib/GSL/gsl-aux.c index c2839a8..0e8406c 100644 --- a/lib/GSL/gsl-aux.c +++ b/lib/GSL/gsl-aux.c | |||
@@ -229,7 +229,7 @@ int mapValCAux(int code, gsl_complex* pval, KGCVEC(x), GCVEC(r)) { | |||
229 | OPV(2,gsl_complex_add(val,xp[k])) | 229 | OPV(2,gsl_complex_add(val,xp[k])) |
230 | OPV(3,gsl_complex_sub(val,xp[k])) | 230 | OPV(3,gsl_complex_sub(val,xp[k])) |
231 | OPV(4,gsl_complex_pow(val,xp[k])) | 231 | OPV(4,gsl_complex_pow(val,xp[k])) |
232 | OPV(5,gsl_complex_pow(val,xp[k])) | 232 | OPV(5,gsl_complex_pow(xp[k],val)) |
233 | default: ERROR(BAD_CODE); | 233 | default: ERROR(BAD_CODE); |
234 | } | 234 | } |
235 | } | 235 | } |
diff --git a/lib/LinearAlgebra/Interface.hs b/lib/LinearAlgebra/Interface.hs index 7d6ff0f..0d2c0a0 100644 --- a/lib/LinearAlgebra/Interface.hs +++ b/lib/LinearAlgebra/Interface.hs | |||
@@ -47,7 +47,7 @@ infixl 7 <.> | |||
47 | 47 | ||
48 | ---------------------------------------------------- | 48 | ---------------------------------------------------- |
49 | 49 | ||
50 | -- | @x .* a = scale (recip x) v@ | 50 | -- | @x .* a = scale x a@ |
51 | (.*) :: (Linear c a) => a -> c a -> c a | 51 | (.*) :: (Linear c a) => a -> c a -> c a |
52 | infixl 7 .* | 52 | infixl 7 .* |
53 | a .* x = scale a x | 53 | a .* x = scale a x |