gmp.info-2 209 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920
  1. This is gmp.info, produced by makeinfo version 6.1 from gmp.texi.
  2. This manual describes how to install and use the GNU multiple precision
  3. arithmetic library, version 6.1.2.
  4. Copyright 1991, 1993-2016 Free Software Foundation, Inc.
  5. Permission is granted to copy, distribute and/or modify this document
  6. under the terms of the GNU Free Documentation License, Version 1.3 or
  7. any later version published by the Free Software Foundation; with no
  8. Invariant Sections, with the Front-Cover Texts being "A GNU Manual", and
  9. with the Back-Cover Texts being "You have freedom to copy and modify
  10. this GNU Manual, like GNU software". A copy of the license is included
  11. in *note GNU Free Documentation License::.
  12. INFO-DIR-SECTION GNU libraries
  13. START-INFO-DIR-ENTRY
  14. * gmp: (gmp). GNU Multiple Precision Arithmetic Library.
  15. END-INFO-DIR-ENTRY
  16. 
  17. File: gmp.info, Node: Exact Remainder, Next: Small Quotient Division, Prev: Exact Division, Up: Division Algorithms
  18. 15.2.6 Exact Remainder
  19. ----------------------
  20. If the exact division algorithm is done with a full subtraction at each
  21. stage and the dividend isn't a multiple of the divisor, then low zero
  22. limbs are produced but with a remainder in the high limbs. For dividend
  23. a, divisor d, quotient q, and b = 2^mp_bits_per_limb, this remainder r
  24. is of the form
  25. a = q*d + r*b^n
  26. n represents the number of zero limbs produced by the subtractions,
  27. that being the number of limbs produced for q. r will be in the range
  28. 0<=r<d and can be viewed as a remainder, but one shifted up by a factor
  29. of b^n.
  30. Carrying out full subtractions at each stage means the same number of
  31. cross products must be done as a normal division, but there's still some
  32. single limb divisions saved. When d is a single limb some
  33. simplifications arise, providing good speedups on a number of
  34. processors.
  35. The functions 'mpn_divexact_by3', 'mpn_modexact_1_odd' and the
  36. internal 'mpn_redc_X' functions differ subtly in how they return r,
  37. leading to some negations in the above formula, but all are essentially
  38. the same.
  39. Clearly r is zero when a is a multiple of d, and this leads to
  40. divisibility or congruence tests which are potentially more efficient
  41. than a normal division.
  42. The factor of b^n on r can be ignored in a GCD when d is odd, hence
  43. the use of 'mpn_modexact_1_odd' by 'mpn_gcd_1' and 'mpz_kronecker_ui'
  44. etc (*note Greatest Common Divisor Algorithms::).
  45. Montgomery's REDC method for modular multiplications uses operands of
  46. the form of x*b^-n and y*b^-n and on calculating (x*b^-n)*(y*b^-n) uses
  47. the factor of b^n in the exact remainder to reach a product in the same
  48. form (x*y)*b^-n (*note Modular Powering Algorithm::).
  49. Notice that r generally gives no useful information about the
  50. ordinary remainder a mod d since b^n mod d could be anything. If
  51. however b^n == 1 mod d, then r is the negative of the ordinary
  52. remainder. This occurs whenever d is a factor of b^n-1, as for example
  53. with 3 in 'mpn_divexact_by3'. For a 32 or 64 bit limb other such
  54. factors include 5, 17 and 257, but no particular use has been found for
  55. this.
  56. 
  57. File: gmp.info, Node: Small Quotient Division, Prev: Exact Remainder, Up: Division Algorithms
  58. 15.2.7 Small Quotient Division
  59. ------------------------------
  60. An NxM division where the number of quotient limbs Q=N-M is small can be
  61. optimized somewhat.
  62. An ordinary basecase division normalizes the divisor by shifting it
  63. to make the high bit set, shifting the dividend accordingly, and
  64. shifting the remainder back down at the end of the calculation. This is
  65. wasteful if only a few quotient limbs are to be formed. Instead a
  66. division of just the top 2*Q limbs of the dividend by the top Q limbs of
  67. the divisor can be used to form a trial quotient. This requires only
  68. those limbs normalized, not the whole of the divisor and dividend.
  69. A multiply and subtract then applies the trial quotient to the M-Q
  70. unused limbs of the divisor and N-Q dividend limbs (which includes Q
  71. limbs remaining from the trial quotient division). The starting trial
  72. quotient can be 1 or 2 too big, but all cases of 2 too big and most
  73. cases of 1 too big are detected by first comparing the most significant
  74. limbs that will arise from the subtraction. An addback is done if the
  75. quotient still turns out to be 1 too big.
  76. This whole procedure is essentially the same as one step of the
  77. basecase algorithm done in a Q limb base, though with the trial quotient
  78. test done only with the high limbs, not an entire Q limb "digit"
  79. product. The correctness of this weaker test can be established by
  80. following the argument of Knuth section 4.3.1 exercise 20 but with the
  81. v2*q>b*r+u2 condition appropriately relaxed.
  82. 
  83. File: gmp.info, Node: Greatest Common Divisor Algorithms, Next: Powering Algorithms, Prev: Division Algorithms, Up: Algorithms
  84. 15.3 Greatest Common Divisor
  85. ============================
  86. * Menu:
  87. * Binary GCD::
  88. * Lehmer's Algorithm::
  89. * Subquadratic GCD::
  90. * Extended GCD::
  91. * Jacobi Symbol::
  92. 
  93. File: gmp.info, Node: Binary GCD, Next: Lehmer's Algorithm, Prev: Greatest Common Divisor Algorithms, Up: Greatest Common Divisor Algorithms
  94. 15.3.1 Binary GCD
  95. -----------------
  96. At small sizes GMP uses an O(N^2) binary style GCD. This is described
  97. in many textbooks, for example Knuth section 4.5.2 algorithm B. It
  98. simply consists of successively reducing odd operands a and b using
  99. a,b = abs(a-b),min(a,b)
  100. strip factors of 2 from a
  101. The Euclidean GCD algorithm, as per Knuth algorithms E and A,
  102. repeatedly computes the quotient q = floor(a/b) and replaces a,b by v, u
  103. - q v. The binary algorithm has so far been found to be faster than the
  104. Euclidean algorithm everywhere. One reason the binary method does well
  105. is that the implied quotient at each step is usually small, so often
  106. only one or two subtractions are needed to get the same effect as a
  107. division. Quotients 1, 2 and 3 for example occur 67.7% of the time, see
  108. Knuth section 4.5.3 Theorem E.
  109. When the implied quotient is large, meaning b is much smaller than a,
  110. then a division is worthwhile. This is the basis for the initial a mod
  111. b reductions in 'mpn_gcd' and 'mpn_gcd_1' (the latter for both Nx1 and
  112. 1x1 cases). But after that initial reduction, big quotients occur too
  113. rarely to make it worth checking for them.
  114. The final 1x1 GCD in 'mpn_gcd_1' is done in the generic C code as
  115. described above. For two N-bit operands, the algorithm takes about 0.68
  116. iterations per bit. For optimum performance some attention needs to be
  117. paid to the way the factors of 2 are stripped from a.
  118. Firstly it may be noted that in twos complement the number of low
  119. zero bits on a-b is the same as b-a, so counting or testing can begin on
  120. a-b without waiting for abs(a-b) to be determined.
  121. A loop stripping low zero bits tends not to branch predict well,
  122. since the condition is data dependent. But on average there's only a
  123. few low zeros, so an option is to strip one or two bits arithmetically
  124. then loop for more (as done for AMD K6). Or use a lookup table to get a
  125. count for several bits then loop for more (as done for AMD K7). An
  126. alternative approach is to keep just one of a or b odd and iterate
  127. a,b = abs(a-b), min(a,b)
  128. a = a/2 if even
  129. b = b/2 if even
  130. This requires about 1.25 iterations per bit, but stripping of a
  131. single bit at each step avoids any branching. Repeating the bit strip
  132. reduces to about 0.9 iterations per bit, which may be a worthwhile
  133. tradeoff.
  134. Generally with the above approaches a speed of perhaps 6 cycles per
  135. bit can be achieved, which is still not terribly fast with for instance
  136. a 64-bit GCD taking nearly 400 cycles. It's this sort of time which
  137. means it's not usually advantageous to combine a set of divisibility
  138. tests into a GCD.
  139. Currently, the binary algorithm is used for GCD only when N < 3.
  140. 
  141. File: gmp.info, Node: Lehmer's Algorithm, Next: Subquadratic GCD, Prev: Binary GCD, Up: Greatest Common Divisor Algorithms
  142. 15.3.2 Lehmer's algorithm
  143. -------------------------
  144. Lehmer's improvement of the Euclidean algorithms is based on the
  145. observation that the initial part of the quotient sequence depends only
  146. on the most significant parts of the inputs. The variant of Lehmer's
  147. algorithm used in GMP splits off the most significant two limbs, as
  148. suggested, e.g., in "A Double-Digit Lehmer-Euclid Algorithm" by Jebelean
  149. (*note References::). The quotients of two double-limb inputs are
  150. collected as a 2 by 2 matrix with single-limb elements. This is done by
  151. the function 'mpn_hgcd2'. The resulting matrix is applied to the inputs
  152. using 'mpn_mul_1' and 'mpn_submul_1'. Each iteration usually reduces
  153. the inputs by almost one limb. In the rare case of a large quotient, no
  154. progress can be made by examining just the most significant two limbs,
  155. and the quotient is computed using plain division.
  156. The resulting algorithm is asymptotically O(N^2), just as the
  157. Euclidean algorithm and the binary algorithm. The quadratic part of the
  158. work are the calls to 'mpn_mul_1' and 'mpn_submul_1'. For small sizes,
  159. the linear work is also significant. There are roughly N calls to the
  160. 'mpn_hgcd2' function. This function uses a couple of important
  161. optimizations:
  162. * It uses the same relaxed notion of correctness as 'mpn_hgcd' (see
  163. next section). This means that when called with the most
  164. significant two limbs of two large numbers, the returned matrix
  165. does not always correspond exactly to the initial quotient sequence
  166. for the two large numbers; the final quotient may sometimes be one
  167. off.
  168. * It takes advantage of the fact the quotients are usually small.
  169. The division operator is not used, since the corresponding
  170. assembler instruction is very slow on most architectures. (This
  171. code could probably be improved further, it uses many branches that
  172. are unfriendly to prediction).
  173. * It switches from double-limb calculations to single-limb
  174. calculations half-way through, when the input numbers have been
  175. reduced in size from two limbs to one and a half.
  176. 
  177. File: gmp.info, Node: Subquadratic GCD, Next: Extended GCD, Prev: Lehmer's Algorithm, Up: Greatest Common Divisor Algorithms
  178. 15.3.3 Subquadratic GCD
  179. -----------------------
  180. For inputs larger than 'GCD_DC_THRESHOLD', GCD is computed via the HGCD
  181. (Half GCD) function, as a generalization to Lehmer's algorithm.
  182. Let the inputs a,b be of size N limbs each. Put S = floor(N/2) + 1.
  183. Then HGCD(a,b) returns a transformation matrix T with non-negative
  184. elements, and reduced numbers (c;d) = T^{-1} (a;b). The reduced numbers
  185. c,d must be larger than S limbs, while their difference abs(c-d) must
  186. fit in S limbs. The matrix elements will also be of size roughly N/2.
  187. The HGCD base case uses Lehmer's algorithm, but with the above stop
  188. condition that returns reduced numbers and the corresponding
  189. transformation matrix half-way through. For inputs larger than
  190. 'HGCD_THRESHOLD', HGCD is computed recursively, using the divide and
  191. conquer algorithm in "On Schönhage's algorithm and subquadratic integer
  192. GCD computation" by Möller (*note References::). The recursive
  193. algorithm consists of these main steps.
  194. * Call HGCD recursively, on the most significant N/2 limbs. Apply
  195. the resulting matrix T_1 to the full numbers, reducing them to a
  196. size just above 3N/2.
  197. * Perform a small number of division or subtraction steps to reduce
  198. the numbers to size below 3N/2. This is essential mainly for the
  199. unlikely case of large quotients.
  200. * Call HGCD recursively, on the most significant N/2 limbs of the
  201. reduced numbers. Apply the resulting matrix T_2 to the full
  202. numbers, reducing them to a size just above N/2.
  203. * Compute T = T_1 T_2.
  204. * Perform a small number of division and subtraction steps to satisfy
  205. the requirements, and return.
  206. GCD is then implemented as a loop around HGCD, similarly to Lehmer's
  207. algorithm. Where Lehmer repeatedly chops off the top two limbs, calls
  208. 'mpn_hgcd2', and applies the resulting matrix to the full numbers, the
  209. sub-quadratic GCD chops off the most significant third of the limbs (the
  210. proportion is a tuning parameter, and 1/3 seems to be more efficient
  211. than, e.g, 1/2), calls 'mpn_hgcd', and applies the resulting matrix.
  212. Once the input numbers are reduced to size below 'GCD_DC_THRESHOLD',
  213. Lehmer's algorithm is used for the rest of the work.
  214. The asymptotic running time of both HGCD and GCD is O(M(N)*log(N)),
  215. where M(N) is the time for multiplying two N-limb numbers.
  216. 
  217. File: gmp.info, Node: Extended GCD, Next: Jacobi Symbol, Prev: Subquadratic GCD, Up: Greatest Common Divisor Algorithms
  218. 15.3.4 Extended GCD
  219. -------------------
  220. The extended GCD function, or GCDEXT, calculates gcd(a,b) and also
  221. cofactors x and y satisfying a*x+b*y=gcd(a,b). All the algorithms used
  222. for plain GCD are extended to handle this case. The binary algorithm is
  223. used only for single-limb GCDEXT. Lehmer's algorithm is used for sizes
  224. up to 'GCDEXT_DC_THRESHOLD'. Above this threshold, GCDEXT is
  225. implemented as a loop around HGCD, but with more book-keeping to keep
  226. track of the cofactors. This gives the same asymptotic running time as
  227. for GCD and HGCD, O(M(N)*log(N))
  228. One difference to plain GCD is that while the inputs a and b are
  229. reduced as the algorithm proceeds, the cofactors x and y grow in size.
  230. This makes the tuning of the chopping-point more difficult. The current
  231. code chops off the most significant half of the inputs for the call to
  232. HGCD in the first iteration, and the most significant two thirds for the
  233. remaining calls. This strategy could surely be improved. Also the stop
  234. condition for the loop, where Lehmer's algorithm is invoked once the
  235. inputs are reduced below 'GCDEXT_DC_THRESHOLD', could maybe be improved
  236. by taking into account the current size of the cofactors.
  237. 
  238. File: gmp.info, Node: Jacobi Symbol, Prev: Extended GCD, Up: Greatest Common Divisor Algorithms
  239. 15.3.5 Jacobi Symbol
  240. --------------------
  241. [This section is obsolete. The current Jacobi code actually uses a very
  242. efficient algorithm.]
  243. 'mpz_jacobi' and 'mpz_kronecker' are currently implemented with a
  244. simple binary algorithm similar to that described for the GCDs (*note
  245. Binary GCD::). They're not very fast when both inputs are large.
  246. Lehmer's multi-step improvement or a binary based multi-step algorithm
  247. is likely to be better.
  248. When one operand fits a single limb, and that includes
  249. 'mpz_kronecker_ui' and friends, an initial reduction is done with either
  250. 'mpn_mod_1' or 'mpn_modexact_1_odd', followed by the binary algorithm on
  251. a single limb. The binary algorithm is well suited to a single limb,
  252. and the whole calculation in this case is quite efficient.
  253. In all the routines sign changes for the result are accumulated using
  254. some bit twiddling, avoiding table lookups or conditional jumps.
  255. 
  256. File: gmp.info, Node: Powering Algorithms, Next: Root Extraction Algorithms, Prev: Greatest Common Divisor Algorithms, Up: Algorithms
  257. 15.4 Powering Algorithms
  258. ========================
  259. * Menu:
  260. * Normal Powering Algorithm::
  261. * Modular Powering Algorithm::
  262. 
  263. File: gmp.info, Node: Normal Powering Algorithm, Next: Modular Powering Algorithm, Prev: Powering Algorithms, Up: Powering Algorithms
  264. 15.4.1 Normal Powering
  265. ----------------------
  266. Normal 'mpz' or 'mpf' powering uses a simple binary algorithm,
  267. successively squaring and then multiplying by the base when a 1 bit is
  268. seen in the exponent, as per Knuth section 4.6.3. The "left to right"
  269. variant described there is used rather than algorithm A, since it's just
  270. as easy and can be done with somewhat less temporary memory.
  271. 
  272. File: gmp.info, Node: Modular Powering Algorithm, Prev: Normal Powering Algorithm, Up: Powering Algorithms
  273. 15.4.2 Modular Powering
  274. -----------------------
  275. Modular powering is implemented using a 2^k-ary sliding window
  276. algorithm, as per "Handbook of Applied Cryptography" algorithm 14.85
  277. (*note References::). k is chosen according to the size of the
  278. exponent. Larger exponents use larger values of k, the choice being
  279. made to minimize the average number of multiplications that must
  280. supplement the squaring.
  281. The modular multiplies and squarings use either a simple division or
  282. the REDC method by Montgomery (*note References::). REDC is a little
  283. faster, essentially saving N single limb divisions in a fashion similar
  284. to an exact remainder (*note Exact Remainder::).
  285. 
  286. File: gmp.info, Node: Root Extraction Algorithms, Next: Radix Conversion Algorithms, Prev: Powering Algorithms, Up: Algorithms
  287. 15.5 Root Extraction Algorithms
  288. ===============================
  289. * Menu:
  290. * Square Root Algorithm::
  291. * Nth Root Algorithm::
  292. * Perfect Square Algorithm::
  293. * Perfect Power Algorithm::
  294. 
  295. File: gmp.info, Node: Square Root Algorithm, Next: Nth Root Algorithm, Prev: Root Extraction Algorithms, Up: Root Extraction Algorithms
  296. 15.5.1 Square Root
  297. ------------------
  298. Square roots are taken using the "Karatsuba Square Root" algorithm by
  299. Paul Zimmermann (*note References::).
  300. An input n is split into four parts of k bits each, so with b=2^k we
  301. have n = a3*b^3 + a2*b^2 + a1*b + a0. Part a3 must be "normalized" so
  302. that either the high or second highest bit is set. In GMP, k is kept on
  303. a limb boundary and the input is left shifted (by an even number of
  304. bits) to normalize.
  305. The square root of the high two parts is taken, by recursive
  306. application of the algorithm (bottoming out in a one-limb Newton's
  307. method),
  308. s1,r1 = sqrtrem (a3*b + a2)
  309. This is an approximation to the desired root and is extended by a
  310. division to give s,r,
  311. q,u = divrem (r1*b + a1, 2*s1)
  312. s = s1*b + q
  313. r = u*b + a0 - q^2
  314. The normalization requirement on a3 means at this point s is either
  315. correct or 1 too big. r is negative in the latter case, so
  316. if r < 0 then
  317. r = r + 2*s - 1
  318. s = s - 1
  319. The algorithm is expressed in a divide and conquer form, but as noted
  320. in the paper it can also be viewed as a discrete variant of Newton's
  321. method, or as a variation on the schoolboy method (no longer taught) for
  322. square roots two digits at a time.
  323. If the remainder r is not required then usually only a few high limbs
  324. of r and u need to be calculated to determine whether an adjustment to s
  325. is required. This optimization is not currently implemented.
  326. In the Karatsuba multiplication range this algorithm is
  327. O(1.5*M(N/2)), where M(n) is the time to multiply two numbers of n
  328. limbs. In the FFT multiplication range this grows to a bound of
  329. O(6*M(N/2)). In practice a factor of about 1.5 to 1.8 is found in the
  330. Karatsuba and Toom-3 ranges, growing to 2 or 3 in the FFT range.
  331. The algorithm does all its calculations in integers and the resulting
  332. 'mpn_sqrtrem' is used for both 'mpz_sqrt' and 'mpf_sqrt'. The extended
  333. precision given by 'mpf_sqrt_ui' is obtained by padding with zero limbs.
  334. 
  335. File: gmp.info, Node: Nth Root Algorithm, Next: Perfect Square Algorithm, Prev: Square Root Algorithm, Up: Root Extraction Algorithms
  336. 15.5.2 Nth Root
  337. ---------------
  338. Integer Nth roots are taken using Newton's method with the following
  339. iteration, where A is the input and n is the root to be taken.
  340. 1 A
  341. a[i+1] = - * ( --------- + (n-1)*a[i] )
  342. n a[i]^(n-1)
  343. The initial approximation a[1] is generated bitwise by successively
  344. powering a trial root with or without new 1 bits, aiming to be just
  345. above the true root. The iteration converges quadratically when started
  346. from a good approximation. When n is large more initial bits are needed
  347. to get good convergence. The current implementation is not particularly
  348. well optimized.
  349. 
  350. File: gmp.info, Node: Perfect Square Algorithm, Next: Perfect Power Algorithm, Prev: Nth Root Algorithm, Up: Root Extraction Algorithms
  351. 15.5.3 Perfect Square
  352. ---------------------
  353. A significant fraction of non-squares can be quickly identified by
  354. checking whether the input is a quadratic residue modulo small integers.
  355. 'mpz_perfect_square_p' first tests the input mod 256, which means
  356. just examining the low byte. Only 44 different values occur for squares
  357. mod 256, so 82.8% of inputs can be immediately identified as
  358. non-squares.
  359. On a 32-bit system similar tests are done mod 9, 5, 7, 13 and 17, for
  360. a total 99.25% of inputs identified as non-squares. On a 64-bit system
  361. 97 is tested too, for a total 99.62%.
  362. These moduli are chosen because they're factors of 2^24-1 (or 2^48-1
  363. for 64-bits), and such a remainder can be quickly taken just using
  364. additions (see 'mpn_mod_34lsub1').
  365. When nails are in use moduli are instead selected by the 'gen-psqr.c'
  366. program and applied with an 'mpn_mod_1'. The same 2^24-1 or 2^48-1
  367. could be done with nails using some extra bit shifts, but this is not
  368. currently implemented.
  369. In any case each modulus is applied to the 'mpn_mod_34lsub1' or
  370. 'mpn_mod_1' remainder and a table lookup identifies non-squares. By
  371. using a "modexact" style calculation, and suitably permuted tables, just
  372. one multiply each is required, see the code for details. Moduli are
  373. also combined to save operations, so long as the lookup tables don't
  374. become too big. 'gen-psqr.c' does all the pre-calculations.
  375. A square root must still be taken for any value that passes these
  376. tests, to verify it's really a square and not one of the small fraction
  377. of non-squares that get through (i.e. a pseudo-square to all the tested
  378. bases).
  379. Clearly more residue tests could be done, 'mpz_perfect_square_p' only
  380. uses a compact and efficient set. Big inputs would probably benefit
  381. from more residue testing, small inputs might be better off with less.
  382. The assumed distribution of squares versus non-squares in the input
  383. would affect such considerations.
  384. 
  385. File: gmp.info, Node: Perfect Power Algorithm, Prev: Perfect Square Algorithm, Up: Root Extraction Algorithms
  386. 15.5.4 Perfect Power
  387. --------------------
  388. Detecting perfect powers is required by some factorization algorithms.
  389. Currently 'mpz_perfect_power_p' is implemented using repeated Nth root
  390. extractions, though naturally only prime roots need to be considered.
  391. (*Note Nth Root Algorithm::.)
  392. If a prime divisor p with multiplicity e can be found, then only
  393. roots which are divisors of e need to be considered, much reducing the
  394. work necessary. To this end divisibility by a set of small primes is
  395. checked.
  396. 
  397. File: gmp.info, Node: Radix Conversion Algorithms, Next: Other Algorithms, Prev: Root Extraction Algorithms, Up: Algorithms
  398. 15.6 Radix Conversion
  399. =====================
  400. Radix conversions are less important than other algorithms. A program
  401. dominated by conversions should probably use a different data
  402. representation.
  403. * Menu:
  404. * Binary to Radix::
  405. * Radix to Binary::
  406. 
  407. File: gmp.info, Node: Binary to Radix, Next: Radix to Binary, Prev: Radix Conversion Algorithms, Up: Radix Conversion Algorithms
  408. 15.6.1 Binary to Radix
  409. ----------------------
  410. Conversions from binary to a power-of-2 radix use a simple and fast O(N)
  411. bit extraction algorithm.
  412. Conversions from binary to other radices use one of two algorithms.
  413. Sizes below 'GET_STR_PRECOMPUTE_THRESHOLD' use a basic O(N^2) method.
  414. Repeated divisions by b^n are made, where b is the radix and n is the
  415. biggest power that fits in a limb. But instead of simply using the
  416. remainder r from such divisions, an extra divide step is done to give a
  417. fractional limb representing r/b^n. The digits of r can then be
  418. extracted using multiplications by b rather than divisions. Special
  419. case code is provided for decimal, allowing multiplications by 10 to
  420. optimize to shifts and adds.
  421. Above 'GET_STR_PRECOMPUTE_THRESHOLD' a sub-quadratic algorithm is
  422. used. For an input t, powers b^(n*2^i) of the radix are calculated,
  423. until a power between t and sqrt(t) is reached. t is then divided by
  424. that largest power, giving a quotient which is the digits above that
  425. power, and a remainder which is those below. These two parts are in
  426. turn divided by the second highest power, and so on recursively. When a
  427. piece has been divided down to less than 'GET_STR_DC_THRESHOLD' limbs,
  428. the basecase algorithm described above is used.
  429. The advantage of this algorithm is that big divisions can make use of
  430. the sub-quadratic divide and conquer division (*note Divide and Conquer
  431. Division::), and big divisions tend to have less overheads than lots of
  432. separate single limb divisions anyway. But in any case the cost of
  433. calculating the powers b^(n*2^i) must first be overcome.
  434. 'GET_STR_PRECOMPUTE_THRESHOLD' and 'GET_STR_DC_THRESHOLD' represent
  435. the same basic thing, the point where it becomes worth doing a big
  436. division to cut the input in half. 'GET_STR_PRECOMPUTE_THRESHOLD'
  437. includes the cost of calculating the radix power required, whereas
  438. 'GET_STR_DC_THRESHOLD' assumes that's already available, which is the
  439. case when recursing.
  440. Since the base case produces digits from least to most significant
  441. but they want to be stored from most to least, it's necessary to
  442. calculate in advance how many digits there will be, or at least be sure
  443. not to underestimate that. For GMP the number of input bits is
  444. multiplied by 'chars_per_bit_exactly' from 'mp_bases', rounding up. The
  445. result is either correct or one too big.
  446. Examining some of the high bits of the input could increase the
  447. chance of getting the exact number of digits, but an exact result every
  448. time would not be practical, since in general the difference between
  449. numbers 100... and 99... is only in the last few bits and the work to
  450. identify 99... might well be almost as much as a full conversion.
  451. The r/b^n scheme described above for using multiplications to bring
  452. out digits might be useful for more than a single limb. Some brief
  453. experiments with it on the base case when recursing didn't give a
  454. noticeable improvement, but perhaps that was only due to the
  455. implementation. Something similar would work for the sub-quadratic
  456. divisions too, though there would be the cost of calculating a bigger
  457. radix power.
  458. Another possible improvement for the sub-quadratic part would be to
  459. arrange for radix powers that balanced the sizes of quotient and
  460. remainder produced, i.e. the highest power would be an b^(n*k)
  461. approximately equal to sqrt(t), not restricted to a 2^i factor. That
  462. ought to smooth out a graph of times against sizes, but may or may not
  463. be a net speedup.
  464. 
  465. File: gmp.info, Node: Radix to Binary, Prev: Binary to Radix, Up: Radix Conversion Algorithms
  466. 15.6.2 Radix to Binary
  467. ----------------------
  468. *This section needs to be rewritten, it currently describes the
  469. algorithms used before GMP 4.3.*
  470. Conversions from a power-of-2 radix into binary use a simple and fast
  471. O(N) bitwise concatenation algorithm.
  472. Conversions from other radices use one of two algorithms. Sizes
  473. below 'SET_STR_PRECOMPUTE_THRESHOLD' use a basic O(N^2) method. Groups
  474. of n digits are converted to limbs, where n is the biggest power of the
  475. base b which will fit in a limb, then those groups are accumulated into
  476. the result by multiplying by b^n and adding. This saves multi-precision
  477. operations, as per Knuth section 4.4 part E (*note References::). Some
  478. special case code is provided for decimal, giving the compiler a chance
  479. to optimize multiplications by 10.
  480. Above 'SET_STR_PRECOMPUTE_THRESHOLD' a sub-quadratic algorithm is
  481. used. First groups of n digits are converted into limbs. Then adjacent
  482. limbs are combined into limb pairs with x*b^n+y, where x and y are the
  483. limbs. Adjacent limb pairs are combined into quads similarly with
  484. x*b^(2n)+y. This continues until a single block remains, that being the
  485. result.
  486. The advantage of this method is that the multiplications for each x
  487. are big blocks, allowing Karatsuba and higher algorithms to be used.
  488. But the cost of calculating the powers b^(n*2^i) must be overcome.
  489. 'SET_STR_PRECOMPUTE_THRESHOLD' usually ends up quite big, around 5000
  490. digits, and on some processors much bigger still.
  491. 'SET_STR_PRECOMPUTE_THRESHOLD' is based on the input digits (and
  492. tuned for decimal), though it might be better based on a limb count, so
  493. as to be independent of the base. But that sort of count isn't used by
  494. the base case and so would need some sort of initial calculation or
  495. estimate.
  496. The main reason 'SET_STR_PRECOMPUTE_THRESHOLD' is so much bigger than
  497. the corresponding 'GET_STR_PRECOMPUTE_THRESHOLD' is that 'mpn_mul_1' is
  498. much faster than 'mpn_divrem_1' (often by a factor of 5, or more).
  499. 
  500. File: gmp.info, Node: Other Algorithms, Next: Assembly Coding, Prev: Radix Conversion Algorithms, Up: Algorithms
  501. 15.7 Other Algorithms
  502. =====================
  503. * Menu:
  504. * Prime Testing Algorithm::
  505. * Factorial Algorithm::
  506. * Binomial Coefficients Algorithm::
  507. * Fibonacci Numbers Algorithm::
  508. * Lucas Numbers Algorithm::
  509. * Random Number Algorithms::
  510. 
  511. File: gmp.info, Node: Prime Testing Algorithm, Next: Factorial Algorithm, Prev: Other Algorithms, Up: Other Algorithms
  512. 15.7.1 Prime Testing
  513. --------------------
  514. The primality testing in 'mpz_probab_prime_p' (*note Number Theoretic
  515. Functions::) first does some trial division by small factors and then
  516. uses the Miller-Rabin probabilistic primality testing algorithm, as
  517. described in Knuth section 4.5.4 algorithm P (*note References::).
  518. For an odd input n, and with n = q*2^k+1 where q is odd, this
  519. algorithm selects a random base x and tests whether x^q mod n is 1 or
  520. -1, or an x^(q*2^j) mod n is 1, for 1<=j<=k. If so then n is probably
  521. prime, if not then n is definitely composite.
  522. Any prime n will pass the test, but some composites do too. Such
  523. composites are known as strong pseudoprimes to base x. No n is a strong
  524. pseudoprime to more than 1/4 of all bases (see Knuth exercise 22), hence
  525. with x chosen at random there's no more than a 1/4 chance a "probable
  526. prime" will in fact be composite.
  527. In fact strong pseudoprimes are quite rare, making the test much more
  528. powerful than this analysis would suggest, but 1/4 is all that's proven
  529. for an arbitrary n.
  530. 
  531. File: gmp.info, Node: Factorial Algorithm, Next: Binomial Coefficients Algorithm, Prev: Prime Testing Algorithm, Up: Other Algorithms
  532. 15.7.2 Factorial
  533. ----------------
  534. Factorials are calculated by a combination of two algorithms. An idea
  535. is shared among them: to compute the odd part of the factorial; a final
  536. step takes account of the power of 2 term, by shifting.
  537. For small n, the odd factor of n! is computed with the simple
  538. observation that it is equal to the product of all positive odd numbers
  539. smaller than n times the odd factor of [n/2]!, where [x] is the integer
  540. part of x, and so on recursively. The procedure can be best illustrated
  541. with an example,
  542. 23! = (23.21.19.17.15.13.11.9.7.5.3)(11.9.7.5.3)(5.3)2^{19}
  543. Current code collects all the factors in a single list, with a loop
  544. and no recursion, and compute the product, with no special care for
  545. repeated chunks.
  546. When n is larger, computation pass trough prime sieving. An helper
  547. function is used, as suggested by Peter Luschny:
  548. n
  549. -----
  550. n! | | L(p,n)
  551. msf(n) = -------------- = | | p
  552. [n/2]!^2.2^k p=3
  553. Where p ranges on odd prime numbers. The exponent k is chosen to
  554. obtain an odd integer number: k is the number of 1 bits in the binary
  555. representation of [n/2]. The function L(p,n) can be defined as zero
  556. when p is composite, and, for any prime p, it is computed with:
  557. ---
  558. \ n
  559. L(p,n) = / [---] mod 2 <= log (n) .
  560. --- p^i p
  561. i>0
  562. With this helper function, we are able to compute the odd part of n!
  563. using the recursion implied by n!=[n/2]!^2*msf(n)*2^k. The recursion
  564. stops using the small-n algorithm on some [n/2^i].
  565. Both the above algorithms use binary splitting to compute the product
  566. of many small factors. At first as many products as possible are
  567. accumulated in a single register, generating a list of factors that fit
  568. in a machine word. This list is then split into halves, and the product
  569. is computed recursively.
  570. Such splitting is more efficient than repeated Nx1 multiplies since
  571. it forms big multiplies, allowing Karatsuba and higher algorithms to be
  572. used. And even below the Karatsuba threshold a big block of work can be
  573. more efficient for the basecase algorithm.
  574. 
  575. File: gmp.info, Node: Binomial Coefficients Algorithm, Next: Fibonacci Numbers Algorithm, Prev: Factorial Algorithm, Up: Other Algorithms
  576. 15.7.3 Binomial Coefficients
  577. ----------------------------
  578. Binomial coefficients C(n,k) are calculated by first arranging k <= n/2
  579. using C(n,k) = C(n,n-k) if necessary, and then evaluating the following
  580. product simply from i=2 to i=k.
  581. k (n-k+i)
  582. C(n,k) = (n-k+1) * prod -------
  583. i=2 i
  584. It's easy to show that each denominator i will divide the product so
  585. far, so the exact division algorithm is used (*note Exact Division::).
  586. The numerators n-k+i and denominators i are first accumulated into as
  587. many fit a limb, to save multi-precision operations, though for
  588. 'mpz_bin_ui' this applies only to the divisors, since n is an 'mpz_t'
  589. and n-k+i in general won't fit in a limb at all.
  590. 
  591. File: gmp.info, Node: Fibonacci Numbers Algorithm, Next: Lucas Numbers Algorithm, Prev: Binomial Coefficients Algorithm, Up: Other Algorithms
  592. 15.7.4 Fibonacci Numbers
  593. ------------------------
  594. The Fibonacci functions 'mpz_fib_ui' and 'mpz_fib2_ui' are designed for
  595. calculating isolated F[n] or F[n],F[n-1] values efficiently.
  596. For small n, a table of single limb values in '__gmp_fib_table' is
  597. used. On a 32-bit limb this goes up to F[47], or on a 64-bit limb up to
  598. F[93]. For convenience the table starts at F[-1].
  599. Beyond the table, values are generated with a binary powering
  600. algorithm, calculating a pair F[n] and F[n-1] working from high to low
  601. across the bits of n. The formulas used are
  602. F[2k+1] = 4*F[k]^2 - F[k-1]^2 + 2*(-1)^k
  603. F[2k-1] = F[k]^2 + F[k-1]^2
  604. F[2k] = F[2k+1] - F[2k-1]
  605. At each step, k is the high b bits of n. If the next bit of n is 0
  606. then F[2k],F[2k-1] is used, or if it's a 1 then F[2k+1],F[2k] is used,
  607. and the process repeated until all bits of n are incorporated. Notice
  608. these formulas require just two squares per bit of n.
  609. It'd be possible to handle the first few n above the single limb
  610. table with simple additions, using the defining Fibonacci recurrence
  611. F[k+1]=F[k]+F[k-1], but this is not done since it usually turns out to
  612. be faster for only about 10 or 20 values of n, and including a block of
  613. code for just those doesn't seem worthwhile. If they really mattered
  614. it'd be better to extend the data table.
  615. Using a table avoids lots of calculations on small numbers, and makes
  616. small n go fast. A bigger table would make more small n go fast, it's
  617. just a question of balancing size against desired speed. For GMP the
  618. code is kept compact, with the emphasis primarily on a good powering
  619. algorithm.
  620. 'mpz_fib2_ui' returns both F[n] and F[n-1], but 'mpz_fib_ui' is only
  621. interested in F[n]. In this case the last step of the algorithm can
  622. become one multiply instead of two squares. One of the following two
  623. formulas is used, according as n is odd or even.
  624. F[2k] = F[k]*(F[k]+2F[k-1])
  625. F[2k+1] = (2F[k]+F[k-1])*(2F[k]-F[k-1]) + 2*(-1)^k
  626. F[2k+1] here is the same as above, just rearranged to be a multiply.
  627. For interest, the 2*(-1)^k term both here and above can be applied just
  628. to the low limb of the calculation, without a carry or borrow into
  629. further limbs, which saves some code size. See comments with
  630. 'mpz_fib_ui' and the internal 'mpn_fib2_ui' for how this is done.
  631. 
  632. File: gmp.info, Node: Lucas Numbers Algorithm, Next: Random Number Algorithms, Prev: Fibonacci Numbers Algorithm, Up: Other Algorithms
  633. 15.7.5 Lucas Numbers
  634. --------------------
  635. 'mpz_lucnum2_ui' derives a pair of Lucas numbers from a pair of
  636. Fibonacci numbers with the following simple formulas.
  637. L[k] = F[k] + 2*F[k-1]
  638. L[k-1] = 2*F[k] - F[k-1]
  639. 'mpz_lucnum_ui' is only interested in L[n], and some work can be
  640. saved. Trailing zero bits on n can be handled with a single square
  641. each.
  642. L[2k] = L[k]^2 - 2*(-1)^k
  643. And the lowest 1 bit can be handled with one multiply of a pair of
  644. Fibonacci numbers, similar to what 'mpz_fib_ui' does.
  645. L[2k+1] = 5*F[k-1]*(2*F[k]+F[k-1]) - 4*(-1)^k
  646. 
  647. File: gmp.info, Node: Random Number Algorithms, Prev: Lucas Numbers Algorithm, Up: Other Algorithms
  648. 15.7.6 Random Numbers
  649. ---------------------
  650. For the 'urandomb' functions, random numbers are generated simply by
  651. concatenating bits produced by the generator. As long as the generator
  652. has good randomness properties this will produce well-distributed N bit
  653. numbers.
  654. For the 'urandomm' functions, random numbers in a range 0<=R<N are
  655. generated by taking values R of ceil(log2(N)) bits each until one
  656. satisfies R<N. This will normally require only one or two attempts, but
  657. the attempts are limited in case the generator is somehow degenerate and
  658. produces only 1 bits or similar.
  659. The Mersenne Twister generator is by Matsumoto and Nishimura (*note
  660. References::). It has a non-repeating period of 2^19937-1, which is a
  661. Mersenne prime, hence the name of the generator. The state is 624 words
  662. of 32-bits each, which is iterated with one XOR and shift for each
  663. 32-bit word generated, making the algorithm very fast. Randomness
  664. properties are also very good and this is the default algorithm used by
  665. GMP.
  666. Linear congruential generators are described in many text books, for
  667. instance Knuth volume 2 (*note References::). With a modulus M and
  668. parameters A and C, an integer state S is iterated by the formula S <-
  669. A*S+C mod M. At each step the new state is a linear function of the
  670. previous, mod M, hence the name of the generator.
  671. In GMP only moduli of the form 2^N are supported, and the current
  672. implementation is not as well optimized as it could be. Overheads are
  673. significant when N is small, and when N is large clearly the multiply at
  674. each step will become slow. This is not a big concern, since the
  675. Mersenne Twister generator is better in every respect and is therefore
  676. recommended for all normal applications.
  677. For both generators the current state can be deduced by observing
  678. enough output and applying some linear algebra (over GF(2) in the case
  679. of the Mersenne Twister). This generally means raw output is unsuitable
  680. for cryptographic applications without further hashing or the like.
  681. 
  682. File: gmp.info, Node: Assembly Coding, Prev: Other Algorithms, Up: Algorithms
  683. 15.8 Assembly Coding
  684. ====================
  685. The assembly subroutines in GMP are the most significant source of speed
  686. at small to moderate sizes. At larger sizes algorithm selection becomes
  687. more important, but of course speedups in low level routines will still
  688. speed up everything proportionally.
  689. Carry handling and widening multiplies that are important for GMP
  690. can't be easily expressed in C. GCC 'asm' blocks help a lot and are
  691. provided in 'longlong.h', but hand coding low level routines invariably
  692. offers a speedup over generic C by a factor of anything from 2 to 10.
  693. * Menu:
  694. * Assembly Code Organisation::
  695. * Assembly Basics::
  696. * Assembly Carry Propagation::
  697. * Assembly Cache Handling::
  698. * Assembly Functional Units::
  699. * Assembly Floating Point::
  700. * Assembly SIMD Instructions::
  701. * Assembly Software Pipelining::
  702. * Assembly Loop Unrolling::
  703. * Assembly Writing Guide::
  704. 
  705. File: gmp.info, Node: Assembly Code Organisation, Next: Assembly Basics, Prev: Assembly Coding, Up: Assembly Coding
  706. 15.8.1 Code Organisation
  707. ------------------------
  708. The various 'mpn' subdirectories contain machine-dependent code, written
  709. in C or assembly. The 'mpn/generic' subdirectory contains default code,
  710. used when there's no machine-specific version of a particular file.
  711. Each 'mpn' subdirectory is for an ISA family. Generally 32-bit and
  712. 64-bit variants in a family cannot share code and have separate
  713. directories. Within a family further subdirectories may exist for CPU
  714. variants.
  715. In each directory a 'nails' subdirectory may exist, holding code with
  716. nails support for that CPU variant. A 'NAILS_SUPPORT' directive in each
  717. file indicates the nails values the code handles. Nails code only
  718. exists where it's faster, or promises to be faster, than plain code.
  719. There's no effort put into nails if they're not going to enhance a given
  720. CPU.
  721. 
  722. File: gmp.info, Node: Assembly Basics, Next: Assembly Carry Propagation, Prev: Assembly Code Organisation, Up: Assembly Coding
  723. 15.8.2 Assembly Basics
  724. ----------------------
  725. 'mpn_addmul_1' and 'mpn_submul_1' are the most important routines for
  726. overall GMP performance. All multiplications and divisions come down to
  727. repeated calls to these. 'mpn_add_n', 'mpn_sub_n', 'mpn_lshift' and
  728. 'mpn_rshift' are next most important.
  729. On some CPUs assembly versions of the internal functions
  730. 'mpn_mul_basecase' and 'mpn_sqr_basecase' give significant speedups,
  731. mainly through avoiding function call overheads. They can also
  732. potentially make better use of a wide superscalar processor, as can
  733. bigger primitives like 'mpn_addmul_2' or 'mpn_addmul_4'.
  734. The restrictions on overlaps between sources and destinations (*note
  735. Low-level Functions::) are designed to facilitate a variety of
  736. implementations. For example, knowing 'mpn_add_n' won't have partly
  737. overlapping sources and destination means reading can be done far ahead
  738. of writing on superscalar processors, and loops can be vectorized on a
  739. vector processor, depending on the carry handling.
  740. 
  741. File: gmp.info, Node: Assembly Carry Propagation, Next: Assembly Cache Handling, Prev: Assembly Basics, Up: Assembly Coding
  742. 15.8.3 Carry Propagation
  743. ------------------------
  744. The problem that presents most challenges in GMP is propagating carries
  745. from one limb to the next. In functions like 'mpn_addmul_1' and
  746. 'mpn_add_n', carries are the only dependencies between limb operations.
  747. On processors with carry flags, a straightforward CISC style 'adc' is
  748. generally best. AMD K6 'mpn_addmul_1' however is an example of an
  749. unusual set of circumstances where a branch works out better.
  750. On RISC processors generally an add and compare for overflow is used.
  751. This sort of thing can be seen in 'mpn/generic/aors_n.c'. Some carry
  752. propagation schemes require 4 instructions, meaning at least 4 cycles
  753. per limb, but other schemes may use just 1 or 2. On wide superscalar
  754. processors performance may be completely determined by the number of
  755. dependent instructions between carry-in and carry-out for each limb.
  756. On vector processors good use can be made of the fact that a carry
  757. bit only very rarely propagates more than one limb. When adding a
  758. single bit to a limb, there's only a carry out if that limb was
  759. '0xFF...FF' which on random data will be only 1 in 2^mp_bits_per_limb.
  760. 'mpn/cray/add_n.c' is an example of this, it adds all limbs in parallel,
  761. adds one set of carry bits in parallel and then only rarely needs to
  762. fall through to a loop propagating further carries.
  763. On the x86s, GCC (as of version 2.95.2) doesn't generate particularly
  764. good code for the RISC style idioms that are necessary to handle carry
  765. bits in C. Often conditional jumps are generated where 'adc' or 'sbb'
  766. forms would be better. And so unfortunately almost any loop involving
  767. carry bits needs to be coded in assembly for best results.
  768. 
  769. File: gmp.info, Node: Assembly Cache Handling, Next: Assembly Functional Units, Prev: Assembly Carry Propagation, Up: Assembly Coding
  770. 15.8.4 Cache Handling
  771. ---------------------
  772. GMP aims to perform well both on operands that fit entirely in L1 cache
  773. and those which don't.
  774. Basic routines like 'mpn_add_n' or 'mpn_lshift' are often used on
  775. large operands, so L2 and main memory performance is important for them.
  776. 'mpn_mul_1' and 'mpn_addmul_1' are mostly used for multiply and square
  777. basecases, so L1 performance matters most for them, unless assembly
  778. versions of 'mpn_mul_basecase' and 'mpn_sqr_basecase' exist, in which
  779. case the remaining uses are mostly for larger operands.
  780. For L2 or main memory operands, memory access times will almost
  781. certainly be more than the calculation time. The aim therefore is to
  782. maximize memory throughput, by starting a load of the next cache line
  783. while processing the contents of the previous one. Clearly this is only
  784. possible if the chip has a lock-up free cache or some sort of prefetch
  785. instruction. Most current chips have both these features.
  786. Prefetching sources combines well with loop unrolling, since a
  787. prefetch can be initiated once per unrolled loop (or more than once if
  788. the loop covers more than one cache line).
  789. On CPUs without write-allocate caches, prefetching destinations will
  790. ensure individual stores don't go further down the cache hierarchy,
  791. limiting bandwidth. Of course for calculations which are slow anyway,
  792. like 'mpn_divrem_1', write-throughs might be fine.
  793. The distance ahead to prefetch will be determined by memory latency
  794. versus throughput. The aim of course is to have data arriving
  795. continuously, at peak throughput. Some CPUs have limits on the number
  796. of fetches or prefetches in progress.
  797. If a special prefetch instruction doesn't exist then a plain load can
  798. be used, but in that case care must be taken not to attempt to read past
  799. the end of an operand, since that might produce a segmentation
  800. violation.
  801. Some CPUs or systems have hardware that detects sequential memory
  802. accesses and initiates suitable cache movements automatically, making
  803. life easy.
  804. 
  805. File: gmp.info, Node: Assembly Functional Units, Next: Assembly Floating Point, Prev: Assembly Cache Handling, Up: Assembly Coding
  806. 15.8.5 Functional Units
  807. -----------------------
  808. When choosing an approach for an assembly loop, consideration is given
  809. to what operations can execute simultaneously and what throughput can
  810. thereby be achieved. In some cases an algorithm can be tweaked to
  811. accommodate available resources.
  812. Loop control will generally require a counter and pointer updates,
  813. costing as much as 5 instructions, plus any delays a branch introduces.
  814. CPU addressing modes might reduce pointer updates, perhaps by allowing
  815. just one updating pointer and others expressed as offsets from it, or on
  816. CISC chips with all addressing done with the loop counter as a scaled
  817. index.
  818. The final loop control cost can be amortised by processing several
  819. limbs in each iteration (*note Assembly Loop Unrolling::). This at
  820. least ensures loop control isn't a big fraction the work done.
  821. Memory throughput is always a limit. If perhaps only one load or one
  822. store can be done per cycle then 3 cycles/limb will the top speed for
  823. "binary" operations like 'mpn_add_n', and any code achieving that is
  824. optimal.
  825. Integer resources can be freed up by having the loop counter in a
  826. float register, or by pressing the float units into use for some
  827. multiplying, perhaps doing every second limb on the float side (*note
  828. Assembly Floating Point::).
  829. Float resources can be freed up by doing carry propagation on the
  830. integer side, or even by doing integer to float conversions in integers
  831. using bit twiddling.
  832. 
  833. File: gmp.info, Node: Assembly Floating Point, Next: Assembly SIMD Instructions, Prev: Assembly Functional Units, Up: Assembly Coding
  834. 15.8.6 Floating Point
  835. ---------------------
  836. Floating point arithmetic is used in GMP for multiplications on CPUs
  837. with poor integer multipliers. It's mostly useful for 'mpn_mul_1',
  838. 'mpn_addmul_1' and 'mpn_submul_1' on 64-bit machines, and
  839. 'mpn_mul_basecase' on both 32-bit and 64-bit machines.
  840. With IEEE 53-bit double precision floats, integer multiplications
  841. producing up to 53 bits will give exact results. Breaking a 64x64
  842. multiplication into eight 16x32->48 bit pieces is convenient. With some
  843. care though six 21x32->53 bit products can be used, if one of the lower
  844. two 21-bit pieces also uses the sign bit.
  845. For the 'mpn_mul_1' family of functions on a 64-bit machine, the
  846. invariant single limb is split at the start, into 3 or 4 pieces. Inside
  847. the loop, the bignum operand is split into 32-bit pieces. Fast
  848. conversion of these unsigned 32-bit pieces to floating point is highly
  849. machine-dependent. In some cases, reading the data into the integer
  850. unit, zero-extending to 64-bits, then transferring to the floating point
  851. unit back via memory is the only option.
  852. Converting partial products back to 64-bit limbs is usually best done
  853. as a signed conversion. Since all values are smaller than 2^53, signed
  854. and unsigned are the same, but most processors lack unsigned
  855. conversions.
  856. Here is a diagram showing 16x32 bit products for an 'mpn_mul_1' or
  857. 'mpn_addmul_1' with a 64-bit limb. The single limb operand V is split
  858. into four 16-bit parts. The multi-limb operand U is split in the loop
  859. into two 32-bit parts.
  860. +---+---+---+---+
  861. |v48|v32|v16|v00| V operand
  862. +---+---+---+---+
  863. +-------+---+---+
  864. x | u32 | u00 | U operand (one limb)
  865. +---------------+
  866. ---------------------------------
  867. +-----------+
  868. | u00 x v00 | p00 48-bit products
  869. +-----------+
  870. +-----------+
  871. | u00 x v16 | p16
  872. +-----------+
  873. +-----------+
  874. | u00 x v32 | p32
  875. +-----------+
  876. +-----------+
  877. | u00 x v48 | p48
  878. +-----------+
  879. +-----------+
  880. | u32 x v00 | r32
  881. +-----------+
  882. +-----------+
  883. | u32 x v16 | r48
  884. +-----------+
  885. +-----------+
  886. | u32 x v32 | r64
  887. +-----------+
  888. +-----------+
  889. | u32 x v48 | r80
  890. +-----------+
  891. p32 and r32 can be summed using floating-point addition, and likewise
  892. p48 and r48. p00 and p16 can be summed with r64 and r80 from the
  893. previous iteration.
  894. For each loop then, four 49-bit quantities are transferred to the
  895. integer unit, aligned as follows,
  896. |-----64bits----|-----64bits----|
  897. +------------+
  898. | p00 + r64' | i00
  899. +------------+
  900. +------------+
  901. | p16 + r80' | i16
  902. +------------+
  903. +------------+
  904. | p32 + r32 | i32
  905. +------------+
  906. +------------+
  907. | p48 + r48 | i48
  908. +------------+
  909. The challenge then is to sum these efficiently and add in a carry
  910. limb, generating a low 64-bit result limb and a high 33-bit carry limb
  911. (i48 extends 33 bits into the high half).
  912. 
  913. File: gmp.info, Node: Assembly SIMD Instructions, Next: Assembly Software Pipelining, Prev: Assembly Floating Point, Up: Assembly Coding
  914. 15.8.7 SIMD Instructions
  915. ------------------------
  916. The single-instruction multiple-data support in current microprocessors
  917. is aimed at signal processing algorithms where each data point can be
  918. treated more or less independently. There's generally not much support
  919. for propagating the sort of carries that arise in GMP.
  920. SIMD multiplications of say four 16x16 bit multiplies only do as much
  921. work as one 32x32 from GMP's point of view, and need some shifts and
  922. adds besides. But of course if say the SIMD form is fully pipelined and
  923. uses less instruction decoding then it may still be worthwhile.
  924. On the x86 chips, MMX has so far found a use in 'mpn_rshift' and
  925. 'mpn_lshift', and is used in a special case for 16-bit multipliers in
  926. the P55 'mpn_mul_1'. SSE2 is used for Pentium 4 'mpn_mul_1',
  927. 'mpn_addmul_1', and 'mpn_submul_1'.
  928. 
  929. File: gmp.info, Node: Assembly Software Pipelining, Next: Assembly Loop Unrolling, Prev: Assembly SIMD Instructions, Up: Assembly Coding
  930. 15.8.8 Software Pipelining
  931. --------------------------
  932. Software pipelining consists of scheduling instructions around the
  933. branch point in a loop. For example a loop might issue a load not for
  934. use in the present iteration but the next, thereby allowing extra cycles
  935. for the data to arrive from memory.
  936. Naturally this is wanted only when doing things like loads or
  937. multiplies that take several cycles to complete, and only where a CPU
  938. has multiple functional units so that other work can be done in the
  939. meantime.
  940. A pipeline with several stages will have a data value in progress at
  941. each stage and each loop iteration moves them along one stage. This is
  942. like juggling.
  943. If the latency of some instruction is greater than the loop time then
  944. it will be necessary to unroll, so one register has a result ready to
  945. use while another (or multiple others) are still in progress. (*note
  946. Assembly Loop Unrolling::).
  947. 
  948. File: gmp.info, Node: Assembly Loop Unrolling, Next: Assembly Writing Guide, Prev: Assembly Software Pipelining, Up: Assembly Coding
  949. 15.8.9 Loop Unrolling
  950. ---------------------
  951. Loop unrolling consists of replicating code so that several limbs are
  952. processed in each loop. At a minimum this reduces loop overheads by a
  953. corresponding factor, but it can also allow better register usage, for
  954. example alternately using one register combination and then another.
  955. Judicious use of 'm4' macros can help avoid lots of duplication in the
  956. source code.
  957. Any amount of unrolling can be handled with a loop counter that's
  958. decremented by N each time, stopping when the remaining count is less
  959. than the further N the loop will process. Or by subtracting N at the
  960. start, the termination condition becomes when the counter C is less than
  961. 0 (and the count of remaining limbs is C+N).
  962. Alternately for a power of 2 unroll the loop count and remainder can
  963. be established with a shift and mask. This is convenient if also making
  964. a computed jump into the middle of a large loop.
  965. The limbs not a multiple of the unrolling can be handled in various
  966. ways, for example
  967. * A simple loop at the end (or the start) to process the excess.
  968. Care will be wanted that it isn't too much slower than the unrolled
  969. part.
  970. * A set of binary tests, for example after an 8-limb unrolling, test
  971. for 4 more limbs to process, then a further 2 more or not, and
  972. finally 1 more or not. This will probably take more code space
  973. than a simple loop.
  974. * A 'switch' statement, providing separate code for each possible
  975. excess, for example an 8-limb unrolling would have separate code
  976. for 0 remaining, 1 remaining, etc, up to 7 remaining. This might
  977. take a lot of code, but may be the best way to optimize all cases
  978. in combination with a deep pipelined loop.
  979. * A computed jump into the middle of the loop, thus making the first
  980. iteration handle the excess. This should make times smoothly
  981. increase with size, which is attractive, but setups for the jump
  982. and adjustments for pointers can be tricky and could become quite
  983. difficult in combination with deep pipelining.
  984. 
  985. File: gmp.info, Node: Assembly Writing Guide, Prev: Assembly Loop Unrolling, Up: Assembly Coding
  986. 15.8.10 Writing Guide
  987. ---------------------
  988. This is a guide to writing software pipelined loops for processing limb
  989. vectors in assembly.
  990. First determine the algorithm and which instructions are needed.
  991. Code it without unrolling or scheduling, to make sure it works. On a
  992. 3-operand CPU try to write each new value to a new register, this will
  993. greatly simplify later steps.
  994. Then note for each instruction the functional unit and/or issue port
  995. requirements. If an instruction can use either of two units, like U0 or
  996. U1 then make a category "U0/U1". Count the total using each unit (or
  997. combined unit), and count all instructions.
  998. Figure out from those counts the best possible loop time. The goal
  999. will be to find a perfect schedule where instruction latencies are
  1000. completely hidden. The total instruction count might be the limiting
  1001. factor, or perhaps a particular functional unit. It might be possible
  1002. to tweak the instructions to help the limiting factor.
  1003. Suppose the loop time is N, then make N issue buckets, with the final
  1004. loop branch at the end of the last. Now fill the buckets with dummy
  1005. instructions using the functional units desired. Run this to make sure
  1006. the intended speed is reached.
  1007. Now replace the dummy instructions with the real instructions from
  1008. the slow but correct loop you started with. The first will typically be
  1009. a load instruction. Then the instruction using that value is placed in
  1010. a bucket an appropriate distance down. Run the loop again, to check it
  1011. still runs at target speed.
  1012. Keep placing instructions, frequently measuring the loop. After a
  1013. few you will need to wrap around from the last bucket back to the top of
  1014. the loop. If you used the new-register for new-value strategy above
  1015. then there will be no register conflicts. If not then take care not to
  1016. clobber something already in use. Changing registers at this time is
  1017. very error prone.
  1018. The loop will overlap two or more of the original loop iterations,
  1019. and the computation of one vector element result will be started in one
  1020. iteration of the new loop, and completed one or several iterations
  1021. later.
  1022. The final step is to create feed-in and wind-down code for the loop.
  1023. A good way to do this is to make a copy (or copies) of the loop at the
  1024. start and delete those instructions which don't have valid antecedents,
  1025. and at the end replicate and delete those whose results are unwanted
  1026. (including any further loads).
  1027. The loop will have a minimum number of limbs loaded and processed, so
  1028. the feed-in code must test if the request size is smaller and skip
  1029. either to a suitable part of the wind-down or to special code for small
  1030. sizes.
  1031. 
  1032. File: gmp.info, Node: Internals, Next: Contributors, Prev: Algorithms, Up: Top
  1033. 16 Internals
  1034. ************
  1035. *This chapter is provided only for informational purposes and the
  1036. various internals described here may change in future GMP releases.
  1037. Applications expecting to be compatible with future releases should use
  1038. only the documented interfaces described in previous chapters.*
  1039. * Menu:
  1040. * Integer Internals::
  1041. * Rational Internals::
  1042. * Float Internals::
  1043. * Raw Output Internals::
  1044. * C++ Interface Internals::
  1045. 
  1046. File: gmp.info, Node: Integer Internals, Next: Rational Internals, Prev: Internals, Up: Internals
  1047. 16.1 Integer Internals
  1048. ======================
  1049. 'mpz_t' variables represent integers using sign and magnitude, in space
  1050. dynamically allocated and reallocated. The fields are as follows.
  1051. '_mp_size'
  1052. The number of limbs, or the negative of that when representing a
  1053. negative integer. Zero is represented by '_mp_size' set to zero,
  1054. in which case the '_mp_d' data is unused.
  1055. '_mp_d'
  1056. A pointer to an array of limbs which is the magnitude. These are
  1057. stored "little endian" as per the 'mpn' functions, so '_mp_d[0]' is
  1058. the least significant limb and '_mp_d[ABS(_mp_size)-1]' is the most
  1059. significant. Whenever '_mp_size' is non-zero, the most significant
  1060. limb is non-zero.
  1061. Currently there's always at least one limb allocated, so for
  1062. instance 'mpz_set_ui' never needs to reallocate, and 'mpz_get_ui'
  1063. can fetch '_mp_d[0]' unconditionally (though its value is then only
  1064. wanted if '_mp_size' is non-zero).
  1065. '_mp_alloc'
  1066. '_mp_alloc' is the number of limbs currently allocated at '_mp_d',
  1067. and naturally '_mp_alloc >= ABS(_mp_size)'. When an 'mpz' routine
  1068. is about to (or might be about to) increase '_mp_size', it checks
  1069. '_mp_alloc' to see whether there's enough space, and reallocates if
  1070. not. 'MPZ_REALLOC' is generally used for this.
  1071. The various bitwise logical functions like 'mpz_and' behave as if
  1072. negative values were twos complement. But sign and magnitude is always
  1073. used internally, and necessary adjustments are made during the
  1074. calculations. Sometimes this isn't pretty, but sign and magnitude are
  1075. best for other routines.
  1076. Some internal temporary variables are setup with 'MPZ_TMP_INIT' and
  1077. these have '_mp_d' space obtained from 'TMP_ALLOC' rather than the
  1078. memory allocation functions. Care is taken to ensure that these are big
  1079. enough that no reallocation is necessary (since it would have
  1080. unpredictable consequences).
  1081. '_mp_size' and '_mp_alloc' are 'int', although 'mp_size_t' is usually
  1082. a 'long'. This is done to make the fields just 32 bits on some 64 bits
  1083. systems, thereby saving a few bytes of data space but still providing
  1084. plenty of range.
  1085. 
  1086. File: gmp.info, Node: Rational Internals, Next: Float Internals, Prev: Integer Internals, Up: Internals
  1087. 16.2 Rational Internals
  1088. =======================
  1089. 'mpq_t' variables represent rationals using an 'mpz_t' numerator and
  1090. denominator (*note Integer Internals::).
  1091. The canonical form adopted is denominator positive (and non-zero), no
  1092. common factors between numerator and denominator, and zero uniquely
  1093. represented as 0/1.
  1094. It's believed that casting out common factors at each stage of a
  1095. calculation is best in general. A GCD is an O(N^2) operation so it's
  1096. better to do a few small ones immediately than to delay and have to do a
  1097. big one later. Knowing the numerator and denominator have no common
  1098. factors can be used for example in 'mpq_mul' to make only two cross GCDs
  1099. necessary, not four.
  1100. This general approach to common factors is badly sub-optimal in the
  1101. presence of simple factorizations or little prospect for cancellation,
  1102. but GMP has no way to know when this will occur. As per *note
  1103. Efficiency::, that's left to applications. The 'mpq_t' framework might
  1104. still suit, with 'mpq_numref' and 'mpq_denref' for direct access to the
  1105. numerator and denominator, or of course 'mpz_t' variables can be used
  1106. directly.
  1107. 
  1108. File: gmp.info, Node: Float Internals, Next: Raw Output Internals, Prev: Rational Internals, Up: Internals
  1109. 16.3 Float Internals
  1110. ====================
  1111. Efficient calculation is the primary aim of GMP floats and the use of
  1112. whole limbs and simple rounding facilitates this.
  1113. 'mpf_t' floats have a variable precision mantissa and a single
  1114. machine word signed exponent. The mantissa is represented using sign
  1115. and magnitude.
  1116. most least
  1117. significant significant
  1118. limb limb
  1119. _mp_d
  1120. |---- _mp_exp ---> |
  1121. _____ _____ _____ _____ _____
  1122. |_____|_____|_____|_____|_____|
  1123. . <------------ radix point
  1124. <-------- _mp_size --------->
  1125. The fields are as follows.
  1126. '_mp_size'
  1127. The number of limbs currently in use, or the negative of that when
  1128. representing a negative value. Zero is represented by '_mp_size'
  1129. and '_mp_exp' both set to zero, and in that case the '_mp_d' data
  1130. is unused. (In the future '_mp_exp' might be undefined when
  1131. representing zero.)
  1132. '_mp_prec'
  1133. The precision of the mantissa, in limbs. In any calculation the
  1134. aim is to produce '_mp_prec' limbs of result (the most significant
  1135. being non-zero).
  1136. '_mp_d'
  1137. A pointer to the array of limbs which is the absolute value of the
  1138. mantissa. These are stored "little endian" as per the 'mpn'
  1139. functions, so '_mp_d[0]' is the least significant limb and
  1140. '_mp_d[ABS(_mp_size)-1]' the most significant.
  1141. The most significant limb is always non-zero, but there are no
  1142. other restrictions on its value, in particular the highest 1 bit
  1143. can be anywhere within the limb.
  1144. '_mp_prec+1' limbs are allocated to '_mp_d', the extra limb being
  1145. for convenience (see below). There are no reallocations during a
  1146. calculation, only in a change of precision with 'mpf_set_prec'.
  1147. '_mp_exp'
  1148. The exponent, in limbs, determining the location of the implied
  1149. radix point. Zero means the radix point is just above the most
  1150. significant limb. Positive values mean a radix point offset
  1151. towards the lower limbs and hence a value >= 1, as for example in
  1152. the diagram above. Negative exponents mean a radix point further
  1153. above the highest limb.
  1154. Naturally the exponent can be any value, it doesn't have to fall
  1155. within the limbs as the diagram shows, it can be a long way above
  1156. or a long way below. Limbs other than those included in the
  1157. '{_mp_d,_mp_size}' data are treated as zero.
  1158. The '_mp_size' and '_mp_prec' fields are 'int', although the
  1159. 'mp_size_t' type is usually a 'long'. The '_mp_exp' field is usually
  1160. 'long'. This is done to make some fields just 32 bits on some 64 bits
  1161. systems, thereby saving a few bytes of data space but still providing
  1162. plenty of precision and a very large range.
  1163. The following various points should be noted.
  1164. Low Zeros
  1165. The least significant limbs '_mp_d[0]' etc can be zero, though such
  1166. low zeros can always be ignored. Routines likely to produce low
  1167. zeros check and avoid them to save time in subsequent calculations,
  1168. but for most routines they're quite unlikely and aren't checked.
  1169. Mantissa Size Range
  1170. The '_mp_size' count of limbs in use can be less than '_mp_prec' if
  1171. the value can be represented in less. This means low precision
  1172. values or small integers stored in a high precision 'mpf_t' can
  1173. still be operated on efficiently.
  1174. '_mp_size' can also be greater than '_mp_prec'. Firstly a value is
  1175. allowed to use all of the '_mp_prec+1' limbs available at '_mp_d',
  1176. and secondly when 'mpf_set_prec_raw' lowers '_mp_prec' it leaves
  1177. '_mp_size' unchanged and so the size can be arbitrarily bigger than
  1178. '_mp_prec'.
  1179. Rounding
  1180. All rounding is done on limb boundaries. Calculating '_mp_prec'
  1181. limbs with the high non-zero will ensure the application requested
  1182. minimum precision is obtained.
  1183. The use of simple "trunc" rounding towards zero is efficient, since
  1184. there's no need to examine extra limbs and increment or decrement.
  1185. Bit Shifts
  1186. Since the exponent is in limbs, there are no bit shifts in basic
  1187. operations like 'mpf_add' and 'mpf_mul'. When differing exponents
  1188. are encountered all that's needed is to adjust pointers to line up
  1189. the relevant limbs.
  1190. Of course 'mpf_mul_2exp' and 'mpf_div_2exp' will require bit
  1191. shifts, but the choice is between an exponent in limbs which
  1192. requires shifts there, or one in bits which requires them almost
  1193. everywhere else.
  1194. Use of '_mp_prec+1' Limbs
  1195. The extra limb on '_mp_d' ('_mp_prec+1' rather than just
  1196. '_mp_prec') helps when an 'mpf' routine might get a carry from its
  1197. operation. 'mpf_add' for instance will do an 'mpn_add' of
  1198. '_mp_prec' limbs. If there's no carry then that's the result, but
  1199. if there is a carry then it's stored in the extra limb of space and
  1200. '_mp_size' becomes '_mp_prec+1'.
  1201. Whenever '_mp_prec+1' limbs are held in a variable, the low limb is
  1202. not needed for the intended precision, only the '_mp_prec' high
  1203. limbs. But zeroing it out or moving the rest down is unnecessary.
  1204. Subsequent routines reading the value will simply take the high
  1205. limbs they need, and this will be '_mp_prec' if their target has
  1206. that same precision. This is no more than a pointer adjustment,
  1207. and must be checked anyway since the destination precision can be
  1208. different from the sources.
  1209. Copy functions like 'mpf_set' will retain a full '_mp_prec+1' limbs
  1210. if available. This ensures that a variable which has '_mp_size'
  1211. equal to '_mp_prec+1' will get its full exact value copied.
  1212. Strictly speaking this is unnecessary since only '_mp_prec' limbs
  1213. are needed for the application's requested precision, but it's
  1214. considered that an 'mpf_set' from one variable into another of the
  1215. same precision ought to produce an exact copy.
  1216. Application Precisions
  1217. '__GMPF_BITS_TO_PREC' converts an application requested precision
  1218. to an '_mp_prec'. The value in bits is rounded up to a whole limb
  1219. then an extra limb is added since the most significant limb of
  1220. '_mp_d' is only non-zero and therefore might contain only one bit.
  1221. '__GMPF_PREC_TO_BITS' does the reverse conversion, and removes the
  1222. extra limb from '_mp_prec' before converting to bits. The net
  1223. effect of reading back with 'mpf_get_prec' is simply the precision
  1224. rounded up to a multiple of 'mp_bits_per_limb'.
  1225. Note that the extra limb added here for the high only being
  1226. non-zero is in addition to the extra limb allocated to '_mp_d'.
  1227. For example with a 32-bit limb, an application request for 250 bits
  1228. will be rounded up to 8 limbs, then an extra added for the high
  1229. being only non-zero, giving an '_mp_prec' of 9. '_mp_d' then gets
  1230. 10 limbs allocated. Reading back with 'mpf_get_prec' will take
  1231. '_mp_prec' subtract 1 limb and multiply by 32, giving 256 bits.
  1232. Strictly speaking, the fact the high limb has at least one bit
  1233. means that a float with, say, 3 limbs of 32-bits each will be
  1234. holding at least 65 bits, but for the purposes of 'mpf_t' it's
  1235. considered simply to be 64 bits, a nice multiple of the limb size.
  1236. 
  1237. File: gmp.info, Node: Raw Output Internals, Next: C++ Interface Internals, Prev: Float Internals, Up: Internals
  1238. 16.4 Raw Output Internals
  1239. =========================
  1240. 'mpz_out_raw' uses the following format.
  1241. +------+------------------------+
  1242. | size | data bytes |
  1243. +------+------------------------+
  1244. The size is 4 bytes written most significant byte first, being the
  1245. number of subsequent data bytes, or the twos complement negative of that
  1246. when a negative integer is represented. The data bytes are the absolute
  1247. value of the integer, written most significant byte first.
  1248. The most significant data byte is always non-zero, so the output is
  1249. the same on all systems, irrespective of limb size.
  1250. In GMP 1, leading zero bytes were written to pad the data bytes to a
  1251. multiple of the limb size. 'mpz_inp_raw' will still accept this, for
  1252. compatibility.
  1253. The use of "big endian" for both the size and data fields is
  1254. deliberate, it makes the data easy to read in a hex dump of a file.
  1255. Unfortunately it also means that the limb data must be reversed when
  1256. reading or writing, so neither a big endian nor little endian system can
  1257. just read and write '_mp_d'.
  1258. 
  1259. File: gmp.info, Node: C++ Interface Internals, Prev: Raw Output Internals, Up: Internals
  1260. 16.5 C++ Interface Internals
  1261. ============================
  1262. A system of expression templates is used to ensure something like
  1263. 'a=b+c' turns into a simple call to 'mpz_add' etc. For 'mpf_class' the
  1264. scheme also ensures the precision of the final destination is used for
  1265. any temporaries within a statement like 'f=w*x+y*z'. These are
  1266. important features which a naive implementation cannot provide.
  1267. A simplified description of the scheme follows. The true scheme is
  1268. complicated by the fact that expressions have different return types.
  1269. For detailed information, refer to the source code.
  1270. To perform an operation, say, addition, we first define a "function
  1271. object" evaluating it,
  1272. struct __gmp_binary_plus
  1273. {
  1274. static void eval(mpf_t f, const mpf_t g, const mpf_t h)
  1275. {
  1276. mpf_add(f, g, h);
  1277. }
  1278. };
  1279. And an "additive expression" object,
  1280. __gmp_expr<__gmp_binary_expr<mpf_class, mpf_class, __gmp_binary_plus> >
  1281. operator+(const mpf_class &f, const mpf_class &g)
  1282. {
  1283. return __gmp_expr
  1284. <__gmp_binary_expr<mpf_class, mpf_class, __gmp_binary_plus> >(f, g);
  1285. }
  1286. The seemingly redundant '__gmp_expr<__gmp_binary_expr<...>>' is used
  1287. to encapsulate any possible kind of expression into a single template
  1288. type. In fact even 'mpf_class' etc are 'typedef' specializations of
  1289. '__gmp_expr'.
  1290. Next we define assignment of '__gmp_expr' to 'mpf_class'.
  1291. template <class T>
  1292. mpf_class & mpf_class::operator=(const __gmp_expr<T> &expr)
  1293. {
  1294. expr.eval(this->get_mpf_t(), this->precision());
  1295. return *this;
  1296. }
  1297. template <class Op>
  1298. void __gmp_expr<__gmp_binary_expr<mpf_class, mpf_class, Op> >::eval
  1299. (mpf_t f, mp_bitcnt_t precision)
  1300. {
  1301. Op::eval(f, expr.val1.get_mpf_t(), expr.val2.get_mpf_t());
  1302. }
  1303. where 'expr.val1' and 'expr.val2' are references to the expression's
  1304. operands (here 'expr' is the '__gmp_binary_expr' stored within the
  1305. '__gmp_expr').
  1306. This way, the expression is actually evaluated only at the time of
  1307. assignment, when the required precision (that of 'f') is known.
  1308. Furthermore the target 'mpf_t' is now available, thus we can call
  1309. 'mpf_add' directly with 'f' as the output argument.
  1310. Compound expressions are handled by defining operators taking
  1311. subexpressions as their arguments, like this:
  1312. template <class T, class U>
  1313. __gmp_expr
  1314. <__gmp_binary_expr<__gmp_expr<T>, __gmp_expr<U>, __gmp_binary_plus> >
  1315. operator+(const __gmp_expr<T> &expr1, const __gmp_expr<U> &expr2)
  1316. {
  1317. return __gmp_expr
  1318. <__gmp_binary_expr<__gmp_expr<T>, __gmp_expr<U>, __gmp_binary_plus> >
  1319. (expr1, expr2);
  1320. }
  1321. And the corresponding specializations of '__gmp_expr::eval':
  1322. template <class T, class U, class Op>
  1323. void __gmp_expr
  1324. <__gmp_binary_expr<__gmp_expr<T>, __gmp_expr<U>, Op> >::eval
  1325. (mpf_t f, mp_bitcnt_t precision)
  1326. {
  1327. // declare two temporaries
  1328. mpf_class temp1(expr.val1, precision), temp2(expr.val2, precision);
  1329. Op::eval(f, temp1.get_mpf_t(), temp2.get_mpf_t());
  1330. }
  1331. The expression is thus recursively evaluated to any level of
  1332. complexity and all subexpressions are evaluated to the precision of 'f'.
  1333. 
  1334. File: gmp.info, Node: Contributors, Next: References, Prev: Internals, Up: Top
  1335. Appendix A Contributors
  1336. ***********************
  1337. Torbjörn Granlund wrote the original GMP library and is still the main
  1338. developer. Code not explicitly attributed to others, was contributed by
  1339. Torbjörn. Several other individuals and organizations have contributed
  1340. GMP. Here is a list in chronological order on first contribution:
  1341. Gunnar Sjödin and Hans Riesel helped with mathematical problems in
  1342. early versions of the library.
  1343. Richard Stallman helped with the interface design and revised the
  1344. first version of this manual.
  1345. Brian Beuning and Doug Lea helped with testing of early versions of
  1346. the library and made creative suggestions.
  1347. John Amanatides of York University in Canada contributed the function
  1348. 'mpz_probab_prime_p'.
  1349. Paul Zimmermann wrote the REDC-based mpz_powm code, the
  1350. Schönhage-Strassen FFT multiply code, and the Karatsuba square root
  1351. code. He also improved the Toom3 code for GMP 4.2. Paul sparked the
  1352. development of GMP 2, with his comparisons between bignum packages. The
  1353. ECMNET project Paul is organizing was a driving force behind many of the
  1354. optimizations in GMP 3. Paul also wrote the new GMP 4.3 nth root code
  1355. (with Torbjörn).
  1356. Ken Weber (Kent State University, Universidade Federal do Rio Grande
  1357. do Sul) contributed now defunct versions of 'mpz_gcd', 'mpz_divexact',
  1358. 'mpn_gcd', and 'mpn_bdivmod', partially supported by CNPq (Brazil) grant
  1359. 301314194-2.
  1360. Per Bothner of Cygnus Support helped to set up GMP to use Cygnus'
  1361. configure. He has also made valuable suggestions and tested numerous
  1362. intermediary releases.
  1363. Joachim Hollman was involved in the design of the 'mpf' interface,
  1364. and in the 'mpz' design revisions for version 2.
  1365. Bennet Yee contributed the initial versions of 'mpz_jacobi' and
  1366. 'mpz_legendre'.
  1367. Andreas Schwab contributed the files 'mpn/m68k/lshift.S' and
  1368. 'mpn/m68k/rshift.S' (now in '.asm' form).
  1369. Robert Harley of Inria, France and David Seal of ARM, England,
  1370. suggested clever improvements for population count. Robert also wrote
  1371. highly optimized Karatsuba and 3-way Toom multiplication functions for
  1372. GMP 3, and contributed the ARM assembly code.
  1373. Torsten Ekedahl of the Mathematical department of Stockholm
  1374. University provided significant inspiration during several phases of the
  1375. GMP development. His mathematical expertise helped improve several
  1376. algorithms.
  1377. Linus Nordberg wrote the new configure system based on autoconf and
  1378. implemented the new random functions.
  1379. Kevin Ryde worked on a large number of things: optimized x86 code, m4
  1380. asm macros, parameter tuning, speed measuring, the configure system,
  1381. function inlining, divisibility tests, bit scanning, Jacobi symbols,
  1382. Fibonacci and Lucas number functions, printf and scanf functions, perl
  1383. interface, demo expression parser, the algorithms chapter in the manual,
  1384. 'gmpasm-mode.el', and various miscellaneous improvements elsewhere.
  1385. Kent Boortz made the Mac OS 9 port.
  1386. Steve Root helped write the optimized alpha 21264 assembly code.
  1387. Gerardo Ballabio wrote the 'gmpxx.h' C++ class interface and the C++
  1388. 'istream' input routines.
  1389. Jason Moxham rewrote 'mpz_fac_ui'.
  1390. Pedro Gimeno implemented the Mersenne Twister and made other random
  1391. number improvements.
  1392. Niels Möller wrote the sub-quadratic GCD, extended GCD and jacobi
  1393. code, the quadratic Hensel division code, and (with Torbjörn) the new
  1394. divide and conquer division code for GMP 4.3. Niels also helped
  1395. implement the new Toom multiply code for GMP 4.3 and implemented helper
  1396. functions to simplify Toom evaluations for GMP 5.0. He wrote the
  1397. original version of mpn_mulmod_bnm1, and he is the main author of the
  1398. mini-gmp package used for gmp bootstrapping.
  1399. Alberto Zanoni and Marco Bodrato suggested the unbalanced multiply
  1400. strategy, and found the optimal strategies for evaluation and
  1401. interpolation in Toom multiplication.
  1402. Marco Bodrato helped implement the new Toom multiply code for GMP 4.3
  1403. and implemented most of the new Toom multiply and squaring code for 5.0.
  1404. He is the main author of the current mpn_mulmod_bnm1, mpn_mullo_n, and
  1405. mpn_sqrlo. Marco also wrote the functions mpn_invert and
  1406. mpn_invertappr, and improved the speed of integer root extraction. He
  1407. is the author of the current combinatorial functions: binomial,
  1408. factorial, multifactorial, primorial.
  1409. David Harvey suggested the internal function 'mpn_bdiv_dbm1',
  1410. implementing division relevant to Toom multiplication. He also worked
  1411. on fast assembly sequences, in particular on a fast AMD64
  1412. 'mpn_mul_basecase'. He wrote the internal middle product functions
  1413. 'mpn_mulmid_basecase', 'mpn_toom42_mulmid', 'mpn_mulmid_n' and related
  1414. helper routines.
  1415. Martin Boij wrote 'mpn_perfect_power_p'.
  1416. Marc Glisse improved 'gmpxx.h': use fewer temporaries (faster),
  1417. specializations of 'numeric_limits' and 'common_type', C++11 features
  1418. (move constructors, explicit bool conversion, UDL), make the conversion
  1419. from 'mpq_class' to 'mpz_class' explicit, optimize operations where one
  1420. argument is a small compile-time constant, replace some heap allocations
  1421. by stack allocations. He also fixed the eofbit handling of C++ streams,
  1422. and removed one division from 'mpq/aors.c'.
  1423. David S Miller wrote assembly code for SPARC T3 and T4.
  1424. Mark Sofroniou cleaned up the types of mul_fft.c, letting it work for
  1425. huge operands.
  1426. Ulrich Weigand ported GMP to the powerpc64le ABI.
  1427. (This list is chronological, not ordered after significance. If you
  1428. have contributed to GMP but are not listed above, please tell
  1429. <gmp-devel@gmplib.org> about the omission!)
  1430. The development of floating point functions of GNU MP 2, were
  1431. supported in part by the ESPRIT-BRA (Basic Research Activities) 6846
  1432. project POSSO (POlynomial System SOlving).
  1433. The development of GMP 2, 3, and 4.0 was supported in part by the IDA
  1434. Center for Computing Sciences.
  1435. The development of GMP 4.3, 5.0, and 5.1 was supported in part by the
  1436. Swedish Foundation for Strategic Research.
  1437. Thanks go to Hans Thorsen for donating an SGI system for the GMP test
  1438. system environment.
  1439. 
  1440. File: gmp.info, Node: References, Next: GNU Free Documentation License, Prev: Contributors, Up: Top
  1441. Appendix B References
  1442. *********************
  1443. B.1 Books
  1444. =========
  1445. * Jonathan M. Borwein and Peter B. Borwein, "Pi and the AGM: A Study
  1446. in Analytic Number Theory and Computational Complexity", Wiley,
  1447. 1998.
  1448. * Richard Crandall and Carl Pomerance, "Prime Numbers: A
  1449. Computational Perspective", 2nd edition, Springer-Verlag, 2005.
  1450. <http://www.math.dartmouth.edu/~carlp/>
  1451. * Henri Cohen, "A Course in Computational Algebraic Number Theory",
  1452. Graduate Texts in Mathematics number 138, Springer-Verlag, 1993.
  1453. <http://www.math.u-bordeaux.fr/~cohen/>
  1454. * Donald E. Knuth, "The Art of Computer Programming", volume 2,
  1455. "Seminumerical Algorithms", 3rd edition, Addison-Wesley, 1998.
  1456. <http://www-cs-faculty.stanford.edu/~knuth/taocp.html>
  1457. * John D. Lipson, "Elements of Algebra and Algebraic Computing", The
  1458. Benjamin Cummings Publishing Company Inc, 1981.
  1459. * Alfred J. Menezes, Paul C. van Oorschot and Scott A. Vanstone,
  1460. "Handbook of Applied Cryptography",
  1461. <http://www.cacr.math.uwaterloo.ca/hac/>
  1462. * Richard M. Stallman and the GCC Developer Community, "Using the GNU
  1463. Compiler Collection", Free Software Foundation, 2008, available
  1464. online <https://gcc.gnu.org/onlinedocs/>, and in the GCC package
  1465. <https://ftp.gnu.org/gnu/gcc/>
  1466. B.2 Papers
  1467. ==========
  1468. * Yves Bertot, Nicolas Magaud and Paul Zimmermann, "A Proof of GMP
  1469. Square Root", Journal of Automated Reasoning, volume 29, 2002, pp.
  1470. 225-252. Also available online as INRIA Research Report 4475, June
  1471. 2002, <http://hal.inria.fr/docs/00/07/21/13/PDF/RR-4475.pdf>
  1472. * Christoph Burnikel and Joachim Ziegler, "Fast Recursive Division",
  1473. Max-Planck-Institut fuer Informatik Research Report MPI-I-98-1-022,
  1474. <http://data.mpi-sb.mpg.de/internet/reports.nsf/NumberView/1998-1-022>
  1475. * Torbjörn Granlund and Peter L. Montgomery, "Division by Invariant
  1476. Integers using Multiplication", in Proceedings of the SIGPLAN
  1477. PLDI'94 Conference, June 1994. Also available
  1478. <https://gmplib.org/~tege/divcnst-pldi94.pdf>.
  1479. * Niels Möller and Torbjörn Granlund, "Improved division by invariant
  1480. integers", IEEE Transactions on Computers, 11 June 2010.
  1481. <https://gmplib.org/~tege/division-paper.pdf>
  1482. * Torbjörn Granlund and Niels Möller, "Division of integers large and
  1483. small", to appear.
  1484. * Tudor Jebelean, "An algorithm for exact division", Journal of
  1485. Symbolic Computation, volume 15, 1993, pp. 169-180. Research
  1486. report version available
  1487. <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1992/92-35.ps.gz>
  1488. * Tudor Jebelean, "Exact Division with Karatsuba Complexity -
  1489. Extended Abstract", RISC-Linz technical report 96-31,
  1490. <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1996/96-31.ps.gz>
  1491. * Tudor Jebelean, "Practical Integer Division with Karatsuba
  1492. Complexity", ISSAC 97, pp. 339-341. Technical report available
  1493. <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1996/96-29.ps.gz>
  1494. * Tudor Jebelean, "A Generalization of the Binary GCD Algorithm",
  1495. ISSAC 93, pp. 111-116. Technical report version available
  1496. <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1993/93-01.ps.gz>
  1497. * Tudor Jebelean, "A Double-Digit Lehmer-Euclid Algorithm for Finding
  1498. the GCD of Long Integers", Journal of Symbolic Computation, volume
  1499. 19, 1995, pp. 145-157. Technical report version also available
  1500. <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1992/92-69.ps.gz>
  1501. * Werner Krandick and Tudor Jebelean, "Bidirectional Exact Integer
  1502. Division", Journal of Symbolic Computation, volume 21, 1996, pp.
  1503. 441-455. Early technical report version also available
  1504. <ftp://ftp.risc.uni-linz.ac.at/pub/techreports/1994/94-50.ps.gz>
  1505. * Makoto Matsumoto and Takuji Nishimura, "Mersenne Twister: A
  1506. 623-dimensionally equidistributed uniform pseudorandom number
  1507. generator", ACM Transactions on Modelling and Computer Simulation,
  1508. volume 8, January 1998, pp. 3-30. Available online
  1509. <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/ARTICLES/mt.ps.gz>
  1510. (or .pdf)
  1511. * R. Moenck and A. Borodin, "Fast Modular Transforms via Division",
  1512. Proceedings of the 13th Annual IEEE Symposium on Switching and
  1513. Automata Theory, October 1972, pp. 90-96. Reprinted as "Fast
  1514. Modular Transforms", Journal of Computer and System Sciences,
  1515. volume 8, number 3, June 1974, pp. 366-386.
  1516. * Niels Möller, "On Schönhage's algorithm and subquadratic integer
  1517. GCD computation", in Mathematics of Computation, volume 77, January
  1518. 2008, pp. 589-607.
  1519. * Peter L. Montgomery, "Modular Multiplication Without Trial
  1520. Division", in Mathematics of Computation, volume 44, number 170,
  1521. April 1985.
  1522. * Arnold Schönhage and Volker Strassen, "Schnelle Multiplikation
  1523. grosser Zahlen", Computing 7, 1971, pp. 281-292.
  1524. * Kenneth Weber, "The accelerated integer GCD algorithm", ACM
  1525. Transactions on Mathematical Software, volume 21, number 1, March
  1526. 1995, pp. 111-122.
  1527. * Paul Zimmermann, "Karatsuba Square Root", INRIA Research Report
  1528. 3805, November 1999,
  1529. <http://hal.inria.fr/inria-00072854/PDF/RR-3805.pdf>
  1530. * Paul Zimmermann, "A Proof of GMP Fast Division and Square Root
  1531. Implementations",
  1532. <http://www.loria.fr/~zimmerma/papers/proof-div-sqrt.ps.gz>
  1533. * Dan Zuras, "On Squaring and Multiplying Large Integers", ARITH-11:
  1534. IEEE Symposium on Computer Arithmetic, 1993, pp. 260 to 271.
  1535. Reprinted as "More on Multiplying and Squaring Large Integers",
  1536. IEEE Transactions on Computers, volume 43, number 8, August 1994,
  1537. pp. 899-908.
  1538. 
  1539. File: gmp.info, Node: GNU Free Documentation License, Next: Concept Index, Prev: References, Up: Top
  1540. Appendix C GNU Free Documentation License
  1541. *****************************************
  1542. Version 1.3, 3 November 2008
  1543. Copyright © 2000-2002, 2007, 2008 Free Software Foundation, Inc.
  1544. <http://fsf.org/>
  1545. Everyone is permitted to copy and distribute verbatim copies
  1546. of this license document, but changing it is not allowed.
  1547. 0. PREAMBLE
  1548. The purpose of this License is to make a manual, textbook, or other
  1549. functional and useful document "free" in the sense of freedom: to
  1550. assure everyone the effective freedom to copy and redistribute it,
  1551. with or without modifying it, either commercially or
  1552. noncommercially. Secondarily, this License preserves for the
  1553. author and publisher a way to get credit for their work, while not
  1554. being considered responsible for modifications made by others.
  1555. This License is a kind of "copyleft", which means that derivative
  1556. works of the document must themselves be free in the same sense.
  1557. It complements the GNU General Public License, which is a copyleft
  1558. license designed for free software.
  1559. We have designed this License in order to use it for manuals for
  1560. free software, because free software needs free documentation: a
  1561. free program should come with manuals providing the same freedoms
  1562. that the software does. But this License is not limited to
  1563. software manuals; it can be used for any textual work, regardless
  1564. of subject matter or whether it is published as a printed book. We
  1565. recommend this License principally for works whose purpose is
  1566. instruction or reference.
  1567. 1. APPLICABILITY AND DEFINITIONS
  1568. This License applies to any manual or other work, in any medium,
  1569. that contains a notice placed by the copyright holder saying it can
  1570. be distributed under the terms of this License. Such a notice
  1571. grants a world-wide, royalty-free license, unlimited in duration,
  1572. to use that work under the conditions stated herein. The
  1573. "Document", below, refers to any such manual or work. Any member
  1574. of the public is a licensee, and is addressed as "you". You accept
  1575. the license if you copy, modify or distribute the work in a way
  1576. requiring permission under copyright law.
  1577. A "Modified Version" of the Document means any work containing the
  1578. Document or a portion of it, either copied verbatim, or with
  1579. modifications and/or translated into another language.
  1580. A "Secondary Section" is a named appendix or a front-matter section
  1581. of the Document that deals exclusively with the relationship of the
  1582. publishers or authors of the Document to the Document's overall
  1583. subject (or to related matters) and contains nothing that could
  1584. fall directly within that overall subject. (Thus, if the Document
  1585. is in part a textbook of mathematics, a Secondary Section may not
  1586. explain any mathematics.) The relationship could be a matter of
  1587. historical connection with the subject or with related matters, or
  1588. of legal, commercial, philosophical, ethical or political position
  1589. regarding them.
  1590. The "Invariant Sections" are certain Secondary Sections whose
  1591. titles are designated, as being those of Invariant Sections, in the
  1592. notice that says that the Document is released under this License.
  1593. If a section does not fit the above definition of Secondary then it
  1594. is not allowed to be designated as Invariant. The Document may
  1595. contain zero Invariant Sections. If the Document does not identify
  1596. any Invariant Sections then there are none.
  1597. The "Cover Texts" are certain short passages of text that are
  1598. listed, as Front-Cover Texts or Back-Cover Texts, in the notice
  1599. that says that the Document is released under this License. A
  1600. Front-Cover Text may be at most 5 words, and a Back-Cover Text may
  1601. be at most 25 words.
  1602. A "Transparent" copy of the Document means a machine-readable copy,
  1603. represented in a format whose specification is available to the
  1604. general public, that is suitable for revising the document
  1605. straightforwardly with generic text editors or (for images composed
  1606. of pixels) generic paint programs or (for drawings) some widely
  1607. available drawing editor, and that is suitable for input to text
  1608. formatters or for automatic translation to a variety of formats
  1609. suitable for input to text formatters. A copy made in an otherwise
  1610. Transparent file format whose markup, or absence of markup, has
  1611. been arranged to thwart or discourage subsequent modification by
  1612. readers is not Transparent. An image format is not Transparent if
  1613. used for any substantial amount of text. A copy that is not
  1614. "Transparent" is called "Opaque".
  1615. Examples of suitable formats for Transparent copies include plain
  1616. ASCII without markup, Texinfo input format, LaTeX input format,
  1617. SGML or XML using a publicly available DTD, and standard-conforming
  1618. simple HTML, PostScript or PDF designed for human modification.
  1619. Examples of transparent image formats include PNG, XCF and JPG.
  1620. Opaque formats include proprietary formats that can be read and
  1621. edited only by proprietary word processors, SGML or XML for which
  1622. the DTD and/or processing tools are not generally available, and
  1623. the machine-generated HTML, PostScript or PDF produced by some word
  1624. processors for output purposes only.
  1625. The "Title Page" means, for a printed book, the title page itself,
  1626. plus such following pages as are needed to hold, legibly, the
  1627. material this License requires to appear in the title page. For
  1628. works in formats which do not have any title page as such, "Title
  1629. Page" means the text near the most prominent appearance of the
  1630. work's title, preceding the beginning of the body of the text.
  1631. The "publisher" means any person or entity that distributes copies
  1632. of the Document to the public.
  1633. A section "Entitled XYZ" means a named subunit of the Document
  1634. whose title either is precisely XYZ or contains XYZ in parentheses
  1635. following text that translates XYZ in another language. (Here XYZ
  1636. stands for a specific section name mentioned below, such as
  1637. "Acknowledgements", "Dedications", "Endorsements", or "History".)
  1638. To "Preserve the Title" of such a section when you modify the
  1639. Document means that it remains a section "Entitled XYZ" according
  1640. to this definition.
  1641. The Document may include Warranty Disclaimers next to the notice
  1642. which states that this License applies to the Document. These
  1643. Warranty Disclaimers are considered to be included by reference in
  1644. this License, but only as regards disclaiming warranties: any other
  1645. implication that these Warranty Disclaimers may have is void and
  1646. has no effect on the meaning of this License.
  1647. 2. VERBATIM COPYING
  1648. You may copy and distribute the Document in any medium, either
  1649. commercially or noncommercially, provided that this License, the
  1650. copyright notices, and the license notice saying this License
  1651. applies to the Document are reproduced in all copies, and that you
  1652. add no other conditions whatsoever to those of this License. You
  1653. may not use technical measures to obstruct or control the reading
  1654. or further copying of the copies you make or distribute. However,
  1655. you may accept compensation in exchange for copies. If you
  1656. distribute a large enough number of copies you must also follow the
  1657. conditions in section 3.
  1658. You may also lend copies, under the same conditions stated above,
  1659. and you may publicly display copies.
  1660. 3. COPYING IN QUANTITY
  1661. If you publish printed copies (or copies in media that commonly
  1662. have printed covers) of the Document, numbering more than 100, and
  1663. the Document's license notice requires Cover Texts, you must
  1664. enclose the copies in covers that carry, clearly and legibly, all
  1665. these Cover Texts: Front-Cover Texts on the front cover, and
  1666. Back-Cover Texts on the back cover. Both covers must also clearly
  1667. and legibly identify you as the publisher of these copies. The
  1668. front cover must present the full title with all words of the title
  1669. equally prominent and visible. You may add other material on the
  1670. covers in addition. Copying with changes limited to the covers, as
  1671. long as they preserve the title of the Document and satisfy these
  1672. conditions, can be treated as verbatim copying in other respects.
  1673. If the required texts for either cover are too voluminous to fit
  1674. legibly, you should put the first ones listed (as many as fit
  1675. reasonably) on the actual cover, and continue the rest onto
  1676. adjacent pages.
  1677. If you publish or distribute Opaque copies of the Document
  1678. numbering more than 100, you must either include a machine-readable
  1679. Transparent copy along with each Opaque copy, or state in or with
  1680. each Opaque copy a computer-network location from which the general
  1681. network-using public has access to download using public-standard
  1682. network protocols a complete Transparent copy of the Document, free
  1683. of added material. If you use the latter option, you must take
  1684. reasonably prudent steps, when you begin distribution of Opaque
  1685. copies in quantity, to ensure that this Transparent copy will
  1686. remain thus accessible at the stated location until at least one
  1687. year after the last time you distribute an Opaque copy (directly or
  1688. through your agents or retailers) of that edition to the public.
  1689. It is requested, but not required, that you contact the authors of
  1690. the Document well before redistributing any large number of copies,
  1691. to give them a chance to provide you with an updated version of the
  1692. Document.
  1693. 4. MODIFICATIONS
  1694. You may copy and distribute a Modified Version of the Document
  1695. under the conditions of sections 2 and 3 above, provided that you
  1696. release the Modified Version under precisely this License, with the
  1697. Modified Version filling the role of the Document, thus licensing
  1698. distribution and modification of the Modified Version to whoever
  1699. possesses a copy of it. In addition, you must do these things in
  1700. the Modified Version:
  1701. A. Use in the Title Page (and on the covers, if any) a title
  1702. distinct from that of the Document, and from those of previous
  1703. versions (which should, if there were any, be listed in the
  1704. History section of the Document). You may use the same title
  1705. as a previous version if the original publisher of that
  1706. version gives permission.
  1707. B. List on the Title Page, as authors, one or more persons or
  1708. entities responsible for authorship of the modifications in
  1709. the Modified Version, together with at least five of the
  1710. principal authors of the Document (all of its principal
  1711. authors, if it has fewer than five), unless they release you
  1712. from this requirement.
  1713. C. State on the Title page the name of the publisher of the
  1714. Modified Version, as the publisher.
  1715. D. Preserve all the copyright notices of the Document.
  1716. E. Add an appropriate copyright notice for your modifications
  1717. adjacent to the other copyright notices.
  1718. F. Include, immediately after the copyright notices, a license
  1719. notice giving the public permission to use the Modified
  1720. Version under the terms of this License, in the form shown in
  1721. the Addendum below.
  1722. G. Preserve in that license notice the full lists of Invariant
  1723. Sections and required Cover Texts given in the Document's
  1724. license notice.
  1725. H. Include an unaltered copy of this License.
  1726. I. Preserve the section Entitled "History", Preserve its Title,
  1727. and add to it an item stating at least the title, year, new
  1728. authors, and publisher of the Modified Version as given on the
  1729. Title Page. If there is no section Entitled "History" in the
  1730. Document, create one stating the title, year, authors, and
  1731. publisher of the Document as given on its Title Page, then add
  1732. an item describing the Modified Version as stated in the
  1733. previous sentence.
  1734. J. Preserve the network location, if any, given in the Document
  1735. for public access to a Transparent copy of the Document, and
  1736. likewise the network locations given in the Document for
  1737. previous versions it was based on. These may be placed in the
  1738. "History" section. You may omit a network location for a work
  1739. that was published at least four years before the Document
  1740. itself, or if the original publisher of the version it refers
  1741. to gives permission.
  1742. K. For any section Entitled "Acknowledgements" or "Dedications",
  1743. Preserve the Title of the section, and preserve in the section
  1744. all the substance and tone of each of the contributor
  1745. acknowledgements and/or dedications given therein.
  1746. L. Preserve all the Invariant Sections of the Document, unaltered
  1747. in their text and in their titles. Section numbers or the
  1748. equivalent are not considered part of the section titles.
  1749. M. Delete any section Entitled "Endorsements". Such a section
  1750. may not be included in the Modified Version.
  1751. N. Do not retitle any existing section to be Entitled
  1752. "Endorsements" or to conflict in title with any Invariant
  1753. Section.
  1754. O. Preserve any Warranty Disclaimers.
  1755. If the Modified Version includes new front-matter sections or
  1756. appendices that qualify as Secondary Sections and contain no
  1757. material copied from the Document, you may at your option designate
  1758. some or all of these sections as invariant. To do this, add their
  1759. titles to the list of Invariant Sections in the Modified Version's
  1760. license notice. These titles must be distinct from any other
  1761. section titles.
  1762. You may add a section Entitled "Endorsements", provided it contains
  1763. nothing but endorsements of your Modified Version by various
  1764. parties--for example, statements of peer review or that the text
  1765. has been approved by an organization as the authoritative
  1766. definition of a standard.
  1767. You may add a passage of up to five words as a Front-Cover Text,
  1768. and a passage of up to 25 words as a Back-Cover Text, to the end of
  1769. the list of Cover Texts in the Modified Version. Only one passage
  1770. of Front-Cover Text and one of Back-Cover Text may be added by (or
  1771. through arrangements made by) any one entity. If the Document
  1772. already includes a cover text for the same cover, previously added
  1773. by you or by arrangement made by the same entity you are acting on
  1774. behalf of, you may not add another; but you may replace the old
  1775. one, on explicit permission from the previous publisher that added
  1776. the old one.
  1777. The author(s) and publisher(s) of the Document do not by this
  1778. License give permission to use their names for publicity for or to
  1779. assert or imply endorsement of any Modified Version.
  1780. 5. COMBINING DOCUMENTS
  1781. You may combine the Document with other documents released under
  1782. this License, under the terms defined in section 4 above for
  1783. modified versions, provided that you include in the combination all
  1784. of the Invariant Sections of all of the original documents,
  1785. unmodified, and list them all as Invariant Sections of your
  1786. combined work in its license notice, and that you preserve all
  1787. their Warranty Disclaimers.
  1788. The combined work need only contain one copy of this License, and
  1789. multiple identical Invariant Sections may be replaced with a single
  1790. copy. If there are multiple Invariant Sections with the same name
  1791. but different contents, make the title of each such section unique
  1792. by adding at the end of it, in parentheses, the name of the
  1793. original author or publisher of that section if known, or else a
  1794. unique number. Make the same adjustment to the section titles in
  1795. the list of Invariant Sections in the license notice of the
  1796. combined work.
  1797. In the combination, you must combine any sections Entitled
  1798. "History" in the various original documents, forming one section
  1799. Entitled "History"; likewise combine any sections Entitled
  1800. "Acknowledgements", and any sections Entitled "Dedications". You
  1801. must delete all sections Entitled "Endorsements."
  1802. 6. COLLECTIONS OF DOCUMENTS
  1803. You may make a collection consisting of the Document and other
  1804. documents released under this License, and replace the individual
  1805. copies of this License in the various documents with a single copy
  1806. that is included in the collection, provided that you follow the
  1807. rules of this License for verbatim copying of each of the documents
  1808. in all other respects.
  1809. You may extract a single document from such a collection, and
  1810. distribute it individually under this License, provided you insert
  1811. a copy of this License into the extracted document, and follow this
  1812. License in all other respects regarding verbatim copying of that
  1813. document.
  1814. 7. AGGREGATION WITH INDEPENDENT WORKS
  1815. A compilation of the Document or its derivatives with other
  1816. separate and independent documents or works, in or on a volume of a
  1817. storage or distribution medium, is called an "aggregate" if the
  1818. copyright resulting from the compilation is not used to limit the
  1819. legal rights of the compilation's users beyond what the individual
  1820. works permit. When the Document is included in an aggregate, this
  1821. License does not apply to the other works in the aggregate which
  1822. are not themselves derivative works of the Document.
  1823. If the Cover Text requirement of section 3 is applicable to these
  1824. copies of the Document, then if the Document is less than one half
  1825. of the entire aggregate, the Document's Cover Texts may be placed
  1826. on covers that bracket the Document within the aggregate, or the
  1827. electronic equivalent of covers if the Document is in electronic
  1828. form. Otherwise they must appear on printed covers that bracket
  1829. the whole aggregate.
  1830. 8. TRANSLATION
  1831. Translation is considered a kind of modification, so you may
  1832. distribute translations of the Document under the terms of section
  1833. 4. Replacing Invariant Sections with translations requires special
  1834. permission from their copyright holders, but you may include
  1835. translations of some or all Invariant Sections in addition to the
  1836. original versions of these Invariant Sections. You may include a
  1837. translation of this License, and all the license notices in the
  1838. Document, and any Warranty Disclaimers, provided that you also
  1839. include the original English version of this License and the
  1840. original versions of those notices and disclaimers. In case of a
  1841. disagreement between the translation and the original version of
  1842. this License or a notice or disclaimer, the original version will
  1843. prevail.
  1844. If a section in the Document is Entitled "Acknowledgements",
  1845. "Dedications", or "History", the requirement (section 4) to
  1846. Preserve its Title (section 1) will typically require changing the
  1847. actual title.
  1848. 9. TERMINATION
  1849. You may not copy, modify, sublicense, or distribute the Document
  1850. except as expressly provided under this License. Any attempt
  1851. otherwise to copy, modify, sublicense, or distribute it is void,
  1852. and will automatically terminate your rights under this License.
  1853. However, if you cease all violation of this License, then your
  1854. license from a particular copyright holder is reinstated (a)
  1855. provisionally, unless and until the copyright holder explicitly and
  1856. finally terminates your license, and (b) permanently, if the
  1857. copyright holder fails to notify you of the violation by some
  1858. reasonable means prior to 60 days after the cessation.
  1859. Moreover, your license from a particular copyright holder is
  1860. reinstated permanently if the copyright holder notifies you of the
  1861. violation by some reasonable means, this is the first time you have
  1862. received notice of violation of this License (for any work) from
  1863. that copyright holder, and you cure the violation prior to 30 days
  1864. after your receipt of the notice.
  1865. Termination of your rights under this section does not terminate
  1866. the licenses of parties who have received copies or rights from you
  1867. under this License. If your rights have been terminated and not
  1868. permanently reinstated, receipt of a copy of some or all of the
  1869. same material does not give you any rights to use it.
  1870. 10. FUTURE REVISIONS OF THIS LICENSE
  1871. The Free Software Foundation may publish new, revised versions of
  1872. the GNU Free Documentation License from time to time. Such new
  1873. versions will be similar in spirit to the present version, but may
  1874. differ in detail to address new problems or concerns. See
  1875. <https://www.gnu.org/copyleft/>.
  1876. Each version of the License is given a distinguishing version
  1877. number. If the Document specifies that a particular numbered
  1878. version of this License "or any later version" applies to it, you
  1879. have the option of following the terms and conditions either of
  1880. that specified version or of any later version that has been
  1881. published (not as a draft) by the Free Software Foundation. If the
  1882. Document does not specify a version number of this License, you may
  1883. choose any version ever published (not as a draft) by the Free
  1884. Software Foundation. If the Document specifies that a proxy can
  1885. decide which future versions of this License can be used, that
  1886. proxy's public statement of acceptance of a version permanently
  1887. authorizes you to choose that version for the Document.
  1888. 11. RELICENSING
  1889. "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
  1890. World Wide Web server that publishes copyrightable works and also
  1891. provides prominent facilities for anybody to edit those works. A
  1892. public wiki that anybody can edit is an example of such a server.
  1893. A "Massive Multiauthor Collaboration" (or "MMC") contained in the
  1894. site means any set of copyrightable works thus published on the MMC
  1895. site.
  1896. "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
  1897. license published by Creative Commons Corporation, a not-for-profit
  1898. corporation with a principal place of business in San Francisco,
  1899. California, as well as future copyleft versions of that license
  1900. published by that same organization.
  1901. "Incorporate" means to publish or republish a Document, in whole or
  1902. in part, as part of another Document.
  1903. An MMC is "eligible for relicensing" if it is licensed under this
  1904. License, and if all works that were first published under this
  1905. License somewhere other than this MMC, and subsequently
  1906. incorporated in whole or in part into the MMC, (1) had no cover
  1907. texts or invariant sections, and (2) were thus incorporated prior
  1908. to November 1, 2008.
  1909. The operator of an MMC Site may republish an MMC contained in the
  1910. site under CC-BY-SA on the same site at any time before August 1,
  1911. 2009, provided the MMC is eligible for relicensing.
  1912. ADDENDUM: How to use this License for your documents
  1913. ====================================================
  1914. To use this License in a document you have written, include a copy of
  1915. the License in the document and put the following copyright and license
  1916. notices just after the title page:
  1917. Copyright (C) YEAR YOUR NAME.
  1918. Permission is granted to copy, distribute and/or modify this document
  1919. under the terms of the GNU Free Documentation License, Version 1.3
  1920. or any later version published by the Free Software Foundation;
  1921. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  1922. Texts. A copy of the license is included in the section entitled ``GNU
  1923. Free Documentation License''.
  1924. If you have Invariant Sections, Front-Cover Texts and Back-Cover
  1925. Texts, replace the "with...Texts." line with this:
  1926. with the Invariant Sections being LIST THEIR TITLES, with
  1927. the Front-Cover Texts being LIST, and with the Back-Cover Texts
  1928. being LIST.
  1929. If you have Invariant Sections without Cover Texts, or some other
  1930. combination of the three, merge those two alternatives to suit the
  1931. situation.
  1932. If your document contains nontrivial examples of program code, we
  1933. recommend releasing these examples in parallel under your choice of free
  1934. software license, such as the GNU General Public License, to permit
  1935. their use in free software.
  1936. 
  1937. File: gmp.info, Node: Concept Index, Next: Function Index, Prev: GNU Free Documentation License, Up: Top
  1938. Concept Index
  1939. *************
  1940. �[index�]
  1941. * Menu:
  1942. * #include: Headers and Libraries.
  1943. (line 6)
  1944. * --build: Build Options. (line 51)
  1945. * --disable-fft: Build Options. (line 307)
  1946. * --disable-shared: Build Options. (line 44)
  1947. * --disable-static: Build Options. (line 44)
  1948. * --enable-alloca: Build Options. (line 273)
  1949. * --enable-assert: Build Options. (line 313)
  1950. * --enable-cxx: Build Options. (line 225)
  1951. * --enable-fat: Build Options. (line 160)
  1952. * --enable-profiling: Build Options. (line 317)
  1953. * --enable-profiling <1>: Profiling. (line 6)
  1954. * --exec-prefix: Build Options. (line 32)
  1955. * --host: Build Options. (line 65)
  1956. * --prefix: Build Options. (line 32)
  1957. * -finstrument-functions: Profiling. (line 66)
  1958. * 2exp functions: Efficiency. (line 43)
  1959. * 68000: Notes for Particular Systems.
  1960. (line 94)
  1961. * 80x86: Notes for Particular Systems.
  1962. (line 150)
  1963. * ABI: Build Options. (line 167)
  1964. * ABI <1>: ABI and ISA. (line 6)
  1965. * About this manual: Introduction to GMP. (line 57)
  1966. * AC_CHECK_LIB: Autoconf. (line 11)
  1967. * AIX: ABI and ISA. (line 174)
  1968. * AIX <1>: Notes for Particular Systems.
  1969. (line 7)
  1970. * Algorithms: Algorithms. (line 6)
  1971. * alloca: Build Options. (line 273)
  1972. * Allocation of memory: Custom Allocation. (line 6)
  1973. * AMD64: ABI and ISA. (line 44)
  1974. * Anonymous FTP of latest version: Introduction to GMP. (line 37)
  1975. * Application Binary Interface: ABI and ISA. (line 6)
  1976. * Arithmetic functions: Integer Arithmetic. (line 6)
  1977. * Arithmetic functions <1>: Rational Arithmetic. (line 6)
  1978. * Arithmetic functions <2>: Float Arithmetic. (line 6)
  1979. * ARM: Notes for Particular Systems.
  1980. (line 20)
  1981. * Assembly cache handling: Assembly Cache Handling.
  1982. (line 6)
  1983. * Assembly carry propagation: Assembly Carry Propagation.
  1984. (line 6)
  1985. * Assembly code organisation: Assembly Code Organisation.
  1986. (line 6)
  1987. * Assembly coding: Assembly Coding. (line 6)
  1988. * Assembly floating Point: Assembly Floating Point.
  1989. (line 6)
  1990. * Assembly loop unrolling: Assembly Loop Unrolling.
  1991. (line 6)
  1992. * Assembly SIMD: Assembly SIMD Instructions.
  1993. (line 6)
  1994. * Assembly software pipelining: Assembly Software Pipelining.
  1995. (line 6)
  1996. * Assembly writing guide: Assembly Writing Guide.
  1997. (line 6)
  1998. * Assertion checking: Build Options. (line 313)
  1999. * Assertion checking <1>: Debugging. (line 78)
  2000. * Assignment functions: Assigning Integers. (line 6)
  2001. * Assignment functions <1>: Simultaneous Integer Init & Assign.
  2002. (line 6)
  2003. * Assignment functions <2>: Initializing Rationals.
  2004. (line 6)
  2005. * Assignment functions <3>: Assigning Floats. (line 6)
  2006. * Assignment functions <4>: Simultaneous Float Init & Assign.
  2007. (line 6)
  2008. * Autoconf: Autoconf. (line 6)
  2009. * Basics: GMP Basics. (line 6)
  2010. * Binomial coefficient algorithm: Binomial Coefficients Algorithm.
  2011. (line 6)
  2012. * Binomial coefficient functions: Number Theoretic Functions.
  2013. (line 124)
  2014. * Binutils strip: Known Build Problems.
  2015. (line 28)
  2016. * Bit manipulation functions: Integer Logic and Bit Fiddling.
  2017. (line 6)
  2018. * Bit scanning functions: Integer Logic and Bit Fiddling.
  2019. (line 39)
  2020. * Bit shift left: Integer Arithmetic. (line 38)
  2021. * Bit shift right: Integer Division. (line 74)
  2022. * Bits per limb: Useful Macros and Constants.
  2023. (line 7)
  2024. * Bug reporting: Reporting Bugs. (line 6)
  2025. * Build directory: Build Options. (line 19)
  2026. * Build notes for binary packaging: Notes for Package Builds.
  2027. (line 6)
  2028. * Build notes for particular systems: Notes for Particular Systems.
  2029. (line 6)
  2030. * Build options: Build Options. (line 6)
  2031. * Build problems known: Known Build Problems.
  2032. (line 6)
  2033. * Build system: Build Options. (line 51)
  2034. * Building GMP: Installing GMP. (line 6)
  2035. * Bus error: Debugging. (line 7)
  2036. * C compiler: Build Options. (line 178)
  2037. * C++ compiler: Build Options. (line 249)
  2038. * C++ interface: C++ Class Interface. (line 6)
  2039. * C++ interface internals: C++ Interface Internals.
  2040. (line 6)
  2041. * C++ istream input: C++ Formatted Input. (line 6)
  2042. * C++ ostream output: C++ Formatted Output.
  2043. (line 6)
  2044. * C++ support: Build Options. (line 225)
  2045. * CC: Build Options. (line 178)
  2046. * CC_FOR_BUILD: Build Options. (line 212)
  2047. * CFLAGS: Build Options. (line 178)
  2048. * Checker: Debugging. (line 114)
  2049. * checkergcc: Debugging. (line 121)
  2050. * Code organisation: Assembly Code Organisation.
  2051. (line 6)
  2052. * Compaq C++: Notes for Particular Systems.
  2053. (line 25)
  2054. * Comparison functions: Integer Comparisons. (line 6)
  2055. * Comparison functions <1>: Comparing Rationals. (line 6)
  2056. * Comparison functions <2>: Float Comparison. (line 6)
  2057. * Compatibility with older versions: Compatibility with older versions.
  2058. (line 6)
  2059. * Conditions for copying GNU MP: Copying. (line 6)
  2060. * Configuring GMP: Installing GMP. (line 6)
  2061. * Congruence algorithm: Exact Remainder. (line 30)
  2062. * Congruence functions: Integer Division. (line 150)
  2063. * Constants: Useful Macros and Constants.
  2064. (line 6)
  2065. * Contributors: Contributors. (line 6)
  2066. * Conventions for parameters: Parameter Conventions.
  2067. (line 6)
  2068. * Conventions for variables: Variable Conventions.
  2069. (line 6)
  2070. * Conversion functions: Converting Integers. (line 6)
  2071. * Conversion functions <1>: Rational Conversions.
  2072. (line 6)
  2073. * Conversion functions <2>: Converting Floats. (line 6)
  2074. * Copying conditions: Copying. (line 6)
  2075. * CPPFLAGS: Build Options. (line 204)
  2076. * CPU types: Introduction to GMP. (line 24)
  2077. * CPU types <1>: Build Options. (line 107)
  2078. * Cross compiling: Build Options. (line 65)
  2079. * Cryptography functions, low-level: Low-level Functions. (line 507)
  2080. * Custom allocation: Custom Allocation. (line 6)
  2081. * CXX: Build Options. (line 249)
  2082. * CXXFLAGS: Build Options. (line 249)
  2083. * Cygwin: Notes for Particular Systems.
  2084. (line 57)
  2085. * Darwin: Known Build Problems.
  2086. (line 51)
  2087. * Debugging: Debugging. (line 6)
  2088. * Demonstration programs: Demonstration Programs.
  2089. (line 6)
  2090. * Digits in an integer: Miscellaneous Integer Functions.
  2091. (line 23)
  2092. * Divisibility algorithm: Exact Remainder. (line 30)
  2093. * Divisibility functions: Integer Division. (line 136)
  2094. * Divisibility functions <1>: Integer Division. (line 150)
  2095. * Divisibility testing: Efficiency. (line 91)
  2096. * Division algorithms: Division Algorithms. (line 6)
  2097. * Division functions: Integer Division. (line 6)
  2098. * Division functions <1>: Rational Arithmetic. (line 24)
  2099. * Division functions <2>: Float Arithmetic. (line 33)
  2100. * DJGPP: Notes for Particular Systems.
  2101. (line 57)
  2102. * DJGPP <1>: Known Build Problems.
  2103. (line 18)
  2104. * DLLs: Notes for Particular Systems.
  2105. (line 70)
  2106. * DocBook: Build Options. (line 340)
  2107. * Documentation formats: Build Options. (line 333)
  2108. * Documentation license: GNU Free Documentation License.
  2109. (line 6)
  2110. * DVI: Build Options. (line 336)
  2111. * Efficiency: Efficiency. (line 6)
  2112. * Emacs: Emacs. (line 6)
  2113. * Exact division functions: Integer Division. (line 125)
  2114. * Exact remainder: Exact Remainder. (line 6)
  2115. * Example programs: Demonstration Programs.
  2116. (line 6)
  2117. * Exec prefix: Build Options. (line 32)
  2118. * Execution profiling: Build Options. (line 317)
  2119. * Execution profiling <1>: Profiling. (line 6)
  2120. * Exponentiation functions: Integer Exponentiation.
  2121. (line 6)
  2122. * Exponentiation functions <1>: Float Arithmetic. (line 41)
  2123. * Export: Integer Import and Export.
  2124. (line 45)
  2125. * Expression parsing demo: Demonstration Programs.
  2126. (line 15)
  2127. * Expression parsing demo <1>: Demonstration Programs.
  2128. (line 17)
  2129. * Expression parsing demo <2>: Demonstration Programs.
  2130. (line 19)
  2131. * Extended GCD: Number Theoretic Functions.
  2132. (line 43)
  2133. * Factor removal functions: Number Theoretic Functions.
  2134. (line 104)
  2135. * Factorial algorithm: Factorial Algorithm. (line 6)
  2136. * Factorial functions: Number Theoretic Functions.
  2137. (line 112)
  2138. * Factorization demo: Demonstration Programs.
  2139. (line 22)
  2140. * Fast Fourier Transform: FFT Multiplication. (line 6)
  2141. * Fat binary: Build Options. (line 160)
  2142. * FFT multiplication: Build Options. (line 307)
  2143. * FFT multiplication <1>: FFT Multiplication. (line 6)
  2144. * Fibonacci number algorithm: Fibonacci Numbers Algorithm.
  2145. (line 6)
  2146. * Fibonacci sequence functions: Number Theoretic Functions.
  2147. (line 132)
  2148. * Float arithmetic functions: Float Arithmetic. (line 6)
  2149. * Float assignment functions: Assigning Floats. (line 6)
  2150. * Float assignment functions <1>: Simultaneous Float Init & Assign.
  2151. (line 6)
  2152. * Float comparison functions: Float Comparison. (line 6)
  2153. * Float conversion functions: Converting Floats. (line 6)
  2154. * Float functions: Floating-point Functions.
  2155. (line 6)
  2156. * Float initialization functions: Initializing Floats. (line 6)
  2157. * Float initialization functions <1>: Simultaneous Float Init & Assign.
  2158. (line 6)
  2159. * Float input and output functions: I/O of Floats. (line 6)
  2160. * Float internals: Float Internals. (line 6)
  2161. * Float miscellaneous functions: Miscellaneous Float Functions.
  2162. (line 6)
  2163. * Float random number functions: Miscellaneous Float Functions.
  2164. (line 27)
  2165. * Float rounding functions: Miscellaneous Float Functions.
  2166. (line 9)
  2167. * Float sign tests: Float Comparison. (line 34)
  2168. * Floating point mode: Notes for Particular Systems.
  2169. (line 34)
  2170. * Floating-point functions: Floating-point Functions.
  2171. (line 6)
  2172. * Floating-point number: Nomenclature and Types.
  2173. (line 21)
  2174. * fnccheck: Profiling. (line 77)
  2175. * Formatted input: Formatted Input. (line 6)
  2176. * Formatted output: Formatted Output. (line 6)
  2177. * Free Documentation License: GNU Free Documentation License.
  2178. (line 6)
  2179. * FreeBSD: Notes for Particular Systems.
  2180. (line 43)
  2181. * FreeBSD <1>: Notes for Particular Systems.
  2182. (line 52)
  2183. * frexp: Converting Integers. (line 43)
  2184. * frexp <1>: Converting Floats. (line 24)
  2185. * FTP of latest version: Introduction to GMP. (line 37)
  2186. * Function classes: Function Classes. (line 6)
  2187. * FunctionCheck: Profiling. (line 77)
  2188. * GCC Checker: Debugging. (line 114)
  2189. * GCD algorithms: Greatest Common Divisor Algorithms.
  2190. (line 6)
  2191. * GCD extended: Number Theoretic Functions.
  2192. (line 43)
  2193. * GCD functions: Number Theoretic Functions.
  2194. (line 26)
  2195. * GDB: Debugging. (line 57)
  2196. * Generic C: Build Options. (line 151)
  2197. * GMP Perl module: Demonstration Programs.
  2198. (line 28)
  2199. * GMP version number: Useful Macros and Constants.
  2200. (line 12)
  2201. * gmp.h: Headers and Libraries.
  2202. (line 6)
  2203. * gmpxx.h: C++ Interface General.
  2204. (line 8)
  2205. * GNU Debugger: Debugging. (line 57)
  2206. * GNU Free Documentation License: GNU Free Documentation License.
  2207. (line 6)
  2208. * GNU strip: Known Build Problems.
  2209. (line 28)
  2210. * gprof: Profiling. (line 41)
  2211. * Greatest common divisor algorithms: Greatest Common Divisor Algorithms.
  2212. (line 6)
  2213. * Greatest common divisor functions: Number Theoretic Functions.
  2214. (line 26)
  2215. * Hardware floating point mode: Notes for Particular Systems.
  2216. (line 34)
  2217. * Headers: Headers and Libraries.
  2218. (line 6)
  2219. * Heap problems: Debugging. (line 23)
  2220. * Home page: Introduction to GMP. (line 33)
  2221. * Host system: Build Options. (line 65)
  2222. * HP-UX: ABI and ISA. (line 76)
  2223. * HP-UX <1>: ABI and ISA. (line 114)
  2224. * HPPA: ABI and ISA. (line 76)
  2225. * I/O functions: I/O of Integers. (line 6)
  2226. * I/O functions <1>: I/O of Rationals. (line 6)
  2227. * I/O functions <2>: I/O of Floats. (line 6)
  2228. * i386: Notes for Particular Systems.
  2229. (line 150)
  2230. * IA-64: ABI and ISA. (line 114)
  2231. * Import: Integer Import and Export.
  2232. (line 11)
  2233. * In-place operations: Efficiency. (line 57)
  2234. * Include files: Headers and Libraries.
  2235. (line 6)
  2236. * info-lookup-symbol: Emacs. (line 6)
  2237. * Initialization functions: Initializing Integers.
  2238. (line 6)
  2239. * Initialization functions <1>: Simultaneous Integer Init & Assign.
  2240. (line 6)
  2241. * Initialization functions <2>: Initializing Rationals.
  2242. (line 6)
  2243. * Initialization functions <3>: Initializing Floats. (line 6)
  2244. * Initialization functions <4>: Simultaneous Float Init & Assign.
  2245. (line 6)
  2246. * Initialization functions <5>: Random State Initialization.
  2247. (line 6)
  2248. * Initializing and clearing: Efficiency. (line 21)
  2249. * Input functions: I/O of Integers. (line 6)
  2250. * Input functions <1>: I/O of Rationals. (line 6)
  2251. * Input functions <2>: I/O of Floats. (line 6)
  2252. * Input functions <3>: Formatted Input Functions.
  2253. (line 6)
  2254. * Install prefix: Build Options. (line 32)
  2255. * Installing GMP: Installing GMP. (line 6)
  2256. * Instruction Set Architecture: ABI and ISA. (line 6)
  2257. * instrument-functions: Profiling. (line 66)
  2258. * Integer: Nomenclature and Types.
  2259. (line 6)
  2260. * Integer arithmetic functions: Integer Arithmetic. (line 6)
  2261. * Integer assignment functions: Assigning Integers. (line 6)
  2262. * Integer assignment functions <1>: Simultaneous Integer Init & Assign.
  2263. (line 6)
  2264. * Integer bit manipulation functions: Integer Logic and Bit Fiddling.
  2265. (line 6)
  2266. * Integer comparison functions: Integer Comparisons. (line 6)
  2267. * Integer conversion functions: Converting Integers. (line 6)
  2268. * Integer division functions: Integer Division. (line 6)
  2269. * Integer exponentiation functions: Integer Exponentiation.
  2270. (line 6)
  2271. * Integer export: Integer Import and Export.
  2272. (line 45)
  2273. * Integer functions: Integer Functions. (line 6)
  2274. * Integer import: Integer Import and Export.
  2275. (line 11)
  2276. * Integer initialization functions: Initializing Integers.
  2277. (line 6)
  2278. * Integer initialization functions <1>: Simultaneous Integer Init & Assign.
  2279. (line 6)
  2280. * Integer input and output functions: I/O of Integers. (line 6)
  2281. * Integer internals: Integer Internals. (line 6)
  2282. * Integer logical functions: Integer Logic and Bit Fiddling.
  2283. (line 6)
  2284. * Integer miscellaneous functions: Miscellaneous Integer Functions.
  2285. (line 6)
  2286. * Integer random number functions: Integer Random Numbers.
  2287. (line 6)
  2288. * Integer root functions: Integer Roots. (line 6)
  2289. * Integer sign tests: Integer Comparisons. (line 28)
  2290. * Integer special functions: Integer Special Functions.
  2291. (line 6)
  2292. * Interix: Notes for Particular Systems.
  2293. (line 65)
  2294. * Internals: Internals. (line 6)
  2295. * Introduction: Introduction to GMP. (line 6)
  2296. * Inverse modulo functions: Number Theoretic Functions.
  2297. (line 70)
  2298. * IRIX: ABI and ISA. (line 139)
  2299. * IRIX <1>: Known Build Problems.
  2300. (line 38)
  2301. * ISA: ABI and ISA. (line 6)
  2302. * istream input: C++ Formatted Input. (line 6)
  2303. * Jacobi symbol algorithm: Jacobi Symbol. (line 6)
  2304. * Jacobi symbol functions: Number Theoretic Functions.
  2305. (line 79)
  2306. * Karatsuba multiplication: Karatsuba Multiplication.
  2307. (line 6)
  2308. * Karatsuba square root algorithm: Square Root Algorithm.
  2309. (line 6)
  2310. * Kronecker symbol functions: Number Theoretic Functions.
  2311. (line 91)
  2312. * Language bindings: Language Bindings. (line 6)
  2313. * Latest version of GMP: Introduction to GMP. (line 37)
  2314. * LCM functions: Number Theoretic Functions.
  2315. (line 64)
  2316. * Least common multiple functions: Number Theoretic Functions.
  2317. (line 64)
  2318. * Legendre symbol functions: Number Theoretic Functions.
  2319. (line 82)
  2320. * libgmp: Headers and Libraries.
  2321. (line 22)
  2322. * libgmpxx: Headers and Libraries.
  2323. (line 27)
  2324. * Libraries: Headers and Libraries.
  2325. (line 22)
  2326. * Libtool: Headers and Libraries.
  2327. (line 33)
  2328. * Libtool versioning: Notes for Package Builds.
  2329. (line 9)
  2330. * License conditions: Copying. (line 6)
  2331. * Limb: Nomenclature and Types.
  2332. (line 31)
  2333. * Limb size: Useful Macros and Constants.
  2334. (line 7)
  2335. * Linear congruential algorithm: Random Number Algorithms.
  2336. (line 25)
  2337. * Linear congruential random numbers: Random State Initialization.
  2338. (line 18)
  2339. * Linear congruential random numbers <1>: Random State Initialization.
  2340. (line 32)
  2341. * Linking: Headers and Libraries.
  2342. (line 22)
  2343. * Logical functions: Integer Logic and Bit Fiddling.
  2344. (line 6)
  2345. * Low-level functions: Low-level Functions. (line 6)
  2346. * Low-level functions for cryptography: Low-level Functions. (line 507)
  2347. * Lucas number algorithm: Lucas Numbers Algorithm.
  2348. (line 6)
  2349. * Lucas number functions: Number Theoretic Functions.
  2350. (line 143)
  2351. * MacOS X: Known Build Problems.
  2352. (line 51)
  2353. * Mailing lists: Introduction to GMP. (line 44)
  2354. * Malloc debugger: Debugging. (line 29)
  2355. * Malloc problems: Debugging. (line 23)
  2356. * Memory allocation: Custom Allocation. (line 6)
  2357. * Memory management: Memory Management. (line 6)
  2358. * Mersenne twister algorithm: Random Number Algorithms.
  2359. (line 17)
  2360. * Mersenne twister random numbers: Random State Initialization.
  2361. (line 13)
  2362. * MINGW: Notes for Particular Systems.
  2363. (line 57)
  2364. * MIPS: ABI and ISA. (line 139)
  2365. * Miscellaneous float functions: Miscellaneous Float Functions.
  2366. (line 6)
  2367. * Miscellaneous integer functions: Miscellaneous Integer Functions.
  2368. (line 6)
  2369. * MMX: Notes for Particular Systems.
  2370. (line 156)
  2371. * Modular inverse functions: Number Theoretic Functions.
  2372. (line 70)
  2373. * Most significant bit: Miscellaneous Integer Functions.
  2374. (line 34)
  2375. * MPN_PATH: Build Options. (line 321)
  2376. * MS Windows: Notes for Particular Systems.
  2377. (line 57)
  2378. * MS Windows <1>: Notes for Particular Systems.
  2379. (line 70)
  2380. * MS-DOS: Notes for Particular Systems.
  2381. (line 57)
  2382. * Multi-threading: Reentrancy. (line 6)
  2383. * Multiplication algorithms: Multiplication Algorithms.
  2384. (line 6)
  2385. * Nails: Low-level Functions. (line 685)
  2386. * Native compilation: Build Options. (line 51)
  2387. * NetBSD: Notes for Particular Systems.
  2388. (line 100)
  2389. * NeXT: Known Build Problems.
  2390. (line 57)
  2391. * Next prime function: Number Theoretic Functions.
  2392. (line 19)
  2393. * Nomenclature: Nomenclature and Types.
  2394. (line 6)
  2395. * Non-Unix systems: Build Options. (line 11)
  2396. * Nth root algorithm: Nth Root Algorithm. (line 6)
  2397. * Number sequences: Efficiency. (line 145)
  2398. * Number theoretic functions: Number Theoretic Functions.
  2399. (line 6)
  2400. * Numerator and denominator: Applying Integer Functions.
  2401. (line 6)
  2402. * obstack output: Formatted Output Functions.
  2403. (line 79)
  2404. * OpenBSD: Notes for Particular Systems.
  2405. (line 109)
  2406. * Optimizing performance: Performance optimization.
  2407. (line 6)
  2408. * ostream output: C++ Formatted Output.
  2409. (line 6)
  2410. * Other languages: Language Bindings. (line 6)
  2411. * Output functions: I/O of Integers. (line 6)
  2412. * Output functions <1>: I/O of Rationals. (line 6)
  2413. * Output functions <2>: I/O of Floats. (line 6)
  2414. * Output functions <3>: Formatted Output Functions.
  2415. (line 6)
  2416. * Packaged builds: Notes for Package Builds.
  2417. (line 6)
  2418. * Parameter conventions: Parameter Conventions.
  2419. (line 6)
  2420. * Parsing expressions demo: Demonstration Programs.
  2421. (line 15)
  2422. * Parsing expressions demo <1>: Demonstration Programs.
  2423. (line 17)
  2424. * Parsing expressions demo <2>: Demonstration Programs.
  2425. (line 19)
  2426. * Particular systems: Notes for Particular Systems.
  2427. (line 6)
  2428. * Past GMP versions: Compatibility with older versions.
  2429. (line 6)
  2430. * PDF: Build Options. (line 336)
  2431. * Perfect power algorithm: Perfect Power Algorithm.
  2432. (line 6)
  2433. * Perfect power functions: Integer Roots. (line 28)
  2434. * Perfect square algorithm: Perfect Square Algorithm.
  2435. (line 6)
  2436. * Perfect square functions: Integer Roots. (line 37)
  2437. * perl: Demonstration Programs.
  2438. (line 28)
  2439. * Perl module: Demonstration Programs.
  2440. (line 28)
  2441. * Postscript: Build Options. (line 336)
  2442. * Power/PowerPC: Notes for Particular Systems.
  2443. (line 115)
  2444. * Power/PowerPC <1>: Known Build Problems.
  2445. (line 63)
  2446. * Powering algorithms: Powering Algorithms. (line 6)
  2447. * Powering functions: Integer Exponentiation.
  2448. (line 6)
  2449. * Powering functions <1>: Float Arithmetic. (line 41)
  2450. * PowerPC: ABI and ISA. (line 173)
  2451. * Precision of floats: Floating-point Functions.
  2452. (line 6)
  2453. * Precision of hardware floating point: Notes for Particular Systems.
  2454. (line 34)
  2455. * Prefix: Build Options. (line 32)
  2456. * Prime testing algorithms: Prime Testing Algorithm.
  2457. (line 6)
  2458. * Prime testing functions: Number Theoretic Functions.
  2459. (line 7)
  2460. * Primorial functions: Number Theoretic Functions.
  2461. (line 117)
  2462. * printf formatted output: Formatted Output. (line 6)
  2463. * Probable prime testing functions: Number Theoretic Functions.
  2464. (line 7)
  2465. * prof: Profiling. (line 24)
  2466. * Profiling: Profiling. (line 6)
  2467. * Radix conversion algorithms: Radix Conversion Algorithms.
  2468. (line 6)
  2469. * Random number algorithms: Random Number Algorithms.
  2470. (line 6)
  2471. * Random number functions: Integer Random Numbers.
  2472. (line 6)
  2473. * Random number functions <1>: Miscellaneous Float Functions.
  2474. (line 27)
  2475. * Random number functions <2>: Random Number Functions.
  2476. (line 6)
  2477. * Random number seeding: Random State Seeding.
  2478. (line 6)
  2479. * Random number state: Random State Initialization.
  2480. (line 6)
  2481. * Random state: Nomenclature and Types.
  2482. (line 46)
  2483. * Rational arithmetic: Efficiency. (line 111)
  2484. * Rational arithmetic functions: Rational Arithmetic. (line 6)
  2485. * Rational assignment functions: Initializing Rationals.
  2486. (line 6)
  2487. * Rational comparison functions: Comparing Rationals. (line 6)
  2488. * Rational conversion functions: Rational Conversions.
  2489. (line 6)
  2490. * Rational initialization functions: Initializing Rationals.
  2491. (line 6)
  2492. * Rational input and output functions: I/O of Rationals. (line 6)
  2493. * Rational internals: Rational Internals. (line 6)
  2494. * Rational number: Nomenclature and Types.
  2495. (line 16)
  2496. * Rational number functions: Rational Number Functions.
  2497. (line 6)
  2498. * Rational numerator and denominator: Applying Integer Functions.
  2499. (line 6)
  2500. * Rational sign tests: Comparing Rationals. (line 28)
  2501. * Raw output internals: Raw Output Internals.
  2502. (line 6)
  2503. * Reallocations: Efficiency. (line 30)
  2504. * Reentrancy: Reentrancy. (line 6)
  2505. * References: References. (line 5)
  2506. * Remove factor functions: Number Theoretic Functions.
  2507. (line 104)
  2508. * Reporting bugs: Reporting Bugs. (line 6)
  2509. * Root extraction algorithm: Nth Root Algorithm. (line 6)
  2510. * Root extraction algorithms: Root Extraction Algorithms.
  2511. (line 6)
  2512. * Root extraction functions: Integer Roots. (line 6)
  2513. * Root extraction functions <1>: Float Arithmetic. (line 37)
  2514. * Root testing functions: Integer Roots. (line 28)
  2515. * Root testing functions <1>: Integer Roots. (line 37)
  2516. * Rounding functions: Miscellaneous Float Functions.
  2517. (line 9)
  2518. * Sample programs: Demonstration Programs.
  2519. (line 6)
  2520. * Scan bit functions: Integer Logic and Bit Fiddling.
  2521. (line 39)
  2522. * scanf formatted input: Formatted Input. (line 6)
  2523. * SCO: Known Build Problems.
  2524. (line 38)
  2525. * Seeding random numbers: Random State Seeding.
  2526. (line 6)
  2527. * Segmentation violation: Debugging. (line 7)
  2528. * Sequent Symmetry: Known Build Problems.
  2529. (line 68)
  2530. * Services for Unix: Notes for Particular Systems.
  2531. (line 65)
  2532. * Shared library versioning: Notes for Package Builds.
  2533. (line 9)
  2534. * Sign tests: Integer Comparisons. (line 28)
  2535. * Sign tests <1>: Comparing Rationals. (line 28)
  2536. * Sign tests <2>: Float Comparison. (line 34)
  2537. * Size in digits: Miscellaneous Integer Functions.
  2538. (line 23)
  2539. * Small operands: Efficiency. (line 7)
  2540. * Solaris: ABI and ISA. (line 204)
  2541. * Solaris <1>: Known Build Problems.
  2542. (line 72)
  2543. * Solaris <2>: Known Build Problems.
  2544. (line 77)
  2545. * Sparc: Notes for Particular Systems.
  2546. (line 127)
  2547. * Sparc <1>: Notes for Particular Systems.
  2548. (line 132)
  2549. * Sparc V9: ABI and ISA. (line 204)
  2550. * Special integer functions: Integer Special Functions.
  2551. (line 6)
  2552. * Square root algorithm: Square Root Algorithm.
  2553. (line 6)
  2554. * SSE2: Notes for Particular Systems.
  2555. (line 156)
  2556. * Stack backtrace: Debugging. (line 49)
  2557. * Stack overflow: Build Options. (line 273)
  2558. * Stack overflow <1>: Debugging. (line 7)
  2559. * Static linking: Efficiency. (line 14)
  2560. * stdarg.h: Headers and Libraries.
  2561. (line 17)
  2562. * stdio.h: Headers and Libraries.
  2563. (line 11)
  2564. * Stripped libraries: Known Build Problems.
  2565. (line 28)
  2566. * Sun: ABI and ISA. (line 204)
  2567. * SunOS: Notes for Particular Systems.
  2568. (line 144)
  2569. * Systems: Notes for Particular Systems.
  2570. (line 6)
  2571. * Temporary memory: Build Options. (line 273)
  2572. * Texinfo: Build Options. (line 333)
  2573. * Text input/output: Efficiency. (line 151)
  2574. * Thread safety: Reentrancy. (line 6)
  2575. * Toom multiplication: Toom 3-Way Multiplication.
  2576. (line 6)
  2577. * Toom multiplication <1>: Toom 4-Way Multiplication.
  2578. (line 6)
  2579. * Toom multiplication <2>: Higher degree Toom'n'half.
  2580. (line 6)
  2581. * Toom multiplication <3>: Other Multiplication.
  2582. (line 6)
  2583. * Types: Nomenclature and Types.
  2584. (line 6)
  2585. * ui and si functions: Efficiency. (line 50)
  2586. * Unbalanced multiplication: Unbalanced Multiplication.
  2587. (line 6)
  2588. * Upward compatibility: Compatibility with older versions.
  2589. (line 6)
  2590. * Useful macros and constants: Useful Macros and Constants.
  2591. (line 6)
  2592. * User-defined precision: Floating-point Functions.
  2593. (line 6)
  2594. * Valgrind: Debugging. (line 129)
  2595. * Variable conventions: Variable Conventions.
  2596. (line 6)
  2597. * Version number: Useful Macros and Constants.
  2598. (line 12)
  2599. * Web page: Introduction to GMP. (line 33)
  2600. * Windows: Notes for Particular Systems.
  2601. (line 57)
  2602. * Windows <1>: Notes for Particular Systems.
  2603. (line 70)
  2604. * x86: Notes for Particular Systems.
  2605. (line 150)
  2606. * x87: Notes for Particular Systems.
  2607. (line 34)
  2608. * XML: Build Options. (line 340)
  2609. 
  2610. File: gmp.info, Node: Function Index, Prev: Concept Index, Up: Top
  2611. Function and Type Index
  2612. ***********************
  2613. �[index�]
  2614. * Menu:
  2615. * _mpz_realloc: Integer Special Functions.
  2616. (line 13)
  2617. * __GMP_CC: Useful Macros and Constants.
  2618. (line 22)
  2619. * __GMP_CFLAGS: Useful Macros and Constants.
  2620. (line 23)
  2621. * __GNU_MP_VERSION: Useful Macros and Constants.
  2622. (line 9)
  2623. * __GNU_MP_VERSION_MINOR: Useful Macros and Constants.
  2624. (line 10)
  2625. * __GNU_MP_VERSION_PATCHLEVEL: Useful Macros and Constants.
  2626. (line 11)
  2627. * abs: C++ Interface Integers.
  2628. (line 46)
  2629. * abs <1>: C++ Interface Rationals.
  2630. (line 47)
  2631. * abs <2>: C++ Interface Floats.
  2632. (line 82)
  2633. * ceil: C++ Interface Floats.
  2634. (line 83)
  2635. * cmp: C++ Interface Integers.
  2636. (line 47)
  2637. * cmp <1>: C++ Interface Integers.
  2638. (line 48)
  2639. * cmp <2>: C++ Interface Rationals.
  2640. (line 48)
  2641. * cmp <3>: C++ Interface Rationals.
  2642. (line 49)
  2643. * cmp <4>: C++ Interface Floats.
  2644. (line 84)
  2645. * cmp <5>: C++ Interface Floats.
  2646. (line 85)
  2647. * floor: C++ Interface Floats.
  2648. (line 95)
  2649. * gcd: C++ Interface Integers.
  2650. (line 68)
  2651. * gmp_asprintf: Formatted Output Functions.
  2652. (line 63)
  2653. * gmp_errno: Random State Initialization.
  2654. (line 56)
  2655. * GMP_ERROR_INVALID_ARGUMENT: Random State Initialization.
  2656. (line 56)
  2657. * GMP_ERROR_UNSUPPORTED_ARGUMENT: Random State Initialization.
  2658. (line 56)
  2659. * gmp_fprintf: Formatted Output Functions.
  2660. (line 28)
  2661. * gmp_fscanf: Formatted Input Functions.
  2662. (line 24)
  2663. * GMP_LIMB_BITS: Low-level Functions. (line 713)
  2664. * GMP_NAIL_BITS: Low-level Functions. (line 711)
  2665. * GMP_NAIL_MASK: Low-level Functions. (line 721)
  2666. * GMP_NUMB_BITS: Low-level Functions. (line 712)
  2667. * GMP_NUMB_MASK: Low-level Functions. (line 722)
  2668. * GMP_NUMB_MAX: Low-level Functions. (line 730)
  2669. * gmp_obstack_printf: Formatted Output Functions.
  2670. (line 75)
  2671. * gmp_obstack_vprintf: Formatted Output Functions.
  2672. (line 77)
  2673. * gmp_printf: Formatted Output Functions.
  2674. (line 23)
  2675. * gmp_randclass: C++ Interface Random Numbers.
  2676. (line 6)
  2677. * gmp_randclass::get_f: C++ Interface Random Numbers.
  2678. (line 44)
  2679. * gmp_randclass::get_f <1>: C++ Interface Random Numbers.
  2680. (line 45)
  2681. * gmp_randclass::get_z_bits: C++ Interface Random Numbers.
  2682. (line 37)
  2683. * gmp_randclass::get_z_bits <1>: C++ Interface Random Numbers.
  2684. (line 38)
  2685. * gmp_randclass::get_z_range: C++ Interface Random Numbers.
  2686. (line 41)
  2687. * gmp_randclass::gmp_randclass: C++ Interface Random Numbers.
  2688. (line 11)
  2689. * gmp_randclass::gmp_randclass <1>: C++ Interface Random Numbers.
  2690. (line 26)
  2691. * gmp_randclass::seed: C++ Interface Random Numbers.
  2692. (line 32)
  2693. * gmp_randclass::seed <1>: C++ Interface Random Numbers.
  2694. (line 33)
  2695. * gmp_randclear: Random State Initialization.
  2696. (line 62)
  2697. * gmp_randinit: Random State Initialization.
  2698. (line 45)
  2699. * gmp_randinit_default: Random State Initialization.
  2700. (line 6)
  2701. * gmp_randinit_lc_2exp: Random State Initialization.
  2702. (line 16)
  2703. * gmp_randinit_lc_2exp_size: Random State Initialization.
  2704. (line 30)
  2705. * gmp_randinit_mt: Random State Initialization.
  2706. (line 12)
  2707. * gmp_randinit_set: Random State Initialization.
  2708. (line 41)
  2709. * gmp_randseed: Random State Seeding.
  2710. (line 6)
  2711. * gmp_randseed_ui: Random State Seeding.
  2712. (line 8)
  2713. * gmp_randstate_t: Nomenclature and Types.
  2714. (line 46)
  2715. * GMP_RAND_ALG_DEFAULT: Random State Initialization.
  2716. (line 50)
  2717. * GMP_RAND_ALG_LC: Random State Initialization.
  2718. (line 50)
  2719. * gmp_scanf: Formatted Input Functions.
  2720. (line 20)
  2721. * gmp_snprintf: Formatted Output Functions.
  2722. (line 44)
  2723. * gmp_sprintf: Formatted Output Functions.
  2724. (line 33)
  2725. * gmp_sscanf: Formatted Input Functions.
  2726. (line 28)
  2727. * gmp_urandomb_ui: Random State Miscellaneous.
  2728. (line 6)
  2729. * gmp_urandomm_ui: Random State Miscellaneous.
  2730. (line 12)
  2731. * gmp_vasprintf: Formatted Output Functions.
  2732. (line 64)
  2733. * gmp_version: Useful Macros and Constants.
  2734. (line 18)
  2735. * gmp_vfprintf: Formatted Output Functions.
  2736. (line 29)
  2737. * gmp_vfscanf: Formatted Input Functions.
  2738. (line 25)
  2739. * gmp_vprintf: Formatted Output Functions.
  2740. (line 24)
  2741. * gmp_vscanf: Formatted Input Functions.
  2742. (line 21)
  2743. * gmp_vsnprintf: Formatted Output Functions.
  2744. (line 46)
  2745. * gmp_vsprintf: Formatted Output Functions.
  2746. (line 34)
  2747. * gmp_vsscanf: Formatted Input Functions.
  2748. (line 29)
  2749. * hypot: C++ Interface Floats.
  2750. (line 96)
  2751. * lcm: C++ Interface Integers.
  2752. (line 69)
  2753. * mpf_abs: Float Arithmetic. (line 46)
  2754. * mpf_add: Float Arithmetic. (line 6)
  2755. * mpf_add_ui: Float Arithmetic. (line 7)
  2756. * mpf_ceil: Miscellaneous Float Functions.
  2757. (line 6)
  2758. * mpf_class: C++ Interface General.
  2759. (line 19)
  2760. * mpf_class::fits_sint_p: C++ Interface Floats.
  2761. (line 87)
  2762. * mpf_class::fits_slong_p: C++ Interface Floats.
  2763. (line 88)
  2764. * mpf_class::fits_sshort_p: C++ Interface Floats.
  2765. (line 89)
  2766. * mpf_class::fits_uint_p: C++ Interface Floats.
  2767. (line 91)
  2768. * mpf_class::fits_ulong_p: C++ Interface Floats.
  2769. (line 92)
  2770. * mpf_class::fits_ushort_p: C++ Interface Floats.
  2771. (line 93)
  2772. * mpf_class::get_d: C++ Interface Floats.
  2773. (line 98)
  2774. * mpf_class::get_mpf_t: C++ Interface General.
  2775. (line 65)
  2776. * mpf_class::get_prec: C++ Interface Floats.
  2777. (line 120)
  2778. * mpf_class::get_si: C++ Interface Floats.
  2779. (line 99)
  2780. * mpf_class::get_str: C++ Interface Floats.
  2781. (line 100)
  2782. * mpf_class::get_ui: C++ Interface Floats.
  2783. (line 102)
  2784. * mpf_class::mpf_class: C++ Interface Floats.
  2785. (line 11)
  2786. * mpf_class::mpf_class <1>: C++ Interface Floats.
  2787. (line 12)
  2788. * mpf_class::mpf_class <2>: C++ Interface Floats.
  2789. (line 32)
  2790. * mpf_class::mpf_class <3>: C++ Interface Floats.
  2791. (line 33)
  2792. * mpf_class::mpf_class <4>: C++ Interface Floats.
  2793. (line 41)
  2794. * mpf_class::mpf_class <5>: C++ Interface Floats.
  2795. (line 42)
  2796. * mpf_class::mpf_class <6>: C++ Interface Floats.
  2797. (line 44)
  2798. * mpf_class::mpf_class <7>: C++ Interface Floats.
  2799. (line 45)
  2800. * mpf_class::operator=: C++ Interface Floats.
  2801. (line 59)
  2802. * mpf_class::set_prec: C++ Interface Floats.
  2803. (line 121)
  2804. * mpf_class::set_prec_raw: C++ Interface Floats.
  2805. (line 122)
  2806. * mpf_class::set_str: C++ Interface Floats.
  2807. (line 104)
  2808. * mpf_class::set_str <1>: C++ Interface Floats.
  2809. (line 105)
  2810. * mpf_class::swap: C++ Interface Floats.
  2811. (line 109)
  2812. * mpf_clear: Initializing Floats. (line 36)
  2813. * mpf_clears: Initializing Floats. (line 40)
  2814. * mpf_cmp: Float Comparison. (line 6)
  2815. * mpf_cmp_d: Float Comparison. (line 8)
  2816. * mpf_cmp_si: Float Comparison. (line 10)
  2817. * mpf_cmp_ui: Float Comparison. (line 9)
  2818. * mpf_cmp_z: Float Comparison. (line 7)
  2819. * mpf_div: Float Arithmetic. (line 28)
  2820. * mpf_div_2exp: Float Arithmetic. (line 53)
  2821. * mpf_div_ui: Float Arithmetic. (line 31)
  2822. * mpf_eq: Float Comparison. (line 17)
  2823. * mpf_fits_sint_p: Miscellaneous Float Functions.
  2824. (line 19)
  2825. * mpf_fits_slong_p: Miscellaneous Float Functions.
  2826. (line 17)
  2827. * mpf_fits_sshort_p: Miscellaneous Float Functions.
  2828. (line 21)
  2829. * mpf_fits_uint_p: Miscellaneous Float Functions.
  2830. (line 18)
  2831. * mpf_fits_ulong_p: Miscellaneous Float Functions.
  2832. (line 16)
  2833. * mpf_fits_ushort_p: Miscellaneous Float Functions.
  2834. (line 20)
  2835. * mpf_floor: Miscellaneous Float Functions.
  2836. (line 7)
  2837. * mpf_get_d: Converting Floats. (line 6)
  2838. * mpf_get_default_prec: Initializing Floats. (line 11)
  2839. * mpf_get_d_2exp: Converting Floats. (line 15)
  2840. * mpf_get_prec: Initializing Floats. (line 61)
  2841. * mpf_get_si: Converting Floats. (line 27)
  2842. * mpf_get_str: Converting Floats. (line 36)
  2843. * mpf_get_ui: Converting Floats. (line 28)
  2844. * mpf_init: Initializing Floats. (line 18)
  2845. * mpf_init2: Initializing Floats. (line 25)
  2846. * mpf_inits: Initializing Floats. (line 30)
  2847. * mpf_init_set: Simultaneous Float Init & Assign.
  2848. (line 15)
  2849. * mpf_init_set_d: Simultaneous Float Init & Assign.
  2850. (line 18)
  2851. * mpf_init_set_si: Simultaneous Float Init & Assign.
  2852. (line 17)
  2853. * mpf_init_set_str: Simultaneous Float Init & Assign.
  2854. (line 24)
  2855. * mpf_init_set_ui: Simultaneous Float Init & Assign.
  2856. (line 16)
  2857. * mpf_inp_str: I/O of Floats. (line 38)
  2858. * mpf_integer_p: Miscellaneous Float Functions.
  2859. (line 13)
  2860. * mpf_mul: Float Arithmetic. (line 18)
  2861. * mpf_mul_2exp: Float Arithmetic. (line 49)
  2862. * mpf_mul_ui: Float Arithmetic. (line 19)
  2863. * mpf_neg: Float Arithmetic. (line 43)
  2864. * mpf_out_str: I/O of Floats. (line 17)
  2865. * mpf_pow_ui: Float Arithmetic. (line 39)
  2866. * mpf_random2: Miscellaneous Float Functions.
  2867. (line 35)
  2868. * mpf_reldiff: Float Comparison. (line 28)
  2869. * mpf_set: Assigning Floats. (line 9)
  2870. * mpf_set_d: Assigning Floats. (line 12)
  2871. * mpf_set_default_prec: Initializing Floats. (line 6)
  2872. * mpf_set_prec: Initializing Floats. (line 64)
  2873. * mpf_set_prec_raw: Initializing Floats. (line 71)
  2874. * mpf_set_q: Assigning Floats. (line 14)
  2875. * mpf_set_si: Assigning Floats. (line 11)
  2876. * mpf_set_str: Assigning Floats. (line 17)
  2877. * mpf_set_ui: Assigning Floats. (line 10)
  2878. * mpf_set_z: Assigning Floats. (line 13)
  2879. * mpf_sgn: Float Comparison. (line 33)
  2880. * mpf_sqrt: Float Arithmetic. (line 35)
  2881. * mpf_sqrt_ui: Float Arithmetic. (line 36)
  2882. * mpf_sub: Float Arithmetic. (line 11)
  2883. * mpf_sub_ui: Float Arithmetic. (line 14)
  2884. * mpf_swap: Assigning Floats. (line 50)
  2885. * mpf_t: Nomenclature and Types.
  2886. (line 21)
  2887. * mpf_trunc: Miscellaneous Float Functions.
  2888. (line 8)
  2889. * mpf_ui_div: Float Arithmetic. (line 29)
  2890. * mpf_ui_sub: Float Arithmetic. (line 12)
  2891. * mpf_urandomb: Miscellaneous Float Functions.
  2892. (line 25)
  2893. * mpn_add: Low-level Functions. (line 67)
  2894. * mpn_addmul_1: Low-level Functions. (line 148)
  2895. * mpn_add_1: Low-level Functions. (line 62)
  2896. * mpn_add_n: Low-level Functions. (line 52)
  2897. * mpn_andn_n: Low-level Functions. (line 462)
  2898. * mpn_and_n: Low-level Functions. (line 447)
  2899. * mpn_cmp: Low-level Functions. (line 293)
  2900. * mpn_cnd_add_n: Low-level Functions. (line 540)
  2901. * mpn_cnd_sub_n: Low-level Functions. (line 542)
  2902. * mpn_cnd_swap: Low-level Functions. (line 567)
  2903. * mpn_com: Low-level Functions. (line 487)
  2904. * mpn_copyd: Low-level Functions. (line 496)
  2905. * mpn_copyi: Low-level Functions. (line 492)
  2906. * mpn_divexact_1: Low-level Functions. (line 231)
  2907. * mpn_divexact_by3: Low-level Functions. (line 238)
  2908. * mpn_divexact_by3c: Low-level Functions. (line 240)
  2909. * mpn_divmod: Low-level Functions. (line 226)
  2910. * mpn_divmod_1: Low-level Functions. (line 210)
  2911. * mpn_divrem: Low-level Functions. (line 183)
  2912. * mpn_divrem_1: Low-level Functions. (line 208)
  2913. * mpn_gcd: Low-level Functions. (line 301)
  2914. * mpn_gcdext: Low-level Functions. (line 316)
  2915. * mpn_gcd_1: Low-level Functions. (line 311)
  2916. * mpn_get_str: Low-level Functions. (line 371)
  2917. * mpn_hamdist: Low-level Functions. (line 436)
  2918. * mpn_iorn_n: Low-level Functions. (line 467)
  2919. * mpn_ior_n: Low-level Functions. (line 452)
  2920. * mpn_lshift: Low-level Functions. (line 269)
  2921. * mpn_mod_1: Low-level Functions. (line 264)
  2922. * mpn_mul: Low-level Functions. (line 114)
  2923. * mpn_mul_1: Low-level Functions. (line 133)
  2924. * mpn_mul_n: Low-level Functions. (line 103)
  2925. * mpn_nand_n: Low-level Functions. (line 472)
  2926. * mpn_neg: Low-level Functions. (line 96)
  2927. * mpn_nior_n: Low-level Functions. (line 477)
  2928. * mpn_perfect_square_p: Low-level Functions. (line 442)
  2929. * mpn_popcount: Low-level Functions. (line 432)
  2930. * mpn_random: Low-level Functions. (line 422)
  2931. * mpn_random2: Low-level Functions. (line 423)
  2932. * mpn_rshift: Low-level Functions. (line 281)
  2933. * mpn_scan0: Low-level Functions. (line 406)
  2934. * mpn_scan1: Low-level Functions. (line 414)
  2935. * mpn_sec_add_1: Low-level Functions. (line 553)
  2936. * mpn_sec_div_qr: Low-level Functions. (line 629)
  2937. * mpn_sec_div_qr_itch: Low-level Functions. (line 632)
  2938. * mpn_sec_div_r: Low-level Functions. (line 648)
  2939. * mpn_sec_div_r_itch: Low-level Functions. (line 650)
  2940. * mpn_sec_invert: Low-level Functions. (line 664)
  2941. * mpn_sec_invert_itch: Low-level Functions. (line 666)
  2942. * mpn_sec_mul: Low-level Functions. (line 574)
  2943. * mpn_sec_mul_itch: Low-level Functions. (line 577)
  2944. * mpn_sec_powm: Low-level Functions. (line 604)
  2945. * mpn_sec_powm_itch: Low-level Functions. (line 607)
  2946. * mpn_sec_sqr: Low-level Functions. (line 590)
  2947. * mpn_sec_sqr_itch: Low-level Functions. (line 592)
  2948. * mpn_sec_sub_1: Low-level Functions. (line 555)
  2949. * mpn_sec_tabselect: Low-level Functions. (line 621)
  2950. * mpn_set_str: Low-level Functions. (line 386)
  2951. * mpn_sizeinbase: Low-level Functions. (line 364)
  2952. * mpn_sqr: Low-level Functions. (line 125)
  2953. * mpn_sqrtrem: Low-level Functions. (line 346)
  2954. * mpn_sub: Low-level Functions. (line 88)
  2955. * mpn_submul_1: Low-level Functions. (line 160)
  2956. * mpn_sub_1: Low-level Functions. (line 83)
  2957. * mpn_sub_n: Low-level Functions. (line 74)
  2958. * mpn_tdiv_qr: Low-level Functions. (line 172)
  2959. * mpn_xnor_n: Low-level Functions. (line 482)
  2960. * mpn_xor_n: Low-level Functions. (line 457)
  2961. * mpn_zero: Low-level Functions. (line 500)
  2962. * mpn_zero_p: Low-level Functions. (line 298)
  2963. * mpq_abs: Rational Arithmetic. (line 33)
  2964. * mpq_add: Rational Arithmetic. (line 6)
  2965. * mpq_canonicalize: Rational Number Functions.
  2966. (line 21)
  2967. * mpq_class: C++ Interface General.
  2968. (line 18)
  2969. * mpq_class::canonicalize: C++ Interface Rationals.
  2970. (line 41)
  2971. * mpq_class::get_d: C++ Interface Rationals.
  2972. (line 51)
  2973. * mpq_class::get_den: C++ Interface Rationals.
  2974. (line 67)
  2975. * mpq_class::get_den_mpz_t: C++ Interface Rationals.
  2976. (line 77)
  2977. * mpq_class::get_mpq_t: C++ Interface General.
  2978. (line 64)
  2979. * mpq_class::get_num: C++ Interface Rationals.
  2980. (line 66)
  2981. * mpq_class::get_num_mpz_t: C++ Interface Rationals.
  2982. (line 76)
  2983. * mpq_class::get_str: C++ Interface Rationals.
  2984. (line 52)
  2985. * mpq_class::mpq_class: C++ Interface Rationals.
  2986. (line 9)
  2987. * mpq_class::mpq_class <1>: C++ Interface Rationals.
  2988. (line 10)
  2989. * mpq_class::mpq_class <2>: C++ Interface Rationals.
  2990. (line 21)
  2991. * mpq_class::mpq_class <3>: C++ Interface Rationals.
  2992. (line 26)
  2993. * mpq_class::mpq_class <4>: C++ Interface Rationals.
  2994. (line 28)
  2995. * mpq_class::set_str: C++ Interface Rationals.
  2996. (line 54)
  2997. * mpq_class::set_str <1>: C++ Interface Rationals.
  2998. (line 55)
  2999. * mpq_class::swap: C++ Interface Rationals.
  3000. (line 58)
  3001. * mpq_clear: Initializing Rationals.
  3002. (line 15)
  3003. * mpq_clears: Initializing Rationals.
  3004. (line 19)
  3005. * mpq_cmp: Comparing Rationals. (line 6)
  3006. * mpq_cmp_si: Comparing Rationals. (line 16)
  3007. * mpq_cmp_ui: Comparing Rationals. (line 14)
  3008. * mpq_cmp_z: Comparing Rationals. (line 7)
  3009. * mpq_denref: Applying Integer Functions.
  3010. (line 16)
  3011. * mpq_div: Rational Arithmetic. (line 22)
  3012. * mpq_div_2exp: Rational Arithmetic. (line 26)
  3013. * mpq_equal: Comparing Rationals. (line 33)
  3014. * mpq_get_d: Rational Conversions.
  3015. (line 6)
  3016. * mpq_get_den: Applying Integer Functions.
  3017. (line 22)
  3018. * mpq_get_num: Applying Integer Functions.
  3019. (line 21)
  3020. * mpq_get_str: Rational Conversions.
  3021. (line 21)
  3022. * mpq_init: Initializing Rationals.
  3023. (line 6)
  3024. * mpq_inits: Initializing Rationals.
  3025. (line 11)
  3026. * mpq_inp_str: I/O of Rationals. (line 26)
  3027. * mpq_inv: Rational Arithmetic. (line 36)
  3028. * mpq_mul: Rational Arithmetic. (line 14)
  3029. * mpq_mul_2exp: Rational Arithmetic. (line 18)
  3030. * mpq_neg: Rational Arithmetic. (line 30)
  3031. * mpq_numref: Applying Integer Functions.
  3032. (line 15)
  3033. * mpq_out_str: I/O of Rationals. (line 17)
  3034. * mpq_set: Initializing Rationals.
  3035. (line 23)
  3036. * mpq_set_d: Rational Conversions.
  3037. (line 16)
  3038. * mpq_set_den: Applying Integer Functions.
  3039. (line 24)
  3040. * mpq_set_f: Rational Conversions.
  3041. (line 17)
  3042. * mpq_set_num: Applying Integer Functions.
  3043. (line 23)
  3044. * mpq_set_si: Initializing Rationals.
  3045. (line 29)
  3046. * mpq_set_str: Initializing Rationals.
  3047. (line 35)
  3048. * mpq_set_ui: Initializing Rationals.
  3049. (line 27)
  3050. * mpq_set_z: Initializing Rationals.
  3051. (line 24)
  3052. * mpq_sgn: Comparing Rationals. (line 27)
  3053. * mpq_sub: Rational Arithmetic. (line 10)
  3054. * mpq_swap: Initializing Rationals.
  3055. (line 54)
  3056. * mpq_t: Nomenclature and Types.
  3057. (line 16)
  3058. * mpz_2fac_ui: Number Theoretic Functions.
  3059. (line 109)
  3060. * mpz_abs: Integer Arithmetic. (line 44)
  3061. * mpz_add: Integer Arithmetic. (line 6)
  3062. * mpz_addmul: Integer Arithmetic. (line 24)
  3063. * mpz_addmul_ui: Integer Arithmetic. (line 26)
  3064. * mpz_add_ui: Integer Arithmetic. (line 7)
  3065. * mpz_and: Integer Logic and Bit Fiddling.
  3066. (line 10)
  3067. * mpz_array_init: Integer Special Functions.
  3068. (line 9)
  3069. * mpz_bin_ui: Number Theoretic Functions.
  3070. (line 120)
  3071. * mpz_bin_uiui: Number Theoretic Functions.
  3072. (line 122)
  3073. * mpz_cdiv_q: Integer Division. (line 12)
  3074. * mpz_cdiv_qr: Integer Division. (line 14)
  3075. * mpz_cdiv_qr_ui: Integer Division. (line 21)
  3076. * mpz_cdiv_q_2exp: Integer Division. (line 26)
  3077. * mpz_cdiv_q_ui: Integer Division. (line 17)
  3078. * mpz_cdiv_r: Integer Division. (line 13)
  3079. * mpz_cdiv_r_2exp: Integer Division. (line 29)
  3080. * mpz_cdiv_r_ui: Integer Division. (line 19)
  3081. * mpz_cdiv_ui: Integer Division. (line 23)
  3082. * mpz_class: C++ Interface General.
  3083. (line 17)
  3084. * mpz_class::fits_sint_p: C++ Interface Integers.
  3085. (line 50)
  3086. * mpz_class::fits_slong_p: C++ Interface Integers.
  3087. (line 51)
  3088. * mpz_class::fits_sshort_p: C++ Interface Integers.
  3089. (line 52)
  3090. * mpz_class::fits_uint_p: C++ Interface Integers.
  3091. (line 54)
  3092. * mpz_class::fits_ulong_p: C++ Interface Integers.
  3093. (line 55)
  3094. * mpz_class::fits_ushort_p: C++ Interface Integers.
  3095. (line 56)
  3096. * mpz_class::get_d: C++ Interface Integers.
  3097. (line 58)
  3098. * mpz_class::get_mpz_t: C++ Interface General.
  3099. (line 63)
  3100. * mpz_class::get_si: C++ Interface Integers.
  3101. (line 59)
  3102. * mpz_class::get_str: C++ Interface Integers.
  3103. (line 60)
  3104. * mpz_class::get_ui: C++ Interface Integers.
  3105. (line 61)
  3106. * mpz_class::mpz_class: C++ Interface Integers.
  3107. (line 6)
  3108. * mpz_class::mpz_class <1>: C++ Interface Integers.
  3109. (line 14)
  3110. * mpz_class::mpz_class <2>: C++ Interface Integers.
  3111. (line 19)
  3112. * mpz_class::mpz_class <3>: C++ Interface Integers.
  3113. (line 21)
  3114. * mpz_class::set_str: C++ Interface Integers.
  3115. (line 63)
  3116. * mpz_class::set_str <1>: C++ Interface Integers.
  3117. (line 64)
  3118. * mpz_class::swap: C++ Interface Integers.
  3119. (line 71)
  3120. * mpz_clear: Initializing Integers.
  3121. (line 48)
  3122. * mpz_clears: Initializing Integers.
  3123. (line 52)
  3124. * mpz_clrbit: Integer Logic and Bit Fiddling.
  3125. (line 54)
  3126. * mpz_cmp: Integer Comparisons. (line 6)
  3127. * mpz_cmpabs: Integer Comparisons. (line 17)
  3128. * mpz_cmpabs_d: Integer Comparisons. (line 18)
  3129. * mpz_cmpabs_ui: Integer Comparisons. (line 19)
  3130. * mpz_cmp_d: Integer Comparisons. (line 7)
  3131. * mpz_cmp_si: Integer Comparisons. (line 8)
  3132. * mpz_cmp_ui: Integer Comparisons. (line 9)
  3133. * mpz_com: Integer Logic and Bit Fiddling.
  3134. (line 19)
  3135. * mpz_combit: Integer Logic and Bit Fiddling.
  3136. (line 57)
  3137. * mpz_congruent_2exp_p: Integer Division. (line 148)
  3138. * mpz_congruent_p: Integer Division. (line 144)
  3139. * mpz_congruent_ui_p: Integer Division. (line 146)
  3140. * mpz_divexact: Integer Division. (line 122)
  3141. * mpz_divexact_ui: Integer Division. (line 123)
  3142. * mpz_divisible_2exp_p: Integer Division. (line 135)
  3143. * mpz_divisible_p: Integer Division. (line 132)
  3144. * mpz_divisible_ui_p: Integer Division. (line 133)
  3145. * mpz_even_p: Miscellaneous Integer Functions.
  3146. (line 17)
  3147. * mpz_export: Integer Import and Export.
  3148. (line 43)
  3149. * mpz_fac_ui: Number Theoretic Functions.
  3150. (line 108)
  3151. * mpz_fdiv_q: Integer Division. (line 33)
  3152. * mpz_fdiv_qr: Integer Division. (line 35)
  3153. * mpz_fdiv_qr_ui: Integer Division. (line 42)
  3154. * mpz_fdiv_q_2exp: Integer Division. (line 47)
  3155. * mpz_fdiv_q_ui: Integer Division. (line 38)
  3156. * mpz_fdiv_r: Integer Division. (line 34)
  3157. * mpz_fdiv_r_2exp: Integer Division. (line 50)
  3158. * mpz_fdiv_r_ui: Integer Division. (line 40)
  3159. * mpz_fdiv_ui: Integer Division. (line 44)
  3160. * mpz_fib2_ui: Number Theoretic Functions.
  3161. (line 130)
  3162. * mpz_fib_ui: Number Theoretic Functions.
  3163. (line 129)
  3164. * mpz_fits_sint_p: Miscellaneous Integer Functions.
  3165. (line 9)
  3166. * mpz_fits_slong_p: Miscellaneous Integer Functions.
  3167. (line 7)
  3168. * mpz_fits_sshort_p: Miscellaneous Integer Functions.
  3169. (line 11)
  3170. * mpz_fits_uint_p: Miscellaneous Integer Functions.
  3171. (line 8)
  3172. * mpz_fits_ulong_p: Miscellaneous Integer Functions.
  3173. (line 6)
  3174. * mpz_fits_ushort_p: Miscellaneous Integer Functions.
  3175. (line 10)
  3176. * mpz_gcd: Number Theoretic Functions.
  3177. (line 25)
  3178. * mpz_gcdext: Number Theoretic Functions.
  3179. (line 41)
  3180. * mpz_gcd_ui: Number Theoretic Functions.
  3181. (line 31)
  3182. * mpz_getlimbn: Integer Special Functions.
  3183. (line 22)
  3184. * mpz_get_d: Converting Integers. (line 26)
  3185. * mpz_get_d_2exp: Converting Integers. (line 34)
  3186. * mpz_get_si: Converting Integers. (line 17)
  3187. * mpz_get_str: Converting Integers. (line 46)
  3188. * mpz_get_ui: Converting Integers. (line 10)
  3189. * mpz_hamdist: Integer Logic and Bit Fiddling.
  3190. (line 28)
  3191. * mpz_import: Integer Import and Export.
  3192. (line 9)
  3193. * mpz_init: Initializing Integers.
  3194. (line 25)
  3195. * mpz_init2: Initializing Integers.
  3196. (line 32)
  3197. * mpz_inits: Initializing Integers.
  3198. (line 28)
  3199. * mpz_init_set: Simultaneous Integer Init & Assign.
  3200. (line 26)
  3201. * mpz_init_set_d: Simultaneous Integer Init & Assign.
  3202. (line 29)
  3203. * mpz_init_set_si: Simultaneous Integer Init & Assign.
  3204. (line 28)
  3205. * mpz_init_set_str: Simultaneous Integer Init & Assign.
  3206. (line 33)
  3207. * mpz_init_set_ui: Simultaneous Integer Init & Assign.
  3208. (line 27)
  3209. * mpz_inp_raw: I/O of Integers. (line 61)
  3210. * mpz_inp_str: I/O of Integers. (line 30)
  3211. * mpz_invert: Number Theoretic Functions.
  3212. (line 68)
  3213. * mpz_ior: Integer Logic and Bit Fiddling.
  3214. (line 13)
  3215. * mpz_jacobi: Number Theoretic Functions.
  3216. (line 78)
  3217. * mpz_kronecker: Number Theoretic Functions.
  3218. (line 86)
  3219. * mpz_kronecker_si: Number Theoretic Functions.
  3220. (line 87)
  3221. * mpz_kronecker_ui: Number Theoretic Functions.
  3222. (line 88)
  3223. * mpz_lcm: Number Theoretic Functions.
  3224. (line 61)
  3225. * mpz_lcm_ui: Number Theoretic Functions.
  3226. (line 62)
  3227. * mpz_legendre: Number Theoretic Functions.
  3228. (line 81)
  3229. * mpz_limbs_finish: Integer Special Functions.
  3230. (line 47)
  3231. * mpz_limbs_modify: Integer Special Functions.
  3232. (line 40)
  3233. * mpz_limbs_read: Integer Special Functions.
  3234. (line 34)
  3235. * mpz_limbs_write: Integer Special Functions.
  3236. (line 39)
  3237. * mpz_lucnum2_ui: Number Theoretic Functions.
  3238. (line 141)
  3239. * mpz_lucnum_ui: Number Theoretic Functions.
  3240. (line 140)
  3241. * mpz_mfac_uiui: Number Theoretic Functions.
  3242. (line 110)
  3243. * mpz_mod: Integer Division. (line 112)
  3244. * mpz_mod_ui: Integer Division. (line 113)
  3245. * mpz_mul: Integer Arithmetic. (line 18)
  3246. * mpz_mul_2exp: Integer Arithmetic. (line 36)
  3247. * mpz_mul_si: Integer Arithmetic. (line 19)
  3248. * mpz_mul_ui: Integer Arithmetic. (line 20)
  3249. * mpz_neg: Integer Arithmetic. (line 41)
  3250. * mpz_nextprime: Number Theoretic Functions.
  3251. (line 18)
  3252. * mpz_odd_p: Miscellaneous Integer Functions.
  3253. (line 16)
  3254. * mpz_out_raw: I/O of Integers. (line 45)
  3255. * mpz_out_str: I/O of Integers. (line 17)
  3256. * mpz_perfect_power_p: Integer Roots. (line 27)
  3257. * mpz_perfect_square_p: Integer Roots. (line 36)
  3258. * mpz_popcount: Integer Logic and Bit Fiddling.
  3259. (line 22)
  3260. * mpz_powm: Integer Exponentiation.
  3261. (line 6)
  3262. * mpz_powm_sec: Integer Exponentiation.
  3263. (line 16)
  3264. * mpz_powm_ui: Integer Exponentiation.
  3265. (line 8)
  3266. * mpz_pow_ui: Integer Exponentiation.
  3267. (line 29)
  3268. * mpz_primorial_ui: Number Theoretic Functions.
  3269. (line 116)
  3270. * mpz_probab_prime_p: Number Theoretic Functions.
  3271. (line 6)
  3272. * mpz_random: Integer Random Numbers.
  3273. (line 41)
  3274. * mpz_random2: Integer Random Numbers.
  3275. (line 50)
  3276. * mpz_realloc2: Initializing Integers.
  3277. (line 56)
  3278. * mpz_remove: Number Theoretic Functions.
  3279. (line 102)
  3280. * mpz_roinit_n: Integer Special Functions.
  3281. (line 67)
  3282. * MPZ_ROINIT_N: Integer Special Functions.
  3283. (line 83)
  3284. * mpz_root: Integer Roots. (line 6)
  3285. * mpz_rootrem: Integer Roots. (line 12)
  3286. * mpz_rrandomb: Integer Random Numbers.
  3287. (line 29)
  3288. * mpz_scan0: Integer Logic and Bit Fiddling.
  3289. (line 35)
  3290. * mpz_scan1: Integer Logic and Bit Fiddling.
  3291. (line 37)
  3292. * mpz_set: Assigning Integers. (line 9)
  3293. * mpz_setbit: Integer Logic and Bit Fiddling.
  3294. (line 51)
  3295. * mpz_set_d: Assigning Integers. (line 12)
  3296. * mpz_set_f: Assigning Integers. (line 14)
  3297. * mpz_set_q: Assigning Integers. (line 13)
  3298. * mpz_set_si: Assigning Integers. (line 11)
  3299. * mpz_set_str: Assigning Integers. (line 20)
  3300. * mpz_set_ui: Assigning Integers. (line 10)
  3301. * mpz_sgn: Integer Comparisons. (line 27)
  3302. * mpz_size: Integer Special Functions.
  3303. (line 30)
  3304. * mpz_sizeinbase: Miscellaneous Integer Functions.
  3305. (line 22)
  3306. * mpz_si_kronecker: Number Theoretic Functions.
  3307. (line 89)
  3308. * mpz_sqrt: Integer Roots. (line 17)
  3309. * mpz_sqrtrem: Integer Roots. (line 20)
  3310. * mpz_sub: Integer Arithmetic. (line 11)
  3311. * mpz_submul: Integer Arithmetic. (line 30)
  3312. * mpz_submul_ui: Integer Arithmetic. (line 32)
  3313. * mpz_sub_ui: Integer Arithmetic. (line 12)
  3314. * mpz_swap: Assigning Integers. (line 36)
  3315. * mpz_t: Nomenclature and Types.
  3316. (line 6)
  3317. * mpz_tdiv_q: Integer Division. (line 54)
  3318. * mpz_tdiv_qr: Integer Division. (line 56)
  3319. * mpz_tdiv_qr_ui: Integer Division. (line 63)
  3320. * mpz_tdiv_q_2exp: Integer Division. (line 68)
  3321. * mpz_tdiv_q_ui: Integer Division. (line 59)
  3322. * mpz_tdiv_r: Integer Division. (line 55)
  3323. * mpz_tdiv_r_2exp: Integer Division. (line 71)
  3324. * mpz_tdiv_r_ui: Integer Division. (line 61)
  3325. * mpz_tdiv_ui: Integer Division. (line 65)
  3326. * mpz_tstbit: Integer Logic and Bit Fiddling.
  3327. (line 60)
  3328. * mpz_ui_kronecker: Number Theoretic Functions.
  3329. (line 90)
  3330. * mpz_ui_pow_ui: Integer Exponentiation.
  3331. (line 31)
  3332. * mpz_ui_sub: Integer Arithmetic. (line 14)
  3333. * mpz_urandomb: Integer Random Numbers.
  3334. (line 12)
  3335. * mpz_urandomm: Integer Random Numbers.
  3336. (line 21)
  3337. * mpz_xor: Integer Logic and Bit Fiddling.
  3338. (line 16)
  3339. * mp_bitcnt_t: Nomenclature and Types.
  3340. (line 42)
  3341. * mp_bits_per_limb: Useful Macros and Constants.
  3342. (line 7)
  3343. * mp_exp_t: Nomenclature and Types.
  3344. (line 27)
  3345. * mp_get_memory_functions: Custom Allocation. (line 86)
  3346. * mp_limb_t: Nomenclature and Types.
  3347. (line 31)
  3348. * mp_set_memory_functions: Custom Allocation. (line 14)
  3349. * mp_size_t: Nomenclature and Types.
  3350. (line 37)
  3351. * operator"": C++ Interface Integers.
  3352. (line 29)
  3353. * operator"" <1>: C++ Interface Rationals.
  3354. (line 36)
  3355. * operator"" <2>: C++ Interface Floats.
  3356. (line 55)
  3357. * operator%: C++ Interface Integers.
  3358. (line 34)
  3359. * operator/: C++ Interface Integers.
  3360. (line 33)
  3361. * operator<<: C++ Formatted Output.
  3362. (line 10)
  3363. * operator<< <1>: C++ Formatted Output.
  3364. (line 19)
  3365. * operator<< <2>: C++ Formatted Output.
  3366. (line 32)
  3367. * operator>>: C++ Formatted Input. (line 10)
  3368. * operator>> <1>: C++ Formatted Input. (line 13)
  3369. * operator>> <2>: C++ Formatted Input. (line 24)
  3370. * operator>> <3>: C++ Interface Rationals.
  3371. (line 86)
  3372. * sgn: C++ Interface Integers.
  3373. (line 65)
  3374. * sgn <1>: C++ Interface Rationals.
  3375. (line 56)
  3376. * sgn <2>: C++ Interface Floats.
  3377. (line 106)
  3378. * sqrt: C++ Interface Integers.
  3379. (line 66)
  3380. * sqrt <1>: C++ Interface Floats.
  3381. (line 107)
  3382. * swap: C++ Interface Integers.
  3383. (line 72)
  3384. * swap <1>: C++ Interface Rationals.
  3385. (line 59)
  3386. * swap <2>: C++ Interface Floats.
  3387. (line 110)
  3388. * trunc: C++ Interface Floats.
  3389. (line 111)