-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtour-gf2x.html
173 lines (138 loc) · 4.69 KB
/
tour-gf2x.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<html>
<head>
<title>
A Tour of NTL: Using NTL with the gf2x library </title>
</head>
<center>
<a href="tour-gmp.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a>
<a href="tour.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a>
<a href="tour-time.html"> <img src="arrow3.gif" alt="[Next]" align=bottom></a>
</center>
<h1>
<p align=center>
A Tour of NTL: Using NTL with the <tt>GF2X</tt> library
</p>
</h1>
<p> <hr> <p>
<tt>gf2x</tt> is a library for fast multiplication
of polynomials over <i>GF(2)</i>.
The <tt>gf2x</tt> library was developed by Emmanuel Thomé,
Paul Zimmermmann, Pierrick Gaudry, and Richard Brent.
You can get more information about it, as well as the latest version
from <a href="http://gforge.inria.fr/projects/gf2x/">here.</a>
<p>
Unlike NTL, which only imlements a version of Karatsuba multiplication,
<tt>gf2x</tt> implements other algorithms that are faster
for very large degree polynomials.
If you use NTL if the <tt>gf2x</tt> library,
then multiplication, division, GCD, and minimum polynomal
calculations for the <a href="GF2X.cpp.html">GF2X</a> class will
be faster for large degree polymials.
<p>
<b>Warning:</b>
<i>the current version of <tt>gf2x</tt> (v1.1) is neither thread safe
or exception safe;
do not use it if you need these features in NTL.</i>
<p>
<h2>
Downloading and building <tt>gf2x</tt>
</h2>
<p>
Download <tt>gf2x</tt> from <a href="http://gforge.inria.fr/projects/gf2x/">here.</a>
You will get a file <tt>gf2x-XXX.tar.gz</tt>.
<p>
Now do the following:
<pre>
% gunzip gf2x-XXX.tar.gz
% tar xf gf2x-XXX.tar
% cd gf2x-XXX
% ./configure --prefix=$HOME/sw
% make
% make check
% make install
</pre>
This will build, test, and install <tt>gf2x</tt> in <tt>$HOME/sw</tt>.
Of course, change $HOME/sw to whatever you want (the default is
<tt>/usr/local</tt>).
You will find the <tt>gf2x</tt> header files in <tt>$HOME/sw/include</tt>
and the compiled binaries in <tt>$HOME/sw/lib</tt>.
<p>
You can also supply the option
<tt>--disable-shared</tt> to the <tt>configure</tt> script,
if you only want static libraries.
However, if you ultimately want to build NTL as a shared
library, then you must also buld <tt>gf2x</tt> as a shared library.
<p>
<p>
You must ensure that NTL and <tt>gf2x</tt> have the same
<a href="tour-unix.html#abi">ABI</a>.
<tt>gf2x</tt>'s configuration script might need some
help to select the right one.
For example, you may have to pass
<pre>
ABI=64 CFLAGS="-m64 -O2"
</pre>
to <tt>gf2x</tt>'s configure script to force a 64-bit ABI.
<p>
<h2>
Building and using NTL with <tt>gf2x</tt>
</h2>
<p>
When building NTL with <tt>gf2x</tt>, you have to tell NTL that you want to
use it.
The easiest way to do this is by passing the argument
<tt>NTL_GF2X_LIB=on</tt> to the NTL configuration script
when you are <a href="tour-unix.html">installing NTL</a>.
Assuming you installed <tt>gf2x</tt> in <tt>$HOME/sw</tt> as above,
and you also want to install NTL in <tt>$HOME/sw</tt>,
you execute:
<pre>
% ./configure PREFIX=$HOME/sw NTL_GF2X_LIB=on GF2X_PREFIX=$HOME/sw
</pre>
You can write this more simply as
<pre>
% ./configure DEF_PREFIX=$HOME/sw NTL_GF2X_LIB=on
</pre>
Here, <tt>DEF_PREFIX</tt> is a variable that is used
to specify the location of all software,
and it defaults to <tt>/usr/local</tt>.
<p>
If you installed <tt>gf2x</tt> in <tt>/usr/local</tt> (or some other
standard system directory where your compiler will look by default)
then simply
<pre>
% ./configure PREFIX=$HOME/sw NTL_GF2X_LIB=on
</pre>
does the job.
Moreover, if NTL is also to be installed in <tt>/usr/local</tt>,
then
<pre>
% ./configure NTL_GF2X_LIB=on
</pre>
does the job.
<p>
Instead of passing arguments to the configure script,
you can also just edit the <tt>config.h</tt> and <tt>makefile</tt> by hand.
The documentation in these files should be self-explanatory.
<p>
When compiling programs that use NTL with <tt>gf2x</tt>,
you need to link with the <tt>gf2x</tt> library.
If <tt>gf2x</tt> is installed as above in
<tt>$HOME/sw</tt>, rather than in a standard system directory,
this just means adding
<tt>-L$HOME/sw/lib -lgf2x</tt> to the compilation command.
If you installed <tt>gf2x</tt> in a standard system directory,
then just <tt>-lgf2x</tt> does the job.
Note that <tt>-lgf2x</tt> must come <i>after</i> <tt>-lntl</tt>
on the command line.
Finally, if NTL and <tt>gf2x</tt> are installed as
shared libraries, then you don't even need <tt>-lgf2x</tt>.
<p> <hr> <p>
<p>
<center>
<a href="tour-gmp.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a>
<a href="tour.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a>
<a href="tour-time.html"> <img src="arrow3.gif" alt="[Next]" align=bottom></a>
</center>
</body>
</html>