ginac库访问矩阵元素

2020-10-17  本文已影响0人  一路向后

1.程序源码

#include <iostream>
#include <ginac/ginac.h>

using namespace std;
using namespace GiNaC;

int main()
{
        matrix A = matrix(2,2,lst(1,2,3,4));

        //输出矩阵元素
        cout << A[3] << endl;

       //修改矩阵元素
        A[3] = 5;

        cout << A << endl;

        return 0;
}

2.编译源码

$ g++ -o example example.c -lginac -lcln -I/usr/local/include -L/usr/local/lib64

3.运行结果

./example
4
[[1,2],[3,5]]
上一篇 下一篇

猜你喜欢

热点阅读