39using std::runtime_error;
52 cout <<
"v.nelem() = " <<
v.nelem() <<
"\n";
56 cout <<
"v.begin() = " << *
v.begin() <<
"\n";
58 cout <<
"v = \n" <<
v <<
"\n";
65 cout <<
"v2 = \n" << v2 <<
"\n";
67 for (
Index i = 0; i < 1000; ++i) {
76 cout <<
"v = \n" <<
v <<
"\n";
77 cout <<
"v2 = \n" << v2 <<
"\n";
78 cout <<
"v2.nelem() = \n" << v2.
nelem() <<
"\n";
84 cout <<
"\nv3 = \n" << v3 <<
"\n";
86 cout <<
"\nv3 after junking v2 = \n" << v3 <<
"\n";
88 cout <<
"\nv3 after *2 = \n" << v3 <<
"\n";
93 for (
Index i = 0; i <
M.nrows(); ++i)
94 for (
Index j = 0; j <
M.ncols(); ++j)
M(i, j) = ++n;
97 cout <<
"\nM =\n" <<
M <<
"\n";
99 cout <<
"\nM(Range(2,4),Range(2,4)) =\n"
102 cout <<
"\nM(Range(2,4),Range(2,4))(Range(1,2),Range(1,2)) =\n"
105 cout <<
"\nM(1,Range(joker)) =\n" <<
M(1,
Range(
joker)) <<
"\n";
107 cout <<
"\nFilling M(1,Range(1,2)) with junk.\n";
110 cout <<
"\nM(Range(0,4),Range(0,4)) =\n"
113 cout <<
"\nFilling M(Range(4,2,2),Range(6,3)) with junk.\n";
118 cout <<
"\nM =\n" <<
M <<
"\n";
122 cout <<
"\nC(Range(3,4,2),Range(2,3,3)) =\n"
125 cout <<
"\nC(Range(3,4,2),Range(2,3,3)).transpose() =\n"
134 cout <<
"v.nelem() = " <<
v.nelem() <<
"\n";
147 for (
Index i = 0; i <
a.nelem(); ++i) {
152 cout <<
"a = \n" <<
a <<
"\n";
153 cout <<
"b = \n" <<
b <<
"\n";
154 cout <<
"a*b \n= " <<
a *
b <<
"\n";
166 cout <<
"\nB*C =\n" << A <<
"\n";
178 cout <<
"b = \n" <<
b <<
"\n";
179 cout <<
"M =\n" <<
M <<
"\n";
182 cout <<
"\na = M*b = \n" <<
a <<
"\n";
195 cout <<
"Transforming.\n";
199 for (
Index i = 0; i < 1000; ++i) {
213 cout <<
"min(sin(x)), max(sin(x)) = " <<
min(y) <<
", " <<
max(y) <<
"\n";
227 cout <<
"B = " << B <<
"\n";
237 cout <<
"M = " <<
M <<
"\n";
248 cout <<
"M = " <<
M <<
"\n";
261 cout <<
"sb = \n" << sb <<
"\n";
265 cout <<
"sc = \n" << sc <<
"\n";
275 cout <<
"M = \n" <<
M <<
"\n";
282 Array<Numeric> c{1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
283 cout <<
"a = \n" <<
a <<
"\n";
284 cout <<
"b = \n" <<
b <<
"\n";
285 cout <<
"c = \n" <<
c <<
"\n";
291 cout <<
"a = " <<
a <<
"\n";
293 cout <<
"b = " <<
b <<
"\n";
313 cout <<
"a.sum() = " <<
a.sum() <<
"\n";
320 cout <<
"a *= a =\n" <<
a <<
"\n";
330 cout <<
"a =\n" <<
a <<
"\n";
331 cout <<
"b =\n" <<
b <<
"\n";
336 Vector a{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
337 cout <<
"a =\n" <<
a <<
"\n";
343 cout <<
"By reference:\n";
348 cout <<
"s = " << s <<
"\n";
354 cout <<
"By value:\n";
359 cout <<
"s = " << s <<
"\n";
365 cout <<
"a =\n" <<
a <<
"\n";
367 cout <<
"b =\n" <<
b <<
"\n";
375 cout <<
"a*=b =\n" <<
a <<
"\n";
377 cout <<
"a/=b =\n" <<
a <<
"\n";
379 cout <<
"a+=b =\n" <<
a <<
"\n";
381 cout <<
"a-=b =\n" <<
a <<
"\n";
386 Array<Index> a{1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1};
387 cout <<
"min/max of a = " <<
min(
a) <<
"/" <<
max(
a) <<
"\n";
391 cout <<
"Test filling constructor for Array:\n";
393 cout <<
"a =\n" <<
a <<
"\n";
397 cout <<
"Test Arrays of Vectors:\n";
399 a.push_back({1.0, 2.0});
400 a.push_back(
Vector(1.0, 10, 1.0));
401 cout <<
"a =\n" <<
a <<
"\n";
405 cout <<
"Test default constructor for Matrix:\n";
408 cout <<
"b =\n" <<
b <<
"\n";
412 cout <<
"Test Arrays of Matrix:\n";
432 cout <<
"a =\n" <<
a <<
"\n";
436 cout <<
"Test Matrices of size 0:\n";
441 cout <<
"a =\n" <<
a <<
"\n";
445 b.resize(
b.nrows(),
b.ncols() + 3);
447 cout <<
"b =\n" <<
b <<
"\n";
451 c.resize(
c.nrows() + 3,
c.ncols());
453 cout <<
"c =\n" <<
c <<
"\n";
457 cout <<
"Test Tensor3:\n";
464 for (
Index i = 0; i <
a.npages(); ++i)
465 for (
Index j = 0; j <
a.nrows(); ++j)
466 for (
Index k = 0; k <
a.ncols(); ++k)
a(i, j, k) = (
Numeric)(++fill);
468 cout <<
"a =\n" <<
a <<
"\n";
470 cout <<
"Taking out first row of first page:\n"
473 cout <<
"Taking out last column of second page:\n"
476 cout <<
"Taking out the first letter on every page:\n"
479 cout <<
"Taking out first page:\n"
482 cout <<
"Taking out last row of all pages:\n"
485 cout <<
"Taking out second column of all pages:\n"
490 cout <<
"After element-vise multiplication with 2:\n" <<
a <<
"\n";
494 cout <<
"After taking the square-root:\n" <<
a <<
"\n";
497 cout <<
"Let's allocate a large tensor, "
498 << (
Numeric)(s * s * s * 8) / 1024. / 1024. <<
" MB...\n";
502 cout <<
"Set it to 1...\n";
506 cout <<
"a(900,900,900) = " <<
a(90, 90, 90) <<
"\n";
510 cout <<
"Fill with running numbers, using for loops...\n";
511 for (
Index i = 0; i <
a.npages(); ++i)
512 for (
Index j = 0; j <
a.nrows(); ++j)
513 for (
Index k = 0; k <
a.ncols(); ++k)
a(i, j, k) = (
Numeric)(++fill);
515 cout <<
"Max(a) = ...\n";
517 cout <<
max(
a) <<
"\n";
521 cout <<
"Test von X = A*X:\n";
522 Matrix X(3, 3), A(3, 3), B(3, 3);
524 for (
Index j = 0; j < A.nrows(); ++j)
525 for (
Index k = 0; k < A.ncols(); ++k) {
529 cout <<
"A:\n" << A <<
"\n";
530 cout <<
"X:\n" << X <<
"\n";
533 cout <<
"B = A*X:\n" << B <<
"\n";
535 cout <<
"X = A*X:\n" << X <<
"\n";
537 cout <<
"This is not the same, and should not be, because you\n"
538 <<
"are not allowed to use the same matrix as input and output\n"
543 cout <<
"Making things look bigger than they are...\n";
546 cout <<
"1. Make a scalar look like a vector:\n";
549 cout <<
"a, viewed as a vector: " << av <<
"\n";
550 cout <<
"Describe a: " <<
describe(
a) <<
"\n";
552 cout <<
"a, after the first element\n"
553 <<
"of the vector has been increased by 1: " <<
a <<
"\n";
558 <<
"\n2. Make a vector look like a matrix:\n"
559 <<
"This is an exception, because the new dimension is added at the end.\n";
562 cout <<
"a, viewed as a matrix:\n" << am <<
"\n";
563 cout <<
"Trasnpose view:\n" <<
transpose(am) <<
"\n";
566 cout <<
"\n3. Make a matrix look like a tensor3:\n";
568 cout <<
"at3 = \n" << at3 <<
"\n";
569 cout <<
"Describe at3: " <<
describe(at3) <<
"\n";
571 cout <<
"a after Increasing element at3(0,2,0) by 1: \n" <<
a <<
"\n\n";
574 cout <<
"at4 = \n" << at4 <<
"\n";
575 cout <<
"Describe at4: " <<
describe(at4) <<
"\n";
578 cout <<
"at5 = \n" << at5 <<
"\n";
579 cout <<
"Describe at5: " <<
describe(at5) <<
"\n";
582 cout <<
"at6 = \n" << at6 <<
"\n";
583 cout <<
"Describe at6: " <<
describe(at6) <<
"\n";
586 cout <<
"at7 = \n" << at7 <<
"\n";
587 cout <<
"Describe at7: " <<
describe(at7) <<
"\n";
589 at7(0, 0, 0, 0, 0, 2, 0) -= 1;
591 cout <<
"After subtracting 1 from at7(0,0,0,0,0,2,0)\n"
592 <<
"a = " <<
a <<
"\n";
594 cout <<
"\nAll in one go:\n";
598 cout <<
"bt7:\n" << bt7 <<
"\n";
599 cout <<
"Describe bt7: " <<
describe(bt7) <<
"\n";
608 cout <<
"Test, if dimension expansion works implicitly.\n";
618 cout <<
"Test the new copy semantics.\n";
623 cout <<
"b = " <<
b <<
"\n";
628 cout <<
"b = " <<
b <<
"\n";
633 cout <<
"b = " <<
b <<
"\n";
637 cout <<
"Test using naked joker on Vector.\n";
640 cout <<
"a = " <<
a <<
"\n";
641 cout <<
"b = " <<
b <<
"\n";
645 Vector v1(5e-15, 10, 0.42e-15 / 11);
666 cout << endl <<
"========================" << endl << endl;
674 cout << endl <<
"========================" << endl << endl;
685 Vector v1(1, 5, 1), v2(5);
709 cout <<
"Vector: " << v1 << endl;
710 cout <<
"VectorView: " << vv << endl;
714 }
catch (
const std::runtime_error& e) {
715 std::cerr << e.what() << endl;
719 cout <<
"VectorView: " << vv << endl;
720 cout <<
"Vector: " << v1 << endl;
728 Vector x{1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
729 cout <<
"x: " << x << endl;
732 cout <<
"y: " << y << endl;
735 cout <<
"z:\n" << z << endl;
737 cout <<
"Every other z:\n" << z(
Range(1, 2, 2),
joker) << endl;
742 cout <<
"zz:\n" << zz << endl;
743 cout <<
"New x: " << x << endl;
755 throw std::logic_error(
"Fail to initialize");;
763 static_assert(r.
numer == 3,
"Rational fail to initialize properly");
764 static_assert(r.
denom == 2,
"Rational fail to initialize properly");
768 static_assert(r2.
numer == 5,
"Rational fail to initialize properly");
769 static_assert(r2.
denom == 2,
"Rational fail to initialize properly");
773 static_assert(r3.
numer == 0,
"Rational fail to initialize properly");
774 static_assert(r3.
denom == 0,
"Rational fail to initialize properly");
775 static_assert(r3 not_eq r3,
"Undefined rational does not equal self");
776 static_assert(r3.
isUndefined(),
"Rational fail to initialize properly");
780 static_assert(r4.
numer == 0,
"Rational fail to initialize properly");
781 static_assert(r4.
denom == 1,
"Rational fail to initialize properly");
785 static_assert(r5.
numer == 1,
"Rational fail to initialize properly");
786 static_assert(r5.
denom == 6,
"Rational fail to initialize properly");
790 static_assert(r6.
numer == 1,
"Rational fail to initialize properly");
791 static_assert(r6.
denom == 1,
"Rational fail to initialize properly");
792 static_assert(r6.
toInt() == 1,
"Rational fail to initialize properly");
793 static_assert(r6.
toIndex() == 1,
"Rational fail to initialize properly");
794 static_assert(r6.
toNumeric() == 1e0,
"Rational fail to initialize properly");
796 constexpr Index rattest=1<<8;
798 static_assert(r7 == 2,
"Rational fail to initialize properly");
802#define docheck(fn, val, expect) \
803 cout << #fn << "(" << val << ") = " << fn(x) << " (expected " << #expect \
841 auto compare_func = [](
Numeric n) {
return n != 0; };
842 cout << std::any_of(v1.
begin(), v1.
end(), compare_func) << endl;
844 cout << std::any_of(v1.
begin(), v1.
end(), compare_func) << endl;
863 for (
Index i = 0; i < ntests; i++) {
879 for (
Index j = 0; j < n_diag; j++) {
880 pass = pass && (
v[j] == A(j, j));
881 pass = pass && (vt[j] == AT(j, j));
883 if (j < vb.
nelem()) pass = pass && (vb[j] == B(j, j));
889 cout <<
"test diagonal: Passed all tests." << endl;
891 cout <<
"test diagonal: Failed." << endl;
899 Vector x(n), xt, x_ref(n), y(m), y_ref(m);
904 for (
Index i = 0; i < ntests; i++) {
914 if (err_mul > max_err) max_err = err_mul;
917 cout <<
"\t A * x: max. rel. error = " << err_mul << endl;
926 if (err_mul > max_err) max_err = err_mul;
929 cout <<
"\t A^T * x: max. rel. error = " << err_mul << endl;
933 Index column_stride(random_column_stride()),
934 row_stride(random_row_stride());
937 m_sub = (m - 1) / row_stride + 1;
938 n_sub = (n - 1) / column_stride + 1;
950 if (err_mul > max_err) max_err = err_mul;
953 cout <<
"\t Random stride: max. rel. error = " << err_mul << endl << endl;
957 if ((m > 1) && (n > 1)) {
958 Index y_offset = rand() % (m - 1);
959 Index x_offset = rand() % (n - 1);
961 m_sub = m - y_offset - 1;
962 n_sub = n - x_offset - 1;
965 A(
Range(y_offset, m_sub),
Range(x_offset, n_sub)),
966 x[
Range(x_offset, n_sub)]);
968 A(
Range(y_offset, m_sub),
Range(x_offset, n_sub)),
969 x[
Range(x_offset, n_sub)]);
972 y[
Range(y_offset, m_sub)], y_ref[
Range(y_offset, m_sub)],
true);
973 if (err_mul > max_err) max_err = err_mul;
976 cout <<
"\t Random offset: max. rel. error = " << err_mul << endl
989 cout <<
"Matrix-Vector Multiplication: n = m = 100, ntests = 100" << endl;
994 cout <<
"Matrix-Vector Multiplication: n = 100, m = 20, ntests = 100"
999 if (err > max_err) max_err = err;
1002 cout <<
"Matrix-Vector Multiplication: n = 20, m = 100, ntests = 100"
1007 if (err > max_err) max_err = err;
1010 cout << endl <<
"Matrix Vector Multiplication: PASSED" << endl;
1012 cout << endl <<
"Matrix Vector Multiplication: FAILED" << endl;
1016 if (err > max_err) max_err = err;
1019 cout <<
"Matrix-Vector Multiplication: n = 20, m = 100, ntests = 100"
1024 if (err > max_err) max_err = err;
1027 cout <<
"Matrix-Vector Multiplication: n = 20, m = 100, ntests = 100"
1033 cout << endl <<
"Matrix Vector Multiplication: PASSED" << endl;
1035 cout << endl <<
"Matrix Vector Multiplication: FAILED" << endl;
1063 Matrix A(m, k), B(k, n), C(m, n), C_ref(m, n);
1065 for (
Index i = 0; i < ntests; i++) {
1071 cout <<
"MATRIX MULTIPLICATION: m = " << m <<
", k = " << k;
1072 cout <<
", n = " << n << endl;
1084 if (err_mul > max_err) max_err = err_mul;
1088 <<
"A * B: max. rel. error = " << err_mul << endl;
1099 if (err_trans1 > max_err) max_err = err_trans1;
1103 <<
"A^T * B: max. rel. err = " << err_trans1 << endl;
1114 if (err_trans2 > max_err) max_err = err_trans2;
1118 <<
"A * B^T: max. rel. err = " << err_trans2 << endl;
1126 if (err_trans3 > max_err) max_err = err_trans3;
1130 <<
"A^T * B^T: max. rel. err = " << err_trans3 << endl;
1136 Rand<Index> k_rand(1, k - 1), m_rand(1, m - 1), n_rand(1, n - 1);
1138 for (
Index i = 0; i < nsubtests - 1; i++) {
1139 Index k1(k_rand()), m1(m_rand()), n1(n_rand());
1151 mult(C_sub, A_sub, B_sub);
1155 if (err > max_err) max_err = err;
1159 <<
"Submatrix multiplication: max. rel. err = " << err;
1191 if (err > max_err) max_err = err;
1195 if (err > max_err) max_err = err;
1199 if (err > max_err) max_err = err;
1203 if (err > max_err) max_err = err;
1206 err =
matrix_mult(200, 200, 200, 20, 20, verbose);
1207 if (err > max_err) max_err = err;
1211 if (err > max_err) max_err = err;
1215 if (err > max_err) max_err = err;
1218 err =
matrix_mult(100, 100, 100, 0, 100, verbose);
1219 if (err > max_err) max_err = err;
1227 cout <<
"Array" << endl;
1230 cout <<
v.empty() << endl;
1232 cout <<
v.empty() << endl;
1235 cout <<
"Vector" << endl;
1238 cout <<
v.empty() << endl;
1240 cout <<
v.empty() << endl;
1243 cout <<
"Matrix" << endl;
1246 cout <<
v.empty() << endl;
1248 cout <<
v.empty() << endl;
1250 cout <<
v.empty() << endl;
1253 cout <<
"Tensor3" << endl;
1256 cout <<
v.empty() << endl;
1258 cout <<
v.empty() << endl;
1260 cout <<
v.empty() << endl;
1262 cout <<
v.empty() << endl;
1265 cout <<
"Tensor4" << endl;
1267 v.resize(0, 1, 1, 1);
1268 cout <<
v.empty() << endl;
1269 v.resize(1, 0, 1, 1);
1270 cout <<
v.empty() << endl;
1271 v.resize(1, 1, 0, 1);
1272 cout <<
v.empty() << endl;
1273 v.resize(1, 1, 1, 0);
1274 cout <<
v.empty() << endl;
1275 v.resize(1, 1, 1, 1);
1276 cout <<
v.empty() << endl;
1279 cout <<
"Tensor5" << endl;
1281 v.resize(0, 1, 1, 1, 1);
1282 cout <<
v.empty() << endl;
1283 v.resize(1, 0, 1, 1, 1);
1284 cout <<
v.empty() << endl;
1285 v.resize(1, 1, 0, 1, 1);
1286 cout <<
v.empty() << endl;
1287 v.resize(1, 1, 1, 0, 1);
1288 cout <<
v.empty() << endl;
1289 v.resize(1, 1, 1, 1, 0);
1290 cout <<
v.empty() << endl;
1291 v.resize(1, 1, 1, 1, 1);
1292 cout <<
v.empty() << endl;
1295 cout <<
"Tensor6" << endl;
1297 v.resize(0, 1, 1, 1, 1, 1);
1298 cout <<
v.empty() << endl;
1299 v.resize(1, 0, 1, 1, 1, 1);
1300 cout <<
v.empty() << endl;
1301 v.resize(1, 1, 0, 1, 1, 1);
1302 cout <<
v.empty() << endl;
1303 v.resize(1, 1, 1, 0, 1, 1);
1304 cout <<
v.empty() << endl;
1305 v.resize(1, 1, 1, 1, 0, 1);
1306 cout <<
v.empty() << endl;
1307 v.resize(1, 1, 1, 1, 1, 0);
1308 cout <<
v.empty() << endl;
1309 v.resize(1, 1, 1, 1, 1, 1);
1310 cout <<
v.empty() << endl;
1313 cout <<
"Tensor7" << endl;
1315 v.resize(0, 1, 1, 1, 1, 1, 1);
1316 cout <<
v.empty() << endl;
1317 v.resize(1, 0, 1, 1, 1, 1, 1);
1318 cout <<
v.empty() << endl;
1319 v.resize(1, 1, 0, 1, 1, 1, 1);
1320 cout <<
v.empty() << endl;
1321 v.resize(1, 1, 1, 0, 1, 1, 1);
1322 cout <<
v.empty() << endl;
1323 v.resize(1, 1, 1, 1, 0, 1, 1);
1324 cout <<
v.empty() << endl;
1325 v.resize(1, 1, 1, 1, 1, 0, 1);
1326 cout <<
v.empty() << endl;
1327 v.resize(1, 1, 1, 1, 1, 1, 0);
1328 cout <<
v.empty() << endl;
1329 v.resize(1, 1, 1, 1, 1, 1, 1);
1330 cout <<
v.empty() << endl;
1340 Numeric step = (stop - start) / ((
double)n - 1);
1341 for (
Index i = 0; i < n - 1; i++) x[i] = start + (
double)i * step;
1353 std::cout <<
"vv.nelem: " << vv.
nelem() << std::endl;
1354 std::cout <<
"mv.nrows: " << mv.
nrows() <<
" ";
1355 std::cout <<
"mv.ncols: " << mv.
ncols() << std::endl;
1359 std::cout <<
"mv2.nrows: " << mv2.
nrows() <<
" ";
1360 std::cout <<
"mv2.ncols: " << mv2.
ncols() << std::endl;
1366 std::cout <<
Tensor7(2, 2, 2, 2, 2, 2, 1, 8).
reduce_rank<0, 1, 2, 3, 4, 5>() <<
'\n';
1367 std::cout <<
Tensor7(2, 2, 2, 2, 2, 1, 1, 9).
reduce_rank<0, 1, 2, 3, 4>() <<
'\n';
1368 std::cout <<
Tensor7(2, 2, 2, 2, 1, 1, 1, 10).
reduce_rank<0, 1, 2, 3>() <<
'\n';
1372 std::cout <<
Tensor7(1, 1, 1, 1, 1, 1, 1, 14) <<
'\n';
1373 std::cout <<
Tensor6(2, 2, 2, 2, 2, 1, 15).
reduce_rank<0, 1, 2, 3, 4>() <<
'\n';
1378 std::cout <<
Tensor6(1, 1, 1, 1, 1, 1, 20) <<
'\n';
1383 std::cout <<
Tensor5(1, 1, 1, 1, 1, 25) <<
'\n';
1387 std::cout <<
Tensor4(1, 1, 1, 1, 29) <<
'\n';
1390 std::cout <<
Tensor3(1, 1, 1, 32) <<
'\n';
1392 std::cout <<
Matrix(1, 1, 34) <<
'\n';
1413 Tensor7 testvar(9, 2, 4, 3, 5, 7, 11);
for (
Index i=0; i<9; i++)
1414 for (
Index j=0; j<2; j++) {
1415 for (
Index k=0; k<4; k++) {
1416 for (
Index l=0; l<3; l++) {
1417 for (
Index m=0; m<5; m++) {
1418 for (
Index n=0; n<7; n++) {
1419 for (
Index o=0; o<11; o++) {
1420 testvar(i, j, k, l, m, n, o) =
Numeric(val++);
1429 for (
Index j=0; j<2; j++) {
1430 for (
Index k=0; k<4; k++) {
1431 for (
Index l=0; l<3; l++) {
1432 for (
Index m=0; m<5; m++) {
1433 for (
Index n=0; n<7; n++) {
1434 for (
Index o=0; o<11; o++) {
1435 std::cout <<
Tensor7(testvar(
joker,
Range(j, 1),
Range(k, 1),
Range(l, 1),
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<0>() <<
'\n';
1436 std::cout << testvar(
joker, j, k, l, m, n, o) <<
'\n';
1444 for (
Index i=0; i<9; i++) {
1445 for (
Index k=0; k<4; k++) {
1446 for (
Index l=0; l<3; l++) {
1447 for (
Index m=0; m<5; m++) {
1448 for (
Index n=0; n<7; n++) {
1449 for (
Index o=0; o<11; o++) {
1450 std::cout <<
Tensor7(testvar(
Range(i, 1),
joker,
Range(k, 1),
Range(l, 1),
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<1>() <<
'\n';
1451 std::cout << testvar(i,
joker, k, l, m, n, o) <<
'\n';
1459 for (
Index i=0; i<9; i++) {
1460 for (
Index j=0; j<2; j++) {
1461 for (
Index l=0; l<3; l++) {
1462 for (
Index m=0; m<5; m++) {
1463 for (
Index n=0; n<7; n++) {
1464 for (
Index o=0; o<11; o++) {
1465 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
joker,
Range(l, 1),
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<2>() <<
'\n';
1466 std::cout << testvar(i, j,
joker, l, m, n, o) <<
'\n';
1474 for (
Index i=0; i<9; i++) {
1475 for (
Index j=0; j<2; j++) {
1476 for (
Index k=0; k<4; k++) {
1477 for (
Index m=0; m<5; m++) {
1478 for (
Index n=0; n<7; n++) {
1479 for (
Index o=0; o<11; o++) {
1480 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
joker,
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<3>() <<
'\n';
1481 std::cout << testvar(i, j, k,
joker, m, n, o) <<
'\n';
1489 for (
Index i=0; i<9; i++) {
1490 for (
Index j=0; j<2; j++) {
1491 for (
Index k=0; k<4; k++) {
1492 for (
Index l=0; l<3; l++) {
1493 for (
Index n=0; n<7; n++) {
1494 for (
Index o=0; o<11; o++) {
1495 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
Range(l, 1),
joker,
Range(n, 1),
Range(o, 1))).
reduce_rank<4>() <<
'\n';
1496 std::cout << testvar(i, j, k, l,
joker, n, o) <<
'\n';
1504 for (
Index i=0; i<9; i++) {
1505 for (
Index j=0; j<2; j++) {
1506 for (
Index k=0; k<4; k++) {
1507 for (
Index l=0; l<3; l++) {
1508 for (
Index m=0; m<5; m++) {
1509 for (
Index o=0; o<11; o++) {
1510 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
Range(l, 1),
Range(m, 1),
joker,
Range(o, 1))).
reduce_rank<5>() <<
'\n';
1511 std::cout << testvar(i, j, k, l, m,
joker, o) <<
'\n';
1519 for (
Index i=0; i<9; i++) {
1520 for (
Index j=0; j<2; j++) {
1521 for (
Index k=0; k<4; k++) {
1522 for (
Index l=0; l<3; l++) {
1523 for (
Index m=0; m<5; m++) {
1524 for (
Index n=0; n<7; n++) {
1525 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
Range(l, 1),
Range(m, 1),
Range(n, 1),
joker)).
reduce_rank<6>() <<
'\n';
1526 std::cout << testvar(i, j, k, l, m, n,
joker) <<
'\n';
1536 for (
Index k=0; k<4; k++) {
1537 for (
Index l=0; l<3; l++) {
1538 for (
Index m=0; m<5; m++) {
1539 for (
Index n=0; n<7; n++) {
1540 for (
Index o=0; o<11; o++) {
1541 std::cout <<
Tensor7(testvar(
joker,
joker,
Range(k, 1),
Range(l, 1),
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<0, 1>() <<
'\n';
1542 std::cout << testvar(
joker,
joker, k, l, m, n, o) <<
'\n';
1549 for (
Index j=0; j<2; j++) {
1550 for (
Index l=0; l<3; l++) {
1551 for (
Index m=0; m<5; m++) {
1552 for (
Index n=0; n<7; n++) {
1553 for (
Index o=0; o<11; o++) {
1554 std::cout <<
Tensor7(testvar(
joker,
Range(j, 1),
joker,
Range(l, 1),
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<0, 2>() <<
'\n';
1555 std::cout << testvar(
joker, j,
joker, l, m, n, o) <<
'\n';
1562 for (
Index j=0; j<2; j++) {
1563 for (
Index k=0; k<4; k++) {
1564 for (
Index m=0; m<5; m++) {
1565 for (
Index n=0; n<7; n++) {
1566 for (
Index o=0; o<11; o++) {
1567 std::cout <<
Tensor7(testvar(
joker,
Range(j, 1),
Range(k, 1),
joker,
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<0, 3>() <<
'\n';
1568 std::cout << testvar(
joker, j, k,
joker, m, n, o) <<
'\n';
1575 for (
Index j=0; j<2; j++) {
1576 for (
Index k=0; k<4; k++) {
1577 for (
Index l=0; l<3; l++) {
1578 for (
Index n=0; n<7; n++) {
1579 for (
Index o=0; o<11; o++) {
1580 std::cout <<
Tensor7(testvar(
joker,
Range(j, 1),
Range(k, 1),
Range(l, 1),
joker,
Range(n, 1),
Range(o, 1))).
reduce_rank<0, 4>() <<
'\n';
1581 std::cout << testvar(
joker, j, k, l,
joker, n, o) <<
'\n';
1588 for (
Index j=0; j<2; j++) {
1589 for (
Index k=0; k<4; k++) {
1590 for (
Index l=0; l<3; l++) {
1591 for (
Index m=0; m<5; m++) {
1592 for (
Index o=0; o<11; o++) {
1593 std::cout <<
Tensor7(testvar(
joker,
Range(j, 1),
Range(k, 1),
Range(l, 1),
Range(m, 1),
joker,
Range(o, 1))).
reduce_rank<0, 5>() <<
'\n';
1594 std::cout << testvar(
joker, j, k, l, m,
joker, o) <<
'\n';
1601 for (
Index j=0; j<2; j++) {
1602 for (
Index k=0; k<4; k++) {
1603 for (
Index l=0; l<3; l++) {
1604 for (
Index m=0; m<5; m++) {
1605 for (
Index n=0; n<7; n++) {
1606 std::cout <<
Tensor7(testvar(
joker,
Range(j, 1),
Range(k, 1),
Range(l, 1),
Range(m, 1),
Range(n, 1),
joker)).
reduce_rank<0, 6>() <<
'\n';
1607 std::cout << testvar(
joker, j, k, l, m, n,
joker) <<
'\n';
1614 for (
Index i=0; i<9; i++) {
1615 for (
Index l=0; l<3; l++) {
1616 for (
Index m=0; m<5; m++) {
1617 for (
Index n=0; n<7; n++) {
1618 for (
Index o=0; o<11; o++) {
1619 std::cout <<
Tensor7(testvar(
Range(i, 1),
joker,
joker,
Range(l, 1),
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<1, 2>() <<
'\n';
1620 std::cout << testvar(i,
joker,
joker, l, m, n, o) <<
'\n';
1627 for (
Index i=0; i<9; i++) {
1628 for (
Index k=0; k<4; k++) {
1629 for (
Index m=0; m<5; m++) {
1630 for (
Index n=0; n<7; n++) {
1631 for (
Index o=0; o<11; o++) {
1632 std::cout <<
Tensor7(testvar(
Range(i, 1),
joker,
Range(k, 1),
joker,
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<1, 3>() <<
'\n';
1633 std::cout << testvar(i,
joker, k,
joker, m, n, o) <<
'\n';
1640 for (
Index i=0; i<9; i++) {
1641 for (
Index k=0; k<4; k++) {
1642 for (
Index l=0; l<3; l++) {
1643 for (
Index n=0; n<7; n++) {
1644 for (
Index o=0; o<11; o++) {
1645 std::cout <<
Tensor7(testvar(
Range(i, 1),
joker,
Range(k, 1),
Range(l, 1),
joker,
Range(n, 1),
Range(o, 1))).
reduce_rank<1, 4>() <<
'\n';
1646 std::cout << testvar(i,
joker, k, l,
joker, n, o) <<
'\n';
1653 for (
Index i=0; i<9; i++) {
1654 for (
Index k=0; k<4; k++) {
1655 for (
Index l=0; l<3; l++) {
1656 for (
Index m=0; m<5; m++) {
1657 for (
Index o=0; o<11; o++) {
1658 std::cout <<
Tensor7(testvar(
Range(i, 1),
joker,
Range(k, 1),
Range(l, 1),
Range(m, 1),
joker,
Range(o, 1))).
reduce_rank<1, 5>() <<
'\n';
1659 std::cout << testvar(i,
joker, k, l, m,
joker, o) <<
'\n';
1666 for (
Index i=0; i<9; i++) {
1667 for (
Index k=0; k<4; k++) {
1668 for (
Index l=0; l<3; l++) {
1669 for (
Index m=0; m<5; m++) {
1670 for (
Index n=0; n<7; n++) {
1671 std::cout <<
Tensor7(testvar(
Range(i, 1),
joker,
Range(k, 1),
Range(l, 1),
Range(m, 1),
Range(n, 1),
joker)).
reduce_rank<1, 6>() <<
'\n';
1672 std::cout << testvar(i,
joker, k, l, m, n,
joker) <<
'\n';
1679 for (
Index i=0; i<9; i++) {
1680 for (
Index j=0; j<2; j++) {
1681 for (
Index m=0; m<5; m++) {
1682 for (
Index n=0; n<7; n++) {
1683 for (
Index o=0; o<11; o++) {
1684 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
joker,
joker,
Range(m, 1),
Range(n, 1),
Range(o, 1))).
reduce_rank<2, 3>() <<
'\n';
1685 std::cout << testvar(i, j,
joker,
joker, m, n, o) <<
'\n';
1692 for (
Index i=0; i<9; i++) {
1693 for (
Index j=0; j<2; j++) {
1694 for (
Index l=0; l<3; l++) {
1695 for (
Index n=0; n<7; n++) {
1696 for (
Index o=0; o<11; o++) {
1697 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
joker,
Range(l, 1),
joker,
Range(n, 1),
Range(o, 1))).
reduce_rank<2, 4>() <<
'\n';
1698 std::cout << testvar(i, j,
joker, l,
joker, n, o) <<
'\n';
1705 for (
Index i=0; i<9; i++) {
1706 for (
Index j=0; j<2; j++) {
1707 for (
Index l=0; l<3; l++) {
1708 for (
Index m=0; m<5; m++) {
1709 for (
Index o=0; o<11; o++) {
1710 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
joker,
Range(l, 1),
Range(m, 1),
joker,
Range(o, 1))).
reduce_rank<2, 5>() <<
'\n';
1711 std::cout << testvar(i, j,
joker, l, m,
joker, o) <<
'\n';
1718 for (
Index i=0; i<9; i++) {
1719 for (
Index j=0; j<2; j++) {
1720 for (
Index l=0; l<3; l++) {
1721 for (
Index m=0; m<5; m++) {
1722 for (
Index n=0; n<7; n++) {
1723 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
joker,
Range(l, 1),
Range(m, 1),
Range(n, 1),
joker)).
reduce_rank<2, 6>() <<
'\n';
1724 std::cout << testvar(i, j,
joker, l, m, n,
joker) <<
'\n';
1731 for (
Index i=0; i<9; i++) {
1732 for (
Index j=0; j<2; j++) {
1733 for (
Index k=0; k<4; k++) {
1734 for (
Index n=0; n<7; n++) {
1735 for (
Index o=0; o<11; o++) {
1736 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
joker,
joker,
Range(n, 1),
Range(o, 1))).
reduce_rank<3, 4>() <<
'\n';
1737 std::cout << testvar(i, j, k,
joker,
joker, n, o) <<
'\n';
1744 for (
Index i=0; i<9; i++) {
1745 for (
Index j=0; j<2; j++) {
1746 for (
Index k=0; k<4; k++) {
1747 for (
Index m=0; m<5; m++) {
1748 for (
Index o=0; o<11; o++) {
1749 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
joker,
Range(m, 1),
joker,
Range(o, 1))).
reduce_rank<3, 5>() <<
'\n';
1750 std::cout << testvar(i, j, k,
joker, m,
joker, o) <<
'\n';
1757 for (
Index i=0; i<9; i++) {
1758 for (
Index j=0; j<2; j++) {
1759 for (
Index k=0; k<4; k++) {
1760 for (
Index m=0; m<5; m++) {
1761 for (
Index n=0; n<7; n++) {
1762 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
joker,
Range(m, 1),
Range(n, 1),
joker)).
reduce_rank<3, 6>() <<
'\n';
1763 std::cout << testvar(i, j, k,
joker, m, n,
joker) <<
'\n';
1770 for (
Index i=0; i<9; i++) {
1771 for (
Index j=0; j<2; j++) {
1772 for (
Index k=0; k<4; k++) {
1773 for (
Index l=0; l<3; l++) {
1774 for (
Index o=0; o<11; o++) {
1775 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
Range(l, 1),
joker,
joker,
Range(o, 1))).
reduce_rank<4, 5>() <<
'\n';
1776 std::cout << testvar(i, j, k, l,
joker,
joker, o) <<
'\n';
1783 for (
Index i=0; i<9; i++) {
1784 for (
Index j=0; j<2; j++) {
1785 for (
Index k=0; k<4; k++) {
1786 for (
Index l=0; l<3; l++) {
1787 for (
Index n=0; n<7; n++) {
1788 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
Range(l, 1),
joker,
Range(n, 1),
joker)).
reduce_rank<4, 6>() <<
'\n';
1789 std::cout << testvar(i, j, k, l,
joker, n,
joker) <<
'\n';
1796 for (
Index i=0; i<9; i++) {
1797 for (
Index j=0; j<2; j++) {
1798 for (
Index k=0; k<4; k++) {
1799 for (
Index l=0; l<3; l++) {
1800 for (
Index m=0; m<5; m++) {
1801 std::cout <<
Tensor7(testvar(
Range(i, 1),
Range(j, 1),
Range(k, 1),
Range(l, 1),
Range(m, 1),
joker,
joker)).
reduce_rank<5, 6>() <<
'\n';
1802 std::cout << testvar(i, j, k, l, m,
joker,
joker) <<
'\n';
1815 }
catch(std::exception& e) {
1816 std::cerr << e.what() <<
'\n';
1824 std::vector<Index> x(30);
1825 std::iota(x.begin(), x.end(), -15);
1826 for (
auto& i: x) std::cout <<
"-1^" << i <<
'=' <<
pow_negative_one(i) <<
'\n';
This file contains the definition of Array.
base max(const Array< base > &x)
Max function.
base min(const Array< base > &x)
Min function.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
static constexpr bool matpack_type
static constexpr bool matpack_type
A constant view of a Matrix.
Numeric * get_c_array() const noexcept
Index nrows() const noexcept
static constexpr bool matpack_type
Index ncols() const noexcept
ConstVectorView diagonal() const ARTS_NOEXCEPT
Matrix diagonal as vector.
static constexpr bool matpack_type
static constexpr bool matpack_type
static constexpr bool matpack_type
static constexpr bool matpack_type
A constant view of a Vector.
static constexpr bool matpack_type
Index nelem() const noexcept
Returns the number of elements.
Vector reduce_rank() &&ARTS_NOEXCEPT
const Numeric * get_c_array() const ARTS_NOEXCEPT
Conversion to plain C-array.
Vector reduce_rank() &&ARTS_NOEXCEPT
Vector reduce_rank() &&ARTS_NOEXCEPT
Vector reduce_rank() &&ARTS_NOEXCEPT
static constexpr bool matpack_type
Vector reduce_rank() &&ARTS_NOEXCEPT
Vector reduce_rank() &&ARTS_NOEXCEPT
Iterator1D begin() ARTS_NOEXCEPT
Return iterator to first element.
Iterator1D end() ARTS_NOEXCEPT
Return iterator behind last element.
void resize(Index n)
Resize function.
void mult(MatrixView C, ConstMatrixView A, const Block &B)
#define ARTS_ASSERT(condition,...)
String describe(ConstTensor7View x)
Describe Tensor7.
Header file for describe.cc.
The declarations of all the exception classes.
bool is_increasing(ConstVectorView x)
Checks if a vector is sorted and strictly increasing.
bool is_sorted(ConstVectorView x)
Checks if a vector is sorted in ascending order.
bool is_decreasing(ConstVectorView x)
Checks if a vector is sorted in reversed order and is strictly decreasing.
Header file for logic.cc.
constexpr Index pow_negative_one(Index x) noexcept
Computes std::pow(-1, x) without std::pow.
Header file for sparse matrices.
void mult_general(VectorView y, const ConstMatrixView &M, const ConstVectorView &x) ARTS_NOEXCEPT
Matrix Vector multiplication.
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...
NUMERIC Numeric
The type to use for all floating point numbers.
INDEX Index
The type to use for all integer numbers and indices.
ConstComplexMatrixView transpose(ConstComplexMatrixView m)
Const version of transpose.
This file contains the definition of String, the ARTS string class.
auto mat(matpack::matrix auto &&x)
Map the input to a non-owning const-correct Eigen Map representing a row matrix.
Contains the rational class definition.
Numeric sqrt(const Rational r)
Square root.
constexpr Rational numeric2rational(Numeric x, size_t maxdec=4) noexcept
Rational from Numeric.
Implements rational numbers to work with other ARTS types.
constexpr bool isUndefined() const noexcept
Is the object not defined.
constexpr Numeric toNumeric() const noexcept
Converts this to a Numeric.
constexpr Index toIndex(int n=1) const noexcept
Converts the value to index by n-scaled division.
constexpr int toInt(int n=1) const noexcept
Converts the value to int by n-scaled division in Index form.
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
void junk2(ConstVectorView a)
#define docheck(fn, val, expect)
Numeric matrix_vector_mult(Index m, Index n, Index ntests, bool verbose)
void junk4(Tensor4View a)
Numeric test_matrix_vector_multiplication(bool verbose)
void test_pow_negative_one()
Numeric matrix_mult(Index k, Index m, Index n, Index ntests, Index nsubtests, bool verbose)
Perform matrix multiplication test.
Numeric test_matrix_multiplication(bool verbose)
Perform matrix multiplication tests.
Numeric by_value(Numeric x)
void fill_with_junk(VectorView x)
Numeric by_reference(const Numeric &x)
constexpr Rational test_numeric2rational(const Index i, const Index maxi, const Rational r=0, const Rational n2r=0)
bool test_diagonal(Index ntests)
Test diagonal vector.
void test37(const Index &i)
void test_empty()
Check if the empty function is working correctly.
void random_fill_matrix(MatrixView A, Numeric range, bool positive)
Fill matrix with random values.
Numeric get_maximum_error(ConstVectorView v1, ConstVectorView v2, bool relative)
Maximum element-wise error of two vectors.
void random_fill_vector(VectorView v, Numeric range, bool positive)
Fill vector with random values.
Range random_range(Index n)
Generate random sub-range of the range [0, n-1].
Utility functions for testing.
Index make_wigner_ready(int largest, int fastest, int size)
Ready Wigner.
Numeric wigner3j(const Rational j1, const Rational j2, const Rational j3, const Rational m1, const Rational m2, const Rational m3)
Wigner 3J symbol.
Wigner symbol interactions.