
On Tue, Mar 8, 2011 at 8:44 PM, Ryan
Is it possible to predefine a subrange or project with a specific range so that when called I only had to pass in the matrix? I'm currently dealing with several 9x9 matrices that I need to access the 3x3 submatrix (topleft, topmiddle, topright, etc.). Is there a way to typedef or templatize a subrange or project so that I just need to pass the 9x9 matrix and get the topleft matrix?
Example:
typedef subrange(input_matrix, 0, 3, 0, 3) topleft; //This is what I want to somehow define.
You can't do that. If you don't want to write every time the "subrange" expression you can always create a macro or (better) a function like the one: namespace ublas = ::boost::numeric::ublas; template <typename MatrixT> inline ublas::matrix_range<MatrixT> topleft(MatrixT& M) { return ublas::subrange(M, 0, 3, 0, 3); } and use this function just like the case here below:
matrix<double> A(9,9); topleft(A) = zero_matrix<double>(3,3);
Best, -- Marco