Mercurial > hg > may
changeset 447:926f2986a5e0
A bit tidier (though no faster)
author | Chris Cannam |
---|---|
date | Thu, 24 Oct 2013 09:18:15 +0100 |
parents | 1b879a959f84 |
children | 3a7b70ecfb70 |
files | .hgsubstate src/may/matrix.yeti |
diffstat | 2 files changed, 19 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsubstate Thu Oct 24 09:18:02 2013 +0100 +++ b/.hgsubstate Thu Oct 24 09:18:15 2013 +0100 @@ -1,1 +1,1 @@ -4b91cd40a51b64283ba6b5550709e89f6ec492db ext +0530a3093ed168e9328434d02e4be55962e546bf ext
--- a/src/may/matrix.yeti Thu Oct 24 09:18:02 2013 +0100 +++ b/src/may/matrix.yeti Thu Oct 24 09:18:15 2013 +0100 @@ -47,34 +47,31 @@ load may.vector.type; load may.matrix.type; -size m = +width m = case m of DenseRows r: - major = length r; - { - rows = major, - columns = if major > 0 then vec.length r[0] else 0 fi, - }; + if not empty? r then vec.length r[0] else 0 fi; DenseCols c: - major = length c; - { - rows = if major > 0 then vec.length c[0] else 0 fi, - columns = major, - }; + length c; SparseCSR { values, indices, pointers, extent }: - { - rows = (length pointers) - 1, - columns = extent - }; + extent; SparseCSC { values, indices, pointers, extent }: - { - rows = extent, - columns = (length pointers) - 1 - }; + (length pointers) - 1; esac; -width m = (size m).columns; -height m = (size m).rows; +height m = + case m of + DenseRows r: + length r; + DenseCols c: + if not empty? c then vec.length c[0] else 0 fi; + SparseCSR { values, indices, pointers, extent }: + (length pointers) - 1; + SparseCSC { values, indices, pointers, extent }: + extent; + esac; + +size m = { rows = height m, columns = width m }; nonZeroValues m = (nz d =