2.37 Exercise 2.37
matrix-*-matrix maps over each row of the matrix a procedure that maps
multiplication by the scalar v over the entries in the row.
(define (matrix-*-vector m v) | (map (lambda (r) (map (lambda (e) (* e v)) r)) m)) |
|
transpose uses cons with accumulate-n to create a list of lists
made up of the columns of the original matrix.
(define (transpose mat) | (accumulate-n cons nil mat)) |
|
matrix-*-matrix computes the dot-product of each row of m with
each column of n (where the columns are found with transpose).
(define (matrix-*-matrix m n) | (let ((cols (transpose n))) | (map | (lambda (row) | (map (lambda (col) (dot-product row col)) | cols)) | m))) |
|