ARTS 2.5.11 (git: 725533f0)
m_reduce.h
Go to the documentation of this file.
1
13#ifndef m_reduce_h
14#define m_reduce_h
15
16#include <cstring>
17#include "array.h"
18#include "exceptions.h"
19#include "matpack_data.h"
20
22
23inline Index num_elem_from_dim_sizes(const ArrayOfIndex& dim_sizes) {
24 Index m = 1;
25 for (ArrayOfIndex::const_iterator it = dim_sizes.begin();
26 it != dim_sizes.end();
27 it++)
28 m *= *it;
29
30 return m;
31}
32
33// Need this for each matpack type: Vector
34inline void select_dims_by_size(ArrayOfIndex& dim_sizes,
35 const Index min_num_elem,
36 const Vector& type) {
37 dim_sizes.resize(0);
38 if (type.nelem() > min_num_elem) dim_sizes.push_back(type.nelem());
39}
40
41// Need this for each matpack type: Matrix
42inline void select_dims_by_size(ArrayOfIndex& dim_sizes,
43 const Index min_num_elem,
44 const Matrix& type) {
45 dim_sizes.resize(0);
46 if (type.nrows() > min_num_elem) dim_sizes.push_back(type.nrows());
47 if (type.ncols() > min_num_elem) dim_sizes.push_back(type.ncols());
48}
49
50// Need this for each matpack type: Tensor3
51inline void select_dims_by_size(ArrayOfIndex& dim_sizes,
52 const Index min_num_elem,
53 const Tensor3& type) {
54 dim_sizes.resize(0);
55 if (type.npages() > min_num_elem) dim_sizes.push_back(type.npages());
56 if (type.nrows() > min_num_elem) dim_sizes.push_back(type.nrows());
57 if (type.ncols() > min_num_elem) dim_sizes.push_back(type.ncols());
58}
59
60// Need this for each matpack type: Tensor4
61inline void select_dims_by_size(ArrayOfIndex& dim_sizes,
62 const Index min_num_elem,
63 const Tensor4& type) {
64 dim_sizes.resize(0);
65 if (type.nbooks() > min_num_elem) dim_sizes.push_back(type.nbooks());
66 if (type.npages() > min_num_elem) dim_sizes.push_back(type.npages());
67 if (type.nrows() > min_num_elem) dim_sizes.push_back(type.nrows());
68 if (type.ncols() > min_num_elem) dim_sizes.push_back(type.ncols());
69}
70
71// Need this for each matpack type: Tensor5
72inline void select_dims_by_size(ArrayOfIndex& dim_sizes,
73 const Index min_num_elem,
74 const Tensor5& type) {
75 dim_sizes.resize(0);
76 if (type.nshelves() > min_num_elem) dim_sizes.push_back(type.nshelves());
77 if (type.nbooks() > min_num_elem) dim_sizes.push_back(type.nbooks());
78 if (type.npages() > min_num_elem) dim_sizes.push_back(type.npages());
79 if (type.nrows() > min_num_elem) dim_sizes.push_back(type.nrows());
80 if (type.ncols() > min_num_elem) dim_sizes.push_back(type.ncols());
81}
82
83// Need this for each matpack type: Tensor6
84inline void select_dims_by_size(ArrayOfIndex& dim_sizes,
85 const Index min_num_elem,
86 const Tensor6& type) {
87 dim_sizes.resize(0);
88 if (type.nvitrines() > min_num_elem) dim_sizes.push_back(type.nvitrines());
89 if (type.nshelves() > min_num_elem) dim_sizes.push_back(type.nshelves());
90 if (type.nbooks() > min_num_elem) dim_sizes.push_back(type.nbooks());
91 if (type.npages() > min_num_elem) dim_sizes.push_back(type.npages());
92 if (type.nrows() > min_num_elem) dim_sizes.push_back(type.nrows());
93 if (type.ncols() > min_num_elem) dim_sizes.push_back(type.ncols());
94}
95
96// Need this for each matpack type: Tensor7
97inline void select_dims_by_size(ArrayOfIndex& dim_sizes,
98 const Index min_num_elem,
99 const Tensor7& type) {
100 dim_sizes.resize(0);
101 if (type.nlibraries() > min_num_elem) dim_sizes.push_back(type.nlibraries());
102 if (type.nvitrines() > min_num_elem) dim_sizes.push_back(type.nvitrines());
103 if (type.nshelves() > min_num_elem) dim_sizes.push_back(type.nshelves());
104 if (type.nbooks() > min_num_elem) dim_sizes.push_back(type.nbooks());
105 if (type.npages() > min_num_elem) dim_sizes.push_back(type.npages());
106 if (type.nrows() > min_num_elem) dim_sizes.push_back(type.nrows());
107 if (type.ncols() > min_num_elem) dim_sizes.push_back(type.ncols());
108}
109
111
112// To Numeric
113
114/* Workspace method: Doxygen documentation will be auto-generated */
115inline void Reduce(
116 // WS Generic Output:
117 Numeric& o,
118 // WS Input:
119 // WS Generic Input:
120 const Vector& i,
121 const Verbosity&) {
122 if (i.nelem() == 1)
123 o = i[0];
124 else {
125 ostringstream os;
126 os << "The Vector is not also a Numeric";
127 throw std::runtime_error(os.str());
128 }
129}
130
131/* Workspace method: Doxygen documentation will be auto-generated */
132inline void Reduce(
133 // WS Generic Output:
134 Numeric& o,
135 // WS Input:
136 // WS Generic Input:
137 const Matrix& i,
138 const Verbosity&) {
139 if (i.ncols() == 1 && i.nrows() == 1)
140 o = i(0, 0);
141 else {
142 ostringstream os;
143 os << "The Matrix is not also a Numeric";
144 throw std::runtime_error(os.str());
145 }
146}
147
148/* Workspace method: Doxygen documentation will be auto-generated */
149inline void Reduce(
150 // WS Generic Output:
151 Numeric& o,
152 // WS Input:
153 // WS Generic Input:
154 const Tensor3& i,
155 const Verbosity&) {
156 if (i.ncols() == 1 && i.nrows() == 1 && i.npages() == 1)
157 o = i(0, 0, 0);
158 else {
159 ostringstream os;
160 os << "The Tensor3 is not also a Numeric";
161 throw std::runtime_error(os.str());
162 }
163}
164
165/* Workspace method: Doxygen documentation will be auto-generated */
166inline void Reduce(
167 // WS Generic Output:
168 Numeric& o,
169 // WS Input:
170 // WS Generic Input:
171 const Tensor4& i,
172 const Verbosity&) {
173 if (i.ncols() == 1 && i.nrows() == 1 && i.npages() == 1 && i.nbooks() == 1)
174 o = i(0, 0, 0, 0);
175 else {
176 ostringstream os;
177 os << "The Tensor4 is not also a Numeric";
178 throw std::runtime_error(os.str());
179 }
180}
181
182/* Workspace method: Doxygen documentation will be auto-generated */
183inline void Reduce(
184 // WS Generic Output:
185 Numeric& o,
186 // WS Input:
187 // WS Generic Input:
188 const Tensor5& i,
189 const Verbosity&) {
190 if (i.ncols() == 1 && i.nrows() == 1 && i.npages() == 1 && i.nbooks() == 1 &&
191 i.nshelves() == 1)
192 o = i(0, 0, 0, 0, 0);
193 else {
194 ostringstream os;
195 os << "The Tensor5 is not also a Numeric";
196 throw std::runtime_error(os.str());
197 }
198}
199
200/* Workspace method: Doxygen documentation will be auto-generated */
201inline void Reduce(
202 // WS Generic Output:
203 Numeric& o,
204 // WS Input:
205 // WS Generic Input:
206 const Tensor6& i,
207 const Verbosity&) {
208 if (i.ncols() == 1 && i.nrows() == 1 && i.npages() == 1 && i.nbooks() == 1 &&
209 i.nshelves() == 1 && i.nvitrines() == 1)
210 o = i(0, 0, 0, 0, 0, 0);
211 else {
212 ostringstream os;
213 os << "The Tensor6 is not also a Numeric";
214 throw std::runtime_error(os.str());
215 }
216}
217
218/* Workspace method: Doxygen documentation will be auto-generated */
219inline void Reduce(
220 // WS Generic Output:
221 Numeric& o,
222 // WS Input:
223 // WS Generic Input:
224 const Tensor7& i,
225 const Verbosity&) {
226 if (i.ncols() == 1 && i.nrows() == 1 && i.npages() == 1 && i.nbooks() == 1 &&
227 i.nshelves() == 1 && i.nvitrines() == 1 && i.nlibraries() == 1)
228 o = i(0, 0, 0, 0, 0, 0, 0);
229 else {
230 ostringstream os;
231 os << "The Tensor7 is not also a Numeric";
232 throw std::runtime_error(os.str());
233 }
234}
235
236//To Vector
237
238/* Workspace method: Doxygen documentation will be auto-generated */
239inline void Reduce(
240 // WS Generic Output:
241 Vector& o,
242 // WS Input:
243 // WS Generic Input:
244 const Matrix& i,
245 const Verbosity&) {
246 ArrayOfIndex dim_sizes;
247 Index test = 1;
248
249 select_dims_by_size(dim_sizes, 1, i);
250 Index num = dim_sizes.nelem();
251 if (num == test) {
252 o.resize(dim_sizes[0]);
253 memcpy(o.data_handle(),
254 i.data_handle(),
255 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
256 } else {
257 ostringstream os;
258 os << "The Matrix of size (" << dim_sizes << ") \n"
259 << "does not fit a Vector";
260 throw std::runtime_error(os.str());
261 }
262}
263
264/* Workspace method: Doxygen documentation will be auto-generated */
265inline void Reduce(
266 // WS Generic Output:
267 Vector& o,
268 // WS Input:
269 // WS Generic Input:
270 const Tensor3& i,
271 const Verbosity&) {
272 ArrayOfIndex dim_sizes;
273 Index test = 1;
274
275 select_dims_by_size(dim_sizes, 1, i);
276 Index num = dim_sizes.nelem();
277 if (num == test) {
278 o.resize(dim_sizes[0]);
279 memcpy(o.data_handle(),
280 i.data_handle(),
281 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
282 } else {
283 ostringstream os;
284 os << "The Tensor3 of size (" << dim_sizes << ") \n"
285 << "does not fit a Vector";
286 throw std::runtime_error(os.str());
287 }
288}
289
290/* Workspace method: Doxygen documentation will be auto-generated */
291inline void Reduce(
292 // WS Generic Output:
293 Vector& o,
294 // WS Input:
295 // WS Generic Input:
296 const Tensor4& i,
297 const Verbosity&) {
298 ArrayOfIndex dim_sizes;
299 Index test = 1;
300
301 select_dims_by_size(dim_sizes, 1, i);
302 Index num = dim_sizes.nelem();
303 if (num == test) {
304 o.resize(dim_sizes[0]);
305 memcpy(o.data_handle(),
306 i.data_handle(),
307 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
308 } else {
309 ostringstream os;
310 os << "The Tensor4 of size (" << dim_sizes << ") \n"
311 << "does not fit a Vector";
312 throw std::runtime_error(os.str());
313 }
314}
315
316/* Workspace method: Doxygen documentation will be auto-generated */
317inline void Reduce(
318 // WS Generic Output:
319 Vector& o,
320 // WS Input:
321 // WS Generic Input:
322 const Tensor5& i,
323 const Verbosity&) {
324 ArrayOfIndex dim_sizes;
325 Index test = 1;
326
327 select_dims_by_size(dim_sizes, 1, i);
328 Index num = dim_sizes.nelem();
329 if (num == test) {
330 o.resize(dim_sizes[0]);
331 memcpy(o.data_handle(),
332 i.data_handle(),
333 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
334 } else {
335 ostringstream os;
336 os << "The Tensor5 of size (" << dim_sizes << ") \n"
337 << "does not fit a Vector";
338 throw std::runtime_error(os.str());
339 }
340}
341
342/* Workspace method: Doxygen documentation will be auto-generated */
343inline void Reduce(
344 // WS Generic Output:
345 Vector& o,
346 // WS Input:
347 // WS Generic Input:
348 const Tensor6& i,
349 const Verbosity&) {
350 ArrayOfIndex dim_sizes;
351 Index test = 1;
352
353 select_dims_by_size(dim_sizes, 1, i);
354 Index num = dim_sizes.nelem();
355 if (num == test) {
356 o.resize(dim_sizes[0]);
357 memcpy(o.data_handle(),
358 i.data_handle(),
359 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
360 } else {
361 ostringstream os;
362 os << "The Tensor6 of size (" << dim_sizes << ") \n"
363 << "does not fit a Vector";
364 throw std::runtime_error(os.str());
365 }
366}
367
368/* Workspace method: Doxygen documentation will be auto-generated */
369inline void Reduce(
370 // WS Generic Output:
371 Vector& o,
372 // WS Input:
373 // WS Generic Input:
374 const Tensor7& i,
375 const Verbosity&) {
376 ArrayOfIndex dim_sizes;
377 Index test = 1;
378
379 select_dims_by_size(dim_sizes, 1, i);
380 Index num = dim_sizes.nelem();
381 if (num == test) {
382 o.resize(dim_sizes[0]);
383 memcpy(o.data_handle(),
384 i.data_handle(),
385 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
386 } else {
387 ostringstream os;
388 os << "The Tensor7 of size (" << dim_sizes << ") \n"
389 << "does not fit a Vector";
390 throw std::runtime_error(os.str());
391 }
392}
393
394// To Matrix
395
396/* Workspace method: Doxygen documentation will be auto-generated */
397inline void Reduce(
398 // WS Generic Output:
399 Matrix& o,
400 // WS Input:
401 // WS Generic Input:
402 const Tensor3& i,
403 const Verbosity&) {
404 ArrayOfIndex dim_sizes;
405 Index test = 2;
406
407 select_dims_by_size(dim_sizes, 1, i);
408 Index num = dim_sizes.nelem();
409 if (num == test) {
410 o.resize(dim_sizes[0], dim_sizes[1]);
411 memcpy(o.data_handle(),
412 i.data_handle(),
413 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
414 } else {
415 ostringstream os;
416 os << "The Tensor3 of size (" << dim_sizes << ") \n"
417 << "does not fit a Matrix";
418 throw std::runtime_error(os.str());
419 }
420}
421
422/* Workspace method: Doxygen documentation will be auto-generated */
423inline void Reduce(
424 // WS Generic Output:
425 Matrix& o,
426 // WS Input:
427 // WS Generic Input:
428 const Tensor4& i,
429 const Verbosity&) {
430 ArrayOfIndex dim_sizes;
431 Index test = 2;
432
433 select_dims_by_size(dim_sizes, 1, i);
434 Index num = dim_sizes.nelem();
435 if (num == test) {
436 o.resize(dim_sizes[0], dim_sizes[1]);
437 memcpy(o.data_handle(),
438 i.data_handle(),
439 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
440 } else {
441 ostringstream os;
442 os << "The Tensor4 of size (" << dim_sizes << ") \n"
443 << "does not fit a Matrix";
444 throw std::runtime_error(os.str());
445 }
446}
447
448/* Workspace method: Doxygen documentation will be auto-generated */
449inline void Reduce(
450 // WS Generic Output:
451 Matrix& o,
452 // WS Input:
453 // WS Generic Input:
454 const Tensor5& i,
455 const Verbosity&) {
456 ArrayOfIndex dim_sizes;
457 Index test = 2;
458
459 select_dims_by_size(dim_sizes, 1, i);
460 Index num = dim_sizes.nelem();
461 if (num == test) {
462 o.resize(dim_sizes[0], dim_sizes[1]);
463 memcpy(o.data_handle(),
464 i.data_handle(),
465 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
466 } else {
467 ostringstream os;
468 os << "The Tensor5 of size (" << dim_sizes << ") \n"
469 << "does not fit a Matrix";
470 throw std::runtime_error(os.str());
471 }
472}
473
474/* Workspace method: Doxygen documentation will be auto-generated */
475inline void Reduce(
476 // WS Generic Output:
477 Matrix& o,
478 // WS Input:
479 // WS Generic Input:
480 const Tensor6& i,
481 const Verbosity&) {
482 ArrayOfIndex dim_sizes;
483 Index test = 2;
484
485 select_dims_by_size(dim_sizes, 1, i);
486 Index num = dim_sizes.nelem();
487 if (num == test) {
488 o.resize(dim_sizes[0], dim_sizes[1]);
489 memcpy(o.data_handle(),
490 i.data_handle(),
491 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
492 } else {
493 ostringstream os;
494 os << "The Tensor6 of size (" << dim_sizes << ") \n"
495 << "does not fit a Matrix";
496 throw std::runtime_error(os.str());
497 }
498}
499
500/* Workspace method: Doxygen documentation will be auto-generated */
501inline void Reduce(
502 // WS Generic Output:
503 Matrix& o,
504 // WS Input:
505 // WS Generic Input:
506 const Tensor7& i,
507 const Verbosity&) {
508 ArrayOfIndex dim_sizes;
509 Index test = 2;
510
511 select_dims_by_size(dim_sizes, 1, i);
512 Index num = dim_sizes.nelem();
513 if (num == test) {
514 o.resize(dim_sizes[0], dim_sizes[1]);
515 memcpy(o.data_handle(),
516 i.data_handle(),
517 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
518 } else {
519 ostringstream os;
520 os << "The Tensor7 of size (" << dim_sizes << ") \n"
521 << "does not fit a Matrix";
522 throw std::runtime_error(os.str());
523 }
524}
525
526// To Tensor 3
527
528/* Workspace method: Doxygen documentation will be auto-generated */
529inline void Reduce(
530 // WS Generic Output:
531 Tensor3& o,
532 // WS Input:
533 // WS Generic Input:
534 const Tensor4& i,
535 const Verbosity&) {
536 ArrayOfIndex dim_sizes;
537 Index test = 3;
538
539 select_dims_by_size(dim_sizes, 1, i);
540 Index num = dim_sizes.nelem();
541 if (num == test) {
542 o.resize(dim_sizes[0], dim_sizes[1], dim_sizes[2]);
543 memcpy(o.data_handle(),
544 i.data_handle(),
545 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
546 } else {
547 ostringstream os;
548 os << "The Tensor4 of size (" << dim_sizes << ") \n"
549 << "does not fit a Tensor3";
550 throw std::runtime_error(os.str());
551 }
552}
553
554/* Workspace method: Doxygen documentation will be auto-generated */
555inline void Reduce(
556 // WS Generic Output:
557 Tensor3& o,
558 // WS Input:
559 // WS Generic Input:
560 const Tensor5& i,
561 const Verbosity&) {
562 ArrayOfIndex dim_sizes;
563 Index test = 3;
564
565 select_dims_by_size(dim_sizes, 1, i);
566 Index num = dim_sizes.nelem();
567 if (num == test) {
568 o.resize(dim_sizes[0], dim_sizes[1], dim_sizes[2]);
569 memcpy(o.data_handle(),
570 i.data_handle(),
571 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
572 } else {
573 ostringstream os;
574 os << "The Tensor5 of size (" << dim_sizes << ") \n"
575 << "does not fit a Tensor3";
576 throw std::runtime_error(os.str());
577 }
578}
579
580/* Workspace method: Doxygen documentation will be auto-generated */
581inline void Reduce(
582 // WS Generic Output:
583 Tensor3& o,
584 // WS Input:
585 // WS Generic Input:
586 const Tensor6& i,
587 const Verbosity&) {
588 ArrayOfIndex dim_sizes;
589 Index test = 3;
590
591 select_dims_by_size(dim_sizes, 1, i);
592 Index num = dim_sizes.nelem();
593 if (num == test) {
594 o.resize(dim_sizes[0], dim_sizes[1], dim_sizes[2]);
595 memcpy(o.data_handle(),
596 i.data_handle(),
597 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
598 } else {
599 ostringstream os;
600 os << "The Tensor6 of size (" << dim_sizes << ") \n"
601 << "does not fit a Tensor3";
602 throw std::runtime_error(os.str());
603 }
604}
605
606/* Workspace method: Doxygen documentation will be auto-generated */
607inline void Reduce(
608 // WS Generic Output:
609 Tensor3& o,
610 // WS Input:
611 // WS Generic Input:
612 const Tensor7& i,
613 const Verbosity&) {
614 ArrayOfIndex dim_sizes;
615 Index test = 3;
616
617 select_dims_by_size(dim_sizes, 1, i);
618 Index num = dim_sizes.nelem();
619 if (num == test) {
620 o.resize(dim_sizes[0], dim_sizes[1], dim_sizes[2]);
621 memcpy(o.data_handle(),
622 i.data_handle(),
623 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
624 } else {
625 ostringstream os;
626 os << "The Tensor7 of size (" << dim_sizes << ") \n"
627 << "does not fit a Tensor3";
628 throw std::runtime_error(os.str());
629 }
630}
631
632// To Tensor4
633
634/* Workspace method: Doxygen documentation will be auto-generated */
635inline void Reduce(
636 // WS Generic Output:
637 Tensor4& o,
638 // WS Input:
639 // WS Generic Input:
640 const Tensor5& i,
641 const Verbosity&) {
642 ArrayOfIndex dim_sizes;
643 Index test = 4;
644
645 select_dims_by_size(dim_sizes, 1, i);
646 Index num = dim_sizes.nelem();
647 if (num == test) {
648 o.resize(dim_sizes[0], dim_sizes[1], dim_sizes[2], dim_sizes[3]);
649 memcpy(o.data_handle(),
650 i.data_handle(),
651 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
652 } else {
653 ostringstream os;
654 os << "The Tensor5 of size (" << dim_sizes << ") \n"
655 << "does not fit a Tensor4";
656 throw std::runtime_error(os.str());
657 }
658}
659
660/* Workspace method: Doxygen documentation will be auto-generated */
661inline void Reduce(
662 // WS Generic Output:
663 Tensor4& o,
664 // WS Input:
665 // WS Generic Input:
666 const Tensor6& i,
667 const Verbosity&) {
668 ArrayOfIndex dim_sizes;
669 Index test = 4;
670
671 select_dims_by_size(dim_sizes, 1, i);
672 Index num = dim_sizes.nelem();
673 if (num == test) {
674 o.resize(dim_sizes[0], dim_sizes[1], dim_sizes[2], dim_sizes[3]);
675 memcpy(o.data_handle(),
676 i.data_handle(),
677 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
678 } else {
679 ostringstream os;
680 os << "The Tensor6 of size (" << dim_sizes << ") \n"
681 << "does not fit a Tensor4";
682 throw std::runtime_error(os.str());
683 }
684}
685
686/* Workspace method: Doxygen documentation will be auto-generated */
687inline void Reduce(
688 // WS Generic Output:
689 Tensor4& o,
690 // WS Input:
691 // WS Generic Input:
692 const Tensor7& i,
693 const Verbosity&) {
694 ArrayOfIndex dim_sizes;
695 Index test = 4;
696
697 select_dims_by_size(dim_sizes, 1, i);
698 Index num = dim_sizes.nelem();
699 if (num == test) {
700 o.resize(dim_sizes[0], dim_sizes[1], dim_sizes[2], dim_sizes[3]);
701 memcpy(o.data_handle(),
702 i.data_handle(),
703 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
704 } else {
705 ostringstream os;
706 os << "The Tensor7 of size (" << dim_sizes << ") \n"
707 << "does not fit a Tensor4";
708 throw std::runtime_error(os.str());
709 }
710}
711
712// To Tensor5
713
714/* Workspace method: Doxygen documentation will be auto-generated */
715inline void Reduce(
716 // WS Generic Output:
717 Tensor5& o,
718 // WS Input:
719 // WS Generic Input:
720 const Tensor6& i,
721 const Verbosity&) {
722 ArrayOfIndex dim_sizes;
723 Index test = 5;
724
725 select_dims_by_size(dim_sizes, 1, i);
726 Index num = dim_sizes.nelem();
727 if (num == test) {
728 o.resize(
729 dim_sizes[0], dim_sizes[1], dim_sizes[2], dim_sizes[3], dim_sizes[4]);
730 memcpy(o.data_handle(),
731 i.data_handle(),
732 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
733 } else {
734 ostringstream os;
735 os << "The Tensor6 of size (" << dim_sizes << ") \n"
736 << "does not fit a Tensor5";
737 throw std::runtime_error(os.str());
738 }
739}
740
741/* Workspace method: Doxygen documentation will be auto-generated */
742inline void Reduce(
743 // WS Generic Output:
744 Tensor5& o,
745 // WS Input:
746 // WS Generic Input:
747 const Tensor7& i,
748 const Verbosity&) {
749 ArrayOfIndex dim_sizes;
750 Index test = 5;
751
752 select_dims_by_size(dim_sizes, 1, i);
753 Index num = dim_sizes.nelem();
754 if (num == test) {
755 o.resize(
756 dim_sizes[0], dim_sizes[1], dim_sizes[2], dim_sizes[3], dim_sizes[4]);
757 memcpy(o.data_handle(),
758 i.data_handle(),
759 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
760 } else {
761 ostringstream os;
762 os << "The Tensor7 of size (" << dim_sizes << ") \n"
763 << "does not fit a Tensor5";
764 throw std::runtime_error(os.str());
765 }
766}
767
768// To Tensor6
769
770/* Workspace method: Doxygen documentation will be auto-generated */
771inline void Reduce(
772 // WS Generic Output:
773 Tensor6& o,
774 // WS Input:
775 // WS Generic Input:
776 const Tensor7& i,
777 const Verbosity&) {
778 ArrayOfIndex dim_sizes;
779 Index test = 6;
780
781 select_dims_by_size(dim_sizes, 1, i);
782 Index num = dim_sizes.nelem();
783 if (num == test) {
784 o.resize(dim_sizes[0],
785 dim_sizes[1],
786 dim_sizes[2],
787 dim_sizes[3],
788 dim_sizes[4],
789 dim_sizes[5]);
790 memcpy(o.data_handle(),
791 i.data_handle(),
792 sizeof(Numeric) * num_elem_from_dim_sizes(dim_sizes));
793 } else {
794 ostringstream os;
795 os << "The Tensor7 of size (" << dim_sizes << ") \n"
796 << "does not fit a Tensor6";
797 throw std::runtime_error(os.str());
798 }
799}
800
801#endif /* m_reduce_h */
This file contains the definition of Array.
Index nelem() const ARTS_NOEXCEPT
Definition array.h:75
The declarations of all the exception classes.
void Reduce(Numeric &o, const Vector &i, const Verbosity &)
WORKSPACE METHOD: Reduce.
Definition m_reduce.h:115
Index num_elem_from_dim_sizes(const ArrayOfIndex &dim_sizes)
Definition m_reduce.h:23
void select_dims_by_size(ArrayOfIndex &dim_sizes, const Index min_num_elem, const Vector &type)
Definition m_reduce.h:34