The observed behavior of Matrix-Vector and Vector-Matrix multiplication in the library is by design. Distinguishing column
and row
vectors is not possible within mere Vector
type, so explicit matrix-by-vector multiply and vector-by-matrix multiply operations simply have respective signatures:
Matrix.Multiply: Vector -> Vector // matrix-by-vector
and
Matrix.LeftMultiply: Vector -> Vector // vector-by-matrix
where in the first case both argument and result are assumed column
vectors, and in the second case both are assumed row
ones.
The library always assumes "right" vector orientation when chaining operations in more complex expressions, at the same time enforcing other dimensionality checks, indeed.
If you want for whatever reason to explicitly distinguishing row
from column
vectors and carry, if required, the burden of explicit transpositions, then using 1-by-n
and n-by-1
matrices in place of row
and column
vectors respectively is the way to go. In this case if matrix dimensions do not agree the library will be throwing System.ArgumentException
instead of silently assuming "right" transposition.