source: git/factory/ffops.h @ f0596e

spielwiese
Last change on this file since f0596e was 067233, checked in by Jens Schmidt <schmidt@…>, 27 years ago
* ffops.h: #include fix git-svn-id: file:///usr/local/Singular/svn/trunk@672 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/* emacs edit mode for this file is -*- C++ -*- */
2/* $Id: ffops.h,v 1.4 1997-09-09 07:06:29 schmidt Exp $ */
3
4#ifndef INCL_FFOPS_H
5#define INCL_FFOPS_H
6
7#include <config.h>
8
9#include "cf_globals.h"
10
11extern int ff_prime;
12extern int ff_halfprime;
13extern short * ff_invtab;
14extern bool ff_big;
15
16int ff_newinv ( const int );
17int ff_biginv ( const int );
18void ff_setprime ( const int );
19
20inline int ff_norm ( const int a )
21{
22    int n = a % ff_prime;
23    if ( n < 0 )
24        return n + ff_prime;
25    else
26        return n;
27}
28
29inline int ff_symmetric( const int a )
30{
31    if ( cf_glob_switches.isOn( SW_SYMMETRIC_FF ) )
32        return ( a > ff_halfprime ) ? a - ff_prime : a;
33    else
34        return a;
35}
36
37inline int ff_longnorm ( const long a )
38{
39    int n = (int)(a % (long)ff_prime);
40    if ( n < 0 )
41        return n + ff_prime;
42    else
43        return n;
44}
45
46inline int ff_bignorm ( const long long int a )
47{
48    int n = (int)(a % (long long int)ff_prime);
49    if ( n < 0 )
50        return n + ff_prime;
51    else
52        return n;
53}
54
55inline int ff_add ( const int a, const int b )
56{
57    return ff_norm( a + b );
58}
59
60inline int ff_sub ( const int a, const int b )
61{
62    return ff_norm( a - b );
63}
64
65inline int ff_neg ( const int a )
66{
67    return ff_norm( -a );
68}
69
70inline int ff_mul ( const int a, const int b )
71{
72    if ( ff_big )
73        return ff_bignorm( (long long int)a * (long long int)b );
74    else
75        return ff_longnorm ( (long)a * (long)b );
76}
77
78inline int ff_inv ( const int a )
79{
80    if ( ff_big )
81        return ff_biginv( a );
82    else {
83        register b;
84        if ( (b = (int)(ff_invtab[a])) )
85            return b;
86        else
87            return ff_newinv( a );
88    }
89
90}
91
92inline int ff_div ( const int a, const int b )
93{
94    return ff_mul( a, ff_inv( b ) );
95}
96
97#endif /* ! INCL_FFOPS_H */
Note: See TracBrowser for help on using the repository browser.