QMCPACK
test_hdf_multiarray.cpp File Reference
+ Include dependency graph for test_hdf_multiarray.cpp:

Go to the source code of this file.

Typedefs

template<std::ptrdiff_t D>
using extensions = typename boost::multi::layout_t< D >::extensions_type
 

Functions

 TEST_CASE ("hdf_multiarray_one_dim", "[hdf]")
 

Typedef Documentation

◆ extensions

using extensions = typename boost::multi::layout_t<D>::extensions_type

Definition at line 28 of file test_hdf_multiarray.cpp.

Function Documentation

◆ TEST_CASE()

TEST_CASE ( "hdf_multiarray_one_dim"  ,
""  [hdf] 
)

Definition at line 30 of file test_hdf_multiarray.cpp.

References hdf_archive::close(), hdf_archive::create(), qmcplusplus::okay, hdf_archive::open(), hdf_archive::read(), qmcplusplus::REQUIRE(), and hdf_archive::writeEntry().

31 {
32  hdf_archive hd;
33  hd.create("test_stl.hdf");
34 
35  boost::multi::array<double, 1> v(extensions<1u>{3});
36  v[0] = 2.3;
37  v[1] = -100.3;
38  v[2] = 135.22;
39 
40  bool okay = hd.writeEntry(v, "boost_multiarray_one_dim");
41  REQUIRE(okay);
42 
43  hd.close();
44 
45  hdf_archive hd2;
46  okay = hd2.open("test_stl.hdf");
47  REQUIRE(okay);
48 
49  boost::multi::array<double, 1> v2(extensions<1u>{3});
50  hd2.read(v2, "boost_multiarray_one_dim");
51  REQUIRE(v2.size() == 3);
52  for (int i = 0; i < v.size(); i++)
53  {
54  REQUIRE(v[i] == v2[i]);
55  }
56 }
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
void close()
close all the open groups and file
Definition: hdf_archive.cpp:38
class to handle hdf file
Definition: hdf_archive.h:51
REQUIRE(std::filesystem::exists(filename))
typename boost::multi::layout_t< D >::extensions_type extensions
bool create(const std::filesystem::path &fname, unsigned flags=H5F_ACC_TRUNC)
create a file
void read(T &data, const std::string &aname)
read the data from the group aname and check status runtime error is issued on I/O error ...
Definition: hdf_archive.h:306
bool writeEntry(T &data, const std::string &aname)
write the data to the group aname and return status use write() for inbuilt error checking ...
Definition: hdf_archive.h:244