YoushouldhavereceivedcopiesoftheGNUGeneralPublicLicenseandthe GNULesserGeneralPublicLicensealongwiththeGNUMPLibrary.Ifnot,
see https://www.gnu.org/licenses/. */
#include <stdio.h> #include"gmp-impl.h"
/* change this to "#define TRACE(x) x" for diagnostics */ #define TRACE(x)
/* Store F[n] at fp and F[n-1] at f1p. fp and f1p should have room for MPN_FIB2_SIZE(n)limbs.
/* fp normalized, f1p at most one high zero */
ASSERT (fp[size-1] != 0);
ASSERT (f1p[size-1] != 0 || f1p[size-2] != 0);
/* f1p[size-1] might be zero, but this occurs rarely, so it's not
worth bothering checking for it */
ASSERT (alloc >= 2*size);
mpn_sqr (xp, fp, size);
mpn_sqr (fp, f1p, size);
size *= 2;
/* Shrink if possible. Since fp was normalized there'll be at mostonehighzeroonxp(andifthereisthenthere'soneon
yp too). */
ASSERT (xp[size-1] != 0 || fp[size-1] == 0);
size -= (xp[size-1] == 0);
ASSERT (xp[size-1] != 0); /* only one xp high zero */
/* now n&mask is the new bit of n being considered */
mask >>= 1;
/* Calculate F[2k] = F[2k+1] - F[2k-1], replacing the unwanted one of
F[2k+1] and F[2k-1]. */ if (n & mask)
ASSERT_NOCARRY (mpn_sub_n (f1p, fp, f1p, size)); else {
ASSERT_NOCARRY (mpn_sub_n ( fp, fp, f1p, size));
/* Can have a high zero after replacing F[2k+1] with F[2k].
f1p will have a high zero if fp does. */
ASSERT (fp[size-1] != 0 || f1p[size-1] == 0);
size -= (fp[size-1] == 0);
}
} while (mask != 1);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.