chickadee » matrix-utils » make-fill-matrix


Given a procedure VECTOR-SET!, returns a procedure FILL-MATRIX! of the form FILL-MATRIX!:: M * N * A * F * F0 * [IX * IY * EX * EY] -> A

Where procedure FILL-MATRIX! fills matrix A of size M x N with the values returned by applying procedure F to each pair of indices in the matrix.

Procedure F is of the form LAMBDA I J AX -> VAL * AX1, where I, J are matrix indices, and AX is accumulator value (like in fold). The initial value of AX is given by F0. Procedure F is expected to return two values: the value to be placed in matrix A at position [I,J], and the new accumulator value (or #f).

Optional arguments IX IY EX EY may specify a sub-matrix in matrix A to be filled. These arguments are checked to make sure they specify a valid sub-matrix.

VECTOR-SET! is one of the homogeneous vector setting procedures from SRFI-4. Procedure F must ensure that it returns values that are within the range of the SRFI-4 type used.