summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/oldtests.hs5
-rw-r--r--examples/tests.hs35
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs2
-rw-r--r--lib/Data/Packed/Matrix.hs4
-rw-r--r--lib/GSL/gsl-aux.c2
-rw-r--r--lib/LinearAlgebra/Interface.hs2
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 @@
1import Test.HUnit 1import Test.HUnit
2import GSLHaskell 2import LinearAlgebra
3import GSL hiding (exp)
3import System.Random(randomRs,mkStdGen) 4import System.Random(randomRs,mkStdGen)
4 5
5realMatrix = fromLists :: [[Double]] -> Matrix Double 6realMatrix = fromLists :: [[Double]] -> Matrix Double
@@ -8,7 +9,7 @@ realVector = fromList :: [Double] -> Vector Double
8 9
9 10
10infixl 2 =~= 11infixl 2 =~=
11a =~= b = pnorm 1 (flatten (a - b)) < 1E-6 12a =~= b = pnorm PNorm1 (flatten (a - b)) < 1E-6
12 13
13randomMatrix seed (n,m) = reshape m $ realVector $ take (n*m) $ randomRs (-100,100) $ mkStdGen seed 14randomMatrix 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
9import Data.Packed.Internal((>|<), fdat, cdat, multiply', multiplyG, MatrixOrder(..)) 9import Data.Packed.Internal((>|<), fdat, cdat, multiply', multiplyG, MatrixOrder(..))
10import Data.Packed.Vector 10import GSL hiding (sin,cos,exp,choose)
11import Data.Packed.Matrix 11import LinearAlgebra hiding ((<>))
12import GSL.Vector
13import GSL.Integration
14import GSL.Differentiation
15import GSL.Special hiding (choose, multiply, exp)
16import GSL.Fourier
17import GSL.Polynomials
18import LAPACK
19import Test.QuickCheck 12import Test.QuickCheck
20import Test.HUnit hiding ((~:)) 13import Test.HUnit hiding ((~:))
21import Complex 14
22import LinearAlgebra.Algorithms
23import LinearAlgebra.Linear hiding ((<>))
24import GSL.Matrix
25import GSLHaskell hiding ((<>),constant)
26 15
27dist :: (Normed t, Num t) => t -> t -> Double 16dist :: (Normed t, Num t) => t -> t -> Double
28dist a b = norm (a-b) 17dist a b = pnorm Infinity (a-b)
29 18
30infixl 4 |~| 19infixl 4 |~|
31a |~| b = a :~8~: b 20a |~| 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
283arit1 u = vectorMapValR PowVS 2 (vectorMapR Sin u) 272arit1 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
287arit2 u = (vectorMapR Cos u) `mul` (vectorMapR Tan u) 275arit2 u = sin u ** 2 + cos u ** 2 |~| 1
288 |~| vectorMapR Sin u 276 where _ = u :: Vector Double
289 277
278arit3 u = cos u * tan u |~| sin u
279 where _ = u :: Vector Double
290 280
291-- arit3 (PairV u v) = 281arit4 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
3507 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@ 3507 |> [2.0,2.0,2.0,2.0,2.0,2.0,2.0]@
351-} 351-}
352constant :: Double -> Int -> Vector Double 352constant :: Field a => a -> Int -> Vector a
353constant = constantD 353constant = 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
33import Data.Packed.Internal 33import Data.Packed.Internal
@@ -95,7 +95,7 @@ takeDiag :: (Field t) => Matrix t -> Vector t
95takeDiag m = fromList [cdat m `at` (k*cols m+k) | k <- [0 .. min (rows m) (cols m) -1]] 95takeDiag 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
98ident :: Int -> Matrix Double 98ident :: Field a => Int -> Matrix a
99ident n = diag (constant 1 n) 99ident 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
52infixl 7 .* 52infixl 7 .*
53a .* x = scale a x 53a .* x = scale a x