Registered Member
|
Say I have two matrices mat1 of size 3xN and mat2 of size m x n. And N = m*n , i.e number of cols in mat1 is same as the size of mat2.
I want to multiply column 0 of a matrix mat1 with mat2(0,0), column 1 of mat1 with mat2(0,1), and so on. If mat2 was a vector of length N, thaen I could have done
How do I do this operation efficiently without creating temporaries , since my N is quite large. Update: One solution I found is to map mat2 to a vector by doing:
But still I would like to know if there is a better way. P.S I have by default row_major enabled, so the above code does what i expect.
Last edited by hijokpayne on Tue Oct 29, 2013 7:05 pm, edited 1 time in total.
|
Moderator
|
Nothing better than the map trick. However, be careful of the storage order of mat2.
|
Registered Member
|
Thanks. I like the .asDiagonal() functionality.
However I feel, it will be nice to have a similar .asVector() functionality for Matrix types. I mean something similar to Matlab's A ( : ). |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]