shard_apply_matrix: Apply a Function Over Matrix Columns with Shared Inputs
Description
A convenience wrapper for the common "per-column apply" pattern. The matrix
is shared once and each worker receives a zero-copy column view when possible.
An atomic vector of length ncol(X) with the results.
Arguments
X
A numeric/integer/logical matrix (or a shared matrix created by share()).
MARGIN
Must be 2 (columns).
FUN
Function of the form function(v, ...) returning a scalar atomic.
VARS
Optional named list of extra variables. Large atomic VARS are
auto-shared based on policy$auto_share_min_bytes.
workers
Number of workers (passed to shard_map()).
...
Additional arguments forwarded to FUN.
policy
A shard_apply_policy() object.
Details
Current limitation: MARGIN must be 2 (columns). Row-wise apply would require
strided/gather slicing and is intentionally explicit in shard via views/kernels.