chickadee » matrix-utils » make-matrix-fold

make-matrix-fold:procedure

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

Where procedure MATRIX-FOLD 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.

Procedure F is of the form LAMBDA I J 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.

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.