diff --git a/Sim/Simulation/DepthprobeSimulation.cpp b/Sim/Simulation/DepthprobeSimulation.cpp index e7a91b9b376653da011c591ebd0a2fba1d1b18c8..557e90bff150d644c28d4746884c6a205e162f93 100644 --- a/Sim/Simulation/DepthprobeSimulation.cpp +++ b/Sim/Simulation/DepthprobeSimulation.cpp @@ -137,7 +137,7 @@ void DepthprobeSimulation::initElementVector() alpha_limits.isInRange(result_angle)); } - m_cache.resize(m_depth_eles.size(), std::valarray<double>(0.0, zAxis()->size())); + m_cache = std::vector<double>(m_depth_eles.size() * zAxis()->size(), 0.); } std::unique_ptr<IComputation> @@ -175,11 +175,11 @@ void DepthprobeSimulation::addDataToCache(double weight) const size_t N0 = alphaAxis()->size(); const size_t N1 = zAxis()->size(); ASSERT(m_depth_eles.size() == N0); - // ASSERT(m_cache.size() == N0 * N1); + ASSERT(m_cache.size() == N0 * N1); for (size_t j = 0; j < N0; ++j) for (size_t i = 0; i < N1; ++i) - m_cache[j][i] += m_depth_eles[j].getIntensities()[i] * weight; + m_cache[j * N1 + i] += m_depth_eles[j].getIntensities()[i] * weight; } void DepthprobeSimulation::validateParametrization(const ParameterDistribution& par_distr) const @@ -203,17 +203,8 @@ size_t DepthprobeSimulation::numberOfElements() const SimulationResult DepthprobeSimulation::packResult() { - const size_t N = m_depth_eles.size(); - ASSERT(m_cache.size() == N); - ASSERT(N == alphaAxis()->size()); - const std::vector<const IAxis*> axes{alphaAxis()->clone(), zAxis()->clone()}; - std::vector<double> out; - out.reserve(axes[0]->size() * axes[1]->size()); - for (size_t i = 0, size = N; i < size; ++i) - for (const double v : m_cache[i]) - out.push_back(v); - auto data = std::make_unique<Datafield>(axes, out); + auto data = std::make_unique<Datafield>(axes, m_cache); return {*data, simCoordSystem()}; } diff --git a/Sim/Simulation/DepthprobeSimulation.h b/Sim/Simulation/DepthprobeSimulation.h index 3b0c8cc617c92cc42874b71792723c149f3fe57f..ba6429c2e1b59dc9a610504a3b7b82b1977e5677 100644 --- a/Sim/Simulation/DepthprobeSimulation.h +++ b/Sim/Simulation/DepthprobeSimulation.h @@ -16,7 +16,6 @@ #define BORNAGAIN_SIM_SIMULATION_DEPTHPROBESIMULATION_H #include "Sim/Simulation/ISimulation.h" -#include <valarray> class Beam; class DepthprobeElement; @@ -105,7 +104,7 @@ private: //... Caches: std::unique_ptr<IAxis> m_alpha_axis; std::unique_ptr<IAxis> m_z_axis; - std::vector<std::valarray<double>> m_cache; + std::vector<double> m_cache; std::vector<DepthprobeElement> m_depth_eles; #endif // SWIG };