- array-sample array scalesprocedure
We assume that array is an array all of whose lower bounds are zero, and scales is a vector of positive exact integers whose length is the same as the dimension of array.
Informally, if we construct a new matrix $S$ with the entries of scales on the main diagonal, then the $\vec i$th element of (array-sample array scales) is the $S\vec i$th element of array.
More formally, if array is specialized, then array-sample returns
(specialized-array-share array (interval-scale (array-domain array) scales) (lambda multi-index (apply values (map * multi-index (vector->list scales)))))
with the result inheriting the safety and mutability of array.
Otherwise, if array is mutable, then array-sample returns
(make-array (interval-scale (array-domain array) scales) (lambda multi-index (apply (array-getter array) (map * multi-index (vector->list scales)))) (lambda (v . multi-index) (apply (array-setter array) v (map * multi-index (vector->list scales)))))
Finally, if array is immutable, then array-sample returns
(make-array (interval-scale (array-domain array) scales) (lambda multi-index (apply (array-getter array) (map * multi-index (vector->list scales)))))
It is an error if array and scales don't satisfy these requirements.