This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Amend Vector of ones to Matrix

Tags: None
(comma "," separated)
JLoveless
Registered Member
Posts
6
Karma
0

Amend Vector of ones to Matrix

Wed Aug 17, 2011 8:30 pm
How would one go about amending a vector of 1's to a matrix

E.g.
Code: Select all
Matrix3f mat;
mat<<1,2,3,
     4,5,6,
     7,8,9;

Vector3f vec(1,1,1);

to yield
Code: Select all
MatrixXf vecmat(3,4);
vecmat<<1,1,2,3,
        1,4,5,6,
        1,7,8,9;

Thank you in advance!
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
what about:

vecmat.resize(3,4);
vecmat << Vector3f::Constant(1), mat;
JLoveless
Registered Member
Posts
6
Karma
0

Re: Amend Vector of ones to Matrix

Wed Aug 17, 2011 8:38 pm
That's perfect thank you.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]