[ntl] NTL + GMP

Alberto Megía elcapo.meti at gmail.com
Thu Mar 17 12:41:19 CDT 2011


Hi,

my name is Alberto, i am a Universidad Complutense de Madrid student. For my
research i am trying to use your NTL library with GMP. First of all, please
forgive my english level...
Well, these are the steps i took for installing it:

Installing GMP(gmp-5.0.1 version)

sudo apt-get install m4
1º gunzip gmp-XXX.tar.gz
2º tar xf gmp-XXX.tar
3º cd gmp-XXX
** As 'root':
4º ./configure
5º make
6º make check
7º make install

Installing NTL (ntl-5.5.2 version):

sudo apt-get install g++
1º gunzip ntl-XXX.tar.gz
2º tar xf ntl-XXX.tar
3º cd ntl-XXX/src
*** As 'root':
4º ./configure NTL_GMP_LIB=on CC=gcc CXX=g++
5º make
6º make check
7º make install


After these steps, i think all went good. Now i was getting started with it.
I have a simple trial division implemented with GMP, and i want it with NTL
with GMP as the primary long integer package, to get the performance
benefits of GMP using NTL. I have tried with this:

#include <NTL/ZZ.h>

NTL_CLIENT

int main() {

    ZZ numero, raizEntera, limInf, limSup, factor;
    factor = 0;
    numero = 1037239934749514921;
    limInf = 2;
    limSup = 1000000000000000000;
    raizEntera = SqrRoot(numero);
    if(limSup > raizEntera) {
        limSup = raizEntera;
    }
    if( (numero % limInf) == 0 ) factor = 2;
    else {
        if( (limInf % 2) == 0) limInf++;
        while(limInf <= limSup) {
            if( (numero % limInf) == 0) {
                factor = limInf;
                break;
            }
        limInf = limInf + 2;
        }
    }
    cout << "Factor found: " << factor << "\n";
}

I compile the program using the sentence -> g++ -static nuevaTrial.c -o
nuevaTrial -lntl -lgmp  -lm -m64 (my machine is 64 bits and i want a static
compilation) Is this the way i have to do it?
I have tried with that, but the results are not what i expected:

real    2m48.641s
user    2m48.380s
sys    0m0.200s

And the time i got with the same version but only with GMP was:

real    0m53.383s
user    0m53.330s
sys    0m0.010s

Can you tell me what i am doing wrong? Is that the result i should expect? i
have been looking at the documentation right here ->
http://www.shoup.net/ntl/doc/tour.html but that is what i get.

Thanks a lot for for your time.
Regards,
Alberto
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://shoup.net/pipermail/ntl_shoup.net/attachments/20110317/19498e98/attachment.html>


More information about the ntl mailing list