64 std::cout <<
"[1] Row-major view (Aleph::layout_right, the default)\n";
68 std::vector<double> buf(3 * 4, 0.0);
71 for (
size_t i = 0; i <
m.extent(0); ++i)
72 for (
size_t j = 0; j <
m.extent(1); ++j)
73 m(i, j) =
static_cast<double>(i * 10 + j);
75 std::cout <<
"m(" <<
m.extent(0) <<
"x" <<
m.extent(1) <<
"):\n";
76 for (
size_t i = 0; i <
m.extent(0); ++i)
78 for (
size_t j = 0; j <
m.extent(1); ++j)
79 std::cout <<
m(i, j) <<
"\t";
82 std::cout <<
"Row-major: m(1, 2) sits at buf[1*4 + 2] = buf["
83 << (1 *
m.extent(1) + 2) <<
"] = " << buf[1 * 4 + 2] <<
"\n\n";
88 std::cout <<
"[2] Column-major view (Aleph::layout_left) over the same data\n";
92 std::vector<int> buf(2 * 3);
96 for (
size_t j = 0; j <
m.extent(1); ++j)
97 for (
size_t i = 0; i <
m.extent(0); ++i)
100 std::cout <<
"Column-major fill order produced buf = [";
101 for (
size_t k = 0;
k < buf.size(); ++
k)
102 std::cout << buf[
k] << (
k + 1 < buf.size() ?
", " :
"");
104 std::cout <<
"(first axis varies fastest: m(0,0),m(1,0),m(0,1),... -- the\n"
105 " layout a Fortran/BLAS routine would expect from this buffer)\n\n";
110 std::cout <<
"[3] Read-only view over const data\n";
113 const std::vector<double>
readings{98.6, 99.1, 97.9, 100.2};
117 for (
size_t i = 0; i <
m.extent(0); ++i)
119 std::cout <<
"Average of " <<
m.extent(0) <<
" read-only samples: "
120 << (
total /
static_cast<double>(
m.extent(0))) <<
"\n";
121 std::cout <<
"(m(0) = readings[0]; the view has no write access to \"const double\")\n\n";
127 std::cout <<
"\n=== Aleph::mdspan: zero-copy matrix views ===\n\n";
133 std::cout <<
"Done.\n";
Non-owning multidimensional array view (Aleph::mdspan).
Non-owning view of a contiguous buffer as a multidimensional grid.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
void print_rule()
Prints a horizontal rule for example output separation.
void next()
Advance all underlying iterators (bounds-checked).
Column-major layout: the first axis varies fastest (Fortran convention).
FooMap m(5, fst_unit_pair_hash, snd_unit_pair_hash)