summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2010-01-18 09:51:31 +0000
committerAlberto Ruiz <aruiz@um.es>2010-01-18 09:51:31 +0000
commit102d6b19beadd76b28d32e1aa40844fad19af756 (patch)
tree1b7736d5d392b0ef43e2e119fc2d1d1a91cd5831
parent830164c7c34d874aa66754206be956f85456842f (diff)
deprecate .* and */
-rw-r--r--examples/lie.hs7
-rw-r--r--lib/Data/Packed/Random.hs3
-rw-r--r--lib/Numeric/LinearAlgebra/Interface.hs4
-rw-r--r--lib/Numeric/LinearAlgebra/Tests.hs6
-rw-r--r--lib/Numeric/LinearAlgebra/Tests/Instances.hs2
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
3import Numeric.LinearAlgebra 3import Numeric.LinearAlgebra
4import Text.Printf(printf)
5 4
6disp = putStrLn . format " " (printf "%.5f") 5disp = putStrLn . dispf 5
7 6
8rot1 :: Double -> Matrix Double 7rot1 :: Double -> Matrix Double
9rot1 a = (3><3) 8rot1 a = (3><3)
@@ -50,14 +49,14 @@ infix 8 &
50a & b = a <> b - b <> a 49a & b = a <> b - b <> a
51 50
52infixl 6 |+| 51infixl 6 |+|
53a |+| b = a + b + a & b */2 + (a-b) & (a & b) */12 52a |+| b = a + b + a&b /2 + (a-b)&(a & b) /12
54 53
55main = do 54main = 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
22import Numeric.GSL.Vector 22import Numeric.GSL.Vector
23import Data.Packed 23import Data.Packed
24import Numeric.LinearAlgebra.Linear
24import Numeric.LinearAlgebra.Algorithms 25import Numeric.LinearAlgebra.Algorithms
25import Numeric.LinearAlgebra.Instances() 26import Numeric.LinearAlgebra.Instances()
26import Numeric.LinearAlgebra.Interface 27import 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
54infixl 7 .* 56infixl 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
61infixl 7 */ 65infixl 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
285makeUnitary v | realPart n > 1 = v */ n 285makeUnitary 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