How can I multiply a matrix and a vector "row-wise" in nalgebra? Like I would do in numpy
>>> m = np.eye(3)
>>> v = np.array([1, 2, 3])
>>> m * v # Or v * m
# Gives [[1, 0, 0],
# [0, 2, 0],
# [0, 0, 3]]
What I tried:
dotis doing the "real" math operation (outputting a vector)m * vorv * mdoesn't work because it wants either 2 matrices or 2 vectorscomponent_mulrequires the same number of elements
Note: I know that I can convert my vector into a matrix and use other operations, but my goal is to avoid useless work.
You would need to know what numpy calulates. In both cases
v * morm * v, if I multiply a vector by the identity matrix, the result is that vector:eg.
[1.0, 2.0, 3.0]The straight-forward method to write the vector elements directly into the matrix would only need one loop: