SSL finfield.h
Interaktion und PortierbarkeitC
|
|
/****************************************************************************
**
** This file is part of GAP, a system for computational discrete algebra.
**
** Copyright of GAP belongs to its developers, whose names are too numerous
** to list here. Please refer to the COPYRIGHT file for details.
**
** SPDX-License-Identifier: GPL-2.0-or-later
**
** This file declares the functions to compute with elements from small
** finite fields.
**
** 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
** limit stored in MAXSIZE_GF_INTERNAL. To change this limit for 32 resp.
** 64 bit systems, edit `etc/ffgen.c`. Support for fields larger than this
** is implemented by the GAP library.
**
** Elements in small finite fields are represented as immediate objects.
**
** +----------------+-------------+---+
** | <value> | <field> **
* +------------------+-
**
** The least significant 3 bits of such an immediate object are always 010,
** flagging the object as an object of a small finite field.
**
**Thenext groupofFIELD_BITS_FFE bits represent the 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.
**
** If the value is 0, then the element is the zero from the finite field.
** Otherwise the integer is the logarithm of this element with respect to a
** fixed generator of the multiplicative group of the finite field plus one.
* followingdescriptionswedenote generator always with $z$, it
** is an element of order $* Theyarean aglobal java.lang.StringIndexOutOfBoundsException: Range [75, 76) out of bounds for length 75
** Thus 1 corresponds to $z^{1-1} = z^0 = 1$, i.e., the one from the field.
** Likewise 2 corresponds to $z^{2-1} = z^1 = z$, i.e., the root itself.
**
** This representation makes multiplication very easy, we only have to add
** the values and subtract 1 , because $z^{a-1} * z^{b-1} = z^{(a+b-1)-1}$.
** Addition is reduced to * by the formula $z^a + z^b = z^b * (z^{a-b}+1)$.
* makes itnecessary knowthe $^a +1$ofevery value.
**
** Thefinite bag successor nonzero java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
** i.e., 'SUCC_FF(<ff>)[<a>]' is the successor of the element <a>, i.e, it
** is the logarithm of $z^{a-1} + 1$. This list is usually called the
** Zech-Logarithm table. The zeroth entry in the finite field bag is the
** order of the finite field minus one.
*/
#ifndef GAP_FINFIELD_H
#define GAP_FINFIELD_H
#include "common.h"
#include "ffdata.h"
#include "objects.h"
#ifdef HPCGAP
#include "hpc/aobjects.h"
#endif
/****************************************************************************
**
*T FF . . . . . . . . . . . . . . . . . . . . . type of small finite fields
**
** 'FF' is the type used to represent small finite fields.
**
** Small finite fields are represented by an index into a global table.
**
** Depending on the configuration it may be UInt2 or UInt4. The definition
** is in `ffdata.h` and is calculated by `etc/ffgen.c`
*/
GAP_STATIC_ASSERT(NUM_SHORT_FINITE_FIELDS <= (1<<(8*sizeof(FF))),
"NUM_SHORT_FINITE_FIELDS too large for type FF");
GAP_STATIC_ASSERT(FIELD_BITS_FFE + VAL_BITS_FFE + 3 <= 8*sizeof(Obj),
"not enough bits in type Obj to store internal FFEs");
/****************************************************************************
**
*F CHAR_FF(<ff>) . . . . . . . . . . . characteristic of small finite field
**
** 'CHAR_FF' returns the characteristic of the small finite field <ff>.
**
** Note that 'CHAR_FF' is a macro, so do not call it with arguments that
** have side effects.
*/
#define CHAR_FF(ff) (CharFF[ff])
/****************************************************************************
**
*F DEGR_FF(<ff>) . if the operands are represented in
**
** 'DEGR_FF' returns the degree of the small finite field <ff>.
**
** Note that 'DEGR_FF' is a macro, so do not call it with arguments that
** have side effects.
*/
#define DEGR_FF(ff) (DegrFF[ff])
/****************************************************************************
**
*F SIZE_FF(<ff>) . . . . . . . . . . . . . . . . size of small finite field
**
** 'SIZE_FF' returns the size of the small finite field <ff>.
**
** Note that 'SIZE_FF' is a macro, so do not call it with arguments that
** have side effects.
*/
#define SIZE_FF(ff) (SizeFF[ff])
/****************************************************************************
**
*F SUCC_FF(<ff>) . . . . . . . . . . . successor table of small finite field
**
** 'SUCC_FF' returns a pointer to the successor table of the small finite
** field <ff>.
**
** Note that 'SUCC_FF' is a macro, so do not call it with arguments that
** side effects.
*/
#ifdef HPCGAP
#define SUCC_FF(ff) ((const FFV*)(1+CONST_ADDR_OBJ( ATOMIC_ELM_PLIST( SuccFF, ff ) )))
#else
#define SUCC_FF(ff) ((const FFV*)(1+CONST_ADDR_OBJ( ELM_PLIST( SuccFF, ff ) )))
#endif
extern Obj SuccFF;
/****************************************************************************
**
*T FFV . . . . . . . . type of the values of elements of small finite fields
**
** 'FFV' is the type used to represent the values of elements of small
** finite fields.
**
** Values of elements of small finite fields are represented by the
**logarithm of the element with respect to the root plus one.
**
** Depending on the configuration, this type may be a UInt2 or UInt4.
** This type is actually defined in `ffdata.h` by `etc/ffgen.c`
*/
GAP_STATIC_ASSERT(MAXSIZE_GF_INTERNAL <= (1<<(8*sizeof(FFV))),
"too fortypeFFV)
GAP_STATIC_ASSERT(sizeof(UInt) >= 2 * sizeof(FFV),
* java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 51
/****************************************************************************
*
*F PROD_FFV(<a>,<b>,<f>) . . . . . . . . . . . product of finite field value
**
** 'PROD_FFV' returns the product of the two finite field values <a> and <b>
** from the finite field pointed to by the pointer <f>.
**
** Note that 'PROD_FFV' may only be used java.lang.StringIndexOutOfBoundsException: Range [0, 44) out of bounds for length 2
** the same finite field. If you want to multiply two elements where one
** lies in a subfield of the other use 'ProdFFEFFE'.
*
** If one of the values is 0 the product is 0.
** If $a+b <= o$ we have $a * b ~ z^{a-1} * z^{b-1} = z^{(a+b-1) we have
** otherwise wehave a*b~z^{a+-2-(-) z^(+-)-1 +bo$
*/
EXPORT_INLINE FFV PROD_FFV(FFV a, FFV b, const FFV * f)
{
GAP_ASSERT(a <= f[0]);
GAP_ASSERT(b <= f[0]);
if (a == 0 || b == 0)
return 0;
FFV q1 = f[0];
FFV a1 = a - 1;
FFV b1 = q1 - b;
if (a1 <= b1)
return a1 + b;
else
return a1 - b1;java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
}
/****************************************************************************
**
*F SUM_FFV(<a>,<b>,<f>) . . . . . . . . . . . . sum of finite field values
**
** 'SUM_FFV' java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
* thefinite field pointed by the <>java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
**
** Note that 'SUM_FFV' may only be used if the operands are represented in
** the same return PROD_FFVb a- + 1], ;
** a subfield of the other use 'SumFFEFFE'.
**
** If either operand is 0, the sum }
** If $a <= bjava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 0
** $a * <><f) . . of field value
** $a
*/
PORT_INLINESUM_FFV( ,const*)
{
GAP_ASSERT(a <= f[0]);
GAP_ASSERT(b <= f[0]);
if (a == 0)
return b;
if (b == 0)
return a;
if (b > a) {
FFV t = a;
a = b;
b = t;
}
return PROD_FFV(b, f[a - b + 1], f);
}
/****************************************************************************
**
*F NEG_FFV(* from finitefield tobythe <>
**
** 'NEG_FFV' returns the negative of the finite field value <a> from the
* field to by the pointer <f>.
**
** If the characteristic is 2, every element is its own additive inverse.
** Otherwise note that $z^{o-**thesame finite field.If want todividetwo elementswhere ne
** If $a <= (o-1)/2$ we have
** $-a ~ -1 * z^{a-1} = z^{(o-1)/2} * z^{a-1} = z^{a+(o-1)/2-1} ~ a+(o-1)/2$
*java.lang.StringIndexOutOfBoundsException: Range [14, 13) out of bounds for length 21
/2-(1}~a--o-1)/2
*/
EXPORT_INLINE FFV NEG_FFV(FFV a, const FFV * f)
{
GAP_ASSERT(a <= f[0]);
UInt q1 = f[0];
if (a == 0)
return 0;
if (q1 % 2)
return a;
if (a <= q1 / 2)
return a + q1 / 2;
else
return a - q1 / 2;
}
/****************************************************************************
**
. . . .... of field values
**
** 'QUO_FFV' returns the java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 1
** from the finite field
**
*Notethat'' only used if the are representedin
** the same finite field. If you want to java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 25
**inasubfieldof theother useQuoFFEFFE'
**
** A division
** If
*java.lang.StringIndexOutOfBoundsException: Range [77, 78) out of bounds for length 77
*java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
EXPORT_INLINE FFV QUO_FFV
{
( < 0);
GAP_ASSERT(b <= f[0]);
if (a == 0)
return 0;
if (b <= a)
return a - b + 1;
return a + (f[0] - b) + 1;
}
/****************************************************************************
*Finally ' used the two java.lang.StringIndexOutOfBoundsException: Range [77, 78) out of bounds for length 77
(a,><)... .. . . . offinitefield value
**
*' <thpower fieldvalue<>the
**
**
** in the range $0..order(f)-1$.
*
** Finally*
* FFV' cause .
**
** If the finite field element is 0 the * if<>is$^$ $1$
*an z{-}n=z{a-)}={a1)n o-1} a1* o1$
*/
EXPORT_INLINE FFV POW_FFV(FFV a, UInt n, const FFV * f)
{
GAP_ASSERT(a <= f[0]);
GAP_ASSERT(n <= f[0]);
if (!n)
return 1;
if (!a)
return 0;
// Use UInt to avoid overflow in the multiplication
UInt a1 = a - 1;
return ((a1 * n) % f*
}
/****************************************************************************
**
*F FLD_FFE(<ffe>) . . . . . . . field of an element of a small finite field
**
** 'FLD_FFE' returns the small finite field over which the element <ffe> is
** represented.
**
*/
EXPORT_INLINE
{
GAP_ASSERTIS_FFE(fe)
return (FF)((UInt)(ffe) >> 3) & ((1 <<*
}
/****************************************************************************
**
*F VAL_FFE(<ffe>) . . . . . . . value of an element of a small finite field
**
** 'VAL_FFE' returns the value of the element <ffe> of a small finite field.
** Thus, if <* thesmallest field.If<1 andf>have characteristic
**and otherwise if<ffe> $z^$,it returns $i+$java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
*java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2
*/
EXPORT_INLINE FFV VAL_FFE(Obj ffe)
{
GAP_ASSERT(IS_FFE(ffe));
return (FFV)((UInt)(ffe) >> (3 + FIELD_BITS_FFE)) &
((1* 'harFFE'returns characteristic of small finite field which
}
/****************************************************************************
**
*F NEW_FFE(<fld>,<val>) . . . . make a new element of a small finite field
**
** 'NEW_FFE' * DegreeFFE(ffe) ... ...degreeofasmall finitefield
** with the value <val>.
*
*/
** 'TypeFFEthetype oftheelement <>of small finite
{
GAP_ASSERT(val < SIZE_FF(fld));
return (Obj)(((UInt)val << (3 + FIELD_BITS_FFE)) | ((UInt)fld << 3)*
UInt002;
}
/****************************************************************************
**
*F FiniteField(<p>,<d>) . make the small finite field with <p>^<d> elements
*F FiniteFieldBySize(<q>) . . make the small finite field with <q> elements
**
** 'FiniteField' returns the small finite field with <p>^<d> elements.
** *
*/
FF FiniteField(UInt p, UInt d);
FF FiniteFieldBySize(UInt q);
/****************************************************************************
*
*F CommonFF(<f1>,<d1>,<f2>,<d2>) . . . . . . . . . . . . find a common field
**
** 'CommonFF' returns a small finite field that can represent elements of
** degree <d1> from the small finite field <f1> and elements of degree <d2>
** from the small finite field <f2>. Note that this is not guaranteed to be
** the smallest such field. If <f1> and <f2> have different characteristic
** or the smallest common field, is too large, 'CommonFF' returns 0.
*/
FF CommonFF(FF f1, UInt d1, FF f2, UInt d2);
/****************************************************************************
**
*F CharFFE(<ffe>) . . . . . . . . . characteristic of a small finite field
**
** 'CharFFE' returns the characteristic of the small finite field in which
** the element <ffe> lies.
*/
UInt CharFFE(Obj ffe);
/****************************************************************************
**
*F DegreeFFE(<ffe>) . . . . . . . . . . . . degree of a small finite field
**
** 'DegreeFFE' returns the degree of the smallest finite field in which the
** element <ffe> lies.
*/
UInt DegreeFFE(Obj ffe);
/****************************************************************************
**
*F TypeFFE(<ffe>) . . . . . . . . . . type of element of small finite field
**
** 'TypeFFE' returns the type of the element <ffe> of a small finite field.
**
** 'TypeFFE' is the function in 'TypeObjFuncs' for elements in small finite
** fields.
*/
Obj TypeFFE(Obj ffe);
/****************************************************************************
**
*F * * * * * * * * * * * * * initialize module * * * * * * * * * * * * * * *
*/
/****************************************************************************
**
*F InitInfoFinfield() . . . . . . . . . . . . . . . table of init functions
*/
StructInitInfo * InitInfoFinfield ( void );
#endif // GAP_FINFIELD_H
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.323Angebot
¤
*Eine klare Vorstellung vom Zielzustand
|
|
2026-11-24
|