相关疑难解决方法(0)

Ax = b线性代数系统的C++内存有效解决方案

我正在使用用于Boost UBlas的数​​值库绑定来解决简单的线性系统.以下工作正常,但它仅限于处理相对较小的'm'的矩阵A(mxm).

在实践中,我有一个更大的矩阵,维数m = 10 ^ 6(最多10 ^ 7).
是否存在用于解决有效使用内存的Ax = b的现有C++方法.

#include<boost/numeric/ublas/matrix.hpp>
#include<boost/numeric/ublas/io.hpp>
#include<boost/numeric/bindings/traits/ublas_matrix.hpp>
#include<boost/numeric/bindings/lapack/gesv.hpp>
#include <boost/numeric/bindings/traits/ublas_vector2.hpp>

// compileable with this command


//g++ -I/home/foolb/.boost/include/boost-1_38 -I/home/foolb/.boostnumbind/include/boost-numeric-bindings solve_Axb_byhand.cc -o solve_Axb_byhand -llapack


namespace ublas = boost::numeric::ublas;
namespace lapack= boost::numeric::bindings::lapack;


int main()
{
    ublas::matrix<float,ublas::column_major> A(3,3);
    ublas::vector<float> b(3);


    for(unsigned i=0;i < A.size1();i++)
        for(unsigned j =0;j < A.size2();j++)
        {
            std::cout << "enter element "<<i << j << std::endl;
            std::cin >> A(i,j);
        }

    std::cout << A << std::endl;

    b(0) = 21; b(1) = 1; b(2) = …
Run Code Online (Sandbox Code Playgroud)

c++ boost linear-algebra lapack umfpack

9
推荐指数
3
解决办法
9246
查看次数

标签 统计

boost ×1

c++ ×1

lapack ×1

linear-algebra ×1

umfpack ×1