Mercurial > hg > may
changeset 293:f481ac8052c4
Add entrywise product
author | Chris Cannam |
---|---|
date | Fri, 31 May 2013 17:34:04 +0100 |
parents | 240eb77ee2e8 |
children | 9bc985b602b3 |
files | yetilab/matrix.yeti |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/yetilab/matrix.yeti Fri May 31 17:32:56 2013 +0100 +++ b/yetilab/matrix.yeti Fri May 31 17:34:04 2013 +0100 @@ -568,6 +568,13 @@ fi; fi; +entryWiseProduct m1 m2 = // or element-wise, or Hadamard product +//!!! todo: faster, sparse version, units + if (size m1) != (size m2) + then failWith "Matrices are not the same size: \(size m1), \(size m2)"; + else generate do row col: at' m1 row col * at' m2 row col done (size m1); + fi; + concatAgainstGrain tagger getter counter mm = (n = counter (size (head mm)); tagger (array @@ -745,6 +752,7 @@ abs = abs', filter = filter', product, + entryWiseProduct, concat, rowSlice, columnSlice, @@ -793,6 +801,7 @@ abs is matrix -> matrix, filter is (number -> boolean) -> matrix -> matrix, product is matrix -> matrix -> matrix, + entryWiseProduct is matrix -> matrix -> matrix, concat is (Horizontal () | Vertical ()) -> list<matrix> -> matrix, rowSlice is matrix -> number -> number -> matrix, columnSlice is matrix -> number -> number -> matrix,