From 584b7d9eccd60ceae5afee5c1b22419713a5dce0 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Fri, 6 Apr 2018 18:08:37 +0200 Subject: [PATCH 1/2] Add ExpData copy constructor and others --- include/amici/edata.h | 33 ++++++++++++++++++++++++++-- src/edata.cpp | 51 ++++++++++++++++++++++++++++++++----------- 2 files changed, 69 insertions(+), 15 deletions(-) diff --git a/include/amici/edata.h b/include/amici/edata.h index 628696d312..969f6632fa 100644 --- a/include/amici/edata.h +++ b/include/amici/edata.h @@ -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 const& my, + std::vector const& sigmay, + std::vector const& mz, + std::vector 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); diff --git a/src/edata.cpp b/src/edata.cpp index 761409fd1d..164eea55b3 100644 --- a/src/edata.cpp +++ b/src/edata.cpp @@ -9,20 +9,45 @@ 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(nt * nytrue), + std::vector(nt * nytrue), + std::vector(nmaxevent * nztrue), + std::vector(nmaxevent * nztrue)) + +{ +} + +ExpData::ExpData(int nytrue, int nztrue, int nt, int nmaxevent, + const std::vector &my, + const std::vector &sigmay, + const std::vector &mz, + const std::vector &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) +{ +// std::vector my; +// /** standard deviation of observed data (dimension: nt x nytrue, row-major) */ +// std::vector sigmay; + +// /** observed events (dimension: nmaxevents x nztrue, row-major) */ +// std::vector mz; +// /** standard deviation of observed events/roots +// * (dimension: nmaxevents x nztrue, row-major)*/ +// std::vector sigmaz; } void ExpData::setObservedData(const double *observedData) { From e37f0fc8304f98be91db69163412787d0c690a82 Mon Sep 17 00:00:00 2001 From: Daniel Weindl Date: Fri, 6 Apr 2018 20:37:52 +0200 Subject: [PATCH 2/2] Cleanup --- src/edata.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/edata.cpp b/src/edata.cpp index 164eea55b3..473f2f3fcb 100644 --- a/src/edata.cpp +++ b/src/edata.cpp @@ -39,15 +39,6 @@ ExpData::ExpData(const ExpData &other) : ExpData(other.nytrue, other.nztrue, other.nt, other.nmaxevent, other.my, other.sigmay, other.mz, other.sigmaz) { -// std::vector my; -// /** standard deviation of observed data (dimension: nt x nytrue, row-major) */ -// std::vector sigmay; - -// /** observed events (dimension: nmaxevents x nztrue, row-major) */ -// std::vector mz; -// /** standard deviation of observed events/roots -// * (dimension: nmaxevents x nztrue, row-major)*/ -// std::vector sigmaz; } void ExpData::setObservedData(const double *observedData) {