diff options
-rw-r--r-- | examples/lie.hs | 7 | ||||
-rw-r--r-- | lib/Data/Packed/Random.hs | 3 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Interface.hs | 4 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests.hs | 6 | ||||
-rw-r--r-- | lib/Numeric/LinearAlgebra/Tests/Instances.hs | 2 |
5 files changed, 13 insertions, 9 deletions
diff --git a/examples/lie.hs b/examples/lie.hs index 87f7ed1..db21ea8 100644 --- a/examples/lie.hs +++ b/examples/lie.hs | |||
@@ -1,9 +1,8 @@ | |||
1 | -- The magic of Lie Algebra | 1 | -- The magic of Lie Algebra |
2 | 2 | ||
3 | import Numeric.LinearAlgebra | 3 | import Numeric.LinearAlgebra |
4 | import Text.Printf(printf) | ||
5 | 4 | ||
6 | disp = putStrLn . format " " (printf "%.5f") | 5 | disp = putStrLn . dispf 5 |
7 | 6 | ||
8 | rot1 :: Double -> Matrix Double | 7 | rot1 :: Double -> Matrix Double |
9 | rot1 a = (3><3) | 8 | rot1 a = (3><3) |
@@ -50,14 +49,14 @@ infix 8 & | |||
50 | a & b = a <> b - b <> a | 49 | a & b = a <> b - b <> a |
51 | 50 | ||
52 | infixl 6 |+| | 51 | infixl 6 |+| |
53 | a |+| b = a + b + a & b */2 + (a-b) & (a & b) */12 | 52 | a |+| b = a + b + a&b /2 + (a-b)&(a & b) /12 |
54 | 53 | ||
55 | main = do | 54 | main = do |
56 | let a = 45*deg | 55 | let a = 45*deg |
57 | b = 50*deg | 56 | b = 50*deg |
58 | c = -30*deg | 57 | c = -30*deg |
59 | exact = rot3 a <> rot1 b <> rot2 c | 58 | exact = rot3 a <> rot1 b <> rot2 c |
60 | lie = a.*g3 |+| b.*g1 |+| c.*g2 | 59 | lie = scalar a * g3 |+| scalar b * g1 |+| scalar c * g2 |
61 | putStrLn "position in the tangent space:" | 60 | putStrLn "position in the tangent space:" |
62 | disp lie | 61 | disp lie |
63 | putStrLn "exponential map back to the group (2 terms):" | 62 | putStrLn "exponential map back to the group (2 terms):" |
diff --git a/lib/Data/Packed/Random.hs b/lib/Data/Packed/Random.hs index a6145be..fea3cdd 100644 --- a/lib/Data/Packed/Random.hs +++ b/lib/Data/Packed/Random.hs | |||
@@ -21,6 +21,7 @@ module Data.Packed.Random ( | |||
21 | 21 | ||
22 | import Numeric.GSL.Vector | 22 | import Numeric.GSL.Vector |
23 | import Data.Packed | 23 | import Data.Packed |
24 | import Numeric.LinearAlgebra.Linear | ||
24 | import Numeric.LinearAlgebra.Algorithms | 25 | import Numeric.LinearAlgebra.Algorithms |
25 | import Numeric.LinearAlgebra.Instances() | 26 | import Numeric.LinearAlgebra.Instances() |
26 | import Numeric.LinearAlgebra.Interface | 27 | import Numeric.LinearAlgebra.Interface |
@@ -54,7 +55,7 @@ uniformSample seed n rgs = m where | |||
54 | d = dim a | 55 | d = dim a |
55 | dat = toRows $ reshape n $ randomVector seed Uniform (n*d) | 56 | dat = toRows $ reshape n $ randomVector seed Uniform (n*d) |
56 | am = constant 1 n `outer` a | 57 | am = constant 1 n `outer` a |
57 | m = fromColumns (zipWith (.*) cs dat) + am | 58 | m = fromColumns (zipWith scale cs dat) + am |
58 | 59 | ||
59 | ------------ utilities ------------------------------- | 60 | ------------ utilities ------------------------------- |
60 | 61 | ||
diff --git a/lib/Numeric/LinearAlgebra/Interface.hs b/lib/Numeric/LinearAlgebra/Interface.hs index 0ae9698..509b91c 100644 --- a/lib/Numeric/LinearAlgebra/Interface.hs +++ b/lib/Numeric/LinearAlgebra/Interface.hs | |||
@@ -49,6 +49,8 @@ infixl 7 <.> | |||
49 | 49 | ||
50 | ---------------------------------------------------- | 50 | ---------------------------------------------------- |
51 | 51 | ||
52 | {-# DEPRECATED (.*) "use scale a x or scalar a * x" #-} | ||
53 | |||
52 | -- | @x .* a = scale x a@ | 54 | -- | @x .* a = scale x a@ |
53 | (.*) :: (Linear c a) => a -> c a -> c a | 55 | (.*) :: (Linear c a) => a -> c a -> c a |
54 | infixl 7 .* | 56 | infixl 7 .* |
@@ -56,6 +58,8 @@ a .* x = scale a x | |||
56 | 58 | ||
57 | ---------------------------------------------------- | 59 | ---------------------------------------------------- |
58 | 60 | ||
61 | {-# DEPRECATED (*/) "use scale (recip a) x or x / scalar a" #-} | ||
62 | |||
59 | -- | @a *\/ x = scale (recip x) a@ | 63 | -- | @a *\/ x = scale (recip x) a@ |
60 | (*/) :: (Linear c a) => c a -> a -> c a | 64 | (*/) :: (Linear c a) => c a -> a -> c a |
61 | infixl 7 */ | 65 | infixl 7 */ |
diff --git a/lib/Numeric/LinearAlgebra/Tests.hs b/lib/Numeric/LinearAlgebra/Tests.hs index 063ae86..c1dae4a 100644 --- a/lib/Numeric/LinearAlgebra/Tests.hs +++ b/lib/Numeric/LinearAlgebra/Tests.hs | |||
@@ -262,8 +262,8 @@ runTests n = do | |||
262 | , utest "expm1" (expmTest1) | 262 | , utest "expm1" (expmTest1) |
263 | , utest "expm2" (expmTest2) | 263 | , utest "expm2" (expmTest2) |
264 | , utest "arith1" $ ((ones (100,100) * 5 + 2)/0.5 - 7)**2 |~| (49 :: RM) | 264 | , utest "arith1" $ ((ones (100,100) * 5 + 2)/0.5 - 7)**2 |~| (49 :: RM) |
265 | , utest "arith2" $ (((1+i) .* ones (100,100) * 5 + 2)/0.5 - 7)**2 |~| ( (140*i-51).*1 :: CM) | 265 | , utest "arith2" $ ((scalar (1+i) * ones (100,100) * 5 + 2)/0.5 - 7)**2 |~| ( scalar (140*i-51) :: CM) |
266 | , utest "arith3" $ exp (i.*ones(10,10)*pi) + 1 |~| 0 | 266 | , utest "arith3" $ exp (scalar i * ones(10,10)*pi) + 1 |~| 0 |
267 | , utest "<\\>" $ (3><2) [2,0,0,3,1,1::Double] <\> 3|>[4,9,5] |~| 2|>[2,3] | 267 | , utest "<\\>" $ (3><2) [2,0,0,3,1,1::Double] <\> 3|>[4,9,5] |~| 2|>[2,3] |
268 | , utest "gamma" (gamma 5 == 24.0) | 268 | , utest "gamma" (gamma 5 == 24.0) |
269 | , besselTest | 269 | , besselTest |
@@ -282,7 +282,7 @@ runTests n = do | |||
282 | ] | 282 | ] |
283 | return () | 283 | return () |
284 | 284 | ||
285 | makeUnitary v | realPart n > 1 = v */ n | 285 | makeUnitary v | realPart n > 1 = v / scalar n |
286 | | otherwise = v | 286 | | otherwise = v |
287 | where n = sqrt (conj v <.> v) | 287 | where n = sqrt (conj v <.> v) |
288 | 288 | ||
diff --git a/lib/Numeric/LinearAlgebra/Tests/Instances.hs b/lib/Numeric/LinearAlgebra/Tests/Instances.hs index 4995e39..d0adfba 100644 --- a/lib/Numeric/LinearAlgebra/Tests/Instances.hs +++ b/lib/Numeric/LinearAlgebra/Tests/Instances.hs | |||
@@ -180,7 +180,7 @@ instance (Field a, Arbitrary a, Num (Vector a)) => Arbitrary (PosDef a) where | |||
180 | l <- replicateM n (choose (0,100)) | 180 | l <- replicateM n (choose (0,100)) |
181 | let s = diag (fromList l) | 181 | let s = diag (fromList l) |
182 | p = v <> real s <> ctrans v | 182 | p = v <> real s <> ctrans v |
183 | return $ PosDef (0.5 .* p + 0.5 .* ctrans p) | 183 | return $ PosDef (0.5 * p + 0.5 * ctrans p) |
184 | 184 | ||
185 | #if MIN_VERSION_QuickCheck(2,0,0) | 185 | #if MIN_VERSION_QuickCheck(2,0,0) |
186 | #else | 186 | #else |