如何声明一个标准::提升直方图的向量?提升直方图的类型是什么?
How to declare a std::vector of boost histograms ? What is the type of a boost histogram?
我目前正在从事一个项目,我需要使用boost直方图的std::vector。
我遇到的问题是我无法找到正确类型的提升直方图。我在下面的代码中进行了最后一次尝试。
下面是这种情况的示例代码:
#include <boost/format.hpp>
#include <boost/histogram.hpp>
#include <boost/histogram/serialization.hpp> // includes serialization code
int main() {
using namespace boost::histogram;
// Creation of the histogram.
auto h = make_histogram(axis::regular<double> {3, 0.0, 1.0, "x"},
axis::regular<double> {3, 0.0, 1.0, "y"},
axis::regular<double> {3, 0.0, 1.0, "z"},
axis::regular<double, axis::transform::log> {3, 1.0, 230.0, "Energy_log"});
h(0.1,0.1,0.1,70);
h(0.1,0.1,0.1,100);
h(0.1,0.1,0.1,200);
//std::vector<*Boost_histogram_TYPE*> histograms4D;
std::vector<boost::histogram::histogram<boost::histogram::axis::variant, boost::histogram::unlimited_storage>> histograms4D;
histograms4D.push_back(h);
}
有没有人已经遇到过这种情况?
我已经感谢您的帮助,
埃利奥特
一旦有了该类型的对象,您就可以命名该类型:
using boost_histogram = decltype(h);
一旦你有了类型,你可以像这样使用它:
std::vector<boost_histogram> histograms4D;
这是一个演示。
使用c++17 时,使用构造函数模板参数推导:
住在科里鲁
#include <boost/archive/text_oarchive.hpp>
#include <boost/histogram.hpp>
#include <iostream>
int main() {
using namespace boost::histogram;
auto h = make_histogram(
axis::regular<double> {3, 0.0, 1.0, "x"},
axis::regular<double> {3, 0.0, 1.0, "y"},
axis::regular<double> {3, 0.0, 1.0, "z"},
axis::regular<double, axis::transform::log> {3, 1.0, 230.0, "Energy_log"});
h(0.1,0.1,0.1,70);
h(0.1,0.1,0.1,100);
h(0.1,0.1,0.1,200);
std::vector histograms4D {h};
}
相关文章:
- 为不同配置设置MSVC_RUNTIME_LIBRARY的正确方法是什么
- C++避免重复声明的语法是什么
- 在C++中,将大的无符号浮点数四舍五入为整数的最佳方法是什么
- 实现无开销push_back的最佳方法是什么
- C++从另一个类访问公共静态向量的正确方法是什么
- "throw expression code" 1e7 >返回 d 是什么?投掷标准::overflow_error( "too big" ) : d;意味 着?
- C++中名称篡改的目的是什么
- 在 c++ 中拥有一组结构的正确方法是什么?
- 这个指针和内存代码打印是什么?我不知道是打印垃圾还是如何打印我需要的值
- 是什么阻止DOMTimerCoordinator::NextID进入无休止的循环
- 派生类销毁的最佳实践是什么
- 这个语法std::class<>{}(arg1, arg2) 在C++中是什么意思?
- 通过JNI传递数据数组的最快方法是什么
- "using namespace std;"在C++的作用是什么?
- 在两台机器之间进行时间戳的最佳c++chrono函数是什么
- 文件系统:复制功能的速度秘诀是什么
- 用常见虚拟函数实现的任意组合来实现派生类的正确方法是什么
- 使用QQuickFramebufferObject时同步数据的最佳方式是什么
- 是什么原因导致它无法编译?它是声明签名还是在函数本身的实现中
- 如何声明一个标准::提升直方图的向量?提升直方图的类型是什么?