diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/base/src/Data/Packed/Numeric.hs | 14 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/HMatrix.hs | 18 | ||||
-rw-r--r-- | packages/base/src/Numeric/LinearAlgebra/Static.hs | 10 |
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 | ||
106 | infixr 8 <·>, #> | 106 | infixr 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] |
111 | 5.0 | 111 | 5.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 | ||
142 | app :: Numeric t => Matrix t -> Vector t -> Vector t | ||
143 | app = (#>) | ||
144 | |||
141 | -------------------------------------------------------------------------------- | 145 | -------------------------------------------------------------------------------- |
142 | 146 | ||
143 | class Mul a b c | a b -> c where | 147 | class 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@ |
230 | dot :: (Container Vector t, Product t) => Vector t -> Vector t -> t | 234 | dot :: (Numeric t) => Vector t -> Vector t -> t |
231 | dot u v = udot (conj u) v | 235 | dot 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 | ||
154 | import Numeric.Matrix() | 153 | import Numeric.Matrix() |
155 | import Numeric.Vector() | 154 | import Numeric.Vector() |
156 | import Data.Packed.Numeric hiding ((<>)) | 155 | import Data.Packed.Numeric hiding ((<>), mul) |
157 | import Numeric.LinearAlgebra.Algorithms hiding (linearSolve,Normed,orth) | 156 | import Numeric.LinearAlgebra.Algorithms hiding (linearSolve,Normed,orth) |
158 | import qualified Numeric.LinearAlgebra.Algorithms as A | 157 | import qualified Numeric.LinearAlgebra.Algorithms as A |
159 | import Numeric.LinearAlgebra.Util | 158 | import Numeric.LinearAlgebra.Util |
@@ -161,7 +160,7 @@ import Numeric.LinearAlgebra.Random | |||
161 | import Numeric.Sparse((!#>)) | 160 | import Numeric.Sparse((!#>)) |
162 | import Numeric.LinearAlgebra.Util.CG | 161 | import 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 |
191 | infixr 8 <> | 190 | infixr 8 <> |
192 | 191 | ||
192 | -- | dense matrix product | ||
193 | mul :: Numeric t => Matrix t -> Matrix t -> Matrix t | ||
194 | mul = 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'. |
194 | linearSolve m b = A.mbLinearSolve m b | 198 | linearSolve 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 | ||
26 | Experimental interface with statically checked dimensions. | 26 | Experimental interface with statically checked dimensions. |
27 | 27 | ||
28 | This module is under active development and the interface is subject to changes. | ||
29 | |||
28 | -} | 30 | -} |
29 | 31 | ||
30 | module Numeric.LinearAlgebra.Static( | 32 | module Numeric.LinearAlgebra.Static( |
@@ -62,9 +64,11 @@ module Numeric.LinearAlgebra.Static( | |||
62 | 64 | ||
63 | import GHC.TypeLits | 65 | import GHC.TypeLits |
64 | import Numeric.LinearAlgebra.HMatrix hiding ( | 66 | import 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) | ||
68 | import qualified Numeric.LinearAlgebra.HMatrix as LA | 72 | import qualified Numeric.LinearAlgebra.HMatrix as LA |
69 | import Data.Proxy(Proxy) | 73 | import Data.Proxy(Proxy) |
70 | import Numeric.LinearAlgebra.Static.Internal | 74 | import Numeric.LinearAlgebra.Static.Internal |