有人有SymbolicC++的经验吗?我试图用这个库解决一些线性问题,但是性能似乎不能接受,下面是我的测试
#pragma warning(disable: 4800 4801 4101 4390)
#include<iostream>
using namespace std;
#include "Symbolic/symbolicc++.h"
int main() {
// x==10 y==9 z==7
Symbolic x("x"), y("y"), z("z");
Equations rules = (
x + y + z == 26,
x - y == 1,
2*x - y + z == 18
);
list<Symbolic> s = (x, y, z);
list<Equations> result = solve(rules, s); // slow here
for(auto& x : result) {
cout << x << endl;
}
}解决函数在i7 cpu上采用402 is (调试)/67ms(版本),对于这样一个简单的问题来说,这是不是太慢了?有人知道为什么吗?
谢谢
发布于 2013-03-28 10:33:14
符号计算是缓慢的,如果你想要处理公式,它们就需要。
如果您只想求解线性方程组,请考虑使用专门为此创建的工具,如特征(Page)、BLAS(http://www.netlib.org/blas/)。
还读了computation
发布于 2013-03-29 08:11:08
谢谢卡萨克,艾根已经搞定了。
#include <iostream>
#include "Eigen/Dense"
using namespace std;
using namespace Eigen;
int main()
{
Matrix3f A;
Vector3f b;
A << 1, 1, 1,
1,-1, 0,
2,-1, 1;
b << 26, 1,18;
cout << "Here is the matrix A:\n" << A << endl;
cout << "Here is the vector b:\n" << b << endl;
Vector3f x = A.colPivHouseholderQr().solve(b);
cout << "The solution is:\n" << x << endl;
}https://stackoverflow.com/questions/15679353
复制相似问题