Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Fri, 15 Oct 2004 23:27:23 +0200 (MET DST) From: "Angelo Graziosi (D. Zanello)" To: "Gerrit P. Haase" cc: "Angelo Graziosi (D. Zanello)" , Lapo Luchini , cygwin AT cygwin DOT com Subject: Re: Cygwin GMP 4.1.4-3 does not work correctly In-Reply-To: <1481596141300.20041011150719@familiehaase.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-AntiVirus: checked by Vexira Milter 1.0.6; VAE 6.28.0.3; VDF 6.28.0.20 Hi, with the package gmp-4.1.4-1 I have the same problems that were present with 4.1.3 and that WERE NOT present with 4.1.2! I have downloaded the source gmp-4.1.4.tar.bz2 from http://www.swox.com/gmp/ and have built it and uninstalled the Cygwin GMP package. With this source, all works fine (as Cygwin package 4.1.2)! The simple LiDIA-GMP application is: // ==================================== LiDIA_picalc.cpp #include #include #include #ifdef LIDIA_NAMESPACE using namespace LiDIA; #endif using namespace std; int main() { int nDigits = 10; cout << endl << "Number of digits: "; cin >> nDigits; bigfloat::set_precision(nDigits); bigfloat x = Pi(); cout << setprecision(nDigits) << endl << "PI = " << x << endl; return 0; } // ==================================== With Cygwin packages it is built with g++ -O3 -Wall -I/usr/local/include LiDIA_picalc.cpp \ -s -L/usr/local/lib -lLiDIA -lgmp -o LiDIA_picalc (/usr/local is the directory where I have installed my builds of LiDIA-2.1.2 and gmp-4.1.4 from http://www.swox.com/gmp/) -------------------------------------------- RESULTS with Cygwin packages 4.1.3, 4.1.4 Number of digits: 20 PI = 0.48602824728463545305e-4 -------------------------------------------- RESULTS with Cygwin package 4.1.2, build 4.1.4 from http://www.swox.com/gmp/ source Number of digits: 20 PI = 3.1415926535897932385 With these buids I have verified almost 2000 digits of PI ---------------------------------------------- The simple strictly GMP application is: // ==================================== picalc.cpp =================== #include #include #include using namespace std; int main() { int nBits; mpf_t x,y,t,sx,sx1,y1,pi,TWO,HALF,ONE; cout << endl << "Number of bits precision (0, default): "; cin >> nBits; if (nBits > 0) mpf_set_default_prec(nBits); // Constant definition mpf_init_set_str(ONE,"1e0",10); mpf_init_set_str(TWO,"2e0",10); mpf_init_set_str(HALF,"5e-1",10); mpf_init(x); mpf_init(y); mpf_init(t); mpf_init(sx); mpf_init(sx1); mpf_init(y1); mpf_init(pi); cout << "Current precision: " << mpf_get_default_prec() << endl << endl; mpf_sqrt(x,TWO); // X(0) = sqrt(2) mpf_add(pi,TWO,x); // PI(0) = 2+sqrt(2) mpf_sqrt(y,x); // Y(0) = 2^(1/4) = sqrt(X(0)) mpf_set(sx,y); // SX(0) = sqrt(X(0)) mpf_div(sx1,ONE,sx); // SX1(0) = 1/SX(0), i = 0 do { mpf_add(t,sx,sx1); // T = SX(i)+SX1(i) mpf_mul(x,HALF,t); // X(i+1) = 0.5*(SX(i)+SX1(i)) mpf_sqrt(sx,x); // SX(i+1) = sqrt(X(i+1)) mpf_div(sx1,ONE,sx); // SX1(i+1) = 1/SX(i+1) mpf_mul(t,y,sx); // T = Y(i)*SX(i+1)+SX1(i+1) mpf_add(t,t,sx1); mpf_add(x,x,ONE); // X = X(i+1) + 1 mpf_add(y,y,ONE); // Y = Y(i) + 1 mpf_div(y1,ONE,y); // Y1 = 1/Y(i) // Y(i+1) = [Y(i)*SX(i+1)+SX1(i+1)]/[Y(i)+1] mpf_mul(y,t,y1); mpf_mul(t,x,y1); // T = [X(i+1)+1]/[Y(i)+1] mpf_mul(pi,pi,t); // PI(i+1) = PI(i)*T // For i -> inf, PI(i+1) == PI(i) == PI, T == 1 } while(mpf_eq(ONE,t,1) == 0); // To output only significant digits use %.Ff gmp_printf("T = %.Ff\nPI= %.Ff",t,pi); /* cout << endl << "T = "; mpf_out_str(stdout,10,0,t); cout << endl << "PI= "; mpf_out_str(stdout,10,0,pi); */ mpf_clear(ONE); mpf_clear(TWO); mpf_clear(HALF); mpf_clear(x); mpf_clear(y); mpf_clear(t); mpf_clear(sx); mpf_clear(sx1); mpf_clear(y1); mpf_clear(pi); } // ==================================== With Cygwin packages it is built with g++ -O3 -Wall -I/usr/local/include picalc.cpp \ -s -L/usr/local/lib -lgmp -o picalc (/usr/local is the directory where I have installed my build of gmp-4.1.4 from http://www.swox.com/gmp/) -------------------------------------------- RESULTS with Cygwin packages 4.1.3, 4.1.4 Number of bits precision (0, default): 0 Current precision: 60 T = 1.00000000000000000043 PI= 3.14159265358979323743 in this case the bits precision is always a multiple of 30 (this is strange: one expect a multiple of a power of 2!) -------------------------------------------- RESULTS with Cygwin package 4.1.2, build 4.1.4 from http://www.swox.com/gmp/ source Number of bits precision (0, default): 0 Current precision: 64 T = 1.00000000000000000003 PI= 3.14159265358979323857 in this case the bits precision is always a multiple of 32 With these buids I have verified almost 2000 digits of PI ---------------------------------------------- angelo angelo DOT garziosi AT roma1 DOT infn DOT it On Mon, 11 Oct 2004, Gerrit P. Haase wrote: > Angelo schrieb: > > Oh not again... > > > I have rebuilt my previous applications (which use also LiDIA). > > With version 4.1.3-3 of the package they give incorrect results > > (Pi() prints 0.4...E-4 instead of 3.14..., for example). > > I saw the same problems, but I wasn't able to track this down, so I > thought it might bbe the program I wanted to do something useful... > > I never looked at the GMP site, oh shit. > > > I have noted at GMP site (http://www.swox.com/gmp/) that 4.1.3 has serious > > bugs. There it is suggested to pass at 4.1.4. > > > > When the 4.1.4 for Cygwin? > > Laop is the maintainer, I have CC'ed him. > Unfortunately the previous version was also broken (at least for me > which usually means nothing). > > Lapo, I'll try to build 4.1.4 now, for heavens sake;) > > Gerrit > -- > =^..^= > > -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/