My Project  debian-1:4.1.1-p2+ds-4build3
p_Numbers.h
Go to the documentation of this file.
1 /****************************************
2 * Computer Algebra System SINGULAR *
3 ****************************************/
4 /***************************************************************
5  * File: p_Numbers.h
6  * Purpose: macros/inline functions for number operations
7  * Author: obachman (Olaf Bachmann)
8  * Created: 8/00
9  *******************************************************************/
10 #ifndef P_NUMBERS_H
11 #define P_NUMBERS_H
12 
13 #include "misc/auxiliary.h"
14 #include "coeffs/coeffs.h"
15 #include "coeffs/numbers.h"
16 #include "polys/monomials/ring.h"
17 
18 static FORCE_INLINE number n_Copy_FieldGeneral(number n, const coeffs r)
19 { return n_Copy(n,r); }
20 
21 static FORCE_INLINE void n_Delete_FieldGeneral(number* p, const coeffs r)
22 { n_Delete(p,r); }
23 
24 static FORCE_INLINE number n_Mult_FieldGeneral(number n1, number n2, const coeffs r)
25 { return n_Mult(n1, n2, r); }
26 
27 static FORCE_INLINE number n_Add_FieldGeneral(number n1, number n2, const coeffs r)
28 { return n_Add(n1, n2, r); }
29 
31 { return n_IsZero(n, r); }
32 
33 static FORCE_INLINE BOOLEAN n_Equal_FieldGeneral(number n1, number n2, const coeffs r)
34 { return n_Equal(n1, n2, r); }
35 
36 static FORCE_INLINE number n_Neg_FieldGeneral(number n, const coeffs r)
37 { return n_InpNeg(n, r); }
38 
39 static FORCE_INLINE number n_Sub_FieldGeneral(number n1, number n2, const coeffs r)
40 { return n_Sub(n1, n2, r); }
41 
42 static FORCE_INLINE void n_InpMult_FieldGeneral(number &n1, number n2, const coeffs r)
43 { n_InpMult(n1, n2, r); }
44 
45 static FORCE_INLINE void n_InpAdd_FieldGeneral(number &n1, number n2, const coeffs r)
46 { n_InpAdd(n1, n2, r); }
47 
48 #ifdef HAVE_RINGS
49 #define n_Copy_RingGeneral(n, r) n_Copy_FieldGeneral(n, r)
50 #define n_Delete_RingGeneral(n, r) n_Delete_FieldGeneral(n, r)
51 #define n_Mult_RingGeneral(n1, n2, r) n_Mult_FieldGeneral(n1, n2, r)
52 #define n_Add_RingGeneral(n1, n2, r) n_Add_FieldGeneral(n1, n2, r)
53 #define n_IsZero_RingGeneral(n, r) n_IsZero_FieldGeneral(n, r)
54 #define n_Equal_RingGeneral(n1, n2, r) n_Equal_FieldGeneral(n1, n2, r)
55 #define n_Neg_RingGeneral(n, r) n_Neg_FieldGeneral(n, r)
56 #define n_Sub_RingGeneral(n1, n2, r) n_Sub_FieldGeneral(n1, n2, r)
57 #define n_InpMult_RingGeneral(n1, n2, r) n_InpMult_FieldGeneral(n1, n2, r)
58 
59 static FORCE_INLINE void n_InpAdd_RingGeneral(number &n1, number n2, const coeffs r)
60 { assume(nCoeff_is_Ring(r)); n_InpAdd(n1, n2, r); }
61 #endif
62 
63 #include "coeffs/modulop.h"
64 
65 #define n_Copy_FieldZp(n, r) n
66 #define n_Delete_FieldZp(n, r) do {} while (0)
67 
68 static FORCE_INLINE number n_Mult_FieldZp(number n1, number n2, const coeffs r)
69 { STATISTIC(n_Mult); return npMultM(n1, n2, r); }
70 
71 #ifdef HAVE_NUMSTATS
72 static FORCE_INLINE number n_Add_FieldZp(number n1, number n2, const coeffs r)
73 { STATISTIC(n_Add); const number sum = npAddM(n1, n2, r);
74  // avoid double counting
75  if( npIsZeroM(sum,r) ) STATISTIC(n_CancelOut);
76  return sum;
77 }
78 #else
79 static FORCE_INLINE number n_Add_FieldZp(number n1, number n2, const coeffs r)
80 { return npAddM(n1, n2, r); }
81 #endif
82 
83 #ifdef HAVE_NUMSTATS
84 static FORCE_INLINE number n_Sub_FieldZp(number n1, number n2, const coeffs r)
85 { STATISTIC(n_Sub); const number d = npSubM(n1, n2, r);
86  // avoid double counting
87  if( npIsZeroM(d,r) ) STATISTIC(n_CancelOut);
88  return d;
89 }
90 #else
91 static FORCE_INLINE number n_Sub_FieldZp(number n1, number n2, const coeffs r)
92 { return npSubM(n1, n2, r); }
93 #endif
94 
95 static FORCE_INLINE BOOLEAN n_IsZero_FieldZp(number n, const coeffs r)
96 { STATISTIC(n_IsZero); return npIsZeroM(n, r); }
97 
98 static FORCE_INLINE BOOLEAN n_Equal_FieldZp(number n1, number n2, const coeffs r)
99 { STATISTIC(n_Equal); return npEqualM(n1, n2, r); }
100 
101 static FORCE_INLINE number n_Neg_FieldZp(number n, const coeffs r)
102 { STATISTIC(n_InpNeg); return npNegM(n, r); }
103 
104 static FORCE_INLINE void n_InpMult_FieldZp(number &n1, number n2, const coeffs r)
105 { STATISTIC(n_InpMult); npInpMultM(n1, n2, r); }
106 
107 #ifdef HAVE_NUMSTATS
108 static FORCE_INLINE void n_InpAdd_FieldZp(number &n1, number n2, const coeffs r)
109 {
110  STATISTIC(n_InpAdd); n1=npAddM(n1, n2, r);
111  // avoid double counting
112  if( npIsZeroM(n1,r) ) STATISTIC(n_CancelOut);
113 }
114 #else
115 static FORCE_INLINE void n_InpAdd_FieldZp(number &n1, number n2, const coeffs r)
116 { n1=npAddM(n1, n2, r); }
117 #endif
118 
119 #define DO_LFORCE_INLINE
120 #include "coeffs/longrat.cc" // for inlining... TODO: fix this Uglyness?!!!
121 
122 static FORCE_INLINE number n_Copy_FieldQ(number n, const coeffs r)
123 { STATISTIC(n_Copy); return nlCopy(n, r); }
124 
125 static FORCE_INLINE void n_Delete_FieldQ(number* n, const coeffs r)
126 { STATISTIC(n_Delete); nlDelete(n,r); }
127 
128 static FORCE_INLINE number n_Mult_FieldQ(number n1, number n2, const coeffs r)
129 { STATISTIC(n_Mult); return nlMult(n1,n2, r); }
130 
131 #ifdef HAVE_NUMSTATS
132 static FORCE_INLINE number n_Add_FieldQ(number n1, number n2, const coeffs r)
133 { STATISTIC(n_Add); const number sum = nlAdd(n1, n2, r);
134  // avoid double counting
135  if( nlIsZero(sum,r) ) STATISTIC(n_CancelOut);
136  return sum;
137 }
138 #else
139 static FORCE_INLINE number n_Add_FieldQ(number n1, number n2, const coeffs r)
140 { return nlAdd(n1, n2, r); }
141 #endif
142 
143 #ifdef HAVE_NUMSTATS
144 static FORCE_INLINE number n_Sub_FieldQ(number n1, number n2, const coeffs r)
145 { STATISTIC(n_Sub); const number d = nlSub(n1, n2, r);
146  // avoid double counting
147  if( nlIsZero(d,r) ) STATISTIC(n_CancelOut);
148  return d;
149 }
150 #else
151 static FORCE_INLINE number n_Sub_FieldQ(number n1, number n2, const coeffs r)
152 { return nlSub(n1, n2, r); }
153 #endif
154 
155 static FORCE_INLINE BOOLEAN n_IsZero_FieldQ(number n, const coeffs r)
156 { STATISTIC(n_IsZero); return nlIsZero(n, r); }
157 
158 static FORCE_INLINE BOOLEAN n_Equal_FieldQ(number n1, number n2, const coeffs r)
159 { STATISTIC(n_Equal); return nlEqual(n1, n2, r); }
160 
161 static FORCE_INLINE number n_Neg_FieldQ(number n, const coeffs r)
162 { STATISTIC(n_InpNeg); return nlNeg(n, r); }
163 
164 static FORCE_INLINE void n_InpMult_FieldQ(number &n1, number n2, const coeffs r)
165 { STATISTIC(n_InpMult); nlInpMult(n1, n2, r); }
166 
167 #ifdef HAVE_NUMSTATS
168 static FORCE_INLINE void n_InpAdd_FieldQ(number &n1, number n2, const coeffs r)
169 { STATISTIC(n_InpAdd); assume(nCoeff_is_Q(r)); nlInpAdd(n1, n2, r);
170  // avoid double counting
171  if( nlIsZero(n1,r) ) STATISTIC(n_CancelOut);
172 }
173 #else
174 static FORCE_INLINE void n_InpAdd_FieldQ(number &n1, number n2, const coeffs r)
175 { nlInpAdd(n1, n2, r); }
176 #endif
177 
178 #endif
n_Mult_FieldGeneral
static FORCE_INLINE number n_Mult_FieldGeneral(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:24
n_Sub_FieldGeneral
static FORCE_INLINE number n_Sub_FieldGeneral(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:39
n_InpMult_FieldZp
static FORCE_INLINE void n_InpMult_FieldZp(number &n1, number n2, const coeffs r)
Definition: p_Numbers.h:104
nlIsZero
LINLINE BOOLEAN nlIsZero(number za, const coeffs r)
Definition: longrat.cc:2462
nlInpMult
LINLINE void nlInpMult(number &a, number b, const coeffs r)
Definition: longrat.cc:2614
longrat.cc
npEqualM
#define npEqualM(A, B, r)
Definition: modulop.h:187
npMultM
static number npMultM(number a, number b, const coeffs r)
Definition: modulop.h:63
n_InpMult
static FORCE_INLINE void n_InpMult(number &a, number b, const coeffs r)
multiplication of 'a' and 'b'; replacement of 'a' by the product a*b
Definition: coeffs.h:642
n_Delete_FieldGeneral
static FORCE_INLINE void n_Delete_FieldGeneral(number *p, const coeffs r)
Definition: p_Numbers.h:21
n_Neg_FieldZp
static FORCE_INLINE number n_Neg_FieldZp(number n, const coeffs r)
Definition: p_Numbers.h:101
nlCopy
LINLINE number nlCopy(number a, const coeffs r)
Definition: longrat.cc:2482
n_Neg_FieldQ
static FORCE_INLINE number n_Neg_FieldQ(number n, const coeffs r)
Definition: p_Numbers.h:161
n_InpAdd_RingGeneral
static FORCE_INLINE void n_InpAdd_RingGeneral(number &n1, number n2, const coeffs r)
Definition: p_Numbers.h:59
n_Equal_FieldZp
static FORCE_INLINE BOOLEAN n_Equal_FieldZp(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:98
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
n_IsZero_FieldQ
static FORCE_INLINE BOOLEAN n_IsZero_FieldQ(number n, const coeffs r)
Definition: p_Numbers.h:155
n_Add_FieldQ
static FORCE_INLINE number n_Add_FieldQ(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:139
auxiliary.h
n_IsZero
static FORCE_INLINE BOOLEAN n_IsZero(number n, const coeffs r)
TRUE iff 'n' represents the zero element.
Definition: coeffs.h:465
n_Sub_FieldZp
static FORCE_INLINE number n_Sub_FieldZp(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:91
nlInpAdd
LINLINE void nlInpAdd(number &a, number b, const coeffs r)
Definition: longrat.cc:2548
n_Mult_FieldZp
static FORCE_INLINE number n_Mult_FieldZp(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:68
nlSub
LINLINE number nlSub(number la, number li, const coeffs r)
Definition: longrat.cc:2596
nCoeff_is_Q
static FORCE_INLINE BOOLEAN nCoeff_is_Q(const coeffs r)
Definition: coeffs.h:837
nlEqual
LINLINE BOOLEAN nlEqual(number a, number b, const coeffs r)
Definition: longrat.cc:2426
n_Copy_FieldQ
static FORCE_INLINE number n_Copy_FieldQ(number n, const coeffs r)
Definition: p_Numbers.h:122
n_Add
static FORCE_INLINE number n_Add(number a, number b, const coeffs r)
return the sum of 'a' and 'b', i.e., a+b
Definition: coeffs.h:657
n_InpAdd
static FORCE_INLINE void n_InpAdd(number &a, number b, const coeffs r)
addition of 'a' and 'b'; replacement of 'a' by the sum a+b
Definition: coeffs.h:647
n_Add_FieldGeneral
static FORCE_INLINE number n_Add_FieldGeneral(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:27
npAddM
static number npAddM(number a, number b, const coeffs r)
Definition: modulop.h:116
npSubM
static number npSubM(number a, number b, const coeffs r)
Definition: modulop.h:126
BOOLEAN
int BOOLEAN
Definition: auxiliary.h:85
npNegM
static number npNegM(number a, const coeffs r)
Definition: modulop.h:166
n_InpAdd_FieldQ
static FORCE_INLINE void n_InpAdd_FieldQ(number &n1, number n2, const coeffs r)
Definition: p_Numbers.h:174
nCoeff_is_Ring
static FORCE_INLINE BOOLEAN nCoeff_is_Ring(const coeffs r)
Definition: coeffs.h:759
n_Add_FieldZp
static FORCE_INLINE number n_Add_FieldZp(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:79
coeffs
n_Mult_FieldQ
static FORCE_INLINE number n_Mult_FieldQ(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:128
n_InpMult_FieldQ
static FORCE_INLINE void n_InpMult_FieldQ(number &n1, number n2, const coeffs r)
Definition: p_Numbers.h:164
n_Mult
static FORCE_INLINE number n_Mult(number a, number b, const coeffs r)
return the product of 'a' and 'b', i.e., a*b
Definition: coeffs.h:637
n_InpNeg
static FORCE_INLINE number n_InpNeg(number n, const coeffs r)
in-place negation of n MUST BE USED: n = n_InpNeg(n) (no copy is returned)
Definition: coeffs.h:558
n_InpAdd_FieldGeneral
static FORCE_INLINE void n_InpAdd_FieldGeneral(number &n1, number n2, const coeffs r)
Definition: p_Numbers.h:45
n_Sub
static FORCE_INLINE number n_Sub(number a, number b, const coeffs r)
return the difference of 'a' and 'b', i.e., a-b
Definition: coeffs.h:670
STATISTIC
#define STATISTIC(f)
Definition: numstats.h:16
n_IsZero_FieldGeneral
static FORCE_INLINE BOOLEAN n_IsZero_FieldGeneral(number n, const coeffs r)
Definition: p_Numbers.h:30
n_Equal_FieldGeneral
static FORCE_INLINE BOOLEAN n_Equal_FieldGeneral(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:33
n_Copy_FieldGeneral
static FORCE_INLINE number n_Copy_FieldGeneral(number n, const coeffs r)
Definition: p_Numbers.h:18
ring.h
n_Sub_FieldQ
static FORCE_INLINE number n_Sub_FieldQ(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:151
nlAdd
LINLINE number nlAdd(number la, number li, const coeffs r)
Definition: longrat.cc:2530
n_Neg_FieldGeneral
static FORCE_INLINE number n_Neg_FieldGeneral(number n, const coeffs r)
Definition: p_Numbers.h:36
n_InpAdd_FieldZp
static FORCE_INLINE void n_InpAdd_FieldZp(number &n1, number n2, const coeffs r)
Definition: p_Numbers.h:115
n_Copy
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of 'n'
Definition: coeffs.h:452
assume
#define assume(x)
Definition: mod2.h:390
n_IsZero_FieldZp
static FORCE_INLINE BOOLEAN n_IsZero_FieldZp(number n, const coeffs r)
Definition: p_Numbers.h:95
nlMult
LINLINE number nlMult(number a, number b, const coeffs r)
Definition: longrat.cc:2566
n_Equal
static FORCE_INLINE BOOLEAN n_Equal(number a, number b, const coeffs r)
TRUE iff 'a' and 'b' represent the same number; they may have different representations.
Definition: coeffs.h:461
p
int p
Definition: cfModGcd.cc:4019
nlNeg
LINLINE number nlNeg(number za, const coeffs r)
Definition: longrat.cc:2511
n_Delete_FieldQ
static FORCE_INLINE void n_Delete_FieldQ(number *n, const coeffs r)
Definition: p_Numbers.h:125
npInpMultM
static void npInpMultM(number &a, number b, const coeffs r)
Definition: modulop.h:78
npIsZeroM
static BOOLEAN npIsZeroM(number a, const coeffs)
Definition: modulop.h:171
n_InpMult_FieldGeneral
static FORCE_INLINE void n_InpMult_FieldGeneral(number &n1, number n2, const coeffs r)
Definition: p_Numbers.h:42
nlDelete
LINLINE void nlDelete(number *a, const coeffs r)
Definition: longrat.cc:2495
FORCE_INLINE
#define FORCE_INLINE
Definition: auxiliary.h:343
numbers.h
modulop.h
n_Equal_FieldQ
static FORCE_INLINE BOOLEAN n_Equal_FieldQ(number n1, number n2, const coeffs r)
Definition: p_Numbers.h:158
coeffs.h