C++填充矩阵 boost

标签 c++ algorithm boost matrix fill

您好,我已经查看了这个的 vector 拷贝,但找不到答案

ublas::matrix<int> input;
fill(input.begin1(), input.end1(), in_val);
fill(input.begin2(), input.end2(), in_val);

但它给了我

[2,3] {(3,3,3) (3,0,0)}

如您所料,我只想用 init_val=3 填充所有内容,谢谢。

最佳答案

矩阵有它的构造函数。

ublas::matrix<int> input(2, 3, 3);

做你想做的事

关于C++填充矩阵 boost ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3484560/

相关文章:

algorithm - RGB 相似色近似算法

algorithm - 如何用数学方法表述这样的问题? (续行搜索)

algorithm - 约翰逊算法 - h 函数

c++ - 为什么不能将 auto 用作模板类型参数(例如 std::array<auto, 5>)?

c++ - 作业 : Avoiding magic numbers

c++17 polyfills 和 boost

c++ - Boost::Math::Quaternion 中的异常防护习语

c++ - 我应该从哪里获得其他人用来构建 boost 的 b2.exe 和 bjam.exe?

c++ - 为什么此代码不会生成不明确的调用错误?

c++ - 模板可以在不丢失信息的情况下传递参数类型