Boost logo

Ublas :

From: Gross, Steve (SGross_at_[hidden])
Date: 2007-04-30 15:45:10

I'm trying to figure out if it's possible to get a proxy vector to a matrix row or column and not have to know about the source of the data. That is, let's say you've got some function permuteVector that takes a vector_range reference as input, and alters the data somehow:

void permuteVector(vector_range & v) { /* permute V somehow... */ }

Now you want to invoke permuteVector on both a matrix row and a matrix column:

typedef matrix<double> Matrix;
Matrix m(3, 3);

/* m(0, 0) = ... */

matrix_row<Matrix> row(m, 1);
matrix_col<Matrix> col(m, 1);

permuteVector(vector_range<matrix_row<Matrix> (row, range(0, 3));
permuteVector(vector_range<matrix_col<Matrix> (col, range(0, 3));

But wait! This code won't compile, because vector_range is templatized on the type of data it points to.

Is there a way to pass in a vector_range (pointing to a row) or a vector_range (point to a column) to the same function?

--Steve (sgross_at_[hidden])