美文网首页
ginac库计算偏微分

ginac库计算偏微分

作者: 一路向后 | 来源:发表于2020-10-13 21:35 被阅读0次

1.程序源码

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

using namespace std;
using namespace GiNaC;

int main()
{
        symbol x("x"), y("y");
        ex poly;

        //z = x^2 + y^2
        poly = pow(x,2) + pow(y,2);

        //关于x和y的偏微分
        cout << poly.diff(x) << endl;
        cout << poly.diff(y) << endl;

        return 0;
}

2.编译源码

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

3.运行结果

./example
2*x
2*y

相关文章

网友评论

      本文标题:ginac库计算偏微分

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