summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-04-24 10:30:01 +0200
committerAlberto Ruiz <aruiz@um.es>2014-04-24 10:30:01 +0200
commit6fbed842525491e280448a00a4b5426e6830ccaa (patch)
treeb78d2712f7ac23845fc29120d3a9fbcd7d189004 /lib/Numeric/LinearAlgebra
parent7c5adb83c9cb632c39eb2d844a1496e2a7a23e8b (diff)
cdot and (×)
added cdot dot renamed to udot <.> changed to cdot and moved to Numeric.LinearAlgebra.Util new general contraction operator (×) Plot functions moved to Numeric.LinearAlgebra.Util
Diffstat (limited to 'lib/Numeric/LinearAlgebra')
-rw-r--r--lib/Numeric/LinearAlgebra/Util.hs24
-rw-r--r--lib/Numeric/LinearAlgebra/Util/Convolution.hs2
2 files changed, 17 insertions, 9 deletions
diff --git a/lib/Numeric/LinearAlgebra/Util.hs b/lib/Numeric/LinearAlgebra/Util.hs
index f7c40d7..f6aa7da 100644
--- a/lib/Numeric/LinearAlgebra/Util.hs
+++ b/lib/Numeric/LinearAlgebra/Util.hs
@@ -19,10 +19,11 @@ module Numeric.LinearAlgebra.Util(
19 diagl, 19 diagl,
20 row, 20 row,
21 col, 21 col,
22 (&),(!), (¦), (#), 22 (&), (¦), (#),
23 (?),(¿), 23 (?), (¿),
24 rand, randn, 24 rand, randn,
25 cross, 25 cross,
26 (<.>),
26 norm, 27 norm,
27 unitary, 28 unitary,
28 mt, 29 mt,
@@ -45,7 +46,13 @@ module Numeric.LinearAlgebra.Util(
45 vec, 46 vec,
46 vech, 47 vech,
47 dup, 48 dup,
48 vtrans 49 vtrans,
50 -- * Plot
51 mplot,
52 plot, parametricPlot,
53 splot, mesh, meshdom,
54 matrixToPGM, imshow,
55 gnuplotX, gnuplotpdf, gnuplotWin
49) where 56) where
50 57
51import Numeric.Container 58import Numeric.Container
@@ -55,6 +62,7 @@ import Numeric.Vector()
55 62
56import System.Random(randomIO) 63import System.Random(randomIO)
57import Numeric.LinearAlgebra.Util.Convolution 64import Numeric.LinearAlgebra.Util.Convolution
65import Graphics.Plot
58 66
59 67
60disp :: Int -> Matrix Double -> IO () 68disp :: Int -> Matrix Double -> IO ()
@@ -99,11 +107,6 @@ infixl 3 &
99(&) :: Vector Double -> Vector Double -> Vector Double 107(&) :: Vector Double -> Vector Double -> Vector Double
100a & b = vjoin [a,b] 108a & b = vjoin [a,b]
101 109
102-- | horizontal concatenation of real matrices
103infixl 3 !
104(!) :: Matrix Double -> Matrix Double -> Matrix Double
105a ! b = fromBlocks [[a,b]]
106
107-- | (00A6) horizontal concatenation of real matrices 110-- | (00A6) horizontal concatenation of real matrices
108infixl 3 ¦ 111infixl 3 ¦
109(¦) :: Matrix Double -> Matrix Double -> Matrix Double 112(¦) :: Matrix Double -> Matrix Double -> Matrix Double
@@ -161,6 +164,11 @@ size m = (rows m, cols m)
161mt :: Matrix Double -> Matrix Double 164mt :: Matrix Double -> Matrix Double
162mt = trans . inv 165mt = trans . inv
163 166
167-- | dot product: @u \<.\> v = 'cdot' u v@
168(<.>) :: (Container Vector t, Product t) => Vector t -> Vector t -> t
169infixl 7 <.>
170u <.> v = cdot u v
171
164---------------------------------------------------------------------- 172----------------------------------------------------------------------
165 173
166-- | Matrix of pairwise squared distances of row vectors 174-- | Matrix of pairwise squared distances of row vectors
diff --git a/lib/Numeric/LinearAlgebra/Util/Convolution.hs b/lib/Numeric/LinearAlgebra/Util/Convolution.hs
index be9b1eb..1043614 100644
--- a/lib/Numeric/LinearAlgebra/Util/Convolution.hs
+++ b/lib/Numeric/LinearAlgebra/Util/Convolution.hs
@@ -75,7 +75,7 @@ matSS dr m = map (reshape c) [ subVector (k*c) n v | k <- [0 .. r - dr] ]
75corr2 :: Product a => Matrix a -> Matrix a -> Matrix a 75corr2 :: Product a => Matrix a -> Matrix a -> Matrix a
76-- ^ 2D correlation 76-- ^ 2D correlation
77corr2 ker mat = dims 77corr2 ker mat = dims
78 . concatMap (map ((<.> ker') . flatten) . matSS c . trans) 78 . concatMap (map (udot ker' . flatten) . matSS c . trans)
79 . matSS r $ mat 79 . matSS r $ mat
80 where 80 where
81 r = rows ker 81 r = rows ker