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)
Forthe-2inL[2k]withkeven,itseems(noproof)L[2^(b-1)]==-1mod 2^b,soforinstancein32-bitsL[0x80000000]hasalowlimbof 0xFFFFFFFFsotherewouldhavebeenaborrow.AgainL[0x80000000]is
obviously huge, but probably should be made to work. */
/* +1 since L[n]=F[n]+2F[n-1] might be 1 limb bigger than F[n], further +1 sincesquareormulusedbelowmightneedanextralimboverthetrue
size */
lalloc = MPN_FIB2_SIZE (n) + 2;
lp = MPZ_NEWALLOC (ln, lalloc);
TMP_MARK;
xalloc = lalloc;
xp = TMP_ALLOC_LIMBS (xalloc);
/* Strip trailing zeros from n, until either an odd number is reached wheretheL[2k+1]formulacanbeused,oruntilnfitswithinthe
FIB_TABLE data. The table is preferred of course. */
zeros = 0; for (;;)
{ if (n & 1)
{ /* L[2k+1] = 5*F[k-1]*(2*F[k]+F[k-1]) - 4*(-1)^k */
/* First time around the loop k==n determines (-1)^k, after that k is
always even and we set n=0 to indicate that. */ if (n & 1)
{ /* L[n]^2 == 0 or 1 mod 4, like all squares, so +2 gives no carry */
ASSERT (xp[0] <= MP_LIMB_T_MAX-2);
xp[0] += 2;
n = 0;
} else
{ /* won't go negative */
MPN_DECR_U (xp, lsize, CNST_LIMB(2));
}
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.