ARTS  2.4.0(git:4fb77825)
test_tensor.cc
Go to the documentation of this file.
1 /* Copyright (C) 2002-2012
2  Stefan Buehler <sbuehler@ltu.se>
3  Wolfram-Andre Haas <wolhaas@hermes.fho-emden.de>
4 
5  This program is free software; you can redistribute it and/or modify it
6  under the terms of the GNU General Public License as published by the
7  Free Software Foundation; either version 2, or (at your option) any
8  later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18  USA. */
19 
20 #include <cmath>
21 #include <iostream>
22 
23 #include "array.h"
24 #include "matpackVII.h"
25 
26 using std::cout;
27 using std::setprecision;
28 
29 /* --------------------------------------------------------------
30  Helper functions for filling tensors with running numbers,
31  starting with start = 1 (default).
32  -------------------------------------------------------------- */
33 
35  Tensor4 t(b, p, r, c);
36 
37  Index fill = start;
38 
39  for (Index i = 0; i < b; i++)
40  for (Index j = 0; j < p; j++)
41  for (Index k = 0; k < r; k++)
42  for (Index l = 0; l < c; l++) t(i, j, k, l) = (Numeric)(fill++);
43 
44  return t;
45 }
46 
48  Index s, Index b, Index p, Index r, Index c, Index start = 1) {
49  Tensor5 t(s, b, p, r, c);
50 
51  Index fill = start;
52 
53  for (Index i = 0; i < s; i++)
54  for (Index j = 0; j < b; j++)
55  for (Index k = 0; k < p; k++)
56  for (Index l = 0; l < r; l++)
57  for (Index m = 0; m < c; m++) t(i, j, k, l, m) = (Numeric)(fill++);
58 
59  return t;
60 }
61 
62 /*********************
63  * Tests for Tensor4 *
64  *********************/
65 
66 void test1() {
67  cout << "Test Tensor4:\n\n";
68 
69  Tensor4 a = fill_tensor4(2, 3, 3, 4); // 2 books, 3 pages, 3 rows, 4 columns
70 
71  cout << "Dimensions of tensor a:\n"
72  << "book = " << a.nbooks() << ", page = " << a.npages()
73  << ", row = " << a.nrows() << ", column = " << a.ncols() << '\n';
74 
75  cout << "\nmin(a) = " << min(a) << ", max(a) = " << max(a) << "\n\na=\n"
76  << a << "\n\n";
77 
78  cout << "Second book:\n"
79  << a(1, Range(joker), Range(joker), Range(joker)) << "\n\n";
80 
81  cout << "First letter of every page of every book:\n"
82  << a(Range(joker), Range(joker), 0, 0) << "\n\n";
83 
84  cout << "First rows of second page of every book\n"
85  << a(Range(joker), 1, 0, Range(joker)) << "\n\n";
86 
87  cout << "Third column of third page of first book\n"
88  << a(0, 2, Range(joker), 2) << "\n\n";
89 
90  cout << "Substract 10 from each element of the second book:\n"
91  << (a(1, Range(joker), Range(joker), Range(joker)) -= 10) << "\n\n";
92 
93  // Create a sub-tensor of Tensor4
94  Tensor4View b = a(Range(joker), Range(0, 2), Range(joker), Range(1, 3));
95 
96  cout << "b =\n" << b << '\n';
97 }
98 
99 void test2() {
100  Tensor4 a = fill_tensor4(2, 2, 4, 5, 4); // Fill a with running numbers,
101  // starting with 4
102 
103  cout << "a =\n" << a << "\n\n";
104 
105  transform(a, sqrt, a);
106 
107  cout << "After taking the square-root:\n" << setprecision(3) << a << '\n';
108 }
109 
110 void test3() {
111  ArrayOfTensor4 a(2);
112  Tensor4 b(2, 2, 2, 3, 1.5);
113 
114  a[0].resize(2, 1, 4, 5);
115  a[0] = 3;
116  a[1] = b;
117 
118  cout << "a =\n" << a << '\n';
119 }
120 
121 /*********************
122  * Tests for Tensor5 *
123  *********************/
124 
125 void test4() {
126  cout << "Test Tensor5:\n\n";
127 
128  Tensor5 a = fill_tensor5(2, 2, 3, 3, 4); // 2 shelves,
129  // 2 books, 3 pages,
130  // 3 rows, 4 columns
131 
132  cout << "Dimensions of tensor a:\n"
133  << "shelf = " << a.nshelves() << ", book = " << a.nbooks()
134  << ", page = " << a.npages() << ", row = " << a.nrows()
135  << ", column = " << a.ncols() << '\n';
136 
137  cout << "\nmin(a) = " << min(a) << ", max(a) = " << max(a) << "\n\na=\n"
138  << a << "\n\n";
139 
140  cout << "Second shelf:\n"
141  << a(1, Range(joker), Range(joker), Range(joker), Range(joker))
142  << "\n\n";
143 
144  cout << "First rows of every second page of every book and every shelf:\n"
145  << a(Range(joker), Range(joker), Range(0, joker, 2), 0, Range(joker))
146  << "\n\n";
147 
148  cout << "First and second letter of third column "
149  << "of every page and every book of first shelf:\n"
150  << a(0, Range(joker), Range(joker), Range(0, 2), 2) << "\n\n";
151 
152  cout << "Last two letters of last row of second and third page "
153  << "of every book and every shelf:\n"
154  << a(Range(joker),
155  Range(joker),
156  Range(1, 2),
157  a.nrows() - 1,
158  Range(a.ncols() - 2, 2))
159  << "\n\n";
160 
161  // Assignment between Tensor5 and Tensor4
162 
163  Tensor4 b(3, 2, a.nrows(), a.ncols(), 4);
164 
165  // Copy the first two pages of a shelf 1, book 1 to b book 2, page 1-2
166  b(1, Range(joker), Range(joker), Range(joker)) =
167  a(0, 0, Range(0, 2), Range(joker), Range(joker));
168 
169  cout << "b =\n" << b << '\n';
170 }
171 
172 void test5() {
173  Tensor5 u = fill_tensor5(2, 3, 3, 2, 3);
174  Tensor5 v = fill_tensor5(2, 3, 3, 2, 3, 5); // Fill v with running numbers,
175  // starting with 5
176 
177  cout << "u =\n" << u << "\n\nv =\n" << v << "\n\n";
178 
179  u += v;
180 
181  cout << "After element-vise addition with tensor v:\n"
182  << "u =\n"
183  << u << '\n';
184 }
185 
186 /*********************
187  * Tests for Tensor6 *
188  *********************/
189 
191  Tensor6& x, Index v, Index s, Index b, Index p, Index r, Index c) {
192  // Lets fill the tensor with special values, so that we can
193  // immediately see the vitrine, shelf, etc.
194  // 345123 shall mean vitrine 3, shelf 4, book 5, and so on.
195  //
196  // Will work only if all dimensions are smaller 10.
197 
198  x.resize(v, s, b, p, r, c);
199 
200  for (Index is = 0; is < s; is++)
201  for (Index iv = 0; iv < v; iv++)
202  for (Index ib = 0; ib < b; ib++)
203  for (Index ip = 0; ip < p; ip++)
204  for (Index ir = 0; ir < r; ir++)
205  for (Index ic = 0; ic < c; ic++)
206  x(iv, is, ib, ip, ir, ic) =
207  (Numeric)(ic + ir * 10 + ip * 100 + ib * 1000 + is * 10000 +
208  iv * 100000);
209 }
210 
211 void test6() {
212  cout << "Test Tensor6:\n\n";
213 
214  Tensor6 a;
215  fill_tensor6(a, 3, 2, 2, 3, 3, 4); // 3 vitrines, 2 shelves,
216  // 2 books, 3 pages,
217  // 3 rows, 4 columns
218 
219  cout << "Dimensions of tensor a:\n"
220  << "vitrine = " << a.nvitrines() << "\n"
221  << "shelf = " << a.nshelves() << "\n"
222  << "book = " << a.nbooks() << "\n"
223  << "page = " << a.npages() << "\n"
224  << "row = " << a.nrows() << "\n"
225  << "column = " << a.ncols() << "\n\n";
226 
227  cout << "a(1,1,1,1,1,1) = " << a(1, 1, 1, 1, 1, 1) << "\n\n";
228 
229  cout << "a(1,1,1,1,Range(joker),1) = " << a(1, 1, 1, 1, Range(joker), 1)
230  << "\n\n";
231 }
232 
233 /*********************
234  * Tests for Tensor7 *
235  *********************/
236 
238  Tensor7& x, Index l, Index v, Index s, Index b, Index p, Index r, Index c) {
239  // Lets fill the tensor with special values, so that we can
240  // immediately see the vitrine, shelf, etc.
241  // 345123 shall mean vitrine 3, shelf 4, book 5, and so on.
242  //
243  // Will work only if all dimensions are smaller 10.
244 
245  x.resize(l, v, s, b, p, r, c);
246 
247  for (Index il = 0; il < l; il++)
248  for (Index is = 0; is < s; is++)
249  for (Index iv = 0; iv < v; iv++)
250  for (Index ib = 0; ib < b; ib++)
251  for (Index ip = 0; ip < p; ip++)
252  for (Index ir = 0; ir < r; ir++)
253  for (Index ic = 0; ic < c; ic++)
254  x(il, iv, is, ib, ip, ir, ic) =
255  (Numeric)(ic + ir * 10 + ip * 100 + ib * 1000 + is * 10000 +
256  iv * 100000 + il * 1000000);
257 }
258 
259 void test7() {
260  cout << "Test Tensor7:\n\n";
261 
262  Tensor7 a;
263  fill_tensor7(a, 2, 3, 2, 2, 3, 3, 4); // 2 libraries,
264  // 3 vitrines, 2 shelves,
265  // 2 books, 3 pages,
266  // 3 rows, 4 columns
267 
268  cout << "Dimensions of tensor a:\n"
269  << "libraries = " << a.nlibraries() << "\n"
270  << "vitrine = " << a.nvitrines() << "\n"
271  << "shelf = " << a.nshelves() << "\n"
272  << "book = " << a.nbooks() << "\n"
273  << "page = " << a.npages() << "\n"
274  << "row = " << a.nrows() << "\n"
275  << "column = " << a.ncols() << "\n\n";
276 
277  cout << "a(1,1,1,1,1,1,1) = " << setprecision(10) << a(1, 1, 1, 1, 1, 1, 1)
278  << "\n\n";
279 
280  cout << "a(1,1,1,1,1,Range(joker),1) = " << setprecision(10)
281  << a(1, 1, 1, 1, 1, Range(joker), 1) << "\n\n";
282 }
283 
284 void test8() {
285  cout << "Test Tensor7:\n"
286  << "The output of this test should be all ones!\n\n";
287 
288  Tensor7 a;
289  fill_tensor7(a, 2, 3, 2, 2, 3, 3, 4); // 2 libraries,
290  // 3 vitrines, 2 shelves,
291  // 2 books, 3 pages,
292  // 3 rows, 4 columns
293 
294  Index I(1); // Select element 1.
295  Range R(1, 1); // Select one element starting at index 1.
296 
297  cout << setprecision(10) << a(I, I, I, I, I, I, I) << "\n";
298  cout << setprecision(10) << a(I, I, I, I, I, I, R) << "\n";
299  cout << setprecision(10) << a(I, I, I, I, I, R, I) << "\n";
300  cout << setprecision(10) << a(I, I, I, I, I, R, R) << "\n";
301  cout << setprecision(10) << a(I, I, I, I, R, I, I) << "\n";
302  cout << setprecision(10) << a(I, I, I, I, R, I, R) << "\n";
303  cout << setprecision(10) << a(I, I, I, I, R, R, I) << "\n";
304  cout << setprecision(10) << a(I, I, I, I, R, R, R) << "\n";
305  cout << setprecision(10) << a(I, I, I, R, I, I, I) << "\n";
306  cout << setprecision(10) << a(I, I, I, R, I, I, R) << "\n";
307  cout << setprecision(10) << a(I, I, I, R, I, R, I) << "\n";
308  cout << setprecision(10) << a(I, I, I, R, I, R, R) << "\n";
309  cout << setprecision(10) << a(I, I, I, R, R, I, I) << "\n";
310  cout << setprecision(10) << a(I, I, I, R, R, I, R) << "\n";
311  cout << setprecision(10) << a(I, I, I, R, R, R, I) << "\n";
312  cout << setprecision(10) << a(I, I, I, R, R, R, R) << "\n";
313  cout << setprecision(10) << a(I, I, R, I, I, I, I) << "\n";
314  cout << setprecision(10) << a(I, I, R, I, I, I, R) << "\n";
315  cout << setprecision(10) << a(I, I, R, I, I, R, I) << "\n";
316  cout << setprecision(10) << a(I, I, R, I, I, R, R) << "\n";
317  cout << setprecision(10) << a(I, I, R, I, R, I, I) << "\n";
318  cout << setprecision(10) << a(I, I, R, I, R, I, R) << "\n";
319  cout << setprecision(10) << a(I, I, R, I, R, R, I) << "\n";
320  cout << setprecision(10) << a(I, I, R, I, R, R, R) << "\n";
321  cout << setprecision(10) << a(I, I, R, R, I, I, I) << "\n";
322  cout << setprecision(10) << a(I, I, R, R, I, I, R) << "\n";
323  cout << setprecision(10) << a(I, I, R, R, I, R, I) << "\n";
324  cout << setprecision(10) << a(I, I, R, R, I, R, R) << "\n";
325  cout << setprecision(10) << a(I, I, R, R, R, I, I) << "\n";
326  cout << setprecision(10) << a(I, I, R, R, R, I, R) << "\n";
327  cout << setprecision(10) << a(I, I, R, R, R, R, I) << "\n";
328  cout << setprecision(10) << a(I, I, R, R, R, R, R) << "\n";
329  cout << setprecision(10) << a(I, R, I, I, I, I, I) << "\n";
330  cout << setprecision(10) << a(I, R, I, I, I, I, R) << "\n";
331  cout << setprecision(10) << a(I, R, I, I, I, R, I) << "\n";
332  cout << setprecision(10) << a(I, R, I, I, I, R, R) << "\n";
333  cout << setprecision(10) << a(I, R, I, I, R, I, I) << "\n";
334  cout << setprecision(10) << a(I, R, I, I, R, I, R) << "\n";
335  cout << setprecision(10) << a(I, R, I, I, R, R, I) << "\n";
336  cout << setprecision(10) << a(I, R, I, I, R, R, R) << "\n";
337  cout << setprecision(10) << a(I, R, I, R, I, I, I) << "\n";
338  cout << setprecision(10) << a(I, R, I, R, I, I, R) << "\n";
339  cout << setprecision(10) << a(I, R, I, R, I, R, I) << "\n";
340  cout << setprecision(10) << a(I, R, I, R, I, R, R) << "\n";
341  cout << setprecision(10) << a(I, R, I, R, R, I, I) << "\n";
342  cout << setprecision(10) << a(I, R, I, R, R, I, R) << "\n";
343  cout << setprecision(10) << a(I, R, I, R, R, R, I) << "\n";
344  cout << setprecision(10) << a(I, R, I, R, R, R, R) << "\n";
345  cout << setprecision(10) << a(I, R, R, I, I, I, I) << "\n";
346  cout << setprecision(10) << a(I, R, R, I, I, I, R) << "\n";
347  cout << setprecision(10) << a(I, R, R, I, I, R, I) << "\n";
348  cout << setprecision(10) << a(I, R, R, I, I, R, R) << "\n";
349  cout << setprecision(10) << a(I, R, R, I, R, I, I) << "\n";
350  cout << setprecision(10) << a(I, R, R, I, R, I, R) << "\n";
351  cout << setprecision(10) << a(I, R, R, I, R, R, I) << "\n";
352  cout << setprecision(10) << a(I, R, R, I, R, R, R) << "\n";
353  cout << setprecision(10) << a(I, R, R, R, I, I, I) << "\n";
354  cout << setprecision(10) << a(I, R, R, R, I, I, R) << "\n";
355  cout << setprecision(10) << a(I, R, R, R, I, R, I) << "\n";
356  cout << setprecision(10) << a(I, R, R, R, I, R, R) << "\n";
357  cout << setprecision(10) << a(I, R, R, R, R, I, I) << "\n";
358  cout << setprecision(10) << a(I, R, R, R, R, I, R) << "\n";
359  cout << setprecision(10) << a(I, R, R, R, R, R, I) << "\n";
360  cout << setprecision(10) << a(I, R, R, R, R, R, R) << "\n";
361  cout << setprecision(10) << a(R, I, I, I, I, I, I) << "\n";
362  cout << setprecision(10) << a(R, I, I, I, I, I, R) << "\n";
363  cout << setprecision(10) << a(R, I, I, I, I, R, I) << "\n";
364  cout << setprecision(10) << a(R, I, I, I, I, R, R) << "\n";
365  cout << setprecision(10) << a(R, I, I, I, R, I, I) << "\n";
366  cout << setprecision(10) << a(R, I, I, I, R, I, R) << "\n";
367  cout << setprecision(10) << a(R, I, I, I, R, R, I) << "\n";
368  cout << setprecision(10) << a(R, I, I, I, R, R, R) << "\n";
369  cout << setprecision(10) << a(R, I, I, R, I, I, I) << "\n";
370  cout << setprecision(10) << a(R, I, I, R, I, I, R) << "\n";
371  cout << setprecision(10) << a(R, I, I, R, I, R, I) << "\n";
372  cout << setprecision(10) << a(R, I, I, R, I, R, R) << "\n";
373  cout << setprecision(10) << a(R, I, I, R, R, I, I) << "\n";
374  cout << setprecision(10) << a(R, I, I, R, R, I, R) << "\n";
375  cout << setprecision(10) << a(R, I, I, R, R, R, I) << "\n";
376  cout << setprecision(10) << a(R, I, I, R, R, R, R) << "\n";
377  cout << setprecision(10) << a(R, I, R, I, I, I, I) << "\n";
378  cout << setprecision(10) << a(R, I, R, I, I, I, R) << "\n";
379  cout << setprecision(10) << a(R, I, R, I, I, R, I) << "\n";
380  cout << setprecision(10) << a(R, I, R, I, I, R, R) << "\n";
381  cout << setprecision(10) << a(R, I, R, I, R, I, I) << "\n";
382  cout << setprecision(10) << a(R, I, R, I, R, I, R) << "\n";
383  cout << setprecision(10) << a(R, I, R, I, R, R, I) << "\n";
384  cout << setprecision(10) << a(R, I, R, I, R, R, R) << "\n";
385  cout << setprecision(10) << a(R, I, R, R, I, I, I) << "\n";
386  cout << setprecision(10) << a(R, I, R, R, I, I, R) << "\n";
387  cout << setprecision(10) << a(R, I, R, R, I, R, I) << "\n";
388  cout << setprecision(10) << a(R, I, R, R, I, R, R) << "\n";
389  cout << setprecision(10) << a(R, I, R, R, R, I, I) << "\n";
390  cout << setprecision(10) << a(R, I, R, R, R, I, R) << "\n";
391  cout << setprecision(10) << a(R, I, R, R, R, R, I) << "\n";
392  cout << setprecision(10) << a(R, I, R, R, R, R, R) << "\n";
393  cout << setprecision(10) << a(R, R, I, I, I, I, I) << "\n";
394  cout << setprecision(10) << a(R, R, I, I, I, I, R) << "\n";
395  cout << setprecision(10) << a(R, R, I, I, I, R, I) << "\n";
396  cout << setprecision(10) << a(R, R, I, I, I, R, R) << "\n";
397  cout << setprecision(10) << a(R, R, I, I, R, I, I) << "\n";
398  cout << setprecision(10) << a(R, R, I, I, R, I, R) << "\n";
399  cout << setprecision(10) << a(R, R, I, I, R, R, I) << "\n";
400  cout << setprecision(10) << a(R, R, I, I, R, R, R) << "\n";
401  cout << setprecision(10) << a(R, R, I, R, I, I, I) << "\n";
402  cout << setprecision(10) << a(R, R, I, R, I, I, R) << "\n";
403  cout << setprecision(10) << a(R, R, I, R, I, R, I) << "\n";
404  cout << setprecision(10) << a(R, R, I, R, I, R, R) << "\n";
405  cout << setprecision(10) << a(R, R, I, R, R, I, I) << "\n";
406  cout << setprecision(10) << a(R, R, I, R, R, I, R) << "\n";
407  cout << setprecision(10) << a(R, R, I, R, R, R, I) << "\n";
408  cout << setprecision(10) << a(R, R, I, R, R, R, R) << "\n";
409  cout << setprecision(10) << a(R, R, R, I, I, I, I) << "\n";
410  cout << setprecision(10) << a(R, R, R, I, I, I, R) << "\n";
411  cout << setprecision(10) << a(R, R, R, I, I, R, I) << "\n";
412  cout << setprecision(10) << a(R, R, R, I, I, R, R) << "\n";
413  cout << setprecision(10) << a(R, R, R, I, R, I, I) << "\n";
414  cout << setprecision(10) << a(R, R, R, I, R, I, R) << "\n";
415  cout << setprecision(10) << a(R, R, R, I, R, R, I) << "\n";
416  cout << setprecision(10) << a(R, R, R, I, R, R, R) << "\n";
417  cout << setprecision(10) << a(R, R, R, R, I, I, I) << "\n";
418  cout << setprecision(10) << a(R, R, R, R, I, I, R) << "\n";
419  cout << setprecision(10) << a(R, R, R, R, I, R, I) << "\n";
420  cout << setprecision(10) << a(R, R, R, R, I, R, R) << "\n";
421  cout << setprecision(10) << a(R, R, R, R, R, I, I) << "\n";
422  cout << setprecision(10) << a(R, R, R, R, R, I, R) << "\n";
423  cout << setprecision(10) << a(R, R, R, R, R, R, I) << "\n";
424  cout << setprecision(10) << a(R, R, R, R, R, R, R) << "\n";
425 }
426 
427 void test9() {
428  cout << "Test Tensor7:\n"
429  << "The output of this test should be 128\n\n";
430 
431  Tensor7 a(2, 3, 2, 2, 3, 3, 4, 0.0); // 2 libraries,
432  // 3 vitrines, 2 shelves,
433  // 2 books, 3 pages,
434  // 3 rows, 4 columns
435  // Fill with zeroes.
436 
437  Index I(1); // Select element 1.
438  Range R(1, 1); // Select one element starting at index 1.
439 
440  a(I, I, I, I, I, I, I) += 1;
441  a(I, I, I, I, I, I, R) += 1;
442  a(I, I, I, I, I, R, I) += 1;
443  a(I, I, I, I, I, R, R) += 1;
444  a(I, I, I, I, R, I, I) += 1;
445  a(I, I, I, I, R, I, R) += 1;
446  a(I, I, I, I, R, R, I) += 1;
447  a(I, I, I, I, R, R, R) += 1;
448  a(I, I, I, R, I, I, I) += 1;
449  a(I, I, I, R, I, I, R) += 1;
450  a(I, I, I, R, I, R, I) += 1;
451  a(I, I, I, R, I, R, R) += 1;
452  a(I, I, I, R, R, I, I) += 1;
453  a(I, I, I, R, R, I, R) += 1;
454  a(I, I, I, R, R, R, I) += 1;
455  a(I, I, I, R, R, R, R) += 1;
456  a(I, I, R, I, I, I, I) += 1;
457  a(I, I, R, I, I, I, R) += 1;
458  a(I, I, R, I, I, R, I) += 1;
459  a(I, I, R, I, I, R, R) += 1;
460  a(I, I, R, I, R, I, I) += 1;
461  a(I, I, R, I, R, I, R) += 1;
462  a(I, I, R, I, R, R, I) += 1;
463  a(I, I, R, I, R, R, R) += 1;
464  a(I, I, R, R, I, I, I) += 1;
465  a(I, I, R, R, I, I, R) += 1;
466  a(I, I, R, R, I, R, I) += 1;
467  a(I, I, R, R, I, R, R) += 1;
468  a(I, I, R, R, R, I, I) += 1;
469  a(I, I, R, R, R, I, R) += 1;
470  a(I, I, R, R, R, R, I) += 1;
471  a(I, I, R, R, R, R, R) += 1;
472  a(I, R, I, I, I, I, I) += 1;
473  a(I, R, I, I, I, I, R) += 1;
474  a(I, R, I, I, I, R, I) += 1;
475  a(I, R, I, I, I, R, R) += 1;
476  a(I, R, I, I, R, I, I) += 1;
477  a(I, R, I, I, R, I, R) += 1;
478  a(I, R, I, I, R, R, I) += 1;
479  a(I, R, I, I, R, R, R) += 1;
480  a(I, R, I, R, I, I, I) += 1;
481  a(I, R, I, R, I, I, R) += 1;
482  a(I, R, I, R, I, R, I) += 1;
483  a(I, R, I, R, I, R, R) += 1;
484  a(I, R, I, R, R, I, I) += 1;
485  a(I, R, I, R, R, I, R) += 1;
486  a(I, R, I, R, R, R, I) += 1;
487  a(I, R, I, R, R, R, R) += 1;
488  a(I, R, R, I, I, I, I) += 1;
489  a(I, R, R, I, I, I, R) += 1;
490  a(I, R, R, I, I, R, I) += 1;
491  a(I, R, R, I, I, R, R) += 1;
492  a(I, R, R, I, R, I, I) += 1;
493  a(I, R, R, I, R, I, R) += 1;
494  a(I, R, R, I, R, R, I) += 1;
495  a(I, R, R, I, R, R, R) += 1;
496  a(I, R, R, R, I, I, I) += 1;
497  a(I, R, R, R, I, I, R) += 1;
498  a(I, R, R, R, I, R, I) += 1;
499  a(I, R, R, R, I, R, R) += 1;
500  a(I, R, R, R, R, I, I) += 1;
501  a(I, R, R, R, R, I, R) += 1;
502  a(I, R, R, R, R, R, I) += 1;
503  a(I, R, R, R, R, R, R) += 1;
504  a(R, I, I, I, I, I, I) += 1;
505  a(R, I, I, I, I, I, R) += 1;
506  a(R, I, I, I, I, R, I) += 1;
507  a(R, I, I, I, I, R, R) += 1;
508  a(R, I, I, I, R, I, I) += 1;
509  a(R, I, I, I, R, I, R) += 1;
510  a(R, I, I, I, R, R, I) += 1;
511  a(R, I, I, I, R, R, R) += 1;
512  a(R, I, I, R, I, I, I) += 1;
513  a(R, I, I, R, I, I, R) += 1;
514  a(R, I, I, R, I, R, I) += 1;
515  a(R, I, I, R, I, R, R) += 1;
516  a(R, I, I, R, R, I, I) += 1;
517  a(R, I, I, R, R, I, R) += 1;
518  a(R, I, I, R, R, R, I) += 1;
519  a(R, I, I, R, R, R, R) += 1;
520  a(R, I, R, I, I, I, I) += 1;
521  a(R, I, R, I, I, I, R) += 1;
522  a(R, I, R, I, I, R, I) += 1;
523  a(R, I, R, I, I, R, R) += 1;
524  a(R, I, R, I, R, I, I) += 1;
525  a(R, I, R, I, R, I, R) += 1;
526  a(R, I, R, I, R, R, I) += 1;
527  a(R, I, R, I, R, R, R) += 1;
528  a(R, I, R, R, I, I, I) += 1;
529  a(R, I, R, R, I, I, R) += 1;
530  a(R, I, R, R, I, R, I) += 1;
531  a(R, I, R, R, I, R, R) += 1;
532  a(R, I, R, R, R, I, I) += 1;
533  a(R, I, R, R, R, I, R) += 1;
534  a(R, I, R, R, R, R, I) += 1;
535  a(R, I, R, R, R, R, R) += 1;
536  a(R, R, I, I, I, I, I) += 1;
537  a(R, R, I, I, I, I, R) += 1;
538  a(R, R, I, I, I, R, I) += 1;
539  a(R, R, I, I, I, R, R) += 1;
540  a(R, R, I, I, R, I, I) += 1;
541  a(R, R, I, I, R, I, R) += 1;
542  a(R, R, I, I, R, R, I) += 1;
543  a(R, R, I, I, R, R, R) += 1;
544  a(R, R, I, R, I, I, I) += 1;
545  a(R, R, I, R, I, I, R) += 1;
546  a(R, R, I, R, I, R, I) += 1;
547  a(R, R, I, R, I, R, R) += 1;
548  a(R, R, I, R, R, I, I) += 1;
549  a(R, R, I, R, R, I, R) += 1;
550  a(R, R, I, R, R, R, I) += 1;
551  a(R, R, I, R, R, R, R) += 1;
552  a(R, R, R, I, I, I, I) += 1;
553  a(R, R, R, I, I, I, R) += 1;
554  a(R, R, R, I, I, R, I) += 1;
555  a(R, R, R, I, I, R, R) += 1;
556  a(R, R, R, I, R, I, I) += 1;
557  a(R, R, R, I, R, I, R) += 1;
558  a(R, R, R, I, R, R, I) += 1;
559  a(R, R, R, I, R, R, R) += 1;
560  a(R, R, R, R, I, I, I) += 1;
561  a(R, R, R, R, I, I, R) += 1;
562  a(R, R, R, R, I, R, I) += 1;
563  a(R, R, R, R, I, R, R) += 1;
564  a(R, R, R, R, R, I, I) += 1;
565  a(R, R, R, R, R, I, R) += 1;
566  a(R, R, R, R, R, R, I) += 1;
567  a(R, R, R, R, R, R, R) += 1;
568 
569  cout << "The sum is: " << a(I, I, I, I, I, I, I) << "\n";
570 }
571 
572 int main() {
573  test9();
574  return 0;
575 }
transform
void transform(VectorView y, double(&my_func)(double), ConstVectorView x)
A generic transform function for vectors, which can be used to implement mathematical functions opera...
Definition: matpackI.cc:1476
test5
void test5()
Definition: test_tensor.cc:172
ConstTensor7View::nshelves
Index nshelves() const
Returns the number of shelves.
Definition: matpackVII.cc:48
ConstTensor6View::nshelves
Index nshelves() const
Returns the number of shelves.
Definition: matpackVI.cc:45
ConstTensor5View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackV.cc:47
test4
void test4()
Definition: test_tensor.cc:125
test6
void test6()
Definition: test_tensor.cc:211
fill_tensor4
Tensor4 fill_tensor4(Index b, Index p, Index r, Index c, Index start=1)
Definition: test_tensor.cc:34
ConstTensor5View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackV.cc:56
ConstTensor6View::npages
Index npages() const
Returns the number of pages.
Definition: matpackVI.cc:51
test2
void test2()
Definition: test_tensor.cc:99
ConstTensor7View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackVII.cc:60
joker
const Joker joker
test9
void test9()
Definition: test_tensor.cc:427
fill_tensor7
void fill_tensor7(Tensor7 &x, Index l, Index v, Index s, Index b, Index p, Index r, Index c)
Definition: test_tensor.cc:237
ConstTensor6View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackVI.cc:54
Tensor4
The Tensor4 class.
Definition: matpackIV.h:421
array.h
This file contains the definition of Array.
ConstTensor5View::npages
Index npages() const
Returns the number of pages.
Definition: matpackV.cc:50
test1
void test1()
Definition: test_tensor.cc:66
sqrt
Numeric sqrt(const Rational r)
Square root.
Definition: rational.h:620
ConstTensor7View::nlibraries
Index nlibraries() const
Returns the number of libraries.
Definition: matpackVII.cc:42
Array
This can be used to make arrays out of anything.
Definition: array.h:108
ConstTensor6View::nvitrines
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVI.cc:42
min
#define min(a, b)
Definition: legacy_continua.cc:20628
ConstTensor7View::nvitrines
Index nvitrines() const
Returns the number of vitrines.
Definition: matpackVII.cc:45
ConstTensor4View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackIV.cc:66
ConstTensor7View::npages
Index npages() const
Returns the number of pages.
Definition: matpackVII.cc:54
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
ConstTensor4View::npages
Index npages() const
Returns the number of pages.
Definition: matpackIV.cc:60
ConstTensor4View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackIV.cc:57
max
#define max(a, b)
Definition: legacy_continua.cc:20629
test7
void test7()
Definition: test_tensor.cc:259
ConstTensor6View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackVI.cc:48
Tensor5
The Tensor5 class.
Definition: matpackV.h:506
ConstTensor4View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackIV.cc:63
test8
void test8()
Definition: test_tensor.cc:284
Range
The range class.
Definition: matpackI.h:160
ConstTensor7View::nbooks
Index nbooks() const
Returns the number of books.
Definition: matpackVII.cc:51
ConstTensor5View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackV.cc:53
Zeeman::start
constexpr Rational start(Rational Ju, Rational Jl, Polarization type) noexcept
Gives the lowest M for a polarization type of this transition.
Definition: zeemandata.h:77
ConstTensor5View::nshelves
Index nshelves() const
Returns the number of shelves.
Definition: matpackV.cc:44
fill_tensor6
void fill_tensor6(Tensor6 &x, Index v, Index s, Index b, Index p, Index r, Index c)
Definition: test_tensor.cc:190
Tensor4View
The Tensor4View class.
Definition: matpackIV.h:284
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
ConstTensor7View::nrows
Index nrows() const
Returns the number of rows.
Definition: matpackVII.cc:57
Tensor6
The Tensor6 class.
Definition: matpackVI.h:1088
fill_tensor5
Tensor5 fill_tensor5(Index s, Index b, Index p, Index r, Index c, Index start=1)
Definition: test_tensor.cc:47
test3
void test3()
Definition: test_tensor.cc:110
main
int main()
Definition: test_tensor.cc:572
ConstTensor6View::ncols
Index ncols() const
Returns the number of columns.
Definition: matpackVI.cc:57
Tensor7
The Tensor7 class.
Definition: matpackVII.h:2382
matpackVII.h