Hi,
*) First question:
I am trying to get a reference to data of a container in the following way:
matrix<double> m(3,3); vector<double>& v(m.column(2));
But this seems not to be possible.
Is there a way to achieve this behaviour?
Either use
matrix_column
What I basically want to achive is having functor object that holds a reference to a row/column of my container matrix.
Looks like you'll need [1].
From my questions about argument types I know that m.column(2) is a kind of an expression. How can I get the underlying reference to data if there even is one?
You could start with m.column(2).data() and traverse the expression tree then. In my experience this only is needed for special applications like bindings to external libraries. I'd generally advise against using it.
*) Second question:
matrix<double> m(10,3);
... fill the matrix ...
matrix<double>::iterator it; // wrong this does not work!!
for (it = m.column(2).begin(); it != m.colum(2).end(); ++it) { cout << *it << " " << foo(*it) << endl; }
How would I declare my iterator? I understand when I use std::library-algorithms the automatic template parameter defer will give me the correct type from begin(). But in my case how should I declare
matrix_column
iterator?
HTH, Joerg