From 63fc6647308bb1eaa63570189bc640c10ba2d4d8 Mon Sep 17 00:00:00 2001 From: Steve Linton Date: Sat, 17 Nov 2018 17:54:06 +0000 Subject: [PATCH] clang-format and further minor adjustments --- etc/ffgen.c | 1 - src/finfield.c | 54 +++++++++++++++++++++++++------------------------- src/finfield.h | 25 +++-------------------- 3 files changed, 30 insertions(+), 50 deletions(-) diff --git a/etc/ffgen.c b/etc/ffgen.c index e59600942d..46df593257 100644 --- a/etc/ffgen.c +++ b/etc/ffgen.c @@ -191,4 +191,3 @@ int main(int argc, char * argv[]) } return 0; } - diff --git a/src/finfield.c b/src/finfield.c index 7b94b22537..9f3358bffa 100644 --- a/src/finfield.c +++ b/src/finfield.c @@ -40,17 +40,17 @@ */ Obj SuccFF; -Obj TypeFF; -Obj TypeFF0; +static Obj TypeFF; +static Obj TypeFF0; /**************************************************************************** ** *V TYPE_FFE . . . . . kernel copy of GAP function TYPE_FFE *V TYPE_FFE0 . . . . . kernel copy of GAP function TYPE_FFE0 -*V TYPE_KERNEL_OBJECT .local copy of GAP variable TYPE_KERNEL_OBJECT used to type -** successor bags -*V PrimitiveRootMod . .local copy of GAP function PrimitiveRootMod, used +*V TYPE_KERNEL_OBJECT .local copy of GAP variable TYPE_KERNEL_OBJECT used to +** type successor bags +*V PrimitiveRootMod . .local copy of GAP function PrimitiveRootMod, used ** when initializing new fields. ** ** These GAP functions are called to compute types of finite field elemnents @@ -58,7 +58,7 @@ Obj TypeFF0; static Obj TYPE_FFE; static Obj TYPE_FFE0; -static Obj TYPE_KERNEL_OBJECT; +static Obj TYPE_KERNEL_OBJECT; static Obj PrimitiveRootMod; /**************************************************************************** @@ -68,17 +68,17 @@ static Obj PrimitiveRootMod; ** 'PolsFF' is a list of Conway polynomials for finite fields. The even ** entries are the proper prime powers, odd entries are the corresponding ** Conway polynomials. -** +** ** This data is now held in a separate file, and includes all fields of ** orders up to 2^32, although not all of that information is used. */ -#include "finfield_conway.h" +#include "finfield_conway.h" /**************************************************************************** ** *F LookupPrimePower ( q ) . . . . . .search for a prime power in tables - ** + ** ** searches the tables of prime powers from ffdata.c for q, returns the index ** of q in SizeFF if it is present and 0 if not (the 0 position of SizeFF is ** unused). @@ -86,8 +86,8 @@ static Obj PrimitiveRootMod; static FF LookupPrimePower(UInt q) { - UInt l,n; - FF ff; + UInt l, n; + FF ff; UInt e; /* search through the finite field table */ l = 1; @@ -116,9 +116,10 @@ static FF LookupPrimePower(UInt q) /**************************************************************************** ** *F FiniteFieldBySize( ) . .make the small finite field with elements -*F FiniteField(

,) . . .make the small finite field with

^ elements +*F FiniteField(

,) . . .make the small finite field with

^ +** elements ** -** The work is done in the Lookup function above, and in FiniteFieldBySize +** The work is done in the Lookup function above, and in FiniteFieldBySize ** where the successor tables are computed. */ @@ -401,13 +402,12 @@ Obj FuncDEGREE_FFE_DEFAULT ( ** 'TypeFFE' is the function in 'TypeObjFuncs' for elements in small finite ** fields. */ -Obj TypeFFE ( - Obj ffe ) +Obj TypeFFE(Obj ffe) { - if (VAL_FFE(ffe) == 0) - return TYPE_FF0( FLD_FFE( ffe ) ); - else - return TYPE_FF( FLD_FFE( ffe ) ); + if (VAL_FFE(ffe) == 0) + return ELM_PLIST(TypeFF0, FLD_FFE(ffe)); + else + return ELM_PLIST(TypeFF, FLD_FFE(ffe)); } @@ -1508,10 +1508,10 @@ Obj FuncZ ( FF ff; /* the finite field */ /* check the argument */ - if ( (IS_INTOBJ(q) && (INT_INTOBJ(q) > MAXSIZE_GF_INTERNAL)) || - (TNUM_OBJ(q) == T_INTPOS)) - return CALL_1ARGS(ZOp, q); - + if ((IS_INTOBJ(q) && (INT_INTOBJ(q) > MAXSIZE_GF_INTERNAL)) || + (TNUM_OBJ(q) == T_INTPOS)) + return CALL_1ARGS(ZOp, q); + if ( !IS_INTOBJ(q) || INT_INTOBJ(q)<=1 ) { q = ErrorReturnObj( "Z: must be a positive prime power (not a %s)", @@ -1521,14 +1521,14 @@ Obj FuncZ ( } ff = FiniteFieldBySize(INT_INTOBJ(q)); - + if (!ff) { ErrorMayQuit("Z: must be a positive prime power (not a %s)", (Int)TNAM_OBJ(q), 0L); } /* make the root */ - return NEW_FFE( ff, (q == INTOBJ_INT(2)) ? 1 : 2 ); + return NEW_FFE(ff, (q == INTOBJ_INT(2)) ? 1 : 2); } Obj FuncZ2(Obj self, Obj p, Obj d) @@ -1553,7 +1553,7 @@ Obj FuncZ2(Obj self, Obj p, Obj d) ErrorMayQuit("Z:

must be a prime", 0, 0); /* make the root */ - return NEW_FFE( ff, (q == 2) ? 1 : 2 ); + return NEW_FFE(ff, (q == 2) ? 1 : 2); } } } @@ -1619,7 +1619,7 @@ static Int InitKernel ( ImportFuncFromLibrary( "TYPE_FFE", &TYPE_FFE ); ImportFuncFromLibrary( "TYPE_FFE0", &TYPE_FFE0 ); ImportFuncFromLibrary( "ZOp", &ZOp ); - InitFopyGVar( "PrimitiveRootMod", &PrimitiveRootMod ); + InitFopyGVar("PrimitiveRootMod", &PrimitiveRootMod); TypeObjFuncs[ T_FFE ] = TypeFFE; /* create the fields and integer conversion bags */ diff --git a/src/finfield.h b/src/finfield.h index 5347f02617..4826950333 100644 --- a/src/finfield.h +++ b/src/finfield.h @@ -13,7 +13,7 @@ ** ** Finite fields are an important domain in computational group theory ** because the classical matrix groups are defined over those finite fields. -** The GAP kernel supports elements of finite fields up to some fixed size +** The GAP kernel supports elements of finite fields up to some fixed size ** limit, typically 2^16 on 32 bit systems and 2^24 on 64 bit systems. ** To change the limits, edit etc/ffgen.c. To access the current limits use ** MAXSIZE_GF_INTERNAL. Support for larger fields is implemented by the @@ -28,8 +28,8 @@ ** The least significant 3 bits of such an immediate object are always 010, ** flagging the object as an object of a small finite field. ** -** The next group of FIELD_BITS_FFE bits represent the small finite field -** where the element lies. They are simply an index into a global table of +** The next group of FIELD_BITS_FFE bits represent the small finite field +** where the element lies. They are simply an index into a global table of ** small finite fields, which is constructed at build time. ** ** The most significant VAL_BITS_FFE bits represent the value of the element. @@ -74,7 +74,6 @@ */ - /**************************************************************************** ** *F CHAR_FF() . . . . . . . . . . . characteristic of small finite field @@ -125,24 +124,6 @@ extern Obj SuccFF; - -/**************************************************************************** -** -*F TYPE_FF() . . . . . . . . . . . . . . . type of a small finite field -** -** 'TYPE_FF' returns the type of elements of the small finite field . -** 'TYPE_FF0' returns the type of the zero of -** -** Note that 'TYPE_FF' and TypeFF0 are macros, so do not call them -** with arguments that have side effects. -*/ -#define TYPE_FF(ff) (ELM_PLIST( TypeFF, ff )) -#define TYPE_FF0(ff) (ELM_PLIST( TypeFF0, ff )) - -extern Obj TypeFF; -extern Obj TypeFF0; - - /**************************************************************************** ** *T FFV . . . . . . . . type of the values of elements of small finite fields