From 4576d73379b2df16400fe1294d14c8a07bdfd11c Mon Sep 17 00:00:00 2001 From: Antonin Portelli Date: Tue, 13 Dec 2016 10:37:37 +0000 Subject: [PATCH] vector version of setUnidimData --- lib/XYSampleData.cpp | 14 ++++++++++++++ lib/XYSampleData.hpp | 14 ++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/lib/XYSampleData.cpp b/lib/XYSampleData.cpp index ecb0811..df53684 100644 --- a/lib/XYSampleData.cpp +++ b/lib/XYSampleData.cpp @@ -171,6 +171,20 @@ const DSample & XYSampleData::y(const Index k, const Index j) const return yData_[j].at(k); } +void XYSampleData::setUnidimData(const DMatSample &xData, + const vector &v) +{ + FOR_STAT_ARRAY(xData, s) + FOR_VEC(xData[central], r) + { + x(r, 0)[s] = xData[s](r); + for (unsigned int j = 0; j < v.size(); ++j) + { + y(r, j)[s] = (*(v[j]))[s](r); + } + } +} + const DMat & XYSampleData::getXXVar(const Index i1, const Index i2) { checkXDim(i1); diff --git a/lib/XYSampleData.hpp b/lib/XYSampleData.hpp index fb16ae8..b5e87d1 100644 --- a/lib/XYSampleData.hpp +++ b/lib/XYSampleData.hpp @@ -80,6 +80,8 @@ public: const DMatSample & x(const Index k); DSample & y(const Index k, const Index j); const DSample & y(const Index k, const Index j) const; + void setUnidimData(const DMatSample &xData, + const std::vector &v); template void setUnidimData(const DMatSample &xData, const Ts & ...yDatas); @@ -141,17 +143,9 @@ void XYSampleData::setUnidimData(const DMatSample &xData, const Ts & ...yDatas) static_assert(static_or::value...>::value, "y data arguments are not compatible with DMatSample"); - std::vector yData{&yDatas...}; + std::vector v{&yDatas...}; - FOR_STAT_ARRAY(xData, s) - FOR_VEC(xData[central], r) - { - x(r, 0)[s] = xData[s](r); - for (unsigned int j = 0; j < yData.size(); ++j) - { - y(r, j)[s] = (*(yData[j]))[s](r); - } - } + setUnidimData(xData, v); } template