mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2007-10-21, 18:52   #1
ixfd64
Bemusing Prompter
 
ixfd64's Avatar
 
"Danny"
Dec 2002
California

3×769 Posts
Default need C/C++ modular arithmetic code for Windows

I'm looking for some C or C++ code that can perform modular operations on very large numbers. I know that GMP is useful, but I've heard that it only works on Unix and Unix-like systems. Is there any way to run GMP code on Windows?

I know that there's also the MIRACL package, but it isn't free ('free' as in free software) and I prefer to use open source software.

Thanks.
ixfd64 is offline   Reply With Quote
Old 2007-10-21, 19:21   #2
potonono
 
potonono's Avatar
 
Jun 2005
USA, IL

193 Posts
Default

http://cs.nyu.edu/exact/core/gmp/
potonono is offline   Reply With Quote
Old 2007-10-21, 23:33   #3
ixfd64
Bemusing Prompter
 
ixfd64's Avatar
 
"Danny"
Dec 2002
California

90316 Posts
Default

I'll check it out tonight.

Thanks for the link!
ixfd64 is offline   Reply With Quote
Old 2007-10-23, 03:22   #4
Citrix
 
Citrix's Avatar
 
Jun 2003

2×787 Posts
Default

I like NTL (google it). Works with visual C++.

Last fiddled with by Citrix on 2007-10-23 at 03:23
Citrix is offline   Reply With Quote
Old 2007-10-24, 07:04   #5
schickel
 
schickel's Avatar
 
"Frank <^>"
Dec 2004
CDP Janesville

40628 Posts
Default

Another library to look at is LibTomMath over at http://libtom.org/

Included with the code is a 200+ page book (pdf) that serves as an introductory textbook to the theory behind the library.

Written in generic C, it will compile with GCC or VC++ v6 with no additional configuration.

Frank
schickel is offline   Reply With Quote
Old 2007-11-05, 11:12   #6
ixfd64
Bemusing Prompter
 
ixfd64's Avatar
 
"Danny"
Dec 2002
California

90316 Posts
Default

I put the gmp.h file in the same folder as my .cpp file, in which I put the line #include <gmp.h>. Am I doing things correctly?
ixfd64 is offline   Reply With Quote
Old 2007-11-05, 19:43   #7
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

1,409 Posts
Default

Quote:
Originally Posted by ixfd64 View Post
I put the gmp.h file in the same folder as my .cpp file, in which I put the line #include <gmp.h>. Am I doing things correctly?
You should use
#include "gmp.h"

And it is not enough to put only gmp.h in the folder. You have to build the gmp library!
As I can remember: download gmp-4.2.2.tar.gz from: http://gmplib.org/
Put this into a folder. Then
tar xfvz gmp-4.2.2.tar.gz
./configure
make
make check

It takes some hours on the computer. Not so fast.

Last fiddled with by R. Gerbicz on 2007-11-05 at 19:49
R. Gerbicz is offline   Reply With Quote
Old 2007-11-05, 23:53   #8
ixfd64
Bemusing Prompter
 
ixfd64's Avatar
 
"Danny"
Dec 2002
California

44038 Posts
Default

OK, I've installed Cygwin and added the appropriate packages (make, gcc, and m4). However, I seem to be having problems.

I entered the "./configure" command and it said that there was no such file or directory. I then tried "make" and it told me that I needed a "makefile."

Ugh, GMP isn't as user-friendly as I thought.
ixfd64 is offline   Reply With Quote
Old 2007-11-06, 00:24   #9
rogue
 
rogue's Avatar
 
"Mark"
Apr 2003
Between here and the

24×7×53 Posts
Default

Quote:
Originally Posted by ixfd64 View Post
OK, I've installed Cygwin and added the appropriate packages (make, gcc, and m4). However, I seem to be having problems.

I entered the "./configure" command and it said that there was no such file or directory. I then tried "make" and it told me that I needed a "makefile."

Ugh, GMP isn't as user-friendly as I thought.
I believe that you will also need nasm (also included in Cygwin), but I could be wrong. You need to start the Cygwin shell, then use the "cd" command to get to the appropriate GMP folder. From there you can configure and make.
rogue is offline   Reply With Quote
Old 2007-11-06, 10:03   #10
ATH
Einyen
 
ATH's Avatar
 
Dec 2003
Denmark

56258 Posts
Default

I use GMP in windows with Visual C++. Here are the GMP 4.2.2 files compiled on a P4 Prescott 3.4 Ghz:

gmp.h
libgmp-3.dll.dll
libgmp-3.lib

I place gmp.h in 2 folders inside the visual studio folder:
Microsoft Visual Studio 6\VC98\Include\
Microsoft Visual Studio 6\VC98\CRT\SRC\

"libgmp-3.dll.dll" I place in any folder that is in the path line, I just put it in c:\windows. (I'm not sure why its called .dll.dll, I think I made a mistake during compiling, but it works).

libgmp-3.lib I place in all project folders where I use GMP and I add it to the project under files Resource library, and add #include <gmp.h> in the header.
ATH is offline   Reply With Quote
Old 2007-11-06, 11:14   #11
ixfd64
Bemusing Prompter
 
ixfd64's Avatar
 
"Danny"
Dec 2002
California

3·769 Posts
Default

Hmm, I'm using Dev-C++. Do you have advice for using this IDE?
ixfd64 is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Basic Number Theory 5: rationals & intro to modular arithmetic Nick Number Theory Discussion Group 1 2016-10-21 22:21
modular arithmetic science_man_88 Miscellaneous Math 42 2011-07-26 02:02
modular arithmetic problem JuanTutors Math 4 2009-03-11 16:06
Modular Arithmetic Numbers Math 27 2005-11-30 15:41
Jim Howell's modular arithmetic program? ixfd64 Software 0 2004-05-27 05:42

All times are UTC. The time now is 03:52.

Tue Oct 20 03:52:16 UTC 2020 up 40 days, 1:03, 0 users, load averages: 2.30, 1.92, 1.82

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.