On Wed, Jan 24, 2024 at 2:27 PM Marten van Kerkwijk <mhvk@astro.utoronto.ca> wrote:
Why do these belong in NumPy? What is the broad field of application of these functions? And, does a more general concept underpin them?
Multiplication of a matrix with a vector is about as common as matrix with matrix or vector with vector, and not currently easy to do for stacks of vectors, so I think the case for matvec is similarly strong as that for matmul and vecdot.
Arguably, vecmat is slightly less common, though completes the quad.
-- Marten
Could you please offer some code or math notation to help communicate this? I am forced to guess at the need. The words "matrix" and "vector" are ambiguous. After all, matrices (of given shape) are a type of vector (i.e., can be added and scaled.) So if by "matrix" you mean "2d array" and by "stack of vectors" you effectively mean "2d array", this sounds like a use for np.dot (possibly after a transpose). However I am going to guess that here by "vector" you actually mean a matrix (i.e., a 2d array) with only one row or only one column, so a "stack" of them is actually 3d. Perhaps the needless dimension is then the real problem and can either not be produced or can be squeezed away.. Thanks, Alan Isaac