chickadee » matrix-utils » make-matrix-fold-partial

make-matrix-fold-partial:procedure

Given a procedure VECTOR-REF, returns a procedure MATRIX-FOLD-PARTIAL of the form MATRIX-FOLD-PARTIAL:: M * N * A * F * P * X0 * [IX * IY * EX * EY] -> XN

Where procedure MATRIX-FOLD-PARTIAL applies the fold operation on a matrix A of size M x N with the values returned by applying procedure F to each pair of indices and the corresponding value at that position in the matrix. MATRIX-FOLD-PARTIAL first applies the predicate P to the current pair of indices, and if the result is true, then F is applied.

Procedure F is of the form LAMBDA V AX -> AX1, where V is a matrix element at position (I,J) and AX is accumulator value. The initial value of AX is given by X0. Procedure F is expected to return the new accumulator value.

Procedure P is of the form LAMBDA I J -> boolean, where I,J are matrix indices.

Optional arguments IX IY EX EY may specify a sub-matrix in matrix A.

VECTOR-REF is one of the homogeneous vector accessor procedures from SRFI-4.