My Project
Loading...
Searching...
No Matches
p_MemAdd.h
Go to the documentation of this file.
1/****************************************
2* Computer Algebra System SINGULAR *
3****************************************/
4/***************************************************************
5 * File: p_MemAdd.h
6 * Purpose: macros for memory addition
7 * Author: obachman (Olaf Bachmann)
8 * Created: 8/00
9 *******************************************************************/
10#ifndef P_MEM_ADD_H
11#define P_MEM_ADD_H
12
13/***************************************************************
14 *
15 * MemSum
16 *
17 ***************************************************************/
18
19#define _p_MemSum(i, r, s1, s2) r[i] = s1[i] + s2[i]
20
21#define _p_MemSum_LengthOne(r, s1, s2) _p_MemSum(0, r, s1, s2)
22#define _p_MemSum_LengthTwo(r, s1, s2) do{_p_MemSum_LengthOne(r, s1, s2); _p_MemSum(1, r, s1, s2);} while(0)
23#define _p_MemSum_LengthThree(r, s1, s2) do{_p_MemSum_LengthTwo(r, s1, s2); _p_MemSum(2, r, s1, s2);} while(0)
24#define _p_MemSum_LengthFour(r, s1, s2) do{_p_MemSum_LengthThree(r, s1, s2); _p_MemSum(3, r, s1, s2);} while(0)
25#define _p_MemSum_LengthFive(r, s1, s2) do{_p_MemSum_LengthFour(r, s1, s2); _p_MemSum(4, r, s1, s2);} while(0)
26#define _p_MemSum_LengthSix(r, s1, s2) do{_p_MemSum_LengthFive(r, s1, s2); _p_MemSum(5, r, s1, s2);} while(0)
27#define _p_MemSum_LengthSeven(r, s1, s2) do{_p_MemSum_LengthSix(r, s1, s2); _p_MemSum(6, r, s1, s2);} while(0)
28#define _p_MemSum_LengthEight(r, s1, s2) do{_p_MemSum_LengthSeven(r, s1, s2); _p_MemSum(7, r, s1, s2);} while(0)
29
30#define _p_MemSum_Declare(r, s1, s2) \
31 const unsigned long* _s1 = ((unsigned long*) s1); \
32 const unsigned long* _s2 = ((unsigned long*) s2); \
33 unsigned long* _r = ((unsigned long*) r)
34
35#define p_MemSum_LengthOne(r, s1, s2, length) _p_MemSum_LengthOne(r, s1, s2)
36#define p_MemSum_LengthTwo(r, s1, s2, length) \
37do \
38{ \
39 _p_MemSum_Declare(r,s1,s2); \
40 _p_MemSum_LengthTwo(_r, _s1, _s2); \
41} \
42while (0)
43#define p_MemSum_LengthThree(r, s1, s2, length) \
44do \
45{ \
46 _p_MemSum_Declare(r,s1,s2); \
47 _p_MemSum_LengthThree(_r, _s1, _s2); \
48} \
49while (0)
50#define p_MemSum_LengthFour(r, s1, s2, length) \
51do \
52{ \
53 _p_MemSum_Declare(r,s1,s2); \
54 _p_MemSum_LengthFour(_r, _s1, _s2); \
55} \
56while (0)
57#define p_MemSum_LengthFive(r, s1, s2, length) \
58do \
59{ \
60 _p_MemSum_Declare(r,s1,s2); \
61 _p_MemSum_LengthFive(_r, _s1, _s2); \
62} \
63while (0)
64#define p_MemSum_LengthSix(r, s1, s2, length) \
65do \
66{ \
67 _p_MemSum_Declare(r,s1,s2); \
68 _p_MemSum_LengthSix(_r, _s1, _s2); \
69} \
70while (0)
71#define p_MemSum_LengthSeven(r, s1, s2, length) \
72do \
73{ \
74 _p_MemSum_Declare(r,s1,s2); \
75 _p_MemSum_LengthSeven(_r, _s1, _s2); \
76} \
77while (0)
78#define p_MemSum_LengthEight(r, s1, s2, length) \
79do \
80{ \
81 _p_MemSum_Declare(r,s1,s2); \
82 _p_MemSum_LengthEight(_r, _s1, _s2); \
83} \
84while (0)
85
86#define p_MemSum_LengthGeneral(r, s1, s2, length) \
87do \
88{ \
89 _p_MemSum_Declare(r,s1,s2); \
90 const unsigned long _l = (unsigned long) length; \
91 unsigned long _i = 0; \
92 \
93 do \
94 { \
95 _r[_i] = _s1[_i] + _s2[_i]; \
96 _i++; \
97 } \
98 while (_i != _l); \
99} \
100while (0)
101
102/***************************************************************
103 *
104 * MemAdd
105 *
106 ***************************************************************/
107#define _p_MemAdd(i, r, s) r[i] += s[i]
108
109#define _p_MemAdd_LengthOne(r, s) _p_MemAdd(0, r, s)
110#define _p_MemAdd_LengthTwo(r, s) do{_p_MemAdd_LengthOne(r, s); _p_MemAdd(1, r, s);} while(0)
111#define _p_MemAdd_LengthThree(r, s) do{_p_MemAdd_LengthTwo(r, s); _p_MemAdd(2, r, s);} while(0)
112#define _p_MemAdd_LengthFour(r, s) do{_p_MemAdd_LengthThree(r, s); _p_MemAdd(3, r, s);} while(0)
113#define _p_MemAdd_LengthFive(r, s) do{_p_MemAdd_LengthFour(r, s); _p_MemAdd(4, r, s);} while(0)
114#define _p_MemAdd_LengthSix(r, s) do{_p_MemAdd_LengthFive(r, s); _p_MemAdd(5, r, s);} while(0)
115#define _p_MemAdd_LengthSeven(r, s) do{_p_MemAdd_LengthSix(r, s); _p_MemAdd(6, r, s);} while(0)
116#define _p_MemAdd_LengthEight(r, s) do{_p_MemAdd_LengthSeven(r, s); _p_MemAdd(7, r, s);} while(0)
117
118#define _p_MemAdd_Declare(r, s) \
119 const unsigned long* _s = ((unsigned long*) s); \
120 unsigned long* _r = ((unsigned long*) r)
121
122#define p_MemAdd_LengthOne(r, s, length) _p_MemAdd_LengthOne(r, s)
123#define p_MemAdd_LengthTwo(r, s, length) \
124do \
125{ \
126 _p_MemAdd_Declare(r,s); \
127 _p_MemAdd_LengthTwo(_r, _s); \
128} \
129while (0)
130#define p_MemAdd_LengthThree(r, s, length) \
131do \
132{ \
133 _p_MemAdd_Declare(r,s); \
134 _p_MemAdd_LengthThree(_r, _s); \
135} \
136while (0)
137#define p_MemAdd_LengthFour(r, s, length) \
138do \
139{ \
140 _p_MemAdd_Declare(r,s); \
141 _p_MemAdd_LengthFour(_r, _s); \
142} \
143while (0)
144#define p_MemAdd_LengthFive(r, s, length) \
145do \
146{ \
147 _p_MemAdd_Declare(r,s); \
148 _p_MemAdd_LengthFive(_r, _s); \
149} \
150while (0)
151#define p_MemAdd_LengthSix(r, s, length) \
152do \
153{ \
154 _p_MemAdd_Declare(r,s); \
155 _p_MemAdd_LengthSix(_r, _s); \
156} \
157while (0)
158#define p_MemAdd_LengthSeven(r, s, length) \
159do \
160{ \
161 _p_MemAdd_Declare(r,s); \
162 _p_MemAdd_LengthSeven(_r, _s); \
163} \
164while (0)
165#define p_MemAdd_LengthEight(r, s, length) \
166do \
167{ \
168 _p_MemAdd_Declare(r,s); \
169 _p_MemAdd_LengthEight(_r, _s); \
170} \
171while (0)
172
173#define p_MemAdd_LengthGeneral(r, s, length) \
174do \
175{ \
176 _p_MemAdd_Declare(r,s); \
177 const unsigned long _l = (unsigned long) length; \
178 unsigned long _i = 0; \
179 \
180 do \
181 { \
182 _r[_i] += _s[_i]; \
183 _i++; \
184 } \
185 while (_i != _l); \
186} \
187while (0)
188
189
190/***************************************************************
191 *
192 * MemDiff
193 *
194 ***************************************************************/
195#define _p_MemDiff(i, r, s1, s2) r[i] = s1[i] - s2[i]
196
197#define _p_MemDiff_LengthOne(r, s1, s2) _p_MemDiff(0, r, s1, s2)
198#define _p_MemDiff_LengthTwo(r, s1, s2) do{_p_MemDiff_LengthOne(r, s1, s2); _p_MemDiff(1, r, s1, s2);} while(0)
199#define _p_MemDiff_LengthThree(r, s1, s2) do{_p_MemDiff_LengthTwo(r, s1, s2); _p_MemDiff(2, r, s1, s2);} while(0)
200#define _p_MemDiff_LengthFour(r, s1, s2) do{_p_MemDiff_LengthThree(r, s1, s2); _p_MemDiff(3, r, s1, s2);} while(0)
201#define _p_MemDiff_LengthFive(r, s1, s2) do{_p_MemDiff_LengthFour(r, s1, s2); _p_MemDiff(4, r, s1, s2);} while(0)
202#define _p_MemDiff_LengthSix(r, s1, s2) do{_p_MemDiff_LengthFive(r, s1, s2); _p_MemDiff(5, r, s1, s2);} while(0)
203#define _p_MemDiff_LengthSeven(r, s1, s2) do{_p_MemDiff_LengthSix(r, s1, s2); _p_MemDiff(6, r, s1, s2);} while(0)
204#define _p_MemDiff_LengthEight(r, s1, s2) do{_p_MemDiff_LengthSeven(r, s1, s2); _p_MemDiff(7, r, s1, s2);} while(0)
205
206#define _p_MemDiff_Declare(r, s1, s2) \
207 const unsigned long* _s1 = ((unsigned long*) s1); \
208 const unsigned long* _s2 = ((unsigned long*) s2); \
209 unsigned long* _r = ((unsigned long*) r)
210
211#define p_MemDiff_LengthOne(r, s1, s2, length) _p_MemDiff_LengthOne(r, s1, s2)
212#define p_MemDiff_LengthTwo(r, s1, s2, length) \
213do \
214{ \
215 _p_MemDiff_Declare(r,s1,s2); \
216 _p_MemDiff_LengthTwo(_r, _s1, _s2); \
217} \
218while (0)
219#define p_MemDiff_LengthThree(r, s1, s2, length) \
220do \
221{ \
222 _p_MemDiff_Declare(r,s1,s2); \
223 _p_MemDiff_LengthThree(_r, _s1, _s2); \
224} \
225while (0)
226#define p_MemDiff_LengthFour(r, s1, s2, length) \
227do \
228{ \
229 _p_MemDiff_Declare(r,s1,s2); \
230 _p_MemDiff_LengthFour(_r, _s1, _s2); \
231} \
232while (0)
233#define p_MemDiff_LengthFive(r, s1, s2, length) \
234do \
235{ \
236 _p_MemDiff_Declare(r,s1,s2); \
237 _p_MemDiff_LengthFive(_r, _s1, _s2); \
238} \
239while (0)
240#define p_MemDiff_LengthSix(r, s1, s2, length) \
241do \
242{ \
243 _p_MemDiff_Declare(r,s1,s2); \
244 _p_MemDiff_LengthSix(_r, _s1, _s2); \
245} \
246while (0)
247#define p_MemDiff_LengthSeven(r, s1, s2, length) \
248do \
249{ \
250 _p_MemDiff_Declare(r,s1,s2); \
251 _p_MemDiff_LengthSeven(_r, _s1, _s2); \
252} \
253while (0)
254#define p_MemDiff_LengthEight(r, s1, s2, length) \
255do \
256{ \
257 _p_MemDiff_Declare(r,s1,s2); \
258 _p_MemDiff_LengthEight(_r, _s1, _s2); \
259} \
260while (0)
261
262#define p_MemDiff_LengthGeneral(r, s1, s2, length) \
263do \
264{ \
265 _p_MemDiff_Declare(r,s1,s2); \
266 const unsigned long _l = (unsigned long) length; \
267 unsigned long _i = 0; \
268 \
269 do \
270 { \
271 _r[_i] = _s1[_i] - _s2[_i]; \
272 _i++; \
273 } \
274 while (_i != _l); \
275} \
276while (0)
277
278
279/***************************************************************
280 *
281 * MemSub
282 *
283 ***************************************************************/
284
285#define _p_MemSub(i, r, s) r[i] -= s[i]
286
287#define _p_MemSub_Declare(r, s) \
288 const unsigned long* _s = ((unsigned long*) s); \
289 unsigned long* _r = ((unsigned long*) r)
290
291#define p_MemSub_LengthGeneral(r, s, length) \
292do \
293{ \
294 _p_MemSub_Declare(r,s); \
295 const unsigned long _l = (unsigned long) length; \
296 unsigned long _i = 0; \
297 \
298 do \
299 { \
300 _r[_i] -= _s[_i]; \
301 _i++; \
302 } \
303 while (_i != _l); \
304} \
305while (0)
306
307#define _p_MemAddSub_Declare(r, s, t) \
308 const unsigned long* _s = ((unsigned long*) s); \
309 const unsigned long* _t = ((unsigned long*) t); \
310 unsigned long* _r = ((unsigned long*) r)
311
312#define p_MemAddSub_LengthGeneral(r, s, t, length) \
313do \
314{ \
315 _p_MemAddSub_Declare(r,s, t); \
316 const unsigned long _l = (unsigned long) length; \
317 unsigned long _i = 0; \
318 \
319 do \
320 { \
321 _r[_i] += _s[_i] - _t[_i]; \
322 _i++; \
323 } \
324 while (_i != _l); \
325} \
326while (0)
327
328#endif /* P_MEM_ADD_H */