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

Creating boolean Array of false and setting rows

Tags: None
(comma "," separated)
matriza
Registered Member
Posts
17
Karma
0
Hi,

I'd like to initialize a dynamic boolean Array and set it to true. At the moment I'm using:
Code: Select all
MatrixXf tmp = MatrixXf::Zero(p, K);
Array<bool, Dynamic, Dynamic> active = (tmp.array() == 0);

Is there a better way?

Also, how do I set an entire row of that Array to false?
Code: Select all
active.row(0) = false;

doesn't work.

Thanks.
jitseniesen
Registered Member
Posts
204
Karma
2
Code: Select all
typedef Array<bool, Dynamic, Dynamic> ArrayXXb;
ArrayXXb active = ArrayXXb::Constant(p, K, false);   // create a p-by-K array and fill it with 'false'
ArrayXXb active2; active2.setConstant(p, K, false);  // alternative method
active.row(0).setConstant(false);                    // set first row to 'false'
See the Quick reference guide for a list of useful commands, including these.
matriza
Registered Member
Posts
17
Karma
0


Bookmarks



Who is online

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