-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
The method matmul
defined in the documentation has multiple problems:
R = promote_op(op, eltype(a), eltype(b))
does not work as promote_op
is not exported from Base
nor public
. To get it to run we would need to write Base.promote_op
, but do we really want to encourage using private symbols?
It uses arguments of type AbstractMatrix
, but then uses indices always starting from 1 which fails with OffsetMatrix
. Reproducer:
using Base: promote_op
a = OffsetMatrix([1 2; 3 4], -2, -2)
matmul(a, a)
To be fair, it's introduced with "a generic square-matrix multiply pseudo-code might look like", i.e. mentioning that it should be "pseudo-code". However, I think this is compensated by calling it "generic".
I think this example should be improved, it should be removed or at least some hints about the shortcomings should be added. The latter one has the disadvantage of not being so observable both for humans and machines (e.g. in training LLMs).