Changeset 02af91 in git for factory/ffops.h
- Timestamp:
- Jun 18, 1996, 8:57:00 AM (27 years ago)
- Branches:
- (u'spielwiese', 'a719bcf0b8dbc648b128303a49777a094b57592c')
- Children:
- cfa45ec3cccf336939c446d85de2dca6283593b1
- Parents:
- 35930b6cf4435468b76d893cb0f2be0e692720cf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
factory/ffops.h
r35930b r02af91 1 1 // emacs edit mode for this file is -*- C++ -*- 2 // $Id: ffops.h,v 1. 0 1996-05-17 10:59:40 stobbe Exp $2 // $Id: ffops.h,v 1.1 1996-06-18 06:57:00 stobbe Exp $ 3 3 4 4 #ifndef INCL_FFOPS_H … … 7 7 /* 8 8 $Log: not supported by cvs2svn $ 9 Revision 1.0 1996/05/17 10:59:40 stobbe 10 Initial revision 11 9 12 */ 10 13 … … 15 18 extern int ff_halfprime; 16 19 extern short * ff_invtab; 20 extern bool ff_big; 17 21 18 22 int ff_newinv ( const int ); 23 int ff_biginv ( const int ); 19 24 void ff_setprime ( const int ); 20 25 21 26 inline int ff_norm ( const int a ) 22 27 { 23 int n = a % ff_prime;24 if ( n < 0 )25 26 else27 28 int n = a % ff_prime; 29 if ( n < 0 ) 30 return n + ff_prime; 31 else 32 return n; 28 33 } 29 34 … … 38 43 inline int ff_longnorm ( const long a ) 39 44 { 40 int n = (int)(a % (long)ff_prime); 41 if ( n < 0 ) 42 return n + ff_prime; 43 else 44 return n; 45 int n = (int)(a % (long)ff_prime); 46 if ( n < 0 ) 47 return n + ff_prime; 48 else 49 return n; 50 } 51 52 inline int ff_bignorm ( const long long int a ) 53 { 54 int n = (int)(a % (long long int)ff_prime); 55 if ( n < 0 ) 56 return n + ff_prime; 57 else 58 return n; 45 59 } 46 60 47 61 inline int ff_add ( const int a, const int b ) 48 62 { 49 return ff_norm( a + b );63 return ff_norm( a + b ); 50 64 } 51 65 52 66 inline int ff_sub ( const int a, const int b ) 53 67 { 54 return ff_norm( a - b );68 return ff_norm( a - b ); 55 69 } 56 70 57 71 inline int ff_neg ( const int a ) 58 72 { 59 return ff_norm( -a );73 return ff_norm( -a ); 60 74 } 61 75 62 76 inline int ff_mul ( const int a, const int b ) 63 77 { 64 return ff_longnorm ( (long)a * (long)b ); 78 if ( ff_big ) 79 return ff_bignorm( (long long int)a * (long long int)b ); 80 else 81 return ff_longnorm ( (long)a * (long)b ); 65 82 } 66 83 67 84 inline int ff_inv ( const int a ) 68 85 { 69 register b; 70 if ( (b = (int)(ff_invtab[a])) ) 71 return b; 72 else 73 return ff_newinv( a ); 86 if ( ff_big ) 87 return ff_biginv( a ); 88 else { 89 register b; 90 if ( (b = (int)(ff_invtab[a])) ) 91 return b; 92 else 93 return ff_newinv( a ); 94 } 95 74 96 } 75 97 76 98 inline int ff_div ( const int a, const int b ) 77 99 { 78 return ff_mul( a, ff_inv( b ) );100 return ff_mul( a, ff_inv( b ) ); 79 101 } 80 102 81 103 #endif /* INCL_FFOPS_H */ 82 83 84 85 86 87
Note: See TracChangeset
for help on using the changeset viewer.