My question is related to Boost.MultiArray class. I understand how to convert a multi_array object into a array_view object as the following codes show:
int my_row = 5;
int my_col = 7;
boost::multi_array<int,2> my_matrix(boost::extents[my_row][my_col]);
int *b = new int [my_row*my_col];
int loop = 0;
for(int i=0; i<my_row; i++)
{
for(int j=0; j<my_col; j++)
{
loop = loop+1;
my_matrix[i][j]=loop;
}
}
std::cout<<"The matrix"<<std::endl;
for (int i=0; i<my_row; i++)
{
for(int j=0; j<my_col; j++)
std::cout<<my_matrix[i][j]<<" ";
std::cout<<std::endl;
}
int new_row = 3;
int new_col = 4;
boost::multi_array<int,2>::array_view<2>::type my_view =
my_matrix[boost::indices
[boost::multi_array<int,2>::index_range(0,new_row,1)]
[boost::multi_array<int,2>::index_range(0,new_col,1)]
];
std::cout<<"The view"<<std::endl;
for (int i=0; i<new_row; i++)
{
for(int j=0; j<new_col; j++)
std::cout<<my_view[i][j]<<" ";
std::cout<<std::endl;
}
My question is since the array_view object is very similar to multi_array object is there a way to transform the array_view object into a multi_array object?