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