Having a 7x5 matrix flattened to a std::vector, I want to get a view on columns and rows using Eric Niebler's range-v3 library. So far, I managed (room for improvement) to get a view on a single row, a single column and to connected rows.
See: https://wandbox.org/permlink/8o4RgSucF3zSNuPN
std::vector<int> numbers = {
00, 01, 02, 03, 04,
10, 11, 12, 13, 14,
20, 21, 22, 23, 24,
30, 31, 32, 33, 34,
40, 41, 42, 43, 44,
50, 51, 52, 53, 54,
60, 61, 62, 63, 64,
};
const size_t n = 5;//number of columns
//Row_3 = {30, 31, 32, 33, 34}
auto Row_3 = numbers | GetRow(3, n);
std::cout << Row_3 << std::endl;
//Col_2 = {02, 12, 22, 32, 42, 52, 62}
auto Col_2 = numbers | GetColumn(2, n);
std::cout << Col_2 << std::endl;
//Row_2_3_4 = {{20, 21, 22, 23, 24},
// {30, 31, 32, 33, 34},
// {40, 41, 42, 43, 44}}
auto Rows_2_3_4 = numbers | GetConnectedRows(2, 4, n);
std::cout << Rows_2_3_4 << std::endl;
But how can I get a fast view on:
list of rows:
auto a = numbers | GetRows({2,3,5}, n);
connected columns:
auto b = numbers | GetCols(2, 4, n);
list of columns:
auto c = numbers | GetCols({1,2,4}, n);
list of rows ("unsorted"):
auto d = numbers | GetRows({5,2,3}, n);
list of columns ("unsorted"):
auto e = numbers | GetCols({4,1,2}, n);
?