summaryrefslogtreecommitdiff
path: root/packages/base/src
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src')
-rw-r--r--packages/base/src/Internal/Algorithms.hs6
-rw-r--r--packages/base/src/Internal/Container.hs2
-rw-r--r--packages/base/src/Internal/Element.hs4
-rw-r--r--packages/base/src/Internal/Vector.hs2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra.hs13
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Data.hs21
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/HMatrix.hs6
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Static.hs4
8 files changed, 38 insertions, 20 deletions
diff --git a/packages/base/src/Internal/Algorithms.hs b/packages/base/src/Internal/Algorithms.hs
index c8b2d3e..99c90aa 100644
--- a/packages/base/src/Internal/Algorithms.hs
+++ b/packages/base/src/Internal/Algorithms.hs
@@ -470,14 +470,14 @@ rq m = {-# SCC "rq" #-} (r,q) where
470 470
471-- | Hessenberg factorization. 471-- | Hessenberg factorization.
472-- 472--
473-- If @(p,h) = hess m@ then @m == p \<> h \<> ctrans p@, where p is unitary 473-- If @(p,h) = hess m@ then @m == p \<> h \<> tr p@, where p is unitary
474-- and h is in upper Hessenberg form (it has zero entries below the first subdiagonal). 474-- and h is in upper Hessenberg form (it has zero entries below the first subdiagonal).
475hess :: Field t => Matrix t -> (Matrix t, Matrix t) 475hess :: Field t => Matrix t -> (Matrix t, Matrix t)
476hess = hess' 476hess = hess'
477 477
478-- | Schur factorization. 478-- | Schur factorization.
479-- 479--
480-- If @(u,s) = schur m@ then @m == u \<> s \<> ctrans u@, where u is unitary 480-- If @(u,s) = schur m@ then @m == u \<> s \<> tr u@, where u is unitary
481-- and s is a Shur matrix. A complex Schur matrix is upper triangular. A real Schur matrix is 481-- and s is a Shur matrix. A complex Schur matrix is upper triangular. A real Schur matrix is
482-- upper triangular in 2x2 blocks. 482-- upper triangular in 2x2 blocks.
483-- 483--
@@ -497,7 +497,7 @@ cholSH = {-# SCC "cholSH" #-} cholSH'
497 497
498-- | Cholesky factorization of a positive definite hermitian or symmetric matrix. 498-- | Cholesky factorization of a positive definite hermitian or symmetric matrix.
499-- 499--
500-- If @c = chol m@ then @c@ is upper triangular and @m == ctrans c \<> c@. 500-- If @c = chol m@ then @c@ is upper triangular and @m == tr c \<> c@.
501chol :: Field t => Matrix t -> Matrix t 501chol :: Field t => Matrix t -> Matrix t
502chol m | exactHermitian m = cholSH m 502chol m | exactHermitian m = cholSH m
503 | otherwise = error "chol requires positive definite complex hermitian or real symmetric matrix" 503 | otherwise = error "chol requires positive definite complex hermitian or real symmetric matrix"
diff --git a/packages/base/src/Internal/Container.hs b/packages/base/src/Internal/Container.hs
index 8926fac..307c6a8 100644
--- a/packages/base/src/Internal/Container.hs
+++ b/packages/base/src/Internal/Container.hs
@@ -72,7 +72,7 @@ infixr 8 <.>
72 72
73 73
74 74
75{- | infix synonym for 'app' 75{- | dense matrix-vector product
76 76
77>>> let m = (2><3) [1..] 77>>> let m = (2><3) [1..]
78>>> m 78>>> m
diff --git a/packages/base/src/Internal/Element.hs b/packages/base/src/Internal/Element.hs
index 6d86f3d..a459678 100644
--- a/packages/base/src/Internal/Element.hs
+++ b/packages/base/src/Internal/Element.hs
@@ -325,9 +325,9 @@ takeDiag m = fromList [flatten m @> (k*cols m+k) | k <- [0 .. min (rows m) (cols
325 325
326------------------------------------------------------------ 326------------------------------------------------------------
327 327
328{- | create a general matrix 328{- | Create a matrix from a list of elements
329 329
330>>> (2><3) [2, 4, 7+2*𝑖, -3, 11, 0] 330>>> (2><3) [2, 4, 7+2*iC, -3, 11, 0]
331(2><3) 331(2><3)
332 [ 2.0 :+ 0.0, 4.0 :+ 0.0, 7.0 :+ 2.0 332 [ 2.0 :+ 0.0, 4.0 :+ 0.0, 7.0 :+ 2.0
333 , (-3.0) :+ (-0.0), 11.0 :+ 0.0, 0.0 :+ 0.0 ] 333 , (-3.0) :+ (-0.0), 11.0 :+ 0.0, 0.0 :+ 0.0 ]
diff --git a/packages/base/src/Internal/Vector.hs b/packages/base/src/Internal/Vector.hs
index 29b6797..de4e670 100644
--- a/packages/base/src/Internal/Vector.hs
+++ b/packages/base/src/Internal/Vector.hs
@@ -127,7 +127,7 @@ n |> l
127 l' = take n l 127 l' = take n l
128 128
129 129
130-- | Create a vector of indexes, useful for matrix extraction using '??' 130-- | Create a vector of indexes, useful for matrix extraction using '(??)'
131idxs :: [Int] -> Vector I 131idxs :: [Int] -> Vector I
132idxs js = fromList (map fromIntegral js) :: Vector I 132idxs js = fromList (map fromIntegral js) :: Vector I
133 133
diff --git a/packages/base/src/Numeric/LinearAlgebra.hs b/packages/base/src/Numeric/LinearAlgebra.hs
index dd4cc67..9cab635 100644
--- a/packages/base/src/Numeric/LinearAlgebra.hs
+++ b/packages/base/src/Numeric/LinearAlgebra.hs
@@ -8,11 +8,16 @@ License : BSD3
8Maintainer : Alberto Ruiz 8Maintainer : Alberto Ruiz
9Stability : provisional 9Stability : provisional
10 10
11
11-} 12-}
12----------------------------------------------------------------------------- 13-----------------------------------------------------------------------------
13module Numeric.LinearAlgebra ( 14module Numeric.LinearAlgebra (
14 15
15 -- * Basic types and data processing 16 -- * Basic Types and data manipulation
17 -- | This package works with 2D ('Matrix') and 1D ('Vector')
18 -- arrays of real ('R') or complex ('C') double precision numbers.
19 -- Single precision and machine integers are also supported for
20 -- basic arithmetic and data manipulation.
16 module Numeric.LinearAlgebra.Data, 21 module Numeric.LinearAlgebra.Data,
17 22
18 -- * Numeric classes 23 -- * Numeric classes
@@ -51,9 +56,9 @@ module Numeric.LinearAlgebra (
51 -- ** dot 56 -- ** dot
52 dot, (<.>), 57 dot, (<.>),
53 -- ** matrix-vector 58 -- ** matrix-vector
54 app, (#>), (<#), (!#>), 59 (#>), (<#), (!#>),
55 -- ** matrix-matrix 60 -- ** matrix-matrix
56 mul, (<>), 61 (<>),
57 -- | The matrix product is also implemented in the "Data.Monoid" instance, where 62 -- | The matrix product is also implemented in the "Data.Monoid" instance, where
58 -- single-element matrices (created from numeric literals or using 'scalar') 63 -- single-element matrices (created from numeric literals or using 'scalar')
59 -- are used for scaling. 64 -- are used for scaling.
@@ -172,7 +177,7 @@ import Internal.Sparse((!#>))
172import Internal.CG 177import Internal.CG
173import Internal.Conversion 178import Internal.Conversion
174 179
175{- | infix synonym of 'mul' 180{- | dense matrix product
176 181
177>>> let a = (3><5) [1..] 182>>> let a = (3><5) [1..]
178>>> a 183>>> a
diff --git a/packages/base/src/Numeric/LinearAlgebra/Data.hs b/packages/base/src/Numeric/LinearAlgebra/Data.hs
index d2843c2..a389aac 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Data.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Data.hs
@@ -8,21 +8,29 @@ License : BSD3
8Maintainer : Alberto Ruiz 8Maintainer : Alberto Ruiz
9Stability : provisional 9Stability : provisional
10 10
11Basic data processing. 11This module provides functions for creation and manipulation of vectors and matrices, IO, and other utilities.
12 12
13-} 13-}
14-------------------------------------------------------------------------------- 14--------------------------------------------------------------------------------
15 15
16module Numeric.LinearAlgebra.Data( 16module Numeric.LinearAlgebra.Data(
17 17
18 -- * Elements
19 R,C,I,Z,type(./.),
20
18 -- * Vector 21 -- * Vector
19 -- | 1D arrays are storable vectors from the vector package. There is no distinction 22 {- | 1D arrays are storable vectors directly reexported from the vector package.
20 -- between row and column vectors. 23 -}
21 24
22 fromList, toList, (|>), vector, range, idxs, 25 fromList, toList, (|>), vector, range, idxs,
23 26
24 -- * Matrix 27 -- * Matrix
25 28
29 {- | The main data type of hmatrix is a 2D dense array defined on top of
30 a storable vector. The internal representation is suitable for direct
31 interface with standard numeric libraries.
32 -}
33
26 (><), matrix, tr, tr', 34 (><), matrix, tr, tr',
27 35
28 -- * Dimensions 36 -- * Dimensions
@@ -56,8 +64,9 @@ module Numeric.LinearAlgebra.Data(
56 -- * Matrix extraction 64 -- * Matrix extraction
57 Extractor(..), (??), 65 Extractor(..), (??),
58 66
59 takeRows, dropRows, takeColumns, dropColumns, 67 (?), (¿), fliprl, flipud,
60 subMatrix, (?), (¿), fliprl, flipud, 68
69 subMatrix, takeRows, dropRows, takeColumns, dropColumns,
61 70
62 remap, 71 remap,
63 72
@@ -92,7 +101,7 @@ module Numeric.LinearAlgebra.Data(
92 separable, 101 separable,
93 fromArray2D, 102 fromArray2D,
94 module Data.Complex, 103 module Data.Complex,
95 R,C,I,Z,Mod, type(./.), 104 Mod,
96 Vector, Matrix, GMatrix, nRows, nCols 105 Vector, Matrix, GMatrix, nRows, nCols
97 106
98) where 107) where
diff --git a/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs b/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs
index 8adaaaf..bac1c0c 100644
--- a/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/HMatrix.hs
@@ -13,7 +13,7 @@ compatibility with previous version, to be removed
13 13
14module Numeric.LinearAlgebra.HMatrix ( 14module Numeric.LinearAlgebra.HMatrix (
15 module Numeric.LinearAlgebra, 15 module Numeric.LinearAlgebra,
16 (¦),(——),ℝ,ℂ,(<·>) 16 (¦),(——),ℝ,ℂ,(<·>),app,mul
17) where 17) where
18 18
19import Numeric.LinearAlgebra 19import Numeric.LinearAlgebra
@@ -23,3 +23,7 @@ infixr 8 <·>
23(<·>) :: Numeric t => Vector t -> Vector t -> t 23(<·>) :: Numeric t => Vector t -> Vector t -> t
24(<·>) = dot 24(<·>) = dot
25 25
26app m v = m #> v
27
28mul a b = a <> b
29
diff --git a/packages/base/src/Numeric/LinearAlgebra/Static.hs b/packages/base/src/Numeric/LinearAlgebra/Static.hs
index d0a790d..0dab0e6 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Static.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Static.hs
@@ -22,7 +22,7 @@ Stability : experimental
22 22
23Experimental interface with statically checked dimensions. 23Experimental interface with statically checked dimensions.
24 24
25This module is under active development and the interface is subject to changes. 25See code examples at http://dis.um.es/~alberto/hmatrix/static.html.
26 26
27-} 27-}
28 28
@@ -65,7 +65,7 @@ import Numeric.LinearAlgebra hiding (
65 row,col,vector,matrix,linspace,toRows,toColumns, 65 row,col,vector,matrix,linspace,toRows,toColumns,
66 (<\>),fromList,takeDiag,svd,eig,eigSH,eigSH', 66 (<\>),fromList,takeDiag,svd,eig,eigSH,eigSH',
67 eigenvalues,eigenvaluesSH,eigenvaluesSH',build, 67 eigenvalues,eigenvaluesSH,eigenvaluesSH',build,
68 qr,size,app,mul,dot,chol,range,R,C) 68 qr,size,dot,chol,range,R,C)
69import qualified Numeric.LinearAlgebra as LA 69import qualified Numeric.LinearAlgebra as LA
70import Data.Proxy(Proxy) 70import Data.Proxy(Proxy)
71import Internal.Static 71import Internal.Static