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 ariths.h GAP source Frank Celler3*W & Martin Schönert4**5**6*Y Copyright (C) 1996, Lehrstuhl D für Mathematik, RWTH Aachen, Germany7*Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland8*Y Copyright (C) 2002 The GAP Group9**10** This file declares the functions of the arithmetic operations package.11*/1213#ifndef GAP_ARITHS_H14#define GAP_ARITHS_H1516/****************************************************************************17**1819*T CompaMethod . . . . . . . . . . type of methods for comparison operations20**21** 'CompaMethod' is the type of methods for comparison operations, i.e., a22** function accepting two arguments of type 'Obj' and returning an 'Int'.23*/24typedef Int (* CompaMethod) ( Obj opL, Obj opR );252627/****************************************************************************28**29*T ArithMethod1 . . . . . . . . . type of methods for arithmetic operations30**31** 'ArithMethod1' is the type of methods for unary arithmetic operations,32** i.e., a function accepting one argument of type 'Obj' and returning an33** 'Obj'.34*/35typedef Obj (* ArithMethod1) ( Obj op );363738/****************************************************************************39**40*T ArithMethod2 . . . . . . . . . type of methods for arithmetic operations41**42** 'ArithMethod2' is the type of methods for binary arithmetic operations,43** i.e., a function accepting two arguments of type 'Obj' and returning an44** 'Obj'.45*/46typedef Obj (* ArithMethod2) ( Obj opL, Obj opR );474849/****************************************************************************50**5152*F * * * * * * * * * * * unary arithmetic operations * * * * * * * * * * * *53*/5455/****************************************************************************56**57*F ZERO( <op> ) . . . . . . . . . . . . . . . . . . . . . zero of an object58**59** 'ZERO' returns the zero of the object <op>.60*/61#define ZERO(op) ((*ZeroFuncs[TNUM_OBJ(op)])(op))6263extern Obj ZEROOp;646566/****************************************************************************67**68*V ZeroFuncs[<type>] . . . . . . . . . . . . . . . . . table of zero methods69*/70extern ArithMethod1 ZeroFuncs [LAST_VIRTUAL_TNUM+1];717273/****************************************************************************74**75*F InstallZeroObject( <verb> )76*/77extern void InstallZeroObject ( Int );7879/****************************************************************************80**81*F ZERO_MUT( <op> ) . . . . . . . . . . . . . . . . . . . . . zero of an object82**83** 'ZERO_MUT' returns the mutable zero of the object <op>.84*/85#define ZERO_MUT(op) ((*ZeroMutFuncs[TNUM_OBJ(op)])(op))8687extern Obj ZeroOp;888990/****************************************************************************91**92*V ZeroMutFuncs[<type>] . . . . . . . . . . . . . . . . . table of zero methods93*/94extern ArithMethod1 ZeroMutFuncs [LAST_VIRTUAL_TNUM+1];959697/****************************************************************************98**99*F InstallZeroMutObject( <verb> )100*/101extern void InstallZeroMutObject ( Int );102103104/****************************************************************************105**106107*F AINV( <op> ) . . . . . . . . . . . . . . . additive inverse of an object108**109** 'AINV' returns the additive inverse of the object <op>.110*/111#define AINV(op) ((*AInvFuncs[TNUM_OBJ(op)])(op))112113extern Obj AInvOp;114115116/****************************************************************************117**118*V AInvFuncs[<type>] . . . . . . . . . . . table of additive inverse methods119*/120extern ArithMethod1 AInvFuncs [LAST_VIRTUAL_TNUM+1];121122123/****************************************************************************124**125*F InstallAinvObject( <verb> )126*/127extern void InstallAinvObject ( Int );128129/****************************************************************************130**131*F AINV_MUT( <op> ) . . . . . . . . . . . . . additive inverse of an object132**133** 'AINV_MUT' returns the mutable additive inverse of the object <op>.134*/135#define AINV_MUT(op) ((*AInvMutFuncs[TNUM_OBJ(op)])(op))136137extern Obj AdditiveInverseOp;138139140/****************************************************************************141**142*V AInvMutFuncs[<type>] . . . . . . . . . . . table of additive inverse methods143*/144extern ArithMethod1 AInvMutFuncs [LAST_VIRTUAL_TNUM+1];145146147/****************************************************************************148**149*F InstallAinvMutObject( <verb> )150*/151extern void InstallAinvMutObject ( Int );152153154/****************************************************************************155**156*F C_AINV( <val>, <left> ) . . . . . . . . . . . . . . . . . . compute ainv157*/158#define C_AINV(val,left) \159val = AINV_MUT( left );160161162/****************************************************************************163**164*F C_AINV_FIA( <val>, <left> ) . . . . . . . . . compute ainv, fast integer165*/166#define C_AINV_FIA(val,left) \167val = AINV_MUT( left );168169170/****************************************************************************171**172*F C_AINV_INTOBJS( <val>, <left> ) . . . . . . . compute ainv of an integer173*/174#define C_AINV_INTOBJS(val,left) \175val = AINV_MUT( left );176177178/****************************************************************************179**180*F ONE( <op> ) . . . . . . . . . . . . . . . . . . . . . . one of an object181**182** 'ONE' returns the one of the object <op>.183*/184#define ONE(op) ((*OneFuncs[TNUM_OBJ(op)])(op))185186extern Obj OneOp;187188189/****************************************************************************190**191*V OneFuncs[<type>] . . . . . . . . . . . . . . . . . table of one methods192*/193extern ArithMethod1 OneFuncs [LAST_VIRTUAL_TNUM+1];194195196/****************************************************************************197**198*F InstallOneObject( <verb> )199*/200extern void InstallOneObject ( Int );201202/****************************************************************************203**204*F ONE_MUT( <op> ) . . . . . . . . one of an object retaining mutability205**206** 'ONE_MUT' returns the one of the object <op> with the same207** mutability level as <op>.208*/209#define ONE_MUT(op) ((*OneMutFuncs[TNUM_OBJ(op)])(op))210211extern Obj OneMutOp;212213214/****************************************************************************215**216*V OneMutFuncs[<type>] . . . . . .table of mutability preservingone methods217*/218extern ArithMethod1 OneMutFuncs [LAST_VIRTUAL_TNUM+1];219220221/****************************************************************************222**223*F InstallOneMutObject( <verb> )224*/225extern void InstallOneMutObject ( Int );226227228/****************************************************************************229**230*F INV( <op> ) . . . . . . . . . . . . . . . . . . . . inverse of an object231**232** 'INV' returns the multiplicative inverse of the object <op>.233*/234#define INV(op) ((*InvFuncs[TNUM_OBJ(op)])(op))235236extern Obj InvOp;237238239/****************************************************************************240**241*V InvFuncs[<type>] . . . . . . . . . . . . . . table of inverse functions242*/243extern ArithMethod1 InvFuncs [LAST_VIRTUAL_TNUM+1];244245246/****************************************************************************247**248*F InstallInvObject( <verb> )249*/250extern void InstallInvObject ( Int );251252253/****************************************************************************254**255*F INV_MUT( <op> ) . . . . . . . . inverse of an object retaining mutability256**257** 'INV_MUT' returns the multiplicative inverse of the object <op>.258*/259#define INV_MUT(op) ((*InvMutFuncs[TNUM_OBJ(op)])(op))260261extern Obj InvMutOp;262263264/****************************************************************************265**266*V InvMutFuncs[<type>] .. .table of mutability preserving inverse functions267*/268extern ArithMethod1 InvMutFuncs [LAST_VIRTUAL_TNUM+1];269270271/****************************************************************************272**273*F InstallInvMutObject( <verb> )274*/275extern void InstallInvMutObject ( Int );276277278/****************************************************************************279**280281*F * * * * * * * * * * * * * comparison operations * * * * * * * * * * * * *282*/283284/****************************************************************************285**286287*F EQ( <opL>, <opR> ) . . . . . . . . . . . . . . comparison of two objects288**289** 'EQ' returns a nonzero value if the object <opL> is equal to the object290** <opR>, and zero otherwise.291*/292#define EQ(opL,opR) ((opL) == (opR) || \293(!ARE_INTOBJS(opL,opR) && \294(*EqFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR)))295296#define EQ2(opL,opR) ((opL) == (opR) || \297(*EqFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))298299extern Obj EqOper;300301302/****************************************************************************303**304*V EqFuncs[<typeL>][<typeR>] . . . . . . . . . . table of comparison methods305*/306extern CompaMethod EqFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];307308309/****************************************************************************310**311*F InstallEqObject( <verb> )312*/313extern void InstallEqObject ( Int );314315316/****************************************************************************317**318319*F LT( <opL>, <opR> ) . . . . . . . . . . . . . . comparison of two objects320**321** 'LT' returns a nonzero value if the object <opL> is less than the object322** <opR>, and zero otherwise.323*/324#define LT(opL,opR) ((opL) == (opR) ? 0 : \325(ARE_INTOBJS(opL,opR) ? (Int)(opL) < (Int)(opR) : \326(*LtFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR)))327328#define LT2(opL,opR) ((opL) == (opR) ? 0 : \329(*LtFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))330331extern Obj LtOper;332333334/****************************************************************************335**336*V LtFuncs[<typeL>][<typeR>] . . . . . . . . . . table of comparison methods337*/338extern CompaMethod LtFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];339340341/****************************************************************************342**343*F InstallLtObject( <verb> )344*/345extern void InstallLtObject ( Int );346347348/****************************************************************************349**350351*F IN( <opL>, <opR> ) . . . . . . . . . . . membership test of two objects352**353** 'IN' returns a nonzero value if the object <opL> is a member of the354** object <opR>, and zero otherwise.355*/356#define IN(opL,opR) ((*InFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))357358extern Obj InOper;359360361/****************************************************************************362**363*V InFuncs[<typeL>][<typeR>] . . . . . . . . . . table of membership methods364*/365extern CompaMethod InFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];366367368/****************************************************************************369**370*F InstallInObject( <verb> )371*/372extern void InstallInObject ( Int );373374375/****************************************************************************376**377378*F * * * * * * * * * * * binary arithmetic operations * * * * * * * * * * * *379*/380381/****************************************************************************382**383384*F SUM( <opL>, <opR> ) . . . . . . . . . . . . . . . . . sum of two objects385**386** 'SUM' returns the sum of the two objects <opL> and <opR>.387**388** At places where performance matters one should use the following code389**390** if ( ! ARE_INTOBJS( <opL>, <opR> )391** || ! SUM_INTOBJS( <res>, <opL>, <opR> ) )392** <res> = SUM( <opL>, <opR> );393*/394#define SUM(opL,opR) ((*SumFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))395396extern Obj SumOper;397398399/****************************************************************************400**401*V SumFuncs[<typeL>][<typeR>] . . . . . . . . . . . . table of sum methods402*/403extern ArithMethod2 SumFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];404405406/****************************************************************************407**408*F InstallSumObject( <verb> )409*/410extern void InstallSumObject ( Int );411412413/****************************************************************************414**415*F C_SUM( <val>, <left>, <right> ) . . . . . . . . . . . . . . . compute sum416*/417#define C_SUM(val,left,right) \418val = SUM( left, right );419420421/****************************************************************************422**423*F C_SUM_FIA( <val>, <left>, <right> ) . . . . . compute sum, fast integers424*/425#define C_SUM_FIA(val,left,right) \426if ( ! ARE_INTOBJS(left,right) || ! SUM_INTOBJS(val,left,right) ) { \427val = SUM( left, right ); \428}429430431/****************************************************************************432**433*F C_SUM_INTOBJS( <val>, <left>, <right> ) . . . compute sum of two integers434*/435#define C_SUM_INTOBJS(val,left,right) \436if ( ! SUM_INTOBJS(val,left,right) ) { \437val = SUM( left, right ); \438}439440441/****************************************************************************442**443444*F DIFF( <opL>, <opR> ) . . . . . . . . . . . . . difference of two objects445**446** 'DIFF' returns the difference of the two objects <opL> and <opR>.447**448** At places where performance matters one should use the following code449**450** if ( ! ARE_INTOBJS( <opL>, <opR> )451** || ! DIFF_INTOBJS( <res>, <opL>, <opR> ) )452** <res> = DIFF( <opL>, <opR> );453*/454#define DIFF(opL,opR) ((*DiffFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))455456extern Obj DiffOper;457458459/****************************************************************************460**461*V DiffFuncs[<typeL>][<typeR>] . . . . . . . . . table of difference methods462*/463extern ArithMethod2 DiffFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];464465466/****************************************************************************467**468*F InstallDiffObject( <verb> )469*/470extern void InstallDiffObject ( Int );471472473/****************************************************************************474**475*F C_DIFF( <val>, <left>, <right> ) . . . . . . . . . . . . . compute diff476*/477#define C_DIFF(val,left,right) \478val = DIFF( left, right );479480481/****************************************************************************482**483*F C_DIFF_FIA( <val>, <left>, <right> ) . . . . compute diff, fast integers484*/485#define C_DIFF_FIA(val,left,right) \486if ( ! ARE_INTOBJS(left,right) || ! DIFF_INTOBJS(val,left,right) ) { \487val = DIFF( left, right ); \488}489490491/****************************************************************************492**493*F C_DIFF_INTOBJS( <val>, <left>, <right> ) . compute diff of two integers494*/495#define C_DIFF_INTOBJS(val,left,right) \496if ( ! DIFF_INTOBJS(val,left,right) ) { \497val = DIFF( left, right ); \498}499500501/****************************************************************************502**503504*F PROD( <opL>, <opR> ) . . . . . . . . . . . . . . product of two objects505**506** 'PROD' returns the product of the two objects <opL> and <opR>.507**508** At places where performance matters one should use the following code509**510** if ( ! ARE_INTOBJS( <opL>, <opR> )511** || ! PROD_INTOBJS( <res>, <opL>, <opR> ) )512** <res> = PROD( <opL>, <opR> );513*/514#define PROD(opL,opR) ((*ProdFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))515516extern Obj ProdOper;517518519/****************************************************************************520**521*V ProdFuncs[<typeL>][<typeR>] . . . . . . . . . . table of product methods522*/523extern ArithMethod2 ProdFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];524525526/****************************************************************************527**528*F InstallProdObject( <verb> )529*/530extern void InstallProdObject ( Int );531532533/****************************************************************************534**535*F C_PROD( <val>, <left>, <right> ) . . . . . . . . . . . . compute product536*/537#define C_PROD(val,left,right) \538val = PROD( left, right );539540541/****************************************************************************542**543*F C_PROD_FIA( <val>, <left>, <right> ) . . compute product, fast integers544*/545#define C_PROD_FIA(val,left,right) \546if ( ! ARE_INTOBJS(left,right) || ! PROD_INTOBJS(val,left,right) ) { \547val = PROD( left, right ); \548}549550551/****************************************************************************552**553*F C_PROD_INTOBJS( <val>, <left>, <right> ) compute product of two integers554*/555#define C_PROD_INTOBJS(val,left,right) \556if ( ! PROD_INTOBJS(val,left,right) ) { \557val = PROD( left, right ); \558}559560561/****************************************************************************562**563564*F QUO( <opL>, <opR> ) . . . . . . . . . . . . . . . quotient of two objects565**566** 'QUO' returns the quotient of the object <opL> by the object <opR>.567*/568#define QUO(opL,opR) ((*QuoFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))569570extern Obj QuoOper;571572573/****************************************************************************574**575*V QuoFuncs[<typeL>][<typeR>] . . . . . . . . . . table of quotient methods576*/577extern ArithMethod2 QuoFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];578579580/****************************************************************************581**582*F InstallQuoObject( <verb> )583*/584extern void InstallQuoObject ( Int );585586587/****************************************************************************588**589590*F LQUO( <opL>, <opR> ) . . . . . . . . . . . left quotient of two operand591**592** 'LQUO' returns the left quotient of the object <opL> by the object <opR>.593*/594#define LQUO(opL,opR) ((*LQuoFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))595596extern Obj LQuoOper;597598599/****************************************************************************600**601*V LQuoFuncs[<typeL>][<typeR>] . . . . . . . table of left quotient methods602*/603extern ArithMethod2 LQuoFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];604605606/****************************************************************************607**608*F InstallLQuoObject( <verb> )609*/610extern void InstallLQuoObject ( Int );611612613/****************************************************************************614**615616*F POW( <opL>, <opR> ) . . . . . . . . . . . . . . . . power of two objects617**618** 'POW' returns the power of the object <opL> by the object <opL>.619*/620#define POW(opL,opR) ((*PowFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))621622extern Obj PowOper;623624extern Obj PowDefault ( Obj opL, Obj opR );625626627/****************************************************************************628**629*V PowFuncs[<typeL>][<typeR>] . . . . . . . . . . . table of power methods630*/631extern ArithMethod2 PowFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];632633634/****************************************************************************635**636*F InstallPowObject( <verb> )637*/638extern void InstallPowObject ( Int );639640641/****************************************************************************642**643644*F COMM( <opL>, <opR> ) . . . . . . . . . . . . . commutator of two objects645**646** 'COMM' returns the commutator of the two objects <opL> and <opR>.647*/648#define COMM(opL,opR) ((*CommFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))649650extern Obj CommOper;651652653/****************************************************************************654**655*V CommFuncs[<typeL>][<typeR>] . . . . . . . . . table of commutator methods656*/657extern ArithMethod2 CommFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];658659660/****************************************************************************661**662*F InstallCommObject( <verb> )663*/664extern void InstallCommObject ( Int );665666667/****************************************************************************668**669670*F MOD( <opL>, <opR> ) . . . . . . . . . . . . . . remainder of two objects671**672** 'MOD' returns the remainder of the object <opL> by the object <opR>.673*/674#define MOD(opL,opR) ((*ModFuncs[TNUM_OBJ(opL)][TNUM_OBJ(opR)])(opL,opR))675676extern Obj ModOper;677678679/****************************************************************************680**681*V ModFuncs[<typeL>][<typeR>] . . . . . . . . . table of remainder methods682*/683extern ArithMethod2 ModFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];684685686/****************************************************************************687**688*F InstallModObject( <verb> )689*/690extern void InstallModObject ( Int );691692693/****************************************************************************694**695696*F * * * * * * * * * * * * * initialize package * * * * * * * * * * * * * * *697*/698699/****************************************************************************700**701702*F InitInfoAriths() . . . . . . . . . . . . . . . . table of init functions703*/704StructInitInfo * InitInfoAriths ( void );705706707#endif // GAP_ARITHS_H708709/****************************************************************************710**711712*E ariths.h . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here713*/714715716