boost::histogram::indexed用法详解
在使用直方图库Boost.Histogram时,有时候需要对每个bin的索引进行处理,比如将某个数值映射到对应的bin中。这个时候就可以使用boost::histogram::indexed。
boost::histogram::indexed是boost::histogram库提供的一种用于遍历多维直方图的迭代器,可以获取当前bin的索引和值,并且支持自定义索引类型。下面我们来看一个示例程序:
#include <iostream>
#include <vector>
#include <boost/histogram.hpp>
int main() {
using namespace boost::histogram;
// 定义二维直方图
auto h = make_histogram(axis::regular<>(4, -1.0, 1.0),
axis::variable<>({0.0, 0.5, 0.8, 1.0, 2.0}));
// 填充数据
std::vector<std::pair<double, double>> data = {
{0.1, 0.3}, {-0.5, 2.0}, {0.8, 1.5}};
for (auto&& d : data)
h(d.first, d.second);
// 遍历直方图
for (auto&& x
Boost.Histogram的indexed用法及自定义索引
本文详细介绍了如何使用boost::histogram::indexed遍历和操作多维直方图,包括利用C++11的range-based for循环,以及自定义索引类型如std::pair<int, int>的例子,旨在帮助理解并有效处理直方图数据。"
119405450,10544032,使用Delphi XE的IdTCPClient和IdTCPServer进行文件传输,"['Delphi开发', '网络通信', '文件操作']
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



