summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-04-24 20:50:10 +0200
committerAlberto Ruiz <aruiz@um.es>2014-04-24 20:50:10 +0200
commitcd3daf7e12fa2a8c775a1d6516049bbc7e44da32 (patch)
treeee2969b42838c13a282a4082dbb0f8c8c53af2a5
parentc2b3835a9a43d822d6134ef51a9ec9627a9e95c3 (diff)
deprecate vjoin, dot and (<.>). Move (⋅) to Container
-rw-r--r--CHANGELOG26
-rw-r--r--lib/Data/Packed/Vector.hs7
-rw-r--r--lib/Numeric/Container.hs20
-rw-r--r--lib/Numeric/LinearAlgebra/Util.hs16
4 files changed, 40 insertions, 29 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 393c52a..dea29a9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,32 +1,18 @@
10.16.0.0 10.16.0.0
2-------- 2--------
3 3
4 * join renamed to vjoin 4 * join deprecated, use vjoin
5 5 * dot and (<.>) deprecated, use udot or (×)
6 * dot renamed to udot (unconjugated dot product) 6
7 * Removed (<.>) 7 * added udot (unconjugated dot product)
8 8 * added (⋅) = cdot, which conjugates the first input vector
9 * added cdot, which conjugates the first input vector
10 * the operator (⋅) = cdot is available from Numeric.LinearAlgebra.Util
11 9
12 * added a general multiplication operator (×) 10 * added a general multiplication operator (×)
13 11
14 * improved build and konst 12 * improved build and konst
15 13
16 * Plot functions moved to Numeric.LinearAlgebra.Util 14 * Plot functions moved to Numeric.LinearAlgebra.Util
17 * removed (!) (use (¦) instead) 15 * removed (!) (use (¦))
18
19This version introduces a few backward incompatible changes but the code can be
20updated very easily:
21
22join -> vjoin
23dot -> udot
24<.> -> ×
25import Graphics.Plot -> import Numeric.LinearAlgebra.Util
26
27The new contraction operator (×) performs matrix products, matrix-vector products,
28unconjugated vector dot products, and scaling of vectors and matrices.
29
30 16
310.15.2.0 170.15.2.0
32-------- 18--------
diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs
index a705ce4..f12031f 100644
--- a/lib/Data/Packed/Vector.hs
+++ b/lib/Data/Packed/Vector.hs
@@ -19,7 +19,7 @@ module Data.Packed.Vector (
19 Vector, 19 Vector,
20 fromList, (|>), toList, buildVector, 20 fromList, (|>), toList, buildVector,
21 dim, (@>), 21 dim, (@>),
22 subVector, takesV, vjoin, 22 subVector, takesV, vjoin, join,
23 mapVector, mapVectorWithIndex, zipVector, zipVectorWith, unzipVector, unzipVectorWith, 23 mapVector, mapVectorWithIndex, zipVector, zipVectorWith, unzipVector, unzipVectorWith,
24 mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, 24 mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_,
25 foldLoop, foldVector, foldVectorG, foldVectorWithIndex 25 foldLoop, foldVector, foldVectorG, foldVectorWithIndex
@@ -88,3 +88,8 @@ unzipVector :: (Storable a, Storable b, Storable (a,b)) => Vector (a,b) -> (Vect
88unzipVector = unzipVectorWith id 88unzipVector = unzipVectorWith id
89 89
90------------------------------------------------------------------- 90-------------------------------------------------------------------
91
92{-# DEPRECATED join "use vjoin or Data.Vector.concat" #-}
93join :: Storable t => [Vector t] -> Vector t
94join = vjoin
95
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs
index 46c2903..aac8c10 100644
--- a/lib/Numeric/Container.hs
+++ b/lib/Numeric/Container.hs
@@ -38,7 +38,7 @@ module Numeric.Container (
38 Product(..), 38 Product(..),
39 Contraction(..), 39 Contraction(..),
40 optimiseMult, 40 optimiseMult,
41 mXm,mXv,vXm,Mul(..),LSDiv(..), cdot, 41 mXm,mXv,vXm,Mul(..),LSDiv(..), cdot, (⋅), dot, (<.>),
42 outer, kronecker, 42 outer, kronecker,
43 -- * Random numbers 43 -- * Random numbers
44 RandDist(..), 44 RandDist(..),
@@ -175,6 +175,13 @@ instance Container Matrix t => Contraction (Matrix t) t (Matrix t) where
175 175
176-------------------------------------------------------------------------------- 176--------------------------------------------------------------------------------
177 177
178-- | dot product (0x22C5): @u ⋅ v = 'cdot' u v@
179(⋅) :: (Container Vector t, Product t) => Vector t -> Vector t -> t
180infixl 7 ⋅
181u ⋅ v = cdot u v
182
183--------------------------------------------------------------------------------
184
178-- bidirectional type inference 185-- bidirectional type inference
179class Konst e d c | d -> c, c -> d 186class Konst e d c | d -> c, c -> d
180 where 187 where
@@ -200,3 +207,14 @@ instance Container Matrix e => Build (Int,Int) (e -> e -> e) Matrix e
200 where 207 where
201 build = build' 208 build = build'
202 209
210--------------------------------------------------------------------------------
211
212{-# DEPRECATED dot "use udot" #-}
213dot :: Product e => Vector e -> Vector e -> e
214dot = udot
215
216{-# DEPRECATED (<.>) "use udot or (×)" #-}
217infixl 7 <.>
218(<.>) :: Product e => Vector e -> Vector e -> e
219(<.>) = udot
220
diff --git a/lib/Numeric/LinearAlgebra/Util.hs b/lib/Numeric/LinearAlgebra/Util.hs
index 2c77d3a..b38aeb2 100644
--- a/lib/Numeric/LinearAlgebra/Util.hs
+++ b/lib/Numeric/LinearAlgebra/Util.hs
@@ -23,7 +23,6 @@ module Numeric.LinearAlgebra.Util(
23 (?), (¿), 23 (?), (¿),
24 rand, randn, 24 rand, randn,
25 cross, 25 cross,
26 (⋅),
27 norm, 26 norm,
28 unitary, 27 unitary,
29 mt, 28 mt,
@@ -86,7 +85,15 @@ rand = randm Uniform
86randn :: Int -> Int -> IO (Matrix Double) 85randn :: Int -> Int -> IO (Matrix Double)
87randn = randm Gaussian 86randn = randm Gaussian
88 87
89-- | create a real diagonal matrix from a list 88{- | create a real diagonal matrix from a list
89
90>>> diagl [1,2,3]
91(3><3)
92 [ 1.0, 0.0, 0.0
93 , 0.0, 2.0, 0.0
94 , 0.0, 0.0, 3.0 ]
95
96-}
90diagl :: [Double] -> Matrix Double 97diagl :: [Double] -> Matrix Double
91diagl = diag . fromList 98diagl = diag . fromList
92 99
@@ -164,11 +171,6 @@ size m = (rows m, cols m)
164mt :: Matrix Double -> Matrix Double 171mt :: Matrix Double -> Matrix Double
165mt = trans . inv 172mt = trans . inv
166 173
167-- | dot product (0x22C5): @u ⋅ v = 'cdot' u v@
168(⋅) :: (Container Vector t, Product t) => Vector t -> Vector t -> t
169infixl 7 ⋅
170u ⋅ v = cdot u v
171
172---------------------------------------------------------------------- 174----------------------------------------------------------------------
173 175
174-- | Matrix of pairwise squared distances of row vectors 176-- | Matrix of pairwise squared distances of row vectors