summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra/Real.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Numeric/LinearAlgebra/Real.hs')
-rw-r--r--lib/Numeric/LinearAlgebra/Real.hs117
1 files changed, 0 insertions, 117 deletions
diff --git a/lib/Numeric/LinearAlgebra/Real.hs b/lib/Numeric/LinearAlgebra/Real.hs
deleted file mode 100644
index 8478ee7..0000000
--- a/lib/Numeric/LinearAlgebra/Real.hs
+++ /dev/null
@@ -1,117 +0,0 @@
1-----------------------------------------------------------------------------
2{- |
3Module : Numeric.LinearAlgebra.Real
4Copyright : (c) Alberto Ruiz 2012
5License : GPL
6
7Maintainer : Alberto Ruiz (aruiz at um dot es)
8Stability : provisional
9
10Additional functions for real arrays.
11
12-}
13-----------------------------------------------------------------------------
14
15module Numeric.LinearAlgebra.Real(
16 (<>), (<\>),
17 vector,
18 linspace,
19 eye,
20 zeros, ones,
21 diagl,
22 row,
23 col,
24 (#),(&), (//), blocks,
25 rand, randn,
26 module Numeric.LinearAlgebra
27) where
28
29import Numeric.LinearAlgebra hiding ((<>), (<\>), linspace)
30import qualified Numeric.LinearAlgebra as LA
31import System.Random(randomIO)
32
33linspace :: Int -> (Double,Double) -> Vector Double
34linspace = LA.linspace
35
36
37infixl 7 <>
38-- | Matrix product
39(<>) ::Mul a b c => a Double -> b Double -> c Double
40(<>) = (LA.<>)
41
42
43infixl 7 <\>
44-- | Least squares solution of a linear system
45(<\>) ::LSDiv b c => Matrix Double -> b Double -> c Double
46(<\>) = (LA.<\>)
47
48
49-- | Pseudorandom matrix with uniform elements between 0 and 1.
50randm :: RandDist
51 -> Int -- ^ rows
52 -> Int -- ^ columns
53 -> IO (Matrix Double)
54randm d r c = do
55 seed <- randomIO
56 return (reshape c $ randomVector seed d (r*c))
57
58-- | Pseudorandom matrix with uniform elements between 0 and 1.
59rand :: Int -> Int -> IO (Matrix Double)
60rand = randm Uniform
61
62-- | Pseudorandom matrix with normal elements
63randn :: Int -> Int -> IO (Matrix Double)
64randn = randm Gaussian
65
66-- | Real identity matrix.
67eye :: Int -> Matrix Double
68eye = ident
69
70-- | Create a real vector from a list.
71vector :: [Double] -> Vector Double
72vector = fromList
73
74-- | Create a real diagonal matrix from a list.
75diagl :: [Double] -> Matrix Double
76diagl = diag . vector
77
78-- | Create a matrix or zeros.
79zeros :: Int -- ^ rows
80 -> Int -- ^ columns
81 -> Matrix Double
82zeros r c = konst 0 (r,c)
83
84-- | Create a matrix or ones.
85ones :: Int -- ^ rows
86 -> Int -- ^ columns
87 -> Matrix Double
88ones r c = konst 1 (r,c)
89
90-- | Concatenation of real vectors.
91infixl 3 #
92(#) :: Vector Double -> Vector Double -> Vector Double
93a # b = join [a,b]
94
95-- | Horizontal concatenation of real matrices.
96infixl 3 !
97(!) :: Matrix Double -> Matrix Double -> Matrix Double
98a ! b = fromBlocks [[a,b]]
99
100-- | Vertical concatenation of real matrices.
101(#) :: Matrix Double -> Matrix Double -> Matrix Double
102infixl 2 #
103a # b = fromBlocks [[a],[b]]
104
105
106-- | Real block matrix from a rectangular list of lists.
107blocks :: [[Matrix Double]] -> Matrix Double
108blocks = fromBlocks
109
110-- | A real matrix with a single row, created from a list of elements.
111row :: [Double] -> Matrix Double
112row = asRow . vector
113
114-- | A real matrix with a single column, created from a list of elements.
115col :: [Double] -> Matrix Double
116col = asColumn . vector
117