#include <math.h>
#include <givaro/givinteger.h>
#include <givaro/givintnumtheo.h>
#include <givaro/givpower.h>
#include <givaro/givpoly1padic.h>
Namespaces |
namespace | Givaro |
| Arithmetic on GF(p^k), with p a prime number less than 2^15.
|
Defines |
#define | _GIVARO_GFQ_ADD(c, a, b, mun, plun) |
#define | _GIVARO_GFQ_NEG(res, a, mo, mun) |
#define | _GIVARO_GFQ_SUB(c, a, b, mo, mun, plun) |
#define | _GIVARO_GFQ_AUTOSUB(c, b, mo, mun, plun) |
#define | _GIVARO_GFQ_MUL(res, a, b, mun) { if ( ((a)==0) || ((b)==0) ) { (res) =0; } else { (res) = (((res) = (a)+(b) )>(TT)(mun))?(res)-(mun):(res); } } |
#define | _GIVARO_GFQ_INV(res, a, mun) { (res) = (mun)-(a); (res)=(res)?(res):(mun); } |
#define | _GIVARO_GFQ_DIV(res, a, b, mun) |
#define | _GIVARO_GFQ_SQ(res, a, mun) |
#define | _GIVARO_GFQ_SQADD(c, a, b, mun, plun) |
#define | _GIVARO_GFQ_MULADD(c, a1, a2, b, mun, plun) |
#define | _GIVARO_GFQ_MULSUB(c, a1, a2, b, mo, mun, plun) |
Define Documentation
#define _GIVARO_GFQ_ADD |
( |
|
c, |
|
|
|
a, |
|
|
|
b, |
|
|
|
mun, |
|
|
|
plun |
|
) |
| |
Value:{ if ((b)==0) (c)=(a); else if ((a)==0) (c)=(b); else { \
(c) = (a)-(b); \
(c) = ((c)>0)?(c):(c)+ (mun); \
(c) = (plun)[(UT)(c)]; \
if (c) { \
(c) = (c)+(b); \
(c) = ((c)>0)?(c):(c)+(mun); \
} } }
#define _GIVARO_GFQ_NEG |
( |
|
res, |
|
|
|
a, |
|
|
|
mo, |
|
|
|
mun |
|
) |
| |
Value:{ if ( (a)==0 ) (res)=0; else\
{ (res) = (a) - (mo) ; (res) = ((res)>0)?(res):(res)+(mun); } }
#define _GIVARO_GFQ_SUB |
( |
|
c, |
|
|
|
a, |
|
|
|
b, |
|
|
|
mo, |
|
|
|
mun, |
|
|
|
plun |
|
) |
| |
Value:{ if ((a)==0) {_GIVARO_GFQ_NEG(c,b,mo,mun);} else if ((b)==0) (c)=(a); else { \
(c) = (b)-(a)-(mo); \
(c) = ((c)>0)?(c):(c)+(mun); \
(c) = ((c)>0)?(c):(c)+ (mun); \
(c) = (plun)[(UT)(c)]; \
if (c) { \
(c) = (c)+(a); \
(c) = ((c)>0)?(c):(c)+(mun); \
} } }
#define _GIVARO_GFQ_AUTOSUB |
( |
|
c, |
|
|
|
b, |
|
|
|
mo, |
|
|
|
mun, |
|
|
|
plun |
|
) |
| |
Value:{ if ((c)==0) {_GIVARO_GFQ_NEG(c,b,mo,mun);} else if ((b)!=0) { \
(c) = (c)-(b)-(mo); \
(c) = ((c)>0)?(c):(c)+(mun); \
(c) = ((c)>0)?(c):(c)+ (mun); \
(c) = (plun)[(UT)(c)]; \
if (c) { \
(c) = (c)+(b); \
(c) = ((c)>0)?(c)-(mo):(c)+(mo); \
(c) = ((c)>0)?(c):(c)+(mun); \
} } }
#define _GIVARO_GFQ_MUL |
( |
|
res, |
|
|
|
a, |
|
|
|
b, |
|
|
|
mun |
|
) |
| { if ( ((a)==0) || ((b)==0) ) { (res) =0; } else { (res) = (((res) = (a)+(b) )>(TT)(mun))?(res)-(mun):(res); } } |
#define _GIVARO_GFQ_INV |
( |
|
res, |
|
|
|
a, |
|
|
|
mun |
|
) |
| { (res) = (mun)-(a); (res)=(res)?(res):(mun); } |
#define _GIVARO_GFQ_DIV |
( |
|
res, |
|
|
|
a, |
|
|
|
b, |
|
|
|
mun |
|
) |
| |
Value:{ \
if ( (a)==0 ) { (res)=0; } else { (res) = (((res)=(a)-(b))>0)?(res):(res)+(mun); } }
#define _GIVARO_GFQ_SQ |
( |
|
res, |
|
|
|
a, |
|
|
|
mun |
|
) |
| |
Value:{ if ( (a)==0) (res) = 0; else \
{ (res) = ( (a) << 1) - (mun); \
(res) = ((res)>0)?(res):(res)+ (mun); } }
#define _GIVARO_GFQ_SQADD |
( |
|
c, |
|
|
|
a, |
|
|
|
b, |
|
|
|
mun, |
|
|
|
plun |
|
) |
| |
Value:{ \
if ((a)==0) { (c)=(b); \
} else if ((b)==0) { \
(c) = (( (c)=((a) << 1) - (mun) )>0)?(c):(c) + (mun); \
} else { \
(c) = (( (c) = ((a) << 1)-(b)-(mun) )<0)?(c)+(mun):(c); \
if ( (c) = (plun)[(UT)(((c)>0)?(c):(c)+(mun))] ) { \
(c) = (( (c) = (c)+(b) )>0)?(c):(c)+(mun); } \
}\
}
#define _GIVARO_GFQ_MULADD |
( |
|
c, |
|
|
|
a1, |
|
|
|
a2, |
|
|
|
b, |
|
|
|
mun, |
|
|
|
plun |
|
) |
| |
Value:{ \
if (((a1)==0) || ((a2)==0)) { (c)=(b); \
} else if ((b)==0) { \
(c) = (( (c)=(a1)+(a2) - (mun) )>0)?(c):(c) + (mun); \
} else { \
(c) = (( (c) = (a1)+(a2)-(b)-(mun) )<0)?(c)+(mun):(c); \
if (( (c) = (plun)[(UT)( ((c)>0)?(c):(c)+(mun) )]) ) { \
(c) = (( (c) = (c)+(b) )>0)?(c):(c)+(mun); }\
}\
}
#define _GIVARO_GFQ_MULSUB |
( |
|
c, |
|
|
|
a1, |
|
|
|
a2, |
|
|
|
b, |
|
|
|
mo, |
|
|
|
mun, |
|
|
|
plun |
|
) |
| |
Value:{ \
if (((a1)==0) || ((a2)==0)) { (c)=(b); \
} else if ((b)==0) { \
(c) = (( (c)=(a1)+(a2) - (mo) -(mun) )>0)?(c):(c) + (mun); \
(c) = (c)>0?(c):(c) + (mun); \
} else { \
(c) = (( (c) = (a1)+(a2)-(b)-(mun) - (mo) )<0)?(c)+(mun):(c); \
(c) = (c)<0?(c)+(mun):(c); \
if ( (c) = (plun)[(UT)( ((c)>0)?(c):(c)+(mun) )] ) { \
(c) = (( (c) = (c)+(b) )>0)?(c):(c)+(mun); }\
}\
}