├── src ├── gmp │ ├── utils.nim.cfg │ ├── extratypes.nim │ ├── utils.nim │ └── header.nim └── gmp.nim ├── gmp.nimble ├── examples ├── gmp_ex2.nim ├── gmp_ex1.nim └── pidigits.nim ├── README ├── COPYING ├── refactor.nim ├── COPYING.LESSERv3 ├── COPYINGv2 ├── gmp.h.done └── gmp.nim /src/gmp/utils.nim.cfg: -------------------------------------------------------------------------------- 1 | path: ".." 2 | -------------------------------------------------------------------------------- /src/gmp.nim: -------------------------------------------------------------------------------- 1 | {.push warning[user]: off.} 2 | when defined(USE_GMP_HEADER): 3 | include gmp/header 4 | else: 5 | include gmp/pure 6 | {.pop.} 7 | -------------------------------------------------------------------------------- /src/gmp/extratypes.nim: -------------------------------------------------------------------------------- 1 | ## some extra type aliases that are common to header and pure 2 | type 3 | mpz* = mm_mpz_struct 4 | mpf* = mm_mpf_struct 5 | mpq* = mm_mpq_struct 6 | 7 | -------------------------------------------------------------------------------- /gmp.nimble: -------------------------------------------------------------------------------- 1 | [Package] 2 | name = "nim-gmp" 3 | version = "0.2.4" 4 | author = "Will Szumski" 5 | description = "Wrapper for the GNU Multiple Precision Arithmetic Library (GMP)" 6 | license = "MIT" 7 | srcDir = "src" 8 | InstallExt = "nim" 9 | 10 | [Deps] 11 | Requires: "nimrod >= 0.9.4" 12 | -------------------------------------------------------------------------------- /examples/gmp_ex2.nim: -------------------------------------------------------------------------------- 1 | ## example showing simple addition. This one reallys shows the power of 2 | ## of big ints: we calculate a number equal to 25 - normally you would run out 3 | ## of fingers when calculating this! 4 | 5 | import gmp 6 | import gmp/utils 7 | 8 | var res = init_mpz() # initialized to zero 9 | let x: mpz = 10 # convert int to mpz_t 10 | let y = init_mpz("15",10) # construct from string (base: 10) 11 | 12 | mpz_add(res,x,y) 13 | 14 | # a few comparisons for good measure 15 | assert x < y 16 | assert x != y 17 | 18 | echo res # prints 25 19 | -------------------------------------------------------------------------------- /examples/gmp_ex1.nim: -------------------------------------------------------------------------------- 1 | ## WARNING: This example is not friendly on the eyes and should 2 | ## probably be ignored. It was used to test basic functionality of 3 | ## the wrapper 4 | 5 | import gmp 6 | 7 | var 8 | a,b: mpz_t 9 | 10 | #converter toPtr(a: var mpz_t): mpz_ptr = 11 | # cast[mpz_ptr](a.addr) 12 | 13 | discard mpz_init_set_str(a.addr,"10",10) 14 | discard mpz_init_set_str(b.addr,"1000000000",10) 15 | mpz_add(a.addr,a.addr,b.addr) 16 | echo mpz_get_str(nil,10,a.addr) 17 | 18 | echo sizeof(mp_limb_t) 19 | echo sizeof(mp_limb_signed_t) 20 | echo sizeof(mp_bitcnt_t) 21 | -------------------------------------------------------------------------------- /examples/pidigits.nim: -------------------------------------------------------------------------------- 1 | ## pidigits from computer language benchmark game 2 | ## ported from original c version by Mr Ledrug, see: 3 | ## http://benchmarksgame.alioth.debian.org/u64q/program.php?test=pidigits&lang=gcc&id=1 4 | 5 | import gmp 6 | import gmp/utils 7 | import unsigned 8 | import strutils 9 | import os 10 | 11 | var 12 | tmp1, tmp2, acc, den, num: mpz_t 13 | 14 | proc extract_digit(nth: culong): culong = 15 | # joggling between tmp1 and tmp2, so GMP won't have to use temp buffers 16 | mpz_mul_ui(tmp1, num, nth) 17 | mpz_add(tmp2, tmp1, acc) 18 | mpz_tdiv_q(tmp1, tmp2, den) 19 | result = mpz_get_ui(tmp1) 20 | 21 | proc eliminate_digit(d: culong) = 22 | mpz_submul_ui(acc, den, d) 23 | mpz_mul_ui(acc, acc, 10) 24 | mpz_mul_ui(num, num, 10) 25 | 26 | 27 | proc next_term(k: culong) = 28 | var k2: culong = k * 2 + 1 29 | mpz_addmul_ui(acc, num, 2) 30 | mpz_mul_ui(acc, acc, k2) 31 | mpz_mul_ui(den, den, k2) 32 | mpz_mul_ui(num, num, k) 33 | 34 | proc main = 35 | var d, k: culong 36 | var i: uint64 37 | var n: int = parseInt paramStr(1) 38 | 39 | mpz_init(tmp1) 40 | mpz_init(tmp2) 41 | 42 | mpz_init_set_ui(acc, 0) 43 | mpz_init_set_ui(den, 1) 44 | mpz_init_set_ui(num, 1) 45 | 46 | while(i < n.uint64): 47 | k.inc 48 | next_term(k) 49 | if mpz_cmp(num, acc) > 0: 50 | continue 51 | 52 | d = extract_digit(3) 53 | if d != extract_digit(4): 54 | continue 55 | stdout.write(chr(ord('0').uint64 + d)) 56 | i.inc 57 | if (i mod 10'u64).uint64 == 0'u64: echo "\t:" & $i 58 | eliminate_digit(d) 59 | 60 | main() 61 | 62 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Wrapper for the GNU multiple precision arithmetic library (GMP). The wrapper itself is licensed under the MIT license. GMP is licensed as follows: 2 | 3 | This library is free; this means that everyone is free to use it and free to redistribute it on a free basis. The library is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of this library that they might get from you. 4 | 5 | Specifically, we want to make sure that you have the right to give away copies of the library, that you receive source code or else can get it if you want it, that you can change this library or use pieces of it in new free programs, and that you know you can do these things. 6 | 7 | To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of the GNU MP library, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. 8 | 9 | Also, for our own protection, we must make certain that everyone finds out that there is no warranty for the GNU MP library. If it is modified by someone else and passed on, we want their recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation. 10 | 11 | More precisely, the GNU MP library is dual licensed, under the conditions of the GNU Lesser General Public License version 3 (see COPYING.LESSERv3), or the GNU General Public License version 2 (see COPYINGv2). This is the recipient's choice, and the recipient also has the additional option of applying later versions of these licenses. (The reason for this dual licensing is to make it possible to use the library with programs which are licensed under GPL version 2, but which for historical or other reasons do not allow use under later versions of the GPL). 12 | 13 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | 2 | LICENSE FOR WRAPPER ONLY: 3 | 4 | The MIT License (MIT) 5 | 6 | Copyright (c) <2014> 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy 9 | of this software and associated documentation files (the "Software"), to deal 10 | in the Software without restriction, including without limitation the rights 11 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | copies of the Software, and to permit persons to whom the Software is 13 | furnished to do so, subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be included in 16 | all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | THE SOFTWARE. 25 | 26 | LICENSE FOR GNU multiple precision arithmetic library: 27 | 28 | This library is free; this means that everyone is free to use it and free to redistribute it on a free basis. The library is not in the public domain; it is copyrighted and there are restrictions on its distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of this library that they might get from you. 29 | 30 | Specifically, we want to make sure that you have the right to give away copies of the library, that you receive source code or else can get it if you want it, that you can change this library or use pieces of it in new free programs, and that you know you can do these things. 31 | 32 | To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of the GNU MP library, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. 33 | 34 | Also, for our own protection, we must make certain that everyone finds out that there is no warranty for the GNU MP library. If it is modified by someone else and passed on, we want their recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation. 35 | 36 | More precisely, the GNU MP library is dual licensed, under the conditions of the GNU Lesser General Public License version 3 (see COPYING.LESSERv3), or the GNU General Public License version 2 (see COPYINGv2). This is the recipient's choice, and the recipient also has the additional option of applying later versions of these licenses. (The reason for this dual licensing is to make it possible to use the library with programs which are licensed under GPL version 2, but which for historical or other reasons do not allow use under later versions of the GPL). 37 | -------------------------------------------------------------------------------- /refactor.nim: -------------------------------------------------------------------------------- 1 | import macros 2 | import strutils 3 | import tables 4 | 5 | const file = "gmp.nim" 6 | const dynlib = "libgmp" 7 | let symbols {.compileTime.} = gorge("nm -A -D /usr/lib/libgmp.so") 8 | var libFuncs {.compileTime.} = newSeq[string]() # stores gmp dll function names 9 | 10 | static: 11 | for line in symbols.split("\n"): 12 | var t = line.split() 13 | libFuncs.add t[t.high].strip 14 | 15 | 16 | proc mkVar(properType: string): PNimrodNode {.compileTime.} = 17 | newNimNode(nnkVarTy).add(ident(properType)) 18 | 19 | proc mkLet(properType: string): PNimrodNode {.compileTime.} = 20 | ident(properType) 21 | 22 | 23 | # src ptrs are const so map to let 24 | # else map to var 25 | # need to set mpz_t etc. to byref with pragma 26 | let mappings {.compileTime.} = { 27 | "mpz_srcptr" : mkLet "mpz_t", 28 | "mpz_ptr" : mkVar "mpz_t", 29 | "mpf_srcptr" : mkLet "mpf_t", 30 | "mpf_ptr" : mkVar "mpf_t", 31 | "mpq_srcptr" : mkLet "mpq_t", 32 | "mpq_ptr" : mkVar "mpq_t", 33 | "mp_ptr" : mkVar "mp_limb_t", # byref doesn't work for clong so should always be var 34 | "mp_srcptr" : mkVar "mp_limb_t", 35 | }.toTable 36 | 37 | proc mkPragma(a: varargs[string]): PNimrodNode {.compileTime.} = 38 | result = newNimNode(nnkPragma) 39 | for str in a: 40 | result.add(ident(str)) 41 | 42 | 43 | let stdPrag {.compileTime.} = mkPragma("pure", "packed") 44 | let byrefPrag {.compileTime.} = mkPragma("byref", "pure", "packed") 45 | 46 | let specialTypes {.compileTime.} = { 47 | "mm_mpz_struct": byrefPrag, 48 | "mm_mpf_struct": byrefPrag, 49 | "mm_mpq_struct": byrefPrag, 50 | }.toTable 51 | 52 | 53 | let oldCodeTxt {.compileTime.} = slurp(file) 54 | var oldCode {.compileTime.} = parseStmt(oldCodeTxt) 55 | 56 | proc getDynlibName(name: string): string {.compileTime.} = 57 | result = "" 58 | for func in libFuncs: 59 | #if nameInHeader in func: # too many iterations 60 | if func.endsWith name: 61 | return func 62 | 63 | macro fix_types(): stmt = 64 | ## changes pragmas from header style to dynlib style 65 | var newCode = oldCode.copy() 66 | var newTypeSection: PNimrodNode 67 | var index = 0 68 | for child in oldCode.children: 69 | if child.kind == nnkTypeSection: 70 | newTypeSection = child.copy() 71 | var newTypeDef: PNimrodNode 72 | var typeDefIndex = -1 73 | for typChild in child.children: 74 | inc typeDefIndex 75 | if typChild.kind == nnkTypeDef: 76 | newTypeDef = typChild.copy() 77 | var pragmaIndex = -1 78 | var pragExpr = newTypeDef.findChild((inc pragmaIndex; it.kind == nnkPragmaExpr)) 79 | if pragExpr == nil: continue 80 | 81 | # this assumes it's exported (I think) 82 | let post = pragExpr.findChild(it.kind == nnkPostfix) 83 | if post == nil: continue 84 | var name = $post[1] 85 | 86 | # change pragmas 87 | if specialTypes.hasKey(name): 88 | pragExpr[1] = specialTypes[name] 89 | newTypeDef[0] = pragExpr 90 | elif typChild[2].kind == nnkObjectTy: 91 | pragExpr[1] = stdPrag 92 | newTypeDef[0] = pragExpr 93 | else: 94 | # remove pragma - moves postfix node to pragExpr position 95 | newTypeDef[0] = post 96 | 97 | # remove pragmas from fields of objects 98 | if typChild[2].kind == nnkObjectTy: 99 | var recList = newTypeDef[2].findChild(it.kind == nnkRecList) 100 | for i in 0.. 1 and (identDefs[1].kind == nnkIdent or identDefs[1].kind == nnkPtrTy): 178 | let paramType = repr identDefs[1] # string value 179 | if mappings.hasKey paramType: 180 | keyFound = true 181 | let val = mappings[paramType] 182 | var identDefsMod = identDefs.copy() 183 | identDefsMod[1] = val.copy() 184 | newParams[index] = identDefsMod 185 | var procDef = child.copy() 186 | procdef[3] = newParams 187 | newCode.add child 188 | if child.repr != procDef.repr: 189 | newCode.add procDef 190 | elif keyFound: 191 | warning("generated dupe") 192 | echo(child.repr) 193 | else: 194 | newCode.add child 195 | # swap to new code 196 | oldCode = newCode 197 | 198 | macro print(): stmt = 199 | result = newStmtList() 200 | for child in oldCode.children: 201 | result.add newCall("echo", child.toStrLit) 202 | 203 | 204 | fix_types() 205 | fix_importc() 206 | nimify_params() 207 | print() 208 | 209 | 210 | discard """ static: 211 | if mappings.hasKey "mpz_srcptr": 212 | echo "ok" 213 | else: 214 | echo "not ok" 215 | """ 216 | -------------------------------------------------------------------------------- /COPYING.LESSERv3: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /src/gmp/utils.nim: -------------------------------------------------------------------------------- 1 | import gmp 2 | import math 3 | 4 | {.deadCodeElim: on.} 5 | {.push hints: off.} 6 | {.experimental.} 7 | 8 | ################################################################################ 9 | # multi-precision ints 10 | ################################################################################ 11 | 12 | 13 | proc finalise(a: ref mpz_t) = 14 | mpz_clear(a[]) 15 | 16 | proc new_mpz*(): ref mpz_t = 17 | new(result,finalise) 18 | mpz_init(result[]) 19 | 20 | proc init_mpz*(): mpz_t = 21 | mpz_init(result) 22 | 23 | #converter toPtr*(a: var mpz_t): ptr mpz_t = 24 | # a.addr 25 | 26 | proc init_mpz*(enc: string, base: cint = 10): mpz_t = 27 | if mpz_init_set_str(result,enc, base) != 0: 28 | raise newException(ValueError,enc & " represents an invalid value") 29 | 30 | converter convert*(a: int): mpz_t = 31 | when sizeof(clong) != sizeof(int): # LLP64 programming model 32 | mpz_init(result) 33 | if a < 0: result.mp_size = -1 else: result.mp_size = (a != 0).cint 34 | if a < 0 and a > low(int): 35 | result.mp_d[] = (-a).mp_limb_t 36 | else: 37 | result.mp_d[] = a.mp_limb_t 38 | else: 39 | mpz_init_set_si(result, a) 40 | 41 | converter convert*(a: mpf_t): mpz_t = 42 | result = init_mpz() 43 | mpz_set_f(result, a) 44 | 45 | proc to_mpz*(a: mpf_t): mpz_t = 46 | result = init_mpz() 47 | mpz_set_f(result, a) 48 | 49 | proc to_mpz*(a: clong): mpz_t = 50 | mpz_init_set_si(result,a) 51 | 52 | proc init_mpz*(val: clong): mpz_t = 53 | mpz_init_set_si(result,val) 54 | 55 | proc new_mpz*(val: clong): ref mpz_t = 56 | new(result,finalise) 57 | mpz_init_set_si(result[],val) 58 | 59 | template mpz_p*(a: clong{lit}): mpz_ptr {.deprecated.} = 60 | # weird interaction with destructor, so use new for now 61 | # should stay alive whilst in scope, hence inject 62 | var temp = new_mpz(a) 63 | temp[].addr 64 | 65 | proc new_mpz*(enc: string, base: cint = 10): ref mpz_t = 66 | new(result,finalise) 67 | if mpz_init_set_str(result[],enc, base) != 0: 68 | raise newException(ValueError,enc & " represents an invalid value") 69 | 70 | #NOTE: default params don't work with static 71 | proc alloc_mpz_t*(shared: static[bool]): ptr mpz_t = 72 | when shared: 73 | #FIXME: U variant doesn't compile at the moment 74 | result = createShared(mpz_t,sizeof(mpz_t)) 75 | else: 76 | result = cast[ptr mpz_t](alloc0(sizeof(mpz_t))) 77 | mpz_init(result) 78 | 79 | proc dealloc_mpz_t*(a: ptr mpz_t, shared: static[bool]) = 80 | mpz_clear(a) 81 | when shared: 82 | # FIXME: freeShared currently bugged (won't compile) 83 | discard reallocShared(a,0) 84 | else: 85 | dealloc(a) 86 | 87 | proc `==`*(a,b: mpz_t): bool = 88 | return mpz_cmp(a,b) == 0 89 | 90 | proc `<`*(a,b: mpz_t): bool = 91 | return mpz_cmp(a,b) < 0 92 | 93 | proc `<=`*(a,b: mpz_t): bool = 94 | let t = mpz_cmp(a,b) 95 | t < 0 or t == 0 96 | 97 | proc cmp*(a,b: mpz_t): int = 98 | return mpz_cmp(a,b) 99 | 100 | proc `$`*(a: mpz_t, base: cint = 10): string = 101 | result = newString(mpz_sizeinbase(a, base) + 1) 102 | return $mpz_get_str(result,base,a) 103 | 104 | proc `$`*(a: ptr mpz_t, base: cint = 10): string = 105 | result = newString(mpz_sizeinbase(a, base) + 1) 106 | return $mpz_get_str(result,base,a) 107 | 108 | proc copy*(a: mpz_t): mpz_t = 109 | ## you must use this function in instead of assignment 110 | mpz_set(result,a) 111 | return result 112 | 113 | # careful when copying values!!! 114 | proc destroy*(a: var mpz_t) {.destructor.} = 115 | mpz_clear(a) 116 | 117 | 118 | ################################################################################ 119 | # multi-precision floats 120 | ################################################################################ 121 | 122 | proc finalise(a: ref mpf_t) = 123 | mpf_clear(a[]) 124 | 125 | proc init_mpf*(): mpf_t = 126 | mpf_init(result) 127 | 128 | proc init_mpf*(enc: string, base: cint = 10): mpf_t = 129 | ## Set the value of rop from the string in str. The string is of the form ‘M@N’ 130 | ## or, if the base is 10 or less, alternatively ‘MeN’. ‘M’ is the mantissa and 131 | ## ‘N’ is the exponent. The # mantissa is always in the specified base. The 132 | ## exponent is either in the specified base or, if base is negative, in decimal. 133 | ## The decimal point expected is taken from the current locale, on systems 134 | ## providing localeconv. 135 | ## 136 | ## The argument base may be in the ranges 2 to 62, or −62 to −2. Negative values 137 | ## are used to specify that the exponent is in decimal. 138 | ## 139 | ## For bases up to 36, case is ignored; upper-case and lower-case letters have the 140 | ## same value; for bases 37 to 62, upper-case letter represent the usual 10..35 141 | ## while lower-case letter represent 36..61. 142 | ## 143 | ## Unlike the corresponding mpz function, the base will not be determined from the 144 | ## leading characters of the string if base is 0. This is so that numbers like 145 | ## ‘0.23’ are not interpreted as octal. 146 | ## 147 | ## White space is allowed in the string, and is simply ignored. [This is not really 148 | ## true; white-space is ignored in the beginning of the string and within the 149 | ## mantissa, but not in other places, such as after a minus sign or in the exponent. 150 | if mpf_init_set_str(result,enc,base) != 0: 151 | # have to free memory even on failure 152 | mpf_clear(result) 153 | raise newException(ValueError,enc & " represents an invalid value") 154 | 155 | proc init_mpf*(val: float): mpf_t = 156 | mpf_init_set_d(result,val) 157 | 158 | proc new_mpf*(val: float): ref mpf_t = 159 | new(result,finalise) 160 | mpf_init_set_d(result[],val) 161 | 162 | proc init_mpf*(val: clong): mpf_t = 163 | mpf_init_set_si(result,val) 164 | 165 | proc to_mpf*(a: float): mpf_t = 166 | result = init_mpf(a) 167 | 168 | template mpf_p*(a: float{lit}): mpf_ptr {.deprecated.} = 169 | ## no longer used now we have nimified function params 170 | # inject so it is finalised when goes out of scope 171 | var temp = new_mpf(a) 172 | temp[].addr 173 | 174 | proc to_mpf*(a: mpz_t): mpf_t = 175 | result = init_mpf() 176 | mpf_set_z(result,a) 177 | 178 | #converter toPtr*(a: var mpf_t): ptr mpf_t = 179 | # a.addr 180 | 181 | converter convert*(a: float): mpf_t = 182 | a.toMpf 183 | 184 | proc copy*(a: mpf_t): mpf_t = 185 | ## you must use this function instead of assignment 186 | mpf_set(result,a) 187 | return result 188 | 189 | proc toFloat*(a: var mpf_t): float = 190 | result = mpf_get_d(a) 191 | if result == 0.0 and mpf_cmp_d(a,0.0) != 0: 192 | raise newException(ValueError, "number too small") 193 | if result == Inf: 194 | raise newException(ValueError, "number too large") 195 | 196 | proc `$`*(a: mpf_t, base: cint = 10, n_digits = 10): string = 197 | var outOfRange = false 198 | var floatVal: float 199 | 200 | #May have to remove this due to system specific behaviour 201 | floatVal = mpf_get_d(a) 202 | if floatVal == 0.0 and mpf_cmp_d(a,0.0) != 0: 203 | outOfRange = true 204 | if floatVal == Inf: 205 | outOfRange = true 206 | 207 | # case: fits in float 208 | if base == 10 and not outOfRange: 209 | return $floatVal 210 | 211 | var exp: mp_exp_t 212 | # +1 for possible minus sign 213 | var str = newString(n_digits + 1) 214 | let coeff = $mpf_get_str(str,exp,base,n_digits,a) 215 | if (exp != 0): 216 | return coeff & "e" & $exp 217 | if coeff == "": 218 | return "0.0" 219 | result = coeff 220 | 221 | proc `==`*(a,b: mpf_t): bool = 222 | return mpf_cmp(a,b) == 0 223 | 224 | proc `<`*(a,b: mpf_t): bool = 225 | return mpf_cmp(a,b) < 0 226 | 227 | proc `<=`*(a,b: mpf_t): bool = 228 | let t = mpf_cmp(a,b) 229 | t < 0 or t == 0 230 | 231 | proc cmp*(a,b: mpf_t): int = 232 | return mpf_cmp(a,b) 233 | 234 | proc destroy*(a: var mpf_t) {.destructor.} = 235 | mpf_clear(a) 236 | 237 | converter convert*(a: mpz_t): mpf_t = 238 | result = init_mpf() 239 | mpf_set_z(result,a) 240 | 241 | {.pop.} 242 | 243 | when isMainModule: 244 | proc testEq() = 245 | var t1 = new(mpz_t) 246 | var t2 = new(mpz_t) 247 | var t3 = new(mpz_t) 248 | 249 | discard mpz_init_set_str(t1[].addr,"123",10) 250 | discard mpz_init_set_str(t2[].addr,"123",10) 251 | discard mpz_init_set_str(t3[].addr,"124",10) 252 | assert t1[] == t2[] 253 | assert t2[] != t3[] 254 | assert t1[] < t3[] 255 | assert t3[] > t1[] 256 | assert t3[].cmp(t1[]) > 0 257 | 258 | proc testAlloc = 259 | var t = alloc_mpz_t(true) 260 | assert (($t) == "0") 261 | dealloc_mpz_t(t,true) 262 | 263 | proc testFloatConv = 264 | var t = 123.456.toMpf 265 | #echo 123.4.mpf_t # converter doesn't work 266 | assert ($t == "123.456") 267 | 268 | proc testToPtr = 269 | var t: mpz_t = 0 270 | var t2: mpz_t = 5 271 | mpz_add(t,t2,t) 272 | assert ($t == "5") 273 | var f: mpf_t = 0.0 274 | var f2: mpf_t = 5.0 275 | mpf_add(f,f2,f) 276 | assert ($f == "5.0") 277 | 278 | proc testToFloat = 279 | 280 | var tooSmall = false 281 | try: 282 | var f = init_mpf("1e-11043") 283 | discard f.toFloat() 284 | except: 285 | var e = getCurrentException() 286 | assert e of ValueError 287 | tooSmall = true 288 | assert(tooSmall) 289 | 290 | var tooLarge = false 291 | try: 292 | var f = init_mpf("1e1104367") 293 | echo f.toFloat() 294 | except: 295 | var e = getCurrentException() 296 | assert e of ValueError 297 | tooLarge = true 298 | assert(tooLarge) 299 | 300 | # check we don't get an excpetion in the case of zero 301 | var f = init_mpf(0.0) 302 | discard f.toFloat() 303 | 304 | proc testLiteralHelpers = 305 | # test should stay alive whilst in scope 306 | let test = mpz_p(123) 307 | GC_fullcollect() 308 | assert($test == "123") 309 | 310 | var res: mpz_t = init_mpz(0) 311 | mpz_add(res.addr,mpz_p(5),mpz_p(19)) 312 | 313 | # a bit clunky 314 | assert res == mpz_p(24)[] 315 | 316 | proc oneFinaliser = 317 | #TODO: should increment global count when debug mode 318 | let test = mpz_p(123) 319 | GC_fullcollect() 320 | 321 | testEq() 322 | testAlloc() 323 | testFloatConv() 324 | testToPtr() 325 | testToFloat() 326 | testLiteralHelpers() 327 | 328 | GC_fullcollect() 329 | echo "before oneFinaliser" 330 | oneFinaliser() 331 | echo "after oneFinaliser" 332 | GC_fullcollect() 333 | echo "after GC_fullcollect" 334 | 335 | -------------------------------------------------------------------------------- /COPYINGv2: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /gmp.h.done: -------------------------------------------------------------------------------- 1 | //#include /* for std::istream, std::ostream, std::string */ 2 | //#include 3 | #include /* for size_t */ 4 | 5 | #ifdef C2NIM 6 | # header "" 7 | #endif 8 | 9 | #mangle ssize_t csize 10 | #mangle "'ptr'" "pntr" 11 | #mangle "'in'" "input" 12 | #mangle "'out'" "output" 13 | #mangle "'type'" "typ" 14 | #mangle "'from'" "frm" 15 | 16 | 17 | typedef unsigned long int mp_limb_t; 18 | typedef long int mp_limb_signed_t; 19 | 20 | 21 | typedef unsigned long int mp_bitcnt_t; 22 | 23 | typedef struct 24 | { 25 | int _mp_alloc; 26 | 27 | int _mp_size; 28 | 29 | 30 | mp_limb_t *_mp_d; 31 | } __mpz_struct; 32 | 33 | 34 | typedef __mpz_struct MP_INT; 35 | typedef __mpz_struct mpz_t[1]; 36 | 37 | typedef mp_limb_t * mp_ptr; 38 | typedef const mp_limb_t * mp_srcptr; 39 | 40 | 41 | 42 | typedef long int mp_size_t; 43 | typedef long int mp_exp_t; 44 | 45 | 46 | typedef struct 47 | { 48 | __mpz_struct _mp_num; 49 | __mpz_struct _mp_den; 50 | } __mpq_struct; 51 | 52 | typedef __mpq_struct MP_RAT; 53 | typedef __mpq_struct mpq_t[1]; 54 | 55 | typedef struct 56 | { 57 | int _mp_prec; 58 | 59 | 60 | 61 | int _mp_size; 62 | 63 | 64 | mp_exp_t _mp_exp; 65 | mp_limb_t *_mp_d; 66 | } __mpf_struct; 67 | 68 | 69 | typedef __mpf_struct mpf_t[1]; 70 | 71 | 72 | typedef enum 73 | { 74 | GMP_RAND_ALG_DEFAULT = 0, 75 | GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT 76 | } gmp_randalg_t; 77 | 78 | 79 | typedef struct 80 | { 81 | mpz_t _mp_seed; 82 | gmp_randalg_t _mp_alg; 83 | union { 84 | void *_mp_lc; 85 | } _mp_algdata; 86 | } __gmp_randstate_struct; 87 | typedef __gmp_randstate_struct gmp_randstate_t[1]; 88 | 89 | 90 | 91 | typedef const __mpz_struct *mpz_srcptr; 92 | typedef __mpz_struct *mpz_ptr; 93 | typedef const __mpf_struct *mpf_srcptr; 94 | typedef __mpf_struct *mpf_ptr; 95 | typedef const __mpq_struct *mpq_srcptr; 96 | typedef __mpq_struct *mpq_ptr; 97 | 98 | 99 | void mp_set_memory_functions (void *(*) (size_t), 100 | void *(*) (void *, size_t, size_t), 101 | void (*) (void *, size_t)) ; 102 | 103 | 104 | void mp_get_memory_functions (void *(**) (size_t), 105 | void *(**) (void *, size_t, size_t), 106 | void (**) (void *, size_t)) ; 107 | 108 | 109 | extern const int mp_bits_per_limb; 110 | 111 | 112 | extern int gmp_errno; 113 | 114 | 115 | extern const char * const gmp_version; 116 | 117 | 118 | void gmp_randinit (gmp_randstate_t, gmp_randalg_t, ...); 119 | 120 | 121 | void gmp_randinit_default (gmp_randstate_t); 122 | 123 | 124 | void gmp_randinit_lc_2exp (gmp_randstate_t, mpz_srcptr, unsigned long int, mp_bitcnt_t); 125 | 126 | 127 | int gmp_randinit_lc_2exp_size (gmp_randstate_t, mp_bitcnt_t); 128 | 129 | 130 | void gmp_randinit_mt (gmp_randstate_t); 131 | 132 | 133 | void gmp_randinit_set (gmp_randstate_t, const __gmp_randstate_struct *); 134 | 135 | 136 | void gmp_randseed (gmp_randstate_t, mpz_srcptr); 137 | 138 | 139 | void gmp_randseed_ui (gmp_randstate_t, unsigned long int); 140 | 141 | 142 | void gmp_randclear (gmp_randstate_t); 143 | 144 | 145 | unsigned long gmp_urandomb_ui (gmp_randstate_t, unsigned long); 146 | 147 | 148 | unsigned long gmp_urandomm_ui (gmp_randstate_t, unsigned long); 149 | 150 | 151 | 152 | 153 | 154 | int gmp_asprintf (char **, const char *, ...); 155 | 156 | 157 | 158 | int gmp_fprintf (FILE *, const char *, ...); 159 | int gmp_printf (const char *, ...); 160 | 161 | 162 | int gmp_snprintf (char *, size_t, const char *, ...); 163 | 164 | 165 | int gmp_sprintf (char *, const char *, ...); 166 | 167 | 168 | 169 | int gmp_vasprintf (char **, const char *, va_list); 170 | 171 | 172 | 173 | 174 | int gmp_vfprintf (FILE *, const char *, va_list); 175 | 176 | 177 | 178 | 179 | int gmp_vprintf (const char *, va_list); 180 | 181 | 182 | 183 | 184 | int gmp_vsnprintf (char *, size_t, const char *, va_list); 185 | 186 | 187 | 188 | 189 | int gmp_vsprintf (char *, const char *, va_list); 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | int gmp_fscanf (FILE *, const char *, ...); 198 | 199 | 200 | 201 | int gmp_scanf (const char *, ...); 202 | 203 | 204 | int gmp_sscanf (const char *, const char *, ...); 205 | 206 | 207 | 208 | int gmp_vfscanf (FILE *, const char *, va_list); 209 | 210 | 211 | 212 | 213 | int gmp_vscanf (const char *, va_list); 214 | 215 | 216 | 217 | 218 | int gmp_vsscanf (const char *, const char *, va_list); 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | void *_mpz_realloc (mpz_ptr, mp_size_t); 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr); 235 | 236 | 237 | void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int); 238 | 239 | 240 | void mpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr); 241 | 242 | 243 | void mpz_addmul_ui (mpz_ptr, mpz_srcptr, unsigned long int); 244 | 245 | 246 | void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr); 247 | 248 | 249 | void mpz_array_init (mpz_ptr, mp_size_t, mp_size_t); 250 | 251 | 252 | void mpz_bin_ui (mpz_ptr, mpz_srcptr, unsigned long int); 253 | 254 | 255 | void mpz_bin_uiui (mpz_ptr, unsigned long int, unsigned long int); 256 | 257 | 258 | void mpz_cdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); 259 | 260 | 261 | void mpz_cdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); 262 | 263 | 264 | unsigned long int mpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); 265 | 266 | 267 | void mpz_cdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); 268 | 269 | 270 | unsigned long int mpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); 271 | 272 | 273 | void mpz_cdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); 274 | 275 | 276 | void mpz_cdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); 277 | 278 | 279 | unsigned long int mpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); 280 | 281 | 282 | unsigned long int mpz_cdiv_ui (mpz_srcptr, unsigned long int) ; 283 | 284 | 285 | void mpz_clear (mpz_ptr); 286 | 287 | 288 | void mpz_clears (mpz_ptr, ...); 289 | 290 | 291 | void mpz_clrbit (mpz_ptr, mp_bitcnt_t); 292 | 293 | 294 | int mpz_cmp (mpz_srcptr, mpz_srcptr) ; 295 | 296 | 297 | int mpz_cmp_d (mpz_srcptr, double) ; 298 | 299 | 300 | int _mpz_cmp_si (mpz_srcptr, signed long int) ; 301 | 302 | 303 | int _mpz_cmp_ui (mpz_srcptr, unsigned long int) ; 304 | 305 | 306 | int mpz_cmpabs (mpz_srcptr, mpz_srcptr) ; 307 | 308 | 309 | int mpz_cmpabs_d (mpz_srcptr, double) ; 310 | 311 | 312 | int mpz_cmpabs_ui (mpz_srcptr, unsigned long int) ; 313 | 314 | 315 | void mpz_com (mpz_ptr, mpz_srcptr); 316 | 317 | 318 | void mpz_combit (mpz_ptr, mp_bitcnt_t); 319 | 320 | 321 | int mpz_congruent_p (mpz_srcptr, mpz_srcptr, mpz_srcptr) ; 322 | 323 | 324 | int mpz_congruent_2exp_p (mpz_srcptr, mpz_srcptr, mp_bitcnt_t) ; 325 | 326 | 327 | int mpz_congruent_ui_p (mpz_srcptr, unsigned long, unsigned long) ; 328 | 329 | 330 | void mpz_divexact (mpz_ptr, mpz_srcptr, mpz_srcptr); 331 | 332 | 333 | void mpz_divexact_ui (mpz_ptr, mpz_srcptr, unsigned long); 334 | 335 | 336 | int mpz_divisible_p (mpz_srcptr, mpz_srcptr) ; 337 | 338 | 339 | int mpz_divisible_ui_p (mpz_srcptr, unsigned long) ; 340 | 341 | 342 | int mpz_divisible_2exp_p (mpz_srcptr, mp_bitcnt_t) ; 343 | 344 | 345 | void mpz_dump (mpz_srcptr); 346 | 347 | 348 | void *mpz_export (void *, size_t *, int, size_t, int, size_t, mpz_srcptr); 349 | 350 | 351 | void mpz_fac_ui (mpz_ptr, unsigned long int); 352 | 353 | 354 | void mpz_2fac_ui (mpz_ptr, unsigned long int); 355 | 356 | 357 | void mpz_mfac_uiui (mpz_ptr, unsigned long int, unsigned long int); 358 | 359 | 360 | void mpz_primorial_ui (mpz_ptr, unsigned long int); 361 | 362 | 363 | void mpz_fdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); 364 | 365 | 366 | void mpz_fdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); 367 | 368 | 369 | unsigned long int mpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); 370 | 371 | 372 | void mpz_fdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); 373 | 374 | 375 | unsigned long int mpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); 376 | 377 | 378 | void mpz_fdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); 379 | 380 | 381 | void mpz_fdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); 382 | 383 | 384 | unsigned long int mpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); 385 | 386 | 387 | unsigned long int mpz_fdiv_ui (mpz_srcptr, unsigned long int) ; 388 | 389 | 390 | void mpz_fib_ui (mpz_ptr, unsigned long int); 391 | 392 | 393 | void mpz_fib2_ui (mpz_ptr, mpz_ptr, unsigned long int); 394 | 395 | 396 | int mpz_fits_sint_p (mpz_srcptr) ; 397 | 398 | 399 | int mpz_fits_slong_p (mpz_srcptr) ; 400 | 401 | 402 | int mpz_fits_sshort_p (mpz_srcptr) ; 403 | void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr); 404 | 405 | 406 | unsigned long int mpz_gcd_ui (mpz_ptr, mpz_srcptr, unsigned long int); 407 | 408 | 409 | void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); 410 | 411 | 412 | double mpz_get_d (mpz_srcptr) ; 413 | 414 | 415 | double mpz_get_d_2exp (signed long int *, mpz_srcptr); 416 | 417 | 418 | long int mpz_get_si (mpz_srcptr) ; 419 | 420 | 421 | char *mpz_get_str (char *, int, mpz_srcptr); 422 | mp_bitcnt_t mpz_hamdist (mpz_srcptr, mpz_srcptr) ; 423 | 424 | 425 | void mpz_import (mpz_ptr, size_t, int, size_t, int, size_t, const void *); 426 | 427 | 428 | void mpz_init (mpz_ptr); 429 | 430 | 431 | void mpz_init2 (mpz_ptr, mp_bitcnt_t); 432 | 433 | 434 | void mpz_inits (mpz_ptr, ...); 435 | 436 | 437 | void mpz_init_set (mpz_ptr, mpz_srcptr); 438 | 439 | 440 | void mpz_init_set_d (mpz_ptr, double); 441 | 442 | 443 | void mpz_init_set_si (mpz_ptr, signed long int); 444 | 445 | 446 | int mpz_init_set_str (mpz_ptr, const char *, int); 447 | 448 | 449 | void mpz_init_set_ui (mpz_ptr, unsigned long int); 450 | 451 | 452 | 453 | size_t mpz_inp_raw (mpz_ptr, FILE *); 454 | 455 | 456 | 457 | 458 | size_t mpz_inp_str (mpz_ptr, FILE *, int); 459 | 460 | 461 | 462 | int mpz_invert (mpz_ptr, mpz_srcptr, mpz_srcptr); 463 | 464 | 465 | void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr); 466 | 467 | 468 | int mpz_jacobi (mpz_srcptr, mpz_srcptr) ; 469 | 470 | 471 | 472 | 473 | int mpz_kronecker_si (mpz_srcptr, long) ; 474 | 475 | 476 | int mpz_kronecker_ui (mpz_srcptr, unsigned long) ; 477 | 478 | 479 | int mpz_si_kronecker (long, mpz_srcptr) ; 480 | 481 | 482 | int mpz_ui_kronecker (unsigned long, mpz_srcptr) ; 483 | 484 | 485 | void mpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr); 486 | 487 | 488 | void mpz_lcm_ui (mpz_ptr, mpz_srcptr, unsigned long); 489 | 490 | 491 | 492 | 493 | void mpz_lucnum_ui (mpz_ptr, unsigned long int); 494 | 495 | 496 | void mpz_lucnum2_ui (mpz_ptr, mpz_ptr, unsigned long int); 497 | 498 | 499 | int mpz_millerrabin (mpz_srcptr, int) ; 500 | 501 | 502 | void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr); 503 | 504 | 505 | 506 | 507 | void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr); 508 | 509 | 510 | void mpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); 511 | 512 | 513 | void mpz_mul_si (mpz_ptr, mpz_srcptr, long int); 514 | 515 | 516 | void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int); 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | void mpz_nextprime (mpz_ptr, mpz_srcptr); 525 | 526 | 527 | 528 | size_t mpz_out_raw (FILE *, mpz_srcptr); 529 | 530 | 531 | 532 | 533 | size_t mpz_out_str (FILE *, int, mpz_srcptr); 534 | 535 | 536 | 537 | int mpz_perfect_power_p (mpz_srcptr) ; 538 | void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int); 539 | 540 | 541 | void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); 542 | 543 | 544 | void mpz_powm_sec (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr); 545 | 546 | 547 | void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr); 548 | 549 | 550 | int mpz_probab_prime_p (mpz_srcptr, int) ; 551 | 552 | 553 | void mpz_random (mpz_ptr, mp_size_t); 554 | 555 | 556 | void mpz_random2 (mpz_ptr, mp_size_t); 557 | 558 | 559 | void mpz_realloc2 (mpz_ptr, mp_bitcnt_t); 560 | 561 | 562 | mp_bitcnt_t mpz_remove (mpz_ptr, mpz_srcptr, mpz_srcptr); 563 | 564 | 565 | int mpz_root (mpz_ptr, mpz_srcptr, unsigned long int); 566 | 567 | 568 | void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); 569 | 570 | 571 | void mpz_rrandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t); 572 | 573 | 574 | mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) ; 575 | 576 | 577 | mp_bitcnt_t mpz_scan1 (mpz_srcptr, mp_bitcnt_t) ; 578 | 579 | 580 | void mpz_set (mpz_ptr, mpz_srcptr); 581 | 582 | 583 | void mpz_set_d (mpz_ptr, double); 584 | 585 | 586 | void mpz_set_f (mpz_ptr, mpf_srcptr); 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | void mpz_set_si (mpz_ptr, signed long int); 595 | 596 | 597 | int mpz_set_str (mpz_ptr, const char *, int); 598 | 599 | 600 | void mpz_set_ui (mpz_ptr, unsigned long int); 601 | 602 | 603 | void mpz_setbit (mpz_ptr, mp_bitcnt_t); 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | size_t mpz_sizeinbase (mpz_srcptr, int) ; 612 | 613 | 614 | void mpz_sqrt (mpz_ptr, mpz_srcptr); 615 | 616 | 617 | void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr); 618 | 619 | 620 | void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr); 621 | 622 | 623 | void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int); 624 | 625 | 626 | void mpz_ui_sub (mpz_ptr, unsigned long int, mpz_srcptr); 627 | 628 | 629 | void mpz_submul (mpz_ptr, mpz_srcptr, mpz_srcptr); 630 | 631 | 632 | void mpz_submul_ui (mpz_ptr, mpz_srcptr, unsigned long int); 633 | 634 | 635 | void mpz_swap (mpz_ptr, mpz_ptr) ; 636 | 637 | 638 | unsigned long int mpz_tdiv_ui (mpz_srcptr, unsigned long int) ; 639 | 640 | 641 | void mpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr); 642 | 643 | 644 | void mpz_tdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); 645 | 646 | 647 | unsigned long int mpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int); 648 | 649 | 650 | void mpz_tdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr); 651 | 652 | 653 | unsigned long int mpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int); 654 | 655 | 656 | void mpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr); 657 | 658 | 659 | void mpz_tdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t); 660 | 661 | 662 | unsigned long int mpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int); 663 | 664 | 665 | int mpz_tstbit (mpz_srcptr, mp_bitcnt_t) ; 666 | 667 | 668 | void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int); 669 | 670 | 671 | void mpz_urandomb (mpz_ptr, gmp_randstate_t, mp_bitcnt_t); 672 | 673 | 674 | void mpz_urandomm (mpz_ptr, gmp_randstate_t, mpz_srcptr); 675 | 676 | 677 | 678 | void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr); 679 | 680 | 681 | mp_srcptr mpz_limbs_read (mpz_srcptr); 682 | 683 | 684 | mp_ptr mpz_limbs_write (mpz_ptr, mp_size_t); 685 | 686 | 687 | mp_ptr mpz_limbs_modify (mpz_ptr, mp_size_t); 688 | 689 | 690 | void mpz_limbs_finish (mpz_ptr, mp_size_t); 691 | 692 | 693 | mpz_srcptr mpz_roinit_n (mpz_ptr, mp_srcptr, mp_size_t); 694 | void mpq_add (mpq_ptr, mpq_srcptr, mpq_srcptr); 695 | 696 | 697 | void mpq_canonicalize (mpq_ptr); 698 | 699 | 700 | void mpq_clear (mpq_ptr); 701 | 702 | 703 | void mpq_clears (mpq_ptr, ...); 704 | 705 | 706 | int mpq_cmp (mpq_srcptr, mpq_srcptr) ; 707 | 708 | 709 | int _mpq_cmp_si (mpq_srcptr, long, unsigned long) ; 710 | 711 | 712 | int _mpq_cmp_ui (mpq_srcptr, unsigned long int, unsigned long int) ; 713 | 714 | 715 | void mpq_div (mpq_ptr, mpq_srcptr, mpq_srcptr); 716 | 717 | 718 | void mpq_div_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t); 719 | 720 | 721 | int mpq_equal (mpq_srcptr, mpq_srcptr) ; 722 | 723 | 724 | void mpq_get_num (mpz_ptr, mpq_srcptr); 725 | 726 | 727 | void mpq_get_den (mpz_ptr, mpq_srcptr); 728 | 729 | 730 | double mpq_get_d (mpq_srcptr) ; 731 | 732 | 733 | char *mpq_get_str (char *, int, mpq_srcptr); 734 | 735 | 736 | void mpq_init (mpq_ptr); 737 | 738 | 739 | void mpq_inits (mpq_ptr, ...); 740 | 741 | 742 | 743 | size_t mpq_inp_str (mpq_ptr, FILE *, int); 744 | 745 | 746 | 747 | void mpq_inv (mpq_ptr, mpq_srcptr); 748 | 749 | 750 | void mpq_mul (mpq_ptr, mpq_srcptr, mpq_srcptr); 751 | 752 | 753 | void mpq_mul_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t); 754 | size_t mpq_out_str (FILE *, int, mpq_srcptr); 755 | 756 | 757 | 758 | void mpq_set (mpq_ptr, mpq_srcptr); 759 | 760 | 761 | void mpq_set_d (mpq_ptr, double); 762 | 763 | 764 | void mpq_set_den (mpq_ptr, mpz_srcptr); 765 | 766 | 767 | void mpq_set_f (mpq_ptr, mpf_srcptr); 768 | 769 | 770 | void mpq_set_num (mpq_ptr, mpz_srcptr); 771 | 772 | 773 | void mpq_set_si (mpq_ptr, signed long int, unsigned long int); 774 | 775 | 776 | int mpq_set_str (mpq_ptr, const char *, int); 777 | 778 | 779 | void mpq_set_ui (mpq_ptr, unsigned long int, unsigned long int); 780 | 781 | 782 | void mpq_set_z (mpq_ptr, mpz_srcptr); 783 | 784 | 785 | void mpq_sub (mpq_ptr, mpq_srcptr, mpq_srcptr); 786 | 787 | 788 | void mpq_swap (mpq_ptr, mpq_ptr) ; 789 | 790 | 791 | 792 | 793 | 794 | void mpf_abs (mpf_ptr, mpf_srcptr); 795 | 796 | 797 | void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr); 798 | 799 | 800 | void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned long int); 801 | 802 | void mpf_ceil (mpf_ptr, mpf_srcptr); 803 | 804 | 805 | void mpf_clear (mpf_ptr); 806 | 807 | 808 | void mpf_clears (mpf_ptr, ...); 809 | 810 | 811 | int mpf_cmp (mpf_srcptr, mpf_srcptr) ; 812 | 813 | 814 | int mpf_cmp_d (mpf_srcptr, double) ; 815 | 816 | 817 | int mpf_cmp_si (mpf_srcptr, signed long int) ; 818 | 819 | 820 | int mpf_cmp_ui (mpf_srcptr, unsigned long int) ; 821 | 822 | 823 | void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr); 824 | 825 | 826 | void mpf_div_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t); 827 | 828 | 829 | void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned long int); 830 | 831 | 832 | void mpf_dump (mpf_srcptr); 833 | 834 | 835 | int mpf_eq (mpf_srcptr, mpf_srcptr, mp_bitcnt_t) ; 836 | 837 | 838 | int mpf_fits_sint_p (mpf_srcptr) ; 839 | 840 | 841 | int mpf_fits_slong_p (mpf_srcptr) ; 842 | 843 | 844 | int mpf_fits_sshort_p (mpf_srcptr) ; 845 | 846 | 847 | int mpf_fits_uint_p (mpf_srcptr) ; 848 | 849 | 850 | int mpf_fits_ulong_p (mpf_srcptr) ; 851 | 852 | 853 | int mpf_fits_ushort_p (mpf_srcptr) ; 854 | 855 | 856 | void mpf_floor (mpf_ptr, mpf_srcptr); 857 | 858 | 859 | double mpf_get_d (mpf_srcptr) ; 860 | 861 | 862 | double mpf_get_d_2exp (signed long int *, mpf_srcptr); 863 | 864 | 865 | mp_bitcnt_t mpf_get_default_prec (void) ; 866 | 867 | 868 | mp_bitcnt_t mpf_get_prec (mpf_srcptr) ; 869 | 870 | 871 | long mpf_get_si (mpf_srcptr) ; 872 | 873 | 874 | char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr); 875 | 876 | 877 | unsigned long mpf_get_ui (mpf_srcptr) ; 878 | 879 | 880 | void mpf_init (mpf_ptr); 881 | 882 | 883 | void mpf_init2 (mpf_ptr, mp_bitcnt_t); 884 | 885 | 886 | void mpf_inits (mpf_ptr, ...); 887 | 888 | 889 | void mpf_init_set (mpf_ptr, mpf_srcptr); 890 | 891 | 892 | void mpf_init_set_d (mpf_ptr, double); 893 | 894 | 895 | void mpf_init_set_si (mpf_ptr, signed long int); 896 | 897 | 898 | int mpf_init_set_str (mpf_ptr, const char *, int); 899 | 900 | 901 | void mpf_init_set_ui (mpf_ptr, unsigned long int); 902 | 903 | 904 | 905 | size_t mpf_inp_str (mpf_ptr, FILE *, int); 906 | 907 | 908 | 909 | int mpf_integer_p (mpf_srcptr) ; 910 | 911 | 912 | void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr); 913 | 914 | 915 | void mpf_mul_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t); 916 | 917 | 918 | void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned long int); 919 | 920 | 921 | void mpf_neg (mpf_ptr, mpf_srcptr); 922 | 923 | 924 | 925 | size_t mpf_out_str (FILE *, int, size_t, mpf_srcptr); 926 | 927 | 928 | 929 | void mpf_pow_ui (mpf_ptr, mpf_srcptr, unsigned long int); 930 | 931 | 932 | void mpf_random2 (mpf_ptr, mp_size_t, mp_exp_t); 933 | 934 | 935 | void mpf_reldiff (mpf_ptr, mpf_srcptr, mpf_srcptr); 936 | 937 | 938 | void mpf_set (mpf_ptr, mpf_srcptr); 939 | 940 | 941 | void mpf_set_d (mpf_ptr, double); 942 | 943 | 944 | void mpf_set_default_prec (mp_bitcnt_t) ; 945 | 946 | 947 | void mpf_set_prec (mpf_ptr, mp_bitcnt_t); 948 | 949 | 950 | void mpf_set_prec_raw (mpf_ptr, mp_bitcnt_t) ; 951 | 952 | 953 | void mpf_set_q (mpf_ptr, mpq_srcptr); 954 | 955 | 956 | void mpf_set_si (mpf_ptr, signed long int); 957 | 958 | 959 | int mpf_set_str (mpf_ptr, const char *, int); 960 | 961 | 962 | void mpf_set_ui (mpf_ptr, unsigned long int); 963 | 964 | 965 | void mpf_set_z (mpf_ptr, mpz_srcptr); 966 | 967 | 968 | size_t mpf_size (mpf_srcptr) ; 969 | 970 | 971 | void mpf_sqrt (mpf_ptr, mpf_srcptr); 972 | 973 | 974 | void mpf_sqrt_ui (mpf_ptr, unsigned long int); 975 | 976 | 977 | void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr); 978 | 979 | 980 | void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned long int); 981 | 982 | 983 | void mpf_swap (mpf_ptr, mpf_ptr) ; 984 | 985 | 986 | void mpf_trunc (mpf_ptr, mpf_srcptr); 987 | 988 | 989 | void mpf_ui_div (mpf_ptr, unsigned long int, mpf_srcptr); 990 | 991 | 992 | void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr); 993 | 994 | 995 | void mpf_urandomb (mpf_t, gmp_randstate_t, mp_bitcnt_t); 996 | mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 997 | 998 | 999 | mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); 1000 | mp_limb_t mpn_divexact_by3c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | mp_limb_t mpn_divrem (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t); 1007 | 1008 | 1009 | mp_limb_t mpn_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t); 1010 | 1011 | 1012 | mp_limb_t mpn_divrem_2 (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr); 1013 | 1014 | 1015 | mp_limb_t mpn_div_qr_1 (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t); 1016 | 1017 | 1018 | mp_limb_t mpn_div_qr_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr); 1019 | 1020 | 1021 | mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t); 1022 | 1023 | 1024 | mp_limb_t mpn_gcd_1 (mp_srcptr, mp_size_t, mp_limb_t) ; 1025 | 1026 | 1027 | mp_limb_t mpn_gcdext_1 (mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t); 1028 | 1029 | 1030 | mp_size_t mpn_gcdext (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t); 1031 | 1032 | 1033 | size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t); 1034 | 1035 | 1036 | mp_bitcnt_t mpn_hamdist (mp_srcptr, mp_srcptr, mp_size_t) ; 1037 | 1038 | 1039 | mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); 1040 | 1041 | 1042 | mp_limb_t mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb_t) ; 1043 | 1044 | 1045 | mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); 1046 | 1047 | 1048 | mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); 1049 | 1050 | 1051 | void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1052 | 1053 | 1054 | void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t); 1055 | 1056 | 1057 | 1058 | mp_limb_t mpn_neg (mp_ptr, mp_srcptr, mp_size_t); 1059 | 1060 | 1061 | 1062 | 1063 | void mpn_com (mp_ptr, mp_srcptr, mp_size_t); 1064 | 1065 | 1066 | 1067 | int mpn_perfect_square_p (mp_srcptr, mp_size_t) ; 1068 | 1069 | 1070 | int mpn_perfect_power_p (mp_srcptr, mp_size_t) ; 1071 | 1072 | 1073 | mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t) ; 1074 | 1075 | 1076 | mp_size_t mpn_pow_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); 1077 | 1078 | 1079 | 1080 | mp_limb_t mpn_preinv_mod_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) ; 1081 | 1082 | 1083 | void mpn_random (mp_ptr, mp_size_t); 1084 | 1085 | 1086 | void mpn_random2 (mp_ptr, mp_size_t); 1087 | 1088 | 1089 | mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int); 1090 | 1091 | 1092 | mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t) ; 1093 | 1094 | 1095 | mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t) ; 1096 | 1097 | 1098 | mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int); 1099 | 1100 | 1101 | size_t mpn_sizeinbase (mp_srcptr, mp_size_t, int); 1102 | 1103 | 1104 | mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t); 1105 | 1106 | 1107 | 1108 | mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); 1109 | 1110 | 1111 | 1112 | 1113 | mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) ; 1114 | 1115 | 1116 | 1117 | mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1118 | 1119 | 1120 | mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t); 1121 | 1122 | 1123 | void mpn_tdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t); 1124 | 1125 | 1126 | void mpn_and_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1127 | 1128 | void mpn_andn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1129 | 1130 | void mpn_nand_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1131 | 1132 | void mpn_ior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1133 | 1134 | void mpn_iorn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1135 | 1136 | void mpn_nior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1137 | 1138 | void mpn_xor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1139 | 1140 | void mpn_xnor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1141 | 1142 | 1143 | void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t); 1144 | 1145 | void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t); 1146 | 1147 | void mpn_zero (mp_ptr, mp_size_t); 1148 | 1149 | 1150 | mp_limb_t mpn_cnd_add_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1151 | 1152 | mp_limb_t mpn_cnd_sub_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t); 1153 | 1154 | 1155 | mp_limb_t mpn_sec_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); 1156 | 1157 | mp_size_t mpn_sec_add_1_itch (mp_size_t) ; 1158 | 1159 | 1160 | mp_limb_t mpn_sec_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr); 1161 | 1162 | mp_size_t mpn_sec_sub_1_itch (mp_size_t) ; 1163 | 1164 | 1165 | void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); 1166 | 1167 | mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) ; 1168 | 1169 | 1170 | void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr); 1171 | 1172 | mp_size_t mpn_sec_sqr_itch (mp_size_t) ; 1173 | 1174 | 1175 | void mpn_sec_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_bitcnt_t, mp_srcptr, mp_size_t, mp_ptr); 1176 | 1177 | mp_size_t mpn_sec_powm_itch (mp_size_t, mp_bitcnt_t, mp_size_t) ; 1178 | 1179 | 1180 | void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t); 1181 | 1182 | 1183 | mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); 1184 | 1185 | mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) ; 1186 | 1187 | void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr); 1188 | 1189 | mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) ; 1190 | 1191 | 1192 | int mpn_sec_invert (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_bitcnt_t, mp_ptr); 1193 | 1194 | mp_size_t mpn_sec_invert_itch (mp_size_t) ; 1195 | 1196 | // externed stuff 1197 | 1198 | void mpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u); 1199 | 1200 | int mpz_fits_uint_p (mpz_srcptr __gmp_z); 1201 | 1202 | int mpz_fits_ulong_p (mpz_srcptr __gmp_z); 1203 | 1204 | 1205 | int mpz_fits_ushort_p (mpz_srcptr __gmp_z); 1206 | 1207 | unsigned long mpz_get_ui (mpz_srcptr __gmp_z); 1208 | 1209 | 1210 | mp_limb_t mpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n); 1211 | 1212 | 1213 | void mpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u); 1214 | 1215 | 1216 | int mpz_perfect_square_p (mpz_srcptr __gmp_a); 1217 | 1218 | mp_bitcnt_t mpz_popcount (mpz_srcptr __gmp_u); 1219 | 1220 | 1221 | void mpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u); 1222 | 1223 | 1224 | size_t mpz_size (mpz_srcptr __gmp_z); 1225 | 1226 | 1227 | void mpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u); 1228 | 1229 | void mpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u); 1230 | 1231 | 1232 | mp_limb_t mpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize); 1233 | 1234 | 1235 | 1236 | mp_limb_t mpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n); 1237 | 1238 | 1239 | 1240 | int mpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size); 1241 | 1242 | 1243 | 1244 | mp_limb_t mpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize); 1245 | 1246 | 1247 | 1248 | mp_limb_t mpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n); 1249 | 1250 | 1251 | mp_limb_t mpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n); 1252 | 1253 | enum 1254 | { 1255 | GMP_ERROR_NONE = 0, 1256 | GMP_ERROR_UNSUPPORTED_ARGUMENT = 1, 1257 | GMP_ERROR_DIVISION_BY_ZERO = 2, 1258 | GMP_ERROR_SQRT_OF_NEGATIVE = 4, 1259 | GMP_ERROR_INVALID_ARGUMENT = 8 1260 | }; 1261 | -------------------------------------------------------------------------------- /gmp.nim: -------------------------------------------------------------------------------- 1 | # Definitions for GNU multiple precision functions. -*- mode: c -*- 2 | # 3 | #Copyright 1991, 1993-1997, 1999-2014 Free Software Foundation, Inc. 4 | # 5 | #This file is part of the GNU MP Library. 6 | # 7 | #The GNU MP Library is free software; you can redistribute it and/or modify 8 | #it under the terms of either: 9 | # 10 | # the GNU Lesser General Public License as published by the Free 11 | # Software Foundation; either version 3 of the License, or (at your 12 | # option) any later version. 13 | # 14 | #or 15 | # 16 | # the GNU General Public License as published by the Free Software 17 | # Foundation; either version 2 of the License, or (at your option) any 18 | # later version. 19 | # 20 | #or both in parallel, as here. 21 | # 22 | #The GNU MP Library is distributed in the hope that it will be useful, but 23 | #WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 24 | #or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 25 | #for more details. 26 | # 27 | #You should have received copies of the GNU General Public License and the 28 | #GNU Lesser General Public License along with the GNU MP Library. If not, 29 | #see https://www.gnu.org/licenses/. 30 | 31 | ## identifiers starting with __ have been changed to start with mm_ 32 | ## idenitifers starting with _ have been changed to start with m_ 33 | ## struct members starting with _ , no longer start with _ 34 | 35 | #FIXME: add other OSs 36 | when defined(Posix): 37 | {.passl: "-lgmp".} 38 | 39 | type 40 | INNER_C_UNION_5532179898798000430* {.importc: "no_name", header: "".} = object {. 41 | union.} 42 | mp_lc* {.importc: "_mp_lc".}: pointer 43 | 44 | # should check limb sizes / import them directly? 45 | mp_limb_t* {.importc: "mp_limb_t", nodecl.} = culong 46 | mp_limb_signed_t* {.importc: "mp_limb_signed_t", nodecl.} = clong 47 | mp_bitcnt_t* {.importc: "mp_bitcnt_t", nodecl.} = culong 48 | mm_mpz_struct* {.importc: "__mpz_struct", header: "".} = object 49 | mp_alloc* {.importc: "_mp_alloc".}: cint 50 | mp_size* {.importc: "_mp_size".}: cint 51 | mp_d* {.importc: "_mp_d".}: ptr mp_limb_t 52 | 53 | MP_INT* = mm_mpz_struct 54 | #mpz_t* = array[1, mm_mpz_struct] 55 | mpz_t* = mm_mpz_struct 56 | mp_ptr* = ptr mp_limb_t 57 | mp_srcptr* = ptr mp_limb_t 58 | mp_size_t* {.importc: "mp_size_t", nodecl.} = clong 59 | mp_exp_t* {.importc: "mp_exp_t", nodecl.} = clong 60 | mm_mpq_struct* {.importc: "__mpq_struct", header: "".} = object 61 | mp_num* {.importc: "_mp_num".}: mm_mpz_struct 62 | mp_den* {.importc: "_mp_den".}: mm_mpz_struct 63 | 64 | MP_RAT* = mm_mpq_struct 65 | #mpq_t* = array[1, mm_mpq_struct] 66 | mpq_t* = mm_mpq_struct 67 | mm_mpf_struct* {.importc: "__mpf_struct", header: "".} = object 68 | mp_prec* {.importc: "_mp_prec".}: cint 69 | mp_size* {.importc: "_mp_size".}: cint 70 | mp_exp* {.importc: "_mp_exp".}: mp_exp_t 71 | mp_d* {.importc: "_mp_d".}: ptr mp_limb_t 72 | 73 | #mpf_t* = array[1, mm_mpf_struct] 74 | mpf_t* = mm_mpf_struct 75 | gmp_randalg_t* = distinct cint 76 | mm_gmp_randstate_struct* {.importc: "__gmp_randstate_struct", header: "".} = object 77 | mp_seed* {.importc: "_mp_seed".}: mpz_t 78 | mp_alg* {.importc: "_mp_alg".}: gmp_randalg_t 79 | mp_algdata* {.importc: "_mp_algdata".}: INNER_C_UNION_5532179898798000430 80 | 81 | #gmp_randstate_t* = array[1, mm_gmp_randstate_struct] 82 | gmp_randstate_t* = mm_gmp_randstate_struct 83 | mpz_srcptr* = ptr mm_mpz_struct 84 | mpz_ptr* = ptr mm_mpz_struct 85 | mpf_srcptr* = ptr mm_mpf_struct 86 | mpf_ptr* = ptr mm_mpf_struct 87 | mpq_srcptr* = ptr mm_mpq_struct 88 | mpq_ptr* = ptr mm_mpq_struct 89 | 90 | 91 | const 92 | GMP_RAND_ALG_DEFAULT: gmp_randalg_t = 0.gmp_randalg_t 93 | GMP_RAND_ALG_LC: gmp_randalg_t = GMP_RAND_ALG_DEFAULT 94 | 95 | proc mp_set_memory_functions*(a2: proc (a2: csize): pointer; a3: proc ( 96 | a2: pointer; a3: csize; a4: csize): pointer; 97 | a4: proc (a2: pointer; a3: csize)) {. 98 | importc: "mp_set_memory_functions", header: "".} 99 | proc mp_get_memory_functions*(a2: proc (a2: csize): pointer; a3: proc ( 100 | a2: pointer; a3: csize; a4: csize): pointer; 101 | a4: proc (a2: pointer; a3: csize)) {. 102 | importc: "mp_get_memory_functions", header: "".} 103 | var mp_bits_per_limb* {.importc: "mp_bits_per_limb", header: "".}: cint 104 | 105 | var gmp_errno* {.importc: "gmp_errno", header: "".}: cint 106 | 107 | var gmp_version* {.importc: "gmp_version", header: "".}: cstring 108 | 109 | proc gmp_randinit*(a2: gmp_randstate_t; a3: gmp_randalg_t) {.varargs, 110 | importc: "gmp_randinit", header: "".} 111 | proc gmp_randinit_default*(a2: gmp_randstate_t) {. 112 | importc: "gmp_randinit_default", header: "".} 113 | proc gmp_randinit_lc_2exp*(a2: gmp_randstate_t; a3: mpz_srcptr; a4: culong; 114 | a5: mp_bitcnt_t) {.importc: "gmp_randinit_lc_2exp", 115 | header: "".} 116 | proc gmp_randinit_lc_2exp_size*(a2: gmp_randstate_t; a3: mp_bitcnt_t): cint {. 117 | importc: "gmp_randinit_lc_2exp_size", header: "".} 118 | proc gmp_randinit_mt*(a2: gmp_randstate_t) {.importc: "gmp_randinit_mt", 119 | header: "".} 120 | proc gmp_randinit_set*(a2: gmp_randstate_t; a3: ptr mm_gmp_randstate_struct) {. 121 | importc: "gmp_randinit_set", header: "".} 122 | proc gmp_randseed*(a2: gmp_randstate_t; a3: mpz_srcptr) {. 123 | importc: "gmp_randseed", header: "".} 124 | proc gmp_randseed_ui*(a2: gmp_randstate_t; a3: culong) {. 125 | importc: "gmp_randseed_ui", header: "".} 126 | proc gmp_randclear*(a2: gmp_randstate_t) {.importc: "gmp_randclear", 127 | header: "".} 128 | proc gmp_urandomb_ui*(a2: gmp_randstate_t; a3: culong): culong {. 129 | importc: "gmp_urandomb_ui", header: "".} 130 | proc gmp_urandomm_ui*(a2: gmp_randstate_t; a3: culong): culong {. 131 | importc: "gmp_urandomm_ui", header: "".} 132 | proc gmp_asprintf*(a2: cstringArray; a3: cstring): cint {.varargs, 133 | importc: "gmp_asprintf", header: "".} 134 | proc gmp_fprintf*(a2: ptr FILE; a3: cstring): cint {.varargs, 135 | importc: "gmp_fprintf", header: "".} 136 | proc gmp_printf*(a2: cstring): cint {.varargs, importc: "gmp_printf", 137 | header: "".} 138 | proc gmp_snprintf*(a2: cstring; a3: csize; a4: cstring): cint {.varargs, 139 | importc: "gmp_snprintf", header: "".} 140 | proc gmp_sprintf*(a2: cstring; a3: cstring): cint {.varargs, 141 | importc: "gmp_sprintf", header: "".} 142 | #proc gmp_vasprintf*(a2: cstringArray; a3: cstring; a4: va_list): cint {. 143 | # importc: "gmp_vasprintf", header: "".} 144 | #proc gmp_vfprintf*(a2: ptr FILE; a3: cstring; a4: va_list): cint {. 145 | # importc: "gmp_vfprintf", header: "".} 146 | #proc gmp_vprintf*(a2: cstring; a3: va_list): cint {.importc: "gmp_vprintf", 147 | # header: "".} 148 | #proc gmp_vsnprintf*(a2: cstring; a3: csize; a4: cstring; a5: va_list): cint {. 149 | # importc: "gmp_vsnprintf", header: "".} 150 | #proc gmp_vsprintf*(a2: cstring; a3: cstring; a4: va_list): cint {. 151 | # importc: "gmp_vsprintf", header: "".} 152 | proc gmp_fscanf*(a2: ptr FILE; a3: cstring): cint {.varargs, 153 | importc: "gmp_fscanf", header: "".} 154 | proc gmp_scanf*(a2: cstring): cint {.varargs, importc: "gmp_scanf", 155 | header: "".} 156 | proc gmp_sscanf*(a2: cstring; a3: cstring): cint {.varargs, 157 | importc: "gmp_sscanf", header: "".} 158 | #proc gmp_vfscanf*(a2: ptr FILE; a3: cstring; a4: va_list): cint {. 159 | # importc: "gmp_vfscanf", header: "".} 160 | #proc gmp_vscanf*(a2: cstring; a3: va_list): cint {.importc: "gmp_vscanf", 161 | # header: "".} 162 | #proc gmp_vsscanf*(a2: cstring; a3: cstring; a4: va_list): cint {. 163 | # importc: "gmp_vsscanf", header: "".} 164 | proc m_mpz_realloc*(a2: mpz_ptr; a3: mp_size_t): pointer {. 165 | importc: "_mpz_realloc", header: "".} 166 | proc mpz_add*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_add", 167 | header: "".} 168 | proc mpz_add_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 169 | importc: "mpz_add_ui", header: "".} 170 | proc mpz_addmul*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 171 | importc: "mpz_addmul", header: "".} 172 | proc mpz_addmul_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 173 | importc: "mpz_addmul_ui", header: "".} 174 | proc mpz_and*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_and", 175 | header: "".} 176 | proc mpz_array_init*(a2: mpz_ptr; a3: mp_size_t; a4: mp_size_t) {. 177 | importc: "mpz_array_init", header: "".} 178 | proc mpz_bin_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 179 | importc: "mpz_bin_ui", header: "".} 180 | proc mpz_bin_uiui*(a2: mpz_ptr; a3: culong; a4: culong) {. 181 | importc: "mpz_bin_uiui", header: "".} 182 | proc mpz_cdiv_q*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 183 | importc: "mpz_cdiv_q", header: "".} 184 | proc mpz_cdiv_q_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 185 | importc: "mpz_cdiv_q_2exp", header: "".} 186 | proc mpz_cdiv_q_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 187 | importc: "mpz_cdiv_q_ui", header: "".} 188 | proc mpz_cdiv_qr*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 189 | importc: "mpz_cdiv_qr", header: "".} 190 | proc mpz_cdiv_qr_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: culong): culong {. 191 | importc: "mpz_cdiv_qr_ui", header: "".} 192 | proc mpz_cdiv_r*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 193 | importc: "mpz_cdiv_r", header: "".} 194 | proc mpz_cdiv_r_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 195 | importc: "mpz_cdiv_r_2exp", header: "".} 196 | proc mpz_cdiv_r_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 197 | importc: "mpz_cdiv_r_ui", header: "".} 198 | proc mpz_cdiv_ui*(a2: mpz_srcptr; a3: culong): culong {.importc: "mpz_cdiv_ui", 199 | header: "".} 200 | proc mpz_clear*(a2: mpz_ptr) {.importc: "mpz_clear", header: "".} 201 | proc mpz_clears*(a2: mpz_ptr) {.varargs, importc: "mpz_clears", 202 | header: "".} 203 | proc mpz_clrbit*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_clrbit", 204 | header: "".} 205 | proc mpz_cmp*(a2: mpz_srcptr; a3: mpz_srcptr): cint {.importc: "mpz_cmp", 206 | header: "".} 207 | proc mpz_cmp_d*(a2: mpz_srcptr; a3: cdouble): cint {.importc: "mpz_cmp_d", 208 | header: "".} 209 | proc m_mpz_cmp_si*(a2: mpz_srcptr; a3: clong): cint {.importc: "_mpz_cmp_si", 210 | header: "".} 211 | proc m_mpz_cmp_ui*(a2: mpz_srcptr; a3: culong): cint {.importc: "_mpz_cmp_ui", 212 | header: "".} 213 | proc mpz_cmpabs*(a2: mpz_srcptr; a3: mpz_srcptr): cint {.importc: "mpz_cmpabs", 214 | header: "".} 215 | proc mpz_cmpabs_d*(a2: mpz_srcptr; a3: cdouble): cint {.importc: "mpz_cmpabs_d", 216 | header: "".} 217 | proc mpz_cmpabs_ui*(a2: mpz_srcptr; a3: culong): cint {. 218 | importc: "mpz_cmpabs_ui", header: "".} 219 | proc mpz_com*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_com", 220 | header: "".} 221 | proc mpz_combit*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_combit", 222 | header: "".} 223 | proc mpz_congruent_p*(a2: mpz_srcptr; a3: mpz_srcptr; a4: mpz_srcptr): cint {. 224 | importc: "mpz_congruent_p", header: "".} 225 | proc mpz_congruent_2exp_p*(a2: mpz_srcptr; a3: mpz_srcptr; a4: mp_bitcnt_t): cint {. 226 | importc: "mpz_congruent_2exp_p", header: "".} 227 | proc mpz_congruent_ui_p*(a2: mpz_srcptr; a3: culong; a4: culong): cint {. 228 | importc: "mpz_congruent_ui_p", header: "".} 229 | proc mpz_divexact*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 230 | importc: "mpz_divexact", header: "".} 231 | proc mpz_divexact_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 232 | importc: "mpz_divexact_ui", header: "".} 233 | proc mpz_divisible_p*(a2: mpz_srcptr; a3: mpz_srcptr): cint {. 234 | importc: "mpz_divisible_p", header: "".} 235 | proc mpz_divisible_ui_p*(a2: mpz_srcptr; a3: culong): cint {. 236 | importc: "mpz_divisible_ui_p", header: "".} 237 | proc mpz_divisible_2exp_p*(a2: mpz_srcptr; a3: mp_bitcnt_t): cint {. 238 | importc: "mpz_divisible_2exp_p", header: "".} 239 | proc mpz_dump*(a2: mpz_srcptr) {.importc: "mpz_dump", header: "".} 240 | proc mpz_export*(a2: pointer; a3: ptr csize; a4: cint; a5: csize; a6: cint; 241 | a7: csize; a8: mpz_srcptr): pointer {.importc: "mpz_export", 242 | header: "".} 243 | proc mpz_fac_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_fac_ui", 244 | header: "".} 245 | proc mpz_2fac_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_2fac_ui", 246 | header: "".} 247 | proc mpz_mfac_uiui*(a2: mpz_ptr; a3: culong; a4: culong) {. 248 | importc: "mpz_mfac_uiui", header: "".} 249 | proc mpz_primorial_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_primorial_ui", 250 | header: "".} 251 | proc mpz_fdiv_q*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 252 | importc: "mpz_fdiv_q", header: "".} 253 | proc mpz_fdiv_q_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 254 | importc: "mpz_fdiv_q_2exp", header: "".} 255 | proc mpz_fdiv_q_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 256 | importc: "mpz_fdiv_q_ui", header: "".} 257 | proc mpz_fdiv_qr*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 258 | importc: "mpz_fdiv_qr", header: "".} 259 | proc mpz_fdiv_qr_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: culong): culong {. 260 | importc: "mpz_fdiv_qr_ui", header: "".} 261 | proc mpz_fdiv_r*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 262 | importc: "mpz_fdiv_r", header: "".} 263 | proc mpz_fdiv_r_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 264 | importc: "mpz_fdiv_r_2exp", header: "".} 265 | proc mpz_fdiv_r_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 266 | importc: "mpz_fdiv_r_ui", header: "".} 267 | proc mpz_fdiv_ui*(a2: mpz_srcptr; a3: culong): culong {.importc: "mpz_fdiv_ui", 268 | header: "".} 269 | proc mpz_fib_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_fib_ui", 270 | header: "".} 271 | proc mpz_fib2_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: culong) {. 272 | importc: "mpz_fib2_ui", header: "".} 273 | proc mpz_fits_sint_p*(a2: mpz_srcptr): cint {.importc: "mpz_fits_sint_p", 274 | header: "".} 275 | proc mpz_fits_slong_p*(a2: mpz_srcptr): cint {.importc: "mpz_fits_slong_p", 276 | header: "".} 277 | proc mpz_fits_sshort_p*(a2: mpz_srcptr): cint {.importc: "mpz_fits_sshort_p", 278 | header: "".} 279 | proc mpz_gcd*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_gcd", 280 | header: "".} 281 | proc mpz_gcd_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 282 | importc: "mpz_gcd_ui", header: "".} 283 | proc mpz_gcdext*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_ptr; a5: mpz_srcptr; 284 | a6: mpz_srcptr) {.importc: "mpz_gcdext", header: "".} 285 | proc mpz_get_d*(a2: mpz_srcptr): cdouble {.importc: "mpz_get_d", 286 | header: "".} 287 | proc mpz_get_d_2exp*(a2: ptr clong; a3: mpz_srcptr): cdouble {. 288 | importc: "mpz_get_d_2exp", header: "".} 289 | proc mpz_get_si*(a2: mpz_srcptr): clong {.importc: "mpz_get_si", 290 | header: "".} 291 | proc mpz_get_str*(a2: cstring; a3: cint; a4: mpz_srcptr): cstring {. 292 | importc: "mpz_get_str", header: "".} 293 | proc mpz_hamdist*(a2: mpz_srcptr; a3: mpz_srcptr): mp_bitcnt_t {. 294 | importc: "mpz_hamdist", header: "".} 295 | proc mpz_import*(a2: mpz_ptr; a3: csize; a4: cint; a5: csize; a6: cint; 296 | a7: csize; a8: pointer) {.importc: "mpz_import", 297 | header: "".} 298 | proc mpz_init*(a2: mpz_ptr) {.importc: "mpz_init", header: "".} 299 | proc mpz_init2*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_init2", 300 | header: "".} 301 | proc mpz_inits*(a2: mpz_ptr) {.varargs, importc: "mpz_inits", header: "".} 302 | proc mpz_init_set*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_init_set", 303 | header: "".} 304 | proc mpz_init_set_d*(a2: mpz_ptr; a3: cdouble) {.importc: "mpz_init_set_d", 305 | header: "".} 306 | proc mpz_init_set_si*(a2: mpz_ptr; a3: clong) {.importc: "mpz_init_set_si", 307 | header: "".} 308 | proc mpz_init_set_str*(a2: mpz_ptr; a3: cstring; a4: cint): cint {. 309 | importc: "mpz_init_set_str", header: "".} 310 | proc mpz_init_set_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_init_set_ui", 311 | header: "".} 312 | proc mpz_inp_raw*(a2: mpz_ptr; a3: ptr FILE): csize {.importc: "mpz_inp_raw", 313 | header: "".} 314 | proc mpz_inp_str*(a2: mpz_ptr; a3: ptr FILE; a4: cint): csize {. 315 | importc: "mpz_inp_str", header: "".} 316 | proc mpz_invert*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr): cint {. 317 | importc: "mpz_invert", header: "".} 318 | proc mpz_ior*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_ior", 319 | header: "".} 320 | proc mpz_jacobi*(a2: mpz_srcptr; a3: mpz_srcptr): cint {.importc: "mpz_jacobi", 321 | header: "".} 322 | proc mpz_kronecker_si*(a2: mpz_srcptr; a3: clong): cint {. 323 | importc: "mpz_kronecker_si", header: "".} 324 | proc mpz_kronecker_ui*(a2: mpz_srcptr; a3: culong): cint {. 325 | importc: "mpz_kronecker_ui", header: "".} 326 | proc mpz_si_kronecker*(a2: clong; a3: mpz_srcptr): cint {. 327 | importc: "mpz_si_kronecker", header: "".} 328 | proc mpz_ui_kronecker*(a2: culong; a3: mpz_srcptr): cint {. 329 | importc: "mpz_ui_kronecker", header: "".} 330 | proc mpz_lcm*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_lcm", 331 | header: "".} 332 | proc mpz_lcm_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 333 | importc: "mpz_lcm_ui", header: "".} 334 | proc mpz_lucnum_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_lucnum_ui", 335 | header: "".} 336 | proc mpz_lucnum2_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: culong) {. 337 | importc: "mpz_lucnum2_ui", header: "".} 338 | proc mpz_millerrabin*(a2: mpz_srcptr; a3: cint): cint {. 339 | importc: "mpz_millerrabin", header: "".} 340 | proc mpz_mod*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_mod", 341 | header: "".} 342 | proc mpz_mul*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_mul", 343 | header: "".} 344 | proc mpz_mul_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 345 | importc: "mpz_mul_2exp", header: "".} 346 | proc mpz_mul_si*(a2: mpz_ptr; a3: mpz_srcptr; a4: clong) {. 347 | importc: "mpz_mul_si", header: "".} 348 | proc mpz_mul_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 349 | importc: "mpz_mul_ui", header: "".} 350 | proc mpz_nextprime*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_nextprime", 351 | header: "".} 352 | proc mpz_out_raw*(a2: ptr FILE; a3: mpz_srcptr): csize {.importc: "mpz_out_raw", 353 | header: "".} 354 | proc mpz_out_str*(a2: ptr FILE; a3: cint; a4: mpz_srcptr): csize {. 355 | importc: "mpz_out_str", header: "".} 356 | proc mpz_perfect_power_p*(a2: mpz_srcptr): cint {. 357 | importc: "mpz_perfect_power_p", header: "".} 358 | proc mpz_pow_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 359 | importc: "mpz_pow_ui", header: "".} 360 | proc mpz_powm*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 361 | importc: "mpz_powm", header: "".} 362 | proc mpz_powm_sec*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 363 | importc: "mpz_powm_sec", header: "".} 364 | proc mpz_powm_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong; a5: mpz_srcptr) {. 365 | importc: "mpz_powm_ui", header: "".} 366 | proc mpz_probab_prime_p*(a2: mpz_srcptr; a3: cint): cint {. 367 | importc: "mpz_probab_prime_p", header: "".} 368 | proc mpz_random*(a2: mpz_ptr; a3: mp_size_t) {.importc: "mpz_random", 369 | header: "".} 370 | proc mpz_random2*(a2: mpz_ptr; a3: mp_size_t) {.importc: "mpz_random2", 371 | header: "".} 372 | proc mpz_realloc2*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_realloc2", 373 | header: "".} 374 | proc mpz_remove*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr): mp_bitcnt_t {. 375 | importc: "mpz_remove", header: "".} 376 | proc mpz_root*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): cint {. 377 | importc: "mpz_root", header: "".} 378 | proc mpz_rootrem*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: culong) {. 379 | importc: "mpz_rootrem", header: "".} 380 | proc mpz_rrandomb*(a2: mpz_ptr; a3: gmp_randstate_t; a4: mp_bitcnt_t) {. 381 | importc: "mpz_rrandomb", header: "".} 382 | proc mpz_scan0*(a2: mpz_srcptr; a3: mp_bitcnt_t): mp_bitcnt_t {. 383 | importc: "mpz_scan0", header: "".} 384 | proc mpz_scan1*(a2: mpz_srcptr; a3: mp_bitcnt_t): mp_bitcnt_t {. 385 | importc: "mpz_scan1", header: "".} 386 | proc mpz_set*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_set", 387 | header: "".} 388 | proc mpz_set_d*(a2: mpz_ptr; a3: cdouble) {.importc: "mpz_set_d", 389 | header: "".} 390 | proc mpz_set_f*(a2: mpz_ptr; a3: mpf_srcptr) {.importc: "mpz_set_f", 391 | header: "".} 392 | proc mpz_set_si*(a2: mpz_ptr; a3: clong) {.importc: "mpz_set_si", 393 | header: "".} 394 | proc mpz_set_str*(a2: mpz_ptr; a3: cstring; a4: cint): cint {. 395 | importc: "mpz_set_str", header: "".} 396 | proc mpz_set_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_set_ui", 397 | header: "".} 398 | proc mpz_setbit*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_setbit", 399 | header: "".} 400 | proc mpz_sizeinbase*(a2: mpz_srcptr; a3: cint): csize {. 401 | importc: "mpz_sizeinbase", header: "".} 402 | proc mpz_sqrt*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_sqrt", 403 | header: "".} 404 | proc mpz_sqrtrem*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr) {. 405 | importc: "mpz_sqrtrem", header: "".} 406 | proc mpz_sub*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_sub", 407 | header: "".} 408 | proc mpz_sub_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 409 | importc: "mpz_sub_ui", header: "".} 410 | proc mpz_ui_sub*(a2: mpz_ptr; a3: culong; a4: mpz_srcptr) {. 411 | importc: "mpz_ui_sub", header: "".} 412 | proc mpz_submul*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 413 | importc: "mpz_submul", header: "".} 414 | proc mpz_submul_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 415 | importc: "mpz_submul_ui", header: "".} 416 | proc mpz_swap*(a2: mpz_ptr; a3: mpz_ptr) {.importc: "mpz_swap", 417 | header: "".} 418 | proc mpz_tdiv_ui*(a2: mpz_srcptr; a3: culong): culong {.importc: "mpz_tdiv_ui", 419 | header: "".} 420 | proc mpz_tdiv_q*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 421 | importc: "mpz_tdiv_q", header: "".} 422 | proc mpz_tdiv_q_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 423 | importc: "mpz_tdiv_q_2exp", header: "".} 424 | proc mpz_tdiv_q_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 425 | importc: "mpz_tdiv_q_ui", header: "".} 426 | proc mpz_tdiv_qr*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 427 | importc: "mpz_tdiv_qr", header: "".} 428 | proc mpz_tdiv_qr_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: culong): culong {. 429 | importc: "mpz_tdiv_qr_ui", header: "".} 430 | proc mpz_tdiv_r*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 431 | importc: "mpz_tdiv_r", header: "".} 432 | proc mpz_tdiv_r_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 433 | importc: "mpz_tdiv_r_2exp", header: "".} 434 | proc mpz_tdiv_r_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 435 | importc: "mpz_tdiv_r_ui", header: "".} 436 | proc mpz_tstbit*(a2: mpz_srcptr; a3: mp_bitcnt_t): cint {.importc: "mpz_tstbit", 437 | header: "".} 438 | proc mpz_ui_pow_ui*(a2: mpz_ptr; a3: culong; a4: culong) {. 439 | importc: "mpz_ui_pow_ui", header: "".} 440 | proc mpz_urandomb*(a2: mpz_ptr; a3: gmp_randstate_t; a4: mp_bitcnt_t) {. 441 | importc: "mpz_urandomb", header: "".} 442 | proc mpz_urandomm*(a2: mpz_ptr; a3: gmp_randstate_t; a4: mpz_srcptr) {. 443 | importc: "mpz_urandomm", header: "".} 444 | proc mpz_xor*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_xor", 445 | header: "".} 446 | proc mpz_limbs_read*(a2: mpz_srcptr): mp_srcptr {.importc: "mpz_limbs_read", 447 | header: "".} 448 | proc mpz_limbs_write*(a2: mpz_ptr; a3: mp_size_t): mp_ptr {. 449 | importc: "mpz_limbs_write", header: "".} 450 | proc mpz_limbs_modify*(a2: mpz_ptr; a3: mp_size_t): mp_ptr {. 451 | importc: "mpz_limbs_modify", header: "".} 452 | proc mpz_limbs_finish*(a2: mpz_ptr; a3: mp_size_t) {. 453 | importc: "mpz_limbs_finish", header: "".} 454 | proc mpz_roinit_n*(a2: mpz_ptr; a3: mp_srcptr; a4: mp_size_t): mpz_srcptr {. 455 | importc: "mpz_roinit_n", header: "".} 456 | proc mpq_add*(a2: mpq_ptr; a3: mpq_srcptr; a4: mpq_srcptr) {.importc: "mpq_add", 457 | header: "".} 458 | proc mpq_canonicalize*(a2: mpq_ptr) {.importc: "mpq_canonicalize", 459 | header: "".} 460 | proc mpq_clear*(a2: mpq_ptr) {.importc: "mpq_clear", header: "".} 461 | proc mpq_clears*(a2: mpq_ptr) {.varargs, importc: "mpq_clears", 462 | header: "".} 463 | proc mpq_cmp*(a2: mpq_srcptr; a3: mpq_srcptr): cint {.importc: "mpq_cmp", 464 | header: "".} 465 | proc m_mpq_cmp_si*(a2: mpq_srcptr; a3: clong; a4: culong): cint {. 466 | importc: "_mpq_cmp_si", header: "".} 467 | proc m_mpq_cmp_ui*(a2: mpq_srcptr; a3: culong; a4: culong): cint {. 468 | importc: "_mpq_cmp_ui", header: "".} 469 | proc mpq_div*(a2: mpq_ptr; a3: mpq_srcptr; a4: mpq_srcptr) {.importc: "mpq_div", 470 | header: "".} 471 | proc mpq_div_2exp*(a2: mpq_ptr; a3: mpq_srcptr; a4: mp_bitcnt_t) {. 472 | importc: "mpq_div_2exp", header: "".} 473 | proc mpq_equal*(a2: mpq_srcptr; a3: mpq_srcptr): cint {.importc: "mpq_equal", 474 | header: "".} 475 | proc mpq_get_num*(a2: mpz_ptr; a3: mpq_srcptr) {.importc: "mpq_get_num", 476 | header: "".} 477 | proc mpq_get_den*(a2: mpz_ptr; a3: mpq_srcptr) {.importc: "mpq_get_den", 478 | header: "".} 479 | proc mpq_get_d*(a2: mpq_srcptr): cdouble {.importc: "mpq_get_d", 480 | header: "".} 481 | proc mpq_get_str*(a2: cstring; a3: cint; a4: mpq_srcptr): cstring {. 482 | importc: "mpq_get_str", header: "".} 483 | proc mpq_init*(a2: mpq_ptr) {.importc: "mpq_init", header: "".} 484 | proc mpq_inits*(a2: mpq_ptr) {.varargs, importc: "mpq_inits", header: "".} 485 | proc mpq_inp_str*(a2: mpq_ptr; a3: ptr FILE; a4: cint): csize {. 486 | importc: "mpq_inp_str", header: "".} 487 | proc mpq_inv*(a2: mpq_ptr; a3: mpq_srcptr) {.importc: "mpq_inv", 488 | header: "".} 489 | proc mpq_mul*(a2: mpq_ptr; a3: mpq_srcptr; a4: mpq_srcptr) {.importc: "mpq_mul", 490 | header: "".} 491 | proc mpq_mul_2exp*(a2: mpq_ptr; a3: mpq_srcptr; a4: mp_bitcnt_t) {. 492 | importc: "mpq_mul_2exp", header: "".} 493 | proc mpq_out_str*(a2: ptr FILE; a3: cint; a4: mpq_srcptr): csize {. 494 | importc: "mpq_out_str", header: "".} 495 | proc mpq_set*(a2: mpq_ptr; a3: mpq_srcptr) {.importc: "mpq_set", 496 | header: "".} 497 | proc mpq_set_d*(a2: mpq_ptr; a3: cdouble) {.importc: "mpq_set_d", 498 | header: "".} 499 | proc mpq_set_den*(a2: mpq_ptr; a3: mpz_srcptr) {.importc: "mpq_set_den", 500 | header: "".} 501 | proc mpq_set_f*(a2: mpq_ptr; a3: mpf_srcptr) {.importc: "mpq_set_f", 502 | header: "".} 503 | proc mpq_set_num*(a2: mpq_ptr; a3: mpz_srcptr) {.importc: "mpq_set_num", 504 | header: "".} 505 | proc mpq_set_si*(a2: mpq_ptr; a3: clong; a4: culong) {.importc: "mpq_set_si", 506 | header: "".} 507 | proc mpq_set_str*(a2: mpq_ptr; a3: cstring; a4: cint): cint {. 508 | importc: "mpq_set_str", header: "".} 509 | proc mpq_set_ui*(a2: mpq_ptr; a3: culong; a4: culong) {.importc: "mpq_set_ui", 510 | header: "".} 511 | proc mpq_set_z*(a2: mpq_ptr; a3: mpz_srcptr) {.importc: "mpq_set_z", 512 | header: "".} 513 | proc mpq_sub*(a2: mpq_ptr; a3: mpq_srcptr; a4: mpq_srcptr) {.importc: "mpq_sub", 514 | header: "".} 515 | proc mpq_swap*(a2: mpq_ptr; a3: mpq_ptr) {.importc: "mpq_swap", 516 | header: "".} 517 | proc mpf_abs*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_abs", 518 | header: "".} 519 | proc mpf_add*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {.importc: "mpf_add", 520 | header: "".} 521 | proc mpf_add_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 522 | importc: "mpf_add_ui", header: "".} 523 | proc mpf_ceil*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_ceil", 524 | header: "".} 525 | proc mpf_clear*(a2: mpf_ptr) {.importc: "mpf_clear", header: "".} 526 | proc mpf_clears*(a2: mpf_ptr) {.varargs, importc: "mpf_clears", 527 | header: "".} 528 | proc mpf_cmp*(a2: mpf_srcptr; a3: mpf_srcptr): cint {.importc: "mpf_cmp", 529 | header: "".} 530 | proc mpf_cmp_d*(a2: mpf_srcptr; a3: cdouble): cint {.importc: "mpf_cmp_d", 531 | header: "".} 532 | proc mpf_cmp_si*(a2: mpf_srcptr; a3: clong): cint {.importc: "mpf_cmp_si", 533 | header: "".} 534 | proc mpf_cmp_ui*(a2: mpf_srcptr; a3: culong): cint {.importc: "mpf_cmp_ui", 535 | header: "".} 536 | proc mpf_div*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {.importc: "mpf_div", 537 | header: "".} 538 | proc mpf_div_2exp*(a2: mpf_ptr; a3: mpf_srcptr; a4: mp_bitcnt_t) {. 539 | importc: "mpf_div_2exp", header: "".} 540 | proc mpf_div_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 541 | importc: "mpf_div_ui", header: "".} 542 | proc mpf_dump*(a2: mpf_srcptr) {.importc: "mpf_dump", header: "".} 543 | proc mpf_eq*(a2: mpf_srcptr; a3: mpf_srcptr; a4: mp_bitcnt_t): cint {. 544 | importc: "mpf_eq", header: "".} 545 | proc mpf_fits_sint_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_sint_p", 546 | header: "".} 547 | proc mpf_fits_slong_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_slong_p", 548 | header: "".} 549 | proc mpf_fits_sshort_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_sshort_p", 550 | header: "".} 551 | proc mpf_fits_uint_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_uint_p", 552 | header: "".} 553 | proc mpf_fits_ulong_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_ulong_p", 554 | header: "".} 555 | proc mpf_fits_ushort_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_ushort_p", 556 | header: "".} 557 | proc mpf_floor*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_floor", 558 | header: "".} 559 | proc mpf_get_d*(a2: mpf_srcptr): cdouble {.importc: "mpf_get_d", 560 | header: "".} 561 | proc mpf_get_d_2exp*(a2: ptr clong; a3: mpf_srcptr): cdouble {. 562 | importc: "mpf_get_d_2exp", header: "".} 563 | proc mpf_get_default_prec*(): mp_bitcnt_t {.importc: "mpf_get_default_prec", 564 | header: "".} 565 | proc mpf_get_prec*(a2: mpf_srcptr): mp_bitcnt_t {.importc: "mpf_get_prec", 566 | header: "".} 567 | proc mpf_get_si*(a2: mpf_srcptr): clong {.importc: "mpf_get_si", 568 | header: "".} 569 | proc mpf_get_str*(a2: cstring; a3: ptr mp_exp_t; a4: cint; a5: csize; 570 | a6: mpf_srcptr): cstring {.importc: "mpf_get_str", 571 | header: "".} 572 | proc mpf_get_ui*(a2: mpf_srcptr): culong {.importc: "mpf_get_ui", 573 | header: "".} 574 | proc mpf_init*(a2: mpf_ptr) {.importc: "mpf_init", header: "".} 575 | proc mpf_init2*(a2: mpf_ptr; a3: mp_bitcnt_t) {.importc: "mpf_init2", 576 | header: "".} 577 | proc mpf_inits*(a2: mpf_ptr) {.varargs, importc: "mpf_inits", header: "".} 578 | proc mpf_init_set*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_init_set", 579 | header: "".} 580 | proc mpf_init_set_d*(a2: mpf_ptr; a3: cdouble) {.importc: "mpf_init_set_d", 581 | header: "".} 582 | proc mpf_init_set_si*(a2: mpf_ptr; a3: clong) {.importc: "mpf_init_set_si", 583 | header: "".} 584 | proc mpf_init_set_str*(a2: mpf_ptr; a3: cstring; a4: cint): cint {. 585 | importc: "mpf_init_set_str", header: "".} 586 | proc mpf_init_set_ui*(a2: mpf_ptr; a3: culong) {.importc: "mpf_init_set_ui", 587 | header: "".} 588 | proc mpf_inp_str*(a2: mpf_ptr; a3: ptr FILE; a4: cint): csize {. 589 | importc: "mpf_inp_str", header: "".} 590 | proc mpf_integer_p*(a2: mpf_srcptr): cint {.importc: "mpf_integer_p", 591 | header: "".} 592 | proc mpf_mul*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {.importc: "mpf_mul", 593 | header: "".} 594 | proc mpf_mul_2exp*(a2: mpf_ptr; a3: mpf_srcptr; a4: mp_bitcnt_t) {. 595 | importc: "mpf_mul_2exp", header: "".} 596 | proc mpf_mul_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 597 | importc: "mpf_mul_ui", header: "".} 598 | proc mpf_neg*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_neg", 599 | header: "".} 600 | proc mpf_out_str*(a2: ptr FILE; a3: cint; a4: csize; a5: mpf_srcptr): csize {. 601 | importc: "mpf_out_str", header: "".} 602 | proc mpf_pow_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 603 | importc: "mpf_pow_ui", header: "".} 604 | proc mpf_random2*(a2: mpf_ptr; a3: mp_size_t; a4: mp_exp_t) {. 605 | importc: "mpf_random2", header: "".} 606 | proc mpf_reldiff*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {. 607 | importc: "mpf_reldiff", header: "".} 608 | proc mpf_set*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_set", 609 | header: "".} 610 | proc mpf_set_d*(a2: mpf_ptr; a3: cdouble) {.importc: "mpf_set_d", 611 | header: "".} 612 | proc mpf_set_default_prec*(a2: mp_bitcnt_t) {.importc: "mpf_set_default_prec", 613 | header: "".} 614 | proc mpf_set_prec*(a2: mpf_ptr; a3: mp_bitcnt_t) {.importc: "mpf_set_prec", 615 | header: "".} 616 | proc mpf_set_prec_raw*(a2: mpf_ptr; a3: mp_bitcnt_t) {. 617 | importc: "mpf_set_prec_raw", header: "".} 618 | proc mpf_set_q*(a2: mpf_ptr; a3: mpq_srcptr) {.importc: "mpf_set_q", 619 | header: "".} 620 | proc mpf_set_si*(a2: mpf_ptr; a3: clong) {.importc: "mpf_set_si", 621 | header: "".} 622 | proc mpf_set_str*(a2: mpf_ptr; a3: cstring; a4: cint): cint {. 623 | importc: "mpf_set_str", header: "".} 624 | proc mpf_set_ui*(a2: mpf_ptr; a3: culong) {.importc: "mpf_set_ui", 625 | header: "".} 626 | proc mpf_set_z*(a2: mpf_ptr; a3: mpz_srcptr) {.importc: "mpf_set_z", 627 | header: "".} 628 | proc mpf_size*(a2: mpf_srcptr): csize {.importc: "mpf_size", header: "".} 629 | proc mpf_sqrt*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_sqrt", 630 | header: "".} 631 | proc mpf_sqrt_ui*(a2: mpf_ptr; a3: culong) {.importc: "mpf_sqrt_ui", 632 | header: "".} 633 | proc mpf_sub*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {.importc: "mpf_sub", 634 | header: "".} 635 | proc mpf_sub_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 636 | importc: "mpf_sub_ui", header: "".} 637 | proc mpf_swap*(a2: mpf_ptr; a3: mpf_ptr) {.importc: "mpf_swap", 638 | header: "".} 639 | proc mpf_trunc*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_trunc", 640 | header: "".} 641 | proc mpf_ui_div*(a2: mpf_ptr; a3: culong; a4: mpf_srcptr) {. 642 | importc: "mpf_ui_div", header: "".} 643 | proc mpf_ui_sub*(a2: mpf_ptr; a3: culong; a4: mpf_srcptr) {. 644 | importc: "mpf_ui_sub", header: "".} 645 | proc mpf_urandomb*(a2: mpf_t; a3: gmp_randstate_t; a4: mp_bitcnt_t) {. 646 | importc: "mpf_urandomb", header: "".} 647 | proc mpn_add_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t): mp_limb_t {. 648 | importc: "mpn_add_n", header: "".} 649 | proc mpn_addmul_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 650 | importc: "mpn_addmul_1", header: "".} 651 | proc mpn_divexact_by3c*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 652 | importc: "mpn_divexact_by3c", header: "".} 653 | proc mpn_divrem*(a2: mp_ptr; a3: mp_size_t; a4: mp_ptr; a5: mp_size_t; 654 | a6: mp_srcptr; a7: mp_size_t): mp_limb_t {. 655 | importc: "mpn_divrem", header: "".} 656 | proc mpn_divrem_1*(a2: mp_ptr; a3: mp_size_t; a4: mp_srcptr; a5: mp_size_t; 657 | a6: mp_limb_t): mp_limb_t {.importc: "mpn_divrem_1", 658 | header: "".} 659 | proc mpn_divrem_2*(a2: mp_ptr; a3: mp_size_t; a4: mp_ptr; a5: mp_size_t; 660 | a6: mp_srcptr): mp_limb_t {.importc: "mpn_divrem_2", 661 | header: "".} 662 | proc mpn_div_qr_1*(a2: mp_ptr; a3: ptr mp_limb_t; a4: mp_srcptr; a5: mp_size_t; 663 | a6: mp_limb_t): mp_limb_t {.importc: "mpn_div_qr_1", 664 | header: "".} 665 | proc mpn_div_qr_2*(a2: mp_ptr; a3: mp_ptr; a4: mp_srcptr; a5: mp_size_t; 666 | a6: mp_srcptr): mp_limb_t {.importc: "mpn_div_qr_2", 667 | header: "".} 668 | proc mpn_gcd*(a2: mp_ptr; a3: mp_ptr; a4: mp_size_t; a5: mp_ptr; a6: mp_size_t): mp_size_t {. 669 | importc: "mpn_gcd", header: "".} 670 | proc mpn_gcd_1*(a2: mp_srcptr; a3: mp_size_t; a4: mp_limb_t): mp_limb_t {. 671 | importc: "mpn_gcd_1", header: "".} 672 | proc mpn_gcdext_1*(a2: ptr mp_limb_signed_t; a3: ptr mp_limb_signed_t; 673 | a4: mp_limb_t; a5: mp_limb_t): mp_limb_t {. 674 | importc: "mpn_gcdext_1", header: "".} 675 | proc mpn_gcdext*(a2: mp_ptr; a3: mp_ptr; a4: ptr mp_size_t; a5: mp_ptr; 676 | a6: mp_size_t; a7: mp_ptr; a8: mp_size_t): mp_size_t {. 677 | importc: "mpn_gcdext", header: "".} 678 | proc mpn_get_str*(a2: ptr cuchar; a3: cint; a4: mp_ptr; a5: mp_size_t): csize {. 679 | importc: "mpn_get_str", header: "".} 680 | proc mpn_hamdist*(a2: mp_srcptr; a3: mp_srcptr; a4: mp_size_t): mp_bitcnt_t {. 681 | importc: "mpn_hamdist", header: "".} 682 | proc mpn_lshift*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: cuint): mp_limb_t {. 683 | importc: "mpn_lshift", header: "".} 684 | proc mpn_mod_1*(a2: mp_srcptr; a3: mp_size_t; a4: mp_limb_t): mp_limb_t {. 685 | importc: "mpn_mod_1", header: "".} 686 | proc mpn_mul*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_srcptr; 687 | a6: mp_size_t): mp_limb_t {.importc: "mpn_mul", header: "".} 688 | proc mpn_mul_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 689 | importc: "mpn_mul_1", header: "".} 690 | proc mpn_mul_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 691 | importc: "mpn_mul_n", header: "".} 692 | proc mpn_sqr*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t) {.importc: "mpn_sqr", 693 | header: "".} 694 | proc mpn_neg*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t): mp_limb_t {. 695 | importc: "mpn_neg", header: "".} 696 | proc mpn_com*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t) {.importc: "mpn_com", 697 | header: "".} 698 | proc mpn_perfect_square_p*(a2: mp_srcptr; a3: mp_size_t): cint {. 699 | importc: "mpn_perfect_square_p", header: "".} 700 | proc mpn_perfect_power_p*(a2: mp_srcptr; a3: mp_size_t): cint {. 701 | importc: "mpn_perfect_power_p", header: "".} 702 | proc mpn_popcount*(a2: mp_srcptr; a3: mp_size_t): mp_bitcnt_t {. 703 | importc: "mpn_popcount", header: "".} 704 | proc mpn_pow_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t; 705 | a6: mp_ptr): mp_size_t {.importc: "mpn_pow_1", header: "".} 706 | proc mpn_preinv_mod_1*(a2: mp_srcptr; a3: mp_size_t; a4: mp_limb_t; 707 | a5: mp_limb_t): mp_limb_t {.importc: "mpn_preinv_mod_1", 708 | header: "".} 709 | proc mpn_random*(a2: mp_ptr; a3: mp_size_t) {.importc: "mpn_random", 710 | header: "".} 711 | proc mpn_random2*(a2: mp_ptr; a3: mp_size_t) {.importc: "mpn_random2", 712 | header: "".} 713 | proc mpn_rshift*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: cuint): mp_limb_t {. 714 | importc: "mpn_rshift", header: "".} 715 | proc mpn_scan0*(a2: mp_srcptr; a3: mp_bitcnt_t): mp_bitcnt_t {. 716 | importc: "mpn_scan0", header: "".} 717 | proc mpn_scan1*(a2: mp_srcptr; a3: mp_bitcnt_t): mp_bitcnt_t {. 718 | importc: "mpn_scan1", header: "".} 719 | proc mpn_set_str*(a2: mp_ptr; a3: ptr cuchar; a4: csize; a5: cint): mp_size_t {. 720 | importc: "mpn_set_str", header: "".} 721 | proc mpn_sizeinbase*(a2: mp_srcptr; a3: mp_size_t; a4: cint): csize {. 722 | importc: "mpn_sizeinbase", header: "".} 723 | proc mpn_sqrtrem*(a2: mp_ptr; a3: mp_ptr; a4: mp_srcptr; a5: mp_size_t): mp_size_t {. 724 | importc: "mpn_sqrtrem", header: "".} 725 | proc mpn_sub*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_srcptr; 726 | a6: mp_size_t): mp_limb_t {.importc: "mpn_sub", header: "".} 727 | proc mpn_sub_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 728 | importc: "mpn_sub_1", header: "".} 729 | proc mpn_sub_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t): mp_limb_t {. 730 | importc: "mpn_sub_n", header: "".} 731 | proc mpn_submul_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 732 | importc: "mpn_submul_1", header: "".} 733 | proc mpn_tdiv_qr*(a2: mp_ptr; a3: mp_ptr; a4: mp_size_t; a5: mp_srcptr; 734 | a6: mp_size_t; a7: mp_srcptr; a8: mp_size_t) {. 735 | importc: "mpn_tdiv_qr", header: "".} 736 | proc mpn_and_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 737 | importc: "mpn_and_n", header: "".} 738 | proc mpn_andn_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 739 | importc: "mpn_andn_n", header: "".} 740 | proc mpn_nand_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 741 | importc: "mpn_nand_n", header: "".} 742 | proc mpn_ior_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 743 | importc: "mpn_ior_n", header: "".} 744 | proc mpn_iorn_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 745 | importc: "mpn_iorn_n", header: "".} 746 | proc mpn_nior_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 747 | importc: "mpn_nior_n", header: "".} 748 | proc mpn_xor_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 749 | importc: "mpn_xor_n", header: "".} 750 | proc mpn_xnor_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 751 | importc: "mpn_xnor_n", header: "".} 752 | proc mpn_copyi*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t) {. 753 | importc: "mpn_copyi", header: "".} 754 | proc mpn_copyd*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t) {. 755 | importc: "mpn_copyd", header: "".} 756 | proc mpn_zero*(a2: mp_ptr; a3: mp_size_t) {.importc: "mpn_zero", 757 | header: "".} 758 | proc mpn_cnd_add_n*(a2: mp_limb_t; a3: mp_ptr; a4: mp_srcptr; a5: mp_srcptr; 759 | a6: mp_size_t): mp_limb_t {.importc: "mpn_cnd_add_n", 760 | header: "".} 761 | proc mpn_cnd_sub_n*(a2: mp_limb_t; a3: mp_ptr; a4: mp_srcptr; a5: mp_srcptr; 762 | a6: mp_size_t): mp_limb_t {.importc: "mpn_cnd_sub_n", 763 | header: "".} 764 | proc mpn_sec_add_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t; 765 | a6: mp_ptr): mp_limb_t {.importc: "mpn_sec_add_1", 766 | header: "".} 767 | proc mpn_sec_add_1_itch*(a2: mp_size_t): mp_size_t {. 768 | importc: "mpn_sec_add_1_itch", header: "".} 769 | proc mpn_sec_sub_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t; 770 | a6: mp_ptr): mp_limb_t {.importc: "mpn_sec_sub_1", 771 | header: "".} 772 | proc mpn_sec_sub_1_itch*(a2: mp_size_t): mp_size_t {. 773 | importc: "mpn_sec_sub_1_itch", header: "".} 774 | proc mpn_sec_mul*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_srcptr; 775 | a6: mp_size_t; a7: mp_ptr) {.importc: "mpn_sec_mul", 776 | header: "".} 777 | proc mpn_sec_mul_itch*(a2: mp_size_t; a3: mp_size_t): mp_size_t {. 778 | importc: "mpn_sec_mul_itch", header: "".} 779 | proc mpn_sec_sqr*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_ptr) {. 780 | importc: "mpn_sec_sqr", header: "".} 781 | proc mpn_sec_sqr_itch*(a2: mp_size_t): mp_size_t {.importc: "mpn_sec_sqr_itch", 782 | header: "".} 783 | proc mpn_sec_powm*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_srcptr; 784 | a6: mp_bitcnt_t; a7: mp_srcptr; a8: mp_size_t; a9: mp_ptr) {. 785 | importc: "mpn_sec_powm", header: "".} 786 | proc mpn_sec_powm_itch*(a2: mp_size_t; a3: mp_bitcnt_t; a4: mp_size_t): mp_size_t {. 787 | importc: "mpn_sec_powm_itch", header: "".} 788 | proc mpn_sec_tabselect*(a2: ptr mp_limb_t; a3: ptr mp_limb_t; a4: mp_size_t; 789 | a5: mp_size_t; a6: mp_size_t) {. 790 | importc: "mpn_sec_tabselect", header: "".} 791 | proc mpn_sec_div_qr*(a2: mp_ptr; a3: mp_ptr; a4: mp_size_t; a5: mp_srcptr; 792 | a6: mp_size_t; a7: mp_ptr): mp_limb_t {. 793 | importc: "mpn_sec_div_qr", header: "".} 794 | proc mpn_sec_div_qr_itch*(a2: mp_size_t; a3: mp_size_t): mp_size_t {. 795 | importc: "mpn_sec_div_qr_itch", header: "".} 796 | proc mpn_sec_div_r*(a2: mp_ptr; a3: mp_size_t; a4: mp_srcptr; a5: mp_size_t; 797 | a6: mp_ptr) {.importc: "mpn_sec_div_r", header: "".} 798 | proc mpn_sec_div_r_itch*(a2: mp_size_t; a3: mp_size_t): mp_size_t {. 799 | importc: "mpn_sec_div_r_itch", header: "".} 800 | proc mpn_sec_invert*(a2: mp_ptr; a3: mp_ptr; a4: mp_srcptr; a5: mp_size_t; 801 | a6: mp_bitcnt_t; a7: mp_ptr): cint {. 802 | importc: "mpn_sec_invert", header: "".} 803 | proc mpn_sec_invert_itch*(a2: mp_size_t): mp_size_t {. 804 | importc: "mpn_sec_invert_itch", header: "".} 805 | # externed stuff 806 | 807 | proc mpz_abs*(mm_gmp_w: mpz_ptr; mm_gmp_u: mpz_srcptr) {.importc: "mpz_abs", 808 | header: "".} 809 | proc mpz_fits_uint_p*(mm_gmp_z: mpz_srcptr): cint {.importc: "mpz_fits_uint_p", 810 | header: "".} 811 | proc mpz_fits_ulong_p*(mm_gmp_z: mpz_srcptr): cint {.importc: "mpz_fits_ulong_p", 812 | header: "".} 813 | proc mpz_fits_ushort_p*(mm_gmp_z: mpz_srcptr): cint {. 814 | importc: "mpz_fits_ushort_p", header: "".} 815 | proc mpz_get_ui*(mm_gmp_z: mpz_srcptr): culong {.importc: "mpz_get_ui", 816 | header: "".} 817 | proc mpz_getlimbn*(mm_gmp_z: mpz_srcptr; mm_gmp_n: mp_size_t): mp_limb_t {. 818 | importc: "mpz_getlimbn", header: "".} 819 | proc mpz_neg*(mm_gmp_w: mpz_ptr; mm_gmp_u: mpz_srcptr) {.importc: "mpz_neg", 820 | header: "".} 821 | proc mpz_perfect_square_p*(mm_gmp_a: mpz_srcptr): cint {. 822 | importc: "mpz_perfect_square_p", header: "".} 823 | proc mpz_popcount*(mm_gmp_u: mpz_srcptr): mp_bitcnt_t {.importc: "mpz_popcount", 824 | header: "".} 825 | proc mpz_set_q*(mm_gmp_w: mpz_ptr; mm_gmp_u: mpq_srcptr) {.importc: "mpz_set_q", 826 | header: "".} 827 | proc mpz_size*(mm_gmp_z: mpz_srcptr): csize {.importc: "mpz_size", 828 | header: "".} 829 | proc mpq_abs*(mm_gmp_w: mpq_ptr; mm_gmp_u: mpq_srcptr) {.importc: "mpq_abs", 830 | header: "".} 831 | proc mpq_neg*(mm_gmp_w: mpq_ptr; mm_gmp_u: mpq_srcptr) {.importc: "mpq_neg", 832 | header: "".} 833 | proc mpn_add*(mm_gmp_wp: mp_ptr; mm_gmp_xp: mp_srcptr; mm_gmp_xsize: mp_size_t; 834 | mm_gmp_yp: mp_srcptr; mm_gmp_ysize: mp_size_t): mp_limb_t {. 835 | importc: "mpn_add", header: "".} 836 | proc mpn_add_1*(mm_gmp_dst: mp_ptr; mm_gmp_src: mp_srcptr; mm_gmp_size: mp_size_t; 837 | mm_gmp_n: mp_limb_t): mp_limb_t {.importc: "mpn_add_1", 838 | header: "".} 839 | proc mpn_cmp*(mm_gmp_xp: mp_srcptr; mm_gmp_yp: mp_srcptr; mm_gmp_size: mp_size_t): cint {. 840 | importc: "mpn_cmp", header: "".} 841 | # this seems to conflict with earlier definition 842 | #proc mpn_sub*(mm_gmp_wp: mp_ptr; mm_gmp_xp: mp_srcptr; mm_gmp_xsize: mp_size_t; 843 | # mm_gmp_yp: mp_srcptr; mm_gmp_ysize: mp_size_t): mp_limb_t {. 844 | # importc: "mpn_sub", header: "".} 845 | #proc mpn_sub_1*(mm_gmp_dst: mp_ptr; mm_gmp_src: mp_srcptr; mm_gmp_size: mp_size_t; 846 | # mm_gmp_n: mp_limb_t): mp_limb_t {.importc: "mpn_sub_1", 847 | # header: "".} 848 | #proc mpn_neg*(mm_gmp_rp: mp_ptr; mm_gmp_up: mp_srcptr; mm_gmp_n: mp_size_t): mp_limb_t {. 849 | # importc: "mpn_neg", header: "".} 850 | const 851 | GMP_ERROR_NONE* = 0 852 | GMP_ERROR_UNSUPPORTED_ARGUMENT* = 1 853 | GMP_ERROR_DIVISION_BY_ZERO* = 2 854 | GMP_ERROR_SQRT_OF_NEGATIVE* = 4 855 | GMP_ERROR_INVALID_ARGUMENT* = 8 856 | 857 | when isMainModule: 858 | discard 859 | 860 | -------------------------------------------------------------------------------- /src/gmp/header.nim: -------------------------------------------------------------------------------- 1 | # 2 | # Nim GMP wrapper 3 | # (c) Copyright 2014 Will Szumski 4 | # 5 | # See the file "COPYING", included in this 6 | # distribution, for details about the copyright. 7 | # 8 | 9 | #FIXME: other OSes need include path? 10 | {.passl: "-lgmp".} 11 | 12 | type 13 | INNER_C_UNION_5532179898798000430* {.importc: "no_name", header: "".} = object {. 14 | union.} 15 | mp_lc* {.importc: "_mp_lc".}: pointer 16 | 17 | # should check limb sizes / import them directly? 18 | mp_limb_t* {.importc: "mp_limb_t", nodecl.} = uint 19 | mp_limb_signed_t* {.importc: "mp_limb_signed_t", nodecl.} = int 20 | mp_bitcnt_t* {.importc: "mp_bitcnt_t", nodecl.} = culong 21 | mm_mpz_struct* {.byref, importc: "__mpz_struct", header: "".} = object 22 | mp_alloc* {.importc: "_mp_alloc".}: cint 23 | mp_size* {.importc: "_mp_size".}: cint 24 | mp_d* {.importc: "_mp_d".}: ptr mp_limb_t 25 | 26 | MP_INT* = mm_mpz_struct 27 | #mpz_t* = array[1, mm_mpz_struct] 28 | mpz_t* = mm_mpz_struct 29 | mp_ptr* = ptr mp_limb_t 30 | mp_srcptr* = ptr mp_limb_t 31 | mp_size_t* {.importc: "mp_size_t", nodecl.} = clong 32 | mp_exp_t* {.importc: "mp_exp_t", nodecl.} = clong 33 | mm_mpq_struct* {.byref, importc: "__mpq_struct", header: "".} = object 34 | mp_num* {.importc: "_mp_num".}: mm_mpz_struct 35 | mp_den* {.importc: "_mp_den".}: mm_mpz_struct 36 | 37 | MP_RAT* = mm_mpq_struct 38 | #mpq_t* = array[1, mm_mpq_struct] 39 | mpq_t* = mm_mpq_struct 40 | mm_mpf_struct* {.byref, importc: "__mpf_struct", header: "".} = object 41 | mp_prec* {.importc: "_mp_prec".}: cint 42 | mp_size* {.importc: "_mp_size".}: cint 43 | mp_exp* {.importc: "_mp_exp".}: mp_exp_t 44 | mp_d* {.importc: "_mp_d".}: ptr mp_limb_t 45 | 46 | #mpf_t* = array[1, mm_mpf_struct] 47 | mpf_t* = mm_mpf_struct 48 | gmp_randalg_t* = distinct cint 49 | mm_gmp_randstate_struct* {.importc: "__gmp_randstate_struct", header: "".} = object 50 | mp_seed* {.importc: "_mp_seed".}: mpz_t 51 | mp_alg* {.importc: "_mp_alg".}: gmp_randalg_t 52 | mp_algdata* {.importc: "_mp_algdata".}: INNER_C_UNION_5532179898798000430 53 | 54 | #gmp_randstate_t* = array[1, mm_gmp_randstate_struct] 55 | gmp_randstate_t* = mm_gmp_randstate_struct 56 | mpz_srcptr* = ptr mm_mpz_struct 57 | mpz_ptr* = ptr mm_mpz_struct 58 | mpf_srcptr* = ptr mm_mpf_struct 59 | mpf_ptr* = ptr mm_mpf_struct 60 | mpq_srcptr* = ptr mm_mpq_struct 61 | mpq_ptr* = ptr mm_mpq_struct 62 | 63 | include extratypes 64 | 65 | const 66 | GMP_RAND_ALG_DEFAULT: gmp_randalg_t = 0.gmp_randalg_t 67 | GMP_RAND_ALG_LC: gmp_randalg_t = GMP_RAND_ALG_DEFAULT 68 | 69 | proc mpq_numref*(a2: mpq_ptr): mpz_ptr {.importc: "mpq_numref", 70 | header: "".} 71 | proc mpq_numref*(a2: var mpq_t): mpz_ptr {.importc: "mpq_numref", 72 | header: "".} 73 | proc mpq_denref*(a2: mpq_ptr): mpz_ptr {.importc: "mpq_denref", 74 | header: "".} 75 | proc mpq_denref*(a2: var mpq_t): mpz_ptr {.importc: "mpq_denref", 76 | header: "".} 77 | proc mp_set_memory_functions*(a2: proc (a2: csize): pointer; a3: proc ( 78 | a2: pointer; a3: csize; a4: csize): pointer; 79 | a4: proc (a2: pointer; a3: csize)) {. 80 | importc: "mp_set_memory_functions", header: "".} 81 | proc mp_get_memory_functions*(a2: proc (a2: csize): pointer; a3: proc ( 82 | a2: pointer; a3: csize; a4: csize): pointer; 83 | a4: proc (a2: pointer; a3: csize)) {. 84 | importc: "mp_get_memory_functions", header: "".} 85 | var mp_bits_per_limb* {.importc: "mp_bits_per_limb", header: "".}: cint 86 | var gmp_errno* {.importc: "gmp_errno", header: "".}: cint 87 | var gmp_version* {.importc: "gmp_version", header: "".}: cstring 88 | proc gmp_randinit*(a2: gmp_randstate_t; a3: gmp_randalg_t) {.varargs, 89 | importc: "gmp_randinit", header: "".} 90 | proc gmp_randinit_default*(a2: gmp_randstate_t) {. 91 | importc: "gmp_randinit_default", header: "".} 92 | proc gmp_randinit_lc_2exp*(a2: gmp_randstate_t; a3: mpz_srcptr; a4: culong; 93 | a5: mp_bitcnt_t) {.importc: "gmp_randinit_lc_2exp", 94 | header: "".} 95 | proc gmp_randinit_lc_2exp*(a2: gmp_randstate_t; a3: mpz_t; a4: culong; 96 | a5: mp_bitcnt_t) {.importc: "gmp_randinit_lc_2exp", 97 | header: "".} 98 | proc gmp_randinit_lc_2exp_size*(a2: gmp_randstate_t; a3: mp_bitcnt_t): cint {. 99 | importc: "gmp_randinit_lc_2exp_size", header: "".} 100 | proc gmp_randinit_mt*(a2: gmp_randstate_t) {.importc: "gmp_randinit_mt", 101 | header: "".} 102 | proc gmp_randinit_set*(a2: gmp_randstate_t; a3: ptr mm_gmp_randstate_struct) {. 103 | importc: "gmp_randinit_set", header: "".} 104 | proc gmp_randseed*(a2: gmp_randstate_t; a3: mpz_srcptr) {. 105 | importc: "gmp_randseed", header: "".} 106 | proc gmp_randseed*(a2: gmp_randstate_t; a3: mpz_t) {.importc: "gmp_randseed", 107 | header: "".} 108 | proc gmp_randseed_ui*(a2: gmp_randstate_t; a3: culong) {. 109 | importc: "gmp_randseed_ui", header: "".} 110 | proc gmp_randclear*(a2: gmp_randstate_t) {.importc: "gmp_randclear", 111 | header: "".} 112 | proc gmp_urandomb_ui*(a2: gmp_randstate_t; a3: culong): culong {. 113 | importc: "gmp_urandomb_ui", header: "".} 114 | proc gmp_urandomm_ui*(a2: gmp_randstate_t; a3: culong): culong {. 115 | importc: "gmp_urandomm_ui", header: "".} 116 | proc gmp_asprintf*(a2: cstringArray; a3: cstring): cint {.varargs, 117 | importc: "gmp_asprintf", header: "".} 118 | proc gmp_fprintf*(a2: File; a3: cstring): cint {.varargs, 119 | importc: "gmp_fprintf", header: "".} 120 | proc gmp_printf*(a2: cstring): cint {.varargs, importc: "gmp_printf", 121 | header: "".} 122 | proc gmp_snprintf*(a2: cstring; a3: csize; a4: cstring): cint {.varargs, 123 | importc: "gmp_snprintf", header: "".} 124 | proc gmp_sprintf*(a2: cstring; a3: cstring): cint {.varargs, 125 | importc: "gmp_sprintf", header: "".} 126 | proc gmp_fscanf*(a2: File; a3: cstring): cint {.varargs, 127 | importc: "gmp_fscanf", header: "".} 128 | proc gmp_scanf*(a2: cstring): cint {.varargs, importc: "gmp_scanf", 129 | header: "".} 130 | proc gmp_sscanf*(a2: cstring; a3: cstring): cint {.varargs, 131 | importc: "gmp_sscanf", header: "".} 132 | proc m_mpz_realloc*(a2: mpz_ptr; a3: mp_size_t): pointer {. 133 | importc: "_mpz_realloc", header: "".} 134 | proc m_mpz_realloc*(a2: var mpz_t; a3: mp_size_t): pointer {. 135 | importc: "_mpz_realloc", header: "".} 136 | proc mpz_add*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_add", 137 | header: "".} 138 | proc mpz_add*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_add", 139 | header: "".} 140 | proc mpz_add_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 141 | importc: "mpz_add_ui", header: "".} 142 | proc mpz_add_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {.importc: "mpz_add_ui", 143 | header: "".} 144 | proc mpz_addmul*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 145 | importc: "mpz_addmul", header: "".} 146 | proc mpz_addmul*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_addmul", 147 | header: "".} 148 | proc mpz_addmul_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 149 | importc: "mpz_addmul_ui", header: "".} 150 | proc mpz_addmul_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {. 151 | importc: "mpz_addmul_ui", header: "".} 152 | proc mpz_and*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_and", 153 | header: "".} 154 | proc mpz_and*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_and", 155 | header: "".} 156 | proc mpz_array_init*(a2: mpz_ptr; a3: mp_size_t; a4: mp_size_t) {. 157 | importc: "mpz_array_init", header: "".} 158 | proc mpz_array_init*(a2: var mpz_t; a3: mp_size_t; a4: mp_size_t) {. 159 | importc: "mpz_array_init", header: "".} 160 | proc mpz_bin_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 161 | importc: "mpz_bin_ui", header: "".} 162 | proc mpz_bin_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {.importc: "mpz_bin_ui", 163 | header: "".} 164 | proc mpz_bin_uiui*(a2: mpz_ptr; a3: culong; a4: culong) {. 165 | importc: "mpz_bin_uiui", header: "".} 166 | proc mpz_bin_uiui*(a2: var mpz_t; a3: culong; a4: culong) {. 167 | importc: "mpz_bin_uiui", header: "".} 168 | proc mpz_cdiv_q*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 169 | importc: "mpz_cdiv_q", header: "".} 170 | proc mpz_cdiv_q*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_cdiv_q", 171 | header: "".} 172 | proc mpz_cdiv_q_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 173 | importc: "mpz_cdiv_q_2exp", header: "".} 174 | proc mpz_cdiv_q_2exp*(a2: var mpz_t; a3: mpz_t; a4: mp_bitcnt_t) {. 175 | importc: "mpz_cdiv_q_2exp", header: "".} 176 | proc mpz_cdiv_q_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 177 | importc: "mpz_cdiv_q_ui", header: "".} 178 | proc mpz_cdiv_q_ui*(a2: var mpz_t; a3: mpz_t; a4: culong): culong {. 179 | importc: "mpz_cdiv_q_ui", header: "".} 180 | proc mpz_cdiv_qr*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 181 | importc: "mpz_cdiv_qr", header: "".} 182 | proc mpz_cdiv_qr*(a2: var mpz_t; a3: var mpz_t; a4: mpz_t; a5: mpz_t) {. 183 | importc: "mpz_cdiv_qr", header: "".} 184 | proc mpz_cdiv_qr_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: culong): culong {. 185 | importc: "mpz_cdiv_qr_ui", header: "".} 186 | proc mpz_cdiv_qr_ui*(a2: var mpz_t; a3: var mpz_t; a4: mpz_t; a5: culong): culong {. 187 | importc: "mpz_cdiv_qr_ui", header: "".} 188 | proc mpz_cdiv_r*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 189 | importc: "mpz_cdiv_r", header: "".} 190 | proc mpz_cdiv_r*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_cdiv_r", 191 | header: "".} 192 | proc mpz_cdiv_r_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 193 | importc: "mpz_cdiv_r_2exp", header: "".} 194 | proc mpz_cdiv_r_2exp*(a2: var mpz_t; a3: mpz_t; a4: mp_bitcnt_t) {. 195 | importc: "mpz_cdiv_r_2exp", header: "".} 196 | proc mpz_cdiv_r_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 197 | importc: "mpz_cdiv_r_ui", header: "".} 198 | proc mpz_cdiv_r_ui*(a2: var mpz_t; a3: mpz_t; a4: culong): culong {. 199 | importc: "mpz_cdiv_r_ui", header: "".} 200 | proc mpz_cdiv_ui*(a2: mpz_srcptr; a3: culong): culong {.importc: "mpz_cdiv_ui", 201 | header: "".} 202 | proc mpz_cdiv_ui*(a2: mpz_t; a3: culong): culong {.importc: "mpz_cdiv_ui", 203 | header: "".} 204 | proc mpz_clear*(a2: mpz_ptr) {.importc: "mpz_clear", header: "".} 205 | proc mpz_clear*(a2: var mpz_t) {.importc: "mpz_clear", header: "".} 206 | proc mpz_clears*(a2: mpz_ptr) {.varargs, importc: "mpz_clears", 207 | header: "".} 208 | proc mpz_clears*(a2: var mpz_t) {.varargs, importc: "mpz_clears", 209 | header: "".} 210 | proc mpz_clrbit*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_clrbit", 211 | header: "".} 212 | proc mpz_clrbit*(a2: var mpz_t; a3: mp_bitcnt_t) {.importc: "mpz_clrbit", 213 | header: "".} 214 | proc mpz_cmp*(a2: mpz_srcptr; a3: mpz_srcptr): cint {.importc: "mpz_cmp", 215 | header: "".} 216 | proc mpz_cmp*(a2: mpz_t; a3: mpz_t): cint {.importc: "mpz_cmp", 217 | header: "".} 218 | proc mpz_cmp_d*(a2: mpz_srcptr; a3: cdouble): cint {.importc: "mpz_cmp_d", 219 | header: "".} 220 | proc mpz_cmp_d*(a2: mpz_t; a3: cdouble): cint {.importc: "mpz_cmp_d", 221 | header: "".} 222 | proc mpz_cmp_si*(a2: mpz_srcptr; a3: clong): cint {.importc: "_mpz_cmp_si", 223 | header: "".} 224 | proc mpz_cmp_si*(a2: mpz_t; a3: clong): cint {.importc: "_mpz_cmp_si", 225 | header: "".} 226 | proc mpz_cmp_ui*(a2: mpz_srcptr; a3: culong): cint {.importc: "_mpz_cmp_ui", 227 | header: "".} 228 | proc mpz_cmp_ui*(a2: mpz_t; a3: culong): cint {.importc: "_mpz_cmp_ui", 229 | header: "".} 230 | proc mpz_cmpabs*(a2: mpz_srcptr; a3: mpz_srcptr): cint {.importc: "mpz_cmpabs", 231 | header: "".} 232 | proc mpz_cmpabs*(a2: mpz_t; a3: mpz_t): cint {.importc: "mpz_cmpabs", 233 | header: "".} 234 | proc mpz_cmpabs_d*(a2: mpz_srcptr; a3: cdouble): cint {.importc: "mpz_cmpabs_d", 235 | header: "".} 236 | proc mpz_cmpabs_d*(a2: mpz_t; a3: cdouble): cint {.importc: "mpz_cmpabs_d", 237 | header: "".} 238 | proc mpz_cmpabs_ui*(a2: mpz_srcptr; a3: culong): cint {. 239 | importc: "mpz_cmpabs_ui", header: "".} 240 | proc mpz_cmpabs_ui*(a2: mpz_t; a3: culong): cint {.importc: "mpz_cmpabs_ui", 241 | header: "".} 242 | proc mpz_com*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_com", 243 | header: "".} 244 | proc mpz_com*(a2: var mpz_t; a3: mpz_t) {.importc: "mpz_com", header: "".} 245 | proc mpz_combit*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_combit", 246 | header: "".} 247 | proc mpz_combit*(a2: var mpz_t; a3: mp_bitcnt_t) {.importc: "mpz_combit", 248 | header: "".} 249 | proc mpz_congruent_p*(a2: mpz_srcptr; a3: mpz_srcptr; a4: mpz_srcptr): cint {. 250 | importc: "mpz_congruent_p", header: "".} 251 | proc mpz_congruent_p*(a2: mpz_t; a3: mpz_t; a4: mpz_t): cint {. 252 | importc: "mpz_congruent_p", header: "".} 253 | proc mpz_congruent_2exp_p*(a2: mpz_srcptr; a3: mpz_srcptr; a4: mp_bitcnt_t): cint {. 254 | importc: "mpz_congruent_2exp_p", header: "".} 255 | proc mpz_congruent_2exp_p*(a2: mpz_t; a3: mpz_t; a4: mp_bitcnt_t): cint {. 256 | importc: "mpz_congruent_2exp_p", header: "".} 257 | proc mpz_congruent_ui_p*(a2: mpz_srcptr; a3: culong; a4: culong): cint {. 258 | importc: "mpz_congruent_ui_p", header: "".} 259 | proc mpz_congruent_ui_p*(a2: mpz_t; a3: culong; a4: culong): cint {. 260 | importc: "mpz_congruent_ui_p", header: "".} 261 | proc mpz_divexact*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 262 | importc: "mpz_divexact", header: "".} 263 | proc mpz_divexact*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {. 264 | importc: "mpz_divexact", header: "".} 265 | proc mpz_divexact_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 266 | importc: "mpz_divexact_ui", header: "".} 267 | proc mpz_divexact_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {. 268 | importc: "mpz_divexact_ui", header: "".} 269 | proc mpz_divisible_p*(a2: mpz_srcptr; a3: mpz_srcptr): cint {. 270 | importc: "mpz_divisible_p", header: "".} 271 | proc mpz_divisible_p*(a2: mpz_t; a3: mpz_t): cint {.importc: "mpz_divisible_p", 272 | header: "".} 273 | proc mpz_divisible_ui_p*(a2: mpz_srcptr; a3: culong): cint {. 274 | importc: "mpz_divisible_ui_p", header: "".} 275 | proc mpz_divisible_ui_p*(a2: mpz_t; a3: culong): cint {. 276 | importc: "mpz_divisible_ui_p", header: "".} 277 | proc mpz_divisible_2exp_p*(a2: mpz_srcptr; a3: mp_bitcnt_t): cint {. 278 | importc: "mpz_divisible_2exp_p", header: "".} 279 | proc mpz_divisible_2exp_p*(a2: mpz_t; a3: mp_bitcnt_t): cint {. 280 | importc: "mpz_divisible_2exp_p", header: "".} 281 | proc mpz_dump*(a2: mpz_srcptr) {.importc: "mpz_dump", header: "".} 282 | proc mpz_dump*(a2: mpz_t) {.importc: "mpz_dump", header: "".} 283 | proc mpz_export*(a2: pointer; a3: ptr csize; a4: cint; a5: csize; a6: cint; 284 | a7: csize; a8: mpz_srcptr): pointer {.importc: "mpz_export", 285 | header: "".} 286 | proc mpz_export*(a2: pointer; a3: ptr csize; a4: cint; a5: csize; a6: cint; 287 | a7: csize; a8: mpz_t): pointer {.importc: "mpz_export", 288 | header: "".} 289 | proc mpz_fac_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_fac_ui", 290 | header: "".} 291 | proc mpz_fac_ui*(a2: var mpz_t; a3: culong) {.importc: "mpz_fac_ui", 292 | header: "".} 293 | proc mpz_2fac_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_2fac_ui", 294 | header: "".} 295 | proc mpz_2fac_ui*(a2: var mpz_t; a3: culong) {.importc: "mpz_2fac_ui", 296 | header: "".} 297 | proc mpz_mfac_uiui*(a2: mpz_ptr; a3: culong; a4: culong) {. 298 | importc: "mpz_mfac_uiui", header: "".} 299 | proc mpz_mfac_uiui*(a2: var mpz_t; a3: culong; a4: culong) {. 300 | importc: "mpz_mfac_uiui", header: "".} 301 | proc mpz_primorial_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_primorial_ui", 302 | header: "".} 303 | proc mpz_primorial_ui*(a2: var mpz_t; a3: culong) {.importc: "mpz_primorial_ui", 304 | header: "".} 305 | proc mpz_fdiv_q*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 306 | importc: "mpz_fdiv_q", header: "".} 307 | proc mpz_fdiv_q*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_fdiv_q", 308 | header: "".} 309 | proc mpz_fdiv_q_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 310 | importc: "mpz_fdiv_q_2exp", header: "".} 311 | proc mpz_fdiv_q_2exp*(a2: var mpz_t; a3: mpz_t; a4: mp_bitcnt_t) {. 312 | importc: "mpz_fdiv_q_2exp", header: "".} 313 | proc mpz_fdiv_q_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 314 | importc: "mpz_fdiv_q_ui", header: "".} 315 | proc mpz_fdiv_q_ui*(a2: var mpz_t; a3: mpz_t; a4: culong): culong {. 316 | importc: "mpz_fdiv_q_ui", header: "".} 317 | proc mpz_fdiv_qr*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 318 | importc: "mpz_fdiv_qr", header: "".} 319 | proc mpz_fdiv_qr*(a2: var mpz_t; a3: var mpz_t; a4: mpz_t; a5: mpz_t) {. 320 | importc: "mpz_fdiv_qr", header: "".} 321 | proc mpz_fdiv_qr_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: culong): culong {. 322 | importc: "mpz_fdiv_qr_ui", header: "".} 323 | proc mpz_fdiv_qr_ui*(a2: var mpz_t; a3: var mpz_t; a4: mpz_t; a5: culong): culong {. 324 | importc: "mpz_fdiv_qr_ui", header: "".} 325 | proc mpz_fdiv_r*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 326 | importc: "mpz_fdiv_r", header: "".} 327 | proc mpz_fdiv_r*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_fdiv_r", 328 | header: "".} 329 | proc mpz_fdiv_r_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 330 | importc: "mpz_fdiv_r_2exp", header: "".} 331 | proc mpz_fdiv_r_2exp*(a2: var mpz_t; a3: mpz_t; a4: mp_bitcnt_t) {. 332 | importc: "mpz_fdiv_r_2exp", header: "".} 333 | proc mpz_fdiv_r_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 334 | importc: "mpz_fdiv_r_ui", header: "".} 335 | proc mpz_fdiv_r_ui*(a2: var mpz_t; a3: mpz_t; a4: culong): culong {. 336 | importc: "mpz_fdiv_r_ui", header: "".} 337 | proc mpz_fdiv_ui*(a2: mpz_srcptr; a3: culong): culong {.importc: "mpz_fdiv_ui", 338 | header: "".} 339 | proc mpz_fdiv_ui*(a2: mpz_t; a3: culong): culong {.importc: "mpz_fdiv_ui", 340 | header: "".} 341 | proc mpz_fib_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_fib_ui", 342 | header: "".} 343 | proc mpz_fib_ui*(a2: var mpz_t; a3: culong) {.importc: "mpz_fib_ui", 344 | header: "".} 345 | proc mpz_fib2_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: culong) {. 346 | importc: "mpz_fib2_ui", header: "".} 347 | proc mpz_fib2_ui*(a2: var mpz_t; a3: var mpz_t; a4: culong) {. 348 | importc: "mpz_fib2_ui", header: "".} 349 | proc mpz_fits_sint_p*(a2: mpz_srcptr): cint {.importc: "mpz_fits_sint_p", 350 | header: "".} 351 | proc mpz_fits_sint_p*(a2: mpz_t): cint {.importc: "mpz_fits_sint_p", 352 | header: "".} 353 | proc mpz_fits_slong_p*(a2: mpz_srcptr): cint {.importc: "mpz_fits_slong_p", 354 | header: "".} 355 | proc mpz_fits_slong_p*(a2: mpz_t): cint {.importc: "mpz_fits_slong_p", 356 | header: "".} 357 | proc mpz_fits_sshort_p*(a2: mpz_srcptr): cint {.importc: "mpz_fits_sshort_p", 358 | header: "".} 359 | proc mpz_fits_sshort_p*(a2: mpz_t): cint {.importc: "mpz_fits_sshort_p", 360 | header: "".} 361 | proc mpz_gcd*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_gcd", 362 | header: "".} 363 | proc mpz_gcd*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_gcd", 364 | header: "".} 365 | proc mpz_gcd_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 366 | importc: "mpz_gcd_ui", header: "".} 367 | proc mpz_gcd_ui*(a2: var mpz_t; a3: mpz_t; a4: culong): culong {. 368 | importc: "mpz_gcd_ui", header: "".} 369 | proc mpz_gcdext*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_ptr; a5: mpz_srcptr; 370 | a6: mpz_srcptr) {.importc: "mpz_gcdext", header: "".} 371 | proc mpz_gcdext*(a2: var mpz_t; a3: var mpz_t; a4: var mpz_t; a5: mpz_t; 372 | a6: mpz_t) {.importc: "mpz_gcdext", header: "".} 373 | proc mpz_get_d*(a2: mpz_srcptr): cdouble {.importc: "mpz_get_d", 374 | header: "".} 375 | proc mpz_get_d*(a2: mpz_t): cdouble {.importc: "mpz_get_d", header: "".} 376 | proc mpz_get_d_2exp*(a2: ptr clong; a3: mpz_srcptr): cdouble {. 377 | importc: "mpz_get_d_2exp", header: "".} 378 | proc mpz_get_d_2exp*(a2: ptr clong; a3: mpz_t): cdouble {. 379 | importc: "mpz_get_d_2exp", header: "".} 380 | proc mpz_get_si*(a2: mpz_srcptr): clong {.importc: "mpz_get_si", 381 | header: "".} 382 | proc mpz_get_si*(a2: mpz_t): clong {.importc: "mpz_get_si", header: "".} 383 | proc mpz_get_str*(a2: cstring; a3: cint; a4: mpz_srcptr): cstring {. 384 | importc: "mpz_get_str", header: "".} 385 | proc mpz_get_str*(a2: cstring; a3: cint; a4: mpz_t): cstring {. 386 | importc: "mpz_get_str", header: "".} 387 | proc mpz_hamdist*(a2: mpz_srcptr; a3: mpz_srcptr): mp_bitcnt_t {. 388 | importc: "mpz_hamdist", header: "".} 389 | proc mpz_hamdist*(a2: mpz_t; a3: mpz_t): mp_bitcnt_t {.importc: "mpz_hamdist", 390 | header: "".} 391 | proc mpz_import*(a2: mpz_ptr; a3: csize; a4: cint; a5: csize; a6: cint; 392 | a7: csize; a8: pointer) {.importc: "mpz_import", 393 | header: "".} 394 | proc mpz_import*(a2: var mpz_t; a3: csize; a4: cint; a5: csize; a6: cint; 395 | a7: csize; a8: pointer) {.importc: "mpz_import", 396 | header: "".} 397 | proc mpz_init*(a2: mpz_ptr) {.importc: "mpz_init", header: "".} 398 | proc mpz_init*(a2: var mpz_t) {.importc: "mpz_init", header: "".} 399 | proc mpz_init2*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_init2", 400 | header: "".} 401 | proc mpz_init2*(a2: var mpz_t; a3: mp_bitcnt_t) {.importc: "mpz_init2", 402 | header: "".} 403 | proc mpz_inits*(a2: mpz_ptr) {.varargs, importc: "mpz_inits", header: "".} 404 | proc mpz_inits*(a2: var mpz_t) {.varargs, importc: "mpz_inits", 405 | header: "".} 406 | proc mpz_init_set*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_init_set", 407 | header: "".} 408 | proc mpz_init_set*(a2: var mpz_t; a3: mpz_t) {.importc: "mpz_init_set", 409 | header: "".} 410 | proc mpz_init_set_d*(a2: mpz_ptr; a3: cdouble) {.importc: "mpz_init_set_d", 411 | header: "".} 412 | proc mpz_init_set_d*(a2: var mpz_t; a3: cdouble) {.importc: "mpz_init_set_d", 413 | header: "".} 414 | proc mpz_init_set_si*(a2: mpz_ptr; a3: clong) {.importc: "mpz_init_set_si", 415 | header: "".} 416 | proc mpz_init_set_si*(a2: var mpz_t; a3: clong) {.importc: "mpz_init_set_si", 417 | header: "".} 418 | proc mpz_init_set_str*(a2: mpz_ptr; a3: cstring; a4: cint): cint {. 419 | importc: "mpz_init_set_str", header: "".} 420 | proc mpz_init_set_str*(a2: var mpz_t; a3: cstring; a4: cint): cint {. 421 | importc: "mpz_init_set_str", header: "".} 422 | proc mpz_init_set_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_init_set_ui", 423 | header: "".} 424 | proc mpz_init_set_ui*(a2: var mpz_t; a3: culong) {.importc: "mpz_init_set_ui", 425 | header: "".} 426 | proc mpz_inp_raw*(a2: mpz_ptr; a3: File): csize {.importc: "mpz_inp_raw", 427 | header: "".} 428 | proc mpz_inp_raw*(a2: var mpz_t; a3: File): csize {.importc: "mpz_inp_raw", 429 | header: "".} 430 | proc mpz_inp_str*(a2: mpz_ptr; a3: File; a4: cint): csize {. 431 | importc: "mpz_inp_str", header: "".} 432 | proc mpz_inp_str*(a2: var mpz_t; a3: File; a4: cint): csize {. 433 | importc: "mpz_inp_str", header: "".} 434 | proc mpz_invert*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr): cint {. 435 | importc: "mpz_invert", header: "".} 436 | proc mpz_invert*(a2: var mpz_t; a3: mpz_t; a4: mpz_t): cint {. 437 | importc: "mpz_invert", header: "".} 438 | proc mpz_ior*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_ior", 439 | header: "".} 440 | proc mpz_ior*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_ior", 441 | header: "".} 442 | proc mpz_jacobi*(a2: mpz_srcptr; a3: mpz_srcptr): cint {.importc: "mpz_jacobi", 443 | header: "".} 444 | proc mpz_jacobi*(a2: mpz_t; a3: mpz_t): cint {.importc: "mpz_jacobi", 445 | header: "".} 446 | proc mpz_kronecker_si*(a2: mpz_srcptr; a3: clong): cint {. 447 | importc: "mpz_kronecker_si", header: "".} 448 | proc mpz_kronecker_si*(a2: mpz_t; a3: clong): cint {. 449 | importc: "mpz_kronecker_si", header: "".} 450 | proc mpz_kronecker_ui*(a2: mpz_srcptr; a3: culong): cint {. 451 | importc: "mpz_kronecker_ui", header: "".} 452 | proc mpz_kronecker_ui*(a2: mpz_t; a3: culong): cint {. 453 | importc: "mpz_kronecker_ui", header: "".} 454 | proc mpz_si_kronecker*(a2: clong; a3: mpz_srcptr): cint {. 455 | importc: "mpz_si_kronecker", header: "".} 456 | proc mpz_si_kronecker*(a2: clong; a3: mpz_t): cint {. 457 | importc: "mpz_si_kronecker", header: "".} 458 | proc mpz_ui_kronecker*(a2: culong; a3: mpz_srcptr): cint {. 459 | importc: "mpz_ui_kronecker", header: "".} 460 | proc mpz_ui_kronecker*(a2: culong; a3: mpz_t): cint {. 461 | importc: "mpz_ui_kronecker", header: "".} 462 | proc mpz_lcm*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_lcm", 463 | header: "".} 464 | proc mpz_lcm*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_lcm", 465 | header: "".} 466 | proc mpz_lcm_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 467 | importc: "mpz_lcm_ui", header: "".} 468 | proc mpz_lcm_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {.importc: "mpz_lcm_ui", 469 | header: "".} 470 | proc mpz_lucnum_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_lucnum_ui", 471 | header: "".} 472 | proc mpz_lucnum_ui*(a2: var mpz_t; a3: culong) {.importc: "mpz_lucnum_ui", 473 | header: "".} 474 | proc mpz_lucnum2_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: culong) {. 475 | importc: "mpz_lucnum2_ui", header: "".} 476 | proc mpz_lucnum2_ui*(a2: var mpz_t; a3: var mpz_t; a4: culong) {. 477 | importc: "mpz_lucnum2_ui", header: "".} 478 | proc mpz_millerrabin*(a2: mpz_srcptr; a3: cint): cint {. 479 | importc: "mpz_millerrabin", header: "".} 480 | proc mpz_millerrabin*(a2: mpz_t; a3: cint): cint {.importc: "mpz_millerrabin", 481 | header: "".} 482 | proc mpz_mod*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_mod", 483 | header: "".} 484 | proc mpz_mod*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_mod", 485 | header: "".} 486 | proc mpz_mul*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_mul", 487 | header: "".} 488 | proc mpz_mul*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_mul", 489 | header: "".} 490 | proc mpz_mul_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 491 | importc: "mpz_mul_2exp", header: "".} 492 | proc mpz_mul_2exp*(a2: var mpz_t; a3: mpz_t; a4: mp_bitcnt_t) {. 493 | importc: "mpz_mul_2exp", header: "".} 494 | proc mpz_mul_si*(a2: mpz_ptr; a3: mpz_srcptr; a4: clong) {. 495 | importc: "mpz_mul_si", header: "".} 496 | proc mpz_mul_si*(a2: var mpz_t; a3: mpz_t; a4: clong) {.importc: "mpz_mul_si", 497 | header: "".} 498 | proc mpz_mul_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 499 | importc: "mpz_mul_ui", header: "".} 500 | proc mpz_mul_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {.importc: "mpz_mul_ui", 501 | header: "".} 502 | proc mpz_nextprime*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_nextprime", 503 | header: "".} 504 | proc mpz_nextprime*(a2: var mpz_t; a3: mpz_t) {.importc: "mpz_nextprime", 505 | header: "".} 506 | proc mpz_out_raw*(a2: File; a3: mpz_srcptr): csize {.importc: "mpz_out_raw", 507 | header: "".} 508 | proc mpz_out_raw*(a2: File; a3: mpz_t): csize {.importc: "mpz_out_raw", 509 | header: "".} 510 | proc mpz_out_str*(a2: File; a3: cint; a4: mpz_srcptr): csize {. 511 | importc: "mpz_out_str", header: "".} 512 | proc mpz_out_str*(a2: File; a3: cint; a4: mpz_t): csize {. 513 | importc: "mpz_out_str", header: "".} 514 | proc mpz_perfect_power_p*(a2: mpz_srcptr): cint {. 515 | importc: "mpz_perfect_power_p", header: "".} 516 | proc mpz_perfect_power_p*(a2: mpz_t): cint {.importc: "mpz_perfect_power_p", 517 | header: "".} 518 | proc mpz_pow_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 519 | importc: "mpz_pow_ui", header: "".} 520 | proc mpz_pow_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {.importc: "mpz_pow_ui", 521 | header: "".} 522 | proc mpz_powm*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 523 | importc: "mpz_powm", header: "".} 524 | proc mpz_powm*(a2: var mpz_t; a3: mpz_t; a4: mpz_t; a5: mpz_t) {. 525 | importc: "mpz_powm", header: "".} 526 | proc mpz_powm_sec*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 527 | importc: "mpz_powm_sec", header: "".} 528 | proc mpz_powm_sec*(a2: var mpz_t; a3: mpz_t; a4: mpz_t; a5: mpz_t) {. 529 | importc: "mpz_powm_sec", header: "".} 530 | proc mpz_powm_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong; a5: mpz_srcptr) {. 531 | importc: "mpz_powm_ui", header: "".} 532 | proc mpz_powm_ui*(a2: var mpz_t; a3: mpz_t; a4: culong; a5: mpz_t) {. 533 | importc: "mpz_powm_ui", header: "".} 534 | proc mpz_probab_prime_p*(a2: mpz_srcptr; a3: cint): cint {. 535 | importc: "mpz_probab_prime_p", header: "".} 536 | proc mpz_probab_prime_p*(a2: mpz_t; a3: cint): cint {. 537 | importc: "mpz_probab_prime_p", header: "".} 538 | proc mpz_random*(a2: mpz_ptr; a3: mp_size_t) {.importc: "mpz_random", 539 | header: "".} 540 | proc mpz_random*(a2: var mpz_t; a3: mp_size_t) {.importc: "mpz_random", 541 | header: "".} 542 | proc mpz_random2*(a2: mpz_ptr; a3: mp_size_t) {.importc: "mpz_random2", 543 | header: "".} 544 | proc mpz_random2*(a2: var mpz_t; a3: mp_size_t) {.importc: "mpz_random2", 545 | header: "".} 546 | proc mpz_realloc2*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_realloc2", 547 | header: "".} 548 | proc mpz_realloc2*(a2: var mpz_t; a3: mp_bitcnt_t) {.importc: "mpz_realloc2", 549 | header: "".} 550 | proc mpz_remove*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr): mp_bitcnt_t {. 551 | importc: "mpz_remove", header: "".} 552 | proc mpz_remove*(a2: var mpz_t; a3: mpz_t; a4: mpz_t): mp_bitcnt_t {. 553 | importc: "mpz_remove", header: "".} 554 | proc mpz_root*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): cint {. 555 | importc: "mpz_root", header: "".} 556 | proc mpz_root*(a2: var mpz_t; a3: mpz_t; a4: culong): cint {. 557 | importc: "mpz_root", header: "".} 558 | proc mpz_rootrem*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: culong) {. 559 | importc: "mpz_rootrem", header: "".} 560 | proc mpz_rootrem*(a2: var mpz_t; a3: var mpz_t; a4: mpz_t; a5: culong) {. 561 | importc: "mpz_rootrem", header: "".} 562 | proc mpz_rrandomb*(a2: mpz_ptr; a3: gmp_randstate_t; a4: mp_bitcnt_t) {. 563 | importc: "mpz_rrandomb", header: "".} 564 | proc mpz_rrandomb*(a2: var mpz_t; a3: gmp_randstate_t; a4: mp_bitcnt_t) {. 565 | importc: "mpz_rrandomb", header: "".} 566 | proc mpz_scan0*(a2: mpz_srcptr; a3: mp_bitcnt_t): mp_bitcnt_t {. 567 | importc: "mpz_scan0", header: "".} 568 | proc mpz_scan0*(a2: mpz_t; a3: mp_bitcnt_t): mp_bitcnt_t {.importc: "mpz_scan0", 569 | header: "".} 570 | proc mpz_scan1*(a2: mpz_srcptr; a3: mp_bitcnt_t): mp_bitcnt_t {. 571 | importc: "mpz_scan1", header: "".} 572 | proc mpz_scan1*(a2: mpz_t; a3: mp_bitcnt_t): mp_bitcnt_t {.importc: "mpz_scan1", 573 | header: "".} 574 | proc mpz_set*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_set", 575 | header: "".} 576 | proc mpz_set*(a2: var mpz_t; a3: mpz_t) {.importc: "mpz_set", header: "".} 577 | proc mpz_set_d*(a2: mpz_ptr; a3: cdouble) {.importc: "mpz_set_d", 578 | header: "".} 579 | proc mpz_set_d*(a2: var mpz_t; a3: cdouble) {.importc: "mpz_set_d", 580 | header: "".} 581 | proc mpz_set_f*(a2: mpz_ptr; a3: mpf_srcptr) {.importc: "mpz_set_f", 582 | header: "".} 583 | proc mpz_set_f*(a2: var mpz_t; a3: mpf_t) {.importc: "mpz_set_f", 584 | header: "".} 585 | proc mpz_set_si*(a2: mpz_ptr; a3: clong) {.importc: "mpz_set_si", 586 | header: "".} 587 | proc mpz_set_si*(a2: var mpz_t; a3: clong) {.importc: "mpz_set_si", 588 | header: "".} 589 | proc mpz_set_str*(a2: mpz_ptr; a3: cstring; a4: cint): cint {. 590 | importc: "mpz_set_str", header: "".} 591 | proc mpz_set_str*(a2: var mpz_t; a3: cstring; a4: cint): cint {. 592 | importc: "mpz_set_str", header: "".} 593 | proc mpz_set_ui*(a2: mpz_ptr; a3: culong) {.importc: "mpz_set_ui", 594 | header: "".} 595 | proc mpz_set_ui*(a2: var mpz_t; a3: culong) {.importc: "mpz_set_ui", 596 | header: "".} 597 | proc mpz_setbit*(a2: mpz_ptr; a3: mp_bitcnt_t) {.importc: "mpz_setbit", 598 | header: "".} 599 | proc mpz_setbit*(a2: var mpz_t; a3: mp_bitcnt_t) {.importc: "mpz_setbit", 600 | header: "".} 601 | proc mpz_sizeinbase*(a2: mpz_srcptr; a3: cint): csize {. 602 | importc: "mpz_sizeinbase", header: "".} 603 | proc mpz_sizeinbase*(a2: mpz_t; a3: cint): csize {.importc: "mpz_sizeinbase", 604 | header: "".} 605 | proc mpz_sqrt*(a2: mpz_ptr; a3: mpz_srcptr) {.importc: "mpz_sqrt", 606 | header: "".} 607 | proc mpz_sqrt*(a2: var mpz_t; a3: mpz_t) {.importc: "mpz_sqrt", 608 | header: "".} 609 | proc mpz_sqrtrem*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr) {. 610 | importc: "mpz_sqrtrem", header: "".} 611 | proc mpz_sqrtrem*(a2: var mpz_t; a3: var mpz_t; a4: mpz_t) {. 612 | importc: "mpz_sqrtrem", header: "".} 613 | proc mpz_sub*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_sub", 614 | header: "".} 615 | proc mpz_sub*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_sub", 616 | header: "".} 617 | proc mpz_sub_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 618 | importc: "mpz_sub_ui", header: "".} 619 | proc mpz_sub_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {.importc: "mpz_sub_ui", 620 | header: "".} 621 | proc mpz_ui_sub*(a2: mpz_ptr; a3: culong; a4: mpz_srcptr) {. 622 | importc: "mpz_ui_sub", header: "".} 623 | proc mpz_ui_sub*(a2: var mpz_t; a3: culong; a4: mpz_t) {.importc: "mpz_ui_sub", 624 | header: "".} 625 | proc mpz_submul*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 626 | importc: "mpz_submul", header: "".} 627 | proc mpz_submul*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_submul", 628 | header: "".} 629 | proc mpz_submul_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong) {. 630 | importc: "mpz_submul_ui", header: "".} 631 | proc mpz_submul_ui*(a2: var mpz_t; a3: mpz_t; a4: culong) {. 632 | importc: "mpz_submul_ui", header: "".} 633 | proc mpz_swap*(a2: mpz_ptr; a3: mpz_ptr) {.importc: "mpz_swap", 634 | header: "".} 635 | proc mpz_swap*(a2: var mpz_t; a3: var mpz_t) {.importc: "mpz_swap", 636 | header: "".} 637 | proc mpz_tdiv_ui*(a2: mpz_srcptr; a3: culong): culong {.importc: "mpz_tdiv_ui", 638 | header: "".} 639 | proc mpz_tdiv_ui*(a2: mpz_t; a3: culong): culong {.importc: "mpz_tdiv_ui", 640 | header: "".} 641 | proc mpz_tdiv_q*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 642 | importc: "mpz_tdiv_q", header: "".} 643 | proc mpz_tdiv_q*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_tdiv_q", 644 | header: "".} 645 | proc mpz_tdiv_q_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 646 | importc: "mpz_tdiv_q_2exp", header: "".} 647 | proc mpz_tdiv_q_2exp*(a2: var mpz_t; a3: mpz_t; a4: mp_bitcnt_t) {. 648 | importc: "mpz_tdiv_q_2exp", header: "".} 649 | proc mpz_tdiv_q_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 650 | importc: "mpz_tdiv_q_ui", header: "".} 651 | proc mpz_tdiv_q_ui*(a2: var mpz_t; a3: mpz_t; a4: culong): culong {. 652 | importc: "mpz_tdiv_q_ui", header: "".} 653 | proc mpz_tdiv_qr*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: mpz_srcptr) {. 654 | importc: "mpz_tdiv_qr", header: "".} 655 | proc mpz_tdiv_qr*(a2: var mpz_t; a3: var mpz_t; a4: mpz_t; a5: mpz_t) {. 656 | importc: "mpz_tdiv_qr", header: "".} 657 | proc mpz_tdiv_qr_ui*(a2: mpz_ptr; a3: mpz_ptr; a4: mpz_srcptr; a5: culong): culong {. 658 | importc: "mpz_tdiv_qr_ui", header: "".} 659 | proc mpz_tdiv_qr_ui*(a2: var mpz_t; a3: var mpz_t; a4: mpz_t; a5: culong): culong {. 660 | importc: "mpz_tdiv_qr_ui", header: "".} 661 | proc mpz_tdiv_r*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {. 662 | importc: "mpz_tdiv_r", header: "".} 663 | proc mpz_tdiv_r*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_tdiv_r", 664 | header: "".} 665 | proc mpz_tdiv_r_2exp*(a2: mpz_ptr; a3: mpz_srcptr; a4: mp_bitcnt_t) {. 666 | importc: "mpz_tdiv_r_2exp", header: "".} 667 | proc mpz_tdiv_r_2exp*(a2: var mpz_t; a3: mpz_t; a4: mp_bitcnt_t) {. 668 | importc: "mpz_tdiv_r_2exp", header: "".} 669 | proc mpz_tdiv_r_ui*(a2: mpz_ptr; a3: mpz_srcptr; a4: culong): culong {. 670 | importc: "mpz_tdiv_r_ui", header: "".} 671 | proc mpz_tdiv_r_ui*(a2: var mpz_t; a3: mpz_t; a4: culong): culong {. 672 | importc: "mpz_tdiv_r_ui", header: "".} 673 | proc mpz_tstbit*(a2: mpz_srcptr; a3: mp_bitcnt_t): cint {.importc: "mpz_tstbit", 674 | header: "".} 675 | proc mpz_tstbit*(a2: mpz_t; a3: mp_bitcnt_t): cint {.importc: "mpz_tstbit", 676 | header: "".} 677 | proc mpz_ui_pow_ui*(a2: mpz_ptr; a3: culong; a4: culong) {. 678 | importc: "mpz_ui_pow_ui", header: "".} 679 | proc mpz_ui_pow_ui*(a2: var mpz_t; a3: culong; a4: culong) {. 680 | importc: "mpz_ui_pow_ui", header: "".} 681 | proc mpz_urandomb*(a2: mpz_ptr; a3: gmp_randstate_t; a4: mp_bitcnt_t) {. 682 | importc: "mpz_urandomb", header: "".} 683 | proc mpz_urandomb*(a2: var mpz_t; a3: gmp_randstate_t; a4: mp_bitcnt_t) {. 684 | importc: "mpz_urandomb", header: "".} 685 | proc mpz_urandomm*(a2: mpz_ptr; a3: gmp_randstate_t; a4: mpz_srcptr) {. 686 | importc: "mpz_urandomm", header: "".} 687 | proc mpz_urandomm*(a2: var mpz_t; a3: gmp_randstate_t; a4: mpz_t) {. 688 | importc: "mpz_urandomm", header: "".} 689 | proc mpz_xor*(a2: mpz_ptr; a3: mpz_srcptr; a4: mpz_srcptr) {.importc: "mpz_xor", 690 | header: "".} 691 | proc mpz_xor*(a2: var mpz_t; a3: mpz_t; a4: mpz_t) {.importc: "mpz_xor", 692 | header: "".} 693 | proc mpz_limbs_read*(a2: mpz_srcptr): mp_srcptr {.importc: "mpz_limbs_read", 694 | header: "".} 695 | proc mpz_limbs_read*(a2: mpz_t): mp_srcptr {.importc: "mpz_limbs_read", 696 | header: "".} 697 | proc mpz_limbs_write*(a2: mpz_ptr; a3: mp_size_t): mp_ptr {. 698 | importc: "mpz_limbs_write", header: "".} 699 | proc mpz_limbs_write*(a2: var mpz_t; a3: mp_size_t): mp_ptr {. 700 | importc: "mpz_limbs_write", header: "".} 701 | proc mpz_limbs_modify*(a2: mpz_ptr; a3: mp_size_t): mp_ptr {. 702 | importc: "mpz_limbs_modify", header: "".} 703 | proc mpz_limbs_modify*(a2: var mpz_t; a3: mp_size_t): mp_ptr {. 704 | importc: "mpz_limbs_modify", header: "".} 705 | proc mpz_limbs_finish*(a2: mpz_ptr; a3: mp_size_t) {. 706 | importc: "mpz_limbs_finish", header: "".} 707 | proc mpz_limbs_finish*(a2: var mpz_t; a3: mp_size_t) {. 708 | importc: "mpz_limbs_finish", header: "".} 709 | proc mpz_roinit_n*(a2: mpz_ptr; a3: mp_srcptr; a4: mp_size_t): mpz_srcptr {. 710 | importc: "mpz_roinit_n", header: "".} 711 | proc mpz_roinit_n*(a2: var mpz_t; a3: var mp_limb_t; a4: mp_size_t): mpz_srcptr {. 712 | importc: "mpz_roinit_n", header: "".} 713 | proc mpq_add*(a2: mpq_ptr; a3: mpq_srcptr; a4: mpq_srcptr) {.importc: "mpq_add", 714 | header: "".} 715 | proc mpq_add*(a2: var mpq_t; a3: mpq_t; a4: mpq_t) {.importc: "mpq_add", 716 | header: "".} 717 | proc mpq_canonicalize*(a2: mpq_ptr) {.importc: "mpq_canonicalize", 718 | header: "".} 719 | proc mpq_canonicalize*(a2: var mpq_t) {.importc: "mpq_canonicalize", 720 | header: "".} 721 | proc mpq_clear*(a2: mpq_ptr) {.importc: "mpq_clear", header: "".} 722 | proc mpq_clear*(a2: var mpq_t) {.importc: "mpq_clear", header: "".} 723 | proc mpq_clears*(a2: mpq_ptr) {.varargs, importc: "mpq_clears", 724 | header: "".} 725 | proc mpq_clears*(a2: var mpq_t) {.varargs, importc: "mpq_clears", 726 | header: "".} 727 | proc mpq_cmp*(a2: mpq_srcptr; a3: mpq_srcptr): cint {.importc: "mpq_cmp", 728 | header: "".} 729 | proc mpq_cmp*(a2: mpq_t; a3: mpq_t): cint {.importc: "mpq_cmp", 730 | header: "".} 731 | proc m_mpq_cmp_si*(a2: mpq_srcptr; a3: clong; a4: culong): cint {. 732 | importc: "_mpq_cmp_si", header: "".} 733 | proc m_mpq_cmp_si*(a2: mpq_t; a3: clong; a4: culong): cint {. 734 | importc: "_mpq_cmp_si", header: "".} 735 | proc m_mpq_cmp_ui*(a2: mpq_srcptr; a3: culong; a4: culong): cint {. 736 | importc: "_mpq_cmp_ui", header: "".} 737 | proc m_mpq_cmp_ui*(a2: mpq_t; a3: culong; a4: culong): cint {. 738 | importc: "_mpq_cmp_ui", header: "".} 739 | proc mpq_div*(a2: mpq_ptr; a3: mpq_srcptr; a4: mpq_srcptr) {.importc: "mpq_div", 740 | header: "".} 741 | proc mpq_div*(a2: var mpq_t; a3: mpq_t; a4: mpq_t) {.importc: "mpq_div", 742 | header: "".} 743 | proc mpq_div_2exp*(a2: mpq_ptr; a3: mpq_srcptr; a4: mp_bitcnt_t) {. 744 | importc: "mpq_div_2exp", header: "".} 745 | proc mpq_div_2exp*(a2: var mpq_t; a3: mpq_t; a4: mp_bitcnt_t) {. 746 | importc: "mpq_div_2exp", header: "".} 747 | proc mpq_equal*(a2: mpq_srcptr; a3: mpq_srcptr): cint {.importc: "mpq_equal", 748 | header: "".} 749 | proc mpq_equal*(a2: mpq_t; a3: mpq_t): cint {.importc: "mpq_equal", 750 | header: "".} 751 | proc mpq_get_num*(a2: mpz_ptr; a3: mpq_srcptr) {.importc: "mpq_get_num", 752 | header: "".} 753 | proc mpq_get_num*(a2: var mpz_t; a3: mpq_t) {.importc: "mpq_get_num", 754 | header: "".} 755 | proc mpq_get_den*(a2: mpz_ptr; a3: mpq_srcptr) {.importc: "mpq_get_den", 756 | header: "".} 757 | proc mpq_get_den*(a2: var mpz_t; a3: mpq_t) {.importc: "mpq_get_den", 758 | header: "".} 759 | proc mpq_get_d*(a2: mpq_srcptr): cdouble {.importc: "mpq_get_d", 760 | header: "".} 761 | proc mpq_get_d*(a2: mpq_t): cdouble {.importc: "mpq_get_d", header: "".} 762 | proc mpq_get_str*(a2: cstring; a3: cint; a4: mpq_srcptr): cstring {. 763 | importc: "mpq_get_str", header: "".} 764 | proc mpq_get_str*(a2: cstring; a3: cint; a4: mpq_t): cstring {. 765 | importc: "mpq_get_str", header: "".} 766 | proc mpq_init*(a2: mpq_ptr) {.importc: "mpq_init", header: "".} 767 | proc mpq_init*(a2: var mpq_t) {.importc: "mpq_init", header: "".} 768 | proc mpq_inits*(a2: mpq_ptr) {.varargs, importc: "mpq_inits", header: "".} 769 | proc mpq_inits*(a2: var mpq_t) {.varargs, importc: "mpq_inits", 770 | header: "".} 771 | proc mpq_inp_str*(a2: mpq_ptr; a3: File; a4: cint): csize {. 772 | importc: "mpq_inp_str", header: "".} 773 | proc mpq_inp_str*(a2: var mpq_t; a3: File; a4: cint): csize {. 774 | importc: "mpq_inp_str", header: "".} 775 | proc mpq_inv*(a2: mpq_ptr; a3: mpq_srcptr) {.importc: "mpq_inv", 776 | header: "".} 777 | proc mpq_inv*(a2: var mpq_t; a3: mpq_t) {.importc: "mpq_inv", header: "".} 778 | proc mpq_mul*(a2: mpq_ptr; a3: mpq_srcptr; a4: mpq_srcptr) {.importc: "mpq_mul", 779 | header: "".} 780 | proc mpq_mul*(a2: var mpq_t; a3: mpq_t; a4: mpq_t) {.importc: "mpq_mul", 781 | header: "".} 782 | proc mpq_mul_2exp*(a2: mpq_ptr; a3: mpq_srcptr; a4: mp_bitcnt_t) {. 783 | importc: "mpq_mul_2exp", header: "".} 784 | proc mpq_mul_2exp*(a2: var mpq_t; a3: mpq_t; a4: mp_bitcnt_t) {. 785 | importc: "mpq_mul_2exp", header: "".} 786 | proc mpq_out_str*(a2: File; a3: cint; a4: mpq_srcptr): csize {. 787 | importc: "mpq_out_str", header: "".} 788 | proc mpq_out_str*(a2: File; a3: cint; a4: mpq_t): csize {. 789 | importc: "mpq_out_str", header: "".} 790 | proc mpq_set*(a2: mpq_ptr; a3: mpq_srcptr) {.importc: "mpq_set", 791 | header: "".} 792 | proc mpq_set*(a2: var mpq_t; a3: mpq_t) {.importc: "mpq_set", header: "".} 793 | proc mpq_set_d*(a2: mpq_ptr; a3: cdouble) {.importc: "mpq_set_d", 794 | header: "".} 795 | proc mpq_set_d*(a2: var mpq_t; a3: cdouble) {.importc: "mpq_set_d", 796 | header: "".} 797 | proc mpq_set_den*(a2: mpq_ptr; a3: mpz_srcptr) {.importc: "mpq_set_den", 798 | header: "".} 799 | proc mpq_set_den*(a2: var mpq_t; a3: mpz_t) {.importc: "mpq_set_den", 800 | header: "".} 801 | proc mpq_set_f*(a2: mpq_ptr; a3: mpf_srcptr) {.importc: "mpq_set_f", 802 | header: "".} 803 | proc mpq_set_f*(a2: var mpq_t; a3: mpf_t) {.importc: "mpq_set_f", 804 | header: "".} 805 | proc mpq_set_num*(a2: mpq_ptr; a3: mpz_srcptr) {.importc: "mpq_set_num", 806 | header: "".} 807 | proc mpq_set_num*(a2: var mpq_t; a3: mpz_t) {.importc: "mpq_set_num", 808 | header: "".} 809 | proc mpq_set_si*(a2: mpq_ptr; a3: clong; a4: culong) {.importc: "mpq_set_si", 810 | header: "".} 811 | proc mpq_set_si*(a2: var mpq_t; a3: clong; a4: culong) {.importc: "mpq_set_si", 812 | header: "".} 813 | proc mpq_set_str*(a2: mpq_ptr; a3: cstring; a4: cint): cint {. 814 | importc: "mpq_set_str", header: "".} 815 | proc mpq_set_str*(a2: var mpq_t; a3: cstring; a4: cint): cint {. 816 | importc: "mpq_set_str", header: "".} 817 | proc mpq_set_ui*(a2: mpq_ptr; a3: culong; a4: culong) {.importc: "mpq_set_ui", 818 | header: "".} 819 | proc mpq_set_ui*(a2: var mpq_t; a3: culong; a4: culong) {.importc: "mpq_set_ui", 820 | header: "".} 821 | proc mpq_set_z*(a2: mpq_ptr; a3: mpz_srcptr) {.importc: "mpq_set_z", 822 | header: "".} 823 | proc mpq_set_z*(a2: var mpq_t; a3: mpz_t) {.importc: "mpq_set_z", 824 | header: "".} 825 | proc mpq_sub*(a2: mpq_ptr; a3: mpq_srcptr; a4: mpq_srcptr) {.importc: "mpq_sub", 826 | header: "".} 827 | proc mpq_sub*(a2: var mpq_t; a3: mpq_t; a4: mpq_t) {.importc: "mpq_sub", 828 | header: "".} 829 | proc mpq_swap*(a2: mpq_ptr; a3: mpq_ptr) {.importc: "mpq_swap", 830 | header: "".} 831 | proc mpq_swap*(a2: var mpq_t; a3: var mpq_t) {.importc: "mpq_swap", 832 | header: "".} 833 | proc mpf_abs*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_abs", 834 | header: "".} 835 | proc mpf_abs*(a2: var mpf_t; a3: mpf_t) {.importc: "mpf_abs", header: "".} 836 | proc mpf_add*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {.importc: "mpf_add", 837 | header: "".} 838 | proc mpf_add*(a2: var mpf_t; a3: mpf_t; a4: mpf_t) {.importc: "mpf_add", 839 | header: "".} 840 | proc mpf_add_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 841 | importc: "mpf_add_ui", header: "".} 842 | proc mpf_add_ui*(a2: var mpf_t; a3: mpf_t; a4: culong) {.importc: "mpf_add_ui", 843 | header: "".} 844 | proc mpf_ceil*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_ceil", 845 | header: "".} 846 | proc mpf_ceil*(a2: var mpf_t; a3: mpf_t) {.importc: "mpf_ceil", 847 | header: "".} 848 | proc mpf_clear*(a2: mpf_ptr) {.importc: "mpf_clear", header: "".} 849 | proc mpf_clear*(a2: var mpf_t) {.importc: "mpf_clear", header: "".} 850 | proc mpf_clears*(a2: mpf_ptr) {.varargs, importc: "mpf_clears", 851 | header: "".} 852 | proc mpf_clears*(a2: var mpf_t) {.varargs, importc: "mpf_clears", 853 | header: "".} 854 | proc mpf_cmp*(a2: mpf_srcptr; a3: mpf_srcptr): cint {.importc: "mpf_cmp", 855 | header: "".} 856 | proc mpf_cmp*(a2: mpf_t; a3: mpf_t): cint {.importc: "mpf_cmp", 857 | header: "".} 858 | proc mpf_cmp_d*(a2: mpf_srcptr; a3: cdouble): cint {.importc: "mpf_cmp_d", 859 | header: "".} 860 | proc mpf_cmp_d*(a2: mpf_t; a3: cdouble): cint {.importc: "mpf_cmp_d", 861 | header: "".} 862 | proc mpf_cmp_si*(a2: mpf_srcptr; a3: clong): cint {.importc: "mpf_cmp_si", 863 | header: "".} 864 | proc mpf_cmp_si*(a2: mpf_t; a3: clong): cint {.importc: "mpf_cmp_si", 865 | header: "".} 866 | proc mpf_cmp_ui*(a2: mpf_srcptr; a3: culong): cint {.importc: "mpf_cmp_ui", 867 | header: "".} 868 | proc mpf_cmp_ui*(a2: mpf_t; a3: culong): cint {.importc: "mpf_cmp_ui", 869 | header: "".} 870 | proc mpf_div*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {.importc: "mpf_div", 871 | header: "".} 872 | proc mpf_div*(a2: var mpf_t; a3: mpf_t; a4: mpf_t) {.importc: "mpf_div", 873 | header: "".} 874 | proc mpf_div_2exp*(a2: mpf_ptr; a3: mpf_srcptr; a4: mp_bitcnt_t) {. 875 | importc: "mpf_div_2exp", header: "".} 876 | proc mpf_div_2exp*(a2: var mpf_t; a3: mpf_t; a4: mp_bitcnt_t) {. 877 | importc: "mpf_div_2exp", header: "".} 878 | proc mpf_div_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 879 | importc: "mpf_div_ui", header: "".} 880 | proc mpf_div_ui*(a2: var mpf_t; a3: mpf_t; a4: culong) {.importc: "mpf_div_ui", 881 | header: "".} 882 | proc mpf_dump*(a2: mpf_srcptr) {.importc: "mpf_dump", header: "".} 883 | proc mpf_dump*(a2: mpf_t) {.importc: "mpf_dump", header: "".} 884 | proc mpf_eq*(a2: mpf_srcptr; a3: mpf_srcptr; a4: mp_bitcnt_t): cint {. 885 | importc: "mpf_eq", header: "".} 886 | proc mpf_eq*(a2: mpf_t; a3: mpf_t; a4: mp_bitcnt_t): cint {.importc: "mpf_eq", 887 | header: "".} 888 | proc mpf_fits_sint_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_sint_p", 889 | header: "".} 890 | proc mpf_fits_sint_p*(a2: mpf_t): cint {.importc: "mpf_fits_sint_p", 891 | header: "".} 892 | proc mpf_fits_slong_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_slong_p", 893 | header: "".} 894 | proc mpf_fits_slong_p*(a2: mpf_t): cint {.importc: "mpf_fits_slong_p", 895 | header: "".} 896 | proc mpf_fits_sshort_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_sshort_p", 897 | header: "".} 898 | proc mpf_fits_sshort_p*(a2: mpf_t): cint {.importc: "mpf_fits_sshort_p", 899 | header: "".} 900 | proc mpf_fits_uint_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_uint_p", 901 | header: "".} 902 | proc mpf_fits_uint_p*(a2: mpf_t): cint {.importc: "mpf_fits_uint_p", 903 | header: "".} 904 | proc mpf_fits_ulong_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_ulong_p", 905 | header: "".} 906 | proc mpf_fits_ulong_p*(a2: mpf_t): cint {.importc: "mpf_fits_ulong_p", 907 | header: "".} 908 | proc mpf_fits_ushort_p*(a2: mpf_srcptr): cint {.importc: "mpf_fits_ushort_p", 909 | header: "".} 910 | proc mpf_fits_ushort_p*(a2: mpf_t): cint {.importc: "mpf_fits_ushort_p", 911 | header: "".} 912 | proc mpf_floor*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_floor", 913 | header: "".} 914 | proc mpf_floor*(a2: var mpf_t; a3: mpf_t) {.importc: "mpf_floor", 915 | header: "".} 916 | proc mpf_get_d*(a2: mpf_srcptr): cdouble {.importc: "mpf_get_d", 917 | header: "".} 918 | proc mpf_get_d*(a2: mpf_t): cdouble {.importc: "mpf_get_d", header: "".} 919 | proc mpf_get_d_2exp*(a2: ptr clong; a3: mpf_srcptr): cdouble {. 920 | importc: "mpf_get_d_2exp", header: "".} 921 | proc mpf_get_d_2exp*(a2: ptr clong; a3: mpf_t): cdouble {. 922 | importc: "mpf_get_d_2exp", header: "".} 923 | proc mpf_get_default_prec*(): mp_bitcnt_t {.importc: "mpf_get_default_prec", 924 | header: "".} 925 | proc mpf_get_prec*(a2: mpf_srcptr): mp_bitcnt_t {.importc: "mpf_get_prec", 926 | header: "".} 927 | proc mpf_get_prec*(a2: mpf_t): mp_bitcnt_t {.importc: "mpf_get_prec", 928 | header: "".} 929 | proc mpf_get_si*(a2: mpf_srcptr): clong {.importc: "mpf_get_si", 930 | header: "".} 931 | proc mpf_get_si*(a2: mpf_t): clong {.importc: "mpf_get_si", header: "".} 932 | proc mpf_get_str*(a2: cstring; a3: ptr mp_exp_t; a4: cint; a5: csize; 933 | a6: mpf_srcptr): cstring {.importc: "mpf_get_str", 934 | header: "".} 935 | proc mpf_get_str*(a2: cstring; a3: var mp_exp_t; a4: cint; a5: csize; a6: mpf_t): cstring {. 936 | importc: "mpf_get_str", header: "".} 937 | proc mpf_get_ui*(a2: mpf_srcptr): culong {.importc: "mpf_get_ui", 938 | header: "".} 939 | proc mpf_get_ui*(a2: mpf_t): culong {.importc: "mpf_get_ui", header: "".} 940 | proc mpf_init*(a2: mpf_ptr) {.importc: "mpf_init", header: "".} 941 | proc mpf_init*(a2: var mpf_t) {.importc: "mpf_init", header: "".} 942 | proc mpf_init2*(a2: mpf_ptr; a3: mp_bitcnt_t) {.importc: "mpf_init2", 943 | header: "".} 944 | proc mpf_init2*(a2: var mpf_t; a3: mp_bitcnt_t) {.importc: "mpf_init2", 945 | header: "".} 946 | proc mpf_inits*(a2: mpf_ptr) {.varargs, importc: "mpf_inits", header: "".} 947 | proc mpf_inits*(a2: var mpf_t) {.varargs, importc: "mpf_inits", 948 | header: "".} 949 | proc mpf_init_set*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_init_set", 950 | header: "".} 951 | proc mpf_init_set*(a2: var mpf_t; a3: mpf_t) {.importc: "mpf_init_set", 952 | header: "".} 953 | proc mpf_init_set_d*(a2: mpf_ptr; a3: cdouble) {.importc: "mpf_init_set_d", 954 | header: "".} 955 | proc mpf_init_set_d*(a2: var mpf_t; a3: cdouble) {.importc: "mpf_init_set_d", 956 | header: "".} 957 | proc mpf_init_set_si*(a2: mpf_ptr; a3: clong) {.importc: "mpf_init_set_si", 958 | header: "".} 959 | proc mpf_init_set_si*(a2: var mpf_t; a3: clong) {.importc: "mpf_init_set_si", 960 | header: "".} 961 | proc mpf_init_set_str*(a2: mpf_ptr; a3: cstring; a4: cint): cint {. 962 | importc: "mpf_init_set_str", header: "".} 963 | proc mpf_init_set_str*(a2: var mpf_t; a3: cstring; a4: cint): cint {. 964 | importc: "mpf_init_set_str", header: "".} 965 | proc mpf_init_set_ui*(a2: mpf_ptr; a3: culong) {.importc: "mpf_init_set_ui", 966 | header: "".} 967 | proc mpf_init_set_ui*(a2: var mpf_t; a3: culong) {.importc: "mpf_init_set_ui", 968 | header: "".} 969 | proc mpf_inp_str*(a2: mpf_ptr; a3: File; a4: cint): csize {. 970 | importc: "mpf_inp_str", header: "".} 971 | proc mpf_inp_str*(a2: var mpf_t; a3: File; a4: cint): csize {. 972 | importc: "mpf_inp_str", header: "".} 973 | proc mpf_integer_p*(a2: mpf_srcptr): cint {.importc: "mpf_integer_p", 974 | header: "".} 975 | proc mpf_integer_p*(a2: mpf_t): cint {.importc: "mpf_integer_p", 976 | header: "".} 977 | proc mpf_mul*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {.importc: "mpf_mul", 978 | header: "".} 979 | proc mpf_mul*(a2: var mpf_t; a3: mpf_t; a4: mpf_t) {.importc: "mpf_mul", 980 | header: "".} 981 | proc mpf_mul_2exp*(a2: mpf_ptr; a3: mpf_srcptr; a4: mp_bitcnt_t) {. 982 | importc: "mpf_mul_2exp", header: "".} 983 | proc mpf_mul_2exp*(a2: var mpf_t; a3: mpf_t; a4: mp_bitcnt_t) {. 984 | importc: "mpf_mul_2exp", header: "".} 985 | proc mpf_mul_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 986 | importc: "mpf_mul_ui", header: "".} 987 | proc mpf_mul_ui*(a2: var mpf_t; a3: mpf_t; a4: culong) {.importc: "mpf_mul_ui", 988 | header: "".} 989 | proc mpf_neg*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_neg", 990 | header: "".} 991 | proc mpf_neg*(a2: var mpf_t; a3: mpf_t) {.importc: "mpf_neg", header: "".} 992 | proc mpf_out_str*(a2: File; a3: cint; a4: csize; a5: mpf_srcptr): csize {. 993 | importc: "mpf_out_str", header: "".} 994 | proc mpf_out_str*(a2: File; a3: cint; a4: csize; a5: mpf_t): csize {. 995 | importc: "mpf_out_str", header: "".} 996 | proc mpf_pow_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 997 | importc: "mpf_pow_ui", header: "".} 998 | proc mpf_pow_ui*(a2: var mpf_t; a3: mpf_t; a4: culong) {.importc: "mpf_pow_ui", 999 | header: "".} 1000 | proc mpf_random2*(a2: mpf_ptr; a3: mp_size_t; a4: mp_exp_t) {. 1001 | importc: "mpf_random2", header: "".} 1002 | proc mpf_random2*(a2: var mpf_t; a3: mp_size_t; a4: mp_exp_t) {. 1003 | importc: "mpf_random2", header: "".} 1004 | proc mpf_reldiff*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {. 1005 | importc: "mpf_reldiff", header: "".} 1006 | proc mpf_reldiff*(a2: var mpf_t; a3: mpf_t; a4: mpf_t) {.importc: "mpf_reldiff", 1007 | header: "".} 1008 | proc mpf_set*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_set", 1009 | header: "".} 1010 | proc mpf_set*(a2: var mpf_t; a3: mpf_t) {.importc: "mpf_set", header: "".} 1011 | proc mpf_set_d*(a2: mpf_ptr; a3: cdouble) {.importc: "mpf_set_d", 1012 | header: "".} 1013 | proc mpf_set_d*(a2: var mpf_t; a3: cdouble) {.importc: "mpf_set_d", 1014 | header: "".} 1015 | proc mpf_set_default_prec*(a2: mp_bitcnt_t) {.importc: "mpf_set_default_prec", 1016 | header: "".} 1017 | proc mpf_set_prec*(a2: mpf_ptr; a3: mp_bitcnt_t) {.importc: "mpf_set_prec", 1018 | header: "".} 1019 | proc mpf_set_prec*(a2: var mpf_t; a3: mp_bitcnt_t) {.importc: "mpf_set_prec", 1020 | header: "".} 1021 | proc mpf_set_prec_raw*(a2: mpf_ptr; a3: mp_bitcnt_t) {. 1022 | importc: "mpf_set_prec_raw", header: "".} 1023 | proc mpf_set_prec_raw*(a2: var mpf_t; a3: mp_bitcnt_t) {. 1024 | importc: "mpf_set_prec_raw", header: "".} 1025 | proc mpf_set_q*(a2: mpf_ptr; a3: mpq_srcptr) {.importc: "mpf_set_q", 1026 | header: "".} 1027 | proc mpf_set_q*(a2: var mpf_t; a3: mpq_t) {.importc: "mpf_set_q", 1028 | header: "".} 1029 | proc mpf_set_si*(a2: mpf_ptr; a3: clong) {.importc: "mpf_set_si", 1030 | header: "".} 1031 | proc mpf_set_si*(a2: var mpf_t; a3: clong) {.importc: "mpf_set_si", 1032 | header: "".} 1033 | proc mpf_set_str*(a2: mpf_ptr; a3: cstring; a4: cint): cint {. 1034 | importc: "mpf_set_str", header: "".} 1035 | proc mpf_set_str*(a2: var mpf_t; a3: cstring; a4: cint): cint {. 1036 | importc: "mpf_set_str", header: "".} 1037 | proc mpf_set_ui*(a2: mpf_ptr; a3: culong) {.importc: "mpf_set_ui", 1038 | header: "".} 1039 | proc mpf_set_ui*(a2: var mpf_t; a3: culong) {.importc: "mpf_set_ui", 1040 | header: "".} 1041 | proc mpf_set_z*(a2: mpf_ptr; a3: mpz_srcptr) {.importc: "mpf_set_z", 1042 | header: "".} 1043 | proc mpf_set_z*(a2: var mpf_t; a3: mpz_t) {.importc: "mpf_set_z", 1044 | header: "".} 1045 | proc mpf_size*(a2: mpf_srcptr): csize {.importc: "mpf_size", header: "".} 1046 | proc mpf_size*(a2: mpf_t): csize {.importc: "mpf_size", header: "".} 1047 | proc mpf_sqrt*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_sqrt", 1048 | header: "".} 1049 | proc mpf_sqrt*(a2: var mpf_t; a3: mpf_t) {.importc: "mpf_sqrt", 1050 | header: "".} 1051 | proc mpf_sqrt_ui*(a2: mpf_ptr; a3: culong) {.importc: "mpf_sqrt_ui", 1052 | header: "".} 1053 | proc mpf_sqrt_ui*(a2: var mpf_t; a3: culong) {.importc: "mpf_sqrt_ui", 1054 | header: "".} 1055 | proc mpf_sub*(a2: mpf_ptr; a3: mpf_srcptr; a4: mpf_srcptr) {.importc: "mpf_sub", 1056 | header: "".} 1057 | proc mpf_sub*(a2: var mpf_t; a3: mpf_t; a4: mpf_t) {.importc: "mpf_sub", 1058 | header: "".} 1059 | proc mpf_sub_ui*(a2: mpf_ptr; a3: mpf_srcptr; a4: culong) {. 1060 | importc: "mpf_sub_ui", header: "".} 1061 | proc mpf_sub_ui*(a2: var mpf_t; a3: mpf_t; a4: culong) {.importc: "mpf_sub_ui", 1062 | header: "".} 1063 | proc mpf_swap*(a2: mpf_ptr; a3: mpf_ptr) {.importc: "mpf_swap", 1064 | header: "".} 1065 | proc mpf_swap*(a2: var mpf_t; a3: var mpf_t) {.importc: "mpf_swap", 1066 | header: "".} 1067 | proc mpf_trunc*(a2: mpf_ptr; a3: mpf_srcptr) {.importc: "mpf_trunc", 1068 | header: "".} 1069 | proc mpf_trunc*(a2: var mpf_t; a3: mpf_t) {.importc: "mpf_trunc", 1070 | header: "".} 1071 | proc mpf_ui_div*(a2: mpf_ptr; a3: culong; a4: mpf_srcptr) {. 1072 | importc: "mpf_ui_div", header: "".} 1073 | proc mpf_ui_div*(a2: var mpf_t; a3: culong; a4: mpf_t) {.importc: "mpf_ui_div", 1074 | header: "".} 1075 | proc mpf_ui_sub*(a2: mpf_ptr; a3: culong; a4: mpf_srcptr) {. 1076 | importc: "mpf_ui_sub", header: "".} 1077 | proc mpf_ui_sub*(a2: var mpf_t; a3: culong; a4: mpf_t) {.importc: "mpf_ui_sub", 1078 | header: "".} 1079 | proc mpf_urandomb*(a2: mpf_t; a3: gmp_randstate_t; a4: mp_bitcnt_t) {. 1080 | importc: "mpf_urandomb", header: "".} 1081 | proc mpn_add_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t): mp_limb_t {. 1082 | importc: "mpn_add_n", header: "".} 1083 | proc mpn_add_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1084 | a5: mp_size_t): mp_limb_t {.importc: "mpn_add_n", 1085 | header: "".} 1086 | proc mpn_addmul_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 1087 | importc: "mpn_addmul_1", header: "".} 1088 | proc mpn_addmul_1*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1089 | a5: mp_limb_t): mp_limb_t {.importc: "mpn_addmul_1", 1090 | header: "".} 1091 | proc mpn_divexact_by3c*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 1092 | importc: "mpn_divexact_by3c", header: "".} 1093 | proc mpn_divexact_by3c*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1094 | a5: mp_limb_t): mp_limb_t {. 1095 | importc: "mpn_divexact_by3c", header: "".} 1096 | proc mpn_divrem*(a2: mp_ptr; a3: mp_size_t; a4: mp_ptr; a5: mp_size_t; 1097 | a6: mp_srcptr; a7: mp_size_t): mp_limb_t {. 1098 | importc: "mpn_divrem", header: "".} 1099 | proc mpn_divrem*(a2: var mp_limb_t; a3: mp_size_t; a4: var mp_limb_t; 1100 | a5: mp_size_t; a6: var mp_limb_t; a7: mp_size_t): mp_limb_t {. 1101 | importc: "mpn_divrem", header: "".} 1102 | proc mpn_divrem_1*(a2: mp_ptr; a3: mp_size_t; a4: mp_srcptr; a5: mp_size_t; 1103 | a6: mp_limb_t): mp_limb_t {.importc: "mpn_divrem_1", 1104 | header: "".} 1105 | proc mpn_divrem_1*(a2: var mp_limb_t; a3: mp_size_t; a4: var mp_limb_t; 1106 | a5: mp_size_t; a6: mp_limb_t): mp_limb_t {. 1107 | importc: "mpn_divrem_1", header: "".} 1108 | proc mpn_divrem_2*(a2: mp_ptr; a3: mp_size_t; a4: mp_ptr; a5: mp_size_t; 1109 | a6: mp_srcptr): mp_limb_t {.importc: "mpn_divrem_2", 1110 | header: "".} 1111 | proc mpn_divrem_2*(a2: var mp_limb_t; a3: mp_size_t; a4: var mp_limb_t; 1112 | a5: mp_size_t; a6: var mp_limb_t): mp_limb_t {. 1113 | importc: "mpn_divrem_2", header: "".} 1114 | proc mpn_div_qr_1*(a2: mp_ptr; a3: ptr mp_limb_t; a4: mp_srcptr; a5: mp_size_t; 1115 | a6: mp_limb_t): mp_limb_t {.importc: "mpn_div_qr_1", 1116 | header: "".} 1117 | proc mpn_div_qr_1*(a2: var mp_limb_t; a3: ptr mp_limb_t; a4: var mp_limb_t; 1118 | a5: mp_size_t; a6: mp_limb_t): mp_limb_t {. 1119 | importc: "mpn_div_qr_1", header: "".} 1120 | proc mpn_div_qr_2*(a2: mp_ptr; a3: mp_ptr; a4: mp_srcptr; a5: mp_size_t; 1121 | a6: mp_srcptr): mp_limb_t {.importc: "mpn_div_qr_2", 1122 | header: "".} 1123 | proc mpn_div_qr_2*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1124 | a5: mp_size_t; a6: var mp_limb_t): mp_limb_t {. 1125 | importc: "mpn_div_qr_2", header: "".} 1126 | proc mpn_gcd*(a2: mp_ptr; a3: mp_ptr; a4: mp_size_t; a5: mp_ptr; a6: mp_size_t): mp_size_t {. 1127 | importc: "mpn_gcd", header: "".} 1128 | proc mpn_gcd*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1129 | a5: var mp_limb_t; a6: mp_size_t): mp_size_t {.importc: "mpn_gcd", 1130 | header: "".} 1131 | proc mpn_gcd_1*(a2: mp_srcptr; a3: mp_size_t; a4: mp_limb_t): mp_limb_t {. 1132 | importc: "mpn_gcd_1", header: "".} 1133 | proc mpn_gcd_1*(a2: var mp_limb_t; a3: mp_size_t; a4: mp_limb_t): mp_limb_t {. 1134 | importc: "mpn_gcd_1", header: "".} 1135 | proc mpn_gcdext_1*(a2: ptr mp_limb_signed_t; a3: ptr mp_limb_signed_t; 1136 | a4: mp_limb_t; a5: mp_limb_t): mp_limb_t {. 1137 | importc: "mpn_gcdext_1", header: "".} 1138 | proc mpn_gcdext*(a2: mp_ptr; a3: mp_ptr; a4: ptr mp_size_t; a5: mp_ptr; 1139 | a6: mp_size_t; a7: mp_ptr; a8: mp_size_t): mp_size_t {. 1140 | importc: "mpn_gcdext", header: "".} 1141 | proc mpn_gcdext*(a2: var mp_limb_t; a3: var mp_limb_t; a4: ptr mp_size_t; 1142 | a5: var mp_limb_t; a6: mp_size_t; a7: var mp_limb_t; 1143 | a8: mp_size_t): mp_size_t {.importc: "mpn_gcdext", 1144 | header: "".} 1145 | proc mpn_get_str*(a2: ptr cuchar; a3: cint; a4: mp_ptr; a5: mp_size_t): csize {. 1146 | importc: "mpn_get_str", header: "".} 1147 | proc mpn_get_str*(a2: ptr cuchar; a3: cint; a4: var mp_limb_t; a5: mp_size_t): csize {. 1148 | importc: "mpn_get_str", header: "".} 1149 | proc mpn_hamdist*(a2: mp_srcptr; a3: mp_srcptr; a4: mp_size_t): mp_bitcnt_t {. 1150 | importc: "mpn_hamdist", header: "".} 1151 | proc mpn_hamdist*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t): mp_bitcnt_t {. 1152 | importc: "mpn_hamdist", header: "".} 1153 | proc mpn_lshift*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: cuint): mp_limb_t {. 1154 | importc: "mpn_lshift", header: "".} 1155 | proc mpn_lshift*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; a5: cuint): mp_limb_t {. 1156 | importc: "mpn_lshift", header: "".} 1157 | proc mpn_mod_1*(a2: mp_srcptr; a3: mp_size_t; a4: mp_limb_t): mp_limb_t {. 1158 | importc: "mpn_mod_1", header: "".} 1159 | proc mpn_mod_1*(a2: var mp_limb_t; a3: mp_size_t; a4: mp_limb_t): mp_limb_t {. 1160 | importc: "mpn_mod_1", header: "".} 1161 | proc mpn_mul*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_srcptr; 1162 | a6: mp_size_t): mp_limb_t {.importc: "mpn_mul", header: "".} 1163 | proc mpn_mul*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1164 | a5: var mp_limb_t; a6: mp_size_t): mp_limb_t {.importc: "mpn_mul", 1165 | header: "".} 1166 | proc mpn_mul_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 1167 | importc: "mpn_mul_1", header: "".} 1168 | proc mpn_mul_1*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1169 | a5: mp_limb_t): mp_limb_t {.importc: "mpn_mul_1", 1170 | header: "".} 1171 | proc mpn_mul_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1172 | importc: "mpn_mul_n", header: "".} 1173 | proc mpn_mul_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1174 | a5: mp_size_t) {.importc: "mpn_mul_n", header: "".} 1175 | proc mpn_sqr*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t) {.importc: "mpn_sqr", 1176 | header: "".} 1177 | proc mpn_sqr*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t) {. 1178 | importc: "mpn_sqr", header: "".} 1179 | proc mpn_neg*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t): mp_limb_t {. 1180 | importc: "mpn_neg", header: "".} 1181 | proc mpn_neg*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t): mp_limb_t {. 1182 | importc: "mpn_neg", header: "".} 1183 | proc mpn_com*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t) {.importc: "mpn_com", 1184 | header: "".} 1185 | proc mpn_com*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t) {. 1186 | importc: "mpn_com", header: "".} 1187 | proc mpn_perfect_square_p*(a2: mp_srcptr; a3: mp_size_t): cint {. 1188 | importc: "mpn_perfect_square_p", header: "".} 1189 | proc mpn_perfect_square_p*(a2: var mp_limb_t; a3: mp_size_t): cint {. 1190 | importc: "mpn_perfect_square_p", header: "".} 1191 | proc mpn_perfect_power_p*(a2: mp_srcptr; a3: mp_size_t): cint {. 1192 | importc: "mpn_perfect_power_p", header: "".} 1193 | proc mpn_perfect_power_p*(a2: var mp_limb_t; a3: mp_size_t): cint {. 1194 | importc: "mpn_perfect_power_p", header: "".} 1195 | proc mpn_popcount*(a2: mp_srcptr; a3: mp_size_t): mp_bitcnt_t {. 1196 | importc: "mpn_popcount", header: "".} 1197 | proc mpn_popcount*(a2: var mp_limb_t; a3: mp_size_t): mp_bitcnt_t {. 1198 | importc: "mpn_popcount", header: "".} 1199 | proc mpn_pow_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t; 1200 | a6: mp_ptr): mp_size_t {.importc: "mpn_pow_1", header: "".} 1201 | proc mpn_pow_1*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1202 | a5: mp_limb_t; a6: var mp_limb_t): mp_size_t {. 1203 | importc: "mpn_pow_1", header: "".} 1204 | proc mpn_preinv_mod_1*(a2: mp_srcptr; a3: mp_size_t; a4: mp_limb_t; 1205 | a5: mp_limb_t): mp_limb_t {.importc: "mpn_preinv_mod_1", 1206 | header: "".} 1207 | proc mpn_preinv_mod_1*(a2: var mp_limb_t; a3: mp_size_t; a4: mp_limb_t; 1208 | a5: mp_limb_t): mp_limb_t {.importc: "mpn_preinv_mod_1", 1209 | header: "".} 1210 | proc mpn_random*(a2: mp_ptr; a3: mp_size_t) {.importc: "mpn_random", 1211 | header: "".} 1212 | proc mpn_random*(a2: var mp_limb_t; a3: mp_size_t) {.importc: "mpn_random", 1213 | header: "".} 1214 | proc mpn_random2*(a2: mp_ptr; a3: mp_size_t) {.importc: "mpn_random2", 1215 | header: "".} 1216 | proc mpn_random2*(a2: var mp_limb_t; a3: mp_size_t) {.importc: "mpn_random2", 1217 | header: "".} 1218 | proc mpn_rshift*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: cuint): mp_limb_t {. 1219 | importc: "mpn_rshift", header: "".} 1220 | proc mpn_rshift*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; a5: cuint): mp_limb_t {. 1221 | importc: "mpn_rshift", header: "".} 1222 | proc mpn_scan0*(a2: mp_srcptr; a3: mp_bitcnt_t): mp_bitcnt_t {. 1223 | importc: "mpn_scan0", header: "".} 1224 | proc mpn_scan0*(a2: var mp_limb_t; a3: mp_bitcnt_t): mp_bitcnt_t {. 1225 | importc: "mpn_scan0", header: "".} 1226 | proc mpn_scan1*(a2: mp_srcptr; a3: mp_bitcnt_t): mp_bitcnt_t {. 1227 | importc: "mpn_scan1", header: "".} 1228 | proc mpn_scan1*(a2: var mp_limb_t; a3: mp_bitcnt_t): mp_bitcnt_t {. 1229 | importc: "mpn_scan1", header: "".} 1230 | proc mpn_set_str*(a2: mp_ptr; a3: ptr cuchar; a4: csize; a5: cint): mp_size_t {. 1231 | importc: "mpn_set_str", header: "".} 1232 | proc mpn_set_str*(a2: var mp_limb_t; a3: ptr cuchar; a4: csize; a5: cint): mp_size_t {. 1233 | importc: "mpn_set_str", header: "".} 1234 | proc mpn_sizeinbase*(a2: mp_srcptr; a3: mp_size_t; a4: cint): csize {. 1235 | importc: "mpn_sizeinbase", header: "".} 1236 | proc mpn_sizeinbase*(a2: var mp_limb_t; a3: mp_size_t; a4: cint): csize {. 1237 | importc: "mpn_sizeinbase", header: "".} 1238 | proc mpn_sqrtrem*(a2: mp_ptr; a3: mp_ptr; a4: mp_srcptr; a5: mp_size_t): mp_size_t {. 1239 | importc: "mpn_sqrtrem", header: "".} 1240 | proc mpn_sqrtrem*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1241 | a5: mp_size_t): mp_size_t {.importc: "mpn_sqrtrem", 1242 | header: "".} 1243 | proc mpn_sub*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_srcptr; 1244 | a6: mp_size_t): mp_limb_t {.importc: "mpn_sub", header: "".} 1245 | proc mpn_sub*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1246 | a5: var mp_limb_t; a6: mp_size_t): mp_limb_t {.importc: "mpn_sub", 1247 | header: "".} 1248 | proc mpn_sub_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 1249 | importc: "mpn_sub_1", header: "".} 1250 | proc mpn_sub_1*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1251 | a5: mp_limb_t): mp_limb_t {.importc: "mpn_sub_1", 1252 | header: "".} 1253 | proc mpn_sub_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t): mp_limb_t {. 1254 | importc: "mpn_sub_n", header: "".} 1255 | proc mpn_sub_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1256 | a5: mp_size_t): mp_limb_t {.importc: "mpn_sub_n", 1257 | header: "".} 1258 | proc mpn_submul_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t): mp_limb_t {. 1259 | importc: "mpn_submul_1", header: "".} 1260 | proc mpn_submul_1*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1261 | a5: mp_limb_t): mp_limb_t {.importc: "mpn_submul_1", 1262 | header: "".} 1263 | proc mpn_tdiv_qr*(a2: mp_ptr; a3: mp_ptr; a4: mp_size_t; a5: mp_srcptr; 1264 | a6: mp_size_t; a7: mp_srcptr; a8: mp_size_t) {. 1265 | importc: "mpn_tdiv_qr", header: "".} 1266 | proc mpn_tdiv_qr*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1267 | a5: var mp_limb_t; a6: mp_size_t; a7: var mp_limb_t; 1268 | a8: mp_size_t) {.importc: "mpn_tdiv_qr", header: "".} 1269 | proc mpn_and_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1270 | importc: "mpn_and_n", header: "".} 1271 | proc mpn_and_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1272 | a5: mp_size_t) {.importc: "mpn_and_n", header: "".} 1273 | proc mpn_andn_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1274 | importc: "mpn_andn_n", header: "".} 1275 | proc mpn_andn_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1276 | a5: mp_size_t) {.importc: "mpn_andn_n", header: "".} 1277 | proc mpn_nand_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1278 | importc: "mpn_nand_n", header: "".} 1279 | proc mpn_nand_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1280 | a5: mp_size_t) {.importc: "mpn_nand_n", header: "".} 1281 | proc mpn_ior_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1282 | importc: "mpn_ior_n", header: "".} 1283 | proc mpn_ior_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1284 | a5: mp_size_t) {.importc: "mpn_ior_n", header: "".} 1285 | proc mpn_iorn_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1286 | importc: "mpn_iorn_n", header: "".} 1287 | proc mpn_iorn_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1288 | a5: mp_size_t) {.importc: "mpn_iorn_n", header: "".} 1289 | proc mpn_nior_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1290 | importc: "mpn_nior_n", header: "".} 1291 | proc mpn_nior_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1292 | a5: mp_size_t) {.importc: "mpn_nior_n", header: "".} 1293 | proc mpn_xor_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1294 | importc: "mpn_xor_n", header: "".} 1295 | proc mpn_xor_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1296 | a5: mp_size_t) {.importc: "mpn_xor_n", header: "".} 1297 | proc mpn_xnor_n*(a2: mp_ptr; a3: mp_srcptr; a4: mp_srcptr; a5: mp_size_t) {. 1298 | importc: "mpn_xnor_n", header: "".} 1299 | proc mpn_xnor_n*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1300 | a5: mp_size_t) {.importc: "mpn_xnor_n", header: "".} 1301 | proc mpn_copyi*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t) {. 1302 | importc: "mpn_copyi", header: "".} 1303 | proc mpn_copyi*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t) {. 1304 | importc: "mpn_copyi", header: "".} 1305 | proc mpn_copyd*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t) {. 1306 | importc: "mpn_copyd", header: "".} 1307 | proc mpn_copyd*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t) {. 1308 | importc: "mpn_copyd", header: "".} 1309 | proc mpn_zero*(a2: mp_ptr; a3: mp_size_t) {.importc: "mpn_zero", 1310 | header: "".} 1311 | proc mpn_zero*(a2: var mp_limb_t; a3: mp_size_t) {.importc: "mpn_zero", 1312 | header: "".} 1313 | proc mpn_cnd_add_n*(a2: mp_limb_t; a3: mp_ptr; a4: mp_srcptr; a5: mp_srcptr; 1314 | a6: mp_size_t): mp_limb_t {.importc: "mpn_cnd_add_n", 1315 | header: "".} 1316 | proc mpn_cnd_add_n*(a2: mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1317 | a5: var mp_limb_t; a6: mp_size_t): mp_limb_t {. 1318 | importc: "mpn_cnd_add_n", header: "".} 1319 | proc mpn_cnd_sub_n*(a2: mp_limb_t; a3: mp_ptr; a4: mp_srcptr; a5: mp_srcptr; 1320 | a6: mp_size_t): mp_limb_t {.importc: "mpn_cnd_sub_n", 1321 | header: "".} 1322 | proc mpn_cnd_sub_n*(a2: mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1323 | a5: var mp_limb_t; a6: mp_size_t): mp_limb_t {. 1324 | importc: "mpn_cnd_sub_n", header: "".} 1325 | proc mpn_sec_add_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t; 1326 | a6: mp_ptr): mp_limb_t {.importc: "mpn_sec_add_1", 1327 | header: "".} 1328 | proc mpn_sec_add_1*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1329 | a5: mp_limb_t; a6: var mp_limb_t): mp_limb_t {. 1330 | importc: "mpn_sec_add_1", header: "".} 1331 | proc mpn_sec_add_1_itch*(a2: mp_size_t): mp_size_t {. 1332 | importc: "mpn_sec_add_1_itch", header: "".} 1333 | proc mpn_sec_sub_1*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_limb_t; 1334 | a6: mp_ptr): mp_limb_t {.importc: "mpn_sec_sub_1", 1335 | header: "".} 1336 | proc mpn_sec_sub_1*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1337 | a5: mp_limb_t; a6: var mp_limb_t): mp_limb_t {. 1338 | importc: "mpn_sec_sub_1", header: "".} 1339 | proc mpn_sec_sub_1_itch*(a2: mp_size_t): mp_size_t {. 1340 | importc: "mpn_sec_sub_1_itch", header: "".} 1341 | proc mpn_sec_mul*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_srcptr; 1342 | a6: mp_size_t; a7: mp_ptr) {.importc: "mpn_sec_mul", 1343 | header: "".} 1344 | proc mpn_sec_mul*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1345 | a5: var mp_limb_t; a6: mp_size_t; a7: var mp_limb_t) {. 1346 | importc: "mpn_sec_mul", header: "".} 1347 | proc mpn_sec_mul_itch*(a2: mp_size_t; a3: mp_size_t): mp_size_t {. 1348 | importc: "mpn_sec_mul_itch", header: "".} 1349 | proc mpn_sec_sqr*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_ptr) {. 1350 | importc: "mpn_sec_sqr", header: "".} 1351 | proc mpn_sec_sqr*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1352 | a5: var mp_limb_t) {.importc: "mpn_sec_sqr", header: "".} 1353 | proc mpn_sec_sqr_itch*(a2: mp_size_t): mp_size_t {.importc: "mpn_sec_sqr_itch", 1354 | header: "".} 1355 | proc mpn_sec_powm*(a2: mp_ptr; a3: mp_srcptr; a4: mp_size_t; a5: mp_srcptr; 1356 | a6: mp_bitcnt_t; a7: mp_srcptr; a8: mp_size_t; a9: mp_ptr) {. 1357 | importc: "mpn_sec_powm", header: "".} 1358 | proc mpn_sec_powm*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1359 | a5: var mp_limb_t; a6: mp_bitcnt_t; a7: var mp_limb_t; 1360 | a8: mp_size_t; a9: var mp_limb_t) {.importc: "mpn_sec_powm", 1361 | header: "".} 1362 | proc mpn_sec_powm_itch*(a2: mp_size_t; a3: mp_bitcnt_t; a4: mp_size_t): mp_size_t {. 1363 | importc: "mpn_sec_powm_itch", header: "".} 1364 | proc mpn_sec_tabselect*(a2: ptr mp_limb_t; a3: ptr mp_limb_t; a4: mp_size_t; 1365 | a5: mp_size_t; a6: mp_size_t) {. 1366 | importc: "mpn_sec_tabselect", header: "".} 1367 | proc mpn_sec_div_qr*(a2: mp_ptr; a3: mp_ptr; a4: mp_size_t; a5: mp_srcptr; 1368 | a6: mp_size_t; a7: mp_ptr): mp_limb_t {. 1369 | importc: "mpn_sec_div_qr", header: "".} 1370 | proc mpn_sec_div_qr*(a2: var mp_limb_t; a3: var mp_limb_t; a4: mp_size_t; 1371 | a5: var mp_limb_t; a6: mp_size_t; a7: var mp_limb_t): mp_limb_t {. 1372 | importc: "mpn_sec_div_qr", header: "".} 1373 | proc mpn_sec_div_qr_itch*(a2: mp_size_t; a3: mp_size_t): mp_size_t {. 1374 | importc: "mpn_sec_div_qr_itch", header: "".} 1375 | proc mpn_sec_div_r*(a2: mp_ptr; a3: mp_size_t; a4: mp_srcptr; a5: mp_size_t; 1376 | a6: mp_ptr) {.importc: "mpn_sec_div_r", header: "".} 1377 | proc mpn_sec_div_r*(a2: var mp_limb_t; a3: mp_size_t; a4: var mp_limb_t; 1378 | a5: mp_size_t; a6: var mp_limb_t) {. 1379 | importc: "mpn_sec_div_r", header: "".} 1380 | proc mpn_sec_div_r_itch*(a2: mp_size_t; a3: mp_size_t): mp_size_t {. 1381 | importc: "mpn_sec_div_r_itch", header: "".} 1382 | proc mpn_sec_invert*(a2: mp_ptr; a3: mp_ptr; a4: mp_srcptr; a5: mp_size_t; 1383 | a6: mp_bitcnt_t; a7: mp_ptr): cint {. 1384 | importc: "mpn_sec_invert", header: "".} 1385 | proc mpn_sec_invert*(a2: var mp_limb_t; a3: var mp_limb_t; a4: var mp_limb_t; 1386 | a5: mp_size_t; a6: mp_bitcnt_t; a7: var mp_limb_t): cint {. 1387 | importc: "mpn_sec_invert", header: "".} 1388 | proc mpn_sec_invert_itch*(a2: mp_size_t): mp_size_t {. 1389 | importc: "mpn_sec_invert_itch", header: "".} 1390 | proc mpz_abs*(mm_gmp_w: mpz_ptr; mm_gmp_u: mpz_srcptr) {.importc: "mpz_abs", 1391 | header: "".} 1392 | proc mpz_abs*(mm_gmp_w: var mpz_t; mm_gmp_u: mpz_t) {.importc: "mpz_abs", 1393 | header: "".} 1394 | proc mpz_fits_uint_p*(mm_gmp_z: mpz_srcptr): cint {.importc: "mpz_fits_uint_p", 1395 | header: "".} 1396 | proc mpz_fits_uint_p*(mm_gmp_z: mpz_t): cint {.importc: "mpz_fits_uint_p", 1397 | header: "".} 1398 | proc mpz_fits_ulong_p*(mm_gmp_z: mpz_srcptr): cint {. 1399 | importc: "mpz_fits_ulong_p", header: "".} 1400 | proc mpz_fits_ulong_p*(mm_gmp_z: mpz_t): cint {.importc: "mpz_fits_ulong_p", 1401 | header: "".} 1402 | proc mpz_fits_ushort_p*(mm_gmp_z: mpz_srcptr): cint {. 1403 | importc: "mpz_fits_ushort_p", header: "".} 1404 | proc mpz_fits_ushort_p*(mm_gmp_z: mpz_t): cint {.importc: "mpz_fits_ushort_p", 1405 | header: "".} 1406 | proc mpz_get_ui*(mm_gmp_z: mpz_srcptr): culong {.importc: "mpz_get_ui", 1407 | header: "".} 1408 | proc mpz_get_ui*(mm_gmp_z: mpz_t): culong {.importc: "mpz_get_ui", 1409 | header: "".} 1410 | proc mpz_getlimbn*(mm_gmp_z: mpz_srcptr; mm_gmp_n: mp_size_t): mp_limb_t {. 1411 | importc: "mpz_getlimbn", header: "".} 1412 | proc mpz_getlimbn*(mm_gmp_z: mpz_t; mm_gmp_n: mp_size_t): mp_limb_t {. 1413 | importc: "mpz_getlimbn", header: "".} 1414 | proc mpz_neg*(mm_gmp_w: mpz_ptr; mm_gmp_u: mpz_srcptr) {.importc: "mpz_neg", 1415 | header: "".} 1416 | proc mpz_neg*(mm_gmp_w: var mpz_t; mm_gmp_u: mpz_t) {.importc: "mpz_neg", 1417 | header: "".} 1418 | proc mpz_perfect_square_p*(mm_gmp_a: mpz_srcptr): cint {. 1419 | importc: "mpz_perfect_square_p", header: "".} 1420 | proc mpz_perfect_square_p*(mm_gmp_a: mpz_t): cint {. 1421 | importc: "mpz_perfect_square_p", header: "".} 1422 | proc mpz_popcount*(mm_gmp_u: mpz_srcptr): mp_bitcnt_t {.importc: "mpz_popcount", 1423 | header: "".} 1424 | proc mpz_popcount*(mm_gmp_u: mpz_t): mp_bitcnt_t {.importc: "mpz_popcount", 1425 | header: "".} 1426 | proc mpz_set_q*(mm_gmp_w: mpz_ptr; mm_gmp_u: mpq_srcptr) {.importc: "mpz_set_q", 1427 | header: "".} 1428 | proc mpz_set_q*(mm_gmp_w: var mpz_t; mm_gmp_u: mpq_t) {.importc: "mpz_set_q", 1429 | header: "".} 1430 | proc mpz_size*(mm_gmp_z: mpz_srcptr): csize {.importc: "mpz_size", 1431 | header: "".} 1432 | proc mpz_size*(mm_gmp_z: mpz_t): csize {.importc: "mpz_size", header: "".} 1433 | proc mpq_abs*(mm_gmp_w: mpq_ptr; mm_gmp_u: mpq_srcptr) {.importc: "mpq_abs", 1434 | header: "".} 1435 | proc mpq_abs*(mm_gmp_w: var mpq_t; mm_gmp_u: mpq_t) {.importc: "mpq_abs", 1436 | header: "".} 1437 | proc mpq_neg*(mm_gmp_w: mpq_ptr; mm_gmp_u: mpq_srcptr) {.importc: "mpq_neg", 1438 | header: "".} 1439 | proc mpq_neg*(mm_gmp_w: var mpq_t; mm_gmp_u: mpq_t) {.importc: "mpq_neg", 1440 | header: "".} 1441 | proc mpn_add*(mm_gmp_wp: mp_ptr; mm_gmp_xp: mp_srcptr; mm_gmp_xsize: mp_size_t; 1442 | mm_gmp_yp: mp_srcptr; mm_gmp_ysize: mp_size_t): mp_limb_t {. 1443 | importc: "mpn_add", header: "".} 1444 | proc mpn_add*(mm_gmp_wp: var mp_limb_t; mm_gmp_xp: var mp_limb_t; 1445 | mm_gmp_xsize: mp_size_t; mm_gmp_yp: var mp_limb_t; 1446 | mm_gmp_ysize: mp_size_t): mp_limb_t {.importc: "mpn_add", 1447 | header: "".} 1448 | proc mpn_add_1*(mm_gmp_dst: mp_ptr; mm_gmp_src: mp_srcptr; 1449 | mm_gmp_size: mp_size_t; mm_gmp_n: mp_limb_t): mp_limb_t {. 1450 | importc: "mpn_add_1", header: "".} 1451 | proc mpn_add_1*(mm_gmp_dst: var mp_limb_t; mm_gmp_src: var mp_limb_t; 1452 | mm_gmp_size: mp_size_t; mm_gmp_n: mp_limb_t): mp_limb_t {. 1453 | importc: "mpn_add_1", header: "".} 1454 | proc mpn_cmp*(mm_gmp_xp: mp_srcptr; mm_gmp_yp: mp_srcptr; mm_gmp_size: mp_size_t): cint {. 1455 | importc: "mpn_cmp", header: "".} 1456 | proc mpn_cmp*(mm_gmp_xp: var mp_limb_t; mm_gmp_yp: var mp_limb_t; 1457 | mm_gmp_size: mp_size_t): cint {.importc: "mpn_cmp", 1458 | header: "".} 1459 | proc mpz_sgn*(a2: mpz_srcptr): cint {.importc: "mpz_sgn", header: "".} 1460 | proc mpz_sgn*(a2: mpz_t): cint {.importc: "mpz_sgn", header: "".} 1461 | proc mpf_sgn*(a2: mpf_srcptr): cint {.importc: "mpf_sgn", header: "".} 1462 | proc mpf_sgn*(a2: mpf_t): cint {.importc: "mpf_sgn", header: "".} 1463 | proc mpq_sgn*(a2: mpq_srcptr): cint {.importc: "mpq_sgn", header: "".} 1464 | proc mpq_sgn*(a2: mpq_t): cint {.importc: "mpq_sgn", header: "".} 1465 | proc mpz_odd_p*(a2: mpz_srcptr): cint {.importc: "mpz_odd_p", 1466 | header: "".} 1467 | proc mpz_odd_p*(a2: mpz_t): cint {.importc: "mpz_odd_p", header: "".} 1468 | proc mpz_even_p*(a2: mpz_srcptr): cint {.importc: "mpz_even_p", 1469 | header: "".} 1470 | proc mpz_even_p*(a2: mpz_t): cint {.importc: "mpz_even_p", header: "".} 1471 | const 1472 | GMP_ERROR_NONE* = 0 1473 | GMP_ERROR_UNSUPPORTED_ARGUMENT* = 1 1474 | GMP_ERROR_DIVISION_BY_ZERO* = 2 1475 | GMP_ERROR_SQRT_OF_NEGATIVE* = 4 1476 | GMP_ERROR_INVALID_ARGUMENT* = 8 1477 | 1478 | when isMainModule: 1479 | discard 1480 | 1481 | --------------------------------------------------------------------------------