27 using std::setprecision;
41 for (
Index i = 0; i < b; i++)
42 for (
Index j = 0; j < p; j++)
43 for (
Index k = 0; k < r; k++)
44 for (
Index l = 0; l < c; l++)
45 t(i, j, k, l) = (
Numeric)(fill++);
56 for (
Index i = 0; i < s; i++)
57 for (
Index j = 0; j < b; j++)
58 for (
Index k = 0; k < p; k++)
59 for (
Index l = 0; l < r; l++)
60 for (
Index m = 0; m < c; m++)
61 t(i, j, k, l, m) = (
Numeric)(fill++);
72 cout <<
"Test Tensor4:\n\n";
76 cout <<
"Dimensions of tensor a:\n"
78 <<
", row = " << a.
nrows() <<
", column = " << a.
ncols()
81 cout <<
"\nmin(a) = " <<
min(a)
82 <<
", max(a) = " <<
max(a)
86 cout <<
"Second book:\n"
90 cout <<
"First letter of every page of every book:\n"
94 cout <<
"First rows of second page of every book\n"
98 cout <<
"Third column of third page of first book\n"
102 cout <<
"Substract 10 from each element of the second book:\n"
109 cout <<
"b =\n" << b <<
'\n';
117 cout <<
"a =\n" << a <<
"\n\n";
121 cout <<
"After taking the square-root:\n" << setprecision(3) << a <<
'\n';
129 a[0].resize(2, 1, 4, 5);
133 cout <<
"a =\n" << a <<
'\n';
142 cout <<
"Test Tensor5:\n\n";
148 cout <<
"Dimensions of tensor a:\n"
150 <<
", book = " << a.
nbooks() <<
", page = " << a.
npages()
151 <<
", row = " << a.
nrows() <<
", column = " << a.
ncols()
154 cout <<
"\nmin(a) = " <<
min(a)
155 <<
", max(a) = " <<
max(a)
159 cout <<
"Second shelf:\n"
163 cout <<
"First rows of every second page of every book and every shelf:\n"
167 cout <<
"First and second letter of third column "
168 <<
"of every page and every book of first shelf:\n"
172 cout <<
"Last two letters of last row of second and third page "
173 <<
"of every book and every shelf:\n"
175 a.nrows() - 1,
Range(a.ncols() - 2, 2))
180 Tensor4 b(3, 2, a.nrows(), a.ncols(), 4);
186 cout <<
"b =\n" << b <<
'\n';
195 cout <<
"u =\n" << u <<
"\n\nv =\n" << v <<
"\n\n";
199 cout <<
"After element-vise addition with tensor v:\n"
200 <<
"u =\n" << u <<
'\n';
219 for (
Index is = 0; is < s; is++)
220 for (
Index iv = 0; iv < v; iv++)
221 for (
Index ib = 0; ib < b; ib++)
222 for (
Index ip = 0; ip < p; ip++)
223 for (
Index ir = 0; ir < r; ir++)
224 for (
Index ic = 0; ic < c; ic++)
225 x(iv, is, ib, ip, ir, ic)
226 = (
Numeric)(ic + ir*10 + ip*100 + ib*1000 + is*10000 + iv*100000);
231 cout <<
"Test Tensor6:\n\n";
239 cout <<
"Dimensions of tensor a:\n"
241 <<
"shelf = " << a.
nshelves() <<
"\n"
242 <<
"book = " << a.
nbooks() <<
"\n"
243 <<
"page = " << a.
npages() <<
"\n"
244 <<
"row = " << a.
nrows() <<
"\n"
245 <<
"column = " << a.
ncols() <<
"\n\n";
247 cout <<
"a(1,1,1,1,1,1) = " << a(1,1,1,1,1,1) <<
"\n\n";
249 cout <<
"a(1,1,1,1,Range(joker),1) = " << a(1,1,1,1,
Range(
joker),1) <<
"\n\n";
269 for (
Index il = 0; il < l; il++)
270 for (
Index is = 0; is < s; is++)
271 for (
Index iv = 0; iv < v; iv++)
272 for (
Index ib = 0; ib < b; ib++)
273 for (
Index ip = 0; ip < p; ip++)
274 for (
Index ir = 0; ir < r; ir++)
275 for (
Index ic = 0; ic < c; ic++)
276 x(il, iv, is, ib, ip, ir, ic)
277 = (
Numeric)(ic + ir*10 + ip*100 + ib*1000 + is*10000 + iv*100000 + il*1000000);
282 cout <<
"Test Tensor7:\n\n";
286 2, 3, 2, 2, 3, 3, 4);
291 cout <<
"Dimensions of tensor a:\n"
294 <<
"shelf = " << a.
nshelves() <<
"\n"
295 <<
"book = " << a.
nbooks() <<
"\n"
296 <<
"page = " << a.
npages() <<
"\n"
297 <<
"row = " << a.
nrows() <<
"\n"
298 <<
"column = " << a.
ncols() <<
"\n\n";
300 cout <<
"a(1,1,1,1,1,1,1) = " << setprecision(10)
301 << a(1,1,1,1,1,1,1) <<
"\n\n";
303 cout <<
"a(1,1,1,1,1,Range(joker),1) = " << setprecision(10)
309 cout <<
"Test Tensor7:\n"
310 <<
"The output of this test should be all ones!\n\n";
314 2, 3, 2, 2, 3, 3, 4);
322 cout << setprecision(10) << a(I,I,I,I,I,I,I) <<
"\n";
323 cout << setprecision(10) << a(I,I,I,I,I,I,R) <<
"\n";
324 cout << setprecision(10) << a(I,I,I,I,I,R,I) <<
"\n";
325 cout << setprecision(10) << a(I,I,I,I,I,R,R) <<
"\n";
326 cout << setprecision(10) << a(I,I,I,I,R,I,I) <<
"\n";
327 cout << setprecision(10) << a(I,I,I,I,R,I,R) <<
"\n";
328 cout << setprecision(10) << a(I,I,I,I,R,R,I) <<
"\n";
329 cout << setprecision(10) << a(I,I,I,I,R,R,R) <<
"\n";
330 cout << setprecision(10) << a(I,I,I,R,I,I,I) <<
"\n";
331 cout << setprecision(10) << a(I,I,I,R,I,I,R) <<
"\n";
332 cout << setprecision(10) << a(I,I,I,R,I,R,I) <<
"\n";
333 cout << setprecision(10) << a(I,I,I,R,I,R,R) <<
"\n";
334 cout << setprecision(10) << a(I,I,I,R,R,I,I) <<
"\n";
335 cout << setprecision(10) << a(I,I,I,R,R,I,R) <<
"\n";
336 cout << setprecision(10) << a(I,I,I,R,R,R,I) <<
"\n";
337 cout << setprecision(10) << a(I,I,I,R,R,R,R) <<
"\n";
338 cout << setprecision(10) << a(I,I,R,I,I,I,I) <<
"\n";
339 cout << setprecision(10) << a(I,I,R,I,I,I,R) <<
"\n";
340 cout << setprecision(10) << a(I,I,R,I,I,R,I) <<
"\n";
341 cout << setprecision(10) << a(I,I,R,I,I,R,R) <<
"\n";
342 cout << setprecision(10) << a(I,I,R,I,R,I,I) <<
"\n";
343 cout << setprecision(10) << a(I,I,R,I,R,I,R) <<
"\n";
344 cout << setprecision(10) << a(I,I,R,I,R,R,I) <<
"\n";
345 cout << setprecision(10) << a(I,I,R,I,R,R,R) <<
"\n";
346 cout << setprecision(10) << a(I,I,R,R,I,I,I) <<
"\n";
347 cout << setprecision(10) << a(I,I,R,R,I,I,R) <<
"\n";
348 cout << setprecision(10) << a(I,I,R,R,I,R,I) <<
"\n";
349 cout << setprecision(10) << a(I,I,R,R,I,R,R) <<
"\n";
350 cout << setprecision(10) << a(I,I,R,R,R,I,I) <<
"\n";
351 cout << setprecision(10) << a(I,I,R,R,R,I,R) <<
"\n";
352 cout << setprecision(10) << a(I,I,R,R,R,R,I) <<
"\n";
353 cout << setprecision(10) << a(I,I,R,R,R,R,R) <<
"\n";
354 cout << setprecision(10) << a(I,R,I,I,I,I,I) <<
"\n";
355 cout << setprecision(10) << a(I,R,I,I,I,I,R) <<
"\n";
356 cout << setprecision(10) << a(I,R,I,I,I,R,I) <<
"\n";
357 cout << setprecision(10) << a(I,R,I,I,I,R,R) <<
"\n";
358 cout << setprecision(10) << a(I,R,I,I,R,I,I) <<
"\n";
359 cout << setprecision(10) << a(I,R,I,I,R,I,R) <<
"\n";
360 cout << setprecision(10) << a(I,R,I,I,R,R,I) <<
"\n";
361 cout << setprecision(10) << a(I,R,I,I,R,R,R) <<
"\n";
362 cout << setprecision(10) << a(I,R,I,R,I,I,I) <<
"\n";
363 cout << setprecision(10) << a(I,R,I,R,I,I,R) <<
"\n";
364 cout << setprecision(10) << a(I,R,I,R,I,R,I) <<
"\n";
365 cout << setprecision(10) << a(I,R,I,R,I,R,R) <<
"\n";
366 cout << setprecision(10) << a(I,R,I,R,R,I,I) <<
"\n";
367 cout << setprecision(10) << a(I,R,I,R,R,I,R) <<
"\n";
368 cout << setprecision(10) << a(I,R,I,R,R,R,I) <<
"\n";
369 cout << setprecision(10) << a(I,R,I,R,R,R,R) <<
"\n";
370 cout << setprecision(10) << a(I,R,R,I,I,I,I) <<
"\n";
371 cout << setprecision(10) << a(I,R,R,I,I,I,R) <<
"\n";
372 cout << setprecision(10) << a(I,R,R,I,I,R,I) <<
"\n";
373 cout << setprecision(10) << a(I,R,R,I,I,R,R) <<
"\n";
374 cout << setprecision(10) << a(I,R,R,I,R,I,I) <<
"\n";
375 cout << setprecision(10) << a(I,R,R,I,R,I,R) <<
"\n";
376 cout << setprecision(10) << a(I,R,R,I,R,R,I) <<
"\n";
377 cout << setprecision(10) << a(I,R,R,I,R,R,R) <<
"\n";
378 cout << setprecision(10) << a(I,R,R,R,I,I,I) <<
"\n";
379 cout << setprecision(10) << a(I,R,R,R,I,I,R) <<
"\n";
380 cout << setprecision(10) << a(I,R,R,R,I,R,I) <<
"\n";
381 cout << setprecision(10) << a(I,R,R,R,I,R,R) <<
"\n";
382 cout << setprecision(10) << a(I,R,R,R,R,I,I) <<
"\n";
383 cout << setprecision(10) << a(I,R,R,R,R,I,R) <<
"\n";
384 cout << setprecision(10) << a(I,R,R,R,R,R,I) <<
"\n";
385 cout << setprecision(10) << a(I,R,R,R,R,R,R) <<
"\n";
386 cout << setprecision(10) << a(R,I,I,I,I,I,I) <<
"\n";
387 cout << setprecision(10) << a(R,I,I,I,I,I,R) <<
"\n";
388 cout << setprecision(10) << a(R,I,I,I,I,R,I) <<
"\n";
389 cout << setprecision(10) << a(R,I,I,I,I,R,R) <<
"\n";
390 cout << setprecision(10) << a(R,I,I,I,R,I,I) <<
"\n";
391 cout << setprecision(10) << a(R,I,I,I,R,I,R) <<
"\n";
392 cout << setprecision(10) << a(R,I,I,I,R,R,I) <<
"\n";
393 cout << setprecision(10) << a(R,I,I,I,R,R,R) <<
"\n";
394 cout << setprecision(10) << a(R,I,I,R,I,I,I) <<
"\n";
395 cout << setprecision(10) << a(R,I,I,R,I,I,R) <<
"\n";
396 cout << setprecision(10) << a(R,I,I,R,I,R,I) <<
"\n";
397 cout << setprecision(10) << a(R,I,I,R,I,R,R) <<
"\n";
398 cout << setprecision(10) << a(R,I,I,R,R,I,I) <<
"\n";
399 cout << setprecision(10) << a(R,I,I,R,R,I,R) <<
"\n";
400 cout << setprecision(10) << a(R,I,I,R,R,R,I) <<
"\n";
401 cout << setprecision(10) << a(R,I,I,R,R,R,R) <<
"\n";
402 cout << setprecision(10) << a(R,I,R,I,I,I,I) <<
"\n";
403 cout << setprecision(10) << a(R,I,R,I,I,I,R) <<
"\n";
404 cout << setprecision(10) << a(R,I,R,I,I,R,I) <<
"\n";
405 cout << setprecision(10) << a(R,I,R,I,I,R,R) <<
"\n";
406 cout << setprecision(10) << a(R,I,R,I,R,I,I) <<
"\n";
407 cout << setprecision(10) << a(R,I,R,I,R,I,R) <<
"\n";
408 cout << setprecision(10) << a(R,I,R,I,R,R,I) <<
"\n";
409 cout << setprecision(10) << a(R,I,R,I,R,R,R) <<
"\n";
410 cout << setprecision(10) << a(R,I,R,R,I,I,I) <<
"\n";
411 cout << setprecision(10) << a(R,I,R,R,I,I,R) <<
"\n";
412 cout << setprecision(10) << a(R,I,R,R,I,R,I) <<
"\n";
413 cout << setprecision(10) << a(R,I,R,R,I,R,R) <<
"\n";
414 cout << setprecision(10) << a(R,I,R,R,R,I,I) <<
"\n";
415 cout << setprecision(10) << a(R,I,R,R,R,I,R) <<
"\n";
416 cout << setprecision(10) << a(R,I,R,R,R,R,I) <<
"\n";
417 cout << setprecision(10) << a(R,I,R,R,R,R,R) <<
"\n";
418 cout << setprecision(10) << a(R,R,I,I,I,I,I) <<
"\n";
419 cout << setprecision(10) << a(R,R,I,I,I,I,R) <<
"\n";
420 cout << setprecision(10) << a(R,R,I,I,I,R,I) <<
"\n";
421 cout << setprecision(10) << a(R,R,I,I,I,R,R) <<
"\n";
422 cout << setprecision(10) << a(R,R,I,I,R,I,I) <<
"\n";
423 cout << setprecision(10) << a(R,R,I,I,R,I,R) <<
"\n";
424 cout << setprecision(10) << a(R,R,I,I,R,R,I) <<
"\n";
425 cout << setprecision(10) << a(R,R,I,I,R,R,R) <<
"\n";
426 cout << setprecision(10) << a(R,R,I,R,I,I,I) <<
"\n";
427 cout << setprecision(10) << a(R,R,I,R,I,I,R) <<
"\n";
428 cout << setprecision(10) << a(R,R,I,R,I,R,I) <<
"\n";
429 cout << setprecision(10) << a(R,R,I,R,I,R,R) <<
"\n";
430 cout << setprecision(10) << a(R,R,I,R,R,I,I) <<
"\n";
431 cout << setprecision(10) << a(R,R,I,R,R,I,R) <<
"\n";
432 cout << setprecision(10) << a(R,R,I,R,R,R,I) <<
"\n";
433 cout << setprecision(10) << a(R,R,I,R,R,R,R) <<
"\n";
434 cout << setprecision(10) << a(R,R,R,I,I,I,I) <<
"\n";
435 cout << setprecision(10) << a(R,R,R,I,I,I,R) <<
"\n";
436 cout << setprecision(10) << a(R,R,R,I,I,R,I) <<
"\n";
437 cout << setprecision(10) << a(R,R,R,I,I,R,R) <<
"\n";
438 cout << setprecision(10) << a(R,R,R,I,R,I,I) <<
"\n";
439 cout << setprecision(10) << a(R,R,R,I,R,I,R) <<
"\n";
440 cout << setprecision(10) << a(R,R,R,I,R,R,I) <<
"\n";
441 cout << setprecision(10) << a(R,R,R,I,R,R,R) <<
"\n";
442 cout << setprecision(10) << a(R,R,R,R,I,I,I) <<
"\n";
443 cout << setprecision(10) << a(R,R,R,R,I,I,R) <<
"\n";
444 cout << setprecision(10) << a(R,R,R,R,I,R,I) <<
"\n";
445 cout << setprecision(10) << a(R,R,R,R,I,R,R) <<
"\n";
446 cout << setprecision(10) << a(R,R,R,R,R,I,I) <<
"\n";
447 cout << setprecision(10) << a(R,R,R,R,R,I,R) <<
"\n";
448 cout << setprecision(10) << a(R,R,R,R,R,R,I) <<
"\n";
449 cout << setprecision(10) << a(R,R,R,R,R,R,R) <<
"\n";
454 cout <<
"Test Tensor7:\n"
455 <<
"The output of this test should be 128\n\n";
457 Tensor7 a(2, 3, 2, 2, 3, 3, 4, 0.0);
466 a(I,I,I,I,I,I,I) += 1;
467 a(I,I,I,I,I,I,R) += 1;
468 a(I,I,I,I,I,R,I) += 1;
469 a(I,I,I,I,I,R,R) += 1;
470 a(I,I,I,I,R,I,I) += 1;
471 a(I,I,I,I,R,I,R) += 1;
472 a(I,I,I,I,R,R,I) += 1;
473 a(I,I,I,I,R,R,R) += 1;
474 a(I,I,I,R,I,I,I) += 1;
475 a(I,I,I,R,I,I,R) += 1;
476 a(I,I,I,R,I,R,I) += 1;
477 a(I,I,I,R,I,R,R) += 1;
478 a(I,I,I,R,R,I,I) += 1;
479 a(I,I,I,R,R,I,R) += 1;
480 a(I,I,I,R,R,R,I) += 1;
481 a(I,I,I,R,R,R,R) += 1;
482 a(I,I,R,I,I,I,I) += 1;
483 a(I,I,R,I,I,I,R) += 1;
484 a(I,I,R,I,I,R,I) += 1;
485 a(I,I,R,I,I,R,R) += 1;
486 a(I,I,R,I,R,I,I) += 1;
487 a(I,I,R,I,R,I,R) += 1;
488 a(I,I,R,I,R,R,I) += 1;
489 a(I,I,R,I,R,R,R) += 1;
490 a(I,I,R,R,I,I,I) += 1;
491 a(I,I,R,R,I,I,R) += 1;
492 a(I,I,R,R,I,R,I) += 1;
493 a(I,I,R,R,I,R,R) += 1;
494 a(I,I,R,R,R,I,I) += 1;
495 a(I,I,R,R,R,I,R) += 1;
496 a(I,I,R,R,R,R,I) += 1;
497 a(I,I,R,R,R,R,R) += 1;
498 a(I,R,I,I,I,I,I) += 1;
499 a(I,R,I,I,I,I,R) += 1;
500 a(I,R,I,I,I,R,I) += 1;
501 a(I,R,I,I,I,R,R) += 1;
502 a(I,R,I,I,R,I,I) += 1;
503 a(I,R,I,I,R,I,R) += 1;
504 a(I,R,I,I,R,R,I) += 1;
505 a(I,R,I,I,R,R,R) += 1;
506 a(I,R,I,R,I,I,I) += 1;
507 a(I,R,I,R,I,I,R) += 1;
508 a(I,R,I,R,I,R,I) += 1;
509 a(I,R,I,R,I,R,R) += 1;
510 a(I,R,I,R,R,I,I) += 1;
511 a(I,R,I,R,R,I,R) += 1;
512 a(I,R,I,R,R,R,I) += 1;
513 a(I,R,I,R,R,R,R) += 1;
514 a(I,R,R,I,I,I,I) += 1;
515 a(I,R,R,I,I,I,R) += 1;
516 a(I,R,R,I,I,R,I) += 1;
517 a(I,R,R,I,I,R,R) += 1;
518 a(I,R,R,I,R,I,I) += 1;
519 a(I,R,R,I,R,I,R) += 1;
520 a(I,R,R,I,R,R,I) += 1;
521 a(I,R,R,I,R,R,R) += 1;
522 a(I,R,R,R,I,I,I) += 1;
523 a(I,R,R,R,I,I,R) += 1;
524 a(I,R,R,R,I,R,I) += 1;
525 a(I,R,R,R,I,R,R) += 1;
526 a(I,R,R,R,R,I,I) += 1;
527 a(I,R,R,R,R,I,R) += 1;
528 a(I,R,R,R,R,R,I) += 1;
529 a(I,R,R,R,R,R,R) += 1;
530 a(R,I,I,I,I,I,I) += 1;
531 a(R,I,I,I,I,I,R) += 1;
532 a(R,I,I,I,I,R,I) += 1;
533 a(R,I,I,I,I,R,R) += 1;
534 a(R,I,I,I,R,I,I) += 1;
535 a(R,I,I,I,R,I,R) += 1;
536 a(R,I,I,I,R,R,I) += 1;
537 a(R,I,I,I,R,R,R) += 1;
538 a(R,I,I,R,I,I,I) += 1;
539 a(R,I,I,R,I,I,R) += 1;
540 a(R,I,I,R,I,R,I) += 1;
541 a(R,I,I,R,I,R,R) += 1;
542 a(R,I,I,R,R,I,I) += 1;
543 a(R,I,I,R,R,I,R) += 1;
544 a(R,I,I,R,R,R,I) += 1;
545 a(R,I,I,R,R,R,R) += 1;
546 a(R,I,R,I,I,I,I) += 1;
547 a(R,I,R,I,I,I,R) += 1;
548 a(R,I,R,I,I,R,I) += 1;
549 a(R,I,R,I,I,R,R) += 1;
550 a(R,I,R,I,R,I,I) += 1;
551 a(R,I,R,I,R,I,R) += 1;
552 a(R,I,R,I,R,R,I) += 1;
553 a(R,I,R,I,R,R,R) += 1;
554 a(R,I,R,R,I,I,I) += 1;
555 a(R,I,R,R,I,I,R) += 1;
556 a(R,I,R,R,I,R,I) += 1;
557 a(R,I,R,R,I,R,R) += 1;
558 a(R,I,R,R,R,I,I) += 1;
559 a(R,I,R,R,R,I,R) += 1;
560 a(R,I,R,R,R,R,I) += 1;
561 a(R,I,R,R,R,R,R) += 1;
562 a(R,R,I,I,I,I,I) += 1;
563 a(R,R,I,I,I,I,R) += 1;
564 a(R,R,I,I,I,R,I) += 1;
565 a(R,R,I,I,I,R,R) += 1;
566 a(R,R,I,I,R,I,I) += 1;
567 a(R,R,I,I,R,I,R) += 1;
568 a(R,R,I,I,R,R,I) += 1;
569 a(R,R,I,I,R,R,R) += 1;
570 a(R,R,I,R,I,I,I) += 1;
571 a(R,R,I,R,I,I,R) += 1;
572 a(R,R,I,R,I,R,I) += 1;
573 a(R,R,I,R,I,R,R) += 1;
574 a(R,R,I,R,R,I,I) += 1;
575 a(R,R,I,R,R,I,R) += 1;
576 a(R,R,I,R,R,R,I) += 1;
577 a(R,R,I,R,R,R,R) += 1;
578 a(R,R,R,I,I,I,I) += 1;
579 a(R,R,R,I,I,I,R) += 1;
580 a(R,R,R,I,I,R,I) += 1;
581 a(R,R,R,I,I,R,R) += 1;
582 a(R,R,R,I,R,I,I) += 1;
583 a(R,R,R,I,R,I,R) += 1;
584 a(R,R,R,I,R,R,I) += 1;
585 a(R,R,R,I,R,R,R) += 1;
586 a(R,R,R,R,I,I,I) += 1;
587 a(R,R,R,R,I,I,R) += 1;
588 a(R,R,R,R,I,R,I) += 1;
589 a(R,R,R,R,I,R,R) += 1;
590 a(R,R,R,R,R,I,I) += 1;
591 a(R,R,R,R,R,I,R) += 1;
592 a(R,R,R,R,R,R,I) += 1;
593 a(R,R,R,R,R,R,R) += 1;
595 cout <<
"The sum is: " << a(I,I,I,I,I,I,I) <<
"\n";