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.c 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 contains the functions of the arithmetic operations package.11*/12#include "system.h" /* system dependent part */131415#include "gasman.h" /* garbage collector */16#include "objects.h" /* objects */17#include "scanner.h" /* scanner */1819#include "gap.h" /* error handling, initialisation */2021#include "gvars.h" /* global variables */22#include "calls.h" /* generic call mechanism */23#include "opers.h" /* generic operations */2425#include "ariths.h" /* basic arithmetic */2627#include "bool.h" /* booleans */2829#include "records.h" /* generic records */30#include "precord.h" /* plain records */3132#include "lists.h" /* generic lists */33#include "string.h" /* strings */3435#include "code.h" /* coder */36#include "thread.h" /* threads */37#include "tls.h" /* thread-local storage */38394041/****************************************************************************42**4344*F * * * * * * * * * * * unary arithmetic operations * * * * * * * * * * * *45*/4647/****************************************************************************48**49*V ZeroFuncs[ <type> ] . . . . . . . . . . . . . . . . table of zero methods50*/51ArithMethod1 ZeroFuncs [LAST_VIRTUAL_TNUM+1];525354/****************************************************************************55**56*F ZeroObject( <obj> ) . . . . . . . . . . . . . . . . . . . . call methsel57*/58Obj ZEROOp;5960Obj ZeroObject (61Obj obj )6263{64Obj val;65val = DoOperation1Args( ZEROOp, obj );66while (val == 0)67val = ErrorReturnObj("ZEROOp: method should have returned a value", 0L, 0L,68"you can supply one by 'return <value>;'");69return val;70}717273/****************************************************************************74**75*F VerboseZeroObject( <obj> ) . . . . . . . . . . . . call verbose methsel76*/77Obj VerboseZeroObject (78Obj obj )7980{81Obj val;82val = DoVerboseOperation1Args( ZEROOp, obj );83while (val == 0)84val = ErrorReturnObj("ZEROOp: method should have returned a value", 0L, 0L,85"you can supply one by 'return <value>;'");86return val;87}888990/****************************************************************************91**92*F InstallZeroObject( <verb> ) . . . . . . . . . . . . install zero methods93*/94void InstallZeroObject ( Int verb )95{96UInt t1; /* type of left operand */97ArithMethod1 func; /* zero function */9899func = ( verb ? VerboseZeroObject : ZeroObject );100for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {101ZeroFuncs[t1] = func;102}103ZeroFuncs[ T_PREC ] = func;104ZeroFuncs[ T_PREC +IMMUTABLE ] = func;105}106107108/****************************************************************************109**110*F FuncZERO( <self>, <obj> ) . . . . . . . . . . . . . . . . . . call 'ZERO'111*/112Obj FuncZERO (113Obj self,114Obj obj )115{116return ZERO(obj);117}118119/****************************************************************************120**121*V ZeroMutFuncs[ <type> ] . . . . . . . . . . . . . . . . table of zero methods122*/123ArithMethod1 ZeroMutFuncs [LAST_VIRTUAL_TNUM+1];124125126/****************************************************************************127**128*F ZeroMutObject( <obj> ) . . . . . . . . . . . . . . . . . . . . call methsel129*/130Obj ZeroOp;131132Obj ZeroMutObject (133Obj obj )134135{136Obj val;137val = DoOperation1Args( ZeroOp, obj );138while (val == 0)139val = ErrorReturnObj("ZeroOp: method should have returned a value", 0L, 0L,140"you can supply one by 'return <value>;'");141return val;142}143144145/****************************************************************************146**147*F VerboseZeroMutObject( <obj> ) . . . . . . . . . . . . call verbose methsel148*/149Obj VerboseZeroMutObject (150Obj obj )151152{153Obj val;154val = DoVerboseOperation1Args( ZeroOp, obj );155while (val == 0)156val = ErrorReturnObj("ZeroOp: method should have returned a value", 0L, 0L,157"you can supply one by 'return <value>;'");158return val;159}160161162/****************************************************************************163**164*F InstallZeroMutObject( <verb> ) . . . . . . . . . . . . install zero methods165*/166void InstallZeroMutObject ( Int verb )167{168UInt t1; /* type of left operand */169ArithMethod1 func; /* zero function */170171func = ( verb ? VerboseZeroMutObject : ZeroMutObject );172for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {173ZeroMutFuncs[t1] = func;174}175ZeroMutFuncs[ T_PREC ] = func;176ZeroMutFuncs[ T_PREC +IMMUTABLE ] = func;177}178179180/****************************************************************************181**182*F FuncZERO_MUT( <self>, <obj> ) . . . . . . . . . . . . . . call 'ZERO_MUT'183*/184Obj FuncZERO_MUT (185Obj self,186Obj obj )187{188return ZERO_MUT(obj);189}190191192/****************************************************************************193**194*V AInvFuncs[ <type> ] . . . . . . . . . . table of additive inverse methods195*V AInvMutFuncs[ <type> ] . . . . . . . . table of additive inverse methods196** which return mutable results197*/198ArithMethod1 AInvFuncs [LAST_VIRTUAL_TNUM+1];199ArithMethod1 AInvMutFuncs[ LAST_VIRTUAL_TNUM + 1];200201202/****************************************************************************203**204*F AInvObj( <obj> ) . . . . . . . . . . . . . . . . . . . . . call methsel205*/206Obj AInvOp;207208Obj AInvObject (209Obj obj )210{211Obj val;212val = DoOperation1Args( AInvOp, obj );213while (val == 0)214val = ErrorReturnObj("AInvOp: method should have returned a value", 0L, 0L,215"you can supply one by 'return <value>;'");216return val;217}218219220/****************************************************************************221**222*F VerboseAInvObject( <obj> ) . . . . . . . . . . . . call verbose methsel223*/224Obj VerboseAInvObject (225Obj obj )226{227Obj val;228val = DoVerboseOperation1Args( AInvOp, obj );229while (val == 0)230val = ErrorReturnObj("AInvOp: method should have returned a value", 0L, 0L,231"you can supply one by 'return <value>;'");232return val;233}234235236/****************************************************************************237**238*F InstallAinvObject( <verb> ) . . . . . . install additive inverse methods239*/240void InstallAinvObject ( Int verb )241{242UInt t1; /* type of left operand */243ArithMethod1 func; /* ainv function */244245func = ( verb ? VerboseAInvObject : AInvObject );246for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {247AInvFuncs[t1] = func;248}249AInvFuncs[ T_PREC ] = func;250AInvFuncs[ T_PREC +IMMUTABLE ] = func;251}252253254/****************************************************************************255**256*F FuncAINV( <self>, <obj> ) . . . . . . . . . . . . . . . . . . call 'AINV'257*/258Obj FuncAINV (259Obj self,260Obj obj )261{262return AINV(obj);263}264265/****************************************************************************266**267*F AInvMutObject( <obj> ) . .. . . . . . . . . . . . . . . . . call methsel268*/269Obj AdditiveInverseOp;270271Obj AInvMutObject (272Obj obj )273{274Obj val;275val = DoOperation1Args( AdditiveInverseOp, obj );276while (val == 0)277val = ErrorReturnObj("AdditiveInverseOp: method should have returned a value", 0L, 0L,278"you can supply one by 'return <value>;'");279return val;280}281282283/****************************************************************************284**285*F VerboseAInvMutObject( <obj> ) . . . . . . . . . . . . call verbose methsel286*/287Obj VerboseAInvMutObject (288Obj obj )289{290Obj val;291val = DoVerboseOperation1Args( AdditiveInverseOp, obj );292while (val == 0)293val = ErrorReturnObj("AdditiveInverseOp: method should have returned a value", 0L, 0L,294"you can supply one by 'return <value>;'");295return val;296}297298299/****************************************************************************300**301*F InstallAinvMutObject( <verb> ) . . . . . . install additive inverse methods302*/303void InstallAinvMutObject ( Int verb )304{305UInt t1; /* type of left operand */306ArithMethod1 func; /* ainv function */307308func = ( verb ? VerboseAInvMutObject : AInvMutObject );309for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {310AInvMutFuncs[t1] = func;311}312AInvMutFuncs[ T_PREC ] = func;313AInvMutFuncs[ T_PREC +IMMUTABLE ] = func;314}315316317/****************************************************************************318**319*F FuncAINV_MUT( <self>, <obj> ) . . . . . . . . . . . . . . . . . . call 'AINV'320*/321Obj FuncAINV_MUT (322Obj self,323Obj obj )324{325return AINV_MUT(obj);326}327328329/****************************************************************************330**331332*V OneFuncs[ <type> ] . . . . . . . . . . . . . . . . table of one methods333*/334ArithMethod1 OneFuncs [LAST_VIRTUAL_TNUM+1];335336337/****************************************************************************338**339*F OneObject( <obj> ) . . . . . . . . . . . . . . . . . . . . call methsel340*/341Obj OneOp;342343Obj OneObject (344Obj obj )345{346Obj val;347val = DoOperation1Args( OneOp, obj );348while (val == 0)349val = ErrorReturnObj("OneOp: method should have returned a value", 0L, 0L,350"you can supply one by 'return <value>;'");351return val;352}353354355/****************************************************************************356**357*F VerboseOneObject( <obj> ) . . . . . . . . . . . . . . . . . call methsel358*/359Obj VerboseOneObject (360Obj obj )361{362Obj val;363val = DoVerboseOperation1Args( OneOp, obj );364while (val == 0)365val = ErrorReturnObj("OneOp: method should have returned a value", 0L, 0L,366"you can supply one by 'return <value>;'");367return val;368}369370371/****************************************************************************372**373*F InstallOneObject( <verb> ) . . . . . . . . . . . . . install one methods374*/375void InstallOneObject ( Int verb )376{377UInt t1; /* type of left operand */378ArithMethod1 func; /* one function */379380func = ( verb ? VerboseOneObject : OneObject );381for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {382OneFuncs[t1] = func;383}384OneFuncs[ T_PREC ] = func;385OneFuncs[ T_PREC +IMMUTABLE ] = func;386}387388389/****************************************************************************390**391*F FuncONE( <self>, <obj> ) . . . . . . . . . . . . . . . . . call 'ONE'392*/393Obj FuncONE (394Obj self,395Obj obj )396{397return ONE(obj);398}399400/****************************************************************************401**402403*V OneMutFuncs[ <type> ] . . . . .table of mutability retaining one methods404*/405ArithMethod1 OneMutFuncs [LAST_VIRTUAL_TNUM+1];406407408/****************************************************************************409**410*F OneMutObject( <obj> ) . . . . . . . . . . . . . . . . . . . . call methsel411*/412Obj OneMutOp;413414Obj OneMutObject (415Obj obj )416{417Obj val;418val = DoOperation1Args( OneMutOp, obj );419while (val == 0)420val = ErrorReturnObj("ONEOp: method should have returned a value", 0L, 0L,421"you can supply one by 'return <value>;'");422return val;423}424425426/****************************************************************************427**428*F VerboseOneMutObject( <obj> ) . . . . . . . . . . . . . . . call methsel429*/430Obj VerboseOneMutObject (431Obj obj )432{433Obj val;434val = DoVerboseOperation1Args( OneMutOp, obj );435while (val == 0)436val = ErrorReturnObj("ONEOp: method should have returned a value", 0L, 0L,437"you can supply one by 'return <value>;'");438return val;439}440441442/****************************************************************************443**444*F InstallOneMutObject( <verb> ) . . . . . . . . . . . . . install one methods445*/446void InstallOneMutObject ( Int verb )447{448UInt t1; /* type of left operand */449ArithMethod1 func; /* one function */450451func = ( verb ? VerboseOneMutObject : OneMutObject );452for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {453OneMutFuncs[t1] = func;454}455OneMutFuncs[ T_PREC ] = func;456OneMutFuncs[ T_PREC +IMMUTABLE ] = func;457}458459460/****************************************************************************461**462*F FuncONE_MUT( <self>, <obj> ) . . . . . . . . . . . . . . . .call 'ONE_MUT'463*/464Obj FuncONE_MUT (465Obj self,466Obj obj )467{468return ONE_MUT(obj);469}470471472/****************************************************************************473**474475*V InvFuncs[ <type> ] . . . . . . . . . . . . . table of inverse functions476*/477ArithMethod1 InvFuncs [LAST_VIRTUAL_TNUM+1];478479480/****************************************************************************481**482*F InvObject( <obj> ) . . . . . . . . . . . . . . . . . . . . call methsel483*/484Obj InvOp;485486Obj InvObject (487Obj obj )488{489Obj val;490val = DoOperation1Args( InvOp, obj );491while (val == 0)492val = ErrorReturnObj("InvOp: method should have returned a value", 0L, 0L,493"you can supply one by 'return <value>;'");494return val;495}496497498/****************************************************************************499**500*F VerboseInvObject( <obj> ) . . . . . . . . . . . . . . . . . call methsel501*/502Obj VerboseInvObject (503Obj obj )504{505Obj val;506val = DoVerboseOperation1Args( InvOp, obj );507while (val == 0)508val = ErrorReturnObj("InvOp: method should have returned a value", 0L, 0L,509"you can supply one by 'return <value>;'");510return val;511}512513514/****************************************************************************515**516*F InstallInvObject( <verb> ) . . . . . . . . . . . install inverse methods517*/518void InstallInvObject ( Int verb )519{520UInt t1; /* type of left operand */521ArithMethod1 func; /* inv function */522523func = ( verb ? VerboseInvObject : InvObject );524for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {525InvFuncs[t1] = func;526}527InvFuncs[ T_PREC ] = func;528InvFuncs[ T_PREC +IMMUTABLE ] = func;529}530531532/****************************************************************************533**534*F FuncINV( <self>, <obj> ) . . . . . . . . . . . . . . . . . . call 'INV'535*/536Obj FuncINV (537Obj self,538Obj obj )539{540return INV( obj );541}542543544/****************************************************************************545**546*V InvMutFuncs[ <type> ] . table of mutability-preserving inverse functions547*/548ArithMethod1 InvMutFuncs [LAST_VIRTUAL_TNUM+1];549550551/****************************************************************************552**553*F InvMutObject( <obj> ) . . . . . . . . . . . . . . .. . . . . call methsel554*/555Obj InvMutOp;556557Obj InvMutObject (558Obj obj )559{560Obj val;561val = DoOperation1Args( InvMutOp, obj );562while (val == 0)563val = ErrorReturnObj("INVOp: method should have returned a value", 0L, 0L,564"you can supply one by 'return <value>;'");565return val;566}567568569/****************************************************************************570**571*F VerboseInvMutObject( <obj> ) . . . . . . . . . . . . . . . call methsel572*/573Obj VerboseInvMutObject (574Obj obj )575{576Obj val;577val = DoVerboseOperation1Args( InvMutOp, obj );578while (val == 0)579val = ErrorReturnObj("INVOp: method should have returned a value", 0L, 0L,580"you can supply one by 'return <value>;'");581return val;582}583584585/****************************************************************************586**587*F InstallInvMutObject( <verb> ) install mutability preserving inverse methods588*/589void InstallInvMutObject ( Int verb )590{591UInt t1; /* type of left operand */592ArithMethod1 func; /* inv function */593594func = ( verb ? VerboseInvMutObject : InvMutObject );595for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {596InvMutFuncs[t1] = func;597}598InvMutFuncs[ T_PREC ] = func;599InvMutFuncs[ T_PREC +IMMUTABLE ] = func;600}601602603/****************************************************************************604**605*F FuncINV_MUT( <self>, <obj> ) . . . . . . . . . . . . . call 'INV_MUT'606*/607Obj FuncINV_MUT (608Obj self,609Obj obj )610{611return INV_MUT( obj );612}613614615/****************************************************************************616**617618*F * * * * * * * * * * * * * comparison operations * * * * * * * * * * * * *619*/620621/****************************************************************************622**623624*V EqFuncs[ <typeL> ][ <typeR> ] . . . . . . . . table of comparison methods625*/626CompaMethod EqFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];627628629/****************************************************************************630**631*F EqNot( <opL>, <opR> ) . . . . . . . . . . . . . . . . . . . . . not equal632*/633Int EqNot (634Obj opL,635Obj opR )636{637return 0L;638}639640641/****************************************************************************642**643*F EqObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . . call methsel644*/645Obj EqOper;646647Int EqObject (648Obj opL,649Obj opR )650{651return (DoOperation2Args( EqOper, opL, opR ) == True);652}653654655/****************************************************************************656**657*F VerboseEqObject( <opL>, <opR> ) . . . . . . . . . . . . . . call methsel658*/659Int VerboseEqObject (660Obj opL,661Obj opR )662{663return (DoVerboseOperation2Args( EqOper, opL, opR ) == True);664}665666667/****************************************************************************668**669*F InstallEqObject( <verb> ) . . . . . . . . . . install comparison methods670*/671void InstallEqObject ( Int verb )672{673UInt t1; /* type of left operand */674UInt t2; /* type of right operand */675CompaMethod func; /* equal function */676677func = ( verb ? VerboseEqObject : EqObject );678for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {679for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {680EqFuncs[t1][t2] = func;681EqFuncs[t2][t1] = func;682}683}684for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {685686EqFuncs[ t2 ][ T_PREC ] = func;687EqFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;688EqFuncs[ T_PREC ][ t2 ] = func;689EqFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;690}691}692693694/****************************************************************************695**696*F FuncEQ( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . . . call 'EQ'697*/698Obj FuncEQ (699Obj self,700Obj opL,701Obj opR )702{703/* if both operands are T_MACFLOAT, we use the comparison method in all cases,704even if the objects are identical. In this manner, we can have 0./0. != 0./0. as705the IEEE754 standard requires.706if (TNUM_OBJ(opL) == T_MACFLOAT && TNUM_OBJ(opR) == T_MACFLOAT)707return (*EqFuncs[T_MACFLOAT][T_MACFLOAT])(opL,opR) ? True : False;708*/709710return (EQ( opL, opR ) ? True : False);711}712713714/****************************************************************************715**716717*V LtFuncs[ <typeL> ][ <typeR> ] . . . . . . . . table of comparison methods718*/719CompaMethod LtFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];720721722/****************************************************************************723**724*F LtObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . . call methsel725*/726Obj LtOper;727728Int LtObject (729Obj opL,730Obj opR )731{732return (DoOperation2Args( LtOper, opL, opR ) == True);733}734735736/****************************************************************************737**738*F VerboseLtObject( <opL>, <opR> ) . . . . . . . . . . . . . . call methsel739*/740Int VerboseLtObject (741Obj opL,742Obj opR )743{744return (DoVerboseOperation2Args( LtOper, opL, opR ) == True);745}746747748/****************************************************************************749**750*F InstallLtObject( <verb> ) . . . . . . . . . . . install less than methods751*/752void InstallLtObject ( Int verb )753{754UInt t1; /* type of left operand */755UInt t2; /* type of right operand */756CompaMethod func; /* less than function */757758func = ( verb ? VerboseLtObject : LtObject );759for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {760for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {761LtFuncs[t1][t2] = func;762LtFuncs[t2][t1] = func;763}764}765for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {766767LtFuncs[ t2 ][ T_PREC ] = func;768LtFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;769LtFuncs[ T_PREC ][ t2 ] = func;770LtFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;771}772}773774775/****************************************************************************776**777*F FuncLT( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . . . call 'LT'778*/779Obj FuncLT (780Obj self,781Obj opL,782Obj opR )783{784return (LT( opL, opR ) ? True : False);785}786787788/****************************************************************************789**790791*V InFuncs[ <typeL> ][ <typeR> ] . . . . . . . . table of membership methods792*/793CompaMethod InFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];794795796/****************************************************************************797**798*F InUndefined( <self>, <opL>, <opR> ) . . . . . . . . . . . . . cannot 'in'799*/800Int InUndefined (801Obj opL,802Obj opR )803{804return (ErrorReturnObj(805"operations: IN of %s and %s is not defined",806(Int)TNAM_OBJ(opL),807(Int)TNAM_OBJ(opR),808"you can 'return <boolean>;' to give a value for the result" ) == True);809}810811812/****************************************************************************813**814*F InObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . . call methsel815*/816Obj InOper;817818Int InObject (819Obj opL,820Obj opR )821{822return (DoOperation2Args( InOper, opL, opR ) == True);823}824825826/****************************************************************************827**828*F VerboseInObject( <opL>, <opR> ) . . . . . . . . . . . . . . call methsel829*/830Int VerboseInObject (831Obj opL,832Obj opR )833{834return (DoVerboseOperation2Args( InOper, opL, opR ) == True);835}836837838/****************************************************************************839**840*F InstallInObject( <verb> ) . . . . . . . . . . . . . . install in methods841*/842void InstallInObject ( Int verb )843{844UInt t1; /* type of left operand */845UInt t2; /* type of right operand */846CompaMethod func; /* in function */847848func = ( verb ? VerboseInObject : InObject );849for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {850for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {851InFuncs[t1][t2] = func;852InFuncs[t2][t1] = func;853}854}855for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {856857InFuncs[ t2 ][ T_PREC ] = func;858InFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;859}860}861862863/****************************************************************************864**865*F FuncIN( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . . . call 'IN'866*/867Obj FuncIN (868Obj self,869Obj opL,870Obj opR )871{872return (IN( opL, opR ) ? True : False);873}874875876/****************************************************************************877**878879*F * * * * * * * * * * * binary arithmetic operations * * * * * * * * * * * *880*/881882/****************************************************************************883**884885*V SumFuncs[ <typeL> ][ <typeR> ] . . . . . . . . . . table of sum methods886*/887ArithMethod2 SumFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];888889890/****************************************************************************891**892*F SumObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . . call methsel893*/894Obj SumOper;895896Obj SumObject (897Obj opL,898Obj opR )899{900Obj val;901val = DoOperation2Args( SumOper, opL, opR );902while (val == 0)903val = ErrorReturnObj("SUM: method should have returned a value", 0L, 0L,904"you can supply one by 'return <value>;'");905return val;906}907908909/****************************************************************************910**911*F VerboseSumObject( <opL>, <opR> ) . . . . . . . . . . . . . call methsel912*/913Obj VerboseSumObject (914Obj opL,915Obj opR )916{917Obj val;918val = DoVerboseOperation2Args( SumOper, opL, opR );919while (val == 0)920val = ErrorReturnObj("SUM: method should have returned a value", 0L, 0L,921"you can supply one by 'return <value>;'");922return val;923}924925926/****************************************************************************927**928*F InstallSumObject( <verb> ) . . . . . . . . . . . . . install sum methods929*/930void InstallSumObject ( Int verb )931{932UInt t1; /* type of left operand */933UInt t2; /* type of right operand */934ArithMethod2 func; /* sum function */935936func = ( verb ? VerboseSumObject : SumObject );937for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {938for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {939SumFuncs[t1][t2] = func;940SumFuncs[t2][t1] = func;941}942}943for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {944945SumFuncs[ t2 ][ T_PREC ] = func;946SumFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;947SumFuncs[ T_PREC ][ t2 ] = func;948SumFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;949}950}951952953/****************************************************************************954**955*F FuncSUM( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . . call 'SUM'956*/957Obj FuncSUM (958Obj self,959Obj opL,960Obj opR )961{962return SUM( opL, opR );963}964965966/****************************************************************************967**968969*V DiffFuncs[ <typeL> ][ <typeR> ] . . . . . . . table of difference methods970*/971ArithMethod2 DiffFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];972973974/****************************************************************************975**976*F DiffDefault( <opL>, <opR> ) . . . . . . . . . . . . call 'SUM' and 'AINV'977*/978Obj DiffDefault (979Obj opL,980Obj opR )981{982Obj tmp;983984tmp = AINV( opR );985return SUM( opL, tmp );986}987988989/****************************************************************************990**991*F DiffObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . call methsel992*/993Obj DiffOper;994995Obj DiffObject (996Obj opL,997Obj opR )998{999Obj val;1000val = DoOperation2Args( DiffOper, opL, opR );1001while (val == 0)1002val = ErrorReturnObj("DIFF: method should have returned a value", 0L, 0L,1003"you can supply one by 'return <value>;'");1004return val;1005}100610071008/****************************************************************************1009**1010*F VerboseDiffObject( <opL>, <opR> ) . . . . . . . . . . . . . call methsel1011*/1012Obj VerboseDiffObject (1013Obj opL,1014Obj opR )1015{1016Obj val;1017val = DoVerboseOperation2Args( DiffOper, opL, opR );1018while (val == 0)1019val = ErrorReturnObj("DIFF: method should have returned a value", 0L, 0L,1020"you can supply one by 'return <value>;'");1021return val;1022}102310241025/****************************************************************************1026**1027*F InstallDiffObject( <verb> ) . . . . . . . . . install difference methods1028*/1029void InstallDiffObject ( Int verb )1030{1031UInt t1; /* type of left operand */1032UInt t2; /* type of right operand */1033ArithMethod2 func; /* difference function */10341035func = ( verb ? VerboseDiffObject : DiffObject );1036for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {1037for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1038DiffFuncs[t1][t2] = func;1039DiffFuncs[t2][t1] = func;1040}1041}1042for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {10431044DiffFuncs[ t2 ][ T_PREC ] = func;1045DiffFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;1046DiffFuncs[ T_PREC ][ t2 ] = func;1047DiffFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;1048}1049}105010511052/****************************************************************************1053**1054*F FuncDIFF_DEFAULT( <self>, <opL>, <opR> ) . . . . . . call 'DiffDefault'1055*/1056Obj DiffDefaultFunc;10571058Obj FuncDIFF_DEFAULT (1059Obj self,1060Obj opL,1061Obj opR )1062{1063return DiffDefault( opL, opR );1064}106510661067/****************************************************************************1068**1069*F FuncDIFF( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . call 'DIFF'1070*/1071Obj FuncDIFF (1072Obj self,1073Obj opL,1074Obj opR )1075{1076return DIFF( opL, opR );1077}107810791080/****************************************************************************1081**10821083*V ProdFuncs[ <typeL> ][ <typeR> ] . . . . . . . . table of product methods1084*/1085ArithMethod2 ProdFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];108610871088/****************************************************************************1089**1090*F ProdObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . call methsel1091*/1092Obj ProdOper;10931094Obj ProdObject (1095Obj opL,1096Obj opR )1097{1098Obj val;1099val = DoOperation2Args( ProdOper, opL, opR );1100while (val == 0)1101val = ErrorReturnObj("PROD: method should have returned a value", 0L, 0L,1102"you can supply one by 'return <value>;'");1103return val;1104}110511061107/****************************************************************************1108**1109*F VerboseProdObject( <opL>, <opR> ) . . . . . . . . . . . . . call methsel1110*/1111Obj VerboseProdObject (1112Obj opL,1113Obj opR )1114{1115Obj val;1116val = DoVerboseOperation2Args( ProdOper, opL, opR );1117while (val == 0)1118val = ErrorReturnObj("PROD: method should have returned a value", 0L, 0L,1119"you can supply one by 'return <value>;'");1120return val;1121}112211231124/****************************************************************************1125**1126*F InstallProdObject( <verb> ) . . . . . . . . . . . install product methods1127*/1128void InstallProdObject ( Int verb )1129{1130UInt t1; /* type of left operand */1131UInt t2; /* type of right operand */1132ArithMethod2 func; /* product function */11331134func = ( verb ? VerboseProdObject : ProdObject );1135for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {1136for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1137ProdFuncs[t1][t2] = func;1138ProdFuncs[t2][t1] = func;1139}1140}1141for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {11421143ProdFuncs[ t2 ][ T_PREC ] = func;1144ProdFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;1145ProdFuncs[ T_PREC ][ t2 ] = func;1146ProdFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;1147}1148}114911501151/****************************************************************************1152**1153*F FuncPROD( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . call 'PROD'1154*/1155Obj FuncPROD (1156Obj self,1157Obj opL,1158Obj opR )1159{1160return PROD( opL, opR );1161}116211631164/****************************************************************************1165**11661167*V QuoFuncs[ <typeL> ][ <typeR> ] . . . . . . . . table of quotient methods1168*/1169ArithMethod2 QuoFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];117011711172/****************************************************************************1173**1174*F QuoDefault( <opL>, <opR> ) . . . . . . . . . . . . call 'INV' and 'PROD'1175*/1176Obj QuoDefault (1177Obj opL,1178Obj opR )1179{1180Obj tmp;1181tmp = INV_MUT( opR );1182return PROD( opL, tmp );1183}118411851186/****************************************************************************1187**1188*F QuoObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . . call methsel1189*/1190Obj QuoOper;11911192Obj QuoObject (1193Obj opL,1194Obj opR )1195{1196Obj val;1197val = DoOperation2Args( QuoOper, opL, opR );1198while (val == 0)1199val = ErrorReturnObj("QUO: method should have returned a value", 0L, 0L,1200"you can supply one by 'return <value>;'");1201return val;1202}120312041205/****************************************************************************1206**1207*F VerboseQuoObject( <opL>, <opR> ) . . . . . . . . . . . . . call methsel1208*/1209Obj VerboseQuoObject (1210Obj opL,1211Obj opR )1212{1213Obj val;1214val = DoVerboseOperation2Args( QuoOper, opL, opR );1215while (val == 0)1216val = ErrorReturnObj("QUO: method should have returned a value", 0L, 0L,1217"you can supply one by 'return <value>;'");1218return val;1219}122012211222/****************************************************************************1223**1224*F InstallQuoObject( <verb> ) . . . . . . . . . . install quotient methods1225*/1226void InstallQuoObject ( Int verb )1227{1228UInt t1; /* type of left operand */1229UInt t2; /* type of right operand */1230ArithMethod2 func; /* quotient function */12311232func = ( verb ? VerboseQuoObject : QuoObject );1233for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {1234for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1235QuoFuncs[t1][t2] = func;1236QuoFuncs[t2][t1] = func;1237}1238}1239for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {12401241QuoFuncs[ t2 ][ T_PREC ] = func;1242QuoFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;1243QuoFuncs[ T_PREC ][ t2 ] = func;1244QuoFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;1245}1246}124712481249/****************************************************************************1250**1251*F FuncQUO_DEFAULT( <self>, <opL>, <opR> ) . . . . . . . . call 'QuoDefault'1252*/1253Obj QuoDefaultFunc;12541255Obj FuncQUO_DEFAULT (1256Obj self,1257Obj opL,1258Obj opR )1259{1260return QuoDefault( opL, opR );1261}126212631264/****************************************************************************1265**1266*F FuncQUO( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . . call 'QUO'1267*/1268Obj FuncQUO (1269Obj self,1270Obj opL,1271Obj opR )1272{1273return QUO( opL, opR );1274}127512761277/****************************************************************************1278**12791280*V LQuoFuncs[ <typeL> ][ <typeR> ] . . . . . table of left quotient methods1281*/1282ArithMethod2 LQuoFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];128312841285/****************************************************************************1286**1287*F LQuoDefault( <opL>, <opR> ) . . . . . . . . . . . . call 'INV' and 'PROD'1288*/1289Obj LQuoDefault (1290Obj opL,1291Obj opR )1292{1293Obj tmp;1294tmp = INV_MUT( opL );1295return PROD( tmp, opR );1296}129712981299/****************************************************************************1300**1301*F LQuoObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . call methsel1302*/1303Obj LQuoOper;13041305Obj LQuoObject (1306Obj opL,1307Obj opR )1308{1309Obj val;1310val = DoOperation2Args( LQuoOper, opL, opR );1311while (val == 0)1312val = ErrorReturnObj("LeftQuotient: method should have returned a value", 0L, 0L,1313"you can supply one by 'return <value>;'");1314return val;1315}131613171318/****************************************************************************1319**1320*F VerboseLQuoObject( <opL>, <opR> ) . . . . . . . . . . . . . call methsel1321*/1322Obj VerboseLQuoObject (1323Obj opL,1324Obj opR )1325{1326Obj val;1327val = DoOperation2Args( LQuoOper, opL, opR );1328while (val == 0)1329val = ErrorReturnObj("LeftQuotient: method should have returned a value", 0L, 0L,1330"you can supply one by 'return <value>;'");1331return val;1332}133313341335/****************************************************************************1336**1337*F InstallLQuoObject( <verb> ) . . . . . . . . install left quotient methods1338*/1339void InstallLQuoObject ( Int verb )1340{1341UInt t1; /* type of left operand */1342UInt t2; /* type of right operand */1343ArithMethod2 func; /* left quotient function */13441345func = ( verb ? VerboseLQuoObject : LQuoObject );1346for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {1347for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1348LQuoFuncs[t1][t2] = func;1349LQuoFuncs[t2][t1] = func;1350}1351}1352for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1353LQuoFuncs[ t2 ][ T_PREC ] = func;1354LQuoFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;1355LQuoFuncs[ T_PREC ][ t2 ] = func;1356LQuoFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;1357}1358}135913601361/****************************************************************************1362**1363*F FuncLQUO_DEFAULT( <self>, <opL>, <opR> ) . . . . . . call 'LQuoDefault'1364*/1365Obj LQuoDefaultFunc;13661367Obj FuncLQUO_DEFAULT (1368Obj self,1369Obj opL,1370Obj opR )1371{1372return LQuoDefault( opL, opR );1373}137413751376/****************************************************************************1377**1378*F FuncLQUO( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . call 'LQUO'1379*/1380Obj FuncLQUO (1381Obj self,1382Obj opL,1383Obj opR )1384{1385return LQUO( opL, opR );1386}138713881389/****************************************************************************1390**13911392*V PowFuncs[ <typeL> ][ <typeR> ] . . . . . . . . . table of power methods1393*/1394ArithMethod2 PowFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];139513961397/****************************************************************************1398**1399*F PowDefault( <opL>, <opR> ) . . . . . . . . . . . call 'LQUO' and 'PROD'1400*/1401Obj PowDefault (1402Obj opL,1403Obj opR )1404{1405Obj tmp;1406tmp = LQUO( opR, opL );1407return PROD( tmp, opR );1408}140914101411/****************************************************************************1412**1413*F PowObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . . call methsel1414*/1415Obj PowOper;14161417Obj PowObject (1418Obj opL,1419Obj opR )1420{1421Obj val;1422val = DoOperation2Args( PowOper, opL, opR );1423while (val == 0)1424val = ErrorReturnObj("POW: method should have returned a value", 0L, 0L,1425"you can supply one by 'return <value>;'");1426return val;1427}142814291430/****************************************************************************1431**1432*F VerbosePowObject( <opL>, <opR> ) . . . . . . . . . . . . . call methsel1433*/1434Obj VerbosePowObject (1435Obj opL,1436Obj opR )1437{14381439Obj val;1440val = DoVerboseOperation2Args( PowOper, opL, opR );1441while (val == 0)1442val = ErrorReturnObj("POW: method should have returned a value", 0L, 0L,1443"you can supply one by 'return <value>;'");1444return val;1445}144614471448/****************************************************************************1449**1450*F InstallPowObject( <verb> ) . . . . . . . . . . install the power methods1451*/1452void InstallPowObject ( Int verb )1453{1454UInt t1; /* type of left operand */1455UInt t2; /* type of right operand */1456ArithMethod2 func; /* power function */14571458func = ( verb ? VerbosePowObject : PowObject );1459for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {1460for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1461PowFuncs[t1][t2] = func;1462PowFuncs[t2][t1] = func;1463}1464}1465for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {14661467PowFuncs[ t2 ][ T_PREC ] = func;1468PowFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;1469PowFuncs[ T_PREC ][ t2 ] = func;1470PowFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;1471}1472}147314741475/****************************************************************************1476**1477*F FuncPOW_DEFAULT( <self>, <opL>, <opR> ) . . . . . . . . call 'PowDefault'1478*/1479Obj PowDefaultFunc;14801481Obj FuncPOW_DEFAULT (1482Obj self,1483Obj opL,1484Obj opR )1485{1486return PowDefault( opL, opR );1487}148814891490/****************************************************************************1491**1492*F FuncPOW( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . . call 'POW'1493*/1494Obj FuncPOW (1495Obj self,1496Obj opL,1497Obj opR )1498{1499return POW( opL, opR );1500}150115021503/****************************************************************************1504**15051506*V CommFuncs[ <typeL> ][ <typeR> ] . . . . . . . table of commutator methods1507*/1508ArithMethod2 CommFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];150915101511/****************************************************************************1512**1513*F CommDefault( <opL>, <opR> ) . . . . . . . . . . . call 'LQUO' and 'PROD'1514*/1515Obj CommDefault (1516Obj opL,1517Obj opR )1518{1519Obj tmp1;1520Obj tmp2;1521tmp1 = PROD( opR, opL );1522tmp2 = PROD( opL, opR );1523return LQUO( tmp1, tmp2 );1524}152515261527/****************************************************************************1528**1529*F CommObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . call methsel1530*/1531Obj CommOper;15321533Obj CommObject (1534Obj opL,1535Obj opR )1536{1537Obj val;1538val = DoOperation2Args( CommOper, opL, opR );1539while (val == 0)1540val = ErrorReturnObj("Comm: method should have returned a value", 0L, 0L,1541"you can supply one by 'return <value>;'");1542return val;1543}154415451546/****************************************************************************1547**1548*F VerboseCommObject( <opL>, <opR> ) . . . . . . . . . . . . . call methsel1549*/1550Obj VerboseCommObject (1551Obj opL,1552Obj opR )1553{1554Obj val;1555val = DoVerboseOperation2Args( CommOper, opL, opR );1556while (val == 0)1557val = ErrorReturnObj("Comm: method should have returned a value", 0L, 0L,1558"you can supply one by 'return <value>;'");1559return val;1560}156115621563/****************************************************************************1564**1565*F InstallCommObject( <verb> ) . . . . . . . . . install commutator methods1566*/1567void InstallCommObject ( Int verb )1568{1569UInt t1; /* type of left operand */1570UInt t2; /* type of right operand */1571ArithMethod2 func; /* commutator function */15721573func = ( verb ? VerboseCommObject : CommObject );1574for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {1575for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1576CommFuncs[t1][t2] = func;1577CommFuncs[t2][t1] = func;1578}1579}1580for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {15811582CommFuncs[ t2 ][ T_PREC ] = func;1583CommFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;1584CommFuncs[ T_PREC ][ t2 ] = func;1585CommFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;1586}1587}158815891590/****************************************************************************1591**1592*F FuncCOMM_DEFAULT( <self>, <opL>, <opR> ) . . . . . . call 'CommDefault'1593*/1594Obj CommDefaultFunc;15951596Obj FuncCOMM_DEFAULT (1597Obj self,1598Obj opL,1599Obj opR )1600{1601return CommDefault( opL, opR );1602}160316041605/****************************************************************************1606**1607*F FuncCOMM( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . call 'COMM'1608*/1609Obj FuncCOMM (1610Obj self,1611Obj opL,1612Obj opR )1613{1614return COMM( opL, opR );1615}161616171618/****************************************************************************1619**16201621*V ModFuncs[ <typeL> ][ <typeR> ] . . . . . . . table of remainder methods1622*/1623ArithMethod2 ModFuncs [LAST_VIRTUAL_TNUM+1][LAST_VIRTUAL_TNUM+1];1624162516261627/****************************************************************************1628**1629*F ModObject( <opL>, <opR> ) . . . . . . . . . . . . . . . . . call methsel1630*/1631Obj ModOper;16321633Obj ModObject (1634Obj opL,1635Obj opR )1636{1637Obj val;1638val = DoOperation2Args( ModOper, opL, opR );1639while (val == 0)1640val = ErrorReturnObj("mod: method should have returned a value", 0L, 0L,1641"you can supply one by 'return <value>;'");1642return val;1643}164416451646/****************************************************************************1647**1648*F VerboseModObject( <opL>, <opR> ) . . . . . . . . . . . . . call methsel1649*/1650Obj VerboseModObject (1651Obj opL,1652Obj opR )1653{1654Obj val;1655val = DoVerboseOperation2Args( ModOper, opL, opR );1656while (val == 0)1657val = ErrorReturnObj("mod: method should have returned a value", 0L, 0L,1658"you can supply one by 'return <value>;'");1659return val;1660}166116621663/****************************************************************************1664**1665*F InstallModObject( <verb> ) . . . . . . . . . . . install the mod methods1666*/1667void InstallModObject ( Int verb )1668{1669UInt t1; /* type of left operand */1670UInt t2; /* type of right operand */1671ArithMethod2 func; /* mod function */16721673func = ( verb ? VerboseModObject : ModObject );1674for ( t1 = FIRST_EXTERNAL_TNUM; t1 <= LAST_EXTERNAL_TNUM; t1++ ) {1675for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1676ModFuncs[t1][t2] = func;1677ModFuncs[t2][t1] = func;1678}1679}1680for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {16811682ModFuncs[ t2 ][ T_PREC ] = func;1683ModFuncs[ t2 ][ T_PREC +IMMUTABLE ] = func;1684ModFuncs[ T_PREC ][ t2 ] = func;1685ModFuncs[ T_PREC +IMMUTABLE ][ t2 ] = func;1686}1687}168816891690/****************************************************************************1691**1692*F FuncMOD( <self>, <opL>, <opR> ) . . . . . . . . . . . . . . . call 'MOD'1693*/1694Obj FuncMOD (1695Obj self,1696Obj opL,1697Obj opR )1698{1699return MOD( opL, opR );1700}170117021703/****************************************************************************1704**17051706*F * * * * * * * * * * * * * initialize package * * * * * * * * * * * * * * *1707*/17081709/****************************************************************************1710**17111712*V GVarAttrs . . . . . . . . . . . . . . . . . list of attributes to export1713*/1714static StructGVarAttr GVarAttrs [] = {171517161717{ 0 }17181719};172017211722/****************************************************************************1723**1724*V GVarOpers . . . . . . . . . . . . . . . . . list of operations to export1725*/1726static StructGVarOper GVarOpers [] = {17271728{ "EQ", 2, "opL, opR", &EqOper,1729FuncEQ, "src/ariths.c:EQ" },17301731{ "LT", 2, "opL, opR", &LtOper,1732FuncLT, "src/ariths.c:LT" },17331734{ "IN", 2, "opL, opR", &InOper,1735FuncIN, "src/ariths.c:IN" },17361737{ "SUM", 2, "opL, opR", &SumOper,1738FuncSUM, "src/ariths.c:SUM" },17391740{ "DIFF", 2, "opL, opR", &DiffOper,1741FuncDIFF, "src/ariths.c:DIFF" },17421743{ "PROD", 2, "opL, opR", &ProdOper,1744FuncPROD, "src/ariths.c:PROD" },17451746{ "QUO", 2, "opL, opR", &QuoOper,1747FuncQUO, "src/ariths.c:QUO" },17481749{ "LQUO", 2, "opL, opR", &LQuoOper,1750FuncLQUO, "src/ariths.c:LQUO" },17511752{ "POW", 2, "opL, opR", &PowOper,1753FuncPOW, "src/ariths.c:POW" },17541755{ "COMM", 2, "opL, opR", &CommOper,1756FuncCOMM, "src/ariths.c:COMM" },17571758{ "MOD", 2, "opL, opR", &ModOper,1759FuncMOD, "src/ariths.c:MOD" },17601761{ "ZERO", 1, "op", &ZEROOp,1762FuncZERO, "src/ariths.c:ZERO" },17631764{ "ZERO_MUT", 1, "op", &ZeroOp,1765FuncZERO_MUT, "src/ariths.c:ZERO_MUT" },17661767{ "AINV", 1, "op", &AInvOp,1768FuncAINV, "src/ariths.c:AINV" },17691770{ "AINV_MUT", 1, "op", &AdditiveInverseOp,1771FuncAINV_MUT, "src/ariths.c:AINV_MUT" },17721773{ "ONE", 1, "op", &OneOp,1774FuncONE, "src/ariths.c:ONE" },17751776{ "ONE_MUT", 1, "op", &OneMutOp,1777FuncONE_MUT, "src/ariths.c:ONE_MUT" },17781779{ "INV", 1, "op", &InvOp,1780FuncINV, "src/ariths.c:INV" },17811782{ "INV_MUT", 1, "op", &InvMutOp,1783FuncINV_MUT, "src/ariths.c:INV_MUT" },17841785{ 0 }17861787};178817891790/****************************************************************************1791**1792*V GVarFuncs . . . . . . . . . . . . . . . . . . list of functions to export1793*/1794static StructGVarFunc GVarFuncs [] = {17951796{ "COMM_DEFAULT", 2, "opL, opR",1797FuncCOMM_DEFAULT, "src/ariths.c:COMM_DEFAULT" },17981799{ "POW_DEFAULT", 2, "opL, opR",1800FuncPOW_DEFAULT, "src/ariths.c:POW_DEFAULT" },18011802{ "LQUO_DEFAULT", 2, "opL, opR",1803FuncLQUO_DEFAULT, "src/ariths.c:LQUO_DEFAULT" },18041805{ "QUO_DEFAULT", 2, "opL, opR",1806FuncQUO_DEFAULT, "src/ariths.c:QUO_DEFAULT" },18071808{ "DIFF_DEFAULT", 2, "opL, opR",1809FuncDIFF_DEFAULT, "src/ariths.c:DIFF_DEFAULT" },181018111812{ 0 }18131814};181518161817/****************************************************************************1818**18191820*F InitKernel( <module> ) . . . . . . . . initialise kernel data structures1821*/1822static Int InitKernel (1823StructInitInfo * module )1824{1825UInt t1; /* type of left operand */1826UInt t2; /* type of right operand */18271828/* init filters and functions */1829InitHdlrAttrsFromTable( GVarAttrs );1830InitHdlrOpersFromTable( GVarOpers );1831InitHdlrFuncsFromTable( GVarFuncs );18321833/* make and install the 'ZERO' arithmetic operation */1834for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1835ZeroFuncs[t1] = ZeroObject;1836}1837InstallZeroObject(0);18381839/* make and install the 'ZERO_MUT' arithmetic operation */1840for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1841ZeroMutFuncs[t1] = ZeroMutObject;1842}1843InstallZeroObject(0);18441845/* make and install the 'AINV' arithmetic operation */1846for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1847AInvFuncs[t1] = AInvObject;1848}18491850InstallAinvMutObject(0);1851/* make and install the 'AINV_MUT' arithmetic operation */1852for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1853AInvMutFuncs[t1] = AInvMutObject;1854}1855InstallAinvObject(0);18561857/* make and install the 'ONE' arithmetic operation */1858for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1859OneFuncs[t1] = OneObject;1860}1861InstallOneObject(0);18621863/* make and install the 'ONE' arithmetic operation */1864for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1865OneMutFuncs[t1] = OneMutObject;1866}1867InstallOneMutObject(0);18681869/* make and install the 'INV' arithmetic operation */1870for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1871InvFuncs[t1] = InvObject;1872}1873InstallInvObject(0);18741875/* make and install the 'INV' arithmetic operation */1876for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1877InvMutFuncs[t1] = InvMutObject;1878}1879InstallInvMutObject(0);18801881/* make and install the 'EQ' comparison operation */1882for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1883for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1884EqFuncs[t1][t2] = EqNot;1885}1886}1887InstallEqObject(0);18881889/* make and install the 'LT' comparison operation */1890for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1891for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1892LtFuncs[t1][t2] = LtObject;1893}1894}1895InstallLtObject(0);18961897/* make and install the 'IN' comparison operation */1898for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1899for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1900InFuncs[t1][t2] = InUndefined;1901}1902}1903InstallInObject(0);19041905/* make and install the 'SUM' arithmetic operation */1906for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1907for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1908SumFuncs[t1][t2] = SumObject;1909}1910}1911InstallSumObject(0);19121913/* make and install the 'DIFF' arithmetic operation */1914for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1915for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1916DiffFuncs[t1][t2] = DiffDefault;1917}1918}1919InstallDiffObject(0);19201921/* make and install the 'PROD' arithmetic operation */1922for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1923for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1924ProdFuncs[t1][t2] = ProdObject;1925}1926}1927InstallProdObject(0);19281929/* make and install the 'QUO' arithmetic operation */1930for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1931for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1932QuoFuncs[t1][t2] = QuoDefault;1933}1934}1935InstallQuoObject(0);19361937/* make and install the 'LQUO' arithmetic operation */1938for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1939for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1940LQuoFuncs[t1][t2] = LQuoDefault;1941}1942}1943InstallLQuoObject(0);19441945/* make and install the 'POW' arithmetic operation */1946for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1947for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1948PowFuncs[t1][t2] = PowObject;1949}1950}1951InstallPowObject(0);19521953/* make and install the 'COMM' arithmetic operation */1954for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1955for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1956CommFuncs[t1][t2] = CommDefault;1957}1958}1959InstallCommObject(0);19601961/* make and install the 'MOD' arithmetic operation */1962for ( t1 = FIRST_REAL_TNUM; t1 <= LAST_VIRTUAL_TNUM; t1++ ) {1963for ( t2 = FIRST_REAL_TNUM; t2 <= LAST_VIRTUAL_TNUM; t2++ ) {1964ModFuncs[t1][t2] = ModObject;1965}1966}1967InstallModObject(0);196819691970/* return success */1971return 0;1972}197319741975/****************************************************************************1976**1977*F InitLibrary( <module> ) . . . . . . . initialise library data structures1978*/1979static Int InitLibrary (1980StructInitInfo * module )1981{1982/* init filters and functions */1983InitGVarAttrsFromTable( GVarAttrs );1984InitGVarOpersFromTable( GVarOpers );1985InitGVarFuncsFromTable( GVarFuncs );19861987/* return success */1988return 0;1989}199019911992/****************************************************************************1993**1994*F InitInfoAriths() . . . . . . . . . . . . . . . . table of init functions1995*/1996static StructInitInfo module = {1997MODULE_BUILTIN, /* type */1998"ariths", /* name */19990, /* revision entry of c file */20000, /* revision entry of h file */20010, /* version */20020, /* crc */2003InitKernel, /* initKernel */2004InitLibrary, /* initLibrary */20050, /* checkInit */20060, /* preSave */20070, /* postSave */20080 /* postRestore */2009};20102011StructInitInfo * InitInfoAriths ( void )2012{2013return &module;2014}201520162017/****************************************************************************2018**20192020*E ariths.c . . . . . . . . . . . . . . . . . . . . . . . . . . . ends here2021*/2022202320242025202620272028202920302031203220332034