Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you get an iterator to a row of a boost::numeric::ublas::matrix<T>?

Tags:

c++

boost

ublas

I'm working on matrix multiplication, and I would like an iterator over a single row of a boost matrix? Can this be done?

Currently, I have to get an iterator and advance it. It seems like too much CPU work / non-optimized...

boost::numeric::ublas::matrix<T> aMatrix(2048, 4096);
typename boost::numeric::ublas::unbounded_array<T>::iterator it;
it = aMatrix.data().begin();
offset = row * aMatrix.size2();
advance(it, offset);
like image 225
Zak Avatar asked Sep 01 '25 17:09

Zak


1 Answers

Eureka! Matrix proxies...

boost::numeric::ublas::matrix_row<boost::numeric::ublas::matrix<T> > aRow(aMatrix, row);
like image 148
Zak Avatar answered Sep 04 '25 06:09

Zak