summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
Diffstat (limited to 'packages')
-rw-r--r--packages/base/src/Data/Packed/Numeric.hs14
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/HMatrix.hs18
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Static.hs10
3 files changed, 27 insertions, 15 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--------------------------------------------------------------------------------
diff --git a/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs b/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs
index 54ddd68..d2cae6c 100644
--- a/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs
@@ -45,12 +45,12 @@ module Numeric.LinearAlgebra.HMatrix (
45 45
46 -- * Products 46 -- * Products
47 -- ** dot 47 -- ** dot
48 (<·>), 48 dot, (<·>),
49 -- ** matrix-vector 49 -- ** matrix-vector
50 (#>), (!#>), 50 app, (#>), (!#>),
51 -- ** matrix-matrix 51 -- ** matrix-matrix
52 (<>), 52 mul, (<>),
53 -- | The matrix x matrix product is also implemented in the "Data.Monoid" instance, where 53 -- | The matrix product is also implemented in the "Data.Monoid" instance, where
54 -- single-element matrices (created from numeric literals or using 'scalar') 54 -- single-element matrices (created from numeric literals or using 'scalar')
55 -- are used for scaling. 55 -- are used for scaling.
56 -- 56 --
@@ -96,7 +96,6 @@ module Numeric.LinearAlgebra.HMatrix (
96 96
97 -- * SVD 97 -- * SVD
98 svd, 98 svd,
99 fullSVD,
100 thinSVD, 99 thinSVD,
101 compactSVD, 100 compactSVD,
102 singularValues, 101 singularValues,
@@ -153,7 +152,7 @@ import Numeric.LinearAlgebra.Data
153 152
154import Numeric.Matrix() 153import Numeric.Matrix()
155import Numeric.Vector() 154import Numeric.Vector()
156import Data.Packed.Numeric hiding ((<>)) 155import Data.Packed.Numeric hiding ((<>), mul)
157import Numeric.LinearAlgebra.Algorithms hiding (linearSolve,Normed,orth) 156import Numeric.LinearAlgebra.Algorithms hiding (linearSolve,Normed,orth)
158import qualified Numeric.LinearAlgebra.Algorithms as A 157import qualified Numeric.LinearAlgebra.Algorithms as A
159import Numeric.LinearAlgebra.Util 158import Numeric.LinearAlgebra.Util
@@ -161,7 +160,7 @@ import Numeric.LinearAlgebra.Random
161import Numeric.Sparse((!#>)) 160import Numeric.Sparse((!#>))
162import Numeric.LinearAlgebra.Util.CG 161import Numeric.LinearAlgebra.Util.CG
163 162
164{- | dense matrix product 163{- | infix synonym of 'mul'
165 164
166>>> let a = (3><5) [1..] 165>>> let a = (3><5) [1..]
167>>> a 166>>> a
@@ -190,6 +189,11 @@ import Numeric.LinearAlgebra.Util.CG
190(<>) = mXm 189(<>) = mXm
191infixr 8 <> 190infixr 8 <>
192 191
192-- | dense matrix product
193mul :: Numeric t => Matrix t -> Matrix t -> Matrix t
194mul = mXm
195
196
193-- | Solve a linear system (for square coefficient matrix and several right-hand sides) using the LU decomposition, returning Nothing for a singular system. For underconstrained or overconstrained systems use 'linearSolveLS' or 'linearSolveSVD'. 197-- | Solve a linear system (for square coefficient matrix and several right-hand sides) using the LU decomposition, returning Nothing for a singular system. For underconstrained or overconstrained systems use 'linearSolveLS' or 'linearSolveSVD'.
194linearSolve m b = A.mbLinearSolve m b 198linearSolve m b = A.mbLinearSolve m b
195 199
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs
index 213c42c..cbcd4e2 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Static.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs
@@ -25,6 +25,8 @@ Stability : experimental
25 25
26Experimental interface with statically checked dimensions. 26Experimental interface with statically checked dimensions.
27 27
28This module is under active development and the interface is subject to changes.
29
28-} 30-}
29 31
30module Numeric.LinearAlgebra.Static( 32module Numeric.LinearAlgebra.Static(
@@ -62,9 +64,11 @@ module Numeric.LinearAlgebra.Static(
62 64
63import GHC.TypeLits 65import GHC.TypeLits
64import Numeric.LinearAlgebra.HMatrix hiding ( 66import Numeric.LinearAlgebra.HMatrix hiding (
65 (<>),(#>),(<·>),Konst(..),diag, disp,(¦),(——),row,col,vector,matrix,linspace,toRows,toColumns, 67 (<>),(#>),(<·>),Konst(..),diag, disp,(¦),(——),
66 (<\>),fromList,takeDiag,svd,eig,eigSH,eigSH',eigenvalues,eigenvaluesSH,eigenvaluesSH',build, 68 row,col,vector,matrix,linspace,toRows,toColumns,
67 qr,size) 69 (<\>),fromList,takeDiag,svd,eig,eigSH,eigSH',
70 eigenvalues,eigenvaluesSH,eigenvaluesSH',build,
71 qr,size,app,mul,dot)
68import qualified Numeric.LinearAlgebra.HMatrix as LA 72import qualified Numeric.LinearAlgebra.HMatrix as LA
69import Data.Proxy(Proxy) 73import Data.Proxy(Proxy)
70import Numeric.LinearAlgebra.Static.Internal 74import Numeric.LinearAlgebra.Static.Internal