70 inline void get_scoor(
long n, T& b)
const { b = xmin + n * step; }
73 if (n < 0 || n >= q)
return 0;
97 if (n < 0 || n >= q)
return 0;
104 void print(std::ostream& file)
const;
117 : q(fq), xmin(fxmin), xmax(fxmax) {
118 mfunname(
"template<class T> EqualStepCoorMesh<T>::EqualStepCoorMesh<T>(long "
119 "fq, T fxmin, T fxmax)");
146 step = (fxmax - fxmin) / q;
151 if (x < xmin || x >= xmax) {
155 n1 = long((x - xmin) / step);
157 mcerr <<
"ERROR in EqualStepCoorMesh<T>::get_interval:\n"
176 if (x < xmin || x >= xmax) {
183 n1 = long((x - xmin) / step);
185 b1 = xmin + step * n1;
187 if (n1 < 0 || n2 > q || b2 > xmax) {
188 mcerr <<
"ERROR in EqualStepCoorMesh<T>::get_interval:\n"
189 <<
"n1 < 0 || n2 > q || b2 > xmax\n";
215 }
else if (x >= xmax) {
222 n1 = long((x - xmin) / step);
228 b1 = xmin + step * n1;
230 if (n1 < 0 || n2 > q || b2 > xmax) {
231 mcerr <<
"ERROR in EqualStepCoorMesh<T>::get_interval_extrap:\n"
232 <<
"n1 < 0 || n2 > q || b2 > xmax\n";
249 Ifile <<
"EqualStepCoorMesh<T>:\n";
251 Ifile <<
"Type of T is (in internal notations) " <<
typeid(T).name() <<
'\n';
252 Iprint4n(file, q, xmin, xmax, step);
265 mfunname(
"istream& operator>>(istream& file, EqualStepCoorMesh<T>& f)");
312template <
class T,
class D>
316#ifndef TLINE_REDUCE_TO_RAW_ARR
317 if (q <= 1)
return -1;
318 if (x < coor[0] || x > coor[q - 1])
return -1;
319 if (x < coor[1])
return 0;
320 if (x >= coor[q - 2])
return q - 2;
323 while (n2 - n1 > 1) {
324 n3 = n1 + (n2 - n1) / 2;
333 if (q <= 1)
return -1;
334 if (x < arr[0] || x > arr[q - 1])
return -1;
335 if (x < arr[1])
return 0;
336 if (x >= arr[q - 2])
return q - 2;
339 while (n2 - n1 > 1) {
340 n3 = n1 + (n2 - n1) / 2;
357template <
class T,
class D>
360 if (n_start < 0 || n_start > q - 1) {
361 mcerr <<
" ERROR in t_find_interval_end(...):\n";
362 mcerr <<
"n_start < 0 || n_start > q-1\n";
366#ifndef TLINE_REDUCE_TO_RAW_ARR
368 if (q - n_start <= 1)
return -1;
369 if (x < coor[n_start] || x > coor[q - 1])
return -1;
370 if (x < coor[n_start + 1])
return n_start;
371 if (x >= coor[q - 2])
return q - 2;
374 while (n2 - n1 > 1) {
375 n3 = n1 + (n2 - n1) / 2;
385 if (q - n_start <= 1)
return -1;
386 if (x < arr[n_start] || x > arr[q - 1])
return -1;
387 if (x < arr[n_start + 1])
return n_start;
388 if (x >= arr[q - 2])
return q - 2;
391 while (n2 - n1 > 1) {
392 n3 = n1 + (n2 - n1) / 2;
428 inline long get_qi(
void)
const {
return q - 1; }
432#ifndef TLINE_REDUCE_TO_RAW_ARR
440 if (n < 0 || n >= q - 1)
return 0;
441#ifndef TLINE_REDUCE_TO_RAW_ARR
443 b2 = (*amesh)[n + 1];
453 int get_interval(T x,
long& n1, T& b1,
long& n2, T& b2)
const;
458 if (n < 0 || n >= q - 1)
return 0;
466 : q(0), xmin(0), xmax(0), x_old(0), n_old(-1), amesh(NULL) {
478 virtual void print(std::ostream& file)
const;
484#ifndef TLINE_REDUCE_TO_RAW_ARR
497template <
class T,
class D>
499 : q(fq), x_old(0), n_old(-1) {
501 mcerr <<
"ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
506#ifndef TLINE_REDUCE_TO_RAW_ARR
510 xmax = (*amesh)[q - 1];
512 amesh = &((*famesh)[0]);
518 mcerr <<
"ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
523#ifdef CHECK_POINT_MESH
525 for (n = 0; n < q - 1; n++) {
526#ifndef TLINE_REDUCE_TO_RAW_ARR
527 if ((*amesh)[n] >= (*amesh)[n + 1])
529 if (amesh[n] >= amesh[n + 1])
532 mcerr <<
"ERROR in PointCoorMesh<T,D>::PointCoorMesh<T,D>:\n"
533 <<
"amesh[n] >= amesh[n+1]\n";
534#ifndef TLINE_REDUCE_TO_RAW_ARR
548 for (n = 0; n < q - 1; n++) {
549#ifndef TLINE_REDUCE_TO_RAW_ARR
550 if ((*amesh)[n] >= (*amesh)[n + 1])
552 if (amesh[n] >= amesh[n + 1])
555 mcerr <<
"ERROR in PointCoorMesh<T,D>::check(void):\n"
556 <<
"amesh[n] >= amesh[n+1]\n";
557#ifndef TLINE_REDUCE_TO_RAW_ARR
568template <
class T,
class D>
570 if (x < xmin || x >= xmax) {
574#ifndef TLINE_REDUCE_TO_RAW_ARR
575 if (n_old >= 0 && x_old <= x) {
576 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
578 n1 = t_find_interval<T, D>(x, q, *amesh);
582 if (n_old >= 0 && x_old <= x) {
583 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
585 n1 = t_find_interval<T, T*>(x, q, amesh);
591 mcerr <<
"ERROR in PointCoorMesh<T,D>::get_interval:\n"
602template <
class T,
class D>
605 if (x < xmin || x >= xmax) {
612#ifndef TLINE_REDUCE_TO_RAW_ARR
613 if (n_old >= 0 && x_old <= x) {
614 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
616 n1 = t_find_interval<T, D>(x, q, *amesh);
620 if (n_old >= 0 && x_old <= x) {
621 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
623 n1 = t_find_interval<T, T*>(x, q, amesh);
628#ifndef TLINE_REDUCE_TO_RAW_ARR
635 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
636 b2 < xmin || b2 > xmax) {
637 mcerr <<
"ERROR in PointCoorMesh<T,D>::get_interval:\n"
638 <<
"n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax "
639 "|| b2 < xmin || b2 > xmax\n";
649template <
class T,
class D>
659#ifndef TLINE_REDUCE_TO_RAW_ARR
664 }
else if (x >= xmax) {
668#ifndef TLINE_REDUCE_TO_RAW_ARR
669 b1 = (*amesh)[q - 2];
675#ifndef TLINE_REDUCE_TO_RAW_ARR
676 if (n_old >= 0 && x_old <= x) {
677 n1 = t_find_interval_end<T, D>(x, q, *amesh, n_old);
679 n1 = t_find_interval<T, D>(x, q, *amesh);
683 if (n_old >= 0 && x_old <= x) {
684 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
686 n1 = t_find_interval<T, T*>(x, q, amesh);
691#ifndef TLINE_REDUCE_TO_RAW_ARR
698 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
699 b2 < xmin || b2 > xmax) {
700 mcerr <<
"ERROR in PointCoorMesh<T,D>::get_interval:\n"
701 <<
"n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > "
702 "xmax || b2 < xmin || b2 > xmax\n";
714template <
class T,
class D>
716 Ifile <<
"PointCoorMesh<T,D>:\n";
718 Ifile <<
"Type of T is (in internal notations) " <<
typeid(T).name() <<
'\n';
719 Ifile <<
"Type of D is (in internal notations) " <<
typeid(D).name() <<
'\n';
722#ifndef TLINE_REDUCE_TO_RAW_ARR
723 Ifile <<
"(*amesh)=" << (*amesh) <<
'\n';
725 Ifile <<
"amesh:" <<
'\n';
728 for (n = 0; n < q; n++) {
738template <
class T,
class D>
763 inline long get_qi(
void)
const {
return q - 1; }
768#ifdef TLINE_REDUCE_TO_RAW_ARR
776 if (n < 0 || n >= q - 1)
return 0;
777#ifdef TLINE_REDUCE_TO_RAW_ARR
779 b2 = (*amesh)[n + 1];
791 int get_interval(T x,
long& n1, T& b1,
long& n2, T& b2)
const;
796 if (n < 0 || n >= q - 1)
return 0;
822#ifdef TLINE_REDUCE_TO_RAW_ARR
835#ifdef TLINE_REDUCE_TO_RAW_ARR
841 void print(std::ostream& file)
const;
848#ifdef TLINE_REDUCE_TO_RAW_ARR
862 : q(fq), mesh(fq), x_old(0), n_old(-1) {
864 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::CopiedPointCoorMesh<T>:\n"
870 for (n = 0; n < q; n++) {
875#ifdef TLINE_REDUCE_TO_RAW_ARR
880 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::PointCoorMesh<T>:\n"
885#ifdef CHECK_POINT_MESH
887 for (n = 0; n < q - 1; n++) {
888#ifdef TLINE_REDUCE_TO_RAW_ARR
889 if ((*amesh)[n] >= (*amesh)[n + 1])
891 if (mesh[n] >= mesh[n + 1])
894 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::PointCoorMesh<T>:\n"
895 <<
"mesh[n] >= mesh[n+1]\n";
906 : q(fmesh.get_qel()), mesh(fmesh), x_old(0), n_old(-1) {
908 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::CopiedPointCoorMesh<T>:\n"
920#ifdef TLINE_REDUCE_TO_RAW_ARR
925 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::PointCoorMesh<T>:\n"
930#ifdef CHECK_POINT_MESH
932 for (n = 0; n < q - 1; n++) {
933#ifdef TLINE_REDUCE_TO_RAW_ARR
934 if ((*amesh)[n] >= (*amesh)[n + 1])
936 if (mesh[n] >= mesh[n + 1])
939 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::PointCoorMesh<T>:\n"
940 <<
"mesh[n] >= mesh[n+1]\n";
951 if (x < xmin || x >= xmax) {
955#ifdef TLINE_REDUCE_TO_RAW_ARR
956 if (n_old >= 0 && x_old <= x) {
957 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
959 n1 = t_find_interval<T, T*>(x, q, amesh);
963 if (n_old >= 0 && x_old <= x) {
964 n1 = t_find_interval_end<T, DynLinArr<T> >(x, q, mesh, n_old);
966 n1 = t_find_interval<T, DynLinArr<T> >(x, q, mesh);
972 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::get_interval:\n"
986 if (x < xmin || x >= xmax) {
993#ifdef TLINE_REDUCE_TO_RAW_ARR
994 if (n_old >= 0 && x_old <= x) {
995 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
997 n1 = t_find_interval<T, T*>(x, q, amesh);
1001 if (n_old >= 0 && x_old <= x) {
1002 n1 = t_find_interval_end<T, DynLinArr<T> >(x, q, mesh, n_old);
1004 n1 = t_find_interval<T, DynLinArr<T> >(x, q, mesh);
1009#ifdef TLINE_REDUCE_TO_RAW_ARR
1016 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
1017 b2 < xmin || b2 > xmax) {
1018 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::get_interval:\n"
1019 <<
"n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax "
1020 "|| b2 < xmin || b2 > xmax\n";
1040#ifdef TLINE_REDUCE_TO_RAW_ARR
1045 }
else if (x >= xmax) {
1049#ifdef TLINE_REDUCE_TO_RAW_ARR
1050 b1 = (*amesh)[q - 2];
1056#ifndef TLINE_REDUCE_TO_RAW_ARR
1057 if (n_old >= 0 && x_old <= x) {
1058 n1 = t_find_interval_end<T, DynLinArr<T> >(x, q, mesh, n_old);
1060 n1 = t_find_interval<T, DynLinArr<T> >(x, q, mesh);
1064 if (n_old >= 0 && x_old <= x) {
1065 n1 = t_find_interval_end<T, T*>(x, q, amesh, n_old);
1067 n1 = t_find_interval<T, T*>(x, q, amesh);
1072#ifndef TLINE_REDUCE_TO_RAW_ARR
1079 if (n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > xmax ||
1080 b2 < xmin || b2 > xmax) {
1081 mcerr <<
"ERROR in CopiedPointCoorMesh<T>::get_interval:\n"
1082 <<
"n1 < 0 || n1 >= q || n2 < 0 || n2 >= q || b1 < xmin || b1 > "
1083 "xmax || b2 < xmin || b2 > xmax\n";
1097 Ifile <<
"CopiedPointCoorMesh<T>:\n";
1099 Ifile <<
"Type of T is (in internal notations) " <<
typeid(T).name() <<
'\n';
1104 Ifile <<
"mesh= " << mesh <<
'\n';
1128 mfunname(
"istream& operator>>(istream& file, CopiedPointCoorMesh<T>& f)");
1178template <
class T,
class B>
1180 mfunnamep(
"template<class T> verify_types(const T* ths, const B* b2, const "
1185 if (
typeid(*b2) !=
typeid(*ths))
return 0;
1186 if (
typeid(*ths) !=
typeid(T)) {
1188 mcerr <<
"Operator == for class T is called for first object of different "
1190 mcerr <<
"This may mean that this operator is missed in one of derived "
1195 *tb2 =
dynamic_cast<const T*
>(b2);
1216 long& n1)
const = 0;
1232 virtual void print(std::ostream& file)
const {
1233 Ifile <<
"AbsCoorMesh: no content.\n";
1241 mfunnamep(
"virtual int operator==(const AbsCoorMesh<T>&)");
1243 mcerr <<
"AbsCoorMesh::operator == cannot be called since this is abstract "
1251 mfunnamep(
"virtual int operator!=(const AbsCoorMesh<T>&)");
1253 mcerr <<
"AbsCoorMesh::operator != cannot be called since this is abstract "
1261 mfunnamep(
"virtual int apeq_mant(const AbsCoorMesh<T>& m2, T prec)");
1263 mcerr <<
"AbsCoorMesh::apeq_mant != cannot be called since this is "
1326 virtual void print(std::ostream& file)
const {
1327 Ifile <<
"VirtEqualStepCoorMesh<T>: \n";
1337 mfunname(
"virtual int VirtEqualStepCoorMesh<T>::operator==(const "
1338 "AbsCoorMesh<T>& m2)");
1342 if (
this == &m2)
return 1;
1349 if (
operator==(m2) == 1)
1355 mfunname(
"virtual int apeq_mant(const AbsCoorMesh<T>& m2, T prec)");
1359 if (
this == &m2)
return 1;
1375 mfunname(
"istream& operator>>(istream& file, VirtEqualStepCoorMesh<T>& f)");
1460 virtual void print(std::ostream& file)
const {
1461 Ifile <<
"VirtCopiedPointCoorMesh<T>:\n";
1471 mfunname(
"virtual int operator==(const AbsCoorMesh<T>& m2)");
1475 if (
this == &m2)
return 1;
1482 if (
operator==(m2) == 1)
1488 mfunname(
"virtual int apeq_mant(const AbsCoorMesh<T>& m2, T prec)");
1492 if (
this == &m2)
return 1;
1510 mfunname(
"istream& operator>>(istream& file, VirtCopiedPointCoorMesh<T>& f)");
1605 mfunnamep(
"ActivePtr< AbsCoorMesh<T> > read_AbsCoorMesh(istream& file)");
1609 for (n = 0; n < q - 1; n++) {
1611 keyline[n] = file.get();
1614 if (!strcmp(&(keyline[0]),
"AbsCoorMesh: no content.")) {
1616 mcout <<
"attempt to read AbsCoorMesh\n";
1619 if (!strcmp(&(keyline[0]),
"VirtEqualStepCoorMesh<T>: ")) {
1622 return ActivePtr<AbsCoorMesh<T> >(amesh,
dont_clone);
1624 if (!strcmp(&(keyline[0]),
"VirtCopiedPointCoorMesh<T>:")) {
1627 return ActivePtr<AbsCoorMesh<T> >(amesh,
dont_clone);
1630 mcout <<
"cannot identifiy the type of derived AbsCoorMesh\n";
1634 return ActivePtr<AbsCoorMesh<T> >();
1648template <
class T,
class D,
class M>
1650 T x,
int s_include_last_point = 0)
1653 mfunname(
"double t_value_step_ar(...)");
1654 double xmin = mesh.get_xmin();
1655 double xmax = mesh.get_xmax();
1657 if (x < xmin)
return 0;
1658 if (s_include_last_point == 0) {
1659 if (x >= xmax)
return 0;
1661 if (x > xmax)
return 0;
1666 i_ret = mesh.get_interval(x, n1, b1, n2, b2);
1672template <
class T,
class D,
class M1,
class M2>
1675 T x1, T x2,
int s_include_last_point = 0)
1678 mfunname(
"double t_value_step_ar(...)");
1679 double x1min = mesh1.get_xmin();
1680 double x1max = mesh1.get_xmax();
1682 if (x1 < x1min)
return 0;
1683 if (s_include_last_point == 0) {
1684 if (x1 >= x1max)
return 0;
1686 if (x1 > x1max)
return 0;
1688 double x2min = mesh2.get_xmin();
1689 double x2max = mesh2.get_xmax();
1691 if (x2 < x2min)
return 0;
1692 if (s_include_last_point == 0) {
1693 if (x2 >= x2max)
return 0;
1695 if (x2 > x2max)
return 0;
1702 i_ret = mesh1.get_interval(x1, n11, b1, n12, b2);
1705 i_ret = mesh2.get_interval(x2, n21, b1, n22, b2);
1713template <
class T,
class D,
class M>
1715 T x, T val = 1,
int s_include_last_point = 0)
1718 mfunname(
"double t_hfill_step_ar(...)");
1719 double xmin = mesh.get_xmin();
1720 double xmax = mesh.get_xmax();
1722 if (x < xmin)
return;
1723 if (s_include_last_point == 0) {
1724 if (x >= xmax)
return;
1726 if (x > xmax)
return;
1730 i_ret = mesh.get_interval(x, n1);
1739template <
class T,
class D,
class M>
1741 T x, T val = 1,
int s_include_last_point = 0)
1744 mfunname(
"double t_hfill_step_ar(...)");
1745 double xmin = mesh.get_xmin();
1746 double xmax = mesh.get_xmax();
1748 if (x < xmin)
return;
1749 if (s_include_last_point == 0) {
1750 if (x >= xmax)
return;
1752 if (x > xmax)
return;
1756 i_ret = mesh.get_interval(x, n1);
1763template <
class T,
class D,
class M1,
class M2>
1766 T x1, T x2, T val = 1,
int s_include_last_point = 0)
1769 mfunname(
"double t_hfill_step_ar(...)");
1770 double x1min = mesh1.get_xmin();
1771 double x1max = mesh1.get_xmax();
1772 double x2min = mesh2.get_xmin();
1773 double x2max = mesh2.get_xmax();
1775 if (x1 < x1min)
return;
1776 if (s_include_last_point == 0) {
1777 if (x1 >= x1max)
return;
1779 if (x1 > x1max)
return;
1781 if (x2 < x2min)
return;
1782 if (s_include_last_point == 0) {
1783 if (x2 >= x2max)
return;
1785 if (x2 > x2max)
return;
1789 i_ret1 = mesh1.get_interval(x1, n1);
1793 i_ret2 = mesh2.get_interval(x2, n2);
1795 y.ac(n1, n2) += val;
1809template <
class T,
class D,
class M>
1811 T x1, T x2,
int xpower)
1813 mfunname(
"double t_integ_step_ar(...)");
1818 long qi = mesh.get_qi();
1821 double xmin = mesh.get_xmin();
1822 double xmax = mesh.get_xmax();
1823 if (x2 <= xmin)
return 0;
1824 if (x1 >= xmax)
return 0;
1825 if (x1 == x2)
return 0;
1826 long istart, iafterend;
1835 i_ret = mesh.get_interval(x1, n1, b1, n2, b2);
1842 s = (x2 - x1) * y[n1];
1844 s = 0.5 * (x2 * x2 - x1 * x1) * y[n1];
1849 s += (b2 - x1) * y[n1];
1851 s += 0.5 * (b2 * b2 - x1 * x1) * y[n1];
1863 i_ret = mesh.get_interval(x2, n1, b1, n2, b2);
1869 s += (x2 - b1) * y[n1];
1871 s += 0.5 * (x2 * x2 - b1 * b1) * y[n1];
1879 mesh.get_scoor(istart, b);
1881 for (i = istart; i < iafterend; i++) {
1883 mesh.get_scoor(i + 1, b);
1884 s += (b - a) * y[i];
1887 for (i = istart; i < iafterend; i++) {
1889 mesh.get_scoor(i + 1, b);
1890 s += 0.5 * (b * b - a * a) * y[i];
1906template <
class T,
class D,
class M>
1909 T (*
fun)(
long np, T xp1, T xp2, T yp, T xmin, T xmax,
1914 mfunname(
"double t_integ_step_ar(...)");
1918 long qi = mesh.get_qi();
1921 double xmin = mesh.get_xmin();
1922 double xmax = mesh.get_xmax();
1923 if (x2 <= xmin)
return 0;
1924 if (x1 >= xmax)
return 0;
1925 if (x1 == x2)
return 0;
1926 long istart, iafterend;
1935 i_ret = mesh.get_interval(x1, n1, b1, n2, b2);
1943 s =
fun(n1, b1, b2, y[n1], xmin, xmax, x1, x2);
1946 s =
fun(n1, b1, b2, y[n1], xmin, xmax, x1, x2);
1957 i_ret = mesh.get_interval(x2, n1, b1, n2, b2);
1962 s +=
fun(n1, b1, b2, y[n1], xmin, xmax, b1, x2);
1969 mesh.get_scoor(istart, b);
1970 for (i = istart; i < iafterend; i++) {
1972 mesh.get_scoor(i + 1, b);
1973 s +=
fun(i, a, b, y[i], xmin, xmax, a, b);
1986template <
class T,
class D,
class M>
1989 mfunname(
"double t_total_integ_step_ar(...)");
1992 long qi = mesh.get_qi();
1995 long istart, iafterend;
2002 mesh.get_scoor(istart, b);
2003 for (i = istart; i < iafterend; i++) {
2005 mesh.get_scoor(i + 1, b);
2006 s += (b - a) * y[i];
2016template <
class T,
class D,
class M1,
class M2>
2020 mfunname(
"double t_total_integ_step_ar(...)");
2023 long qi1 = mesh1.get_qi();
2025 long qi2 = mesh2.get_qi();
2028 long istart1, iafterend1;
2035 mesh1.get_scoor(istart1, b1);
2036 for (i1 = istart1; i1 < iafterend1; i1++) {
2038 mesh1.get_scoor(i1 + 1, b1);
2041 long istart2, iafterend2;
2048 mesh2.get_scoor(istart2, b2);
2049 for (i2 = istart2; i2 < iafterend2; i2++) {
2051 mesh2.get_scoor(i2 + 1, b2);
2052 s2 += (b2 - a2) * y[i1][i2];
2055 s1 += (b1 - a1) * s2;
2065template <
class T,
class M1,
class M2>
2069 mfunname(
"double t_total_integ_step_ar(...)");
2072 long qi1 = mesh1.get_qi();
2075 long qi2 = mesh2.get_qi();
2079 long istart1, iafterend1;
2086 mesh1.get_scoor(istart1, b1);
2087 for (i1 = istart1; i1 < iafterend1; i1++) {
2089 mesh1.get_scoor(i1 + 1, b1);
2094 long istart2, iafterend2;
2101 mesh2.get_scoor(istart2, b2);
2102 for (i2 = istart2; i2 < iafterend2; i2++) {
2104 mesh2.get_scoor(i2 + 1, b2);
2105 s2 += (b2 - a2) * y.
acu(i1, i2);
2110 s1 += (b1 - a1) * s2;
2126template <
class T,
class D,
class M>
2129 T integ,
int* s_err)
2131 mfunname(
"double t_integ_step_ar(...)");
2137 long qi = mesh.get_qi();
2140 double xmin = mesh.get_xmin();
2141 double xmax = mesh.get_xmax();
2142 if (integ == 0.0)
return xmin;
2147 mesh.get_scoor(n, xp2);
2148 for (n = 0; n < qi; n++) {
2150 mesh.get_scoor(n + 1, xp2);
2152 T s1 = s + y[n] * step;
2154 if (s1 > integ)
break;
2155 if (s1 == integ)
return xp2;
2165 x += (integ - s) / y[n];
2175template <
class T,
class D,
class M>
2178 T integ,
int* s_err)
2180 mfunname(
"double t_find_x_for_already_integ_step_ar(...)");
2186 long qi = mesh.get_qi();
2189 double xmin = mesh.get_xmin();
2190 double xmax = mesh.get_xmax();
2191 if (integ == 0.0)
return xmin;
2192 if (integ > y[qi - 1]) {
2196 if (integ == y[qi - 1])
return xmax;
2200 mesh.get_scoor(0, xp1);
2201 mesh.get_scoor(1, xp2);
2202 return xp1 + (xp2 - xp1) * integ / y[0];
2208 while (nr - nl > 1) {
2218 mesh.get_scoor(nl + 1, xl);
2219 mesh.get_scoor(nr + 1, xr);
2224 T a = (xr - xl) / (y[nr] - y[nl]);
2225 T ret = xl + a * (integ - y[nl]);
2240template <
class T,
class D,
class M>
2242 const M& mesh,
const D& y,
2243 T integ,
int* s_err)
2245 mfunname(
"double t_find_entire_x_for_already_integ_step_ar(...)");
2252 long qi = mesh.get_qi();
2255 long xmin = mesh.get_xmin();
2256 long xmax = mesh.get_xmax();
2257 if (integ == 0)
return xmin;
2258 if (integ > y[qi - 1]) {
2262 if (integ == y[qi - 1])
return xmax;
2265 mesh.get_scoor(0, xp1);
2272 while (nr - nl > 1) {
2283 mesh.get_scoor(nr, x);
2294template <
class T,
class D,
class M>
2298 mfunname(
"double t_hispre_step_ar(...)");
2302 long qi = mesh.get_qi();
2309 mesh.get_scoor(n, xp2);
2310 for (n = 0; n < qi; n++) {
2312 mesh.get_scoor(n + 1, xp2);
2315 "n=" << n <<
" xp1=" << xp1 <<
" xp2=" << xp2 <<
'\n',
2317 s = s + y[n] * step;
2322 for (n = 0; n < qi; n++) {
2330template <
class T,
class D,
class M>
2332 mfunname(
"double t_hisran_step_ar(...)");
2335 long qi = mesh.get_qi();
2336 long s_same =
apeq_mant(integ_y[qi - 1], 1.0, 1.0e-12);
2337 check_econd11a(s_same, != 1.0,
"integ_y[qi-1]=" << integ_y[qi - 1] <<
'\n',
2347 check_econd11a(s_err, != 0,
"mesh=" << mesh <<
" integ_y=" << integ_y
2348 <<
" rannum=" << rannum <<
'\n',
2361template <
class T,
class D,
class M>
2363 mfunname(
"double t_opposite_hisran_step_ar(...)");
2367 long qi = mesh.get_qi();
2368 long s_same =
apeq_mant(integ_y[qi - 1], 1.0, 1.0e-12);
2369 check_econd11a(s_same, != 1.0,
"integ_y[qi-1]=" << integ_y[qi - 1] <<
'\n',
2377 mesh.get_interval_extrap(x, n1, b1, n2, b2);
2384 y1 = integ_y[n1 - 1];
2385 y2 = integ_y[n2 - 1];
2387 T res = y1 + ((y2 - y1) / (b2 - b1)) * (x - b1);
2393template <
class T,
class D,
class M>
2395 mfunname(
"double t_entire_hisran_step_ar(...)");
2399 long qi = mesh.get_qi();
2400 long s_same =
apeq_mant(integ_y[qi - 1], 1.0, 1.0e-12);
2401 check_econd11a(s_same, != 1.0,
"integ_y[qi-1]=" << integ_y[qi - 1] <<
'\n',
2410 check_econd11a(s_err, != 0,
"mesh=" << mesh <<
" integ_y=" << integ_y
2411 <<
" rannum=" << rannum <<
'\n',
2424template <
class T,
class D,
class M>
2426 T x1, T x2,
int& s_err) {
2427 mfunname(
"double t_mean_step_ar(...)");
2435 return xinteg / integ;
2440 mfunname(
"double t_value_straight_2point(...)");
2443 T a = (y2 - y1) / (x2 - x1);
2451 T adx1 = (dx1 > 0) ? dx1 : -dx1;
2457 T adx2 = (dx2 > 0) ? dx2 : -dx2;
2468 if (s_ban_neg == 1 && res < 0.0) res = 0.0;
2478 mfunname(
"double t_integ_straight_2point(...)");
2481 T a = (y2 - y1) / (x2 - x1);
2483 T yl = a * (xl - x1) + b;
2484 T yr = a * (xr - x1) + b;
2485 if (s_ban_neg == 1) {
2486 if (yl <= 0.0 && yr <= 0.0)
return 0.0;
2487 if (yl < 0.0 || yr < 0.0) {
2500 res = 0.5 * a * (xr * xr - xl * xl) + (b - a * x1) * (xr - xl);
2502 res = a * (xr * xr * xr - xl * xl * xl) / 3.0 +
2503 0.5 * (b - a * x1) * (xr * xr - xl * xl);
2510template <
class T,
class D,
class M>
2513 T x,
int s_ban_neg,
int s_extrap_left, T left_bond,
2514 int s_extrap_right, T right_bond) {
2516 mfunname(
"double t_value_straight_point_ar(...)");
2517 double xmin = mesh.get_xmin();
2518 double xmax = mesh.get_xmax();
2520 if (x < left_bond)
return 0.0;
2521 if (x > right_bond)
return 0.0;
2522 if (x < xmin && s_extrap_left == 0)
return 0.0;
2523 if (x > xmax && s_extrap_right == 0)
return 0.0;
2526 mesh.get_interval_extrap(x, n1, b1, n2, b2);
2528 mesh.get_scoor(n1, x1);
2530 mesh.get_scoor(n2, x2);
2571template <
class T,
class D,
class M>
2573 const M& mesh,
const D& y,
2574 T (*funval)(T xp1, T yp1, T xp2, T yp2, T xmin,
2577 T x,
int s_extrap_left, T left_bond,
int s_extrap_right, T right_bond) {
2579 mfunname(
"double t_value_generic_point_ar(...)");
2580 double xmin = mesh.get_xmin();
2581 double xmax = mesh.get_xmax();
2583 if (x < left_bond)
return 0.0;
2584 if (x > right_bond)
return 0.0;
2585 if (x < xmin && s_extrap_left == 0)
return 0.0;
2586 if (x > xmax && s_extrap_right == 0)
return 0.0;
2589 mesh.get_interval_extrap(x, n1, b1, n2, b2);
2591 mesh.get_scoor(n1, x1);
2593 mesh.get_scoor(n2, x2);
2594 return funval(x1, y[n1], x2, y[n2], left_bond, right_bond, x);
2604 mfunname(
"double t_value_power_2point(...)");
2611 if (x1 <= 0.0 && x2 >= 0.0) {
2612 mcerr <<
"T t_value_power_2point(...): \n";
2613 mcerr <<
"x's are of different sign, power cannot be drawn\n";
2616 T pw = log(y1 / y2) / log(x1 / x2);
2618 res = y1 *
pow(x, pw) /
pow(x1, pw);
2626 mfunname(
"double t_value_power_2point(...)");
2633 if (x1 <= 0.0 && x2 >= 0.0) {
2634 res = y1 + (x - x1) * (y2 - y1) / (x2 - x1);
2636 T pw = log(y1 / y2) / log(x1 / x2);
2638 res = y1 *
pow(x, pw) /
pow(x1, pw);
2644 mfunname(
"double t_value_exp_2point(...)");
2652 T a = log(y1 / y2) / (x1 - x2);
2653 T c = y1 /
exp(a * x1);
2655 res = c *
exp(a * x);
2664 mfunname(
"double t_integ_power_2point(...)");
2670 T pw = log(y1 / y2) / log(x1 / x2);
2672 T k = y1 *
pow(x1, -pw);
2673 T t = k / (1 + pw) * (
pow(xr, (pw + 1)) -
pow(xl, (pw + 1)));
2677template <
class T,
class D,
class M>
2682 int s_ban_neg,
int s_extrap_left, T left_bond,
2683 int s_extrap_right, T right_bond) {
2684 mfunname(
"double t_integ_straight_point_ar(...)");
2689 long qi = mesh.get_qi();
2692 double xmin = mesh.get_xmin();
2693 double xmax = mesh.get_xmax();
2694 if (x2 <= xmin && s_extrap_left == 0)
return 0.0;
2695 if (x1 >= xmax && s_extrap_right == 0)
return 0.0;
2696 if (x2 <= left_bond)
return 0.0;
2697 if (x1 >= right_bond)
return 0.0;
2699 if (x1 < left_bond) x1 = left_bond;
2700 if (x2 > right_bond) x2 = right_bond;
2701 if (x1 <= xmin && s_extrap_left == 0) x1 = xmin;
2702 if (x2 > xmax && s_extrap_left == 0) x2 = xmax;
2707 i_ret = mesh.get_interval_extrap(x1, np1, bp1, np2, bp2);
2710 mesh.get_scoor(np1, xp1);
2712 mesh.get_scoor(np2, xp2);
2716 if (i_ret == 2 || x2 <= xp2)
2718 res = t_integ_straight_2point<T>(xp1, yp1, xp2, yp2, x1, x2, xpower,
2724 res = t_integ_straight_2point<T>(xp1, yp1, xp2, yp2, x1i, x2i, xpower,
2732 mesh.get_scoor(np2, xp2);
2749 res += t_integ_straight_2point<T>(xp1, yp1, xp2, yp2, x1i, x2i, xpower,
2756 }
while (s_stop == 0);
2761template <
class T,
class D,
class M>
2764 T x1, T x2,
int s_extrap_left, T left_bond,
2765 int s_extrap_right, T right_bond,
int& s_err) {
2766 mfunname(
"double t_mean_straight_point_ar(...)");
2769 left_bond, s_extrap_right, right_bond);
2775 left_bond, s_extrap_right, right_bond);
2776 return xinteg / integ;
2785template <
class T,
class D,
class M>
2787 const M& mesh,
const D& y,
2789 T (*
fun)(T xp1, T yp1, T xp2, T yp2, T xmin, T xmax, T x1, T x2), T x1,
2790 T x2,
int s_extrap_left, T left_bond,
int s_extrap_right, T right_bond) {
2791 mfunname(
"double t_integ_generic_point_ar(...)");
2796 long qi = mesh.get_qi();
2799 double xmin = mesh.get_xmin();
2800 double xmax = mesh.get_xmax();
2801 if (x2 <= xmin && s_extrap_left == 0)
return 0.0;
2802 if (x1 >= xmax && s_extrap_right == 0)
return 0.0;
2803 if (x2 <= left_bond)
return 0.0;
2804 if (x1 >= right_bond)
return 0.0;
2806 if (x1 < left_bond) x1 = left_bond;
2807 if (x2 > right_bond) x2 = right_bond;
2808 if (x1 <= xmin && s_extrap_left == 0) x1 = xmin;
2809 if (x2 > xmax && s_extrap_left == 0) x2 = xmax;
2814 i_ret = mesh.get_interval_extrap(x1, np1, bp1, np2, bp2);
2817 mesh.get_scoor(np1, xp1);
2819 mesh.get_scoor(np2, xp2);
2823 if (i_ret == 2 || x2 <= xp2)
2825 res =
fun(xp1, yp1, xp2, yp2, xmin, xmax, x1, x2);
2830 res =
fun(xp1, yp1, xp2, yp2, xmin, xmax, x1i, x2i);
2837 mesh.get_scoor(np2, xp2);
2854 res +=
fun(xp1, yp1, xp2, yp2, xmin, xmax, x1i, x2i);
2860 }
while (s_stop == 0);
2873template <
class T,
class D,
class M>
2876 mfunname(
"double t_width_at_hheight_step_ar(...)");
2878 long qi = mesh.get_qi();
2882 for (n = 0; n < qi; ++n) {
2890 if (ymax == 0)
return 0;
2891 T ylev = ymax / 2.0;
2894 for (n = nmax; n < qi; n++) {
2896 if (y[n] > ylev && y[n + 1] <= ylev) {
2898 mesh.get_interval(n, x1, x2);
2900 mesh.get_step(n, step1);
2901 mesh.get_step(n + 1, step2);
2902 step1 = step1 / 2.0;
2903 step2 = step2 / 2.0;
2918 for (n = nmax; n >= 0; n--) {
2919 if (y[n] > ylev && y[n - 1] <= ylev) {
2921 mesh.get_interval(n - 1, x1, x2);
2923 mesh.get_step(n - 1, step1);
2924 mesh.get_step(n, step2);
2925 step1 = step1 / 2.0;
2926 step2 = step2 / 2.0;
DoubleAc pow(const DoubleAc &f, double p)
DoubleAc exp(const DoubleAc &f)
#define check_econd21(a, sign1_b1_sign0, sign2_b2, stream)
#define check_econd11(a, signb, stream)
#define check_econd11a(a, signb, add, stream)
#define check_econd24(a1, sign1, b1, sign0, a2, sign2, b2, stream)
#define mfunnamep(string)
#define check_econd12(a, sign, b, stream)
macro_copy_total_zero(AbsCoorMesh< T >)
virtual int get_interval(T x, long &n1) const =0
virtual T get_xmax(void) const =0
virtual int get_interval_extrap(T x, long &n1, T &b1, long &n2, T &b2) const =0
virtual int operator==(const AbsCoorMesh< T > &)
virtual int get_interval(T x, long &n1, T &b1, long &n2, T &b2) const =0
virtual int get_interval(long n, T &b1, T &b2) const =0
virtual void print(std::ostream &file) const
virtual long get_qi(void) const =0
virtual int apeq_mant(const AbsCoorMesh< T > &, T)
virtual T get_xmin(void) const =0
virtual void get_scoor(long n, T &b) const =0
virtual int operator!=(const AbsCoorMesh< T > &)
virtual int get_step(long n, T &fstep) const =0
void get_scoor(long n, T &b) const
int get_step(long n, T &fstep) const
const DynLinArr< T > & get_mesh(void) const
int get_interval(long n, T &b1, T &b2) const
int get_interval_extrap(T x, long &n1, T &b1, long &n2, T &b2) const
void print(std::ostream &file) const
CopiedPointCoorMesh(void)
CopiedPointCoorMesh< T > & operator=(const CopiedPointCoorMesh< T > &f)
const DynLinArr< long > & get_qel(void) const
void print(std::ostream &file) const
virtual int get_interval_extrap(T x, long &n1, T &b1, long &n2, T &b2) const
int get_step(long n, T &fstep) const
void get_scoor(long n, T &b) const
int get_interval(long n, T &b1, T &b2) const
int get_interval_extrap(T x, long &n1, T &b1, long &n2, T &b2) const
void get_scoor(long n, T &b) const
virtual void print(std::ostream &file) const
virtual int get_interval(long n, T &b1, T &b2) const
int get_step(long n, T &fstep) const
virtual int operator==(const AbsCoorMesh< T > &m2)
virtual int get_interval(T x, long &n1) const
macro_copy_total(VirtCopiedPointCoorMesh< T >)
virtual int get_interval_extrap(T x, long &n1, T &b1, long &n2, T &b2) const
virtual long get_qi(void) const
virtual void print(std::ostream &file) const
virtual int get_interval(long n, T &b1, T &b2) const
virtual T get_xmin(void) const
virtual int apeq_mant(const AbsCoorMesh< T > &m2, T prec)
virtual void get_scoor(long n, T &b) const
virtual int get_interval(T x, long &n1, T &b1, long &n2, T &b2) const
virtual int get_step(long n, T &fstep) const
virtual int operator!=(const AbsCoorMesh< T > &m2)
virtual T get_xmax(void) const
virtual int get_interval(long n, T &b1, T &b2) const
virtual void get_scoor(long n, T &b) const
virtual int apeq_mant(const AbsCoorMesh< T > &m2, T prec)
virtual int get_interval(T x, long &n1, T &b1, long &n2, T &b2) const
virtual T get_xmax(void) const
virtual void print(std::ostream &file) const
virtual long get_qi(void) const
virtual int operator!=(const AbsCoorMesh< T > &m2)
virtual T get_xmin(void) const
macro_copy_total(VirtEqualStepCoorMesh< T >)
virtual int get_interval_extrap(T x, long &n1, T &b1, long &n2, T &b2) const
virtual int operator==(const AbsCoorMesh< T > &m2)
virtual int get_step(long n, T &fstep) const
virtual int get_interval(T x, long &n1) const
long set_position(const String &word, std::istream &istrm, int s_rewind, int s_req_sep)
std::ostream & yesindent(std::ostream &f)
std::ostream & noindent(std::ostream &f)
#define Iprint3n(file, name1, name2, name3)
#define Iprintn(file, name)
#define Iprint2n(file, name1, name2)
#define Iprint4n(file, name1, name2, name3, name4)
T t_find_x_for_integ_step_ar(const M &mesh, const D &y, T integ, int *s_err)
long t_entire_hisran_step_ar(const M &mesh, const D &integ_y, T rannum)
void t_hfill_step_ar_ac(const M &mesh, const D &y, T x, T val=1, int s_include_last_point=0)
T t_value_power_extended_2point(T x1, T y1, T x2, T y2, T x)
T t_value_step_ar(const M &mesh, const D &y, T x, int s_include_last_point=0)
long t_find_entire_x_for_already_integ_step_ar(const M &mesh, const D &y, T integ, int *s_err)
std::istream & operator>>(std::istream &file, EqualStepCoorMesh< T > &f)
int verify_types(const T *ths, const B *b2, const T **tb2)
T t_value_straight_2point(T x1, T y1, T x2, T y2, T x, int s_ban_neg)
T t_hisran_step_ar(const M &mesh, const D &integ_y, T rannum)
long t_find_interval_end(double x, long q, const D &coor, long n_start)
T t_find_x_for_already_integ_step_ar(const M &mesh, const D &y, T integ, int *s_err)
T t_width_at_hheight_step_ar(const M &mesh, const D &y)
T t_integ_power_2point(T x1, T y1, T x2, T y2, T xl, T xr)
T t_value_power_2point(T x1, T y1, T x2, T y2, T x)
void t_hfill_step_ar(const M &mesh, const D &y, T x, T val=1, int s_include_last_point=0)
T t_integ_straight_2point(T x1, T y1, T x2, T y2, T xl, T xr, int xpower, int s_ban_neg)
T t_mean_step_ar(const M &mesh, const D &y, T x1, T x2, int &s_err)
ActivePtr< AbsCoorMesh< T > > read_AbsCoorMesh(std::istream &file)
int operator!=(const EqualStepCoorMesh< T > &f1, const EqualStepCoorMesh< T > &f2)
T t_opposite_hisran_step_ar(const M &mesh, const D &integ_y, T x)
int apeq_mant(const EqualStepCoorMesh< T > &f1, const EqualStepCoorMesh< T > &f2, T prec)
T t_value_exp_2point(T x1, T y1, T x2, T y2, T x)
T t_integ_step_ar(const M &mesh, const D &y, T x1, T x2, int xpower)
T t_mean_straight_point_ar(const M &mesh, const D &y, T x1, T x2, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond, int &s_err)
T t_integ_generic_point_ar(const M &mesh, const D &y, T(*fun)(T xp1, T yp1, T xp2, T yp2, T xmin, T xmax, T x1, T x2), T x1, T x2, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)
T t_total_integ_step_ar(const M &mesh, const D &y)
T t_hispre_step_ar(const M &mesh, const D &y, D &integ_y)
T t_value_straight_point_ar(const M &mesh, const D &y, T x, int s_ban_neg, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)
int operator==(const EqualStepCoorMesh< T > &f1, const EqualStepCoorMesh< T > &f2)
T t_integ_straight_point_ar(const M &mesh, const D &y, T x1, T x2, int xpower, int s_ban_neg, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)
T t_value_generic_point_ar(const M &mesh, const D &y, T(*funval)(T xp1, T yp1, T xp2, T yp2, T xmin, T xmax, T x), T x, int s_extrap_left, T left_bond, int s_extrap_right, T right_bond)
T t_integ_generic_step_ar(const M &mesh, const D &y, T(*fun)(long np, T xp1, T xp2, T yp, T xmin, T xmax, T x1, T x2), T x1, T x2)
long t_find_interval(double x, long q, const D &coor)
std::ostream & operator<<(std::ostream &file, const EqualStepCoorMesh< T > &f)