diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-10 16:43:17 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2020-03-10 16:43:17 +0000 |
commit | 316737fac3d09c6b6b657732611ce91d937ef4b8 (patch) | |
tree | cb11340d9edd5764f5954b5543defbbfa794fbe4 | |
parent | e963cc46d37e6da15580dbf1fa4a784109e58376 (diff) | |
download | mpfr-316737fac3d09c6b6b657732611ce91d937ef4b8.tar.gz |
[src/cbrt.c] Description of the algorithm: corrected indentation;
renamed variable r to t in order to avoid confusion with the code
(where r has a different meaning).
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@13769 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r-- | src/cbrt.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/cbrt.c b/src/cbrt.c index f327a2dea..58a35681a 100644 --- a/src/cbrt.c +++ b/src/cbrt.c @@ -23,26 +23,26 @@ https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., #define MPFR_NEED_LONGLONG_H #include "mpfr-impl.h" - /* The computation of y = x^(1/3) is done as follows: +/* The computation of y = x^(1/3) is done as follows: - Let x = sign * m * 2^(3*e) where m is an integer >= 2^(3n-3) with - n = PREC(y), i.e. m has at least 3n-2 bits. + Let x = sign * m * 2^(3*e) where m is an integer >= 2^(3n-3) with + n = PREC(y), i.e. m has at least 3n-2 bits. - Let s be the integer cube root of m, i.e. the maximum integer such that - m = s^3 + r with r >= 0. + Let s be the integer cube root of m, i.e. the maximum integer such that + m = s^3 + t with t >= 0. - The constraint m >= 2^(3n-3) allows one to have sufficient precision - for s: s >= 2^(n-1), i.e. s has at least n bits. + The constraint m >= 2^(3n-3) allows one to have sufficient precision + for s: s >= 2^(n-1), i.e. s has at least n bits. - FIXME: The description below is incorrect if s has more than n bits - (since n is the target precision). + FIXME: The description below is incorrect if s has more than n bits + (since n is the target precision). - Then x^(1/3) = s * 2^e if r=0 - x^(1/3) = (s+1) * 2^e if round up - x^(1/3) = (s-1) * 2^e if round down - x^(1/3) = s * 2^e if nearest and r < 3/2*s^2+3/4*s+1/8 - (s+1) * 2^e otherwise - */ + Then x^(1/3) = s * 2^e if t = 0 + x^(1/3) = (s+1) * 2^e if round up + x^(1/3) = (s-1) * 2^e if round down + x^(1/3) = s * 2^e if nearest and t < 3/2*s^2+3/4*s+1/8 + (s+1) * 2^e otherwise +*/ int mpfr_cbrt (mpfr_ptr y, mpfr_srcptr x, mpfr_rnd_t rnd_mode) |