76#ifndef ALR_CHECK_BOUND
77#define ALR_CHECK_BOUND
79#ifndef ALR_CHECK_EACH_BOUND
80#define ALR_CHECK_EACH_BOUND
108 mcerr <<
"ERROR in DynLinArr(long fqel):\n";
109 mcerr <<
"qel > max_qel_DynLinArr:\n";
111 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
116 mcerr <<
"ERROR in DynLinArr(long fqel):\n";
117 mcerr <<
"qel < 0:\n";
119 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
123 el = (fqel > 0) ? (
new T[fqel]) : (T*)NULL;
126 DynLinArr(
long fqel,
const T& val) : qel(fqel), el(NULL) {
128 mcerr <<
"ERROR in DynLinArr(long fqel, const T& val):\n";
129 mcerr <<
"qel > max_qel_DynLinArr:\n";
131 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
136 mcerr <<
"ERROR in DynLinArr(long fqel, const T& val):\n";
137 mcerr <<
"qel < 0:\n";
139 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
143 el = (fqel > 0) ? (
new T[fqel]) : (T*)NULL;
148 mcerr <<
"ERROR in DynLinArr(long fqel, const T* ar, ArgInterp_Arr):\n";
149 mcerr <<
"qel > max_qel_DynLinArr:\n";
151 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
156 mcerr <<
"ERROR in DynLinArr(long fqel, const T* ar, ArgInterp_Arr):\n";
157 mcerr <<
"qel < 0:\n";
159 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
163 el = (fqel > 0) ? (
new T[fqel]) : (T*)NULL;
164 for (
long n = 0; n < qel; n++) el[n] = ar[n];
193#ifdef DEBUG_DYNLINARR
194 mcout <<
"DynLinArr( DynLinArr<T>& f, Pilfer) is working\n";
209 for (
long n = 0; n < qel; n++) el[n] = f;
217 for (
long n = 0; n < qel; n++) el[n].
assignAll(f);
222#ifdef ALR_CHECK_BOUND
223 if (n >= 0 && n < qel)
return el[n];
224 mcerr <<
"ERROR in const T& DynLinArr::operator[](long n) const: "
225 <<
"n is out of bounds, n=" << n <<
" qel=" << qel <<
'\n';
226 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
235#ifdef ALR_CHECK_BOUND
236 if (n >= 0 && n < qel)
return el[n];
237 mcerr <<
"ERROR in const T& DynLinArr::operator[](long n) const: "
238 <<
"n is out of bounds, n=" << n <<
" qel=" << qel <<
'\n';
239 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
251 inline const T&
acu(
long n)
const {
256#ifdef ALR_CHECK_BOUND
257 if (qel > 0)
return el[qel - 1];
258 mcerr <<
"ERROR in const T& DynLinArr::last_el(void) const: qel <=0:"
259 <<
" qel" << qel <<
'\n';
260 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
270#ifdef ALR_CHECK_BOUND
271 if (qel > 0)
return el[qel - 1];
272 mcerr <<
"ERROR in const T& DynLinArr::last_el(void) const: qel <=0:"
273 <<
" qel" << qel <<
'\n';
274 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
316#ifdef DEBUG_DYNLINARR
317 mcout <<
"DynLinArr::pilfer is called\n";
322 mcerr <<
"ERROR in DynLinArr::pilfer(...):\n";
323 mcerr <<
"Both the destination and source arrays are not empty\n";
367 template <
class P,
class X>
400 long q_to_sort = 0)
const;
402 long q_to_sort = 0)
const;
423 for (
long n = 0; n < ar.qel; n++) (*fun)(ar.el[n]);
426template <
class T,
class X>
428 void (*fun2)(X& f)) {
429 for (
long n = 0; n < ar.qel; n++) (*fun1)(ar.el[n], fun2);
435 mcerr <<
"ERROR in template<class T> void DynLinArr<T>::check(void):\n";
436 mcerr <<
"qel < 0, qel=" << qel <<
'\n';
437 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
441 if (qel == 0 && el != NULL) {
442 mcerr <<
"ERROR in template<class T> void DynLinArr<T>::check(void):\n";
443 mcerr <<
"qel == 0 && el != NULL: el=" << el <<
'\n';
444 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
450 mcerr <<
"ERROR in template<class T> void DynLinArr<T>::check(void):\n";
451 mcerr <<
"qel > 0 && el == NULL: qel=" << qel <<
'\n';
452 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
457 mcerr <<
"ERROR in template<class T> void DynLinArr<T>::check(void):\n";
458 mcerr <<
"qel > max_qel_DynLinArr: \n";
460 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
469#ifdef DEBUG_DYNLINARR
470 mcout <<
"DynLinArr<T>& DynLinArr<T>::operator=(const DynLinArr<T>& f) is "
482 T* temp_el = (T*)NULL;
485 for (
long n = 0; n < q; n++) temp_el[n] = f.el[n];
495#ifdef DEBUG_DYNLINARR
496 mcout <<
"DynLinArr<T>& DynLinArr<T>::operator=(const DynLinArr<D>& f) is "
499 if (
this == &f)
return *
this;
506 T* temp_el = (T*)NULL;
509 for (
long n = 0; n < q; n++) temp_el[n] = f[n];
520#ifdef DEBUG_DYNLINARR
521 mcout <<
"DynLinArr(const DynLinArr<T>& f) is working\n";
537 mcerr <<
"ERROR in template<class T> void DynLinArr<T>::put_qel(long "
539 mcerr <<
"fqel < 0, fqel=" << fqel <<
'\n';
540 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
547 if (qel > 0) el =
new T[fqel];
557 for (
long n = 0; n < fqel; ++n) {
558 if (n < qel) elh[n] = el[n];
579 mcerr <<
"ERROR in template<class T> void DynLinArr<T>::put_qel(long fqel, "
580 "const T* val, ArgInterp_SingleAdr):\n";
581 mcerr <<
"fqel < 0, fqel=" << fqel <<
'\n';
582 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
586 mcerr <<
sizeof(t) <<
"\n";
591 if (qel > 0) el =
new T[fqel];
593 for (
long n = 0; n < qel; ++n) el[n] = *val;
603 for (
long n = 0; n < fqel; ++n) {
606 else if (val != NULL)
626 mfunnamep(
"void DynLinArr<T>::sort(long q_to_sort = 0)");
629 if (q_to_sort <= 0) q_to_sort = qel;
630 if (q_to_sort <= 1)
return;
632 long n_possible_next = 1;
633 for (
long n = 0; n < q_to_sort - 1; n++) {
637 long nmin = n_possible_next;
639 int s_change_possible_next = 0;
642 for (
long m = n_possible_next + 1; m < q_to_sort; m++) {
644 if (el_min > el[m]) {
645 n_possible_next = nmin;
646 s_change_possible_next = 1;
652 if (s_change_possible_next == 0 || n_possible_next < n + 2) {
653 n_possible_next = n + 2;
663 if (el[n] > el_min) {
664 if (s_change_possible_next == 1) {
666 if (n_possible_next < q_to_sort && el[n] < el[n_possible_next]) {
667 n_possible_next = nmin;
684 "void DynLinArr<T>::sort(DynLinArr< long >& sort_ind, long "
685 "q_to_sort = 0) const");
688 if (q_to_sort <= 0) q_to_sort = qel;
694 for (n = 0; n < q_to_sort; n++) {
697 if (q_to_sort <= 1)
return;
699 long n_possible_next = 1;
701 for (n = 0; n < q_to_sort - 1; n++) {
703 long nmin = n_possible_next;
704 long ind_nmin = sort_ind.
acu(nmin);
705 int s_change_possible_next = 0;
708 for (m = n_possible_next + 1; m < q_to_sort; m++) {
709 if (el[ind_nmin] > el[sort_ind.
acu(m)])
712 n_possible_next = nmin;
713 s_change_possible_next = 1;
715 ind_nmin = sort_ind.
acu(nmin);
718 if (s_change_possible_next == 0 || n_possible_next < n + 2) {
719 n_possible_next = n + 2;
721 if (el[sort_ind.
acu(n)] > el[ind_nmin])
724 if (s_change_possible_next == 1) {
725 if (n_possible_next < q_to_sort &&
726 el[sort_ind.
acu(n)] < el[sort_ind.
acu(n_possible_next)]) {
727 n_possible_next = nmin;
731 sort_ind.
acu(nmin) = sort_ind.
acu(n);
732 sort_ind.
acu(n) = ind_nmin;
739 long q_to_sort)
const {
741 "void DynLinArr<T>::sort_select_increasing(DynLinArr< long >& "
742 "sort_ind, long q_to_sort = 0) const");
745 long s_last_noninc = 0;
746 if (q_to_sort <= 0) {
749 }
else if (q_to_sort == qel) {
757 for (n = 0; n < qel; n++) {
760 if (q_to_sort <= 1)
return;
762 long n_possible_next = 1;
764 for (n = 0; n < q_to_sort - s_last_noninc; n++) {
766 long nmin = n_possible_next;
767 long ind_nmin = sort_ind[nmin];
768 int s_change_possible_next = 0;
771 for (m = n_possible_next + 1; m < qel; m++) {
772 if (el[ind_nmin] > el[sort_ind[m]])
775 n_possible_next = nmin;
776 s_change_possible_next = 1;
778 ind_nmin = sort_ind[nmin];
781 if (s_change_possible_next == 0 || n_possible_next < n + 2) {
782 n_possible_next = n + 2;
784 if (el[sort_ind[n]] > el[ind_nmin])
787 if (s_change_possible_next == 1) {
788 if (n_possible_next < q_to_sort &&
789 el[sort_ind[n]] < el[sort_ind[n_possible_next]]) {
790 n_possible_next = nmin;
794 sort_ind[nmin] = sort_ind[n];
795 sort_ind[n] = ind_nmin;
803 long q_to_sort)
const {
805 "void DynLinArr<T>::sort_select_decreasing(DynLinArr< long >& "
806 "sort_ind, long q_to_sort = 0) const");
809 long s_last_noninc = 0;
810 if (q_to_sort <= 0) {
813 }
else if (q_to_sort == qel) {
822 for (n = 0; n < qel; n++) {
825 if (q_to_sort <= 1)
return;
827 long n_possible_next = 1;
829 for (n = 0; n < q_to_sort - s_last_noninc; n++) {
832 long nmax = n_possible_next;
834 long ind_nmax = sort_ind[nmax];
835 int s_change_possible_next = 0;
838 for (m = n_possible_next + 1; m < qel; m++) {
840 if (el[ind_nmax] < el[sort_ind[m]]) {
841 n_possible_next = nmax;
842 s_change_possible_next = 1;
845 ind_nmax = sort_ind[nmax];
848 if (s_change_possible_next == 0 || n_possible_next < n + 2) {
849 n_possible_next = n + 2;
852 if (el[sort_ind[n]] < el[ind_nmax]) {
853 if (s_change_possible_next == 1) {
854 if (n_possible_next < q_to_sort &&
855 el[sort_ind[n]] > el[sort_ind[n_possible_next]]) {
856 n_possible_next = nmax;
860 sort_ind[nmax] = sort_ind[n];
861 sort_ind[n] = ind_nmax;
945#ifndef BAN_DEFAULT_PAR_FUN_TEMPL
959 mcerr <<
"ERROR in long append(class DynLinArr& dla, ...): dla.get_qel() < "
961 <<
"dla.get_qel()=" << dla.
get_qel() <<
" qael=" << qael <<
'\n';
962 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
967 if (new_qel <= qael) new_qel = std::max(3 * qael,
long(3));
976#define append_to_DynLinArr(t, dla, qael, tempt, new_qel) \
978 if (dla.get_qel() < qael) { \
979 mcerr << "append(class DynLinArr& dla, ...): dla.get_qel() < qael, " \
980 << "dla.get_qel()=" << dla.get_qel() << " qael=" << qael << '\n'; \
984 if (dla.get_qel() == qael) { \
985 if (new_qel <= qael) nn = std::max(3 * qael, long(3)); \
986 dla.put_qel(nn, tempt); \
990#define append_to_DynLinArr_short(t, dla, qael) \
992 if (dla.get_qel() < qael) { \
993 mcerr << "append(class DynLinArr& dla, ...): dla.get_qel() < qael, " \
994 << "dla.get_qel()=" << dla.get_qel() << " qael=" << qael << '\n'; \
998 if (dla.get_qel() == qael) { \
999 nn = std::max(3 * qael, long(3)); \
1000 dla.put_qel(nn, NULL); \
1016 for (n = 0; n < f.
get_qel(); n++) {
1019 Ifile <<
"n=" << n <<
" el[n]=";
1021 std::ostringstream ost;
1036 "template<class T> istream& operator>>(istream& file, DynLinArr<T>& f)");
1048 for (fn = 0; fn < qel; fn++) {
1101 for (n = 0; n < f.
get_qel(); n++) {
1105 std::ostringstream ost;
1118 Ifile <<
"DynLinArr<T>: qel=" << f.
get_qel() <<
" q to print is " << q
1122 mcerr <<
"print_DynLinArr(...): q>f.get_qel(), q=" << q
1123 <<
" f.get_qel()=" << f.
get_qel() <<
'\n';
1124 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1130 for (n = 0; n < q; n++) {
1134 std::ostringstream ost;
1148 Ifile <<
"DynLinArr<T>: qel=" << f.
get_qel() <<
" q to print is " << q
1152 mcerr <<
"print_adr_DynLinArr(...): q>f.get_qel(), q=" << q
1153 <<
" f.get_qel()=" << f.
get_qel() <<
'\n';
1154 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1160 for (n = 0; n < q; n++) {
1164 std::ostringstream ost;
1165 f[n]->
print(ost, l);
1196#define Iprintdla_int(file, name) \
1197 file << indn << #name << "=" << noindent; \
1198 print_DynLinArr_int(file, name);
1199#define Iprintdla_long(file, name) \
1200 file << indn << #name << "=" << noindent; \
1201 print_DynLinArr_long(file, name);
1202#define Iprintdla_float(file, name) \
1203 file << indn << #name << "=" << noindent; \
1204 print_DynLinArr_float(file, name);
1205#define Iprintdla_double(file, name) \
1206 file << indn << #name << "=" << noindent; \
1207 print_DynLinArr_double(file, name);
1210template <
class T,
class X>
1212 mfunnamep(
"template<class T, class X> void copy_DynLinArr(const T& s, X& d)");
1215 long q = s.get_qel();
1218 for (n = 0; n < q; n++) {
1224template <
class T,
class X>
1226 long q = s.get_qel();
1229 for (n = 0; n < q; n++) {
1240 for (n = 0; n < q; n++) f[n].put_qel(fq);
1243template <
class T,
class T1>
1249 for (n = 0; n < q; n++) f[n].assignAll(ft);
1257 if (ncur < dar->get_qel() - 1)
1258 return &((*dar)[++ncur]);
1260 ncur = dar->get_qel();
1264 if (ncur >= 0 || ncur < dar->get_qel())
1265 return &((*dar)[ncur]);
1272 return &((*dar)[--ncur]);
1284int gconfirm_ind(
const DynLinArr<long>& qel,
const DynLinArr<long>& ind);
1285int gconfirm_ind_ext(
const DynLinArr<long>& qel,
const DynLinArr<long>& ind);
1312 for (n = 0; n < qfirst; n++) {
1314 if (!(fd1[n] == fd2[n]))
return 0;
1326 if (qfirst > fd1.
get_qel())
return 0;
1328 for (n = 0; n < qfirst; n++)
1329 if (!(fd1[n] == fd2[n]))
return 0;
1336 for (n = 0; n < qfirst; n++)
1337 if (!(fd1[n] == fd2[n]))
return 0;
1352 if (qfd1 + qfd2 == 0)
return ret;
1353 for (n = 0; n < qfd1; n++) {
1356 for (n = 0; n < qfd2; n++) {
1357 ret[qfd1 + n] = fd2[n];
1373 mcout <<
"explicit DynArr(long fqel, T* val=NULL) is called\n";
1384 mcout <<
"explicit DynArr(long fqel, T* val=NULL) is called\n";
1395 for (n = 0; n < fqel; n++) el.acu(n) = ar[n];
1404 for (
long n = 0; n < qel[0]; n++)
ac(n) = f[n];
1408 DynArr(
long fqel1,
long fqel2, T* val = NULL)
1413 mcout <<
"DynArr(long fqel1, long fqel2, T* val=NULL) is called\n";
1428 <<
"DynArr(long fqel1, long fqel2, T val, ArgInterp_Val t) is called\n";
1438 DynArr(
long fqel1,
long fqel2,
long fqel3, T* val = NULL)
1441 el(fqel1 * fqel2 * fqel3) {
1445 cum_qel[0] = fqel2 * fqel3;
1452 DynArr(
long fqel1,
long fqel2,
long fqel3,
long fqel4, T* val = NULL)
1455 el(fqel1 * fqel2 * fqel3 * fqel4) {
1460 cum_qel[0] = fqel2 * fqel3 * fqel4;
1461 cum_qel[1] = fqel3 * fqel4;
1473 long qdim = qel.get_qel();
1474 if (qdim <= 0)
return;
1475 cum_qel.put_qel(qdim);
1478 for (ndim = 1; ndim < qdim; ndim++) size *= qel[ndim];
1480 cum_qel[qdim - 1] = 1;
1481 for (ndim = qdim - 2; ndim >= 0; ndim--)
1482 cum_qel[ndim] = qel[ndim + 1] * cum_qel[ndim + 1];
1489 long qdim = qel.get_qel();
1490 if (qdim <= 0)
return;
1491 cum_qel.put_qel(qdim);
1494 for (ndim = 1; ndim < qdim; ndim++) size *= qel[ndim];
1496 cum_qel[qdim - 1] = 1;
1497 for (ndim = qdim - 2; ndim >= 0; ndim--)
1498 cum_qel[ndim] = qel[ndim + 1] * cum_qel[ndim + 1];
1504 mcout <<
"DynArr(const DynArr<T>& f) is working\n";
1511 mcout <<
"DynArr( DynArr<T>& f, Pilfer) is working\n";
1517 mcout <<
"DynArr::pilfer is called\n";
1520 if (qel.get_qel() != 0) {
1522 mcerr <<
"ERROR in DynArr::pilfer(...):\n";
1523 mcerr <<
"Both the destination and source arrays are not empty\n";
1534 cum_qel.pilfer(f.cum_qel);
1566 operator D&()
const {
1568 mcerr <<
"ERROR in IndexingProvider::operator D& (): q_deref_ind != "
1571 mcerr <<
"Type of T is (in internal notations) " <<
typeid(D).name()
1575#ifdef ALR_CHECK_BOUND
1583 mcerr <<
"ERROR in T& IndexingProvider::operator=(T& f): q_deref_ind "
1584 "!= arr.get_qel().get_qel()\n";
1586 mcerr <<
"Type of T is (in internal notations) " <<
typeid(D).name()
1590#ifdef ALR_CHECK_BOUND
1600 mcerr <<
"ERROR in DynArr::IndexingProvider& DynArr::operator[](long "
1601 "n): q_deref_ind >= arr.get_qel().get_qel()\n";
1603 mcerr <<
"Type of T is (in internal notations) " <<
typeid(D).name()
1607#ifdef ALR_CHECK_EACH_BOUND
1609 mcerr <<
"Error in IndexingProvider<D>& "
1610 "IndexingProvider::operator[](long n): n < 0 || n >= "
1611 "qel.acu(q_deref_ind)\n";
1613 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1625 mcerr <<
"ERROR in DynArr::IndexingProvider& DynArr::operator[](long "
1626 "n): q_deref_ind >= arr.get_qel().get_qel()\n";
1628 mcerr <<
"Type of T is (in internal notations) " <<
typeid(D).name()
1632#ifdef ALR_CHECK_EACH_BOUND
1634 mcerr <<
"Error in IndexingProvider<D>& "
1635 "IndexingProvider::operator[](long n): n < 0 || n >= "
1636 "qel.acu(q_deref_ind)\n";
1638 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1654 if (qel.get_qel() < 1) {
1655 mcerr <<
"ERROR in DynArr::IndexingProvider DynArr::operator[](long n): "
1656 "qel.get_qel()< 1, qel.get_qel()=" << qel.get_qel() <<
'\n';
1657 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1661#ifdef ALR_CHECK_EACH_BOUND
1662 if (n < 0 || n >= qel.acu(0)) {
1663 mcerr <<
"Error in IndexingProvider<T> DynArr::operator[](long n): n < 0 "
1664 "|| n >= qel.acu(0)\n";
1666 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1675 if (qel.get_qel() < 1) {
1676 mcerr <<
"ERROR in DynArr::IndexingProvider DynArr::operator[](long n): "
1677 "qel.get_qel()< 1, qel.get_qel()=" << qel.get_qel() <<
'\n';
1678 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1682#ifdef ALR_CHECK_EACH_BOUND
1683 if (n < 0 || n >= qel.acu(0)) {
1684 mcerr <<
"Error in IndexingProvider<T> DynArr::operator[](long n): n < 0 "
1685 "|| n >= qel.acu(0)\n";
1687 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1698 if (qel.get_qel() == 1)
return el[i];
1699 mcerr <<
"ERROR in DynArr::ac(long i): qel.get_qel()!= 1, qel.get_qel()="
1700 << qel.get_qel() <<
'\n';
1701 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1706 const T&
ac(
long i)
const {
1708 if (qel.get_qel() == 1)
return el[i];
1709 mcerr <<
"ERROR in DynArr::ac(long i): qel.get_qel()!= 1, qel.get_qel()="
1710 << qel.get_qel() <<
'\n';
1711 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1720 inline const T&
acu(
long i1)
const
1732 if ((q = qel.get_qel()) != ind.
get_qel()) {
1733 mcerr <<
"ERROR in DynArr::ac(const DynLinArr<long>& ind): "
1734 <<
"qel.get_qel()!= ind.get_qel()\n"
1735 <<
"qel.get_qel()=" << qel.get_qel()
1736 <<
" ind.get_qel()=" << ind.
get_qel() <<
'\n';
1737 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1741#ifdef ALR_CHECK_EACH_BOUND
1744 return el[ind.
acu(0)];
1746 return el[calc_lin_ind(ind)];
1749 return el[ind.
acu(0)];
1751 return el.acu(calc_lin_ind(ind));
1755 return el[ind.
acu(0)];
1757 return el[calc_lin_ind(ind)];
1763 if ((q = qel.get_qel()) != ind.get_qel()) {
1764 mcerr <<
"ERROR in DynArr::ac(const DynLinArr<long>& ind): "
1765 <<
"qel.get_qel()!= ind.get_qel()\n"
1766 <<
"qel.get_qel()=" << qel.get_qel()
1767 <<
" ind.get_qel()=" << ind.get_qel() <<
'\n';
1768 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1785#ifdef ALR_CHECK_EACH_BOUND
1788 return el[ind.acu(0)];
1790 return el[calc_lin_ind(ind)];
1793 return el[ind.acu(0)];
1795 return el.acu(calc_lin_ind(ind));
1799 return el[ind.acu(0)];
1801 return el[calc_lin_ind(ind)];
1810 if ((q = qel.get_qel()) > ind.
get_qel()) {
1811 mcerr <<
"ERROR in DynArr::acp(const DynLinArr<long>& ind): "
1812 <<
"qel.get_qel()!= ind.get_qel()\n"
1813 <<
"qel.get_qel()=" << qel.get_qel()
1814 <<
" ind.get_qel()=" << ind.
get_qel() <<
'\n';
1815 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1820#ifdef ALR_CHECK_EACH_BOUND
1823 return el[ind.
acu(0)];
1825 return el[calc_lin_ind(ind)];
1828 return el[ind.
acu(0)];
1830 return el.acu(calc_lin_ind(ind));
1834 return el[ind.
acu(0)];
1836 return el[calc_lin_ind(ind)];
1842 if ((q = qel.get_qel()) > ind.
get_qel()) {
1843 mcerr <<
"ERROR in DynArr::acp(const DynLinArr<long>& ind): "
1844 <<
"qel.get_qel()!= ind.get_qel()\n"
1845 <<
"qel.get_qel()=" << qel.get_qel()
1846 <<
" ind.get_qel()=" << ind.
get_qel() <<
'\n';
1847 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1851#ifdef ALR_CHECK_EACH_BOUND
1854 return el[ind.
acu(0)];
1856 return el[calc_lin_ind(ind)];
1859 return el[ind.
acu(0)];
1861 return el.acu(calc_lin_ind(ind));
1865 return el[ind.
acu(0)];
1867 return el[calc_lin_ind(ind)];
1873 if (qel.get_qel() == 1)
1874 return el.acu(ind.
acu(0));
1876 return el.acu(calc_lin_ind(ind));
1880 if (qel.get_qel() == 1)
1881 return el.acu(ind.acu(0));
1883 return el.acu(calc_lin_ind(ind));
1888 if (qel.get_qel() == 2) {
1889#ifdef ALR_CHECK_EACH_BOUND
1890 if (i1 >= 0 && i1 < qel.acu(0)) {
1891 if (i2 >= 0 && i2 < qel.acu(1)) {
1893 return el[i1 * cum_qel.acu(0) + i2];
1895 return el.acu(i1 * cum_qel.acu(0) + i2);
1898 mcerr <<
"Error in DynArr::ac(long i1, long i2): i2 < 0 || i2 >= "
1903 mcerr <<
"Error in DynArr::ac(long i1, long i2): i1 < 0 || i1 >= "
1908 mcerr <<
"ERROR in DynArr::ac(long i1, long i2): qel.get_qel()!= 2,"
1909 <<
" qel.get_qel()=" << qel.get_qel() <<
'\n';
1911 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1916 return el[i1 * cum_qel.acu(0) + i2];
1953 const T&
ac(
long i1,
long i2)
const
1955 if (qel.get_qel() == 2) {
1956#ifdef ALR_CHECK_EACH_BOUND
1957 if (i1 >= 0 && i1 < qel.acu(0)) {
1958 if (i2 >= 0 && i2 < qel.acu(1)) {
1960 return el[i1 * cum_qel.acu(0) + i2];
1962 return el.acu(i1 * cum_qel.acu(0) + i2);
1965 mcerr <<
"Error in DynArr::ac(long i1, long i2): i2 < 0 || i2 >= "
1970 mcerr <<
"Error in DynArr::ac(long i1, long i2): i1 < 0 || i1 >= "
1975 mcerr <<
"ERROR in DynArr::ac(long i1, long i2): qel.get_qel()!= 2,"
1976 <<
" qel.get_qel()=" << qel.get_qel() <<
'\n';
1978 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
1983 return el[i1 * cum_qel.acu(0) + i2];
2023 return el.acu(i1 * cum_qel.acu(0) + i2);
2025 inline const T&
acu(
long i1,
long i2)
const
2027 return el.acu(i1 * cum_qel.acu(0) + i2);
2030 T&
ac(
long i1,
long i2,
long i3)
2032 if (qel.get_qel() != 3) {
2033 mcerr <<
"ERROR in DynArr::ac(long i1, long i2, long i3): "
2034 "qel.get_qel()!= 3,"
2035 <<
" qel.get_qel()=" << qel.get_qel() <<
'\n';
2036 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
2040#ifdef ALR_CHECK_EACH_BOUND
2041 if (i1 < 0 || i1 >= qel.acu(0)) {
2042 mcerr <<
"Error in DynArr::ac(long i1, long i2, long i3): i1 < 0 || i1 "
2047 if (i2 < 0 || i2 >= qel.acu(1)) {
2048 mcerr <<
"Error in DynArr::ac(long i1, long i2, long i3): i2 < 0 || i2 "
2053 if (i3 < 0 || i3 >= qel.acu(2)) {
2054 mcerr <<
"Error in DynArr::ac(long i1, long i2, long i3): i3 < 0 || i3 "
2060 return el.acu(i1 * cum_qel.acu(0) + i2 * cum_qel.acu(1) + i3);
2062 return el[i1 * cum_qel.acu(0) + i2 * cum_qel[1] + i3];
2065 return el[i1 * cum_qel.acu(0) + i2 * cum_qel[1] + i3];
2070 const T&
ac(
long i1,
long i2,
long i3)
const
2072 if (qel.get_qel() != 3) {
2073 mcerr <<
"ERROR in DynArr::ac(long i1, long i2, long i3): "
2074 "qel.get_qel()!= 3,"
2075 <<
" qel.get_qel()=" << qel.get_qel() <<
'\n';
2076 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
2080#ifdef ALR_CHECK_EACH_BOUND
2081 if (i1 < 0 || i1 >= qel.acu(0)) {
2082 mcerr <<
"Error in DynArr::ac(long i1, long i2, long i3): i1 < 0 || i1 "
2087 if (i2 < 0 || i2 >= qel.acu(1)) {
2088 mcerr <<
"Error in DynArr::ac(long i1, long i2, long i3): i2 < 0 || i2 "
2093 if (i3 < 0 || i3 >= qel.acu(2)) {
2094 mcerr <<
"Error in DynArr::ac(long i1, long i2, long i3): i3 < 0 || i3 "
2100 return el.acu(i1 * cum_qel.acu(0) + i2 * cum_qel.acu(1) + i3);
2102 return el[i1 * cum_qel.acu(0) + i2 * cum_qel[1] + i3];
2105 return el[i1 * cum_qel.acu(0) + i2 * cum_qel[1] + i3];
2114 long qelln = el.get_qel();
2115#ifdef ALR_CHECK_BOUND
2116 if (n >= 0 && n < qelln)
return el[n];
2117 mcerr <<
"ERROR in T& DynArr::ac_lin(long n): "
2118 <<
"n is out of bounds, n=" << n <<
" qelln=" << qelln <<
'\n';
2119 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
2128 long qelln = el.get_qel();
2129#ifdef ALR_CHECK_BOUND
2130 if (n >= 0 && n < qelln)
return el[n];
2131 mcerr <<
"ERROR in T& DynArr::ac_lin(long n): "
2132 <<
"n is out of bounds, n=" << n <<
" qelln=" << qelln <<
'\n';
2133 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
2143 inline const T&
acu_lin(
long n)
const {
return el[n]; }
2184 template <
class P,
class X>
2186 void (*fun2)(X& f));
2194 long q = qel.get_qel();
2195 if (q == 0)
return 0;
2197 for (n = 0; n < q; n++) {
2198 if (qel[n] <= 0)
return 0;
2221 long qdim1 = qel.
get_qel() - 1;
2235 for (n = 0; n < qdim1; n++) {
2236#ifdef ALR_CHECK_EACH_BOUND
2238 if (ind[n] < 0 || ind[n] >= qel[n]) {
2239 mcerr <<
"ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& "
2241 mcerr <<
"ind[n] < 0 || ind[n] >= qel[n]\n";
2247 if (ind.
acu(n) < 0 || ind.
acu(n) >= qel.
acu(n)) {
2248 mcerr <<
"ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& "
2250 mcerr <<
"ind.acu(n) < 0 || ind.acu(n) >= qel.acu(n)\n";
2257 i += ind[n] * cum_qel[n];
2259#ifdef ALR_CHECK_EACH_BOUND
2261 if (ind[qdim1] < 0 || ind[qdim1] >= qel[qdim1]) {
2262 mcerr <<
"ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& ind) "
2264 mcerr <<
"ind[qdim1] < 0 || ind[qdim1] >= qel[qdim1]\n";
2270 if (ind.
acu(qdim1) < 0 || ind.
acu(qdim1) >= qel.acu(qdim1)) {
2271 mcerr <<
"ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& ind) "
2273 mcerr <<
"ind.acu(qdim1) < 0 || ind.acu(qdim1) >= qel.acu(qdim1)\n";
2289 mcout <<
"DynArr<T>& DynArr<T>::operator=(const DynArr<T>& f)\n";
2297 cum_qel = f.cum_qel;
2306#ifdef DEBUG_DYNLINARR
2307 mcout <<
"DynArr<T>& DynArr<T>::operator=(const DynArr<D>& f)\n";
2309 if (
this == &f)
return *
this;
2316 T* temp_el = (q > 0) ? (
new T[q]) : (T*)NULL;
2317 for (
long n = 0; n < q; n++) temp_el[n] = f.
acu_lin(n);
2318 pass(q, fqel, fcum_qel, temp_el);
2324 const long q = ar.el.get_qel();
2325 for (
long n = 0; n < q; n++) (*fun)(ar.el[n]);
2327template <
class T,
class X>
2329 void (*fun2)(X& f)) {
2330 const long q = ar.el.get_qel();
2331 for (
long n = 0; n < q; n++) (*fun1)(ar.el[n], fun2);
2334int find_next_comb(
const DynLinArr<long>& qel, DynLinArr<long>& f);
2335int find_prev_comb(
const DynLinArr<long>& qel, DynLinArr<long>& f);
2342 : ncur(fdar->get_qdim()), dar((
DynArr<T>*)fdar) {
2344 long qdim1 = ncur.get_qel() - 1;
2346 for (n = 0; n < qdim1; n++) ncur[n] = 0;
2353 return &(dar->ac(ncur));
2361 long qdim = ncur.get_qel();
2362 if (qdim <= 0)
return NULL;
2363 for (n = 0; n < qdim; n++) {
2364 if (ncur[n] < 0 || ncur[n] >= dar->get_qel()[n])
return NULL;
2366 return &(dar->ac(ncur));
2373 return &(dar->ac(ncur));
2392 if (qel.get_qel() == 0) {
2400 while ((at = iter.
more()) != NULL) {
2412 for (n = 0; n < q; n++) {
2413 if (!(f1.
acu(n) == f2.
acu(n)))
return 0;
2418template <
class T,
class P>
2423 for (n = 0; n < q; n++) {
2444template <
class T,
class P>
2473template <
class T,
class X>
2476 "template<class T, class X> void copy_DynArr(const DynArr<T>& s, "
2483 while ((at = iter.
more()) != NULL) {
2490template <
class T,
class X>
2493 "template<class T, class X> void convert_DynArr(const DynArr<T>& "
2494 "s, DynArr<X>& d)");
2500 while ((at = iter.
more()) != NULL) {
2502 d.
ac(ncur) = X(*at);
2511 for (n = 0; n < qel; n++) {
2518 mfunnamep(
"template<class T> DynArr<T> DynArr<T>::top(void)");
2524 for (n1 = 0; n1 < qel[0]; n1++) {
2525 for (n2 = 0; n2 < qel[1]; n2++) {
2526 r.
ac(n2, n1) =
ac(n1, n2);
2538 mcerr <<
"ERROR in DynLinArr<T>::DynLinArr(const DynArr<T>& f):\n"
2539 <<
"f.get_qdim() != 1, f.get_qdim()=" << f.
get_qdim() <<
'\n';
2540 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
2549 for (
long n = 0; n < qel; n++) el[n] = f.
ac(n);
2563 mcerr <<
"ERROR in DynLinArr<T>::DynLinArr(const DynArr<T>& f, int "
2564 "n_of_dim,long roc_number):\n"
2565 <<
"f.get_qdim() != 2, f.get_qdim()=" << f.
get_qdim() <<
'\n';
2566 mcerr <<
"Type of T is (in internal notations) " <<
typeid(T).name()
2571 if (n_of_dim == 0) {
2580 if (n_of_dim == 0) {
2581 for (n = 0; n < qel; n++) el[n] = f.
ac(roc_number, n);
2583 for (n = 0; n < qel; n++) el[n] = f.
ac(n, roc_number);
2603 Ifile <<
"Content element by element:\n";
2604 Ifile <<
"(The first number is sequencial number, then there are "
2605 "indexes, the last is the element)\n";
2611 while ((at = iter_f.
more()) != NULL) {
2612 std::ostringstream ost;
2615 Ifile <<
"nseq=" << std::setw(5) << nseq <<
" ncur=";
2617 for (n = 0; n < iter_f.
get_ncur().get_qel(); n++) {
2618 file <<
' ' << std::setw(5) << iter_f.
get_ncur()[n];
2631 Ifile <<
"Content is empty.\n";
2669 "template<class T> istream& operator>>(istream& file, DynArr<T>& f)");
2689 file >> cum_qel_loc;
2695 long qseq = qel_loc[0];
2696 for (n = 1; n < qel_loc.
get_qel(); n++) {
2699 for (n = 0; n < qseq; n++) {
2706 for (m = 0; m < qel_loc.
get_qel(); m++) {
2775 Ifile <<
"Content element by element:\n";
2776 Ifile <<
"(The first number is sequencial number, then there are indexes, "
2777 "the last is the element)\n";
2782 while ((at = iter_f.
more()) != NULL) {
2784 Ifile <<
"nseq=" << std::setw(5) << nseq <<
" ncur=";
2786 for (n = 0; n < iter_f.
get_ncur().get_qel(); n++) {
2787 file <<
' ' << std::setw(5) << iter_f.
get_ncur()[n];
2792 std::ostringstream ost;
2814#define Iprintda_double(file, name) \
2815 file << indn << #name << "=" << noindent; \
2816 print_DynArr_double(file, name);
#define check_econd11(a, signb, stream)
#define mfunnamep(string)
#define check_econd12(a, sign, b, stream)
IndexingProvider(DynArr< D > &farr, long fq_deref_ind, long fcurrent_pos)
IndexingProvider< D > & operator[](long n)
const IndexingProvider< D > & operator[](long n) const
D & operator=(const D &f)
const T & ac(long i1, long i2, long i3) const
int confirm_ind(const DynLinArr< long > &ind)
DynArr(long fqel1, long fqel2, long fqel3, T *val=NULL)
const DynLinArr< T > & get_el(void) const
const T & acp(const DynLinArr< long > &ind) const
DynArr(const DynArr< T > &f)
DynArr(const DynLinArr< long > &fqel, T *val)
DynArr(long fqel, T val, ArgInterp_Val)
T & acu(long i1, long i2)
const T & ac(const DynLinArr< long > &ind) const
DynArr(long fqel, const T *ar, ArgInterp_Arr)
int confirm_ind_ext(const DynLinArr< long > &ind)
IndexingProvider< T > operator[](long n)
virtual DynArr * copy() const
const DynLinArr< long > & get_cum_qel(void) const
const T & ac(long i) const
DynArr(const DynArr< T > &f, Pilfer)
DynArr(long fqel1, long fqel2, long fqel3, long fqel4, T *val=NULL)
const T & acu(long i1) const
void pilfer(const DynArr< T > &f)
DynArr< T > & operator=(const DynArr< T > &f)
DynArr(long fqel1, long fqel2, T val, ArgInterp_Val)
long get_qel_lin(void) const
const IndexingProvider< T > operator[](long n) const
void assignAll(const T &val)
const T & acu(const DynLinArr< long > &ind) const
friend void apply2(DynArr< P > &ar, void(*fun1)(P &f, void(*fun21)(X &f)), void(*fun2)(X &f))
DynArr< T > & operator=(const DynArr< D > &f)
const T & acu(long i1, long i2) const
const T & ac(long i1, long i2) const
const DynLinArr< long > & get_qel(void) const
friend void apply1(DynArr< P > &ar, void(*fun)(P &f))
DynArr(long fqel, T *val=NULL)
DynArr(long fqel1, long fqel2, T *val=NULL)
DynArr(const DynLinArr< long > &fqel, T val, ArgInterp_Val)
void put_qel(T *val=NULL)
T & ac(long i1, long i2, long i3)
int get_s_non_emplty(void) const
long get_qdim(void) const
T & ac(const DynLinArr< long > &ind)
void pass(long q, DynLinArr< long > fqel, DynLinArr< long > fcum_qel, T *fel)
DynArr(const DynLinArr< T > &f)
const T & acu_lin(long n) const
T & acu(const DynLinArr< long > &ind)
const T & ac_lin(long n) const
T & acp(const DynLinArr< long > &ind)
const T & last_el(void) const
DynLinArr(const DynLinArr< T > &f, Pilfer)
virtual DynLinArr * copy() const
void sort_select_decreasing(DynLinArr< long > &sort_ind, long q_to_sort=0) const
DynLinArr(long fqel, const T *ar, ArgInterp_Arr)
DynLinArr< T > & operator=(const DynLinArr< D > &f)
void sort(DynLinArr< long > &sort_ind, long q_to_sort=0) const
const T & acu(long n) const
void put_qel(long fqel, const T *val, ArgInterp_SingleAdr t)
DynLinArr(long fqel, const T &val)
void pilfer(const DynLinArr< T > &f)
friend void apply1(DynLinArr< P > &ar, void(*fun)(P &f))
void pass(long fqel, T *fel)
DynLinArr(const DynArr< T > &f)
void increment(const T &val)
void sort(long q_to_sort=0)
void increment(const T *val=NULL)
DynLinArr(const DynArr< T > &f, int n_of_dim, long roc_number)
friend void apply2(DynLinArr< P > &ar, void(*fun1)(P &f, void(*fun21)(X &f)), void(*fun2)(X &f))
void put_qel(long fqel, const T &val)
DynLinArr & assignAll(const T &f)
DynLinArr< T > & operator=(const DynLinArr< T > &f)
void sort_select_increasing(DynLinArr< long > &sort_ind, long q_to_sort=0) const
const T & operator[](long n) const
DynLinArr< T > & assignAll1(const X &f)
DynLinArr(const DynLinArr< T > &f)
IterDynArr(const DynArr< T > *fdar)
const DynLinArr< long > & get_ncur(void) const
IterDynLinArr(DynLinArr< T > *fdar)
virtual void print(std::ostream &file, int l=1) const
void print_DynArr_double(std::ostream &file, const DynArr< double > &f)
void print_DynLinArr(std::ostream &file, const DynLinArr< T > &f, int l)
DynLinArr< T > merge(const DynLinArr< T > &fd1, long qfd1, const DynLinArr< T > &fd2, long qfd2)
void print_DynArr(std::ostream &file, const DynArr< T > &f, int l)
std::istream & operator>>(std::istream &file, EqualStepCoorMesh< T > &f)
std::ostream & noindent(std::ostream &f)
void apply2(DynLinArr< T > &ar, void(*fun1)(T &f, void(*fun21)(X &f)), void(*fun2)(X &f))
void print_DynArr_float(std::ostream &file, const DynArr< float > &f)
void print_DynLinArr_int_double3(std::ostream &file, const DynLinArr< int > &iar, const DynLinArr< double > &dar1, const DynLinArr< double > &dar2, const DynLinArr< double > &dar3)
int operator!=(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
int ifequal(const DynLinArr< T > &fd1, const DynLinArr< T > &fd2, long qfirst=-1)
const int pq_arrelem_in_line
void print_DynLinArr_long(std::ostream &file, const DynLinArr< long > &f)
void print_DynLinArr_int_double(std::ostream &file, const DynLinArr< int > &iar, const DynLinArr< double > &dar)
int find_prev_comb(const DynLinArr< long > &qel, DynLinArr< long > &f)
void print_DynLinArr_double2(std::ostream &file, const DynLinArr< double > &f1, const DynLinArr< double > &f2)
int gconfirm_ind_ext(const DynLinArr< long > &qel, const DynLinArr< long > &ind)
void put_one_n(std::ostringstream &ost)
void print_DynLinArr_float(std::ostream &file, const DynLinArr< float > &f)
int operator==(const circumf &f1, const circumf &f2)
void apply1(DynLinArr< T > &ar, void(*fun)(T &f))
void copy_DynLinArr(const T &s, X &d)
long append(const T &t, DynLinArr< T > &dla, long &qael, T *tempt=NULL, long new_qel=0)
long set_position(const std::string &word, std::istream &istrm, int s_rewind, int s_req_sep)
int gconfirm_ind(const DynLinArr< long > &qel, const DynLinArr< long > &ind)
void print_DynLinArr_double(std::ostream &file, const DynLinArr< double > &f)
void print_DynArr_int_w(std::ostream &file, const DynArr< int > &f, int w)
void convert_DynLinArr(const T &s, X &d)
void print_adr_DynLinArr(std::ostream &file, const DynLinArr< T > &f, int l, long q)
int find_next_comb(const DynLinArr< long > &qel, DynLinArr< long > &f)
int find_next_comb_not_less(const DynLinArr< long > &qel, DynLinArr< long > &f)
void definp_any_par(T &inp, const std::string &word, const definp_endpar &dep, int fs_short=0)
void assignAll_1(DynLinArr< T > &f, const T1 &ft)
void convert_DynArr(const DynArr< T > &s, DynArr< X > &d)
int apeq_mant(const T &x1, const T &x2, T prec)
void copy_DynArr(const DynArr< T > &s, DynArr< X > &d)
void print_DynLinArr_int(std::ostream &file, const DynLinArr< int > &f)
std::ostream & yesindent(std::ostream &f)
DynLinArr< long > qel_communicat
void put_qel_1(DynLinArr< T > &f, long fq)
#define Iprint3n(file, name1, name2, name3)
#define Iprintn(file, name)
#define Iprint2n(file, name1, name2)