需要注意的是在taucs_matrix.h的#include<cassert>前添加
#include <vector>
这样则可以消除编译过程中taucs_matrix.h中std::vector< > 的一些错误。
若你使用Apple Mac,则在CGAL/taucs_fix.h 中很多判断OS_TYPE的代码都可以注释掉,或者直接将其备份,然后建一个同名的文件,在里面写入
#include "taucs.h"
即可。
以下代码在VS2005中测试.
求解线性方程组 IX = [3 4]^T的示例代码如下:
#include <CGAL/basic.h>
#include <CGAL/Taucs_solver_traits.h>
#include <iostream>
using namespace std;
typedef CGAL::Taucs_solver_traits<float> TaucsSolver;
typedef TaucsSolver::Matrix Matrix;
typedef TaucsSolver::Vector Vector;
#pragma comment(lib,"libatlas.lib")
#pragma comment(lib,"libcblas.lib")
#pragma comment(lib,"libf77blas.lib")
#pragma comment(lib,"liblapack.lib")
#pragma comment(lib,"libmetis.lib")
#pragma comment(lib,"libtaucs.lib")
#pragma comment(lib,"vcf2c.lib")
#pragma comment(lib,"cgal-vc80-mt-s.lib")
int main()
{
Matrix A(2,2);
Vector B(2);
Vector X(2);
A.set_coef(0,0,1);
A.set_coef(0,1,0);
A.set_coef(1,0,0);
A.set_coef(1,1,1);
B[0] = 3, B[1] = 4;
TaucsSolver solver;
float d = 1;
solver.linear_solver(A,B,X,d);
cout<<"The result is:"<<endl;
cout<<X[0]<<" "<<X[1]<<endl;
return 0;
}