diff options
Diffstat (limited to 'lib/Data/Packed')
-rw-r--r-- | lib/Data/Packed/Matrix.hs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Data/Packed/Matrix.hs b/lib/Data/Packed/Matrix.hs index e046ead..1fa8903 100644 --- a/lib/Data/Packed/Matrix.hs +++ b/lib/Data/Packed/Matrix.hs | |||
@@ -252,13 +252,18 @@ asColumn v = reshape 1 v | |||
252 | 252 | ||
253 | 253 | ||
254 | {- | creates a Matrix of the specified size using the supplied function to | 254 | {- | creates a Matrix of the specified size using the supplied function to |
255 | to map the row/column position to the value at that row/column position. | 255 | to map the row\/column position to the value at that row\/column position. |
256 | 256 | ||
257 | @> buildMatrix 3 4 (\ (r,c) -> fromIntegral r * fromIntegral c) | 257 | @> buildMatrix 3 4 (\ (r,c) -> fromIntegral r * fromIntegral c) |
258 | (3><4) | 258 | (3><4) |
259 | [ 0.0, 0.0, 0.0, 0.0, 0.0 | 259 | [ 0.0, 0.0, 0.0, 0.0, 0.0 |
260 | , 0.0, 1.0, 2.0, 3.0, 4.0 | 260 | , 0.0, 1.0, 2.0, 3.0, 4.0 |
261 | , 0.0, 2.0, 4.0, 6.0, 8.0]@ | 261 | , 0.0, 2.0, 4.0, 6.0, 8.0]@ |
262 | |||
263 | Hilbert matrix of order N: | ||
264 | |||
265 | @hilb n = buildMatrix n n (\(i,j)->1/(fromIntegral i + fromIntegral j +1))@ | ||
266 | |||
262 | -} | 267 | -} |
263 | buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a | 268 | buildMatrix :: Element a => Int -> Int -> ((Int, Int) -> a) -> Matrix a |
264 | buildMatrix rc cc f = | 269 | buildMatrix rc cc f = |