changeset 475:ac3dd9a9d924

Add minValue, maxValue
author Chris Cannam
date Thu, 31 Oct 2013 18:25:11 +0000
parents 0541d0d722df
children fb39f266d810
files src/may/matrix.yeti
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/may/matrix.yeti	Wed Oct 30 10:20:34 2013 +0000
+++ b/src/may/matrix.yeti	Thu Oct 31 18:25:11 2013 +0000
@@ -759,6 +759,20 @@
             fi
     fi);
 
+minValue m =
+    if empty?' m then 0
+    else 
+        minv ll = fold min (head ll) (tail ll);
+        minv (map (.v) (enumerate m));
+    fi;
+
+maxValue m =
+    if empty?' m then 0
+    else 
+        maxv ll = fold max (head ll) (tail ll);
+        maxv (map (.v) (enumerate m));
+    fi;
+
 //!!! todo: look at all occurrences of matrix (and complexmatrix)
 // construction and make sure we have good apis for those use cases.
 // in particular, constructing from literal data (list<list<number>>)
@@ -793,6 +807,8 @@
     toDense,
     scaled,
     resizedTo,
+    minValue,
+    maxValue,
     asRows,
     asColumns,
     sum = sum',
@@ -845,6 +861,8 @@
     toDense is matrix -> matrix,
     scaled is number -> matrix -> matrix,
     resizedTo is { .rows is number, .columns is number } -> matrix -> matrix,
+    minValue is matrix -> number,
+    maxValue is matrix -> number,
     asRows is matrix -> list<vector>, 
     asColumns is matrix -> list<vector>,
     sum is matrix -> matrix -> matrix,