OpenGM  2.3.x
Discrete Graphical Model Library
lp_reparametrization_hdf5.hxx
Go to the documentation of this file.
1 /*
2  * lp_reparametrization_hdf5.hxx
3  *
4  * Created on: Jul 3, 2014
5  * Author: bsavchyn
6  */
7 
8 #ifndef LP_REPARAMETRIZATION_HDF5_HXX_
9 #define LP_REPARAMETRIZATION_HDF5_HXX_
10 
13 
14 namespace opengm {
15 namespace hdf5 {
16 
17 template<class GM>
18 void save(const LPReparametrisationStorage<GM>& repa,const std::string& filename,const std::string& modelname)
19 {
20  hid_t file = H5Fcreate(filename.c_str(), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
21  OPENGM_ASSERT(file >= 0);
23  repa.serialize(&marr);
24  marray::hdf5::save(file,modelname.c_str(),marr);
25  H5Fclose(file);
26 }
27 
28 template<class GM>
29 void load(LPReparametrisationStorage<GM>* prepa, const std::string& filename, const std::string& modelname)
30 {
31  hid_t file = H5Fopen(filename.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
32  OPENGM_ASSERT(file>=0);
34  marray::hdf5::load(file,modelname.c_str(),marr);
35  prepa->deserialize(marr);
36  H5Fclose(file);
37 };
38 }
39 }
40 
41 #endif /* LP_REPARAMETRIZATION_HDF5_HXX_ */
The OpenGM namespace.
Definition: config.hxx:43
void load(GM_ &gm, const std::string &, const std::string &)
#define OPENGM_ASSERT(expression)
Definition: opengm.hxx:77
void load(const hid_t &, const std::string &, Marray< T > &)
Load an Marray from an HDF5 dataset.
void deserialize(const VECTOR &serialization)
One-dimensional Marray.
Definition: marray.hxx:50
void save(const hid_t &, const std::string &, const Marray< T > &)
Save an Marray as an HDF5 dataset.
void serialize(VECTOR *pserialization) const
void save(const GM &, const std::string &, const std::string &)
save a graphical model to an HDF5 file