- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cpp2npz.cpp
More file actions
Latest commit
28 lines (22 loc) · 570 Bytes
/
Copy pathtest_cpp2npz.cpp
File metadata and controls
28 lines (22 loc) · 570 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
#include"cpp2npz.h"
#include<iostream>
usingnamespacestd;
intmain()
{
IO_npz n("a.npz");
// Insert simple double vector
vector<int> shape(1);
shape[0] = 10;
double data[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
n.add_array("test0", shape, data);
// again, under different name:
n.add_array("test1", shape, data);
// Insert simple double matrix
double a[3][4] = {{-1.0, 2.0, 5.8, 0.666}, {2.7, 5.0, 2.78, 0.665}, {8.6, 7.5, 3.2, 0.01}};
shape.resize(2);
shape[0] = 3;
shape[1] = 4;
n.add_array("test2", shape, (double*)a);
n.commit();
return0;
}