FLAME  devel
 All Classes Functions Variables Typedefs Enumerations Pages
h5loadertest.cpp
1 
2 #include <typeinfo>
3 #include <iostream>
4 
5 #include "flame/h5loader.h"
6 
7 int main(int argc, char *argv[])
8 {
9  if(argc<2) {
10  std::cerr<<"Usage: "<<argv[0]<<" <h5file>[/<h5/path]/<dsetname>\n";
11  return 1;
12  }
13 
14  try{
15  H5Loader::dontPrint();
16 
17  std::string spec(argv[1]);
18  size_t sep = spec.find_last_of('/');
19  if(sep==spec.npos) {
20  std::cerr<<"Missing dataset name (eg. 'file.h5/dataset')\n";
21  return 1;
22  }
23 
24  H5Loader loader(spec.substr(0,sep));
25 
26  H5Loader::matrix_t data(loader.load(spec.substr(sep+1)));
27 
28  std::cout<<"[\n";
29  for(size_t i=0; i<data.size1(); i++) {
30  std::cout<<"[ ";
31  for(size_t j=0; j<data.size2(); j++) {
32  std::cout<<data(i,j)<<", ";
33  }
34  std::cout<<"]\n";
35  }
36  std::cout<<"]\n";
37  } catch(std::exception& e){
38  std::cerr<<"Error : "<<e.what()<<"\n";
39  return 1;
40  }
41  return 0;
42 }
boost::numeric::ublas::matrix< double, boost::numeric::ublas::row_major, boost::numeric::ublas::unbounded_array< double > > matrix_t
A 2d matrix.
Definition: h5loader.h:37
Helper to read 2d matricies.
Definition: h5loader.h:16