Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Unified Diff: gcc/gmp/mpf/sqrt.c

Issue 3050029: [gcc] GCC 4.5.0=>4.5.1 (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/nacl-toolchain.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « gcc/gmp/mpf/set_z.c ('k') | gcc/gmp/mpf/sqrt_ui.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gcc/gmp/mpf/sqrt.c
diff --git a/gcc/gmp/mpf/sqrt.c b/gcc/gmp/mpf/sqrt.c
deleted file mode 100644
index 19a7ca08b0b4ade446091d507ee43922b8c18a5f..0000000000000000000000000000000000000000
--- a/gcc/gmp/mpf/sqrt.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/* mpf_sqrt -- Compute the square root of a float.
-
-Copyright 1993, 1994, 1996, 2000, 2001, 2004, 2005 Free Software Foundation,
-Inc.
-
-This file is part of the GNU MP Library.
-
-The GNU MP Library is free software; you can redistribute it and/or modify
-it under the terms of the GNU Lesser General Public License as published by
-the Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-The GNU MP Library is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-License for more details.
-
-You should have received a copy of the GNU Lesser General Public License
-along with the GNU MP Library. If not, see http://www.gnu.org/licenses/. */
-
-#include <stdio.h> /* for NULL */
-#include "gmp.h"
-#include "gmp-impl.h"
-
-
-/* As usual, the aim is to produce PREC(r) limbs of result, with the high
- limb non-zero. This is accomplished by applying mpn_sqrtrem to either
- 2*prec or 2*prec-1 limbs, both such sizes resulting in prec limbs.
-
- The choice between 2*prec or 2*prec-1 limbs is based on the input
- exponent. With b=2^GMP_NUMB_BITS the limb base then we can think of
- effectively taking out a factor b^(2k), for suitable k, to get to an
- integer input of the desired size ready for mpn_sqrtrem. It must be an
- even power taken out, ie. an even number of limbs, so the square root
- gives factor b^k and the radix point is still on a limb boundary. So if
- EXP(r) is even we'll get an even number of input limbs 2*prec, or if
- EXP(r) is odd we get an odd number 2*prec-1.
-
- Further limbs below the 2*prec or 2*prec-1 used don't affect the result
- and are simply truncated. This can be seen by considering an integer x,
- with s=floor(sqrt(x)). s is the unique integer satisfying s^2 <= x <
- (s+1)^2. Notice that adding a fraction part to x (ie. some further bits)
- doesn't change the inequality, s remains the unique solution. Working
- suitable factors of 2 into this argument lets it apply to an intended
- precision at any position for any x, not just the integer binary point.
-
- If the input is smaller than 2*prec or 2*prec-1, then we just pad with
- zeros, that of course being our usual interpretation of short inputs.
- The effect is to extend the root beyond the size of the input (for
- instance into fractional limbs if u is an integer). */
-
-void
-mpf_sqrt (mpf_ptr r, mpf_srcptr u)
-{
- mp_size_t usize;
- mp_ptr up, tp;
- mp_size_t prec, tsize;
- mp_exp_t uexp, expodd;
- TMP_DECL;
-
- usize = u->_mp_size;
- if (usize <= 0)
- {
- if (usize < 0)
- SQRT_OF_NEGATIVE;
- r->_mp_size = 0;
- r->_mp_exp = 0;
- return;
- }
-
- TMP_MARK;
-
- uexp = u->_mp_exp;
- prec = r->_mp_prec;
- up = u->_mp_d;
-
- expodd = (uexp & 1);
- tsize = 2 * prec - expodd;
- r->_mp_size = prec;
- r->_mp_exp = (uexp + expodd) / 2; /* ceil(uexp/2) */
-
- /* root size is ceil(tsize/2), this will be our desired "prec" limbs */
- ASSERT ((tsize + 1) / 2 == prec);
-
- tp = (mp_ptr) TMP_ALLOC (tsize * BYTES_PER_MP_LIMB);
-
- if (usize > tsize)
- {
- up += usize - tsize;
- usize = tsize;
- MPN_COPY (tp, up, tsize);
- }
- else
- {
- MPN_ZERO (tp, tsize - usize);
- MPN_COPY (tp + (tsize - usize), up, usize);
- }
-
- mpn_sqrtrem (r->_mp_d, NULL, tp, tsize);
-
- TMP_FREE;
-}
« no previous file with comments | « gcc/gmp/mpf/set_z.c ('k') | gcc/gmp/mpf/sqrt_ui.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698