source:
clfs-sysroot/patches/gmp-4.2.4-branch_update-1.patch@
63c1d49
Last change on this file since 63c1d49 was d3318e9, checked in by , 16 years ago | |
---|---|
|
|
File size: 10.8 KB |
-
doc/gmp.texi
Submitted By: Jim Gifford (jim at cross-lfs dot org) Date: 2009-01-03 Initial Package Version: 4.2.4 Origin: GMP Website Upstream Status: Fixed Description: See http://gmplib.org Website Under Curent Status diff -Naur gmp-4.2.4.orig/doc/gmp.texi gmp-4.2.4/doc/gmp.texi
old new 4849 4849 equal, zero otherwise. I.e., test if @var{op1} and @var{op2} are approximately 4850 4850 equal. 4851 4851 4852 Caution: Currently only whole limbs are compared, and only in an exact 4853 fashion. In the future values like 1000 and 0111 may be considered the same 4854 to 3 bits (on the basis that their difference is that small). 4852 Caution 1: All version of GMP up to version 4.2.4 compared just whole limbs, 4853 meaning sometimes more than @var{op3} bits, sometimes fewer. 4854 4855 Caution 2: This function will consider XXX11...111 and XX100...000 different, 4856 even if ... is replaced by a semi-infinite number of bits. Such numbers are 4857 really just one ulp off, and should be considered equal. 4855 4858 @end deftypefun 4856 4859 4857 4860 @deftypefun void mpf_reldiff (mpf_t @var{rop}, mpf_t @var{op1}, mpf_t @var{op2}) -
mpf/eq.c
diff -Naur gmp-4.2.4.orig/mpf/eq.c gmp-4.2.4/mpf/eq.c
old new 1 1 /* mpf_eq -- Compare two floats up to a specified bit #. 2 2 3 Copyright 1993, 1995, 1996, 2001, 2002 Free Software Foundation, Inc.3 Copyright 1993, 1995, 1996, 2001, 2002, 2008 Free Software Foundation, Inc. 4 4 5 5 This file is part of the GNU MP Library. 6 6 … … 19 19 20 20 #include "gmp.h" 21 21 #include "gmp-impl.h" 22 #include "longlong.h" 22 23 23 24 int 24 25 mpf_eq (mpf_srcptr u, mpf_srcptr v, unsigned long int n_bits) … … 26 27 mp_srcptr up, vp; 27 28 mp_size_t usize, vsize, size, i; 28 29 mp_exp_t uexp, vexp; 30 mp_limb_t diff; 31 int cnt; 29 32 30 33 uexp = u->_mp_exp; 31 34 vexp = v->_mp_exp; … … 53 56 /* U and V have the same sign and are both non-zero. */ 54 57 55 58 /* 2. Are the exponents different? */ 56 if (uexp > vexp) 57 return 0; /* ??? handle (uexp = vexp + 1) */ 58 if (vexp > uexp) 59 return 0; /* ??? handle (vexp = uexp + 1) */ 59 if (uexp != vexp) 60 return 0; 60 61 61 62 usize = ABS (usize); 62 63 vsize = ABS (vsize); … … 93 94 size = usize; 94 95 } 95 96 96 if (size > (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS)97 size = (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;97 up += usize; /* point just above most significant limb */ 98 vp += vsize; /* point just above most significant limb */ 98 99 99 up += usize - size; 100 vp += vsize - size; 100 count_leading_zeros (cnt, up[-1]); 101 if ((vp[-1] >> (GMP_LIMB_BITS - 1 - cnt)) != 1) 102 return 0; /* msb positions different */ 101 103 102 for (i = size - 1; i >= 0; i--) 104 n_bits += cnt - GMP_NAIL_BITS; 105 106 size = MIN (size, (n_bits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS); 107 108 up -= size; /* point at least significant relevant limb */ 109 vp -= size; /* point at least significant relevant limb */ 110 111 for (i = size - 1; i > 0; i--) 103 112 { 104 113 if (up[i] != vp[i]) 105 114 return 0; 106 115 } 107 116 108 return 1; 117 diff = (up[0] ^ vp[0]) >> GMP_NUMB_BITS - 1 - (n_bits - 1) % GMP_NUMB_BITS; 118 return diff == 0; 109 119 } -
mpf/set_str.c
diff -Naur gmp-4.2.4.orig/mpf/set_str.c gmp-4.2.4/mpf/set_str.c
old new 137 137 c = (unsigned char) *++str; 138 138 } 139 139 140 /* Default base to decimal. */ 141 if (base == 0) 142 base = 10; 143 140 144 exp_base = base; 145 141 146 if (base < 0) 142 147 { 143 148 exp_base = 10; … … 165 170 return -1; 166 171 } 167 172 168 /* Default base to decimal. */169 if (base == 0)170 base = 10;171 172 173 /* Locate exponent part of the input. Look from the right of the string, 173 174 since the exponent is usually a lot shorter than the mantissa. */ 174 175 expptr = NULL; -
mpz/perfpow.c
diff -Naur gmp-4.2.4.orig/mpz/perfpow.c gmp-4.2.4/mpz/perfpow.c
old new 1 1 /* mpz_perfect_power_p(arg) -- Return non-zero if ARG is a perfect power, 2 2 zero otherwise. 3 3 4 Copyright 1998, 1999, 2000, 2001, 2005 Free Software Foundation, Inc.4 Copyright 1998, 1999, 2000, 2001, 2005, 2008 Free Software Foundation, Inc. 5 5 6 6 This file is part of the GNU MP Library. 7 7 … … 59 59 #define SMALLEST_OMITTED_PRIME 1009 60 60 61 61 62 #define POW2P(a) (((a) & ((a) - 1)) == 0) 63 62 64 int 63 65 mpz_perfect_power_p (mpz_srcptr u) 64 66 { … … 72 74 mp_size_t usize = SIZ (u); 73 75 TMP_DECL; 74 76 75 if ( usize == 0)76 return 1; /* consider 0 a perfect power*/77 if (mpz_cmpabs_ui (u, 1) <= 0) 78 return 1; /* -1, 0, and +1 are perfect powers */ 77 79 78 80 n2 = mpz_scan1 (u, 0); 79 81 if (n2 == 1) 80 82 return 0; /* 2 divides exactly once. */ 81 83 82 if (n2 != 0 && (n2 & 1) == 0 && usize < 0)83 return 0; /* 2 has even multiplicity with negative U */84 85 84 TMP_MARK; 86 85 87 86 uns = ABS (usize) - n2 / BITS_PER_MP_LIMB; … … 89 88 MPZ_TMP_INIT (u2, uns); 90 89 91 90 mpz_tdiv_q_2exp (u2, u, n2); 91 mpz_abs (u2, u2); 92 93 if (mpz_cmp_ui (u2, 1) == 0) 94 { 95 TMP_FREE; 96 /* factoring completed; consistent power */ 97 return ! (usize < 0 && POW2P(n2)); 98 } 92 99 93 100 if (isprime (n2)) 94 101 goto n2prime; … … 97 104 { 98 105 prime = primes[i]; 99 106 107 if (mpz_cmp_ui (u2, prime) < 0) 108 break; 109 100 110 if (mpz_divisible_ui_p (u2, prime)) /* divisible by this prime? */ 101 111 { 102 112 rem = mpz_tdiv_q_ui (q, u2, prime * prime); … … 115 125 n++; 116 126 } 117 127 118 if ((n & 1) == 0 && usize < 0)119 {120 TMP_FREE;121 return 0; /* even multiplicity with negative U, reject */122 }123 124 128 n2 = gcd (n2, n); 125 129 if (n2 == 1) 126 130 { … … 128 132 return 0; /* we have multiplicity 1 of some factor */ 129 133 } 130 134 131 if (mpz_cmp abs_ui (u2, 1) == 0)135 if (mpz_cmp_ui (u2, 1) == 0) 132 136 { 133 137 TMP_FREE; 134 return 1; /* factoring completed; consistent power */ 138 /* factoring completed; consistent power */ 139 return ! (usize < 0 && POW2P(n2)); 135 140 } 136 141 137 142 /* As soon as n2 becomes a prime number, stop factoring. … … 169 174 else 170 175 { 171 176 unsigned long int nth; 177 178 if (usize < 0 && POW2P(n2)) 179 return 0; 180 172 181 /* We found some factors above. We just need to consider values of n 173 182 that divides n2. */ 174 183 for (nth = 2; nth <= n2; nth++) … … 184 193 exact = mpz_root (q, u2, nth); 185 194 if (exact) 186 195 { 187 TMP_FREE; 188 return 1; 196 if (! (usize < 0 && POW2P(nth))) 197 { 198 TMP_FREE; 199 return 1; 200 } 189 201 } 190 202 if (mpz_cmp_ui (q, SMALLEST_OMITTED_PRIME) < 0) 191 203 { … … 199 211 } 200 212 201 213 n2prime: 214 if (usize < 0 && POW2P(n2)) 215 return 0; 216 202 217 exact = mpz_root (NULL, u2, n2); 203 218 TMP_FREE; 204 219 return exact; -
tests/cxx/t-prec.cc
diff -Naur gmp-4.2.4.orig/tests/cxx/t-prec.cc gmp-4.2.4/tests/cxx/t-prec.cc
old new 1 1 /* Test precision of mpf_class expressions. 2 2 3 Copyright 2001, 2002, 2003 Free Software Foundation, Inc.3 Copyright 2001, 2002, 2003, 2008 Free Software Foundation, Inc. 4 4 5 5 This file is part of the GNU MP Library. 6 6 … … 61 61 g = 1 / f; 62 62 ASSERT_ALWAYS_PREC 63 63 (g, "0.11111 11111 11111 11111 11111 11111 11111 11111 11111 11111" 64 " 11111 11111 11111 11111 11111 11 ", very_large_prec);64 " 11111 11111 11111 11111 11111 111", very_large_prec); 65 65 } 66 66 { 67 67 mpf_class f(15.0, large_prec); … … 69 69 g = 1 / f; 70 70 ASSERT_ALWAYS_PREC 71 71 (g, "0.06666 66666 66666 66666 66666 66666 66666 66666 66666 66666" 72 " 66666 66666 66666 66666 66666 6 7", very_large_prec);72 " 66666 66666 66666 66666 66666 667", very_large_prec); 73 73 } 74 74 75 75 // compound expressions … … 94 94 i = f / g + h; 95 95 ASSERT_ALWAYS_PREC 96 96 (i, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" 97 " 33333 33333 33333 333 ", very_large_prec);97 " 33333 33333 33333 33333 33333 3", very_large_prec); 98 98 } 99 99 { 100 100 mpf_class f(3.0, small_prec); 101 101 mpf_class g(-(1 + f) / 3, very_large_prec); 102 102 ASSERT_ALWAYS_PREC 103 103 (g, "-1.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" 104 " 33333 33333 33333 333 ", very_large_prec);104 " 33333 33333 33333 33333 33333 33", very_large_prec); 105 105 } 106 106 { 107 107 mpf_class f(9.0, medium_prec); … … 117 117 g = hypot(1 + 5 / f, 1.0); 118 118 ASSERT_ALWAYS_PREC 119 119 (g, "1.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666" 120 " 66666 66666 66666 66 7", very_large_prec);120 " 66666 66666 66666 66666 66666 67", very_large_prec); 121 121 } 122 122 123 123 // compound assignments … … 142 142 mpf_class g(0.0, very_large_prec); 143 143 g = mpf_class(1 / f); 144 144 ASSERT_ALWAYS_PREC 145 (g, "0.11111 11111 11111 11111 11111 11111 11111 111 ", medium_prec);145 (g, "0.11111 11111 11111 11111 11111 11111 11111 1111", medium_prec); 146 146 } 147 147 { 148 148 mpf_class f(15.0, large_prec); … … 150 150 g = mpf_class(1 / f); 151 151 ASSERT_ALWAYS_PREC 152 152 (g, "0.06666 66666 66666 66666 66666 66666 66666 66666 66666 66666" 153 " 66666 66 7", large_prec);153 " 66666 6667", large_prec); 154 154 } 155 155 156 156 { … … 158 158 mpf_class h(0.0, very_large_prec); 159 159 h = mpf_class(f / g + 1, large_prec); 160 160 ASSERT_ALWAYS_PREC 161 (h, "1.33333 33333 33333 33333 33333 33333 33333 33333 33333 3333", 161 (h, "1.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" 162 " 33333 333", 162 163 large_prec); 163 164 } 164 165 … … 170 171 g = f - q; 171 172 ASSERT_ALWAYS_PREC 172 173 (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666" 173 " 66666 66666 66666 66 7", very_large_prec);174 " 66666 66666 66666 66666 66666 67", very_large_prec); 174 175 } 175 176 176 177 { … … 179 180 mpf_class g(0.0, very_large_prec); 180 181 g = mpf_class(f - q, large_prec); 181 182 ASSERT_ALWAYS_PREC 182 (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 6667", 183 (g, "2.66666 66666 66666 66666 66666 66666 66666 66666 66666 66666" 184 " 66666 667", 183 185 large_prec); 184 186 } 185 187 { … … 188 190 mpf_class g(0.0, very_large_prec); 189 191 g = mpf_class(f - q); 190 192 ASSERT_ALWAYS_PREC 191 (g, "2.66666 66666 66666 66666 66666 666 7", medium_prec);193 (g, "2.66666 66666 66666 66666 66666 66666 66666 667", medium_prec); 192 194 } 193 195 { 194 196 mpf_class f(15.0, large_prec); … … 196 198 mpf_class g(0.0, very_large_prec); 197 199 g = mpf_class(f + q); 198 200 ASSERT_ALWAYS_PREC 199 (g, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 3333", 201 (g, "15.33333 33333 33333 33333 33333 33333 33333 33333 33333 33333" 202 " 33333 33", 200 203 large_prec); 201 204 } 202 205 }
Note:
See TracBrowser
for help on using the repository browser.