Changeset 8710ff0 in git for factory/gfops.h


Ignore:
Timestamp:
Sep 29, 2012, 1:49:36 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
63e72b40a6237e50811b0e8745201177d25cb979
Parents:
d30a39922dc390f97b6cd257b2e7c55d483f4159
git-author:
Martin Lee <martinlee84@web.de>2012-09-29 13:49:36+02:00
git-committer:
Martin Lee <martinlee84@web.de>2012-10-19 11:05:30+02:00
Message:
chg: 64bit integers in factory by Adi Popescu
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/gfops.h

    rd30a399 r8710ff0  
    3838}
    3939
     40inline bool gf_iszero ( long a )
     41{
     42    return gf_q == a;
     43}
     44
    4045inline bool gf_isone ( int a )
     46{
     47    return 0 == a;
     48}
     49
     50inline bool gf_isone ( long a )
    4151{
    4252    return 0 == a;
     
    5464        return gf_q;
    5565    int c = 0;
     66    while ( i > 1 ) {
     67        c = gf_table[c];
     68        i--;
     69    }
     70    return c;
     71}
     72
     73inline long gf_int2gf ( long i )
     74{
     75    while ( i < 0 )
     76        i += gf_p;
     77    while ( i >= gf_p )
     78        i -= gf_p;
     79    if ( i == 0 )
     80        return gf_q;
     81    long c = 0;
    5682    while ( i > 1 ) {
    5783        c = gf_table[c];
     
    138164}
    139165
     166inline long gf_mul ( long a, int b )
     167{
     168    if ( a == gf_q || b == gf_q )
     169        return gf_q;
     170    else {
     171        long i = a + b;
     172        if ( i >= gf_q1 ) i -= gf_q1;
     173        return i;
     174    }
     175}
     176
    140177inline int gf_div ( int a, int b )
    141178{
     
    184221        return gf_mul( a, gf_power( a, n-1 ) );
    185222}
     223
     224inline long gf_power ( long a, int n )
     225{
     226    if ( n == 0 )
     227        return 0;
     228    else if ( n == 1 )
     229        return a;
     230    else
     231        return gf_mul( a, gf_power( a, n-1 ) );
     232}
    186233//}}}
    187234
     
    191238/*BEGINPUBLIC*/
    192239
     240long gf_gf2ff ( long a );
    193241int gf_gf2ff ( int a );
    194242
     243bool gf_isff ( long a );
    195244bool gf_isff ( int a );
    196245
Note: See TracChangeset for help on using the changeset viewer.