VC2005中测试Taucs库通过
来源:互联网 发布:网络剧主题曲好听 编辑:程序博客网 时间:2024/05/01 22:08
所使用的Taucs为OpenMesh中的版本。将之拷贝到一个目录,如D:/DevTools/taucs-win32.然后修改创建的Project 的属性,在Code Generation选择Multithread Release或Multithread Debug,然后加上附加的路径(这个可以在Tools->Options中一次性地添加).
然后,将下面的例子放于一个源代码文件中编译。
/* Solve a trivial symmetric Ax=b system :
[ 1.0 0.5 0.0 0.0 ] [ 1.0 ]
[ 0.5 1.0 0.5 0.0 ] [ 2.0 ]
[ 0.0 0.5 1.0 0.5 ] X = [ 3.0 ]
[ 0.0 0.0 0.5 1.0 ] [ 4.0 ]
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>
#define TAUCS_CORE_DOUBLE
#include <taucs.h>
#pragma comment(lib,"vcf2c.lib")
#pragma comment(lib,"libcblas.lib")
#pragma comment(lib,"libf77blas.lib")
#pragma comment(lib,"liblapack.lib")
#pragma comment(lib,"libmetis.lib")
#pragma comment(lib,"libatlas.lib")
#pragma comment(lib,"libtaucs.lib")
int main(int argc, char* argv[])
{
int m = 4,n = 4,nnz = 7, i, used;
taucs_double x[4];
taucs_double b[4];
taucs_ccs_matrix * pMatrix;
taucs_logfile ("stdout");
pMatrix = taucs_ccs_create( m, n, nnz, TAUCS_DOUBLE );
pMatrix->colptr[0] = 0;
pMatrix->colptr[1] = 2;
pMatrix->colptr[2] = 4;
pMatrix->colptr[3] = 6;
pMatrix->colptr[4] = 7;
used = 0;
for (i = 0; i < 4; i++ )
{
pMatrix->rowind[used] = i;
pMatrix->taucs_values[used] = 1.0;
used++;
if (i+1 <= 3)
{
pMatrix->rowind[used] = i+1;
pMatrix->taucs_values[used] = 0.5;
used++;
}
}
pMatrix->flags += TAUCS_SYMMETRIC;
pMatrix->flags += TAUCS_LOWER;
i = taucs_ccs_write_ijv(pMatrix, "test.txt" );
b[0] = 1.0; b[1] = 2.0; b[2] = 3.0; b[3] = 4.0;
char* options[] = { "taucs.factor.LLT=true","taucs.factor.ordering=metis",NULL };
i = taucs_linsolve (pMatrix,NULL,1,x,b,options,NULL);
if (i != TAUCS_SUCCESS)
{
printf ("Solution error./n");
if (i==TAUCS_ERROR)
printf ("Generic error.");
if (i==TAUCS_ERROR_NOMEM)
printf ("NOMEM error.");
if (i==TAUCS_ERROR_BADARGS)
printf ("BADARGS error.");
if (i==TAUCS_ERROR_MAXDEPTH)
printf ("MAXDEPTH error.");
if (i==TAUCS_ERROR_INDEFINITE)
printf ("NOT POSITIVE DEFINITE error.");
}
else
{
printf ("Solution success./n");
for (i = 0; i < 4; i++)
printf ("%f/n",x[i]);
}
taucs_dccs_free(pMatrix);
return 0;
}
运行的结果如下:
- VC2005中测试Taucs库通过
- TAUCS库的编译(vs2010)
- TAUCS库的编译(vs2010)
- jsoncpp vc2005 编译测试
- CGAL与Taucs库求解线程方程组示例
- CGAL与Taucs库求解线程方程组示例
- VC2005中安装DirectShow
- 在VC工程中添加多个RC文件(在VC2005编译通过)
- 在VC工程中添加多个RC文件(在VC2005编译通过)
- VC2005 运行库解析
- VC2005运行库文件
- vc2005运行库解析
- VC2005
- vc2005
- VC2005中 WMI编程模板
- vc2005中插入汇编代码
- TAUCS配置笔记
- asp.net中发送邮件(测试通过)
- #define用法总结
- 信号量和线程互斥锁
- _countof() 宏引申出来的语法知识
- 白痴理解的SOAP/Web Service/WSDL关系
- Java修饰符总结
- VC2005中测试Taucs库通过
- 验证手机和股票代码正则
- JS项目-SpiderMonkey编译说明
- ogre-1.7.0 + cegui-0.7.1 + vs2005 编译运行若干问题
- SQL中的叠加--结果集合转换为字符串(小提示) 转
- .Net通过拖放打开文件
- 1.String 数组的连接(最后一个不加,)
- magento -- 1.4版本使用google analytic 流量分析代码的bug
- InstallShield X之二 WebForm安装-1- -