I’m looking for a fast way of creating a new matrix A_{ij} from a given vector b_i and another
matrix C_{ij}. The components of the new matrix should have the form
A_{ij} = b_i * C_{ij}.
So far I am using dot(diag(b), C), but the dot product naturally has a lot of multiplications
with zero, which is quite inefficient. Is there a better way?
Use
*, the element-wise product with the appropriate broadcasting:atleast_2d(b).T(orb.reshape(-1,1)) reshapes the vectorbto a column vector.