Skip to content

Commit d0b6631

Browse files
committed
Simplify ViewBig conversion constructors
We want to use std::array instead of Small for ViewBig::Dimv, because Small won't be defined yet for the coming refactored version, and we already have to deal with non-ra dimv for the var-rank version. * ra/arrays.hh (ViewBig): As stated. (swap): Refactor. * box/view.cc: ViewSmall/ViewBig refactor sandbox. * ra/base.hh (VERSION): Bump to 32.
1 parent 15e77f5 commit d0b6631

File tree

6 files changed

+122
-133
lines changed

6 files changed

+122
-133
lines changed

box/SConstruct

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ env.Prepend(CPPPATH=['..', '.'],
5050
LINKFLAGS=raflags['LINKFLAGS'])
5151

5252
[ra.to_test_ra(env, variant_dir)(example)
53-
for example in ['tuple-construct', 'iterator-as-ravel']]
53+
for example in ['tuple-construct', 'iterator-as-ravel', 'view']]
5454

5555
if not top['skip_summary']:
5656
atexit.register(lambda: ra.print_summary(GetBuildFailures, 'ra/box'))

ra/arrays.hh

Lines changed: 98 additions & 108 deletions
Large diffs are not rendered by default.

ra/base.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ struct choose_<D, O>
299299
// Properly ra::.
300300
// ---------------------
301301

302-
constexpr int VERSION = 31;
302+
constexpr int VERSION = 32;
303303
constexpr int ANY = -1944444444; // only static, meaning tbd at runtime
304304
constexpr int UNB = -1988888888; // unbounded, eg dead axes
305305
constexpr int MIS = -1922222222; // mismatch, only from common_len

test/big-1.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ int main()
8080
ra::Big<int, 2> a ({2, 3}, {0, 1, 2, 3, 4, 5});
8181
ra::Big<int, 2> b ({2, 3}, {0, 1, 2, 3, 4, 5});
8282
auto c = transpose(ra::ViewBig<int *, 2>({3, 2}, a.data()), {1, 0});
83-
a.dimv = c.dimv;
83+
ra::iter(a.dimv) = c.dimv;
8484
for (int k=0; k!=c.rank(); ++k) {
8585
std::cout << "CSTRIDE " << k << " " << c.step(k) << std::endl;
8686
std::cout << "CLEN " << k << " " << c.len(k) << std::endl;

test/ra-0.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ int main()
7171
{
7272
double aa[6] = { 1, 2, 3, 4, 5, 6 };
7373
aa[0] = 99;
74-
ra::ViewBig<double *, 2> a { { {3, 2}, {2, 1}}, aa };
74+
ra::ViewBig<double *, 2> a { {{3, 2}, {2, 1}}, aa };
7575
tr.test_eq(4., a(1, 1));
7676
tr.test_eq(99., a.data()[0]);
7777
}

test/swap.cc

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,23 @@ using std::cout, std::endl, std::flush, ra::TestRecorder;
1515
int main()
1616
{
1717
TestRecorder tr;
18-
auto test =
19-
[&](auto & a0, auto & a1, auto & b0, auto & b1)
20-
{
21-
auto ap = a1.data();
22-
auto bp = b1.data();
23-
tr.test_eq(a0, a1);
24-
tr.test_eq(b0, b1);
25-
swap(a1, b1);
26-
tr.test_eq(a0, b1);
27-
tr.test_eq(b0, a1);
28-
tr.test_eq(ra::scalar(ap), ra::scalar(b1.data()));
29-
tr.test_eq(ra::scalar(bp), ra::scalar(a1.data()));
30-
swap(b1, a1);
31-
tr.test_eq(a0, a1);
32-
tr.test_eq(b0, b1);
33-
tr.test_eq(ra::scalar(ap), ra::scalar(a1.data()));
34-
tr.test_eq(ra::scalar(bp), ra::scalar(b1.data()));
35-
};
36-
tr.section("swap ct and rt");
18+
auto test = [&](auto & a0, auto & a1, auto & b0, auto & b1){
19+
auto ap = a1.data();
20+
auto bp = b1.data();
21+
tr.test_eq(a0, a1);
22+
tr.test_eq(b0, b1);
23+
swap(a1, b1);
24+
tr.test_eq(a0, b1);
25+
tr.test_eq(b0, a1);
26+
tr.test_eq(ra::scalar(ap), ra::scalar(b1.data()));
27+
tr.test_eq(ra::scalar(bp), ra::scalar(a1.data()));
28+
swap(b1, a1);
29+
tr.test_eq(a0, a1);
30+
tr.test_eq(b0, b1);
31+
tr.test_eq(ra::scalar(ap), ra::scalar(a1.data()));
32+
tr.test_eq(ra::scalar(bp), ra::scalar(b1.data()));
33+
};
34+
tr.section("swap ct and rt. Ranks must be the same.");
3735
{
3836
ra::Small<int, 2, 3> a0 = 1 + ra::_0 - ra::_1;
3937
ra::Big<int, 2> a1 ({2, 3}, 1 + ra::_0 - ra::_1);
@@ -43,7 +41,7 @@ int main()
4341

4442
test(a0, a1, b0, b1);
4543
}
46-
tr.section("swap ct and ct");
44+
tr.section("swap ct and ct. Ranks must be the same.");
4745
{
4846
ra::Small<int, 2, 3> a0 = 1 + ra::_0 - ra::_1;
4947
ra::Big<int, 2> a1 ({2, 3}, 1 + ra::_0 - ra::_1);
@@ -53,10 +51,11 @@ int main()
5351

5452
test(a0, a1, b0, b1);
5553
}
56-
tr.section("swap rt and rt");
54+
tr.section("swap rt and rt. Ranks need not be the same.");
5755
{
5856
ra::Small<int, 2, 3> a0 = 1 + ra::_0 - ra::_1;
5957
ra::Big<int> a1 ({2, 3}, 1 + ra::_0 - ra::_1);
58+
6059
ra::Small<int, 2, 3, 4> b0 = 1 - ra::_0 + ra::_1 + ra::_2;
6160
ra::Big<int> b1 ({2, 3, 4}, 1 - ra::_0 + ra::_1 + ra::_2);
6261

0 commit comments

Comments
 (0)