首页
社区
课程
招聘
[分享]在VC++6.0中使用NTL数论库
发表于: 2011-4-25 10:07 8421

[分享]在VC++6.0中使用NTL数论库

2011-4-25 10:07
8421
NTL: A Library for doing Number Theory
NTL is a high-performance, portable C++ library providing data structures and algorithms for manipulating signed, arbitrary length integers, and for vectors, matrices, and polynomials over the integers and over finite fields.
NTL数论库有很多Miracl没有的函数,包括LLL算法等等。

下载页面:
http://www.shoup.net/ntl/download.html
(注意区分Windows与Unix版本)
步骤:

1、修改WinNTL-X_X_X\include\NTL\config.h文件中
#if 1
#define NTL_STD_CXX

#if 0
#define NTL_STD_CXX
2、复制WinNTL-X_X_X\include\NTL文件夹至VC++ 6.0头文件目录
3、新建空Win32 Static Library工程,将源码WinNTL-X_X_X\src文件夹添加至工程,并编译NTL.lib
4、新建空Win32 Console Application工程,添加WinNTL-X_X_X\tests\QuickTest.cpp至工程、添加NTL.lib至工程并编译。如果编译运行没问题,说明安装成功。
5、新建Win32 Application工程,添加NTL.lib至工程,并编译以下代码

#include <NTL/ZZ.h>
#include <windows.h>

//注意包含头文件的顺序,如果顺序不对可能编译失败
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
        ZZ x,y,z;
        z=x+y;
        return 0;
}
说明:下载WinNTL-5_5_2,在VC++ 6.0中测试成功,其他的VC++版本没有测试。
引用:
“TIP: When writing windows applications using NTL (as opposed to console applications) you might want to compile your program with the NTL_NO_MIN_MAX macro defined. This suppresses the declaration of several min and max functions in file tools.h that conflict with macro names in the MFC header files. Do not attempt to build the library with this macro defined -- only programs that use the library. ”
因为NTL的某些命名与MFC有冲突,所以生成控制台程序没错误但在MFC程序中使用的时候错误多多。如果编译出现“error C2062: type 'int' unexpected”等错误的时候,请将
#include <windows.h>
#include <NTL/ZZ.h>
改为
#include <NTL/ZZ.h>
#include <windows.h>
总之#include <windows.h>,要放在NTL头文件之下。
附件包含WinNTL-5_5_2.rar、NTL.lib及测试工程。

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

上传的附件:
收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 123
活跃值: (50)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
好东西,收藏,也许以后有用
2011-4-25 10:23
0
雪    币: 433
活跃值: (45)
能力值: ( LV4,RANK:50 )
在线值:
发帖
回帖
粉丝
3
收藏慢慢学,Number Theory真很难,分枝都有几十个
2011-4-25 12:34
0
游客
登录 | 注册 方可回帖
返回
//