Thank you very much.
----- Original Message -----
From: "Rhys Ulerich"
//choose the third column: array_1d_view_t col_view = A[ boost::indices[ range_t(0,M) ][2] ]; boost::multi_array_ref< int, 1> col( &(col_view[0]), boost::extents[M], boost::fortran_storage_order() );
multi_array_ref wraps a contiguous block of storage [1]. Since matrix A has Fortran ordering, the column is contiguous and your code works.
// and the same for row array_1d_view_t row_view = A[ boost::indices[2][range_t(0,N)] ]; boost::multi_array_ref< int, 1> row( &(row_view[0]), boost::extents[N], boost::fortran_storage_order() );
Rows in Fortran ordering are not contiguous, row_view is not contiguous, and "wrapping" row_view with multi_array_ref isn't what you want. Had you worked with C ordering in your sample code, the columns would fail but the rows would work. You should be using the views directly. Each view models the MultiArray concept and has (nearly) all the iterator goodness that multi_array and multi_array_ref do: //choose the third column: array_1d_view_t col_view = A[ boost::indices[ range_t(0,M) ][2] ]; //..and show it cout << endl << "It's third column is:" << endl; for ( array_1d_view_t::iterator it = col_view.begin(); it != col_view.end(); ++it ) { cout << *(it) << endl; } //and the same for row: array_1d_view_t row_view = A[ boost::indices[2][range_t(0,N)] ]; cout << endl << "It's third row is:" << endl; for ( array_1d_view_t::iterator it = row_view.begin(); it != row_view.end(); ++it ) { cout << *(it) << endl; } - Rhys [1] http://www.boost.org/doc/libs/1_42_0/libs/multi_array/doc/reference.html#mul... _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users