On Thu, Aug 12, 2010 at 10:26 AM, Stavros Macrakis
<macrakis at alum.mit.edu> wrote:
> matrix_max and matrix_min are ambiguous: are they row-wise, column-wise, or
> whole-matrix?
How about this? Make it easier to loop over parts of a matrix
(or any other aggregate) and let the user spell out just what they want.
That's better than the developers trying to speculate.
e.g.
(wishful thinking here)
declare (min, distributes_over (whatever));
declare (max, distributes_over (whatever));
where whatever = list, set, matrix
That makes min(whatever) an element-wise operation.
Assuming that X is a whatever object:
[min (X), max (X)];
=> [least value in X, greatest value of X]
Assuming that columns(X) and rows(X) return whatever objects:
map (min, columns (X));
=> least value of each column of X
map (max, rows (X));
=> greatest value of each row of X
rows(X) and columns(X) could probably avoid copying all
of the elements of X if we're clever enough.
By this approach we can avoid having to either
invent a different foo_min/foo_max for each foo aggregate,
or wedging a special case for foo into an existing function.
All that's needed is a function to return an iterable collection
of foo fragments, which is then the argument of min/max/
mean/sum/sort/unique/etc.
FWIW
Robert Dodier