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:
1.3 KB
|
Line | |
---|
1 | // emacs edit mode for this file is -*- C++ -*- |
---|
2 | // $Id: ffops.h,v 1.0 1996-05-17 10:59:40 stobbe Exp $ |
---|
3 | |
---|
4 | #ifndef INCL_FFOPS_H |
---|
5 | #define INCL_FFOPS_H |
---|
6 | |
---|
7 | /* |
---|
8 | $Log: not supported by cvs2svn $ |
---|
9 | */ |
---|
10 | |
---|
11 | #include "cf_globals.h" |
---|
12 | #include "cf_switches.h" |
---|
13 | |
---|
14 | extern int ff_prime; |
---|
15 | extern int ff_halfprime; |
---|
16 | extern short * ff_invtab; |
---|
17 | |
---|
18 | int ff_newinv ( const int ); |
---|
19 | void ff_setprime ( const int ); |
---|
20 | |
---|
21 | inline int ff_norm ( const int a ) |
---|
22 | { |
---|
23 | int n = a % ff_prime; |
---|
24 | if ( n < 0 ) |
---|
25 | return n + ff_prime; |
---|
26 | else |
---|
27 | return n; |
---|
28 | } |
---|
29 | |
---|
30 | inline int ff_symmetric( const int a ) |
---|
31 | { |
---|
32 | if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) ) |
---|
33 | return ( a > ff_halfprime ) ? a - ff_prime : a; |
---|
34 | else |
---|
35 | return a; |
---|
36 | } |
---|
37 | |
---|
38 | inline int ff_longnorm ( const long a ) |
---|
39 | { |
---|
40 | int n = (int)(a % (long)ff_prime); |
---|
41 | if ( n < 0 ) |
---|
42 | return n + ff_prime; |
---|
43 | else |
---|
44 | return n; |
---|
45 | } |
---|
46 | |
---|
47 | inline int ff_add ( const int a, const int b ) |
---|
48 | { |
---|
49 | return ff_norm( a + b ); |
---|
50 | } |
---|
51 | |
---|
52 | inline int ff_sub ( const int a, const int b ) |
---|
53 | { |
---|
54 | return ff_norm( a - b ); |
---|
55 | } |
---|
56 | |
---|
57 | inline int ff_neg ( const int a ) |
---|
58 | { |
---|
59 | return ff_norm( -a ); |
---|
60 | } |
---|
61 | |
---|
62 | inline int ff_mul ( const int a, const int b ) |
---|
63 | { |
---|
64 | return ff_longnorm ( (long)a * (long)b ); |
---|
65 | } |
---|
66 | |
---|
67 | inline int ff_inv ( const int a ) |
---|
68 | { |
---|
69 | register b; |
---|
70 | if ( (b = (int)(ff_invtab[a])) ) |
---|
71 | return b; |
---|
72 | else |
---|
73 | return ff_newinv( a ); |
---|
74 | } |
---|
75 | |
---|
76 | inline int ff_div ( const int a, const int b ) |
---|
77 | { |
---|
78 | return ff_mul( a, ff_inv( b ) ); |
---|
79 | } |
---|
80 | |
---|
81 | #endif /* INCL_FFOPS_H */ |
---|
82 | |
---|
83 | |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
Note: See
TracBrowser
for help on using the repository browser.