Skip to content

Commit

Permalink
clang-format and further minor adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
stevelinton committed Nov 18, 2018
1 parent 08c9f9c commit 63fc664
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 50 deletions.
1 change: 0 additions & 1 deletion etc/ffgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,3 @@ int main(int argc, char * argv[])
}
return 0;
}

54 changes: 27 additions & 27 deletions src/finfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@
*/

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
*/

static Obj TYPE_FFE;
static Obj TYPE_FFE0;
static Obj TYPE_KERNEL_OBJECT;
static Obj TYPE_KERNEL_OBJECT;
static Obj PrimitiveRootMod;

/****************************************************************************
Expand All @@ -68,26 +68,26 @@ 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).
*/

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;
Expand Down Expand Up @@ -116,9 +116,10 @@ static FF LookupPrimePower(UInt q)
/****************************************************************************
**
*F FiniteFieldBySize( <q>) . .make the small finite field with <q> elements
*F FiniteField(<p>,<d>) . . .make the small finite field with <p>^<d> elements
*F FiniteField(<p>,<d>) . . .make the small finite field with <p>^<d>
** 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.
*/

Expand Down Expand Up @@ -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));
}


Expand Down Expand Up @@ -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: <q> must be a positive prime power (not a %s)",
Expand All @@ -1521,14 +1521,14 @@ Obj FuncZ (
}

ff = FiniteFieldBySize(INT_INTOBJ(q));

if (!ff) {
ErrorMayQuit("Z: <q> 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)
Expand All @@ -1553,7 +1553,7 @@ Obj FuncZ2(Obj self, Obj p, Obj d)
ErrorMayQuit("Z: <p> 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);
}
}
}
Expand Down Expand Up @@ -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 */
Expand Down
25 changes: 3 additions & 22 deletions src/finfield.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -74,7 +74,6 @@
*/



/****************************************************************************
**
*F CHAR_FF(<ff>) . . . . . . . . . . . characteristic of small finite field
Expand Down Expand Up @@ -125,24 +124,6 @@

extern Obj SuccFF;


/****************************************************************************
**
*F TYPE_FF(<ff>) . . . . . . . . . . . . . . . type of a small finite field
**
** 'TYPE_FF' returns the type of elements of the small finite field <ff>.
** 'TYPE_FF0' returns the type of the zero of <ff>
**
** 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
Expand Down

0 comments on commit 63fc664

Please sign in to comment.