美文网首页
itpp库PLU分解

itpp库PLU分解

作者: 一路向后 | 来源:发表于2020-10-08 16:31 被阅读0次

1.程序源码

#include <itpp/itbase.h>

using namespace itpp;

using std::cout;
using std::endl;

int main()
{
        /*矩阵声明*/
        mat X, L, U;
        ivec p;

        /*使用字符串定义矩阵*/
        X = "9,6,0; 6,5,4; 3,4,10;";
        p = "1,1,1";

        /*X的PLU分解结果*/
        lu(X, L, U, p);

        /*打印结果*/
        cout << "X = " << X << endl;
        cout << "L = " << L << endl;
        cout << "U = " << U << endl;
        cout << "p = " << p << endl;

        return 0;
}

2.编译源码

$ g++ -o example example.c -I/usr/local/include -L/usr/local/lib64 -litpp -lgfortran -lblas -llapack -lrefblas

3.运行结果

./example
X = [[9 6 0]
 [6 5 4]
 [3 4 10]]
L = [[1 0 0]
 [0.333333 1 0]
 [0.666667 0.5 1]]
U = [[9 6 0]
 [0 2 10]
 [0 0 -1]]
p = [0 2 2]

相关文章

网友评论

      本文标题:itpp库PLU分解

      本文链接:https://www.haomeiwen.com/subject/zurhpktx.html