数学研发论坛

 找回密码
 欢迎注册
查看: 16452|回复: 72

[讨论] mathe能否提供更新的windows版gmp库

[复制链接]
发表于 2010-9-7 19:14:54 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?欢迎注册

x
我下载了你的4.2和4.21..
现在4.32和5.01出来了
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-9-7 19:33:56 | 显示全部楼层
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

gmp-chudnovsky.c

15.96 KB, 下载次数: 2, 下载积分: 金币 -1 枚, 经验 1 点, 下载 1 次

毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-9-7 19:39:48 | 显示全部楼层
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
   gcd  time =  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
   gcd  time =  0.000
div
然后非法操作了

gmp-chudnovsky.c

15.81 KB, 下载次数: 0, 下载积分: 金币 -1 枚, 经验 1 点, 下载 1 次

原版

毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-9-7 20:26:45 | 显示全部楼层
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
   gcd  time =  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)=
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-9-7 20:47:29 | 显示全部楼层
another code

  1. /*
  2. Hi again!
  3. Here is a simple recursive parallel gmp-chudnovsky program using Cilk or Cilk++.

  4. The Cilk/Cilk++ compiler is based on GNU C, with a few extra keywords to control
  5. parallelism and works with the normal GNU GMP library.  Using Cilk/Cilk++
  6. instead of C with Pthreads or OpenMP makes recursive divide-and-conquer code
  7. easier to implement, debug (see cilkscreen), and maybe faster.
  8. More information about Cilk is at http://en.wikipedia.org/wiki/Cilk.

  9. Also, this simple version of gmp-chudnovsky has the factorization performance
  10. enhancement removed for readability, so running with one core will not be as
  11. fast as the Hanhong Xue's original version.

  12. Enjoy,
  13. David Carver
  14. */

  15. /* Pi computation using Chudnovsky's algortithm.

  16. * Copyright 2002,2005 Hanhong Xue (macroxue at yahoo dot com)

  17. * Slightly modified 2005 by Torbjorn Granlund to allow more than 2G
  18.    digits to be computed.

  19. * Modified 2010 by David Carver (dcarver at tacc dot utexas dot edu) to
  20.    demonstrate a parallel and fully recursive version of the gmp-chudnovsky
  21.    program, using cilk/cilk++.

  22.    To compile with GMP:
  23.    cilk++ -Wall -O2 -o pgmp-chudnovsky pgmp-chudnovsky.cilk -lgmp -lm -lmiser

  24.    To run:
  25.    ./pgmp-chudnovsky 1000 1

  26.    or add the Cilk++ option "-cilk_set_worker_count=" to specify the number
  27.    of workers (hardware threads used).

  28.    ./pgmp-chudnovsky 1000 1 -cilk_set_worker_count=1

  29.    To get help run the program with no options:
  30.    ./pgmp-chudnovsky

  31.    Syntax: ./pgmp-chudnovsky.cilk.bin <digits> <option>
  32.          <digits> digits of pi to output
  33.          <option> 0 - just run (default)
  34.                   1 - output decimal digits to stdout

  35. * Redistribution and use in source and binary forms,with or without
  36. * modification,are permitted provided that the following conditions are met:
  37. * 1. Redistributions of source code must retain the above copyright notice,
  38. * this list of conditions and the following disclaimer.
  39. * 2. Redistributions in binary form must reproduce the above copyright notice,
  40. * this list of conditions and the following disclaimer in the documentation
  41. * and/or other materials provided with the distribution.
  42. *
  43. * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
  44. * IMPLIED WARRANTIES,INCLUDING,BUT NOT LIMITED TO,THE IMPLIED WARRANTIES OF
  45. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  46. * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT,INDIRECT,INCIDENTAL,
  47. * SPECIAL,EXEMPLARY,OR CONSEQUENTIAL DAMAGES (INCLUDING,BUT NOT LIMITED TO,
  48. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,DATA,OR PROFITS;
  49. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  50. * WHETHER IN CONTRACT,STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR
  51. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF
  52. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  53. */

  54. #include <assert.h>
  55. #include <math.h>
  56. #include <stdio.h>
  57. #include <stdlib.h>
  58. #include <string.h>
  59. #include <time.h>
  60. #include <sys/time.h>
  61. #include <gmp.h>
  62. #include <cilk.h>

  63. #define A   13591409
  64. #define B   545140134
  65. #define C   640320
  66. #define D   12

  67. #define BITS_PER_DIGIT   3.32192809488736234787
  68. #define DIGITS_PER_ITER  14.1816474627254776555
  69. #define DOUBLE_PREC      53

  70. ////////////////////////////////////////////////////////////////////////////

  71. double wall_clock()
  72. {
  73.         struct timeval timeval;
  74.         (void) gettimeofday (&timeval,NULL);
  75.         return (timeval.tv_sec + (timeval.tv_usec / 1000000.0));
  76. }

  77. ////////////////////////////////////////////////////////////////////////////

  78. /* binary splitting */
  79. void
  80. bs(unsigned long a,unsigned long b,unsigned gflag,mpz_t pstack1,mpz_t qstack1,
  81.    mpz_t gstack1)
  82. {
  83.   unsigned long mid;
  84.   mpz_t pstack2,qstack2,gstack2;

  85.   if (b-a==1) {

  86.     /*
  87.       g(b-1,b) = (6b-5)(2b-1)(6b-1)
  88.       p(b-1,b) = b^3 * C^3 / 24
  89.       q(b-1,b) = (-1)^b*g(b-1,b)*(A+Bb).
  90.     */

  91.     mpz_set_ui(pstack1,b);
  92.     mpz_mul_ui(pstack1,pstack1,b);
  93.     mpz_mul_ui(pstack1,pstack1,b);
  94.     mpz_mul_ui(pstack1,pstack1,(C/24)*(C/24));
  95.     mpz_mul_ui(pstack1,pstack1,C*24);

  96.     mpz_set_ui(gstack1,2*b-1);
  97.     mpz_mul_ui(gstack1,gstack1,6*b-1);
  98.     mpz_mul_ui(gstack1,gstack1,6*b-5);

  99.     mpz_set_ui(qstack1,b);
  100.     mpz_mul_ui(qstack1,qstack1,B);
  101.     mpz_add_ui(qstack1,qstack1,A);
  102.     mpz_mul   (qstack1,qstack1,gstack1);
  103.     if (b%2)
  104.       mpz_neg(qstack1,qstack1);

  105.   } else {

  106.     /*
  107.       p(a,b) = p(a,m) * p(m,b)
  108.       g(a,b) = g(a,m) * g(m,b)
  109.       q(a,b) = q(a,m) * p(m,b) + q(m,b) * g(a,m)
  110.     */

  111.     mid = a+(b-a)*0.5224;     /* tuning parameter */

  112.     mpz_init(pstack2);
  113.     mpz_init(qstack2);
  114.     mpz_init(gstack2);

  115.     cilk_spawn bs(mid,b,gflag,pstack2,qstack2,gstack2);
  116.     bs(a,mid,1,pstack1,qstack1,gstack1);
  117.     cilk_sync;

  118.     mpz_mul(pstack1,pstack1,pstack2);
  119.     mpz_mul(qstack1,qstack1,pstack2);
  120.     mpz_mul(qstack2,qstack2,gstack1);
  121.     mpz_add(qstack1,qstack1,qstack2);

  122.     if (gflag) {
  123.       mpz_mul(gstack1,gstack1,gstack2);
  124.     }

  125.     mpz_clear(pstack2);
  126.     mpz_clear(qstack2);
  127.     mpz_clear(gstack2);
  128.   }
  129. }

  130. int
  131. cilk_main(int argc,char *argv[])
  132. {
  133.   mpf_t  pi,qi;
  134.   mpz_t   pstack,qstack,gstack;
  135.   long int d=100,out=0,terms;
  136.   unsigned long psize,qsize;
  137.   char *prog_name;
  138.   clock_t begin,end;
  139.   double wbegin,wend;

  140.   prog_name = argv[0];

  141.   if (argc==1) {
  142.     fprintf(stderr,"\nSyntax: %s <digits> <option>\n",prog_name);
  143.     fprintf(stderr,"      <digits> digits of pi to output\n");
  144.     fprintf(stderr,"      <option> 0 - just run (default)\n");
  145.     fprintf(stderr,"               1 - output decimal digits to stdout\n");
  146.     exit(1);
  147.   }
  148.   if (argc>1)
  149.     d = strtoul(argv[1],0,0);
  150.   if (argc>2)
  151.     out = atoi(argv[2]);

  152.   terms = d/DIGITS_PER_ITER;

  153.   fprintf(stderr,"#terms=%ld workers=%d\n",terms,cilk::current_worker_count());

  154.   begin = clock();
  155.   wbegin = wall_clock();

  156.   mpz_init(pstack);
  157.   mpz_init(qstack);
  158.   mpz_init(gstack);

  159.   /* begin binary splitting process */

  160.   if (terms<=0) {
  161.     mpz_set_ui(pstack,1);
  162.     mpz_set_ui(qstack,0);
  163.     mpz_set_ui(gstack,1);
  164.   } else {
  165.     bs(0,terms,0,pstack,qstack,gstack);
  166.   }

  167.   end = clock();
  168.   wend = wall_clock();
  169.   fprintf(stderr,"bs         cputime = %6.3f  wallclock = %6.3f\n",
  170.     (double)(end-begin)/CLOCKS_PER_SEC,(wend-wbegin));
  171.   fflush(stderr);

  172.   mpz_clear(gstack);

  173.   /* prepare to convert integers to floats */

  174.   mpf_set_default_prec((long int)(d*BITS_PER_DIGIT+16));

  175.   /*
  176.           p*(C/D)*sqrt(C)
  177.     pi = -----------------
  178.              (q+A*p)
  179.   */

  180.   psize = mpz_sizeinbase(pstack,10);
  181.   qsize = mpz_sizeinbase(qstack,10);

  182.   mpz_addmul_ui(qstack,pstack,A);
  183.   mpz_mul_ui(pstack,pstack,C/D);

  184.   mpf_init(pi);
  185.   mpf_set_z(pi,pstack);
  186.   mpz_clear(pstack);

  187.   mpf_init(qi);
  188.   mpf_set_z(qi,qstack);
  189.   mpz_clear(qstack);

  190.   /* final step */

  191.   mpf_div(qi,pi,qi);
  192.   mpf_sqrt_ui(pi,C);
  193.   mpf_mul(qi,qi,pi);

  194.   end = clock();
  195.   wend = wall_clock();

  196.   /* output Pi and timing statistics */

  197.   fprintf(stderr,"total      cputime = %6.3f  wallclock = %6.3f\n",
  198.     (double)(end-begin)/CLOCKS_PER_SEC,(wend-wbegin));
  199.   fflush(stderr);

  200.   printf("   P size=%ld digits (%f)\n"
  201.          "   Q size=%ld digits (%f)\n",
  202.          psize,(double)psize/d,qsize,(double)qsize/d);

  203.   if (out&1)  {
  204.     printf("pi(0,%ld)=\n",terms);
  205.     mpf_out_str(stdout,10,d+2,qi);
  206.     printf("\n");
  207.   }

  208.   /* free float resources */

  209.   mpf_clear(pi);
  210.   mpf_clear(qi);

  211.   exit (0);
  212. }


复制代码
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-8 12:12:08 | 显示全部楼层
我也很想得到gmp5.0.1的VC版
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-9 08:30:40 | 显示全部楼层


你们为啥都想要lib呢??
不修改代码,gmp不可能用VC静态编译
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-9 08:34:40 | 显示全部楼层
我基本都在Linux下用gmp.以前那个vc可以使用的版本不是我自己编译的,是从网络上找到的
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
发表于 2010-9-9 09:30:42 | 显示全部楼层
7# 无心人
因为得不到,所以更想得到。
至于OO出于什么理由,我就不知道了 ,呵呵
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
 楼主| 发表于 2010-9-9 09:44:20 | 显示全部楼层
我用msys+mingw编了1个dll,但没有.h也没有.lib没法用
毋因群疑而阻独见  毋任己意而废人言
毋私小惠而伤大体  毋借公论以快私情
您需要登录后才可以回帖 登录 | 欢迎注册

本版积分规则

小黑屋|手机版|数学研发网 ( 苏ICP备07505100号 )

GMT+8, 2019-1-20 09:39 , Processed in 0.064236 second(s), 19 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表