diff options
author | Alberto Ruiz <aruiz@um.es> | 2009-04-27 17:25:18 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2009-04-27 17:25:18 +0000 |
commit | 0c2c887de10702206ee645452a86674500314948 (patch) | |
tree | 935b72efca7b4e65bfa80ba18c2342516aca75d3 /lib/Data/Packed/Matrix.hs | |
parent | c210311be639e8774dca25a332542d6b64ce3ca3 (diff) |
more defined (|>) and (><) as suggested by Tracy Wadleigh
Diffstat (limited to 'lib/Data/Packed/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 16 |
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 @@ | |||
16 | module Data.Packed.Matrix ( | 16 | module 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 | ||
119 | This is the format produced by the instances of Show (Matrix a), which | 119 | This is the format produced by the instances of Show (Matrix a), which |
120 | can also be used for input. | 120 | can also be used for input. |
121 | -} | ||
122 | (><) :: (Element a) => Int -> Int -> [a] -> Matrix a | ||
123 | r >< 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 | 122 | The input list is explicitly truncated, so that it can |
130 | safely be used with lists that are too long (like infinite lists). | 123 | safely be used with lists that are too long (like infinite lists). |
131 | 124 | ||
132 | Example: | 125 | Example: |
@@ -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 | ||
139 | Effectively, a more defined version of '(><)'. | ||
140 | -} | 132 | -} |
141 | (>|<) :: (Element a) => Int -> Int -> [a] -> Matrix a | 133 | (><) :: (Element a) => Int -> Int -> [a] -> Matrix a |
142 | r >|< c = f where | 134 | r >< 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++")" |