summaryrefslogtreecommitdiff
path: root/packages/base/src/Data/Packed/Numeric.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-06-20 11:30:59 +0200
committerAlberto Ruiz <aruiz@um.es>2014-06-20 11:30:59 +0200
commit2869503ccb552238e330562a62a076e48d567f79 (patch)
treeeb4e4ae8fd1960e30814dff0efd205017b6d6a53 /packages/base/src/Data/Packed/Numeric.hs
parent1e564ccf064a3486532aeb32d689e5ca4fd2e260 (diff)
dot, mul, app
Diffstat (limited to 'packages/base/src/Data/Packed/Numeric.hs')
-rw-r--r--packages/base/src/Data/Packed/Numeric.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/packages/base/src/Data/Packed/Numeric.hs b/packages/base/src/Data/Packed/Numeric.hs
index ab9e8a2..7aa53f1 100644
--- a/packages/base/src/Data/Packed/Numeric.hs
+++ b/packages/base/src/Data/Packed/Numeric.hs
@@ -39,7 +39,7 @@ module Data.Packed.Numeric (
39 step, cond, find, assoc, accum, 39 step, cond, find, assoc, accum,
40 Transposable(..), Linear(..), 40 Transposable(..), Linear(..),
41 -- * Matrix product 41 -- * Matrix product
42 Product(..), udot, dot, (<·>), (#>), 42 Product(..), udot, dot, (<·>), (#>), app,
43 Mul(..), 43 Mul(..),
44 (<.>), 44 (<.>),
45 optimiseMult, 45 optimiseMult,
@@ -105,7 +105,7 @@ infixl 7 <.>
105 105
106infixr 8 <·>, #> 106infixr 8 <·>, #>
107 107
108{- | dot product 108{- | infix synonym for 'dot'
109 109
110>>> vector [1,2,3,4] <·> vector [-2,0,1,1] 110>>> vector [1,2,3,4] <·> vector [-2,0,1,1]
1115.0 1115.0
@@ -121,7 +121,7 @@ infixr 8 <·>, #>
121(<·>) = dot 121(<·>) = dot
122 122
123 123
124{- | dense matrix-vector product 124{- | infix synonym for 'app'
125 125
126>>> let m = (2><3) [1..] 126>>> let m = (2><3) [1..]
127>>> m 127>>> m
@@ -138,6 +138,10 @@ fromList [140.0,320.0]
138(#>) :: Numeric t => Matrix t -> Vector t -> Vector t 138(#>) :: Numeric t => Matrix t -> Vector t -> Vector t
139(#>) = mXv 139(#>) = mXv
140 140
141-- | dense matrix-vector product
142app :: Numeric t => Matrix t -> Vector t -> Vector t
143app = (#>)
144
141-------------------------------------------------------------------------------- 145--------------------------------------------------------------------------------
142 146
143class Mul a b c | a b -> c where 147class Mul a b c | a b -> c where
@@ -226,8 +230,8 @@ instance Container Matrix e => Build (Int,Int) (e -> e -> e) Matrix e
226 230
227-------------------------------------------------------------------------------- 231--------------------------------------------------------------------------------
228 232
229-- | dot product: @cdot u v = 'udot' ('conj' u) v@ 233-- @dot u v = 'udot' ('conj' u) v@
230dot :: (Container Vector t, Product t) => Vector t -> Vector t -> t 234dot :: (Numeric t) => Vector t -> Vector t -> t
231dot u v = udot (conj u) v 235dot u v = udot (conj u) v
232 236
233-------------------------------------------------------------------------------- 237--------------------------------------------------------------------------------