YoushouldhavereceivedcopiesoftheGNUGeneralPublicLicenseandthe GNULesserGeneralPublicLicensealongwiththeGNUMPLibrary.Ifnot,
see https://www.gnu.org/licenses/. */
#include <stdlib.h> /* for NULL */
#include"gmp-impl.h" #include"longlong.h"
/* Used when mpn_hgcd or mpn_hgcd2 has failed. Then either one of a or bissmall,orthedifferenceissmall.Performonesubtraction followedbyonedivision.Thenormalcaseistocomputethereduced aandb,andreturnthenewsize.
/* Arrange so that a < b, subtract b -= a, and maintain
normalization. */ if (an == bn)
{ int c;
MPN_CMP (c, ap, bp, an); if (UNLIKELY (c == 0))
{ /* For gcdext, return the smallest of the two cofactors, so
pass d = -1. */ if (s == 0)
hook (ctx, ap, an, NULL, 0, -1); return0;
} elseif (c > 0)
{
MP_PTR_SWAP (ap, bp);
swapped ^= 1;
}
} else
{ if (an > bn)
{
MPN_PTR_SWAP (ap, an, bp, bn);
swapped ^= 1;
}
} if (an <= s)
{ if (s == 0)
hook (ctx, bp, bn, NULL, 0, swapped ^ 1); return0;
}
if (bn <= s)
{ /* Undo subtraction. */
mp_limb_t cy = mpn_add (bp, ap, an, bp, bn); if (cy > 0)
bp[an] = cy; return0;
}
/* Arrange so that a < b */ if (an == bn)
{ int c;
MPN_CMP (c, ap, bp, an); if (UNLIKELY (c == 0))
{ if (s > 0) /* Just record subtraction and return */
hook (ctx, NULL, 0, &one, 1, swapped); else /* Found gcd. */
hook (ctx, bp, bn, NULL, 0, swapped); return0;
}
if (UNLIKELY (bn <= s))
{ if (s == 0)
{
hook (ctx, ap, an, tp, qn, swapped); return0;
}
/* Quotient is one too large, so decrement it and add back A. */ if (bn > 0)
{
mp_limb_t cy = mpn_add (bp, ap, an, bp, bn); if (cy)
bp[an++] = cy;
} else
MPN_COPY (bp, ap, an);
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.