spielwiese
Last change
on this file since 2dd068 was
2dd068,
checked in by Rüdiger Stobbe <stobbe@…>, 28 years ago
|
Initial revision
git-svn-id: file:///usr/local/Singular/svn/trunk@6 2c84dea3-7e68-4137-9b89-c4e89433aadc
|
-
Property mode set to
100644
|
File size:
796 bytes
|
Rev | Line | |
---|
[2dd068] | 1 | // emacs edit mode for this file is -*- C++ -*- |
---|
| 2 | // $Id: ffops.cc,v 1.0 1996-05-17 10:59:46 stobbe Exp $ |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | $Log: not supported by cvs2svn $ |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include "assert.h" |
---|
| 9 | #include "cf_defs.h" |
---|
| 10 | #include "ffops.h" |
---|
| 11 | |
---|
| 12 | int ff_prime = 31991; |
---|
| 13 | int ff_halfprime = 31991 / 2; |
---|
| 14 | short * ff_invtab = new short [31991]; |
---|
| 15 | |
---|
| 16 | void ff_setprime ( const int p ) |
---|
| 17 | { |
---|
| 18 | ff_prime = p; |
---|
| 19 | ff_halfprime = ff_prime / 2; |
---|
| 20 | for ( int i = 0; i < ff_prime; i++ ) ff_invtab[i] = 0; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | int ff_newinv ( const int a ) |
---|
| 24 | { |
---|
| 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; |
---|
| 34 | } |
---|
| 35 | } |
---|
| 36 | if ( r0 == 0 ) |
---|
| 37 | return (ff_invtab[a] = -q1); |
---|
| 38 | else |
---|
| 39 | return (ff_invtab[a] = q0); |
---|
| 40 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.