summaryrefslogtreecommitdiff
path: root/lib/Data/Packed/Matrix.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r--lib/Data/Packed/Matrix.hs16
1 files changed, 4 insertions, 12 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs
index 5a73c06..0b50d8a 100644
--- a/lib/Data/Packed/Matrix.hs
+++ b/lib/Data/Packed/Matrix.hs
@@ -16,7 +16,7 @@
16module Data.Packed.Matrix ( 16module Data.Packed.Matrix (
17 Element, 17 Element,
18 Matrix,rows,cols, 18 Matrix,rows,cols,
19 (><), (>|<), 19 (><),
20 trans, 20 trans,
21 reshape, flatten, 21 reshape, flatten,
22 fromLists, toLists, 22 fromLists, toLists,
@@ -118,15 +118,8 @@ ident n = diag (constant 1 n)
118 118
119This is the format produced by the instances of Show (Matrix a), which 119This is the format produced by the instances of Show (Matrix a), which
120can also be used for input. 120can also be used for input.
121-}
122(><) :: (Element a) => Int -> Int -> [a] -> Matrix a
123r >< c = f where
124 f l | dim v == r*c = matrixFromVector RowMajor c v
125 | otherwise = error $ "inconsistent list size = "
126 ++show (dim v) ++" in ("++show r++"><"++show c++")"
127 where v = fromList l
128 121
129{- | Like '(><)', but explicitly truncates the list, so that it can 122The input list is explicitly truncated, so that it can
130safely be used with lists that are too long (like infinite lists). 123safely be used with lists that are too long (like infinite lists).
131 124
132Example: 125Example:
@@ -136,10 +129,9 @@ Example:
136 [ 1.0, 2.0, 3.0 129 [ 1.0, 2.0, 3.0
137 , 4.0, 5.0, 6.0 ]@ 130 , 4.0, 5.0, 6.0 ]@
138 131
139Effectively, a more defined version of '(><)'.
140-} 132-}
141(>|<) :: (Element a) => Int -> Int -> [a] -> Matrix a 133(><) :: (Element a) => Int -> Int -> [a] -> Matrix a
142r >|< c = f where 134r >< c = f where
143 f l | dim v == r*c = matrixFromVector RowMajor c v 135 f l | dim v == r*c = matrixFromVector RowMajor c v
144 | otherwise = error $ "inconsistent list size = " 136 | otherwise = error $ "inconsistent list size = "
145 ++show (dim v) ++" in ("++show r++"><"++show c++")" 137 ++show (dim v) ++" in ("++show r++"><"++show c++")"