Eigen :: RowVector Iterator

Can someone tell me how on earth can I repeat Eigen :: RowVectorXf?

I searched for 3 hours over the Internet and the documentation, and all I could find was from this link , which I can access:

vector(i) vector[i] 

I have:

 auto vec = std::make_shared<Eigen::RowVectorXf>( rowIndex.size() ); 

Which I want to fill with word frequencies.

 Eigen::RowVectorXf::InnerIterator it(vec); it; ++it 

Not working and

 Eigen::RowVectorXf::Iterator it(vec); it; ++it 

Does not exist.

The only thing that works:

 for ( int i = 0; i < vec->row( 0 ).size(); i++ ) { std::cout << vec->row( 0 )[i] << std::endl; } 

Which IMHO seems bizzare, since I do not need to explicitly point to the string (0), since this is RowVector.

Is there a cleaner, faster, or more elegant way?

+4
source share
1 answer

There is no need for line (0), you can use β†’ coeff (i) (not recommended, because it skips statements, even in debug mode) or use the * operator to dereference your shared_pointer :

 for(int i=0; i<vec->size(); ++i) cout << (*vec)[i]; 

You can also use InnerIterator, but you have to dereference your shared_pointer :

 RowVectorXf::InnerIterator it(*vec); it; ++it 
+8
source

Source: https://habr.com/ru/post/1483473/


All Articles