Changeset 8710ff0 in git for factory/gfops.h
- Timestamp:
- Sep 29, 2012, 1:49:36 PM (12 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/gfops.h
rd30a399 r8710ff0 38 38 } 39 39 40 inline bool gf_iszero ( long a ) 41 { 42 return gf_q == a; 43 } 44 40 45 inline bool gf_isone ( int a ) 46 { 47 return 0 == a; 48 } 49 50 inline bool gf_isone ( long a ) 41 51 { 42 52 return 0 == a; … … 54 64 return gf_q; 55 65 int c = 0; 66 while ( i > 1 ) { 67 c = gf_table[c]; 68 i--; 69 } 70 return c; 71 } 72 73 inline 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; 56 82 while ( i > 1 ) { 57 83 c = gf_table[c]; … … 138 164 } 139 165 166 inline 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 140 177 inline int gf_div ( int a, int b ) 141 178 { … … 184 221 return gf_mul( a, gf_power( a, n-1 ) ); 185 222 } 223 224 inline 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 } 186 233 //}}} 187 234 … … 191 238 /*BEGINPUBLIC*/ 192 239 240 long gf_gf2ff ( long a ); 193 241 int gf_gf2ff ( int a ); 194 242 243 bool gf_isff ( long a ); 195 244 bool gf_isff ( int a ); 196 245
Note: See TracChangeset
for help on using the changeset viewer.