matrix-product in blas3.lisp calls the gsl_blas gemm routine. It has optional parameters TransA and TransB to specify whether the matrices A and/or B should be transposed prior to multiplying. These two take values :trans or :notrans.
The bug is twofold. matrix-product calls matrix-product-dimensions (defined in blas2). To do its job properly, matrix-product-dimensions should have TransA and TransB as parameters, and matrix-product should call it with those as arguments.
Here is the modified matrix-product-dimensions:
(defun matrix-product-dimensions (a b &optional (TRANSA :NOTRANS) (TRANSB :NOTRANS))
(if (typep b 'grid:matrix)
(list (funcall (case transa
(:notrans #'first)
(:trans #'second)
(t (error "Invalid tranposition keyword, ~a" transa)))
(grid:dimensions a))
(funcall (case transb
(:notrans #'second)
(:trans #'first)
(t (error "Invalid tranposition keyword, ~a" transb)))
(grid:dimensions b)))
(first (funcall (case transa
(:notrans #'first)
(:trans #'second)
(t (error "Invalid tranposition keyword, ~a" transa)))
(grid:dimensions a)))))
This can probably be improved. I applied the same fix to the case when b is not a matrix, since matrix-product in blas2 which works on matrix x vector, also accepts that TransB argument.