Program Listing for File SerializableSpline1dInterpolant.h¶
↰ Return to documentation for file (/home/kpenev/projects/git/poet/poet_src/Core/SerializableSpline1dInterpolant.h)
#ifndef __SERIALIZABLE_SPLINE_1D_INTERPOLANT_H
#define __SERIALIZABLE_SPLINE_1D_INTERPOLANT_H
#include "../Core/SharedLibraryExportMacros.h"
#include "../third_party_libs/alglib/alglib/src/interpolation.h"
#include <boost/serialization/base_object.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/export.hpp>
namespace Core {
class LIB_LOCAL SerializableSpline1dInterpolant :
public alglib::spline1dinterpolant
{
private:
friend class boost::serialization::access;
template<class Archive> void serialize(
Archive & ar,
const unsigned int
);
public:
friend std::ostream &operator<<(
std::ostream &os,
const SerializableSpline1dInterpolant &interp
);
}; //End SerializableSpline1dInterpolant class.
std::ostream &operator<<(
std::ostream &os,
const alglib::real_1d_array &array);
template<class Archive> void SerializableSpline1dInterpolant::serialize(
Archive & ar,
const unsigned int
)
{
ar & p_struct->periodic;
ar & p_struct->n;
ar & p_struct->k;
ar & p_struct->c.cnt;
ar & p_struct->c.datatype;
ar & p_struct->x.cnt;
ar & p_struct->x.datatype;
if (Archive::is_loading::value) {
using namespace alglib_impl;
ae_state state;
ae_vector_init(&p_struct->c,
(p_struct->n - 1) * 4 + 2,
p_struct->c.datatype,
&state);
ae_vector_init(&p_struct->x,
p_struct->n,
p_struct->x.datatype,
&state);
}
for (
int node_index=0;
node_index < p_struct->n - 1;
node_index++
) {
double *coef=(p_struct->c.ptr.p_double + 4 * node_index);
ar & coef[0] & coef[1] & coef[2] & coef[3];
ar & p_struct->x.ptr.p_double[node_index];
}
ar & p_struct->x.ptr.p_double[p_struct->n - 1];
} //End SerializableSpline1dInterpolant::serialize definition.
} //End Core namespace.
#endif