38#include "matpack_data.h"
39#include "matpack_arrays.h"
40#include "matpack_math.h"
60 for (Index i = 0; i < nelem; i++) aoi[i] = value;
72 Index n = (Index)floor((stop - start) / step) + 1;
77 for (Index i = 0; i < n; i++) x[i] = start + i * step;
79 out2 <<
" Creating a linearly spaced ArrayOfIndex.\n";
80 out3 <<
" length : " << x.
nelem() <<
"\n";
81 out3 <<
" first value : " << x[0] <<
"\n";
84 out3 <<
" step size : " << x[1] - x[0] <<
"\n";
85 out3 <<
" last value : " << x[x.nelem() - 1] <<
"\n";
140 const Numeric& value,
149 out.resize(in.nrows(), in.ncols());
158 const Numeric& value,
167 out.resize(in.nrows(), in.ncols());
177 const Numeric& x0_row,
178 const Numeric& si_row,
179 const Numeric& fwhm_row,
181 const Numeric& x0_col,
182 const Numeric& si_col,
183 const Numeric& fwhm_col,
187 (si_row>0 && fwhm_row>0),
188 "One of the GINs *si_row* and *fwhm_row* shall be >0, but just one.");
190 (si_col>0 && fwhm_col>0),
191 "One of the GINs *si_col* and *fwhm_col* shall be >0, but just one.");
193 const Index nrow = x_row.nelem();
194 const Index ncol = x_col.nelem();
195 Y.resize(nrow, ncol);
197 const Numeric si4row = si_row > 0 ? si_row : fwhm_row / (2 * sqrt(2 *
NAT_LOG_2));
198 const Numeric si4col = si_col > 0 ? si_col : fwhm_col / (2 * sqrt(2 *
NAT_LOG_2));
199 Vector row_term(nrow);
200 for (Index r=0; r<nrow; ++r)
201 row_term[r] = pow((x_row[r] - x0_row) / si4row, 2.0);
202 Vector col_term(ncol);
203 for (Index
c=0;
c<ncol; ++
c)
204 col_term[
c] = pow((x_col[
c] - x0_col) / si4col, 2.0);
205 const Numeric
fac = 1 / (2 *
PI * si4row * si4col);
206 for (Index r=0; r<nrow; ++r) {
207 for (Index
c=0;
c<ncol; ++
c) {
208 Y(r,
c) =
fac * exp(-0.5 * (row_term[r] + col_term[
c]));
216 const Numeric& value,
225 out.resize(in.nrows(), in.ncols());
234 const Numeric& value,
243 out.resize(in.nrows(), in.ncols());
252 out.resize(in.nrows(), in.ncols());
253 for (Index r = 0; r < in.nrows(); r++) {
254 for (Index
c = 0;
c < in.ncols();
c++) {
255 out(r,
c) = in(r,
c);
271 if (direction ==
"page") {
272 if (index >= t3.npages()) {
274 os <<
"The index " << index
275 <<
" is outside the page range of the Matrix.";
276 throw runtime_error(os.str());
279 m.resize(t3.nrows(), t3.ncols());
280 m = t3(index, joker, joker);
281 }
else if (direction ==
"row") {
282 if (index >= t3.nrows()) {
284 os <<
"The index " << index <<
" is outside the row range of the Matrix.";
285 throw runtime_error(os.str());
288 m.resize(t3.npages(), t3.ncols());
289 m = t3(joker, index, joker);
290 }
else if (direction ==
"column") {
291 if (index >= t3.ncols()) {
293 os <<
"The index " << index
294 <<
" is outside the column range of the Matrix.";
295 throw runtime_error(os.str());
298 m.resize(t3.npages(), t3.nrows());
299 m = t3(joker, joker, index);
302 os <<
"Keyword *direction* must be either *page* or *row* or *column*,"
303 <<
"but you gave: " << direction <<
".";
304 throw runtime_error(os.str());
316 if (M.ncols() != X.nrows()) {
318 os <<
"Matrix dimensions must be consistent!\n"
319 <<
"Matrix1.ncols() = " << M.ncols() <<
"\n"
320 <<
"Matrix2.nrows() = " << X.nrows();
321 throw runtime_error(os.str());
325 Matrix dummy(M.nrows(), X.ncols());
331 Y.resize(dummy.nrows(), dummy.ncols());
342 const Index nv =
v.nelem();
355 const Index nv = v1.nelem();
357 if (v2.nelem() != nv)
358 throw runtime_error(
"Vectors must be of the same size.");
373 const Index nv = v1.nelem();
375 if (v3.nelem() != nv || v2.nelem() != nv)
376 throw runtime_error(
"Vectors must be of the same size.");
390 const Index nv =
v.nelem();
403 const Index nv = v1.nelem();
405 if (v2.nelem() != nv)
406 throw runtime_error(
"Vectors must be of the same size.");
421 const Index nv = v1.nelem();
423 if (v3.nelem() != nv || v2.nelem() != nv)
424 throw runtime_error(
"Vectors must be of the same size.");
435 const Numeric& value,
450 const Index npages = t.npages();
451 const Index nrows = t.nrows();
452 const Index ncols = t.ncols();
454 m.resize(npages * nrows, ncols);
457 for (Index p=0; p<npages; ++p) {
458 for (Index r=0; r<nrows; ++r) {
459 m(i++, joker) = t(p, r, joker);
468 const Numeric& value,
470 x.resize(nrows, ncols);
477 const Numeric& value,
485 const Numeric& limit_low,
486 const Numeric& limit_high,
490 else if (in > limit_high)
499 const Numeric& value,
511 else if (op ==
"last")
512 out = in[in.nelem() - 1];
513 else if (op ==
"max")
515 else if (op ==
"min")
517 else if (op ==
"mean")
521 os <<
"Your choice, *op* = \"" << op <<
"\", is not recognised.\n"
522 <<
"Valid options are: \"first\", \"last\", \"max\", \"min\" and \"mean\".";
523 throw runtime_error(os.str());
530 const Numeric& value,
538 const Numeric& value,
546 const Rational& value,
554 const Rational& value,
562 const Rational& value,
570 const Rational& value,
584 if (M.ncols() != X.nrows()) {
586 os <<
"Matrix dimensions must be consistent!\n"
587 <<
"Matrix1.ncols() = " << M.ncols() <<
"\n"
588 <<
"Matrix2.nrows() = " << X.nrows();
589 throw runtime_error(os.str());
593 Sparse dummy(M.nrows(), X.ncols());
604 const Numeric& value,
609 if (value != 1.0) X *= value;
614 Index n = diag.nelem();
618 for (Index i = 0; i < n; ++i) {
625 Index n = diag.nelem();
630 for (Index i = 0; i < n; ++i) {
634 X.insert_elements(n, indices, indices, diag);
640 const Numeric& value,
649 out.resize(in.npages(), in.nrows(), in.ncols());
661 const Index nv =
v.nelem();
670 const Numeric& value,
679 out.resize(in.npages(), in.nrows(), in.ncols());
690 const Numeric& value,
695 x.resize(npages, nrows, ncols);
698 out2 <<
" Tensor3 = " << value <<
"\n";
699 out3 <<
" npages : " << npages <<
"\n";
700 out3 <<
" nrows : " << nrows <<
"\n";
701 out3 <<
" ncols : " << ncols <<
"\n";
715 if (direction ==
"book") {
716 if (index >= t4.nbooks()) {
718 os <<
"The index " << index
719 <<
" is outside the book range of the Tensor4.";
720 throw runtime_error(os.str());
723 t3.resize(t4.npages(), t4.nrows(), t4.ncols());
724 t3 = t4(index, joker, joker, joker);
725 }
else if (direction ==
"page") {
726 if (index >= t4.npages()) {
728 os <<
"The index " << index
729 <<
" is outside the pages range of the Tensor4.";
730 throw runtime_error(os.str());
733 t3.resize(t4.nbooks(), t4.nrows(), t4.ncols());
734 t3 = t4(joker, index, joker, joker);
735 }
else if (direction ==
"row") {
736 if (index >= t4.nrows()) {
738 os <<
"The index " << index
739 <<
" is outside the row range of the Tensor4.";
740 throw runtime_error(os.str());
743 t3.resize(t4.npages(), t4.nbooks(), t4.ncols());
744 t3 = t4(joker, joker, index, joker);
745 }
else if (direction ==
"column") {
746 if (index >= t4.ncols()) {
748 os <<
"The index " << index
749 <<
" is outside the column range of the Tensor4.";
750 throw runtime_error(os.str());
753 t3.resize(t4.npages(), t4.nbooks(), t4.nrows());
754 t3 = t4(joker, joker, joker, index);
757 os <<
"Keyword *direction* must be either *page*, *book*, *row* or *column*,"
758 <<
"but you gave: " << direction <<
".";
759 throw runtime_error(os.str());
766 const Numeric& value,
775 out.resize(in.nbooks(), in.npages(), in.nrows(), in.ncols());
784 const Numeric& value,
793 out.resize(in.nbooks(), in.npages(), in.nrows(), in.ncols());
805 const Numeric& value,
810 x.resize(nbooks, npages, nrows, ncols);
813 out2 <<
" Tensor4 = " << value <<
"\n";
814 out3 <<
" nbooks : " << nbooks <<
"\n";
815 out3 <<
" npages : " << npages <<
"\n";
816 out3 <<
" nrows : " << nrows <<
"\n";
817 out3 <<
" ncols : " << ncols <<
"\n";
823 const Numeric& value,
832 out.resize(in.nshelves(), in.nbooks(), in.npages(), in.nrows(), in.ncols());
840 const Index& nshelves,
845 const Numeric& value,
850 x.resize(nshelves, nbooks, npages, nrows, ncols);
853 out2 <<
" Tensor5 = " << value <<
"\n";
854 out3 <<
" nshelves : " << nshelves <<
"\n";
855 out3 <<
" nbooks : " << nbooks <<
"\n";
856 out3 <<
" npages : " << npages <<
"\n";
857 out3 <<
" nrows : " << nrows <<
"\n";
858 out3 <<
" ncols : " << ncols <<
"\n";
864 const Numeric& value,
873 out.resize(in.nvitrines(),
886 const Index& nvitrines,
887 const Index& nshelves,
892 const Numeric& value,
897 x.resize(nvitrines, nshelves, nbooks, npages, nrows, ncols);
900 out2 <<
" Tensor6 = " << value <<
"\n";
901 out3 <<
" nvitrines : " << nvitrines <<
"\n";
902 out3 <<
" nshelves : " << nshelves <<
"\n";
903 out3 <<
" nbooks : " << nbooks <<
"\n";
904 out3 <<
" npages : " << npages <<
"\n";
905 out3 <<
" nrows : " << nrows <<
"\n";
906 out3 <<
" ncols : " << ncols <<
"\n";
912 const Numeric& value,
921 out.resize(in.nlibraries(),
935 const Index& nlibraries,
936 const Index& nvitrines,
937 const Index& nshelves,
942 const Numeric& value,
947 x.resize(nlibraries, nvitrines, nshelves, nbooks, npages, nrows, ncols);
950 out2 <<
" Tensor7 = " << value <<
"\n";
951 out3 <<
" nlibraries : " << nlibraries <<
"\n";
952 out3 <<
" nvitrines : " << nvitrines <<
"\n";
953 out3 <<
" nshelves : " << nshelves <<
"\n";
954 out3 <<
" nbooks : " << nbooks <<
"\n";
955 out3 <<
" npages : " << npages <<
"\n";
956 out3 <<
" nrows : " << nrows <<
"\n";
957 out3 <<
" ncols : " << ncols <<
"\n";
966 const Index n = x.nelem();
968 throw runtime_error(
"The vectors *x* and *y* must have the same length.");
971 for (Index i=1; i<n; i++)
972 out += 0.5*(y[i-1]+y[i]) * (x[i]-x[i-1]);
978 const Numeric& value,
987 out.resize(in.nelem());
996 const Numeric& value,
1005 out.resize(in.nelem());
1014 const Numeric& value,
1023 out.resize(in.nelem());
1032 const Numeric& value,
1041 out.resize(in.nelem());
1053 if (
b.nelem() == 1) {
1068 else if (
b.nelem() ==
a.nelem()) {
1079 throw runtime_error(
1080 "The vector *b* must have length 1 or match *a* in length.");
1089 if (
b.nelem() == 1) {
1104 else if (
b.nelem() ==
a.nelem()) {
1115 throw runtime_error(
1116 "The vector *b* must have length 1 or match *a* in length.");
1125 if (
b.nelem() == 1) {
1140 else if (
b.nelem() ==
a.nelem()) {
1151 throw runtime_error(
1152 "The vector *b* must have length 1 or match *a* in length.");
1161 if (
b.nelem() == 1) {
1176 else if (
b.nelem() ==
a.nelem()) {
1187 throw runtime_error(
1188 "The vector *b* must have length 1 or match *a* in length.");
1194 const Numeric& limit_low,
1195 const Numeric& limit_high,
1197 const Index l = in.nelem();
1198 if (out.nelem() != l)
1201 for (Index i=0; i<l; i++) {
1202 if (in[i] < limit_low)
1204 else if (in[i] > limit_high)
1205 out[i] = limit_high;
1214 const Numeric& min_value,
1215 const Numeric& max_value,
1217 const Index nin = in.nelem();
1221 for (Index i = 0; i < nin; i++) {
1222 if (in[i] >= min_value && in[i] <= max_value) {
1234 for (Index i = 0; i < nin; i++) {
1235 if (
c[i] >= min_value &&
c[i] <= max_value) {
1259 if (direction ==
"row") {
1260 if (index >= m.nrows()) {
1262 os <<
"The index " << index <<
" is outside the row range of the Matrix.";
1263 throw runtime_error(os.str());
1266 v.resize(m.ncols());
1267 v = m(index, joker);
1268 }
else if (direction ==
"column") {
1269 if (index >= m.ncols()) {
1271 os <<
"The index " << index
1272 <<
" is outside the column range of the Matrix.";
1273 throw runtime_error(os.str());
1276 v.resize(m.nrows());
1277 v = m(joker, index);
1280 os <<
"Keyword *direction* must be either *row* or *column*,"
1281 <<
"but you gave: " << direction <<
".";
1282 throw runtime_error(os.str());
1288 const Index n = in.nelem();
1293 const Vector
v = in;
1294 for (Index i = 0; i < n; i++) out[i] =
v[n - 1 - i];
1298 for (Index i = 0; i < n; i++) out[i] = in[n - 1 - i];
1308 const Numeric& fwhm,
1312 "One of the GINs *si* and *fwhm* shall be >0, but just one.");
1314 const Index n = x.nelem();
1321 const Numeric si2use = si > 0 ? si : fwhm / (2 * sqrt(2 *
NAT_LOG_2));
1322 const Numeric
fac = 1 / (sqrt(2 *
PI) * si2use);
1323 for (Index i=0; i<n; ++i) {
1324 y[i] =
fac * exp(-0.5 * pow((x[i] - x0) / si2use, 2.0));
1332 const Vector& ingrid,
1333 const Vector& points,
1348 if (is_increasing(ig)) {
1350 }
else if (is_decreasing(ig)) {
1356 const Vector dummy = reverse(ig);
1362 os <<
"The input Vector must be either\n"
1363 <<
"strictly increasing or strictly decreasing,\n"
1364 <<
"but this is not the case.\n";
1365 os <<
"The vector contains:\n" << ig;
1366 throw runtime_error(os.str());
1373 const Vector dummy = p;
1375 for (Index j = 0; j < p.nelem(); j++) p[j] = dummy[si[j]];
1381 Index iig = 0, ip = 0;
1383 while (iig < ig.nelem() && ip < p.nelem()) {
1384 if (p[ip] < ig[iig]) {
1387 }
else if (p[ip] > ig[iig]) {
1388 x.push_back(ig[iig]);
1391 out3 <<
" Skipping point " << p[ip] <<
", which is already "
1392 <<
"in the original grid.\n";
1398 out2 <<
" " << sk <<
" points skipped.\n";
1402 if (ip == p.nelem()) {
1404 while (iig < ig.nelem()) {
1405 x.push_back(ig[iig]);
1408 }
else if (iig == ig.nelem()) {
1410 while (ip < p.nelem()) {
1422 og.resize(x.
nelem());
1426 for (Index i = 0; i < x.
nelem(); ++i) og[i] = x[i];
1428 for (Index i = 0; i < x.
nelem(); ++i)
1429 og[i] = x[x.
nelem() - 1 - i];
1434 const Numeric& start,
1435 const Numeric& stop,
1436 const Numeric& step,
1443 out2 <<
" Creating a linearly spaced vector.\n";
1444 out3 <<
" length : " << x.nelem() <<
"\n";
1445 out3 <<
" first value : " << x[0] <<
"\n";
1447 if (x.nelem() > 1) {
1448 out3 <<
" step size : " << x[1] - x[0] <<
"\n";
1449 out3 <<
" last value : " << x[x.nelem() - 1] <<
"\n";
1455 const Numeric& start,
1456 const Numeric& stop,
1457 const Numeric& step,
1462 linspace(x, log(start), log(stop), step);
1463 transform(x, exp, x);
1465 out2 <<
" Creating a logarithmically spaced vector.\n";
1466 out3 <<
" length : " << x.nelem() <<
"\n";
1467 out3 <<
" first value : " << x[0] <<
"\n";
1469 if (x.nelem() > 1) {
1470 out3 <<
" step size : " << x[1] - x[0] <<
"\n";
1471 out3 <<
" last value : " << x[x.nelem() - 1] <<
"\n";
1483 if (M.ncols() != x.nelem()) {
1485 os <<
"Matrix and vector dimensions must be consistent!\n"
1486 <<
"Matrix.ncols() = " << M.ncols() <<
"\n"
1487 <<
"Vector.nelem() = " << x.nelem();
1488 throw runtime_error(os.str());
1492 Vector dummy(M.nrows());
1496 y.resize(dummy.nelem());
1509 if (M.ncols() != x.nelem()) {
1511 os <<
"Sparse and vector dimensions must be consistent!\n"
1512 <<
"Sparse.ncols() = " << M.ncols() <<
"\n"
1513 <<
"Vector.nelem() = " << x.nelem();
1514 throw runtime_error(os.str());
1518 Vector dummy(M.nrows());
1522 y.resize(dummy.nelem());
1530 const Numeric& start,
1531 const Numeric& stop,
1536 if (n < 2)
throw runtime_error(
"The number of points must be > 1.");
1539 out2 <<
" Creating a linearly spaced vector.\n";
1540 out3 <<
" length : " << n <<
"\n";
1541 out3 <<
" first value : " << x[0] <<
"\n";
1543 if (x.nelem() > 1) {
1544 out3 <<
" step size : " << x[1] - x[0] <<
"\n";
1545 out3 <<
" last value : " << x[x.nelem() - 1] <<
"\n";
1564 Time t0(start), t1(stop);
1567 nlinspace(seconds, t0.Seconds(), t1.Seconds(), n);
1569 x = time_vector(seconds);
1572/* Workspace method: Doxygen documentation will be auto-generated */
1573void VectorNLogSpace(Vector& x,
1575 const Numeric& start,
1576 const Numeric& stop,
1577 const Verbosity& verbosity) {
1581 if (n < 2) throw runtime_error("The number of points must be > 1.
");
1582 if ((start <= 0) || (stop <= 0))
1583 throw runtime_error("Only positive numbers are allowed.
");
1585 nlogspace(x, start, stop, n);
1587 out2 << " Creating
a logarithmically spaced vector.\n
";
1588 out3 << " length :
" << n << "\n
";
1589 out3 << " first value :
" << x[0] << "\n
";
1592 out3 << " last value :
" << x[x.nelem() - 1] << "\n
";
1595/* Workspace method: Doxygen documentation will be auto-generated */
1596void VectorPower(Vector& out,
1598 const Numeric& value,
1600 const Index n = in.nelem();
1601 // Note that in and out can be the same vector
1603 // Out and in are the same.
1607 for (Index i=0; i<n; i++) {
1608 out[i] = pow( in[i], value );
1612/* Workspace method: Doxygen documentation will be auto-generated */
1613void VectorReshapeMatrix(Vector& v,
1615 const String& direction,
1617 const Index nrows = m.nrows();
1618 const Index ncols = m.ncols();
1620 v.resize(nrows * ncols);
1624 if (direction == "column
") {
1625 for (Index col = 0; col < ncols; col++) {
1626 for (Index row = 0; row < nrows; row++) {
1627 v[iv] = m(row, col);
1631 } else if (direction == "row
") {
1632 for (Index row = 0; row < nrows; row++) {
1633 for (Index col = 0; col < ncols; col++) {
1634 v[iv] = m(row, col);
1640 os << "Keyword *direction* must be either *row* or *column*,
"
1641 << "but you gave:
" << direction << ".
";
1642 throw runtime_error(os.str());
1646/* Workspace method: Doxygen documentation will be auto-generated */
1647void VectorSetConstant(Vector& x,
1649 const Numeric& value,
1650 const Verbosity& verbosity) {
1657 out2 << " Creating
a constant vector.\n
";
1658 out3 << " length :
" << n << "\n
";
1659 out3 << " value :
" << value << "\n
";
1662/* Workspace method: Doxygen documentation will be auto-generated */
1663void ArrayOfTimeSetConstant(ArrayOfTime& x,
1666 const Verbosity& verbosity) {
1673 out2 << " Creating
a constant vector.\n
";
1674 out3 << " length :
" << n << "\n
";
1675 out3 << " value :
" << value << "\n
";
1678/* Workspace method: Doxygen documentation will be auto-generated */
1679void Compare(const Numeric& var1,
1680 const Numeric& var2,
1681 const Numeric& maxabsdiff,
1682 const String& error_message,
1683 const String& var1name,
1684 const String& var2name,
1687 const Verbosity& verbosity) {
1688 Numeric maxdiff = var1 - var2;
1690 if (std::isnan(var1) || std::isnan(var2)) {
1691 if (std::isnan(var1) && std::isnan(var2)) {
1693 } else if (std::isnan(var1)) {
1695 os << "Nan found in
" << var1name << ", but there is no
"
1696 << "NaN at same position in
" << var2name << ".\nThis
"
1697 << "is not allowed.
";
1698 throw runtime_error(os.str());
1701 os << "Nan found in
" << var2name << ", but there is no
"
1702 << "NaN at same position in
" << var1name << ".\nThis
"
1703 << "is not allowed.
";
1704 throw runtime_error(os.str());
1708 if (abs(maxdiff) > maxabsdiff) {
1710 os << var1name << "-
" << var2name << " FAILED!\n
";
1711 if (error_message.length()) os << error_message << "\n
";
1712 os << "Max allowed deviation set to:
" << maxabsdiff << endl
1713 << "but the value deviates with:
" << maxdiff << endl;
1714 throw runtime_error(os.str());
1718 out2 << " " << var1name << "-
" << var2name
1719 << " OK (maximum difference =
" << maxdiff << ").\n
";
1722/* Workspace method: Doxygen documentation will be auto-generated */
1723void Compare(const Vector& var1,
1725 const Numeric& maxabsdiff,
1726 const String& error_message,
1727 const String& var1name,
1728 const String& var2name,
1731 const Verbosity& verbosity) {
1732 const Index n = var1.nelem();
1734 if (var2.nelem() != n) {
1736 os << var1name << " (
" << n << ") and
" << var2name << " (
" << var2.nelem()
1737 << ")
do not have the same size.
";
1738 throw runtime_error(os.str());
1741 Numeric maxdiff = 0.0;
1742 for (Index i = 0; i < n; i++) {
1743 Numeric diff = var1[i] - var2[i];
1745 if (std::isnan(var1[i]) || std::isnan(var2[i])) {
1746 if (std::isnan(var1[i]) && std::isnan(var2[i])) {
1748 } else if (std::isnan(var1[i])) {
1750 os << "Nan found in
" << var1name << ", but there is no
"
1751 << "NaN at same position in
" << var2name << ".\nThis
"
1752 << "is not allowed.
";
1753 throw runtime_error(os.str());
1756 os << "Nan found in
" << var2name << ", but there is no
"
1757 << "NaN at same position in
" << var1name << ".\nThis
"
1758 << "is not allowed.
";
1759 throw runtime_error(os.str());
1763 if (abs(diff) > abs(maxdiff)) {
1768 if (std::isnan(maxdiff) || abs(maxdiff) > maxabsdiff) {
1770 os << var1name << "-
" << var2name << " FAILED!\n
";
1771 if (error_message.length()) os << error_message << "\n
";
1772 os << "Max allowed deviation set to:
" << maxabsdiff << endl
1773 << "but the vectors deviate with:
" << maxdiff << endl;
1774 throw runtime_error(os.str());
1778 out2 << " " << var1name << "-
" << var2name
1779 << " OK (maximum difference =
" << maxdiff << ").\n
";
1782/* Workspace method: Doxygen documentation will be auto-generated */
1783void Compare(const Matrix& var1,
1785 const Numeric& maxabsdiff,
1786 const String& error_message,
1787 const String& var1name,
1788 const String& var2name,
1791 const Verbosity& verbosity) {
1792 const Index nrows = var1.nrows();
1793 const Index ncols = var1.ncols();
1795 if (var2.nrows() != nrows || var2.ncols() != ncols) {
1797 os << var1name << " (
" << nrows << ",
" << ncols << ") and
" << var2name
1798 << " (
" << var2.nrows() << ",
" << var2.ncols()
1799 << ")
do not have the same size.
";
1800 throw runtime_error(os.str());
1803 Numeric maxdiff = 0.0;
1805 for (Index r = 0; r < nrows; r++) {
1806 for (Index c = 0; c < ncols; c++) {
1807 Numeric diff = var1(r, c) - var2(r, c);
1809 if (std::isnan(var1(r, c)) || std::isnan(var2(r, c))) {
1810 if (std::isnan(var1(r, c)) && std::isnan(var2(r, c))) {
1812 } else if (std::isnan(var1(r, c))) {
1814 os << "Nan found in
" << var1name << ", but there is no
"
1815 << "NaN at same position in
" << var2name << ".\nThis
"
1816 << "is not allowed.
";
1817 throw runtime_error(os.str());
1820 os << "Nan found in
" << var2name << ", but there is no
"
1821 << "NaN at same position in
" << var1name << ".\nThis
"
1822 << "is not allowed.
";
1823 throw runtime_error(os.str());
1827 if (abs(diff) > abs(maxdiff)) {
1833 if (abs(maxdiff) > maxabsdiff) {
1835 os << var1name << "-
" << var2name << " FAILED!\n
";
1836 if (error_message.length()) os << error_message << "\n
";
1837 os << "Max allowed deviation set to :
" << maxabsdiff << endl
1838 << "but the matrices deviate with:
" << maxdiff << endl;
1839 throw runtime_error(os.str());
1843 out2 << " " << var1name << "-
" << var2name
1844 << " OK (maximum difference =
" << maxdiff << ").\n
";
1847/* Workspace method: Doxygen documentation will be auto-generated */
1848void Compare(const Tensor3& var1,
1849 const Tensor3& var2,
1850 const Numeric& maxabsdiff,
1851 const String& error_message,
1852 const String& var1name,
1853 const String& var2name,
1856 const Verbosity& verbosity) {
1857 const Index ncols = var1.ncols();
1858 const Index nrows = var1.nrows();
1859 const Index npages = var1.npages();
1861 if (var2.ncols() != ncols || var2.nrows() != nrows ||
1862 var2.npages() != npages) {
1864 os << var1name << " and
" << var2name << " do not have the same size.
";
1865 throw runtime_error(os.str());
1868 Numeric maxdiff = 0.0;
1870 for (Index c = 0; c < ncols; c++)
1871 for (Index r = 0; r < nrows; r++)
1872 for (Index p = 0; p < npages; p++) {
1873 Numeric diff = var1(p, r, c) - var2(p, r, c);
1875 if (std::isnan(var1(p, r, c)) || std::isnan(var2(p, r, c))) {
1876 if (std::isnan(var1(p, r, c)) && std::isnan(var2(p, r, c))) {
1878 } else if (std::isnan(var1(p, r, c))) {
1880 os << "Nan found in
" << var1name << ", but there is no
"
1881 << "NaN at same position in
" << var2name << ".\nThis
"
1882 << "is not allowed.
";
1883 throw runtime_error(os.str());
1886 os << "Nan found in
" << var2name << ", but there is no
"
1887 << "NaN at same position in
" << var1name << ".\nThis
"
1888 << "is not allowed.
";
1889 throw runtime_error(os.str());
1893 if (abs(diff) > abs(maxdiff)) {
1898 if (abs(maxdiff) > maxabsdiff) {
1900 os << var1name << "-
" << var2name << " FAILED!\n
";
1901 if (error_message.length()) os << error_message << "\n
";
1902 os << "Max allowed deviation set to :
" << maxabsdiff << endl
1903 << "but the tensors deviate with:
" << maxdiff << endl;
1904 throw runtime_error(os.str());
1908 out2 << " " << var1name << "-
" << var2name
1909 << " OK (maximum difference =
" << maxdiff << ").\n
";
1912/* Workspace method: Doxygen documentation will be auto-generated */
1913void Compare(const Tensor4& var1,
1914 const Tensor4& var2,
1915 const Numeric& maxabsdiff,
1916 const String& error_message,
1917 const String& var1name,
1918 const String& var2name,
1921 const Verbosity& verbosity) {
1922 const Index ncols = var1.ncols();
1923 const Index nrows = var1.nrows();
1924 const Index npages = var1.npages();
1925 const Index nbooks = var1.nbooks();
1927 if (var2.ncols() != ncols || var2.nrows() != nrows ||
1928 var2.npages() != npages || var2.nbooks() != nbooks) {
1930 os << var1name << " and
" << var2name << " do not have the same size.
";
1931 throw runtime_error(os.str());
1934 Numeric maxdiff = 0.0;
1936 for (Index c = 0; c < ncols; c++)
1937 for (Index r = 0; r < nrows; r++)
1938 for (Index p = 0; p < npages; p++)
1939 for (Index b = 0; b < nbooks; b++) {
1940 Numeric diff = var1(b, p, r, c) - var2(b, p, r, c);
1942 if (std::isnan(var1(b, p, r, c)) || std::isnan(var2(b, p, r, c))) {
1943 if (std::isnan(var1(b, p, r, c)) && std::isnan(var2(b, p, r, c))) {
1945 } else if (std::isnan(var1(b, p, r, c))) {
1947 os << "Nan found in
" << var1name << ", but there is no
"
1948 << "NaN at same position in
" << var2name << ".\nThis
"
1949 << "is not allowed.
";
1950 throw runtime_error(os.str());
1953 os << "Nan found in
" << var2name << ", but there is no
"
1954 << "NaN at same position in
" << var1name << ".\nThis
"
1955 << "is not allowed.
";
1956 throw runtime_error(os.str());
1960 if (abs(diff) > abs(maxdiff)) {
1965 if (abs(maxdiff) > maxabsdiff) {
1967 os << var1name << "-
" << var2name << " FAILED!\n
";
1968 if (error_message.length()) os << error_message << "\n
";
1969 os << "Max allowed deviation set to :
" << maxabsdiff << endl
1970 << "but the tensors deviate with:
" << maxdiff << endl;
1971 throw runtime_error(os.str());
1975 out2 << " " << var1name << "-
" << var2name
1976 << " OK (maximum difference =
" << maxdiff << ").\n
";
1979/* Workspace method: Doxygen documentation will be auto-generated */
1980void Compare(const Tensor5& var1,
1981 const Tensor5& var2,
1982 const Numeric& maxabsdiff,
1983 const String& error_message,
1984 const String& var1name,
1985 const String& var2name,
1988 const Verbosity& verbosity) {
1989 const Index ncols = var1.ncols();
1990 const Index nrows = var1.nrows();
1991 const Index npages = var1.npages();
1992 const Index nbooks = var1.nbooks();
1993 const Index nshelves = var1.nshelves();
1995 if (var2.ncols() != ncols || var2.nrows() != nrows ||
1996 var2.npages() != npages || var2.nbooks() != nbooks ||
1997 var2.nshelves() != nshelves) {
1999 os << var1name << " and
" << var2name << " do not have the same size.
";
2000 throw runtime_error(os.str());
2003 Numeric maxdiff = 0.0;
2005 for (Index c = 0; c < ncols; c++)
2006 for (Index r = 0; r < nrows; r++)
2007 for (Index p = 0; p < npages; p++)
2008 for (Index b = 0; b < nbooks; b++)
2009 for (Index s = 0; s < nshelves; s++) {
2010 Numeric diff = var1(s, b, p, r, c) - var2(s, b, p, r, c);
2012 if (std::isnan(var1(s, b, p, r, c)) ||
2013 std::isnan(var2(s, b, p, r, c))) {
2014 if (std::isnan(var1(s, b, p, r, c)) &&
2015 std::isnan(var2(s, b, p, r, c))) {
2017 } else if (std::isnan(var1(s, b, p, r, c))) {
2019 os << "Nan found in
" << var1name << ", but there is no
"
2020 << "NaN at same position in
" << var2name << ".\nThis
"
2021 << "is not allowed.
";
2022 throw runtime_error(os.str());
2025 os << "Nan found in
" << var2name << ", but there is no
"
2026 << "NaN at same position in
" << var1name << ".\nThis
"
2027 << "is not allowed.
";
2028 throw runtime_error(os.str());
2032 if (abs(diff) > abs(maxdiff)) {
2037 if (abs(maxdiff) > maxabsdiff) {
2039 os << var1name << "-
" << var2name << " FAILED!\n
";
2040 if (error_message.length()) os << error_message << "\n
";
2041 os << "Max allowed deviation set to :
" << maxabsdiff << endl
2042 << "but the tensors deviate with:
" << maxdiff << endl;
2043 throw runtime_error(os.str());
2047 out2 << " " << var1name << "-
" << var2name
2048 << " OK (maximum difference =
" << maxdiff << ").\n
";
2051/* Workspace method: Doxygen documentation will be auto-generated */
2052void Compare(const Tensor7& var1,
2053 const Tensor7& var2,
2054 const Numeric& maxabsdiff,
2055 const String& error_message,
2056 const String& var1name,
2057 const String& var2name,
2060 const Verbosity& verbosity) {
2061 const Index ncols = var1.ncols();
2062 const Index nrows = var1.nrows();
2063 const Index npages = var1.npages();
2064 const Index nbooks = var1.nbooks();
2065 const Index nshelves = var1.nshelves();
2066 const Index nvitrines = var1.nvitrines();
2067 const Index nlibraries = var1.nlibraries();
2069 if (var2.ncols() != ncols || var2.nrows() != nrows ||
2070 var2.npages() != npages || var2.nbooks() != nbooks ||
2071 var2.nshelves() != nshelves || var2.nvitrines() != nvitrines ||
2072 var2.nlibraries() != nlibraries) {
2074 os << var1name << " and
" << var2name << " do not have the same size.
";
2075 throw runtime_error(os.str());
2078 Numeric maxdiff = 0.0;
2080 for (Index c = 0; c < ncols; c++)
2081 for (Index r = 0; r < nrows; r++)
2082 for (Index p = 0; p < npages; p++)
2083 for (Index b = 0; b < nbooks; b++)
2084 for (Index s = 0; s < nshelves; s++)
2085 for (Index v = 0; v < nvitrines; v++)
2086 for (Index l = 0; l < nlibraries; l++) {
2088 var1(l, v, s, b, p, r, c) - var2(l, v, s, b, p, r, c);
2090 if (std::isnan(var1(l, v, s, b, p, r, c)) ||
2091 std::isnan(var2(l, v, s, b, p, r, c))) {
2092 if (std::isnan(var1(l, v, s, b, p, r, c)) &&
2093 std::isnan(var2(l, v, s, b, p, r, c))) {
2095 } else if (std::isnan(var1(l, v, s, b, p, r, c))) {
2097 os << "Nan found in
" << var1name << ", but there is no
"
2098 << "NaN at same position in
" << var2name << ".\nThis
"
2099 << "is not allowed.
";
2100 throw runtime_error(os.str());
2103 os << "Nan found in
" << var2name << ", but there is no
"
2104 << "NaN at same position in
" << var1name << ".\nThis
"
2105 << "is not allowed.
";
2106 throw runtime_error(os.str());
2110 if (abs(diff) > abs(maxdiff)) {
2115 if (abs(maxdiff) > maxabsdiff) {
2117 os << var1name << "-
" << var2name << " FAILED!\n
";
2118 if (error_message.length()) os << error_message << "\n
";
2119 os << "Max allowed deviation set to :
" << maxabsdiff << endl
2120 << "but the tensors deviate with:
" << maxdiff << endl;
2121 throw runtime_error(os.str());
2125 out2 << " " << var1name << "-
" << var2name
2126 << " OK (maximum difference =
" << maxdiff << ").\n
";
2129/* Workspace method: Doxygen documentation will be auto-generated */
2130void Compare(const ArrayOfVector& var1,
2131 const ArrayOfVector& var2,
2132 const Numeric& maxabsdiff,
2133 const String& error_message,
2134 const String& var1name,
2135 const String& var2name,
2138 const Verbosity& verbosity) {
2139 if (var1.nelem() != var2.nelem()) {
2141 os << "The two arrays
do not have the same size.
" << endl
2142 << var1name << " nelem:
" << var1.nelem() << endl
2143 << var2name << " nelem:
" << var2.nelem() << endl;
2144 throw runtime_error(os.str());
2147 bool failed = false;
2148 ostringstream fail_msg;
2149 for (Index i = 0; i < var1.nelem(); i++) {
2151 ostringstream vn1, vn2;
2152 vn1 << var1name << "[
" << i << "]
";
2153 vn2 << var2name << "[
" << i << "]
";
2163 } catch (const std::runtime_error& e) {
2167 << "Mismatch at array index:
" << i << endl;
2171 if (failed) throw runtime_error(fail_msg.str());
2174/* Workspace method: Doxygen documentation will be auto-generated */
2175void Compare(const ArrayOfMatrix& var1,
2176 const ArrayOfMatrix& var2,
2177 const Numeric& maxabsdiff,
2178 const String& error_message,
2179 const String& var1name,
2180 const String& var2name,
2183 const Verbosity& verbosity) {
2184 if (var1.nelem() != var2.nelem()) {
2186 os << "The two arrays
do not have the same size.
" << endl
2187 << var1name << " nelem:
" << var1.nelem() << endl
2188 << var2name << " nelem:
" << var2.nelem() << endl;
2189 throw runtime_error(os.str());
2192 bool failed = false;
2193 ostringstream fail_msg;
2194 for (Index i = 0; i < var1.nelem(); i++) {
2196 ostringstream vn1, vn2;
2197 vn1 << var1name << "[
" << i << "]
";
2198 vn2 << var2name << "[
" << i << "]
";
2208 } catch (const std::runtime_error& e) {
2212 << "Mismatch at array index:
" << i << endl;
2216 if (failed) throw runtime_error(fail_msg.str());
2219/* Workspace method: Doxygen documentation will be auto-generated */
2220void Compare(const ArrayOfTensor7& var1,
2221 const ArrayOfTensor7& var2,
2222 const Numeric& maxabsdiff,
2223 const String& error_message,
2224 const String& var1name,
2225 const String& var2name,
2228 const Verbosity& verbosity) {
2229 if (var1.nelem() != var2.nelem()) {
2231 os << "The two arrays
do not have the same size.
" << endl
2232 << var1name << " nelem:
" << var1.nelem() << endl
2233 << var2name << " nelem:
" << var2.nelem() << endl;
2234 throw runtime_error(os.str());
2237 bool failed = false;
2238 ostringstream fail_msg;
2239 for (Index i = 0; i < var1.nelem(); i++) {
2241 ostringstream vn1, vn2;
2242 vn1 << var1name << "[
" << i << "]
";
2243 vn2 << var2name << "[
" << i << "]
";
2253 } catch (const std::runtime_error& e) {
2257 << "Mismatch at array index:
" << i << endl;
2261 if (failed) throw runtime_error(fail_msg.str());
2264/* Workspace method: Doxygen documentation will be auto-generated */
2265void Compare(const GriddedField3& var1,
2266 const GriddedField3& var2,
2267 const Numeric& maxabsdiff,
2268 const String& error_message,
2269 const String& var1name,
2270 const String& var2name,
2273 const Verbosity& verbosity) {
2274 for (Index i = 0; i < var1.get_dim(); i++) {
2275 if (var1.get_grid_size(i) != var2.get_grid_size(i)) {
2277 os << var1name << " and
" << var2name << " grid
" << i
2278 << " do not have the same size:
" << var1.get_grid_size(i)
2279 << " !=
" << var2.get_grid_size(i);
2280 throw runtime_error(os.str());
2282 if (var1.get_grid_name(i) != var2.get_grid_name(i)) {
2284 os << var1name << " and
" << var2name << " grid
" << i
2285 << " do not have the same name:
" << var1.get_grid_name(i)
2286 << " !=
" << var2.get_grid_name(i);
2287 throw runtime_error(os.str());
2302/* Workspace method: Doxygen documentation will be auto-generated */
2303void Compare(const Sparse& var1,
2305 const Numeric& maxabsdiff,
2306 const String& error_message,
2307 const String& var1name,
2308 const String& var2name,
2311 const Verbosity& verbosity) {
2312 const Index nrows = var1.nrows();
2313 const Index ncols = var1.ncols();
2315 if (var2.nrows() != nrows || var2.ncols() != ncols) {
2317 os << var1name << " (
" << nrows << ",
" << ncols << ") and
" << var2name
2318 << " (
" << var2.nrows() << ",
" << var2.ncols()
2319 << ")
do not have the same size.
";
2320 throw runtime_error(os.str());
2323 Numeric maxdiff = 0.0;
2325 for (Index r = 0; r < nrows; r++) {
2326 for (Index c = 0; c < ncols; c++) {
2327 Numeric diff = var1(r, c) - var2(r, c);
2329 if (std::isnan(var1(r, c)) || std::isnan(var2(r, c))) {
2330 if (std::isnan(var1(r, c)) && std::isnan(var2(r, c))) {
2332 } else if (std::isnan(var1(r, c))) {
2334 os << "Nan found in
" << var1name << ", but there is no
"
2335 << "NaN at same position in
" << var2name << ".\nThis
"
2336 << "is not allowed.
";
2337 throw runtime_error(os.str());
2340 os << "Nan found in
" << var2name << ", but there is no
"
2341 << "NaN at same position in
" << var1name << ".\nThis
"
2342 << "is not allowed.
";
2343 throw runtime_error(os.str());
2347 if (abs(diff) > abs(maxdiff)) {
2353 if (abs(maxdiff) > maxabsdiff) {
2355 os << var1name << "-
" << var2name << " FAILED!\n
";
2356 if (error_message.length()) os << error_message << "\n
";
2357 os << "Max allowed deviation set to :
" << maxabsdiff << endl
2358 << "but the matrices deviate with:
" << maxdiff << endl;
2359 throw runtime_error(os.str());
2363 out2 << " " << var1name << "-
" << var2name
2364 << " OK (maximum difference =
" << maxdiff << ").\n
";
2367/* Workspace method: Doxygen documentation will be auto-generated */
2368void Compare(const SingleScatteringData& var1,
2369 const SingleScatteringData& var2,
2370 const Numeric& maxabsdiff,
2371 const String& error_message,
2372 const String& var1name,
2373 const String& var2name,
2376 const Verbosity& verbosity) {
2377 if (var1.ptype != var2.ptype) {
2378 std::ostringstream os;
2379 os << "The particle types don
't match: " << std::endl
2380 << var1name << " = " << PTypeToString(var1.ptype) << ", " << var2name
2381 << " = " << PTypeToString(var2.ptype) << std::endl;
2382 throw std::runtime_error(os.str());
2384 Compare(var1.f_grid,
2388 var1name + ".f_grid",
2389 var2name + ".f_grid",
2393 Compare(var1.T_grid,
2397 var1name + ".T_grid",
2398 var2name + ".T_grid",
2402 Compare(var1.za_grid,
2406 var1name + ".za_grid",
2407 var2name + ".za_grid",
2411 Compare(var1.aa_grid,
2415 var1name + ".aa_grid",
2416 var2name + ".aa_grid",
2420 Compare(var1.pha_mat_data,
2424 var1name + ".pha_mat_data",
2425 var2name + ".pha_mat_data",
2429 Compare(var1.ext_mat_data,
2433 var1name + ".ext_mat_data",
2434 var2name + ".ext_mat_data",
2438 Compare(var1.abs_vec_data,
2442 var1name + ".abs_vec_data",
2443 var2name + ".abs_vec_data",
2449inline void _cr_internal_(const Numeric& var1,
2450 const Numeric& var2,
2451 const Numeric& maxabsreldiff,
2452 const String& error_message,
2453 const String& var1name,
2454 const String& var2name,
2458 if (var1 not_eq 0. and var2 not_eq 0.) {
2459 const Numeric absreldiff = abs(var1 / var2 - 1);
2460 if (absreldiff > maxabsreldiff) {
2462 os << var1name << "-" << var2name << " FAILED!\n";
2463 if (error_message.length()) os << error_message << "\n";
2464 os << "Max allowed deviation set to: " << maxabsreldiff * 100.0 << "%"
2466 << "but the input deviate with: " << absreldiff * 100.0 << "%\n"
2467 << "If you compare non-scalar variables, the reported deviation is\n"
2468 << "the first one found violating the criterion. The maximum\n"
2469 << "difference can be higher.\n";
2470 throw runtime_error(os.str());
2475inline void _cr_internal_(const ConstVectorView var1,
2476 const ConstVectorView var2,
2477 const Numeric& maxabsreldiff,
2478 const String& error_message,
2479 const String& var1name,
2480 const String& var2name,
2483 const Verbosity& verbosity) {
2484 const Index n = var1.nelem();
2485 if (var2.nelem() not_eq n)
2486 throw std::runtime_error("Cannot compare variables of different size");
2487 for (Index i = 0; i < n; i++)
2488 _cr_internal_(var1[i],
2499inline void _cr_internal_(const ConstMatrixView var1,
2500 const ConstMatrixView var2,
2501 const Numeric& maxabsreldiff,
2502 const String& error_message,
2503 const String& var1name,
2504 const String& var2name,
2507 const Verbosity& verbosity) {
2508 const Index n = var1.nrows();
2509 if (var2.nrows() not_eq n)
2510 throw std::runtime_error("Cannot compare variables of different size");
2511 for (Index i = 0; i < n; i++)
2512 _cr_internal_(var1(i, joker),
2523inline void _cr_internal_(const ConstTensor3View var1,
2524 const ConstTensor3View var2,
2525 const Numeric& maxabsreldiff,
2526 const String& error_message,
2527 const String& var1name,
2528 const String& var2name,
2531 const Verbosity& verbosity) {
2532 const Index n = var1.npages();
2533 if (var2.npages() not_eq n)
2534 throw std::runtime_error("Cannot compare variables of different size");
2535 for (Index i = 0; i < n; i++)
2536 _cr_internal_(var1(i, joker, joker),
2537 var2(i, joker, joker),
2547inline void _cr_internal_(const ConstTensor4View var1,
2548 const ConstTensor4View var2,
2549 const Numeric& maxabsreldiff,
2550 const String& error_message,
2551 const String& var1name,
2552 const String& var2name,
2555 const Verbosity& verbosity) {
2556 const Index n = var1.nbooks();
2557 if (var2.nbooks() not_eq n)
2558 throw std::runtime_error("Cannot compare variables of different size");
2559 for (Index i = 0; i < n; i++)
2560 _cr_internal_(var1(i, joker, joker, joker),
2561 var2(i, joker, joker, joker),
2571inline void _cr_internal_(const ConstTensor5View var1,
2572 const ConstTensor5View var2,
2573 const Numeric& maxabsreldiff,
2574 const String& error_message,
2575 const String& var1name,
2576 const String& var2name,
2579 const Verbosity& verbosity) {
2580 const Index n = var1.nshelves();
2581 if (var2.nshelves() not_eq n)
2582 throw std::runtime_error("Cannot compare variables of different size");
2583 for (Index i = 0; i < n; i++)
2584 _cr_internal_(var1(i, joker, joker, joker, joker),
2585 var2(i, joker, joker, joker, joker),
2595inline void _cr_internal_(const ConstTensor6View var1,
2596 const ConstTensor6View var2,
2597 const Numeric& maxabsreldiff,
2598 const String& error_message,
2599 const String& var1name,
2600 const String& var2name,
2603 const Verbosity& verbosity) {
2604 const Index n = var1.nvitrines();
2605 if (var2.nvitrines() not_eq n)
2606 throw std::runtime_error("Cannot compare variables of different size");
2607 for (Index i = 0; i < n; i++)
2608 _cr_internal_(var1(i, joker, joker, joker, joker, joker),
2609 var2(i, joker, joker, joker, joker, joker),
2619inline void _cr_internal_(const ConstTensor7View var1,
2620 const ConstTensor7View var2,
2621 const Numeric& maxabsreldiff,
2622 const String& error_message,
2623 const String& var1name,
2624 const String& var2name,
2627 const Verbosity& verbosity) {
2628 const Index n = var1.nlibraries();
2629 if (var2.nlibraries() not_eq n)
2630 throw std::runtime_error("Cannot compare variables of different size");
2631 for (Index i = 0; i < n; i++)
2632 _cr_internal_(var1(i, joker, joker, joker, joker, joker, joker),
2633 var2(i, joker, joker, joker, joker, joker, joker),
2643inline void _cr_internal_(const PropagationMatrix& var1,
2644 const PropagationMatrix& var2,
2645 const Numeric& maxabsreldiff,
2646 const String& error_message,
2647 const String& var1name,
2648 const String& var2name,
2651 const Verbosity& verbosity) {
2652 _cr_internal_(var1.Data(),
2663inline void _cr_internal_(const StokesVector& var1,
2664 const StokesVector& var2,
2665 const Numeric& maxabsreldiff,
2666 const String& error_message,
2667 const String& var1name,
2668 const String& var2name,
2671 const Verbosity& verbosity) {
2672 _cr_internal_(var1.Data(),
2684inline void _cr_internal_(const Array<T>& var1,
2685 const Array<T>& var2,
2686 const Numeric& maxabsreldiff,
2687 const String& error_message,
2688 const String& var1name,
2689 const String& var2name,
2692 const Verbosity& verbosity) {
2693 const Index n = var1.nelem();
2694 if (var2.nelem() not_eq n)
2695 throw std::runtime_error("Cannot compare arrays of different length");
2696 for (Index i = 0; i < n; i++)
2697 _cr_internal_(var1[i],
2708/* Workspace method: Doxygen documentation will be auto-generated */
2709void CompareRelative(const Numeric& var1,
2710 const Numeric& var2,
2711 const Numeric& maxabsreldiff,
2712 const String& error_message,
2713 const String& var1name,
2714 const String& var2name,
2717 const Verbosity& verbosity) {
2728void CompareRelative(const Vector& var1,
2730 const Numeric& maxabsreldiff,
2731 const String& error_message,
2732 const String& var1name,
2733 const String& var2name,
2736 const Verbosity& verbosity) {
2747void CompareRelative(const Matrix& var1,
2749 const Numeric& maxabsreldiff,
2750 const String& error_message,
2751 const String& var1name,
2752 const String& var2name,
2755 const Verbosity& verbosity) {
2766void CompareRelative(const Tensor3& var1,
2767 const Tensor3& var2,
2768 const Numeric& maxabsreldiff,
2769 const String& error_message,
2770 const String& var1name,
2771 const String& var2name,
2774 const Verbosity& verbosity) {
2785void CompareRelative(const Tensor4& var1,
2786 const Tensor4& var2,
2787 const Numeric& maxabsreldiff,
2788 const String& error_message,
2789 const String& var1name,
2790 const String& var2name,
2793 const Verbosity& verbosity) {
2804void CompareRelative(const Tensor5& var1,
2805 const Tensor5& var2,
2806 const Numeric& maxabsreldiff,
2807 const String& error_message,
2808 const String& var1name,
2809 const String& var2name,
2812 const Verbosity& verbosity) {
2823void CompareRelative(const Tensor6& var1,
2824 const Tensor6& var2,
2825 const Numeric& maxabsreldiff,
2826 const String& error_message,
2827 const String& var1name,
2828 const String& var2name,
2831 const Verbosity& verbosity) {
2842void CompareRelative(const Tensor7& var1,
2843 const Tensor7& var2,
2844 const Numeric& maxabsreldiff,
2845 const String& error_message,
2846 const String& var1name,
2847 const String& var2name,
2850 const Verbosity& verbosity) {
2861void CompareRelative(const ArrayOfVector& var1,
2862 const ArrayOfVector& var2,
2863 const Numeric& maxabsreldiff,
2864 const String& error_message,
2865 const String& var1name,
2866 const String& var2name,
2869 const Verbosity& verbosity) {
2880void CompareRelative(const ArrayOfMatrix& var1,
2881 const ArrayOfMatrix& var2,
2882 const Numeric& maxabsreldiff,
2883 const String& error_message,
2884 const String& var1name,
2885 const String& var2name,
2888 const Verbosity& verbosity) {
2899void CompareRelative(const ArrayOfTensor3& var1,
2900 const ArrayOfTensor3& var2,
2901 const Numeric& maxabsreldiff,
2902 const String& error_message,
2903 const String& var1name,
2904 const String& var2name,
2907 const Verbosity& verbosity) {
2918void CompareRelative(const ArrayOfTensor4& var1,
2919 const ArrayOfTensor4& var2,
2920 const Numeric& maxabsreldiff,
2921 const String& error_message,
2922 const String& var1name,
2923 const String& var2name,
2926 const Verbosity& verbosity) {
2937void CompareRelative(const ArrayOfTensor5& var1,
2938 const ArrayOfTensor5& var2,
2939 const Numeric& maxabsreldiff,
2940 const String& error_message,
2941 const String& var1name,
2942 const String& var2name,
2945 const Verbosity& verbosity) {
2956void CompareRelative(const ArrayOfTensor6& var1,
2957 const ArrayOfTensor6& var2,
2958 const Numeric& maxabsreldiff,
2959 const String& error_message,
2960 const String& var1name,
2961 const String& var2name,
2964 const Verbosity& verbosity) {
2975void CompareRelative(const ArrayOfTensor7& var1,
2976 const ArrayOfTensor7& var2,
2977 const Numeric& maxabsreldiff,
2978 const String& error_message,
2979 const String& var1name,
2980 const String& var2name,
2983 const Verbosity& verbosity) {
2994void CompareRelative(const ArrayOfArrayOfVector& var1,
2995 const ArrayOfArrayOfVector& var2,
2996 const Numeric& maxabsreldiff,
2997 const String& error_message,
2998 const String& var1name,
2999 const String& var2name,
3002 const Verbosity& verbosity) {
3013void CompareRelative(const ArrayOfArrayOfMatrix& var1,
3014 const ArrayOfArrayOfMatrix& var2,
3015 const Numeric& maxabsreldiff,
3016 const String& error_message,
3017 const String& var1name,
3018 const String& var2name,
3021 const Verbosity& verbosity) {
3032void CompareRelative(const ArrayOfArrayOfTensor3& var1,
3033 const ArrayOfArrayOfTensor3& var2,
3034 const Numeric& maxabsreldiff,
3035 const String& error_message,
3036 const String& var1name,
3037 const String& var2name,
3040 const Verbosity& verbosity) {
3051void CompareRelative(const ArrayOfArrayOfTensor4& var1,
3052 const ArrayOfArrayOfTensor4& var2,
3053 const Numeric& maxabsreldiff,
3054 const String& error_message,
3055 const String& var1name,
3056 const String& var2name,
3059 const Verbosity& verbosity) {
3070void CompareRelative(const ArrayOfArrayOfTensor5& var1,
3071 const ArrayOfArrayOfTensor5& var2,
3072 const Numeric& maxabsreldiff,
3073 const String& error_message,
3074 const String& var1name,
3075 const String& var2name,
3078 const Verbosity& verbosity) {
3089void CompareRelative(const ArrayOfArrayOfTensor6& var1,
3090 const ArrayOfArrayOfTensor6& var2,
3091 const Numeric& maxabsreldiff,
3092 const String& error_message,
3093 const String& var1name,
3094 const String& var2name,
3097 const Verbosity& verbosity) {
3108void CompareRelative(const ArrayOfArrayOfTensor7& var1,
3109 const ArrayOfArrayOfTensor7& var2,
3110 const Numeric& maxabsreldiff,
3111 const String& error_message,
3112 const String& var1name,
3113 const String& var2name,
3116 const Verbosity& verbosity) {
3128void CompareRelative(const PropagationMatrix& var1,
3129 const PropagationMatrix& var2,
3130 const Numeric& maxabsreldiff,
3131 const String& error_message,
3132 const String& var1name,
3133 const String& var2name,
3136 const Verbosity& verbosity) {
3148void CompareRelative(const ArrayOfPropagationMatrix& var1,
3149 const ArrayOfPropagationMatrix& var2,
3150 const Numeric& maxabsreldiff,
3151 const String& error_message,
3152 const String& var1name,
3153 const String& var2name,
3156 const Verbosity& verbosity) {
3168void CompareRelative(const ArrayOfArrayOfPropagationMatrix& var1,
3169 const ArrayOfArrayOfPropagationMatrix& var2,
3170 const Numeric& maxabsreldiff,
3171 const String& error_message,
3172 const String& var1name,
3173 const String& var2name,
3176 const Verbosity& verbosity) {
3188void CompareRelative(const StokesVector& var1,
3189 const StokesVector& var2,
3190 const Numeric& maxabsreldiff,
3191 const String& error_message,
3192 const String& var1name,
3193 const String& var2name,
3196 const Verbosity& verbosity) {
3208void CompareRelative(const ArrayOfStokesVector& var1,
3209 const ArrayOfStokesVector& var2,
3210 const Numeric& maxabsreldiff,
3211 const String& error_message,
3212 const String& var1name,
3213 const String& var2name,
3216 const Verbosity& verbosity) {
3228void CompareRelative(const ArrayOfArrayOfStokesVector& var1,
3229 const ArrayOfArrayOfStokesVector& var2,
3230 const Numeric& maxabsreldiff,
3231 const String& error_message,
3232 const String& var1name,
3233 const String& var2name,
3236 const Verbosity& verbosity) {
3248/* Workspace method: Doxygen documentation will be auto-generated */
3249void CompareRelative(const EnergyLevelMap& var1,
3250 const EnergyLevelMap& var2,
3251 const Numeric& maxabsreldiff,
3252 const String& error_message,
3253 const String& var1name,
3254 const String& var2name,
3257 const Verbosity& verbosity) {
3258 _cr_internal_(var1.value,
3267 _cr_internal_(var1.vib_energy,
3278void PrintPhysicalConstants(const Verbosity& verbosity) {
3281 out0 << std::setprecision(15) << std::scientific;
3282 out0 << "---------------------------------------------------------\n"
3283 << "Numerical const in ARTS \tValue\n"
3284 << "Avogadro's constant: \t
" << Constant::avogadro_constant << '\n'
3285 << "Bohr
's magneton: \t " << Constant::bohr_magneton << '\n
'
3286 << "Boltzmann's constant: \t
" << Constant::boltzmann_constant << '\n'
3287 << "Elemental charge: \t
" << Constant::elementary_charge << '\n'
3288 << "Electron mass: \t
" << Constant::electron_mass << '\n'
3289 << "Ideal gas constant: \t
" << Constant::ideal_gas_constant << '\n'
3290 << "Planck
's constant: \t " << Constant::planck_constant << '\n
'
3291 << "Speed of light: \t " << Constant::speed_of_light << '\n
'
3292 << "Vacuum permittivity: \t " << Constant::vacuum_permittivity << '\n
'
3293 << "Doppler constant: \t " << std::sqrt(Constant::doppler_broadening_const_squared) << '\n
'
3294 << "---------------------------------------------------------\n";
This file contains the definition of Array.
base max(const Array< base > &x)
Max function.
base min(const Array< base > &x)
Min function.
void arts_exit(int status)
This is the exit function of ARTS.
The global header file for ARTS.
Constants of physical expressions as constexpr.
TimeStep mean(const ArrayOfTimeStep &dt)
Returns the mean time step.
Stuff related to time in ARTS.
Index nelem() const ARTS_NOEXCEPT
void mult(MatrixView C, ConstMatrixView A, const Block &B)
#define ARTS_ASSERT(condition,...)
#define ARTS_USER_ERROR_IF(condition,...)
Class to map energy levels.
The declarations of all the exception classes.
Implementation of gridded fields.
std::vector< T > linspace(T s, T e, typename std::vector< T >::size_type count) noexcept
void VectorLinSpace(Vector &x, const Numeric &start, const Numeric &stop, const Numeric &step, const Verbosity &verbosity)
WORKSPACE METHOD: VectorLinSpace.
void IndexStepUp(Index &xout, const Index &xin, const Verbosity &)
WORKSPACE METHOD: IndexStepUp.
void VectorDivide(Vector &out, const Vector &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: VectorDivide.
void Tensor4Multiply(Tensor4 &out, const Tensor4 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor4Multiply.
void MatrixSubtract(Matrix &out, const Matrix &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixSubtract.
void VectorCrop(Vector &out, const Vector &in, const Numeric &min_value, const Numeric &max_value, const Verbosity &)
WORKSPACE METHOD: VectorCrop.
void Matrix1ColFromVector(Matrix &m, const Vector &v, const Verbosity &)
WORKSPACE METHOD: Matrix1ColFromVector.
void Tensor7SetConstant(Tensor7 &x, const Index &nlibraries, const Index &nvitrines, const Index &nshelves, const Index &nbooks, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor7SetConstant.
void ArrayOfIndexSetConstant(ArrayOfIndex &aoi, const Index &nelem, const Index &value, const Verbosity &)
WORKSPACE METHOD: ArrayOfIndexSetConstant.
void IndexSubtract(Index &out, const Index &in, const Index &value, const Verbosity &)
WORKSPACE METHOD: IndexSubtract.
void Tensor3Multiply(Tensor3 &out, const Tensor3 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor3Multiply.
void VectorFlip(Vector &out, const Vector &in, const Verbosity &)
WORKSPACE METHOD: VectorFlip.
void IndexDivide(Index &out, const Index &in, const Index &value, const Verbosity &)
WORKSPACE METHOD: IndexDivide.
void Matrix2RowFromVectors(Matrix &m, const Vector &v1, const Vector &v2, const Verbosity &)
WORKSPACE METHOD: Matrix2RowFromVectors.
void NumericClip(Numeric &out, const Numeric &in, const Numeric &limit_low, const Numeric &limit_high, const Verbosity &)
WORKSPACE METHOD: NumericClip.
void Tensor5SetConstant(Tensor5 &x, const Index &nshelves, const Index &nbooks, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor5SetConstant.
void ArrayOfTimeNLinSpace(ArrayOfTime &x, const Index &n, const String &start, const String &stop, const Verbosity &)
WORKSPACE METHOD: ArrayOfTimeNLinSpace.
void Trapz(Numeric &out, const Vector &x, const Vector &y, const Verbosity &)
WORKSPACE METHOD: Trapz.
void DiagonalMatrix(Matrix &X, const Vector &diag, const Verbosity &)
WORKSPACE METHOD: DiagonalMatrix.
void Tensor3ExtractFromTensor4(Tensor3 &t3, const Tensor4 &t4, const Index &index, const String &direction, const Verbosity &)
WORKSPACE METHOD: Tensor3ExtractFromTensor4.
void MatrixMultiply(Matrix &out, const Matrix &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixMultiply.
void SparseSparseMultiply(Sparse &Y, const Sparse &M, const Sparse &X, const Verbosity &)
WORKSPACE METHOD: SparseSparseMultiply.
void MatrixSetConstant(Matrix &x, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixSetConstant.
void VectorMultiply(Vector &out, const Vector &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: VectorMultiply.
void Tensor6SetConstant(Tensor6 &x, const Index &nvitrines, const Index &nshelves, const Index &nbooks, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor6SetConstant.
void IndexAdd(Index &out, const Index &in, const Index &value, const Verbosity &)
WORKSPACE METHOD: IndexAdd.
void VectorSubtractElementwise(Vector &c, const Vector &a, const Vector &b, const Verbosity &)
WORKSPACE METHOD: VectorSubtractElementwise.
void VectorExtractFromMatrix(Vector &v, const Matrix &m, const Index &index, const String &direction, const Verbosity &)
WORKSPACE METHOD: VectorExtractFromMatrix.
constexpr Numeric NAT_LOG_2
void MatrixReshapeTensor3(Matrix &m, const Tensor3 &t, const Verbosity &)
WORKSPACE METHOD: MatrixReshapeTensor3.
void Tensor3Add(Tensor3 &out, const Tensor3 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor3Add.
void VectorGaussian(Vector &y, const Vector &x, const Numeric &x0, const Numeric &si, const Numeric &fwhm, const Verbosity &)
WORKSPACE METHOD: VectorGaussian.
void VectorAddElementwise(Vector &c, const Vector &a, const Vector &b, const Verbosity &)
WORKSPACE METHOD: VectorAddElementwise.
void RationalDivide(Rational &out, const Rational &in, const Rational &value, const Verbosity &)
WORKSPACE METHOD: RationalDivide.
void Matrix1RowFromVector(Matrix &m, const Vector &v, const Verbosity &)
WORKSPACE METHOD: Matrix1RowFromVector.
void Tensor3FromVector(Tensor3 &m, const Vector &v, const Verbosity &)
WORKSPACE METHOD: Tensor3FromVector.
void Tensor6Multiply(Tensor6 &out, const Tensor6 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor6Multiply.
void NumericMultiply(Numeric &out, const Numeric &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: NumericMultiply.
void NumericSubtract(Numeric &out, const Numeric &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: NumericSubtract.
void RationalSubtract(Rational &out, const Rational &in, const Rational &value, const Verbosity &)
WORKSPACE METHOD: RationalSubtract.
void VectorSubtract(Vector &out, const Vector &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: VectorSubtract.
void VectorDivideElementwise(Vector &c, const Vector &a, const Vector &b, const Verbosity &)
WORKSPACE METHOD: VectorDivideElementwise.
void IndexMultiply(Index &out, const Index &in, const Index &value, const Verbosity &)
WORKSPACE METHOD: IndexMultiply.
void Matrix2ColFromVectors(Matrix &m, const Vector &v1, const Vector &v2, const Verbosity &)
WORKSPACE METHOD: Matrix2ColFromVectors.
void NumericDivide(Numeric &out, const Numeric &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: NumericDivide.
void ArrayOfIndexLinSpace(ArrayOfIndex &x, const Index &start, const Index &stop, const Index &step, const Verbosity &verbosity)
WORKSPACE METHOD: ArrayOfIndexLinSpace.
void MatrixDivide(Matrix &out, const Matrix &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixDivide.
void VectorMultiplyElementwise(Vector &c, const Vector &a, const Vector &b, const Verbosity &)
WORKSPACE METHOD: VectorMultiplyElementwise.
void VectorSparseMultiply(Vector &y, const Sparse &M, const Vector &x, const Verbosity &)
WORKSPACE METHOD: VectorSparseMultiply.
void VectorNLinSpace(Vector &x, const Index &n, const Numeric &start, const Numeric &stop, const Verbosity &verbosity)
WORKSPACE METHOD: VectorNLinSpace.
void VectorNLinSpaceVector(Vector &x, const Index &n, const Vector &y, const Verbosity &verbosity)
WORKSPACE METHOD: VectorNLinSpaceVector.
void Tensor4SetConstant(Tensor4 &x, const Index &nbooks, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor4SetConstant.
void Tensor5Multiply(Tensor5 &out, const Tensor5 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor5Multiply.
void Tensor4Add(Tensor4 &out, const Tensor4 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor4Add.
void VectorLogSpace(Vector &x, const Numeric &start, const Numeric &stop, const Numeric &step, const Verbosity &verbosity)
WORKSPACE METHOD: VectorLogSpace.
void Matrix3RowFromVectors(Matrix &m, const Vector &v1, const Vector &v2, const Vector &v3, const Verbosity &)
WORKSPACE METHOD: Matrix3RowFromVectors.
void Tensor7Multiply(Tensor7 &out, const Tensor7 &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: Tensor7Multiply.
void VectorMatrixMultiply(Vector &y, const Matrix &M, const Vector &x, const Verbosity &)
WORKSPACE METHOD: VectorMatrixMultiply.
void IndexStepDown(Index &xout, const Index &xin, const Verbosity &)
WORKSPACE METHOD: IndexStepDown.
void VectorInsertGridPoints(Vector &og, const Vector &ingrid, const Vector &points, const Verbosity &verbosity)
WORKSPACE METHOD: VectorInsertGridPoints.
void FlagOff(Index &x, const Verbosity &)
WORKSPACE METHOD: FlagOff.
void VectorAdd(Vector &out, const Vector &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: VectorAdd.
void RationalAdd(Rational &out, const Rational &in, const Rational &value, const Verbosity &)
WORKSPACE METHOD: RationalAdd.
void Matrix3ColFromVectors(Matrix &m, const Vector &v1, const Vector &v2, const Vector &v3, const Verbosity &)
WORKSPACE METHOD: Matrix3ColFromVectors.
void MatrixIdentity(Matrix &out, const Index &n, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixIdentity.
void VectorClip(Vector &out, const Vector &in, const Numeric &limit_low, const Numeric &limit_high, const Verbosity &)
WORKSPACE METHOD: VectorClip.
void Tensor3SetConstant(Tensor3 &x, const Index &npages, const Index &nrows, const Index &ncols, const Numeric &value, const Verbosity &verbosity)
WORKSPACE METHOD: Tensor3SetConstant.
void SparseIdentity(Sparse &X, const Index &n, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: SparseIdentity.
void MatrixMatrixMultiply(Matrix &Y, const Matrix &M, const Matrix &X, const Verbosity &)
WORKSPACE METHOD: MatrixMatrixMultiply.
void MatrixExtractFromTensor3(Matrix &m, const Tensor3 &t3, const Index &index, const String &direction, const Verbosity &)
WORKSPACE METHOD: MatrixExtractFromTensor3.
void FlagOn(Index &x, const Verbosity &)
WORKSPACE METHOD: FlagOn.
void MatrixCopySparse(Matrix &out, const Sparse &in, const Verbosity &)
WORKSPACE METHOD: MatrixCopySparse.
void MatrixAdd(Matrix &out, const Matrix &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: MatrixAdd.
void NumericFromVector(Numeric &out, const Vector &in, const String &op, const Verbosity &)
WORKSPACE METHOD: NumericFromVector.
void RationalMultiply(Rational &out, const Rational &in, const Rational &value, const Verbosity &)
WORKSPACE METHOD: RationalMultiply.
void NumericAdd(Numeric &out, const Numeric &in, const Numeric &value, const Verbosity &)
WORKSPACE METHOD: NumericAdd.
void MatrixGaussian(Matrix &Y, const Vector &x_row, const Numeric &x0_row, const Numeric &si_row, const Numeric &fwhm_row, const Vector &x_col, const Numeric &x0_col, const Numeric &si_col, const Numeric &fwhm_col, const Verbosity &)
WORKSPACE METHOD: MatrixGaussian.
void nlinspace(Vector &x, const Numeric start, const Numeric stop, const Index n)
nlinspace
Numeric fac(const Index n)
fac
Numeric last(ConstVectorView x)
last
Declarations having to do with the four output streams.
This file contains the definition of String, the ARTS string class.
constexpr Numeric pi
The following mathematical constants are generated in python Decimal package by the code:
constexpr Numeric ln_2
Natural logarithm of 2.
Scattering database structure and functions.
Contains sorting routines.
void get_sorted_indexes(ArrayOfIndex &sorted, const T &data)
get_sorted_indexes
Class to handle time in ARTS.