-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpitfall.cc
More file actions
25 lines (21 loc) · 754 Bytes
/
pitfall.cc
File metadata and controls
25 lines (21 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// -*- mode: c++; coding: utf-8 -*-
// ra-ra/examples - Pitfalls of assigning to lower rank
// (c) Daniel Llorens - 2021
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License as published by the Free
// Software Foundation; either version 3 of the License, or (at your option) any
// later version.
#include "ra/ra.hh"
#include <iostream>
using std::cout, std::endl, std::flush;
int main()
{
// Matching flat array to nested array
{
ra::Small<double, 3, 2> a = {{1, 2}, {3, 4}, {5, 6}};
// b(i) = a(i, ∀ j), which in practice is b(i) = a(i, 1)
ra::Small<ra::Small<double, 2>, 3> b = a;
// 2 2 4 4 6 6 (probably)
cout << b << endl;
}
}