mathe能否提供更新的windows版gmp库
我下载了你的4.2和4.21..现在4.32和5.01出来了 D:\lt\dl>vc6\setvar
D:\lt\dl>set MSVCDir=d:\lt\dl\vc6
D:\lt\dl>set INCLUDE=d:\lt\dl\vc6\ATL\INCLUDE;d:\lt\dl\vc6\INCLUDE;d:\lt\dl\vc6\MFC\INCLUDE;
D:\lt\dl>set LIB=d:\lt\dl\vc6\LIB;d:\lt\dl\vc6\MFC\LIB;
D:\lt\dl>set PATH=d:\lt\dl\vc6\BIN;D:\Oracle\ora92\bin;D:\Oracle\jre\1.3.1\bin;D:\Oracle\jre\1.1.8\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WIN
DOWS\System32\Wbem;C:\Program Files\Intel\Wireless\Bin\;C:\Program Files\Diskeeper Corporation\Diskeeper\;C:\Program Files\ThinkPad\ConnectU
tilities;C:\Program Files\Common Files\Lenovo;C:\Program Files\Lenovo\Client Security Solution
D:\lt\dl>set include=D:\lt\dl\gmp421\include;%include%
D:\lt\dl>set lib=D:\lt\dl\gmp421\lib\Win32\Release;%lib%
D:\lt\dl>cd gmp421
D:\lt\dl\gmp421>cl gmp-chudnovsky.c /link D:\lt\dl\gmp421\lib\Win32\Release\gmp.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
gmp-chudnovsky.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:gmp-chudnovsky.exe
D:\lt\dl\gmp421\lib\Win32\Release\gmp.lib
gmp-chudnovsky.obj
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other libs; use /NODEFAULTLIB:library
gmp.lib(out_str.obj) : error LNK2001: unresolved external symbol ___iob_func
gmp.lib(memory.obj) : error LNK2001: unresolved external symbol ___iob_func
gmp.lib(assert.obj) : error LNK2001: unresolved external symbol ___iob_func
gmp.lib(get_str.obj) : error LNK2001: unresolved external symbol __ftol2_sse
gmp.lib(get_str.obj) : error LNK2001: unresolved external symbol ___security_cookie
gmp.lib(get_str.obj) : error LNK2001: unresolved external symbol @__security_check_cookie@4
gmp-chudnovsky.exe : fatal error LNK1120: 4 unresolved externals D:\lt\dl\gmp421>cl gmp-chudnovsky.c /link D:\lt\dl\gmp421\dll\Win32\Release\gmp.lib
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
gmp-chudnovsky.c
Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:gmp-chudnovsky.exe
D:\lt\dl\gmp421\dll\Win32\Release\gmp.lib
gmp-chudnovsky.obj
D:\lt\dl\gmp421>gmp-chudnovsky.exe
#terms=7, depth=4
sieve time =0.000
.......
bs time =0.000
gcdtime =0.000
div time =0.000
sqrt time =0.000
mul time =0.000
total time =0.000
P size=124 digits (1.240000)
Q size=117 digits (1.170000)
D:\lt\dl\gmp421>gmp-chudnovsky 2
#terms=0, depth=2
sieve time =0.015
bs time =0.000
gcdtime =0.000
div
然后非法操作了 gmp-chudnovsky 1000 11
....
p(65,70)=3^13 5^16 7 11^3 17^2 23^17 29^15 67^3
19 79 131 397 401
p(61,70)=3^26 5^28 7^3 11^3 13^2 17^2 23^29 29^26 31^3 67^3
3 5 7 11 41 43 53 127 367 373 379 383 389
p(53,70)=3^54 5^53 7^5 11^5 13^2 17^2 19^2 23^52 29^52 31^3 59^3 61^3 67^3
5 7^4 11^3 13^2 17^2 19^2 31 37 47 67 71 73 107 109 113 331 337 347 349 353 359
p(36,70)=3^98 5^107 7^12 11^7 13^6 17^3 19^5 23^104 29^103 31^3 37^3 41^3 43^3 47^3 53^3 59^3 61^3 67^3
3^2 5^3 7^7 11^3 13^2 17^2 19^2 29 31^2 37 41 43 47 53 59 61 73 79 83 89 97 101 103 223 227 229 233 239 241 251 257 263 269 271 277 281 283
293 307 311 313 317
p(0,70)=3^204 5^217 7^23 11^12 13^10 17^7 19^8 23^212 29^210 31^6 37^3 41^3 43^3 47^3 53^3 59^3 61^3 67^3
5^5 7^13 11^7 13^7 17^4 19^6 23^2 31^3 37^3 41^3 43^3 47^2 53^2 59^2 61^2 67^2 71^2 73 79 83 89 97 101 103 107 109 113 127 131 137 139 149
51 157 163 167 173 179 181 191 193 197 199 211
bs time =0.453
gcdtime =0.000
div time =0.000
sqrt time =0.000
mul time =0.000
total time =0.453
P size=1334 digits (1.334000)
Q size=1327 digits (1.327000)
pi(0,70)= another code
/*
Hi again!
Here is a simple recursive parallel gmp-chudnovsky program using Cilk or Cilk++.
The Cilk/Cilk++ compiler is based on GNU C, with a few extra keywords to control
parallelism and works with the normal GNU GMP library.Using Cilk/Cilk++
instead of C with Pthreads or OpenMP makes recursive divide-and-conquer code
easier to implement, debug (see cilkscreen), and maybe faster.
More information about Cilk is at http://en.wikipedia.org/wiki/Cilk.
Also, this simple version of gmp-chudnovsky has the factorization performance
enhancement removed for readability, so running with one core will not be as
fast as the Hanhong Xue's original version.
Enjoy,
David Carver
*/
/* Pi computation using Chudnovsky's algortithm.
* Copyright 2002,2005 Hanhong Xue (macroxue at yahoo dot com)
* Slightly modified 2005 by Torbjorn Granlund to allow more than 2G
digits to be computed.
* Modified 2010 by David Carver (dcarver at tacc dot utexas dot edu) to
demonstrate a parallel and fully recursive version of the gmp-chudnovsky
program, using cilk/cilk++.
To compile with GMP:
cilk++ -Wall -O2 -o pgmp-chudnovsky pgmp-chudnovsky.cilk -lgmp -lm -lmiser
To run:
./pgmp-chudnovsky 1000 1
or add the Cilk++ option "-cilk_set_worker_count=" to specify the number
of workers (hardware threads used).
./pgmp-chudnovsky 1000 1 -cilk_set_worker_count=1
To get help run the program with no options:
./pgmp-chudnovsky
Syntax: ./pgmp-chudnovsky.cilk.bin <digits> <option>
<digits> digits of pi to output
<option> 0 - just run (default)
1 - output decimal digits to stdout
* Redistribution and use in source and binary forms,with or without
* modification,are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES,INCLUDING,BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO
* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,INDIRECT,INCIDENTAL,
* SPECIAL,EXEMPLARY,OR CONSEQUENTIAL DAMAGES (INCLUDING,BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA,OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT,STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <sys/time.h>
#include <gmp.h>
#include <cilk.h>
#define A 13591409
#define B 545140134
#define C 640320
#define D 12
#define BITS_PER_DIGIT 3.32192809488736234787
#define DIGITS_PER_ITER14.1816474627254776555
#define DOUBLE_PREC 53
////////////////////////////////////////////////////////////////////////////
double wall_clock()
{
struct timeval timeval;
(void) gettimeofday (&timeval,NULL);
return (timeval.tv_sec + (timeval.tv_usec / 1000000.0));
}
////////////////////////////////////////////////////////////////////////////
/* binary splitting */
void
bs(unsigned long a,unsigned long b,unsigned gflag,mpz_t pstack1,mpz_t qstack1,
mpz_t gstack1)
{
unsigned long mid;
mpz_t pstack2,qstack2,gstack2;
if (b-a==1) {
/*
g(b-1,b) = (6b-5)(2b-1)(6b-1)
p(b-1,b) = b^3 * C^3 / 24
q(b-1,b) = (-1)^b*g(b-1,b)*(A+Bb).
*/
mpz_set_ui(pstack1,b);
mpz_mul_ui(pstack1,pstack1,b);
mpz_mul_ui(pstack1,pstack1,b);
mpz_mul_ui(pstack1,pstack1,(C/24)*(C/24));
mpz_mul_ui(pstack1,pstack1,C*24);
mpz_set_ui(gstack1,2*b-1);
mpz_mul_ui(gstack1,gstack1,6*b-1);
mpz_mul_ui(gstack1,gstack1,6*b-5);
mpz_set_ui(qstack1,b);
mpz_mul_ui(qstack1,qstack1,B);
mpz_add_ui(qstack1,qstack1,A);
mpz_mul (qstack1,qstack1,gstack1);
if (b%2)
mpz_neg(qstack1,qstack1);
} else {
/*
p(a,b) = p(a,m) * p(m,b)
g(a,b) = g(a,m) * g(m,b)
q(a,b) = q(a,m) * p(m,b) + q(m,b) * g(a,m)
*/
mid = a+(b-a)*0.5224; /* tuning parameter */
mpz_init(pstack2);
mpz_init(qstack2);
mpz_init(gstack2);
cilk_spawn bs(mid,b,gflag,pstack2,qstack2,gstack2);
bs(a,mid,1,pstack1,qstack1,gstack1);
cilk_sync;
mpz_mul(pstack1,pstack1,pstack2);
mpz_mul(qstack1,qstack1,pstack2);
mpz_mul(qstack2,qstack2,gstack1);
mpz_add(qstack1,qstack1,qstack2);
if (gflag) {
mpz_mul(gstack1,gstack1,gstack2);
}
mpz_clear(pstack2);
mpz_clear(qstack2);
mpz_clear(gstack2);
}
}
int
cilk_main(int argc,char *argv[])
{
mpf_tpi,qi;
mpz_t pstack,qstack,gstack;
long int d=100,out=0,terms;
unsigned long psize,qsize;
char *prog_name;
clock_t begin,end;
double wbegin,wend;
prog_name = argv;
if (argc==1) {
fprintf(stderr,"\nSyntax: %s <digits> <option>\n",prog_name);
fprintf(stderr," <digits> digits of pi to output\n");
fprintf(stderr," <option> 0 - just run (default)\n");
fprintf(stderr," 1 - output decimal digits to stdout\n");
exit(1);
}
if (argc>1)
d = strtoul(argv,0,0);
if (argc>2)
out = atoi(argv);
terms = d/DIGITS_PER_ITER;
fprintf(stderr,"#terms=%ld workers=%d\n",terms,cilk::current_worker_count());
begin = clock();
wbegin = wall_clock();
mpz_init(pstack);
mpz_init(qstack);
mpz_init(gstack);
/* begin binary splitting process */
if (terms<=0) {
mpz_set_ui(pstack,1);
mpz_set_ui(qstack,0);
mpz_set_ui(gstack,1);
} else {
bs(0,terms,0,pstack,qstack,gstack);
}
end = clock();
wend = wall_clock();
fprintf(stderr,"bs cputime = %6.3fwallclock = %6.3f\n",
(double)(end-begin)/CLOCKS_PER_SEC,(wend-wbegin));
fflush(stderr);
mpz_clear(gstack);
/* prepare to convert integers to floats */
mpf_set_default_prec((long int)(d*BITS_PER_DIGIT+16));
/*
p*(C/D)*sqrt(C)
pi = -----------------
(q+A*p)
*/
psize = mpz_sizeinbase(pstack,10);
qsize = mpz_sizeinbase(qstack,10);
mpz_addmul_ui(qstack,pstack,A);
mpz_mul_ui(pstack,pstack,C/D);
mpf_init(pi);
mpf_set_z(pi,pstack);
mpz_clear(pstack);
mpf_init(qi);
mpf_set_z(qi,qstack);
mpz_clear(qstack);
/* final step */
mpf_div(qi,pi,qi);
mpf_sqrt_ui(pi,C);
mpf_mul(qi,qi,pi);
end = clock();
wend = wall_clock();
/* output Pi and timing statistics */
fprintf(stderr,"total cputime = %6.3fwallclock = %6.3f\n",
(double)(end-begin)/CLOCKS_PER_SEC,(wend-wbegin));
fflush(stderr);
printf(" P size=%ld digits (%f)\n"
" Q size=%ld digits (%f)\n",
psize,(double)psize/d,qsize,(double)qsize/d);
if (out&1){
printf("pi(0,%ld)=\n",terms);
mpf_out_str(stdout,10,d+2,qi);
printf("\n");
}
/* free float resources */
mpf_clear(pi);
mpf_clear(qi);
exit (0);
}
我也很想得到gmp5.0.1的VC版 :Q:
你们为啥都想要lib呢??
不修改代码,gmp不可能用VC静态编译 我基本都在Linux下用gmp.以前那个vc可以使用的版本不是我自己编译的,是从网络上找到的 7# 无心人
因为得不到,所以更想得到。
至于OO出于什么理由,我就不知道了 ,呵呵 我用msys+mingw编了1个dll,但没有.h也没有.lib没法用