std::transform(data.begin(), data.end(), rowmeans.begin(),
[](std::vector<double> const& d) {
return std::accumulate(d.begin(), d.end(), 0.0) / d.size();
});
Although, my personal style would involve a named lambda or function, because I would find that more self-documenting:
auto Mean = [](std::vector<double> const& d) { return std::accumulate(d.begin(), d.end(), 0.0) / d.size(); };
std::transform(data.begin(), data.end(), rowmeans.begin(), Mean);