When I added array broadcasting to SRFI 231 here GitHub - gambiteer/srfi-231 at 231-bis I made some design decisions that differ from those in Racket's math/array and I would like to compare the implementations of the two libraries.
I'd like someone to help by adding type annotations to the following small program to test the interaction of array broadcasting with folding along an axis so that the program will run in Typed Racket.
Thanks.
Brad
#lang racket
(require math/array)
(require math/matrix)
(require racket/flonum)
(define (matrix-multiply A B)
(array-axis-fold
(array-map
fl*
(array-axis-insert A 2)
(array-axis-insert B 0))
1
fl+))
(define A (build-array #(100 100) (lambda (multi-index)
(exact->inexact (- (vector-ref multi-index 0)
(vector-ref multi-index 1))))))
(define B (build-array #(100 100) (lambda (multi-index)
(exact->inexact (+ (vector-ref multi-index 0)
(vector-ref multi-index 1))))))
(define C (time (matrix-multiply A B)))
(define A* (build-matrix 100 100 (lambda (i j)
(exact->inexact (- i
j)))))
(define B* (build-matrix 100 100 (lambda (i j)
(exact->inexact (+ i
j)))))
(define C* (time (matrix* A* B*)))