From: David Doria <daviddoria@gm...>  20090715 16:42:57

There is a matlab function reshape() that lets you "wrap" or "reshape" a vector into a matrix. I did not see anything like this in VNL (maybe I missed it?). If so, maybe something like this can be added (templated, of course)? vnl_matrix<double> Reshape(const vnl_vector<double> &V, const unsigned int rows, const unsigned int cols) { //This function reshapes a vector into a matrix using row major construction. //check input sizes if(V.size() != rows*cols) { std::cout << "Data sizes do not match!" << std::endl; } vnl_matrix<double> M(rows, cols); unsigned int counter = 0; for(unsigned int r = 0; r < rows; r++) { for(unsigned int c = 0; c < cols; c++) { M(r,c) = V[counter]; counter++; } } return M; } Thanks, David 