Skip to content

Commit

Permalink
Merge pull request #297 from ICB-DCM/feature_edata_copyable
Browse files Browse the repository at this point in the history
Add ExpData copy constructor and others
  • Loading branch information
dweindl authored Apr 6, 2018
2 parents fca5da7 + e37f0fc commit 6e828d9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 15 deletions.
33 changes: 31 additions & 2 deletions include/amici/edata.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,42 @@ class ExpData {
public:
/** default constructor */
ExpData();
/**
* @brief ExpData
* @param nytrue
* @param nztrue
* @param nt
* @param nmaxevent
*/
ExpData(int nytrue, int nztrue, int nt, int nmaxevent);
/**
* @brief ExpData
* @param nytrue
* @param nztrue
* @param nt
* @param nmaxevent
* @param my
* @param sigmay
* @param mz
* @param sigmaz
*/
ExpData(int nytrue, int nztrue, int nt, int nmaxevent,
std::vector<realtype> const& my,
std::vector<realtype> const& sigmay,
std::vector<realtype> const& mz,
std::vector<realtype> const& sigmaz);
/**
* constructor that initializes with Model
*
* @param model pointer to model specification object @type Model
*/
ExpData(const Model &model);

/**
* @brief ExpData is currently not copyable
* @brief Copy constructor
* @param other object to copy from
*/
ExpData (const ExpData &other) = delete;
ExpData (const ExpData &other);

void setObservedData(const double *observedData);
void setObservedDataStdDev(const double *observedDataStdDev);
Expand Down
42 changes: 29 additions & 13 deletions src/edata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,36 @@ namespace amici {

ExpData::ExpData() : nytrue(0), nztrue(0), nt(0), nmaxevent(0) {}

ExpData::ExpData(int nytrue, int nztrue, int nt, int nmaxevent)
: ExpData(nytrue, nztrue, nt, nmaxevent,
std::vector<realtype>(nt * nytrue),
std::vector<realtype>(nt * nytrue),
std::vector<realtype>(nmaxevent * nztrue),
std::vector<realtype>(nmaxevent * nztrue))

{
}

ExpData::ExpData(int nytrue, int nztrue, int nt, int nmaxevent,
const std::vector<realtype> &my,
const std::vector<realtype> &sigmay,
const std::vector<realtype> &mz,
const std::vector<realtype> &sigmaz)
: my(my), sigmay(sigmay), mz(mz), sigmaz(sigmaz),
nytrue(nytrue), nztrue(nztrue), nt(nt), nmaxevent(nmaxevent)
{

}

ExpData::ExpData(Model const& model)
: nytrue(model.nytrue),
nztrue(model.nztrue),
nt(model.nt()),
nmaxevent(model.nMaxEvent()) {
/**
* constructor that initializes with Model
*
* @param model pointer to model specification object @type Model
*/
my.resize(model.nt() * model.nytrue);
sigmay.resize(model.nt() * model.nytrue);
mz.resize(model.nMaxEvent() * model.nztrue);
sigmaz.resize(model.nMaxEvent() * model.nztrue);
: ExpData(model.nytrue, model.nztrue, model.nt(), model.nMaxEvent())
{
}

ExpData::ExpData(const ExpData &other)
: ExpData(other.nytrue, other.nztrue, other.nt, other.nmaxevent,
other.my, other.sigmay, other.mz, other.sigmaz)
{
}

void ExpData::setObservedData(const double *observedData) {
Expand Down

0 comments on commit 6e828d9

Please sign in to comment.