Skip to content
Snippets Groups Projects
Commit e9cd4f47 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

provide and use Datafield::setVector2D

parent ddd9aab8
No related branches found
No related tags found
1 merge request!2025provide Datafield::setVector2D, and use it in convolution
......@@ -132,12 +132,7 @@ Datafield::Datafield(const std::string& xlabel, const std::string& ylabel,
newEquiDivision(ylabel, nrows, 0.0, (double)nrows)};
m_frame.reset(new Frame(std::move(axes)));
m_values.reserve(nrows * ncols);
for (size_t j = 0; j < nrows; ++j) {
ASSERT(vec[j].size() == ncols);
for (size_t i = 0; i < ncols; ++i)
m_values.push_back(vec[j][i]);
}
setVector2D(vec);
}
Datafield::Datafield(Datafield&&) noexcept = default;
......@@ -213,6 +208,21 @@ void Datafield::setVector(const std::vector<double>& vector)
m_values = vector;
}
void Datafield::setVector2D(const std::vector<std::vector<double>>& in)
{
const size_t ncols = axis(0).size();
const size_t nrows = axis(1).size();
ASSERT(in.size() == nrows);
m_values.clear();
m_values.reserve(nrows * ncols);
for (size_t j = 0; j < nrows; ++j) {
ASSERT(in[j].size() == ncols);
for (size_t i = 0; i < ncols; ++i)
m_values.push_back(in[j][i]);
}
}
size_t Datafield::rank() const
{
return frame().rank();
......
......@@ -147,6 +147,7 @@ public:
//! Sets new values to raw data vector.
void setVector(const std::vector<double>& data_vector);
void setVector2D(const std::vector<std::vector<double>>& in);
bool hasErrorSigmas() const;
std::vector<double>& errorSigmas();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment