【问题标题】:Why can I initialize a regular Boost matrix like a scalar matrix?为什么我可以像标量矩阵一样初始化常规 Boost 矩阵?
【发布时间】:2013-01-11 13:57:13
【问题描述】:

为什么会这样?它不在任何地方的文档中......

#include <iostream>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/io.hpp>

int main()
{

boost::numeric::ublas::matrix<double> twoByTwoMat(2,2,-2);

std::cout << "This is the matrix: " << twoByTwoMat << std::endl;

return 0;
}

输出:

This is the matrix: [2,2]((-2,-2),(-2,-2))

【问题讨论】:

    标签: c++ boost boost-ublas


    【解决方案1】:

    &lt;boost/numeric/ublas/matrix.hpp&gt;头文件中定义。

    matrix (size_type size1, size_type size2, const value_type &init):
            matrix_container<self_type> (),
            size1_ (size1), size2_ (size2), data_ (layout_type::storage_size (size1, size2), init) {
        }
    

    【讨论】:

    • 好的,谢谢。太糟糕了,我现在觉得自己像个白痴。也许应该更新 boost 文档以反映这一点?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-29
    • 2020-11-09
    • 1970-01-01
    • 1970-01-01
    • 2010-12-03
    相关资源
    最近更新 更多