dimforge / dimforge/nalgebra

Multiply matrix by vector row-wise

Open
#1,358 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.8k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

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]]

I understand that I can convert my vector into a square matrix, then use `*` (or `dot`) or code a generic function that does this task but multiplying each row with a number will be faster.

I thought there would be be a method/operator that does it, so I asked this question on the r/rust "simple question" post and on [SO](https://stackoverflow.com/questions/77888714/multiply-matrix-by-vector-row-wise). It seems that such a method doesn't exist. Can you please confirm?

Moreover, if this is right, should we add this method, and what would be its name?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.