Changeset 02af91 in git for factory/ffops.cc
 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.cc
r35930b r02af91 1 1 // emacs edit mode for this file is * C++ * 2 // $Id: ffops.cc,v 1. 0 19960517 10:59:46stobbe Exp $2 // $Id: ffops.cc,v 1.1 19960618 06:57:00 stobbe Exp $ 3 3 4 4 /* 5 5 $Log: not supported by cvs2svn $ 6 Revision 1.0 1996/05/17 10:59:46 stobbe 7 Initial revision 8 6 9 */ 7 10 … … 12 15 int ff_prime = 31991; 13 16 int ff_halfprime = 31991 / 2; 17 bool ff_big = false; 14 18 short * ff_invtab = new short [31991]; 15 19 16 20 void ff_setprime ( const int p ) 17 21 { 18 ff_prime = p; 19 ff_halfprime = ff_prime / 2; 20 for ( int i = 0; i < ff_prime; i++ ) ff_invtab[i] = 0; 22 ff_prime = p; 23 ff_halfprime = ff_prime / 2; 24 if ( ! ff_big ) 25 for ( int i = 0; i < ff_prime; i++ ) ff_invtab[i] = 0; 21 26 } 22 27 23 28 int ff_newinv ( const int a ) 24 29 { 25 int u, r0 = a, r1 = ff_prime, q0 = 1, q1 = 0; 26 while ( ( r0 > 0 ) && ( r1 > 0 ) ) { 27 u = r0 / r1; 28 r0 = r0 % r1; 29 q0 = u*q1 + q0; 30 if ( r0 > 0 ) { 31 u = r1 / r0; 32 r1 = r1 % r0; 33 q1 = u*q0 + q1; 30 int u, r0 = a, r1 = ff_prime, q0 = 1, q1 = 0; 31 while ( ( r0 > 0 ) && ( r1 > 0 ) ) { 32 u = r0 / r1; 33 r0 = r0 % r1; 34 q0 = u*q1 + q0; 35 if ( r0 > 0 ) { 36 u = r1 / r0; 37 r1 = r1 % r0; 38 q1 = u*q0 + q1; 39 } 34 40 } 35 } 36 if ( r0 == 0 ) 37 return (ff_invtab[a] = q1); 38 else 39 return (ff_invtab[a] = q0); 41 if ( r0 == 0 ) 42 return (ff_invtab[a] = q1); 43 else 44 return (ff_invtab[a] = q0); 40 45 } 46 47 int ff_biginv ( const int a ) 48 { 49 int u, r0 = a, r1 = ff_prime, q0 = 1, q1 = 0; 50 while ( ( r0 > 0 ) && ( r1 > 0 ) ) { 51 u = r0 / r1; 52 r0 = r0 % r1; 53 q0 = u*q1 + q0; 54 if ( r0 > 0 ) { 55 u = r1 / r0; 56 r1 = r1 % r0; 57 q1 = u*q0 + q1; 58 } 59 } 60 if ( r0 == 0 ) 61 return q1; 62 else 63 return q0; 64 }
Note: See TracChangeset
for help on using the changeset viewer.