TAUCS配置笔记

 

 自从前两天知道了可以用TAUCS来对sparse matrix运算以后,对其进行了很长时间的研究。反复编译了很多次,也下了precompiled的lib,可就是不成功。下午问了哥,终于搞定测试过程。

    具体步骤大致如下:

    Using TAUCS from GUI

 

Now it is also possible to compile and run the code from GUI by 

 

specifying the information above through the dialog boxes.

 

1) Note that TAUCS was compiled with -MT. Specify it also in C++ --> 

 

Code generation --> Use run-time library.(Runtime library 选择Multi-

 

threaded Debug DLL (/MDd))  

 

2) Specify the path to the TAUCS headers in ADDITIONAL INCLUDE 

 

DIRECTORIES.(添加头文件的目录)

 

3) Specify the library to link with in Link --> Input: Object/library 

 

modules.

 

4) Specify the path to the libraries in ADDITIONAL PATH LIBRARY.(添

 

加.lib的目录,之后还需要添加以上的.lib 文件至Linker --> input--

 

>additional Dependencies,添加.lib目录只是添加了一个路径,具体的.lib还

 

需要逐个添加)

 

.lib文件为

 

libatlas.lib

libcblas.lib

libf77blas.lib

liblapack.lib

libmetis-vc80-mt.lib

libmetis-vc80-mt-gd.lib

libmetis-vc80-mt-s.lib

libmetis-vc80-mt-sgd.lib

libmetis-vc90-mt.lib

libmetis-vc90-mt-gd.lib

libmetis-vc90-mt-s.lib

libmetis-vc90-mt-sgd.lib

libtaucs-vc80-mt.lib

libtaucs-vc80-mt-gd.lib

libtaucs-vc80-mt-s.lib

libtaucs-vc80-mt-sgd.lib

libtaucs-vc90-mt.lib

libtaucs-vc90-mt-gd.lib

libtaucs-vc90-mt-s.lib

libtaucs-vc90-mt-sgd.lib

libtstatlas.lib

vcf2c-vc80-mt.lib

vcf2c-vc80-mt-gd.lib

vcf2c-vc80-mt-s.lib

vcf2c-vc80-mt-sgd.lib

vcf2c-vc90-mt.lib

vcf2c-vc90-mt-gd.lib

vcf2c-vc90-mt-s.lib

vcf2c-vc90-mt-sgd.lib

 

VS8添加VC80,VS9添加VC90

 

 

taucs_test.cpp

 

// The code from Alejandro with some slight modifications

 

#include <iostream>

#include <vector>

 

using namespace std;

extern "C" {

#include <taucs.h>

}

 

 

 

int main()

{

vector<double> an(10);

vector<int> jn(10);

vector<int> ia(10);

vector<double> f(10); // right-hand size vector object

 

// create CCS matrix structure using vector class

an[0] = 1.0;

an[1] = 0.5;

an[2] = 1.0;

an[3] = 0.5;

an[4] = 1.0;

an[5] = 0.5;

an[6] = 1.0;

 

jn[0] = 0;

jn[1] = 1;

jn[2] = 1;

jn[3] = 2;

jn[4] = 2;

jn[5] = 3;

jn[6] = 3;

 

ia[0] = 0;

ia[1] = 2;

ia[2] = 4;

ia[3] = 6;

ia[4] = 7;

 

// create right-hand size vector object

f[0] = 1.0;

f[1] = 2.0;

f[2] = 3.0;

f[3] = 4.0;

 

// resize vectors.

an.resize(7);

jn.resize(7);

ia.resize(5);

f.resize(4);

int dim = 4;

 

// create TAUCS matrix from vector objects an, jn and ia

taucs_ccs_matrix  A; // a matrix to solve Ax=b in CCS format

A.n = dim;

A.m = dim;

A.flags = (TAUCS_DOUBLE | TAUCS_SYMMETRIC | TAUCS_LOWER);

A.colptr = &ia[0];

A.rowind = &jn[0];

A.values.d = &an[0];

 

// create TAUCS right-hand size

taucs_double* b = &f[0]; // right hand side vector to solve Ax=b

 

// allocate TAUCS solution vector

vector<double> xv(dim);

taucs_double* x = &xv[0]; // the unknown vector to solve Ax=b

 

// solve the linear system

void* F = NULL;

char* options[] = {"taucs.factor.LLT=true", NULL};

void* opt_arg[] = { NULL };

 

taucs_logfile("stdout");

int i = taucs_linsolve(&A, &F, 1, x, b, options, opt_arg);

 

if (i != TAUCS_SUCCESS)

{

cout << "Solution error." << endl;

if (i==TAUCS_ERROR)

cout << "Generic error." << endl;

 

if (i==TAUCS_ERROR_NOMEM)

cout << "NOMEM error." << endl;

 

if (i==TAUCS_ERROR_BADARGS)

cout << "BADARGS error." << endl;

 

if (i==TAUCS_ERROR_MAXDEPTH)

cout << "MAXDEPTH error." << endl;

 

if (i==TAUCS_ERROR_INDEFINITE)

cout << "NOT POSITIVE DEFINITE error." << endl;

}

else

{

cout << "Solution success." << endl;

 

for (unsigned j = 0; j < f.size(); j++)

cout << x[j] << endl;

}

 

// deallocate the factorization

taucs_linsolve(NULL, &F, 0, NULL, NULL, NULL, NULL);

 

return 0;

}

precompiled的header可以在VS2008上顺利运行。
选择普通的lib和include时, C++ --> 

 

Code generation --> Use run-time library.(Runtime library 选择Multi-threaded Debug (/MTd))    

 

具体的原因,估计是因为lib不同了,所以选择的CRT(c runtime library不同)

 

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值