Mercurial > hg > may
comparison yetilab/matrix/matrix.yeti @ 195:3f4f3af724b0
Add type declarations for matrix, filter
author | Chris Cannam |
---|---|
date | Mon, 06 May 2013 16:49:45 +0100 |
parents | 528f16f988d8 |
children | 0b187d845491 |
comparison
equal
deleted
inserted
replaced
194:8148422e9102 | 195:3f4f3af724b0 |
---|---|
10 // switches the row/column order without moving the elements.) | 10 // switches the row/column order without moving the elements.) |
11 | 11 |
12 vec = load yetilab.block.fvector; | 12 vec = load yetilab.block.fvector; |
13 block = load yetilab.block.block; | 13 block = load yetilab.block.block; |
14 bf = load yetilab.block.blockfuncs; | 14 bf = load yetilab.block.blockfuncs; |
15 | |
16 load yetilab.block.blocktype; | |
17 load yetilab.matrix.matrixtype; | |
15 | 18 |
16 make d = { | 19 make d = { |
17 get data () = d, | 20 get data () = d, |
18 get size () = | 21 get size () = |
19 case d of | 22 case d of |
136 make (RowM (array [block.data data])); | 139 make (RowM (array [block.data data])); |
137 | 140 |
138 newColumnVector data = //!!! NB does not copy data | 141 newColumnVector data = //!!! NB does not copy data |
139 make (ColM (array [block.data data])); | 142 make (ColM (array [block.data data])); |
140 | 143 |
141 scaled factor m = | 144 scaled factor m = //!!! v inefficient |
142 generate do row col: factor * m.getAt row col done m.size; | 145 generate do row col: factor * m.getAt row col done m.size; |
143 | 146 |
144 resizedTo newsize m = | 147 resizedTo newsize m = //!!! also v inefficient |
145 (oldsize = m.size; | 148 (oldsize = m.size; |
146 if newsize == oldsize then m | 149 if newsize == oldsize then m |
147 else | 150 else |
148 generate do row col: | 151 generate do row col: |
149 if row < oldsize.rows and col < oldsize.columns | 152 if row < oldsize.rows and col < oldsize.columns |
232 else | 235 else |
233 make (RowM (array (map (block.data . (block.rangeOf start count)) (asRows m)))) | 236 make (RowM (array (map (block.data . (block.rangeOf start count)) (asRows m)))) |
234 fi; | 237 fi; |
235 | 238 |
236 { | 239 { |
237 constMatrix, randomMatrix, zeroMatrix, identityMatrix, zeroSizeMatrix, | 240 generate, |
238 generate, | 241 constMatrix, randomMatrix, zeroMatrix, identityMatrix, zeroSizeMatrix, |
239 width, height, | 242 width, height, |
240 equal, | 243 equal, |
241 copyOf, | 244 copyOf, |
242 transposed, | 245 transposed, |
243 flipped, toRowMajor, toColumnMajor, | 246 flipped, toRowMajor, toColumnMajor, |
244 scaled, | 247 scaled, |
245 resizedTo, | 248 resizedTo, |
246 asRows, asColumns, | 249 asRows, asColumns, |
247 sum = sum', product, | 250 sum = sum', product, |
248 concat, | 251 concat, |
249 rowSlice, columnSlice, | 252 rowSlice, columnSlice, |
250 newMatrix, newRowVector, newColumnVector, | 253 newMatrix, newRowVector, newColumnVector, |
254 } as { | |
255 generate is (number -> number -> number) -> { .rows is number, .columns is number } -> matrix, | |
256 constMatrix is number -> { .rows is number, .columns is number } -> matrix, | |
257 randomMatrix is { .rows is number, .columns is number } -> matrix, | |
258 zeroMatrix is { .rows is number, .columns is number } -> matrix, | |
259 identityMatrix is { .rows is number, .columns is number } -> matrix, | |
260 zeroSizeMatrix is () -> matrix, | |
261 width is matrix -> number, | |
262 height is matrix -> number, | |
263 equal is matrix -> matrix -> boolean, | |
264 copyOf is matrix -> matrix, | |
265 transposed is matrix -> matrix, | |
266 flipped is matrix -> matrix, | |
267 toRowMajor is matrix -> matrix, | |
268 toColumnMajor is matrix -> matrix, | |
269 scaled is number -> matrix -> matrix, | |
270 resizedTo is { .rows is number, .columns is number } -> matrix -> matrix, | |
271 asRows is matrix -> list<block>, | |
272 asColumns is matrix -> list<block>, | |
273 sum is matrix -> matrix -> matrix, | |
274 product is matrix -> matrix -> matrix, | |
275 concat is (Horizontal () | Vertical ()) -> list<matrix> -> matrix, | |
276 rowSlice is number -> number -> matrix -> matrix, | |
277 columnSlice is number -> number -> matrix -> matrix, | |
278 newMatrix is (ColumnMajor () | RowMajor ()) -> list<block> -> matrix, | |
279 newRowVector is block -> matrix, | |
280 newColumnVector is block -> matrix, | |
251 } | 281 } |
252 | 282 |