source:git/kernel/rmodulo2m.h@f92547

spielwiese
Last change on this file since f92547 was f92547, checked in by Oliver Wienand <wienand@…>, 18 years ago
*oliver kspoly.cc: --> kscheckcoef * modified for zero divisors --> ksCreateShortSPoly * create correct short s poly for rings * in case of rings, also calculate coeff kstd2.cc: --> bba * use different enterpairs method in case of rings * small changes (replaced p_ISet by p_NSet) kutil.cc, kutil.h: --> new enterpairs derivate, also downstreams are new derivates of functions --> function to create extended s poly for rings --> nComp fct, will be nGreater later, maybe --> stub for chainCritRing polys.cc: --> chainCrit correct for rings, but not optimized numbers.cc, rmodulo2m.cc, rmodulo2m.h: --> gcd, ncd for zero divisor (att, not really a gcd or ncd) --> IntDiv (att, just takes a machine div, allows to divide by zero div) --> Greater (att, compares zero divisor exponent) git-svn-id: file:///usr/local/Singular/svn/trunk@9026 2c84dea3-7e68-4137-9b89-c4e89433aadc
• Property mode set to `100644`
File size: 1.9 KB
Line
1//#ifndef RMODULO2M_H
2//#define RMODULO2M_H
3/****************************************
4*  Computer Algebra System SINGULAR     *
5****************************************/
6/* \$Id: rmodulo2m.h,v 1.2 2006-03-20 20:33:57 wienand Exp \$ */
7/*
8* ABSTRACT: numbers modulo 2^m
9*/
10#include "structs.h"
11
12extern int nr2mExp;
13extern long nr2mModul;
14
15BOOLEAN nr2mGreaterZero (number k);
16number  nr2mMult        (number a, number b);
17number  nr2mInit        (int i);
18int     nr2mInt         (number &n);
19number  nr2mAdd         (number a, number b);
20number  nr2mSub         (number a, number b);
21void    nr2mPower       (number a, int i, number * result);
22BOOLEAN nr2mIsZero      (number a);
23BOOLEAN nr2mIsOne       (number a);
24BOOLEAN nr2mIsMOne      (number a);
25number  nr2mDiv         (number a, number b);
26number   nr2mIntDiv      (number a,number b);
27number  nr2mNeg         (number c);
28number  nr2mInvers      (number c);
29BOOLEAN nr2mGreater     (number a, number b);
30BOOLEAN nr2mEqual       (number a, number b);
31number   nr2mLcm         (number a,number b, ring r);
32number   nr2mGcd         (number a,number b,ring r);
33nMapFunc nr2mSetMap(ring src, ring dst);
34void    nr2mWrite       (number &a);
35char *  nr2mRead        (char *s, number *a);
36char *  nr2mName        (number n);
37#ifdef LDEBUG
38// BOOLEAN nr2mDBTest      (number a, char *f, int l);
39#endif
40void    nr2mSetExp(int c, ring r);
41void    nr2mInitExp(int c, ring r);
42
43
44static inline number nr2mMultM(number a, number b)
45{
46  return (number)
47    ((((unsigned long) a)*((unsigned long) b)) % ((unsigned long) nr2mModul));
48}
49
50static inline number nr2mAddM(number a, number b)
51{
52  long r = (long)a + (long)b;
53  return (number) (r >= nr2mModul ? r - nr2mModul : r);
54}
55
56static inline number nr2mSubM(number a, number b)
57{
58  return (number)((long)a<(long)b ?
59                       nr2mModul-(long)b+(long)a : (long)a-(long)b);
60}
61
62#define nr2mNegM(A) (number)(nr2mModul-(long)(A))
63#define nr2mEqualM(A,B)  ((A)==(B))
Note: See TracBrowser for help on using the repository browser.