test_cnpy_eigen.cxx
Go to the documentation of this file.
1 #include "WireCellUtil/cnpy.h"
2 
3 #include <Eigen/Core>
4 
5 typedef Eigen::Array<short, Eigen::Dynamic, Eigen::Dynamic> ArrayXXs;
6 
7 const int Nchanc = 480;
8 //const int Nchani = 800;
9 const int Ntick = 2000;
10 
11 int main(int argc, char* argv[])
12 {
13  std::string name = argv[0];
14  name += ".npz";
15 
16  //ArrayXXs a = ArrayXXs::Random(Nchanc,Ntick);
17  ArrayXXs a = ArrayXXs::Zero(Nchanc,Ntick);
18  a(0,1000) = 1000;
19  a(400,0) = 400;
20  const short* data = a.data();
21  cnpy::npz_save<short>(name.c_str(), "a", data, {Ntick, Nchanc}, "w");
22  /*
23  >>> import numpy
24  >>> f = numpy.load("eigentest.npz")
25  >>> a = f['a']
26  >>> print a.shape, a[0,400], a[1000,0]
27  (2000, 480) 400 1000
28  */
29  return 0;
30 }
31 
32 
33 
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
const int Ntick
basic_data data
Definition: format.h:764
Eigen::Array< short, Eigen::Dynamic, Eigen::Dynamic > ArrayXXs
int main(int argc, char *argv[])
const int Nchanc
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124