-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
Broadly, there are two types of operations performed by these matrix summarisations:
- matrix-to-vector
- matrix-to-matrix
To take two examples from matrixStats:
- matrix-to-vector:
val <- colMedians(x)results inlength(val) == ncol(x) - matrix-to-matrix:
val <- colCummaxs(x)results indim(val) == dim(x)
Particularly for matrix-to-matrix ops where the input is a disk-backed object, it may be desirable to be able to specify that the result should be realised on disk (or via some other backend) instead of as an ordinary matrix.
I see two options for the 'contract' of the generic and methods:
- Methods must always return an ordinary vector (matrix-to-vector) or matrix (matrix-to-matrix)
- Methods may return any suitable vector-like (matrix-to-vector) or matrix-like (matrix-to-matrix) object. E.g., the
colCummaxs,DelayedMatrix-methodmight gain aBACKENDargument to specify what sort of object should be returned (with some sort of sensible default based on the class of the input).
I favour (2), although its flexibility makes for a somewhat 'loose' contract between the input and output.