1 | /*************************************************************************** |
---|
2 | * blitz/array/resize.cc Resizing of arrays |
---|
3 | * |
---|
4 | * $Id$ |
---|
5 | * |
---|
6 | * Copyright (C) 1997-2011 Todd Veldhuizen <tveldhui@acm.org> |
---|
7 | * |
---|
8 | * This file is a part of Blitz. |
---|
9 | * |
---|
10 | * Blitz is free software: you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU Lesser General Public License |
---|
12 | * as published by the Free Software Foundation, either version 3 |
---|
13 | * of the License, or (at your option) any later version. |
---|
14 | * |
---|
15 | * Blitz is distributed in the hope that it will be useful, |
---|
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | * GNU Lesser General Public License for more details. |
---|
19 | * |
---|
20 | * You should have received a copy of the GNU Lesser General Public |
---|
21 | * License along with Blitz. If not, see <http://www.gnu.org/licenses/>. |
---|
22 | * |
---|
23 | * Suggestions: blitz-devel@lists.sourceforge.net |
---|
24 | * Bugs: blitz-support@lists.sourceforge.net |
---|
25 | * |
---|
26 | * For more information, please see the Blitz++ Home Page: |
---|
27 | * https://sourceforge.net/projects/blitz/ |
---|
28 | * |
---|
29 | ****************************************************************************/ |
---|
30 | #ifndef BZ_ARRAYRESIZE_CC |
---|
31 | #define BZ_ARRAYRESIZE_CC |
---|
32 | |
---|
33 | #ifndef BZ_ARRAY_H |
---|
34 | #error <blitz/array/resize.cc> must be included via <blitz/array.h> |
---|
35 | #endif |
---|
36 | |
---|
37 | #include <blitz/minmax.h> |
---|
38 | |
---|
39 | BZ_NAMESPACE(blitz) |
---|
40 | |
---|
41 | template<typename T_numtype, int N_rank> |
---|
42 | void Array<T_numtype, N_rank>::resize(int extent0) |
---|
43 | { |
---|
44 | BZPRECONDITION(extent0 >= 0); |
---|
45 | BZPRECONDITION(N_rank == 1); |
---|
46 | |
---|
47 | if (extent0 != length_[0]) |
---|
48 | { |
---|
49 | length_[0] = extent0; |
---|
50 | setupStorage(0); |
---|
51 | } |
---|
52 | } |
---|
53 | |
---|
54 | template<typename T_numtype, int N_rank> |
---|
55 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1) |
---|
56 | { |
---|
57 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0)); |
---|
58 | BZPRECONDITION(N_rank == 2); |
---|
59 | |
---|
60 | if ((extent0 != length_[0]) || (extent1 != length_[1])) |
---|
61 | { |
---|
62 | length_[0] = extent0; |
---|
63 | length_[1] = extent1; |
---|
64 | setupStorage(1); |
---|
65 | } |
---|
66 | } |
---|
67 | |
---|
68 | template<typename T_numtype, int N_rank> |
---|
69 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
70 | int extent2) |
---|
71 | { |
---|
72 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0)); |
---|
73 | BZPRECONDITION(N_rank == 3); |
---|
74 | |
---|
75 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
76 | || (extent2 != length_[2])) |
---|
77 | { |
---|
78 | length_[0] = extent0; |
---|
79 | length_[1] = extent1; |
---|
80 | length_[2] = extent2; |
---|
81 | setupStorage(2); |
---|
82 | } |
---|
83 | } |
---|
84 | |
---|
85 | |
---|
86 | template<typename T_numtype, int N_rank> |
---|
87 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
88 | int extent2, int extent3) |
---|
89 | { |
---|
90 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0) |
---|
91 | && (extent3 >= 0)); |
---|
92 | BZPRECONDITION(N_rank == 4); |
---|
93 | |
---|
94 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
95 | || (extent2 != length_[2]) || (extent3 != length_[3])) |
---|
96 | { |
---|
97 | length_[0] = extent0; |
---|
98 | length_[1] = extent1; |
---|
99 | length_[2] = extent2; |
---|
100 | length_[3] = extent3; |
---|
101 | setupStorage(3); |
---|
102 | } |
---|
103 | } |
---|
104 | |
---|
105 | template<typename T_numtype, int N_rank> |
---|
106 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
107 | int extent2, int extent3, int extent4) |
---|
108 | { |
---|
109 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0) |
---|
110 | && (extent3 >= 0) && (extent4 >= 0)); |
---|
111 | BZPRECONDITION(N_rank == 5); |
---|
112 | |
---|
113 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
114 | || (extent2 != length_[2]) || (extent3 != length_[3]) |
---|
115 | || (extent4 != length_[4])) |
---|
116 | { |
---|
117 | length_[0] = extent0; |
---|
118 | length_[1] = extent1; |
---|
119 | length_[2] = extent2; |
---|
120 | length_[3] = extent3; |
---|
121 | length_[4] = extent4; |
---|
122 | setupStorage(4); |
---|
123 | } |
---|
124 | } |
---|
125 | |
---|
126 | template<typename T_numtype, int N_rank> |
---|
127 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
128 | int extent2, int extent3, int extent4, int extent5) |
---|
129 | { |
---|
130 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0) |
---|
131 | && (extent3 >= 0) && (extent4 >= 0) && (extent5 >= 0)); |
---|
132 | BZPRECONDITION(N_rank == 6); |
---|
133 | |
---|
134 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
135 | || (extent2 != length_[2]) || (extent3 != length_[3]) |
---|
136 | || (extent4 != length_[4]) || (extent5 != length_[5])) |
---|
137 | { |
---|
138 | length_[0] = extent0; |
---|
139 | length_[1] = extent1; |
---|
140 | length_[2] = extent2; |
---|
141 | length_[3] = extent3; |
---|
142 | length_[4] = extent4; |
---|
143 | length_[5] = extent5; |
---|
144 | setupStorage(5); |
---|
145 | } |
---|
146 | } |
---|
147 | |
---|
148 | template<typename T_numtype, int N_rank> |
---|
149 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
150 | int extent2, int extent3, int extent4, int extent5, |
---|
151 | int extent6) |
---|
152 | { |
---|
153 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0) |
---|
154 | && (extent3 >= 0) && (extent4 >= 0) && (extent5 >= 0) |
---|
155 | && (extent6 >= 0)); |
---|
156 | BZPRECONDITION(N_rank == 7); |
---|
157 | |
---|
158 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
159 | || (extent2 != length_[2]) || (extent3 != length_[3]) |
---|
160 | || (extent4 != length_[4]) || (extent5 != length_[5]) |
---|
161 | || (extent6 != length_[6])) |
---|
162 | { |
---|
163 | length_[0] = extent0; |
---|
164 | length_[1] = extent1; |
---|
165 | length_[2] = extent2; |
---|
166 | length_[3] = extent3; |
---|
167 | length_[4] = extent4; |
---|
168 | length_[5] = extent5; |
---|
169 | length_[6] = extent6; |
---|
170 | setupStorage(6); |
---|
171 | } |
---|
172 | } |
---|
173 | |
---|
174 | template<typename T_numtype, int N_rank> |
---|
175 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
176 | int extent2, int extent3, int extent4, int extent5, |
---|
177 | int extent6, int extent7) |
---|
178 | { |
---|
179 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0) |
---|
180 | && (extent3 >= 0) && (extent4 >= 0) && (extent5 >= 0) |
---|
181 | && (extent6 >= 0) && (extent7 >= 0)); |
---|
182 | BZPRECONDITION(N_rank == 8); |
---|
183 | |
---|
184 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
185 | || (extent2 != length_[2]) || (extent3 != length_[3]) |
---|
186 | || (extent4 != length_[4]) || (extent5 != length_[5]) |
---|
187 | || (extent6 != length_[6]) || (extent7 != length_[7])) |
---|
188 | { |
---|
189 | length_[0] = extent0; |
---|
190 | length_[1] = extent1; |
---|
191 | length_[2] = extent2; |
---|
192 | length_[3] = extent3; |
---|
193 | length_[4] = extent4; |
---|
194 | length_[5] = extent5; |
---|
195 | length_[6] = extent6; |
---|
196 | length_[7] = extent7; |
---|
197 | setupStorage(7); |
---|
198 | } |
---|
199 | } |
---|
200 | |
---|
201 | template<typename T_numtype, int N_rank> |
---|
202 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
203 | int extent2, int extent3, int extent4, int extent5, |
---|
204 | int extent6, int extent7, int extent8) |
---|
205 | { |
---|
206 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0) |
---|
207 | && (extent3 >= 0) && (extent4 >= 0) && (extent5 >= 0) |
---|
208 | && (extent6 >= 0) && (extent7 >= 0) && (extent8 >= 0)); |
---|
209 | BZPRECONDITION(N_rank == 9); |
---|
210 | |
---|
211 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
212 | || (extent2 != length_[2]) || (extent3 != length_[3]) |
---|
213 | || (extent4 != length_[4]) || (extent5 != length_[5]) |
---|
214 | || (extent6 != length_[6]) || (extent7 != length_[7]) |
---|
215 | || (extent8 != length_[8])) |
---|
216 | { |
---|
217 | length_[0] = extent0; |
---|
218 | length_[1] = extent1; |
---|
219 | length_[2] = extent2; |
---|
220 | length_[3] = extent3; |
---|
221 | length_[4] = extent4; |
---|
222 | length_[5] = extent5; |
---|
223 | length_[6] = extent6; |
---|
224 | length_[7] = extent7; |
---|
225 | length_[8] = extent8; |
---|
226 | setupStorage(8); |
---|
227 | } |
---|
228 | } |
---|
229 | |
---|
230 | |
---|
231 | template<typename T_numtype, int N_rank> |
---|
232 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
233 | int extent2, int extent3, int extent4, int extent5, |
---|
234 | int extent6, int extent7, int extent8, int extent9) |
---|
235 | { |
---|
236 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0) |
---|
237 | && (extent3 >= 0) && (extent4 >= 0) && (extent5 >= 0) |
---|
238 | && (extent6 >= 0) && (extent7 >= 0) && (extent8 >= 0) |
---|
239 | && (extent9 >= 0)); |
---|
240 | BZPRECONDITION(N_rank == 10); |
---|
241 | |
---|
242 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
243 | || (extent2 != length_[2]) || (extent3 != length_[3]) |
---|
244 | || (extent4 != length_[4]) || (extent5 != length_[5]) |
---|
245 | || (extent6 != length_[6]) || (extent7 != length_[7]) |
---|
246 | || (extent8 != length_[8]) || (extent9 != length_[9])) |
---|
247 | { |
---|
248 | length_[0] = extent0; |
---|
249 | length_[1] = extent1; |
---|
250 | length_[2] = extent2; |
---|
251 | length_[3] = extent3; |
---|
252 | length_[4] = extent4; |
---|
253 | length_[5] = extent5; |
---|
254 | length_[6] = extent6; |
---|
255 | length_[7] = extent7; |
---|
256 | length_[8] = extent8; |
---|
257 | length_[9] = extent9; |
---|
258 | setupStorage(9); |
---|
259 | } |
---|
260 | } |
---|
261 | |
---|
262 | template<typename T_numtype, int N_rank> |
---|
263 | void Array<T_numtype, N_rank>::resize(int extent0, int extent1, |
---|
264 | int extent2, int extent3, int extent4, int extent5, |
---|
265 | int extent6, int extent7, int extent8, int extent9, |
---|
266 | int extent10) |
---|
267 | { |
---|
268 | BZPRECONDITION((extent0 >= 0) && (extent1 >= 0) && (extent2 >= 0) |
---|
269 | && (extent3 >= 0) && (extent4 >= 0) && (extent5 >= 0) |
---|
270 | && (extent6 >= 0) && (extent7 >= 0) && (extent8 >= 0) |
---|
271 | && (extent9 >= 0) && (extent10 >= 0)); |
---|
272 | BZPRECONDITION(N_rank == 11); |
---|
273 | |
---|
274 | if ((extent0 != length_[0]) || (extent1 != length_[1]) |
---|
275 | || (extent2 != length_[2]) || (extent3 != length_[3]) |
---|
276 | || (extent4 != length_[4]) || (extent5 != length_[5]) |
---|
277 | || (extent6 != length_[6]) || (extent7 != length_[7]) |
---|
278 | || (extent8 != length_[8]) || (extent9 != length_[9]) |
---|
279 | || (extent10 != length_[10])) |
---|
280 | { |
---|
281 | length_[0] = extent0; |
---|
282 | length_[1] = extent1; |
---|
283 | length_[2] = extent2; |
---|
284 | length_[3] = extent3; |
---|
285 | length_[4] = extent4; |
---|
286 | length_[5] = extent5; |
---|
287 | length_[6] = extent6; |
---|
288 | length_[7] = extent7; |
---|
289 | length_[8] = extent8; |
---|
290 | length_[9] = extent9; |
---|
291 | length_[10] = extent10; |
---|
292 | setupStorage(10); |
---|
293 | } |
---|
294 | } |
---|
295 | |
---|
296 | |
---|
297 | template<typename T_numtype, int N_rank> |
---|
298 | void Array<T_numtype, N_rank>::resize(Range r0) |
---|
299 | { |
---|
300 | BZPRECONDITION(r0.isAscendingContiguous()); |
---|
301 | |
---|
302 | length_[0] = r0.length(); |
---|
303 | storage_.setBase(0, r0.first()); |
---|
304 | |
---|
305 | setupStorage(0); |
---|
306 | } |
---|
307 | |
---|
308 | template<typename T_numtype, int N_rank> |
---|
309 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1) |
---|
310 | { |
---|
311 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
312 | r1.isAscendingContiguous()); |
---|
313 | |
---|
314 | length_[0] = r0.length(); |
---|
315 | storage_.setBase(0, r0.first()); |
---|
316 | length_[1] = r1.length(); |
---|
317 | storage_.setBase(1, r1.first()); |
---|
318 | |
---|
319 | setupStorage(1); |
---|
320 | } |
---|
321 | |
---|
322 | template<typename T_numtype, int N_rank> |
---|
323 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2) |
---|
324 | { |
---|
325 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
326 | r1.isAscendingContiguous() && r2.isAscendingContiguous()); |
---|
327 | |
---|
328 | length_[0] = r0.length(); |
---|
329 | storage_.setBase(0, r0.first()); |
---|
330 | length_[1] = r1.length(); |
---|
331 | storage_.setBase(1, r1.first()); |
---|
332 | length_[2] = r2.length(); |
---|
333 | storage_.setBase(2, r2.first()); |
---|
334 | |
---|
335 | setupStorage(2); |
---|
336 | } |
---|
337 | |
---|
338 | template<typename T_numtype, int N_rank> |
---|
339 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2, |
---|
340 | Range r3) |
---|
341 | { |
---|
342 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
343 | r1.isAscendingContiguous() && r2.isAscendingContiguous() |
---|
344 | && r3.isAscendingContiguous()); |
---|
345 | |
---|
346 | length_[0] = r0.length(); |
---|
347 | storage_.setBase(0, r0.first()); |
---|
348 | length_[1] = r1.length(); |
---|
349 | storage_.setBase(1, r1.first()); |
---|
350 | length_[2] = r2.length(); |
---|
351 | storage_.setBase(2, r2.first()); |
---|
352 | length_[3] = r3.length(); |
---|
353 | storage_.setBase(3, r3.first()); |
---|
354 | |
---|
355 | setupStorage(3); |
---|
356 | } |
---|
357 | |
---|
358 | template<typename T_numtype, int N_rank> |
---|
359 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2, |
---|
360 | Range r3, Range r4) |
---|
361 | { |
---|
362 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
363 | r1.isAscendingContiguous() && r2.isAscendingContiguous() |
---|
364 | && r3.isAscendingContiguous() && r4.isAscendingContiguous()); |
---|
365 | |
---|
366 | length_[0] = r0.length(); |
---|
367 | storage_.setBase(0, r0.first()); |
---|
368 | length_[1] = r1.length(); |
---|
369 | storage_.setBase(1, r1.first()); |
---|
370 | length_[2] = r2.length(); |
---|
371 | storage_.setBase(2, r2.first()); |
---|
372 | length_[3] = r3.length(); |
---|
373 | storage_.setBase(3, r3.first()); |
---|
374 | length_[4] = r4.length(); |
---|
375 | storage_.setBase(4, r4.first()); |
---|
376 | |
---|
377 | setupStorage(4); |
---|
378 | } |
---|
379 | |
---|
380 | template<typename T_numtype, int N_rank> |
---|
381 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2, |
---|
382 | Range r3, Range r4, Range r5) |
---|
383 | { |
---|
384 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
385 | r1.isAscendingContiguous() && r2.isAscendingContiguous() |
---|
386 | && r3.isAscendingContiguous() && r4.isAscendingContiguous() |
---|
387 | && r5.isAscendingContiguous()); |
---|
388 | |
---|
389 | length_[0] = r0.length(); |
---|
390 | storage_.setBase(0, r0.first()); |
---|
391 | length_[1] = r1.length(); |
---|
392 | storage_.setBase(1, r1.first()); |
---|
393 | length_[2] = r2.length(); |
---|
394 | storage_.setBase(2, r2.first()); |
---|
395 | length_[3] = r3.length(); |
---|
396 | storage_.setBase(3, r3.first()); |
---|
397 | length_[4] = r4.length(); |
---|
398 | storage_.setBase(4, r4.first()); |
---|
399 | length_[5] = r5.length(); |
---|
400 | storage_.setBase(5, r5.first()); |
---|
401 | |
---|
402 | setupStorage(5); |
---|
403 | } |
---|
404 | |
---|
405 | template<typename T_numtype, int N_rank> |
---|
406 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2, |
---|
407 | Range r3, Range r4, Range r5, Range r6) |
---|
408 | { |
---|
409 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
410 | r1.isAscendingContiguous() && r2.isAscendingContiguous() |
---|
411 | && r3.isAscendingContiguous() && r4.isAscendingContiguous() |
---|
412 | && r5.isAscendingContiguous() && r6.isAscendingContiguous()); |
---|
413 | |
---|
414 | length_[0] = r0.length(); |
---|
415 | storage_.setBase(0, r0.first()); |
---|
416 | length_[1] = r1.length(); |
---|
417 | storage_.setBase(1, r1.first()); |
---|
418 | length_[2] = r2.length(); |
---|
419 | storage_.setBase(2, r2.first()); |
---|
420 | length_[3] = r3.length(); |
---|
421 | storage_.setBase(3, r3.first()); |
---|
422 | length_[4] = r4.length(); |
---|
423 | storage_.setBase(4, r4.first()); |
---|
424 | length_[5] = r5.length(); |
---|
425 | storage_.setBase(5, r5.first()); |
---|
426 | length_[6] = r6.length(); |
---|
427 | storage_.setBase(6, r6.first()); |
---|
428 | |
---|
429 | setupStorage(6); |
---|
430 | } |
---|
431 | |
---|
432 | template<typename T_numtype, int N_rank> |
---|
433 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2, |
---|
434 | Range r3, Range r4, Range r5, Range r6, Range r7) |
---|
435 | { |
---|
436 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
437 | r1.isAscendingContiguous() && r2.isAscendingContiguous() |
---|
438 | && r3.isAscendingContiguous() && r4.isAscendingContiguous() |
---|
439 | && r5.isAscendingContiguous() && r6.isAscendingContiguous() |
---|
440 | && r7.isAscendingContiguous()); |
---|
441 | |
---|
442 | length_[0] = r0.length(); |
---|
443 | storage_.setBase(0, r0.first()); |
---|
444 | length_[1] = r1.length(); |
---|
445 | storage_.setBase(1, r1.first()); |
---|
446 | length_[2] = r2.length(); |
---|
447 | storage_.setBase(2, r2.first()); |
---|
448 | length_[3] = r3.length(); |
---|
449 | storage_.setBase(3, r3.first()); |
---|
450 | length_[4] = r4.length(); |
---|
451 | storage_.setBase(4, r4.first()); |
---|
452 | length_[5] = r5.length(); |
---|
453 | storage_.setBase(5, r5.first()); |
---|
454 | length_[6] = r6.length(); |
---|
455 | storage_.setBase(6, r6.first()); |
---|
456 | length_[7] = r7.length(); |
---|
457 | storage_.setBase(7, r7.first()); |
---|
458 | |
---|
459 | setupStorage(7); |
---|
460 | } |
---|
461 | |
---|
462 | template<typename T_numtype, int N_rank> |
---|
463 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2, |
---|
464 | Range r3, Range r4, Range r5, Range r6, Range r7, Range r8) |
---|
465 | { |
---|
466 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
467 | r1.isAscendingContiguous() && r2.isAscendingContiguous() |
---|
468 | && r3.isAscendingContiguous() && r4.isAscendingContiguous() |
---|
469 | && r5.isAscendingContiguous() && r6.isAscendingContiguous() |
---|
470 | && r7.isAscendingContiguous() && r8.isAscendingContiguous()); |
---|
471 | |
---|
472 | length_[0] = r0.length(); |
---|
473 | storage_.setBase(0, r0.first()); |
---|
474 | length_[1] = r1.length(); |
---|
475 | storage_.setBase(1, r1.first()); |
---|
476 | length_[2] = r2.length(); |
---|
477 | storage_.setBase(2, r2.first()); |
---|
478 | length_[3] = r3.length(); |
---|
479 | storage_.setBase(3, r3.first()); |
---|
480 | length_[4] = r4.length(); |
---|
481 | storage_.setBase(4, r4.first()); |
---|
482 | length_[5] = r5.length(); |
---|
483 | storage_.setBase(5, r5.first()); |
---|
484 | length_[6] = r6.length(); |
---|
485 | storage_.setBase(6, r6.first()); |
---|
486 | length_[7] = r7.length(); |
---|
487 | storage_.setBase(7, r7.first()); |
---|
488 | length_[8] = r8.length(); |
---|
489 | storage_.setBase(8, r8.first()); |
---|
490 | |
---|
491 | setupStorage(8); |
---|
492 | } |
---|
493 | |
---|
494 | template<typename T_numtype, int N_rank> |
---|
495 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2, |
---|
496 | Range r3, Range r4, Range r5, Range r6, Range r7, Range r8, |
---|
497 | Range r9) |
---|
498 | { |
---|
499 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
500 | r1.isAscendingContiguous() && r2.isAscendingContiguous() |
---|
501 | && r3.isAscendingContiguous() && r4.isAscendingContiguous() |
---|
502 | && r5.isAscendingContiguous() && r6.isAscendingContiguous() |
---|
503 | && r7.isAscendingContiguous() && r8.isAscendingContiguous() |
---|
504 | && r9.isAscendingContiguous()); |
---|
505 | |
---|
506 | length_[0] = r0.length(); |
---|
507 | storage_.setBase(0, r0.first()); |
---|
508 | length_[1] = r1.length(); |
---|
509 | storage_.setBase(1, r1.first()); |
---|
510 | length_[2] = r2.length(); |
---|
511 | storage_.setBase(2, r2.first()); |
---|
512 | length_[3] = r3.length(); |
---|
513 | storage_.setBase(3, r3.first()); |
---|
514 | length_[4] = r4.length(); |
---|
515 | storage_.setBase(4, r4.first()); |
---|
516 | length_[5] = r5.length(); |
---|
517 | storage_.setBase(5, r5.first()); |
---|
518 | length_[6] = r6.length(); |
---|
519 | storage_.setBase(6, r6.first()); |
---|
520 | length_[7] = r7.length(); |
---|
521 | storage_.setBase(7, r7.first()); |
---|
522 | length_[8] = r8.length(); |
---|
523 | storage_.setBase(8, r8.first()); |
---|
524 | length_[9] = r9.length(); |
---|
525 | storage_.setBase(9, r9.first()); |
---|
526 | |
---|
527 | setupStorage(9); |
---|
528 | } |
---|
529 | |
---|
530 | template<typename T_numtype, int N_rank> |
---|
531 | void Array<T_numtype, N_rank>::resize(Range r0, Range r1, Range r2, |
---|
532 | Range r3, Range r4, Range r5, Range r6, Range r7, Range r8, |
---|
533 | Range r9, Range r10) |
---|
534 | { |
---|
535 | BZPRECONDITION(r0.isAscendingContiguous() && |
---|
536 | r1.isAscendingContiguous() && r2.isAscendingContiguous() |
---|
537 | && r3.isAscendingContiguous() && r4.isAscendingContiguous() |
---|
538 | && r5.isAscendingContiguous() && r6.isAscendingContiguous() |
---|
539 | && r7.isAscendingContiguous() && r8.isAscendingContiguous() |
---|
540 | && r9.isAscendingContiguous() && r10.isAscendingContiguous()); |
---|
541 | |
---|
542 | length_[0] = r0.length(); |
---|
543 | storage_.setBase(0, r0.first()); |
---|
544 | length_[1] = r1.length(); |
---|
545 | storage_.setBase(1, r1.first()); |
---|
546 | length_[2] = r2.length(); |
---|
547 | storage_.setBase(2, r2.first()); |
---|
548 | length_[3] = r3.length(); |
---|
549 | storage_.setBase(3, r3.first()); |
---|
550 | length_[4] = r4.length(); |
---|
551 | storage_.setBase(4, r4.first()); |
---|
552 | length_[5] = r5.length(); |
---|
553 | storage_.setBase(5, r5.first()); |
---|
554 | length_[6] = r6.length(); |
---|
555 | storage_.setBase(6, r6.first()); |
---|
556 | length_[7] = r7.length(); |
---|
557 | storage_.setBase(7, r7.first()); |
---|
558 | length_[8] = r8.length(); |
---|
559 | storage_.setBase(8, r8.first()); |
---|
560 | length_[9] = r9.length(); |
---|
561 | storage_.setBase(9, r9.first()); |
---|
562 | length_[10] = r10.length(); |
---|
563 | storage_.setBase(10, r10.first()); |
---|
564 | |
---|
565 | setupStorage(10); |
---|
566 | } |
---|
567 | |
---|
568 | |
---|
569 | template<typename T_numtype, int N_rank> |
---|
570 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0) |
---|
571 | { |
---|
572 | BZPRECONDITION(length0 > 0); |
---|
573 | BZPRECONDITION(N_rank == 1); |
---|
574 | |
---|
575 | if (length0 != length_[firstRank]) |
---|
576 | { |
---|
577 | #if defined(__KCC) || defined(__DECCXX) |
---|
578 | // NEEDS_WORK: have to discard the base() parameter for EDG, |
---|
579 | // because it gives the following bizarre error: |
---|
580 | |
---|
581 | /* |
---|
582 | * "blitz/tinyvec.h", line 421: error: the size of an array must be greater |
---|
583 | * than zero |
---|
584 | * T_numtype data_[N_length]; |
---|
585 | * ^ |
---|
586 | * detected during: |
---|
587 | * instantiation of class "blitz::TinyVector<int, 0>" at line 273 of |
---|
588 | * "./../blitz/array/resize.cc" |
---|
589 | * instantiation of |
---|
590 | * "void blitz::Array<int, 1>::resizeAndPreserve(int)" |
---|
591 | */ |
---|
592 | T_array B(length0, storage_); |
---|
593 | #else |
---|
594 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0), storage_); // line 273 |
---|
595 | #endif |
---|
596 | if (numElements()) |
---|
597 | { |
---|
598 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), |
---|
599 | ubound(0))); |
---|
600 | B(overlap0) = (*this)(overlap0); |
---|
601 | } |
---|
602 | reference(B); |
---|
603 | } |
---|
604 | } |
---|
605 | |
---|
606 | template<typename T_numtype, int N_rank> |
---|
607 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1) |
---|
608 | { |
---|
609 | BZPRECONDITION((length0 > 0) && (length1 > 0)); |
---|
610 | BZPRECONDITION(N_rank == 2); |
---|
611 | |
---|
612 | if ((length0 != length_[0]) || (length1 != length_[1])) |
---|
613 | { |
---|
614 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1), storage_); |
---|
615 | |
---|
616 | if (numElements()) |
---|
617 | { |
---|
618 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), |
---|
619 | ubound(0))); |
---|
620 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), |
---|
621 | ubound(1))); |
---|
622 | B(overlap0, overlap1) = (*this)(overlap0, overlap1); |
---|
623 | } |
---|
624 | reference(B); |
---|
625 | } |
---|
626 | } |
---|
627 | |
---|
628 | template<typename T_numtype, int N_rank> |
---|
629 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
630 | int length2) |
---|
631 | { |
---|
632 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0)); |
---|
633 | BZPRECONDITION(N_rank == 3); |
---|
634 | |
---|
635 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
636 | || (length2 != length_[2])) |
---|
637 | { |
---|
638 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2), |
---|
639 | storage_); |
---|
640 | if (numElements()) |
---|
641 | { |
---|
642 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), |
---|
643 | ubound(0))); |
---|
644 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), |
---|
645 | ubound(1))); |
---|
646 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), |
---|
647 | ubound(2))); |
---|
648 | B(overlap0, overlap1, overlap2) = (*this)(overlap0, overlap1, |
---|
649 | overlap2); |
---|
650 | } |
---|
651 | reference(B); |
---|
652 | } |
---|
653 | } |
---|
654 | |
---|
655 | template<typename T_numtype, int N_rank> |
---|
656 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
657 | int length2, int length3) |
---|
658 | { |
---|
659 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0) |
---|
660 | && (length3 > 0)); |
---|
661 | BZPRECONDITION(N_rank == 4); |
---|
662 | |
---|
663 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
664 | || (length2 != length_[2]) || (length3 != length_[3])) |
---|
665 | { |
---|
666 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, |
---|
667 | length2, length3), storage_); |
---|
668 | |
---|
669 | if (numElements()) |
---|
670 | { |
---|
671 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), ubound(0))); |
---|
672 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), ubound(1))); |
---|
673 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), ubound(2))); |
---|
674 | Range overlap3 = Range(fromStart, (extrema::min)(B.ubound(3), ubound(3))); |
---|
675 | B(overlap0, overlap1, overlap2, overlap3) = (*this)(overlap0, |
---|
676 | overlap1, overlap2, overlap3); |
---|
677 | } |
---|
678 | reference(B); |
---|
679 | } |
---|
680 | } |
---|
681 | |
---|
682 | template<typename T_numtype, int N_rank> |
---|
683 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
684 | int length2, int length3, int length4) |
---|
685 | { |
---|
686 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0) |
---|
687 | && (length3 > 0) && (length4 > 0)); |
---|
688 | BZPRECONDITION(N_rank == 5); |
---|
689 | |
---|
690 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
691 | || (length2 != length_[2]) || (length3 != length_[3]) |
---|
692 | || (length4 != length_[4])) |
---|
693 | { |
---|
694 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, |
---|
695 | length2, length3, length4), storage_); |
---|
696 | |
---|
697 | if (numElements()) |
---|
698 | { |
---|
699 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), ubound(0))); |
---|
700 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), ubound(1))); |
---|
701 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), ubound(2))); |
---|
702 | Range overlap3 = Range(fromStart, (extrema::min)(B.ubound(3), ubound(3))); |
---|
703 | Range overlap4 = Range(fromStart, (extrema::min)(B.ubound(4), ubound(4))); |
---|
704 | B(overlap0, overlap1, overlap2, overlap3, overlap4) = (*this) |
---|
705 | (overlap0, overlap1, overlap2, overlap3, overlap4); |
---|
706 | } |
---|
707 | reference(B); |
---|
708 | } |
---|
709 | } |
---|
710 | |
---|
711 | template<typename T_numtype, int N_rank> |
---|
712 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
713 | int length2, int length3, int length4, int length5) |
---|
714 | { |
---|
715 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0) |
---|
716 | && (length3 > 0) && (length4 > 0) && (length5 > 0)); |
---|
717 | BZPRECONDITION(N_rank == 6); |
---|
718 | |
---|
719 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
720 | || (length2 != length_[2]) || (length3 != length_[3]) |
---|
721 | || (length4 != length_[4]) || (length5 != length_[5])) |
---|
722 | { |
---|
723 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, |
---|
724 | length3, length4, length5), storage_); |
---|
725 | |
---|
726 | if (numElements()) |
---|
727 | { |
---|
728 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), ubound(0))); |
---|
729 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), ubound(1))); |
---|
730 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), ubound(2))); |
---|
731 | Range overlap3 = Range(fromStart, (extrema::min)(B.ubound(3), ubound(3))); |
---|
732 | Range overlap4 = Range(fromStart, (extrema::min)(B.ubound(4), ubound(4))); |
---|
733 | Range overlap5 = Range(fromStart, (extrema::min)(B.ubound(5), ubound(5))); |
---|
734 | B(overlap0, overlap1, overlap2, overlap3, overlap4, overlap5) |
---|
735 | = (*this)(overlap0, overlap1, overlap2, overlap3, overlap4, |
---|
736 | overlap5); |
---|
737 | } |
---|
738 | reference(B); |
---|
739 | } |
---|
740 | } |
---|
741 | |
---|
742 | /* Added by Julian Cummings */ |
---|
743 | template<typename T_numtype, int N_rank> |
---|
744 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
745 | int length2, int length3, int length4, int length5, int length6) |
---|
746 | { |
---|
747 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0) |
---|
748 | && (length3 > 0) && (length4 > 0) && (length5 > 0) && (length6 > 0)); |
---|
749 | BZPRECONDITION(N_rank == 7); |
---|
750 | |
---|
751 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
752 | || (length2 != length_[2]) || (length3 != length_[3]) |
---|
753 | || (length4 != length_[4]) || (length5 != length_[5]) |
---|
754 | || (length6 != length_[6])) |
---|
755 | { |
---|
756 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, |
---|
757 | length3, length4, length5, length6), storage_); |
---|
758 | |
---|
759 | if (numElements()) |
---|
760 | { |
---|
761 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), |
---|
762 | ubound(0))); |
---|
763 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), |
---|
764 | ubound(1))); |
---|
765 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), |
---|
766 | ubound(2))); |
---|
767 | Range overlap3 = Range(fromStart, (extrema::min)(B.ubound(3), |
---|
768 | ubound(3))); |
---|
769 | Range overlap4 = Range(fromStart, (extrema::min)(B.ubound(4), |
---|
770 | ubound(4))); |
---|
771 | Range overlap5 = Range(fromStart, (extrema::min)(B.ubound(5), |
---|
772 | ubound(5))); |
---|
773 | Range overlap6 = Range(fromStart, (extrema::min)(B.ubound(6), |
---|
774 | ubound(6))); |
---|
775 | B(overlap0, overlap1, overlap2, overlap3, overlap4, overlap5, |
---|
776 | overlap6) |
---|
777 | = (*this)(overlap0, overlap1, overlap2, overlap3, overlap4, |
---|
778 | overlap5, overlap6); |
---|
779 | } |
---|
780 | reference(B); |
---|
781 | } |
---|
782 | } |
---|
783 | |
---|
784 | /* Added by Julian Cummings */ |
---|
785 | template<typename T_numtype, int N_rank> |
---|
786 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
787 | int length2, int length3, int length4, int length5, int length6, |
---|
788 | int length7) |
---|
789 | { |
---|
790 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0) |
---|
791 | && (length3 > 0) && (length4 > 0) && (length5 > 0) && (length6 > 0) |
---|
792 | && (length7 > 0)); |
---|
793 | BZPRECONDITION(N_rank == 8); |
---|
794 | |
---|
795 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
796 | || (length2 != length_[2]) || (length3 != length_[3]) |
---|
797 | || (length4 != length_[4]) || (length5 != length_[5]) |
---|
798 | || (length6 != length_[6]) || (length7 != length_[7])) |
---|
799 | { |
---|
800 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, |
---|
801 | length3, length4, length5, length6, length7), storage_); |
---|
802 | |
---|
803 | if (numElements()) |
---|
804 | { |
---|
805 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), |
---|
806 | ubound(0))); |
---|
807 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), |
---|
808 | ubound(1))); |
---|
809 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), |
---|
810 | ubound(2))); |
---|
811 | Range overlap3 = Range(fromStart, (extrema::min)(B.ubound(3), |
---|
812 | ubound(3))); |
---|
813 | Range overlap4 = Range(fromStart, (extrema::min)(B.ubound(4), |
---|
814 | ubound(4))); |
---|
815 | Range overlap5 = Range(fromStart, (extrema::min)(B.ubound(5), |
---|
816 | ubound(5))); |
---|
817 | Range overlap6 = Range(fromStart, (extrema::min)(B.ubound(6), |
---|
818 | ubound(6))); |
---|
819 | Range overlap7 = Range(fromStart, (extrema::min)(B.ubound(7), |
---|
820 | ubound(7))); |
---|
821 | B(overlap0, overlap1, overlap2, overlap3, overlap4, overlap5, |
---|
822 | overlap6, overlap7) |
---|
823 | = (*this)(overlap0, overlap1, overlap2, overlap3, overlap4, |
---|
824 | overlap5, overlap6, overlap7); |
---|
825 | } |
---|
826 | reference(B); |
---|
827 | } |
---|
828 | } |
---|
829 | |
---|
830 | /* Added by Julian Cummings */ |
---|
831 | template<typename T_numtype, int N_rank> |
---|
832 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
833 | int length2, int length3, int length4, int length5, int length6, |
---|
834 | int length7, int length8) |
---|
835 | { |
---|
836 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0) |
---|
837 | && (length3 > 0) && (length4 > 0) && (length5 > 0) && (length6 > 0) |
---|
838 | && (length7 > 0) && (length8 > 0)); |
---|
839 | BZPRECONDITION(N_rank == 9); |
---|
840 | |
---|
841 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
842 | || (length2 != length_[2]) || (length3 != length_[3]) |
---|
843 | || (length4 != length_[4]) || (length5 != length_[5]) |
---|
844 | || (length6 != length_[6]) || (length7 != length_[7]) |
---|
845 | || (length8 != length_[8])) |
---|
846 | { |
---|
847 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, |
---|
848 | length3, length4, length5, length6, length7, length8), storage_); |
---|
849 | |
---|
850 | if (numElements()) |
---|
851 | { |
---|
852 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), |
---|
853 | ubound(0))); |
---|
854 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), |
---|
855 | ubound(1))); |
---|
856 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), |
---|
857 | ubound(2))); |
---|
858 | Range overlap3 = Range(fromStart, (extrema::min)(B.ubound(3), |
---|
859 | ubound(3))); |
---|
860 | Range overlap4 = Range(fromStart, (extrema::min)(B.ubound(4), |
---|
861 | ubound(4))); |
---|
862 | Range overlap5 = Range(fromStart, (extrema::min)(B.ubound(5), |
---|
863 | ubound(5))); |
---|
864 | Range overlap6 = Range(fromStart, (extrema::min)(B.ubound(6), |
---|
865 | ubound(6))); |
---|
866 | Range overlap7 = Range(fromStart, (extrema::min)(B.ubound(7), |
---|
867 | ubound(7))); |
---|
868 | Range overlap8 = Range(fromStart, (extrema::min)(B.ubound(8), |
---|
869 | ubound(8))); |
---|
870 | B(overlap0, overlap1, overlap2, overlap3, overlap4, overlap5, |
---|
871 | overlap6, overlap7, overlap8) |
---|
872 | = (*this)(overlap0, overlap1, overlap2, overlap3, overlap4, |
---|
873 | overlap5, overlap6, overlap7, overlap8); |
---|
874 | } |
---|
875 | reference(B); |
---|
876 | } |
---|
877 | } |
---|
878 | |
---|
879 | /* Added by Julian Cummings */ |
---|
880 | template<typename T_numtype, int N_rank> |
---|
881 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
882 | int length2, int length3, int length4, int length5, int length6, |
---|
883 | int length7, int length8, int length9) |
---|
884 | { |
---|
885 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0) |
---|
886 | && (length3 > 0) && (length4 > 0) && (length5 > 0) && (length6 > 0) |
---|
887 | && (length7 > 0) && (length8 > 0) && (length9 > 0)); |
---|
888 | BZPRECONDITION(N_rank == 10); |
---|
889 | |
---|
890 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
891 | || (length2 != length_[2]) || (length3 != length_[3]) |
---|
892 | || (length4 != length_[4]) || (length5 != length_[5]) |
---|
893 | || (length6 != length_[6]) || (length7 != length_[7]) |
---|
894 | || (length8 != length_[8]) || (length9 != length_[9])) |
---|
895 | { |
---|
896 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, |
---|
897 | length3, length4, length5, length6, length7, length8, length9), |
---|
898 | storage_); |
---|
899 | |
---|
900 | if (numElements()) |
---|
901 | { |
---|
902 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), |
---|
903 | ubound(0))); |
---|
904 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), |
---|
905 | ubound(1))); |
---|
906 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), |
---|
907 | ubound(2))); |
---|
908 | Range overlap3 = Range(fromStart, (extrema::min)(B.ubound(3), |
---|
909 | ubound(3))); |
---|
910 | Range overlap4 = Range(fromStart, (extrema::min)(B.ubound(4), |
---|
911 | ubound(4))); |
---|
912 | Range overlap5 = Range(fromStart, (extrema::min)(B.ubound(5), |
---|
913 | ubound(5))); |
---|
914 | Range overlap6 = Range(fromStart, (extrema::min)(B.ubound(6), |
---|
915 | ubound(6))); |
---|
916 | Range overlap7 = Range(fromStart, (extrema::min)(B.ubound(7), |
---|
917 | ubound(7))); |
---|
918 | Range overlap8 = Range(fromStart, (extrema::min)(B.ubound(8), |
---|
919 | ubound(8))); |
---|
920 | Range overlap9 = Range(fromStart, (extrema::min)(B.ubound(9), |
---|
921 | ubound(9))); |
---|
922 | B(overlap0, overlap1, overlap2, overlap3, overlap4, overlap5, |
---|
923 | overlap6, overlap7, overlap8, overlap9) |
---|
924 | = (*this)(overlap0, overlap1, overlap2, overlap3, overlap4, |
---|
925 | overlap5, overlap6, overlap7, overlap8, overlap9); |
---|
926 | } |
---|
927 | reference(B); |
---|
928 | } |
---|
929 | } |
---|
930 | |
---|
931 | /* Added by Julian Cummings */ |
---|
932 | template<typename T_numtype, int N_rank> |
---|
933 | void Array<T_numtype, N_rank>::resizeAndPreserve(int length0, int length1, |
---|
934 | int length2, int length3, int length4, int length5, int length6, |
---|
935 | int length7, int length8, int length9, int length10) |
---|
936 | { |
---|
937 | BZPRECONDITION((length0 > 0) && (length1 > 0) && (length2 > 0) |
---|
938 | && (length3 > 0) && (length4 > 0) && (length5 > 0) && (length6 > 0) |
---|
939 | && (length7 > 0) && (length8 > 0) && (length9 > 0) && (length10 > 0)); |
---|
940 | BZPRECONDITION(N_rank == 11); |
---|
941 | |
---|
942 | if ((length0 != length_[0]) || (length1 != length_[1]) |
---|
943 | || (length2 != length_[2]) || (length3 != length_[3]) |
---|
944 | || (length4 != length_[4]) || (length5 != length_[5]) |
---|
945 | || (length6 != length_[6]) || (length7 != length_[7]) |
---|
946 | || (length8 != length_[8]) || (length9 != length_[9]) |
---|
947 | || (length10 != length_[10])) |
---|
948 | { |
---|
949 | T_array B(base(), BZ_BLITZ_SCOPE(shape)(length0, length1, length2, |
---|
950 | length3, length4, length5, length6, length7, length8, length9, |
---|
951 | length10), storage_); |
---|
952 | |
---|
953 | if (numElements()) |
---|
954 | { |
---|
955 | Range overlap0 = Range(fromStart, (extrema::min)(B.ubound(0), |
---|
956 | ubound(0))); |
---|
957 | Range overlap1 = Range(fromStart, (extrema::min)(B.ubound(1), |
---|
958 | ubound(1))); |
---|
959 | Range overlap2 = Range(fromStart, (extrema::min)(B.ubound(2), |
---|
960 | ubound(2))); |
---|
961 | Range overlap3 = Range(fromStart, (extrema::min)(B.ubound(3), |
---|
962 | ubound(3))); |
---|
963 | Range overlap4 = Range(fromStart, (extrema::min)(B.ubound(4), |
---|
964 | ubound(4))); |
---|
965 | Range overlap5 = Range(fromStart, (extrema::min)(B.ubound(5), |
---|
966 | ubound(5))); |
---|
967 | Range overlap6 = Range(fromStart, (extrema::min)(B.ubound(6), |
---|
968 | ubound(6))); |
---|
969 | Range overlap7 = Range(fromStart, (extrema::min)(B.ubound(7), |
---|
970 | ubound(7))); |
---|
971 | Range overlap8 = Range(fromStart, (extrema::min)(B.ubound(8), |
---|
972 | ubound(8))); |
---|
973 | Range overlap9 = Range(fromStart, (extrema::min)(B.ubound(9), |
---|
974 | ubound(9))); |
---|
975 | Range overlap10 = Range(fromStart, (extrema::min)(B.ubound(10), |
---|
976 | ubound(10))); |
---|
977 | } |
---|
978 | reference(B); |
---|
979 | } |
---|
980 | } |
---|
981 | |
---|
982 | template<typename T_numtype, int N_rank> |
---|
983 | void Array<T_numtype, N_rank>::resize(const TinyVector<int,N_rank>& extent) |
---|
984 | { |
---|
985 | // NEEDS_WORK -- don't resize if unnecessary |
---|
986 | // BZPRECONDITION(all(extent > 0)); |
---|
987 | // if (any(extent != length_)) |
---|
988 | // { |
---|
989 | length_ = extent; |
---|
990 | setupStorage(N_rank); |
---|
991 | // } |
---|
992 | } |
---|
993 | |
---|
994 | /* Added by Julian Cummings */ |
---|
995 | template<typename T_numtype, int N_rank> |
---|
996 | void Array<T_numtype, N_rank>::resizeAndPreserve( |
---|
997 | const TinyVector<int,N_rank>& extent) |
---|
998 | { |
---|
999 | // NEEDS_WORK -- don't resize if unnecessary |
---|
1000 | // BZPRECONDITION(all(extent > 0)); |
---|
1001 | // if (any(extent != length_)) |
---|
1002 | // { |
---|
1003 | T_array B(base(), extent, storage_); |
---|
1004 | |
---|
1005 | if (numElements()) |
---|
1006 | { |
---|
1007 | TinyVector<int,N_rank> ub; |
---|
1008 | for (int d=0; d < N_rank; ++d) |
---|
1009 | ub(d) = (extrema::min)(B.ubound(d),ubound(d)); |
---|
1010 | RectDomain<N_rank> overlap(lbound(),ub); |
---|
1011 | B(overlap) = (*this)(overlap); |
---|
1012 | } |
---|
1013 | reference(B); |
---|
1014 | // } |
---|
1015 | } |
---|
1016 | |
---|
1017 | BZ_NAMESPACE_END |
---|
1018 | |
---|
1019 | #endif // BZ_ARRAYRESIZE_CC |
---|