Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346/****************************************************************************1**2*W gmpints.h GAP source John McDermott3**4**5**6**7*Y Copyright (C) 1996, Lehrstuhl D für Mathematik, RWTH Aachen, Germany8*Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland9*Y Copyright (C) 2002 The GAP Group10**11** This file declares the functions handling gmp integers.12*/1314#ifndef GAP_GMPINTS_H15#define GAP_GMPINTS_H1617#ifdef USE_GMP1819// GMP must be included outside of 'extern C'20#ifdef GAP_IN_EXTERN_C21}22#endif23#include <gmp.h>24#ifdef GAP_IN_EXTERN_C25extern "C" {26#endif2728/****************************************************************************29**30*T TypLimb . . . . . . . . . . . . . . . . . . . . . . . type of a GMP Limb31**32**33**34*/35typedef mp_limb_t TypLimb;36typedef mp_size_t TypGMPSize;373839// TODO: Instead of hardcoding the values below, use40// GMP_LIMB_BITS etc. directly.41//42// To safeguard against bugs like compiling GAP against one version of43// GMP and a plugin against another, we may want to add some safeguards.44// E.g. add to config.h another #define GAP_GMP_LIMB_BITS and compare45// that during compile time with GMP_LIMB_BITS.464748#ifdef SYS_IS_64_BIT49#define INTEGER_UNIT_SIZE 850#define INTEGER_ALLOCATION_SIZE 851#define NR_SMALL_INT_BITS (64 - 4)52#else53#define INTEGER_UNIT_SIZE 454#define INTEGER_ALLOCATION_SIZE 455#define NR_SMALL_INT_BITS (32 - 4)56#endif5758#if GMP_LIMB_BITS != INTEGER_UNIT_SIZE * 859#error Aborting compile: unexpected GMP limb size60#endif61#if GMP_NAIL_BITS != 062#error Aborting compile: GAP does not support non-zero GMP nail size63#endif64#ifndef __GNU_MP_RELEASE65#if __GMP_MP_RELEASE < 5000266#error Aborting compile: GAP requires GMP 5.0.2 or newer67#endif68#endif697071#define ADDR_INT(obj) ( (TypLimb *)ADDR_OBJ(obj) )72#define SIZE_INT(obj) ( (TypGMPSize)SIZE_OBJ(obj)/sizeof(TypLimb) )73/* SIZE_INT gives a result in limbs */747576/**************************************************************************77** The following two functions convert a C Int or UInt respectively into78** a GAP integer, either an immediate, small integer if possible or79** otherwise a new GAP bag with TNUM T_INTPOS or T_INTNEG.80**81*F ObjInt_Int(Int i)82*F ObjInt_UInt(UInt i)83**84****************************************************************************/8586Obj ObjInt_Int(Int i);87Obj ObjInt_UInt(UInt i);8889/****************************************************************************90**91*/92extern Obj GMP_REDUCE (93Obj gmp );94extern Obj GMP_NORMALIZE (95Obj gmp );969798/****************************************************************************99**100*F PrintInt( <int> ) . . . . . . . . . . . . . . . print an integer constant101**102** 'PrintInt' prints the integer <int> in the usual decimal notation.103** 'PrintInt' handles objects of type 'T_INT', 'T_INTPOS' and 'T_INTNEG'.104*/105extern void PrintInt (106Obj op );107108109/****************************************************************************110**111*F EqInt( <gmpL>, <gmpR> ) . . . . . test if two integers are equal112**113** 'EqInt' returns 1 if the two GMP integer arguments <gmpL> and114** <gmpR> are equal and 0 otherwise.115*/116extern Int EqInt (117Obj opL,118Obj opR );119120121/****************************************************************************122**123*F LtInt( <gmpL>, <gmpR> ) test if an integer is less than another124**125** 'LtInt' returns 1 if the integer <gmpL> is strictly less than the126** integer <gmpR> and 0 otherwise.127*/128extern Int LtInt (129Obj opL,130Obj opR );131132133/****************************************************************************134**135*F SumInt( <gmpL>, <gmpR> ) . . . . . . . . . sum of two integers136**137** 'SumInt' returns the sum of the two integer arguments <gmpL> and138** <gmpR>.139**140*/141extern Obj SumInt (142Obj opL,143Obj opR );144145/****************************************************************************146**147*F SumOrDiffInt( <gmpL>, <gmpR>, <sign> ) . . . . . . . sum of two integers148**149** 'SumOrDiffInt' returns the sum or difference of the two GMP arguments150** <gmpL> and <gmpR>, depending whether sign is +1 or -1.151**152*/153extern Obj SumOrDiffInt (154Obj opL,155Obj opR,156Int sign );157158159/****************************************************************************160**161*F DiffInt( <gmpL>, <gmpR> ) . . . . difference of two GMP integers162**163** 'DiffInt' returns the difference of the two integer arguments <gmpL>164** and <gmpR>.165**166*/167extern Obj DiffInt (168Obj opL,169Obj opR );170171/****************************************************************************172**173*F ProdInt( <gmpL>, <gmpR> ) . . . . . product of two GMP integers174**175** 'ProdInt' returns the product of the two integer arguments <gmpL>176** and <gmpR>.177**178*/179extern Obj ProdInt (180Obj opL,181Obj opR );182183184/****************************************************************************185**186*F ModInt( <gmpL>, <gmpR> ) representant of res cl of a GMP integer187**188** 'ModInt' returns the smallest positive representant of the residue189** class of the integer <gmpL> modulo the integer <gmpR>.190**191*/192extern Obj ModInt (193Obj opL,194Obj opR );195196197/****************************************************************************198**199*F PowInt( <gmpL>, <gmpR> ) . . . . . . . . power of a GMP integer200**201** 'PowInt' returns the <gmpR>-th (a GMP int) power of the GMP integer202** <gmpL>.203**204*/205extern Obj PowInt (206Obj opL,207Obj opR );208209210/****************************************************************************211**212*F QuoInt( <gmpL>, <gmpR> ) . . . . . quotient of two GMP integers213**214** 'QuoInt' returns the integer part of the two integers <gmpL> and215** <gmpR>.216**217*/218extern Obj QuoInt (219Obj opL,220Obj opR );221222223/****************************************************************************224**225*F RemInt( <gmpL>, <gmpR> ) . . . . remainder of two GMP integers226**227** 'RemInt' returns the remainder of the quotient of the GMP ints228** <gmpL> and <gmpR>.229**230*/231extern Obj RemInt (232Obj opL,233Obj opR );234235236/****************************************************************************237**238*F GcdInt( <gmpL>, <gmpR> ) . . . . . . . gcd of two GMP integers239**240** 'GcdInt' returns the gcd of the two integers <gmpL> and <gmpR>.241*/242extern Obj GcdInt (243Obj opL,244Obj opR );245246247extern Int CLog2Int(Int intnum);248extern Obj FuncLog2Int( Obj self, Obj intnum);249250extern Obj AInvInt ( Obj gmp );251252/****************************************************************************253**254*F * * * * * * * * * * * * * initialize package * * * * * * * * * * * * * * *255*/256257258/****************************************************************************259**260*F InitInfoInt() . . . . . . . . . . . . . . . . table of init functions261*/262StructInitInfo * InitInfoInt ( void );263264#endif // USE_GMP265266#endif // GAP_GMPINTS_H267268/****************************************************************************269**270*E gmpints.h . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here271*/272273274