Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting a row of a matrix to 0, in eigen

Tags:

c++

eigen

kind of strange:

I'm trying to set a full row of a matrix to 0 and neither of the four obvious constructs in eigen would compile:

//U is a p by p matrix. I wanna set its last column to 0.0f
U=solved.eigenvectors();   

U.row(p-1).array()=0;              //don't compile
U.row(p-1).setZero(1,p);           //don't compile
U.row(p-1).array().setZero(p);     //don't compile
U.bottomRows(1).setZero(p);        //don't compile

I also tried other variations on these themes but neither passed the compiler

like image 270
user189035 Avatar asked Mar 13 '14 18:03

user189035


1 Answers

You should use:

U.row(p-1).setZero();
like image 198
herohuyongtao Avatar answered Oct 07 '22 03:10

herohuyongtao