I've just merged a change from Bradley Lucier, author of SRFI 179.  This change is an improvement to the examples and to the corresponding tests.  It does not change the API.

I've added a post-finalization note to explain the change.

Thanks to Bradley for this update.

---------- Forwarded message ---------
From: Bradley Lucier <xxxxxx@github.com>
Date: Thu, Dec 10, 2020 at 9:14 AM
Subject: [scheme-requests-for-implementation/srfi-179] Improve inefficient examples and add commentary (#17)
To: scheme-requests-for-implementation/srfi-179 <xxxxxx@noreply.github.com>
Cc: Subscribed <xxxxxx@noreply.github.com>


array-curry returns an immutable array, whose elements, which are themselves arrays, are computed anew each time they are accessed.

If passed as arguments to (array-outer-product op A B) and if all the elements of the result of array-outer-product are then accessed, then each element of A is accessed (array-volume B) times, and each element of B is accessed (array-volume A) times. In this situation, passing the results of array-curry as arguments to array-outer-product results in some inefficiency.

So we use array-copy to convert the result of array-curry to a specialized array before passing to array-outer-product in the matrix-multiply and inner-product examples, which are the same, really, because

(equal (matrix-multiply A B) (array-inner-product A + * B)) => #t


You can view, comment on, or merge this pull request online at:

  https://github.com/scheme-requests-for-implementation/srfi-179/pull/17

Commit Summary

  • Copy row and column arrays in matrix multiplication example.
  • Precompute curried arguments to array-outer-product
  • Fix type