-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathnested.cc
More file actions
34 lines (23 loc) · 752 Bytes
/
nested.cc
File metadata and controls
34 lines (23 loc) · 752 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
26
27
28
29
30
31
32
33
34
// -*- mode: c++; coding: utf-8 -*-
// ra-ra/examples - Nested heterogeneous arrays
// Daniel Llorens - 2015
// Adapted from blitz++/examples/cast.cpp
#include "ra/ra.hh"
#include <iostream>
using std::cout, std::endl;
int main()
{
ra::Big<ra::Big<int, 1>, 1> A({3}, ra::none);
A(0).resize(3);
A(0) = { 0, 1, 2 };
A(1).resize(5);
A(1) = { 5, 7, 18, 2, 1 };
A(2).resize(4);
A(2) = pow(ra::_0+1, 2);
cout << "A = " << A << endl;
// A = [ [ 0 1 2 ] [ 5 7 18 2 1 ] [ 1 4 9 16 ] ]
// [ra] Note that this is written with the shape in front, so (without the brackets)
// [3 [3 [0 1 2]] [5 [5 7 18 2 1]] [4 [1 4 9 16]]]
// Therefore, the type of A must be known to read this back in.
return 0;
}