Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
AbsArr.h
Go to the documentation of this file.
1#ifndef ABSARR_H
2#define ABSARR_H
3/*
4Simple arrays with variable length.
5DynLinArr - "Dynamic Linear Array" - it is what it is.
6The name is choosen to distinguish this template class from every known
7other libraries.
8The information is kept in one block of memory and accessible with
9indexes. The array is characterized by the only parameter - its physical
10size. If you need a logicl size different from physical, keep the
11logical size in a separated place.
12Increasing of the array size leads to allocation of
13another block of memory and copying all elements to it by
14operator= (which can be correctly defined in the class definitions).
15This is difference with STL, in which vector have logical size
16which can be smaller than the volume of allocated memory.
17Currently the array boundaries are checked at each access, this is
18also difference with STL.
19These checks can be switched out by undefining macro ALR_CHECK_BOUND.
20The copying of array leads to copying all elements, destruction - to
21destruction of elements.
22The array DynLinArr can keep other array DynLinArr as elements
23and constitute multy-dimensional array of not "parallelogram" shape,
24that is for each first index, the dimension corresponding to
25the second index can be different from that of the other first indexes.
26This is very powerful feature, but it is not always desirable.
27If you need box-like array or "parallelogram" shape, use DynArr -
28"Dynamic Array".
29
30In DynArr the number of dimensions is arbitrary, but size of this
31array along each dimension is fixed and independent on
32the indexes of other dimensions. So this is rectangular array.
33The access is performed by indexes,
34but not through operators []. Since it is not trivial to provide
35such access for this array, I preferred the simplest solutions
36and arranged this access through little functions "ac":
37 T& DynArr::ac(long i) // for 1-dimensional array
38 T& DynArr::ac(long i1, long i2) // for 2-dimensional array
39 T& DynArr::ac(const DynLinArr<long>& ind)
40 // for arbitrary number of dimensions
41 // but the number of them in array should be equal to size of ind.
42 // ind is array of indexes. Its first element if the first index,
43 // second is second, etc.
44class DynArr is constructed with the help of DynLinArr.
45DynArr can keep as elements another DynArr's or DynLinArr's.
46DynLinArr can also keep DynArr as elements.
47
48There are many various auxiliary utilites assosiated with these arrays.
49Some of them look little bit antiquated, since they was created in
50stone age and were not revised after innovation of electricity.:)
51This happened because the author needed to port his programs on
52very various computers, not all of them had very advanced C++-related
53software. Today the situation with C++ is being changed rapidly
54and some of these pearls may be arranged by more modern way.
55But the main components of this file are actual and very convenient.
56
57Copyright (c) 1999-2005 I. B. Smirnov
58
59The file can be used, copied, modified, and distributed
60according to the terms of GNU Lesser General Public License version 2.1
61as published by the Free Software Foundation,
62and provided that the above copyright notice, this permission notice,
63and notices about any modifications of the original text
64appear in all copies and in supporting documentation.
65The file is provided "as is" without express or implied warranty.
66*/
67#include <iostream>
68#include <iomanip>
69#include <sstream>
72#include "wcpplib/util/String.h"
74
75// Here there is a good place to switch on the bound check in all programs
76#ifndef ALR_CHECK_BOUND
77#define ALR_CHECK_BOUND
78#endif
79#ifndef ALR_CHECK_EACH_BOUND
80#define ALR_CHECK_EACH_BOUND
81#endif
82
83//#define DEBUG_DYNLINARR // make some print
84//#define DEBUG_DYNARR // make some print and in addition
85// functions from DynArr make some formally unnecessary checks, which are
86// however useful for debug.
87
88namespace Heed {
89extern long max_qel_DynLinArr; // increase it if need
90// Helps to detect access to not inited DynLinArr,
91// what may happen at initializetion of class members
92// and use of not inited member for initialization of the other.
93
94template <class T>
95class DynArr;
96
98class ArgInterp_SingleAdr {}; // for put_qel()
100
101template <class T>
102class DynLinArr : public RegPassivePtr {
103 public:
104 // Constructors
105 DynLinArr(void) : qel(0), el(NULL) { ; }
106 explicit DynLinArr(long fqel) : qel(fqel), el(NULL) {
107 if (qel > max_qel_DynLinArr) {
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()
112 << '\n';
113 spexit(mcerr);
114 }
115 if (qel < 0) {
116 mcerr << "ERROR in DynLinArr(long fqel):\n";
117 mcerr << "qel < 0:\n";
118 Iprintn(mcout, qel);
119 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
120 << '\n';
121 spexit(mcerr);
122 }
123 el = (fqel > 0) ? (new T[fqel]) : (T*)NULL;
124 }
125
126 DynLinArr(long fqel, const T& val) : qel(fqel), el(NULL) {
127 if (qel > max_qel_DynLinArr) {
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()
132 << '\n';
133 spexit(mcerr);
134 }
135 if (qel < 0) {
136 mcerr << "ERROR in DynLinArr(long fqel, const T& val):\n";
137 mcerr << "qel < 0:\n";
138 Iprintn(mcout, qel);
139 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
140 << '\n';
141 spexit(mcerr);
142 }
143 el = (fqel > 0) ? (new T[fqel]) : (T*)NULL;
144 assignAll(val);
145 }
146 DynLinArr(long fqel, const T* ar, ArgInterp_Arr /*t*/) : qel(fqel), el(NULL) {
147 if (qel > max_qel_DynLinArr) {
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()
152 << '\n';
153 spexit(mcerr);
154 }
155 if (qel < 0) {
156 mcerr << "ERROR in DynLinArr(long fqel, const T* ar, ArgInterp_Arr):\n";
157 mcerr << "qel < 0:\n";
158 Iprintn(mcout, qel);
159 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
160 << '\n';
161 spexit(mcerr);
162 }
163 el = (fqel > 0) ? (new T[fqel]) : (T*)NULL;
164 for (long n = 0; n < qel; n++) el[n] = ar[n];
165 }
166 // const T* ar is array here (of course).
167 // ArgInterp_Arr serves to distinguish this
168 // from previous constructor when second argument
169 // does not coincide with T but can be converted to it.
170 // Typical example is when T is double and second argument is 0.
171 // It is assumed that 0 should be converted to 0.0 and previous
172 // constructor should be called. But in practice (Red Hat Linux 6.0)
173 // the compiler says
174 // call of overloaded `DynLinArr(int &, int)' is ambiguous.
175 // I don't know whether this is error of particular compiler or
176 // general problem. But the third dummy argument is anyway convenient
177 // to distringuish these cases.
178
180 template <class D>
182
183 void pass(long fqel, T* fel) {
184 // Do not call directly! Is to be used only
185 // from assignment operator above
186 clear();
187 qel = fqel;
188 el = fel;
189 }
190
191 inline DynLinArr(const DynLinArr<T>& f);
192 DynLinArr(const DynLinArr<T>& f, Pilfer) : qel(f.qel), el(f.el) {
193#ifdef DEBUG_DYNLINARR
194 mcout << "DynLinArr( DynLinArr<T>& f, Pilfer) is working\n";
195#endif
196 f.qel = 0;
197 f.el = 0;
198 }
199 DynLinArr(const DynArr<T>& f); // works only if f has one dimension
200 // otherwise calls spexit.
201
202 DynLinArr(const DynArr<T>& f, int n_of_dim,
203 // 0 - first dim) 1 - second dim)
204 long roc_number);
205 // takes only mentioned raw or column.
206
207 DynLinArr& assignAll(const T& f) {
208 check();
209 for (long n = 0; n < qel; n++) el[n] = f;
210 return *this;
211 }
212 template <class X>
214 // assumes that element is object
215 // which also accepts assignAll, which is called for it.
216 check();
217 for (long n = 0; n < qel; n++) el[n].assignAll(f);
218 return *this;
219 }
220 // DynLinArr& operator=(const T& f) { int n; for( n=0; n<qel; n++) el[n]=f; }
221 inline T& operator[](long n) {
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()
227 << '\n';
228 spexit(mcerr);
229 return el[0];
230#else
231 return el[n];
232#endif
233 }
234 inline const T& operator[](long n) const {
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()
240 << '\n';
241 spexit(mcerr);
242 return el[0];
243#else
244 return el[n];
245#endif
246 }
247 inline T& acu(long n) {
248 // unchecked access
249 return el[n];
250 }
251 inline const T& acu(long n) const {
252 // unchecked access
253 return el[n];
254 }
255 inline T& last_el(void) {
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()
261 << '\n';
262 spexit(mcerr);
263 return el[0];
264#else
265 return el[qel];
266#endif
267 }
268
269 inline const T& last_el(void) const {
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()
275 << '\n';
276 spexit(mcerr);
277 return el[0];
278#else
279 return el[qel];
280#endif
281 }
282
283 long get_qel(void) const { return qel; }
284 void put_qel(long fqel);
285 void put_qel(long fqel, const T* val, ArgInterp_SingleAdr t);
286 // creates array with size fqel
287 // If old array existed, then
288 // If it was less than fqel, it all is copied to new array
289 // and the other elements either assigned *val or
290 // remains not inited.
291 // else its fqel part is copyed to new array.
292 // ArgInterp_SingleAdr serves to distinguish this
293 // from next function when second argument
294 // does not coincide with T but can be converted to it
295 // (for example NULL to int and it is not clear which function
296 // should be called.
297 // Attention!, val is an element, this is assimetry with contructor,
298 // in which ar is an array.
299
300 void put_qel(long fqel, const T& val) {
301 put_qel(fqel, &val, ArgInterp_SingleAdr());
302 }
303 void increment(const T* val = NULL) {
304 check();
305 long q = qel + 1;
306 put_qel(q, *val);
307 }
308 void increment(const T& val) {
309 check();
310 long q = qel + 1;
311 put_qel(q, val);
312 }
313 void clear(void) { put_qel(0); } // Not only clears the content,
314 // but makes zero dimension.
315 void pilfer(const DynLinArr<T>& f) {
316#ifdef DEBUG_DYNLINARR
317 mcout << "DynLinArr::pilfer is called\n";
318#endif
319 if (this != &f) {
320 if (qel != 0) {
321 if (f.qel != 0) {
322 mcerr << "ERROR in DynLinArr::pilfer(...):\n";
323 mcerr << "Both the destination and source arrays are not empty\n";
324 // For explanations why it is dengerous, see similar function
325 // of ActivePtr.
326 spexit(mcerr);
327 } else {
328 delete[] el;
329 qel = 0;
330 }
331 }
332 el = f.el;
333 qel = f.qel;
334 f.el = NULL;
335 f.qel = 0;
336 }
337 }
338
339 void check(void) const;
340
341 /*
342 void print(std::ostream& file, long qpr) const
343 {
344 Ifile<<"DynLinArr<T>: qel="<<get_qel()<<" qpr="<<qpr<<'\n';
345 long n;
346 indn.n+=2;
347 for( n=0; n<qpr; n++)
348 {
349 Ifile<<"n="<<n<<" el[n]="<<this->DynLinArr<T>::operator[](n)<<'\n';
350 }
351 indn.n-=2;
352 }
353 */
354 DynArr<T> top(void); // transpose the vector, rotate it
355 // from vertical colunm to horisontal line for the purpose
356 // of linear algebra calculations.
357
358 // friend void DLA_sort<T>(DynLinArr<T>& f);
359 // Apply any function of one argument (of type T) to each element.
360 template <class P>
361 friend void apply1(DynLinArr<P>& ar, void (*fun)(P& f));
362 // template<class P> friend void apply1m(DynLinArr<P>& ar,
363 // void (*P::fun)(void));
364 // Apply any function of two arguments
365 // (first of which is of type T and the second is of type of address
366 // of another function (possibly apply1) to each element.
367 template <class P, class X>
368 friend void apply2(DynLinArr<P>& ar, void (*fun1)(P& f, void (*fun21)(X& f)),
369 void (*fun2)(X& f));
370
371 // template<class P, class X> friend void apply2m(DynLinArr<P>& ar,
372 // void (*fun1)(P& f, void (*fun21)(X& f) ),
373 // void (*X::fun2)(void) );
374 // void apply(void (*fun)(T& f))
375 //{ long n; for(n=0; n<qel; n++) (*fun)(el[n]); }
376
377 // Attention: the both sorts below at large N are much less efficient
378 // then sort for standard vectors.
379 // At N of the order of 50000 thay take several seconds,
380 // whereas sort for vectors takes several tenths of second.
381
382 void sort(long q_to_sort = 0); // sorts first q_to_sort to increasing order.
383 // If q_to_sort = 0, it sorts all get_qel() elements.
384
385 void sort(DynLinArr<long>& sort_ind, long q_to_sort = 0) const;
386 // to increasing order
387 // Does not change array, but creates index array which gives access
388 // in sorted order. For example:
389 // DynLinArr< long > sort_ind;
390 // collection.sort(sort_ind);
391 // for(n=0; n<q; n++)
392 // {
393 // collection_ordered[n] = collection[sort_ind[n]];
394 // }
395 // Thus content of each n-th element of sort_ind gives
396 // position of n-th (by size) element of array.
397
398 // finds and sorts minimal q_to_sort elements from all.
400 long q_to_sort = 0) const;
402 long q_to_sort = 0) const;
403
404 virtual DynLinArr* copy() const;
405
406 virtual ~DynLinArr() {
407 check();
408 if (el) delete[] el;
409 }
410
411 private:
412 mutable long qel; // number of elements, mutable only for pilfer
413 mutable T* el; // array of qel elements, mutable only for pilfer
414 //(regarding mutable and pilfer see ActivePtr for more comments).
415};
416template <class T>
418 return new DynLinArr<T>(*this);
419}
420
421template <class T>
422void apply1(DynLinArr<T>& ar, void (*fun)(T& f)) {
423 for (long n = 0; n < ar.qel; n++) (*fun)(ar.el[n]);
424}
425
426template <class T, class X>
427void apply2(DynLinArr<T>& ar, void (*fun1)(T& f, void (*fun21)(X& f)),
428 void (*fun2)(X& f)) {
429 for (long n = 0; n < ar.qel; n++) (*fun1)(ar.el[n], fun2);
430}
431
432template <class T>
433void DynLinArr<T>::check(void) const {
434 if (qel < 0) {
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()
438 << '\n';
439 spexit(mcerr);
440 }
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()
445 << '\n';
446 spexit(mcerr);
447 }
448 if (qel > 0) {
449 if (el == NULL) {
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()
453 << '\n';
454 spexit(mcerr);
455 }
456 if (qel > max_qel_DynLinArr) {
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()
461 << '\n';
462 spexit(mcerr);
463 }
464 }
465}
466
467template <class T>
469#ifdef DEBUG_DYNLINARR
470 mcout << "DynLinArr<T>& DynLinArr<T>::operator=(const DynLinArr<T>& f) is "
471 "working\n";
472#endif
473 if (this != &f) {
474 // mcout<<"DynLinArr<T>& operator=(const DynLinArr<T>& f): long(el)="
475 //<<long(el)<<'\n';
476 check();
477 f.check();
478 // First of all we allocate memory and copy to there
479 // all elements from f, because f can be part of this array,
480 // for example, one of its elements.
481 long q = f.get_qel();
482 T* temp_el = (T*)NULL;
483 if (q > 0) {
484 temp_el = new T[q];
485 for (long n = 0; n < q; n++) temp_el[n] = f.el[n];
486 }
487 pass(q, temp_el);
488 }
489 return *this;
490}
491
492template <class T>
493template <class D>
495#ifdef DEBUG_DYNLINARR
496 mcout << "DynLinArr<T>& DynLinArr<T>::operator=(const DynLinArr<D>& f) is "
497 "working\n";
498#endif
499 // if(this != &f)
500 //{
501 // mcout<<"DynLinArr<T>& operator=(const DynLinArr<T>& f): long(el)="
502 //<<long(el)<<'\n';
503 check();
504 f.check();
505 // First of all we allocate memory and copy to there
506 // all elements from f, because f can be part of this array,
507 // for example, one of its elements.
508 long q = f.get_qel();
509 T* temp_el = (T*)NULL;
510 if (q > 0) {
511 temp_el = new T[q];
512 for (long n = 0; n < q; n++) temp_el[n] = f[n];
513 }
514 pass(q, temp_el);
515 return *this;
516}
517
518template <class T>
520 : RegPassivePtr(),
521 qel(0),
522 el(NULL) {
523#ifdef DEBUG_DYNLINARR
524 mcout << "DynLinArr(const DynLinArr<T>& f) is working\n";
525#endif
526 *this = f;
527}
528
529template <class T>
530void DynLinArr<T>::put_qel(long fqel) {
531 //
532 // creates array with size fqel
533 // If old array existed, then
534 // If it was less than fqel, it all is copied to new array
535 // and the other elements either assigned *val or
536 // remains not inited.
537 // else its fqel part is copyed to new array.
538 // mcout<<"put_qel: *this="<<(*this);
539 if (fqel < 0) {
540 mcerr << "ERROR in template<class T> void DynLinArr<T>::put_qel(long "
541 "fqel):\n";
542 mcerr << "fqel < 0, fqel=" << fqel << '\n';
543 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
544 << '\n';
545 spexit(mcerr);
546 }
547 check();
548 if (el == NULL) {
549 qel = fqel;
550 if (qel > 0) el = new T[fqel];
551 } else {
552 if (qel != fqel) {
553 if (fqel <= 0) {
554 qel = 0;
555 delete[] el;
556 el = NULL;
557 } else {
558 T* elh;
559 elh = new T[fqel];
560 for (long n = 0; n < fqel; ++n) {
561 if (n < qel) elh[n] = el[n];
562 }
563 delete[] el;
564 el = elh;
565 qel = fqel;
566 }
567 }
568 }
569}
570
571template <class T>
572void DynLinArr<T>::put_qel(long fqel, const T* val, ArgInterp_SingleAdr t) {
573 // By default val == NULL
574 // creates array with size fqel
575 // If old array existed, then
576 // If it was less than fqel, it all is copied to new array
577 // and the other elements either assigned *val or
578 // remains not inited.
579 // else its fqel part is copyed to new array.
580 // mcout<<"put_qel: *this="<<(*this);
581 if (fqel < 0) {
582 mcerr << "ERROR in template<class T> void DynLinArr<T>::put_qel(long fqel, "
583 "const T* val, ArgInterp_SingleAdr):\n";
584 mcerr << "fqel < 0, fqel=" << fqel << '\n';
585 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
586 << '\n';
587 spexit(mcerr);
588 // Avoid compiler warning because of unused variable t (HS).
589 mcerr << sizeof(t) << "\n";
590 }
591 check();
592 if (el == NULL) {
593 qel = fqel;
594 if (qel > 0) el = new T[fqel];
595 if (val != NULL)
596 for (long n = 0; n < qel; ++n) el[n] = *val;
597 } else {
598 if (qel != fqel) {
599 if (fqel <= 0) {
600 qel = 0;
601 delete[] el;
602 el = NULL;
603 } else {
604 T* elh;
605 elh = new T[fqel];
606 for (long n = 0; n < fqel; ++n) {
607 if (n < qel)
608 elh[n] = el[n];
609 else if (val != NULL)
610 elh[n] = *val;
611 }
612 delete[] el;
613 el = elh;
614 qel = fqel;
615 }
616 }
617 }
618}
619
620// Simple sorting routine optimized for DynLiArr. )ptimized means
621// not doing checks at each indexing, but it is not the best for the large
622// number of N.
623// Note that it can be made better if at choosing n_possible_next
624// to arrange going backward. But this is much more complicated so currently
625// I am not going to do this.
626
627template <class T>
628void DynLinArr<T>::sort(long q_to_sort) {
629 mfunnamep("void DynLinArr<T>::sort(long q_to_sort = 0)");
630
631 check_econd12(q_to_sort, >, qel, mcerr);
632 if (q_to_sort <= 0) q_to_sort = qel;
633 if (q_to_sort <= 1) return;
634
635 long n_possible_next = 1;
636 long q_comp = 0;
637 long n, m;
638 for (n = 0; n < q_to_sort - 1; n++) {
639 // Iprint2n(mcout, n, n_possible_next);
640 // first it finds the minimum along the rest and replaces if it is less
641 // long nmin = n+1;
642 long nmin = n_possible_next;
643 T el_min = el[nmin];
644 int s_change_possible_next = 0;
645
646 // for(m=n+2; m<q_to_sort; m++)
647 for (m = n_possible_next + 1; m < q_to_sort; m++) {
648 q_comp++;
649 // if(el[nmin] > el[m])
650 if (el_min > el[m]) {
651 n_possible_next = nmin;
652 s_change_possible_next = 1;
653 nmin = m;
654 el_min = el[nmin];
655 }
656 }
657 // Iprint4n(mcout, n_possible_next, s_change_possible_next, nmin, el_min);
658 if (s_change_possible_next == 0 || n_possible_next < n + 2) {
659 n_possible_next = n + 2;
660 }
661 // if(el[n] > el[nmin])
662 //{
663 // T t = el[nmin];
664 // el[nmin] = el[n];
665 // el[n] = t;
666 //}
667 // Iprintn(mcout, n_possible_next);
668 // Iprint2n(mcout, el[n], el_min);
669 if (el[n] > el_min) {
670 if (s_change_possible_next == 1) {
671 // if(n_possible_next < q_to_sort)
672 if (n_possible_next < q_to_sort && el[n] < el[n_possible_next]) {
673 n_possible_next = nmin;
674 }
675 }
676 // mcout<<"replacing el[n] and el_min\n";
677 T t = el_min;
678 el[nmin] = el[n];
679 el[n] = t;
680 }
681 // Iprintn(mcout, (*this));
682 }
683 // Iprintn(mcout, q_comp);
684}
685
686// New variant, should be faster, the old is below.
687
688template <class T>
689void DynLinArr<T>::sort(DynLinArr<long>& sort_ind, long q_to_sort) const {
690 mfunnamep(
691 "void DynLinArr<T>::sort(DynLinArr< long >& sort_ind, long "
692 "q_to_sort = 0) const");
693
694 check_econd12(q_to_sort, >, qel, mcerr);
695 if (q_to_sort <= 0) q_to_sort = qel;
696 // if(q_to_sort <= 1) return;
697
698 sort_ind.clear();
699 sort_ind.pilfer(DynLinArr<long>(q_to_sort));
700 long n, m;
701 for (n = 0; n < q_to_sort; n++) {
702 sort_ind.acu(n) = n;
703 }
704 if (q_to_sort <= 1) return;
705
706 long n_possible_next = 1;
707
708 for (n = 0; n < q_to_sort - 1; n++) {
709 // first it finds the minimum along the rest and replaces if it is less
710 long nmin = n_possible_next;
711 long ind_nmin = sort_ind.acu(nmin);
712 int s_change_possible_next = 0;
713
714 // for(m=n+2; m<q_to_sort; m++)
715 for (m = n_possible_next + 1; m < q_to_sort; m++) {
716 if (el[ind_nmin] > el[sort_ind.acu(m)])
717 // if(el[sort_ind.acu(nmin)] > el[sort_ind.acu(m)])
718 {
719 n_possible_next = nmin;
720 s_change_possible_next = 1;
721 nmin = m;
722 ind_nmin = sort_ind.acu(nmin);
723 }
724 }
725 if (s_change_possible_next == 0 || n_possible_next < n + 2) {
726 n_possible_next = n + 2;
727 }
728 if (el[sort_ind.acu(n)] > el[ind_nmin])
729 // if(el[sort_ind.acu(n)] > el[sort_ind.acu(nmin)])
730 {
731 if (s_change_possible_next == 1) {
732 if (n_possible_next < q_to_sort &&
733 el[sort_ind.acu(n)] < el[sort_ind.acu(n_possible_next)]) {
734 n_possible_next = nmin;
735 }
736 }
737 // long t = sort_ind.acu(nmin);
738 sort_ind.acu(nmin) = sort_ind.acu(n);
739 sort_ind.acu(n) = ind_nmin;
740 }
741 }
742}
743
744template <class T>
746 long q_to_sort) const {
747 mfunnamep(
748 "void DynLinArr<T>::sort_select_increasing(DynLinArr< long >& "
749 "sort_ind, long q_to_sort = 0) const");
750
751 check_econd12(q_to_sort, >, qel, mcerr);
752 long s_last_noninc = 0;
753 if (q_to_sort <= 0) {
754 q_to_sort = qel;
755 s_last_noninc = 1;
756 } else if (q_to_sort == qel) {
757 s_last_noninc = 1;
758 }
759
760 // if(qel <= 1) return;
761 sort_ind.clear();
762 sort_ind.pilfer(DynLinArr<long>(qel));
763 long n, m;
764 for (n = 0; n < qel; n++) {
765 sort_ind[n] = n;
766 }
767 if (q_to_sort <= 1) return;
768
769 long n_possible_next = 1;
770
771 for (n = 0; n < q_to_sort - s_last_noninc; n++) {
772 // first it finds the minimum along the rest and replaces if it is less
773 long nmin = n_possible_next;
774 long ind_nmin = sort_ind[nmin];
775 int s_change_possible_next = 0;
776
777 // for(m=n+2; m<q_to_sort; m++)
778 for (m = n_possible_next + 1; m < qel; m++) {
779 if (el[ind_nmin] > el[sort_ind[m]])
780 // if(el[sort_ind.acu(nmin)] > el[sort_ind.acu(m)])
781 {
782 n_possible_next = nmin;
783 s_change_possible_next = 1;
784 nmin = m;
785 ind_nmin = sort_ind[nmin];
786 }
787 }
788 if (s_change_possible_next == 0 || n_possible_next < n + 2) {
789 n_possible_next = n + 2;
790 }
791 if (el[sort_ind[n]] > el[ind_nmin])
792 // if(el[sort_ind.acu(n)] > el[sort_ind.acu(nmin)])
793 {
794 if (s_change_possible_next == 1) {
795 if (n_possible_next < q_to_sort &&
796 el[sort_ind[n]] < el[sort_ind[n_possible_next]]) {
797 n_possible_next = nmin;
798 }
799 }
800 // long t = sort_ind.acu(nmin);
801 sort_ind[nmin] = sort_ind[n];
802 sort_ind[n] = ind_nmin;
803 }
804 }
805 sort_ind.put_qel(qel);
806}
807
808template <class T>
810 long q_to_sort) const {
811 mfunnamep(
812 "void DynLinArr<T>::sort_select_decreasing(DynLinArr< long >& "
813 "sort_ind, long q_to_sort = 0) const");
814
815 check_econd12(q_to_sort, >, qel, mcerr);
816 long s_last_noninc = 0;
817 if (q_to_sort <= 0) {
818 q_to_sort = qel;
819 s_last_noninc = 1;
820 } else if (q_to_sort == qel) {
821 s_last_noninc = 1;
822 }
823 // Iprintn(mcout, q_to_sort);
824
825 // if(qel <= 1) return;
826 sort_ind.clear();
827 sort_ind.pilfer(DynLinArr<long>(qel));
828 long n, m;
829 for (n = 0; n < qel; n++) {
830 sort_ind[n] = n;
831 }
832 if (q_to_sort <= 1) return;
833
834 long n_possible_next = 1;
835
836 for (n = 0; n < q_to_sort - s_last_noninc; n++) {
837 // Iprintn(mcout, n);
838 // first it finds the minimum along the rest and replaces if it is less
839 long nmax = n_possible_next;
840 // Iprintn(mcout, nmax);
841 long ind_nmax = sort_ind[nmax];
842 int s_change_possible_next = 0;
843
844 // for(m=n+2; m<q_to_sort; m++)
845 for (m = n_possible_next + 1; m < qel; m++) {
846 // Iprint3n(mcout, ind_nmax, m, sort_ind[m]);
847 if (el[ind_nmax] < el[sort_ind[m]]) {
848 n_possible_next = nmax;
849 s_change_possible_next = 1;
850 nmax = m;
851 // Iprintn(mcout, nmax);
852 ind_nmax = sort_ind[nmax];
853 }
854 }
855 if (s_change_possible_next == 0 || n_possible_next < n + 2) {
856 n_possible_next = n + 2;
857 }
858 // Iprint4n(mcout, n, sort_ind[n], ind_nmax, el[ind_nmax]);
859 if (el[sort_ind[n]] < el[ind_nmax]) {
860 if (s_change_possible_next == 1) {
861 if (n_possible_next < q_to_sort &&
862 el[sort_ind[n]] > el[sort_ind[n_possible_next]]) {
863 n_possible_next = nmax;
864 }
865 }
866 // long t = sort_ind.acu(nmin);
867 sort_ind[nmax] = sort_ind[n];
868 sort_ind[n] = ind_nmax;
869 }
870 }
871 sort_ind.put_qel(qel);
872}
873
874/*
875template<class T>
876void DynLinArr<T>::sort(DynLinArr< long >& sort_ind, long q_to_sort) const
877{
878 mfunnamep("void DynLinArr<T>::sort(DynLinArr< long >& sort_ind, long q_to_sort
879= 0) const");
880
881 check_econd12(q_to_sort , > , qel , mcerr);
882 if(q_to_sort <= 0) q_to_sort = qel;
883 if(q_to_sort <= 1) return;
884
885 //if(qel <= 1) return;
886 sort_ind.clear();
887 sort_ind.pilfer(DynLinArr< long >(q_to_sort));
888 long n,m;
889 for(n=0; n<q_to_sort; n++)
890 {
891 sort_ind.acu(n) = n;
892 }
893
894 for(n=0; n<q_to_sort-1; n++)
895 {
896 // first it finds the minimum along the rest and replaces if it is less
897 long nmin = n+1;
898 long ind_nmin = sort_ind.acu(nmin);
899 for(m=n+2; m<q_to_sort; m++)
900 {
901 if(el[ind_nmin] > el[sort_ind.acu(m)])
902 //if(el[sort_ind.acu(nmin)] > el[sort_ind.acu(m)])
903 {
904 nmin = m;
905 ind_nmin = sort_ind.acu(nmin);
906 }
907 }
908 if(el[sort_ind.acu(n)] > el[ind_nmin])
909 //if(el[sort_ind.acu(n)] > el[sort_ind.acu(nmin)])
910 {
911 //long t = sort_ind.acu(nmin);
912 sort_ind.acu(nmin) = sort_ind.acu(n);
913 sort_ind.acu(n) = ind_nmin;
914 }
915 }
916}
917*/
918
919/*
920template<T> void DLA_sort(DynLinArr<T>& f)
921{
922 mfunnamep("template<T> void DLA_sort(DynLinArr<T>& f)");
923
924 long q = f.get_qel();
925 if(q <= 1) return;
926 long n,m;
927 T* a = &(f[0]);
928 for(n=0; n<q-1; n++)
929 {
930 for(m=n+1; m<q; m++)
931 {
932 if(a[n] > a[m])
933 {
934 T t = a[m];
935 a[m] = a[n];
936 a[n] = t;
937 }
938 }
939 }
940}
941*/
942/*
943//Somewhy this doen not work prolerly if T is template class itself
944//AbsCont_ts.c:167: type unification failed for function template
945//`template <class T> long int append_TreeNode(TreeNode<...> &,
946//TreeNode<...> &, long int &, T * = 0, long int = 0)'
947*/
948/*
949This is not compiled in Solaris:
950Error: Function templates may not have default parameters.
951*/
952#ifndef BAN_DEFAULT_PAR_FUN_TEMPL
953template <class T>
954long append(const T& t, // value to assign
955 DynLinArr<T>& dla, // array to whose elements this value is to be
956 // assigned
957 long& qael, // input: index of element to which it will be assigned
958 // if qael == get_qel(), the qel will be increased
959 // to either new_qel or by 3 times.
960 // But if qael > get_qel(), it is considered as error.
961 // output: the next index
962 T* tempt = NULL, // data filled to extra elements
963 long new_qel = 0 // recommended new size
964 ) {
965 if (dla.get_qel() < qael) {
966 mcerr << "ERROR in long append(class DynLinArr& dla, ...): dla.get_qel() < "
967 "qael\n"
968 << "dla.get_qel()=" << dla.get_qel() << " qael=" << qael << '\n';
969 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
970 << '\n';
971 spexit(mcerr);
972 }
973 if (dla.get_qel() == qael) {
974 if (new_qel <= qael) new_qel = std::max(3 * qael, long(3));
975 dla.put_qel(new_qel, tempt, ArgInterp_SingleAdr());
976 }
977 dla[qael++] = t;
978 return qael;
979}
980
981#else
982
983#define append_to_DynLinArr(t, dla, qael, tempt, new_qel) \
984 { \
985 if (dla.get_qel() < qael) { \
986 mcerr << "append(class DynLinArr& dla, ...): dla.get_qel() < qael, " \
987 << "dla.get_qel()=" << dla.get_qel() << " qael=" << qael << '\n'; \
988 spexit(mcerr); \
989 } \
990 int nn = new_qel; \
991 if (dla.get_qel() == qael) { \
992 if (new_qel <= qael) nn = std::max(3 * qael, long(3)); \
993 dla.put_qel(nn, tempt); \
994 } \
995 dla[qael++] = t; \
996 }
997#define append_to_DynLinArr_short(t, dla, qael) \
998 { \
999 if (dla.get_qel() < qael) { \
1000 mcerr << "append(class DynLinArr& dla, ...): dla.get_qel() < qael, " \
1001 << "dla.get_qel()=" << dla.get_qel() << " qael=" << qael << '\n'; \
1002 spexit(mcerr); \
1003 } \
1004 int nn = 0; \
1005 if (dla.get_qel() == qael) { \
1006 nn = std::max(3 * qael, long(3)); \
1007 dla.put_qel(nn, NULL); \
1008 } \
1009 dla[qael++] = t; \
1010 }
1011#endif
1012
1013template <class T>
1014std::ostream& operator<<(std::ostream& file, const DynLinArr<T>& f) {
1015 // mfunnamep("template<class T> std::ostream& operator<<(std::ostream& file,
1016 // const DynLinArr<T>& f)");
1017 // mcout<<"operator<<(std::ostream& file, const DynLinArr<T>& f) is
1018 // started\n";
1019 Ifile << "DynLinArr<T>: qel=" << f.get_qel() << '\n';
1020 f.check();
1021 long n;
1022 indn.n += 2;
1023 for (n = 0; n < f.get_qel(); n++) {
1024 // Ifile<<"n="<<n<<" el[n]="<<noindent<<f[n]<<yesindent<<'\n';
1025 if (s_short_output == 0) {
1026 Ifile << "n=" << n << " el[n]=";
1027 }
1028 std::ostringstream ost;
1029 ost << indn << noindent << f[n] << yesindent;
1030 put_one_n(ost);
1031 file << ost.str();
1032 }
1033 // file<<yesindent;
1034 indn.n -= 2;
1035 return file;
1036}
1037
1038
1039
1040template <class T>
1041std::istream& operator>>(std::istream& file, DynLinArr<T>& f) {
1042 mfunnamep(
1043 "template<class T> istream& operator>>(istream& file, DynLinArr<T>& f)");
1044 // mcout<<"operator<<(std::ostream& file, const DynLinArr<T>& f) is
1045 // started\n";
1046 definp_endpar dep(&file, 0, 1, 0, s_short_output);
1047 long qel = 0;
1048 dep.s_short = 0;
1049 DEFINPAP(qel);
1050 dep.s_short = s_short_output;
1051 check_econd11(qel, < 0, mcerr);
1052 f.clear();
1053 f.put_qel(qel);
1054 long fn;
1055 for (fn = 0; fn < qel; fn++) {
1056 if (s_short_output == 0) {
1057 long n = 0;
1058 DEFINPAP(n);
1059 check_econd12(fn, !=, n, mcerr);
1060 }
1061 // set_position("el[n]=", *dep.istrm, dep.s_rewind, dep.s_req_sep);
1062 // file >> f[n];
1063 definp_any_par(f[fn], "el[n]=", dep);
1064 }
1065 return file;
1066}
1067
1068// Commented out unused function (hschindl)
1069/*
1070template<class T>
1071void output_DynLinArr(std::ostream& file, const DynLinArr<T>& f, int l, long q)
1072{
1073 //mfunnamep("template<class T> void output_DynLinArr(std::ostream& file, const
1074DynLinArr<T>& f, int l, long q)");
1075 Ifile<<"DynLinArr<T>: qel="<<f.get_qel()<<" q to print is "<<q<<'\n';
1076 f.check();
1077 if(q>f.get_qel())
1078 {
1079 mcerr<<"output_DynLinArr(...): q>f.get_qel(), q="<<q
1080 <<" f.get_qel()="<<f.get_qel()<<'\n';
1081 mcerr<<"Type of T is (in internal notations) "<<typeid(T).name()<<'\n';
1082 spexit(mcerr);
1083 }
1084 long n;
1085 indn.n+=2;
1086 for( n=0; n<q; n++)
1087 {
1088 //Ifile<<"n="<<n<<" el[n]="<<noindent<<f[n]<<yesindent<<'\n';
1089 Ifile<<"n="<<n<<" el[n]="<<noindent;
1090 std::ostringstream ost;
1091 ost<<f[n]<<yesindent;
1092 put_one_n(ost);
1093 file<<ost.str();
1094 }
1095 //file<<yesindent;
1096 indn.n-=2;
1097}
1098*/
1099
1100template <class T>
1101void print_DynLinArr(std::ostream& file, const DynLinArr<T>& f, int l) {
1102 // mfunnamep("template<class T> void print_DynLinArr(std::ostream& file, const
1103 // DynLinArr<T>& f, int l)");
1104 Ifile << "DynLinArr<T>: qel=" << f.get_qel() << '\n';
1105 f.check();
1106 long n;
1107 indn.n += 2;
1108 for (n = 0; n < f.get_qel(); n++) {
1109 // Ifile<<"n="<<n<<" el[n]="<<noindent; f[n].print(file, l);
1110 // file<<yesindent;
1111 Ifile << "n=" << n << " el[n]=" << noindent;
1112 std::ostringstream ost;
1113 f[n].print(ost, l);
1114 ost << yesindent;
1115 put_one_n(ost);
1116 file << ost.str();
1117 }
1118 indn.n -= 2;
1119}
1120
1121template <class T>
1122void print_DynLinArr(std::ostream& file, const DynLinArr<T>& f, int l, long q) {
1123 // mfunnamep("template<class T> void print_DynLinArr(std::ostream& file, const
1124 // DynLinArr<T>& f, int l, long q)");
1125 Ifile << "DynLinArr<T>: qel=" << f.get_qel() << " q to print is " << q
1126 << '\n';
1127 f.check();
1128 if (q > f.get_qel()) {
1129 mcerr << "print_DynLinArr(...): q>f.get_qel(), q=" << q
1130 << " f.get_qel()=" << f.get_qel() << '\n';
1131 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1132 << '\n';
1133 spexit(mcerr);
1134 }
1135 long n;
1136 indn.n += 2;
1137 for (n = 0; n < q; n++) {
1138 // Ifile<<"n="<<n<<" el[n]="<<noindent; f[n].print(file, l);
1139 // file<<yesindent;
1140 Ifile << "n=" << n << " el[n]=" << noindent;
1141 std::ostringstream ost;
1142 f[n].print(ost, l);
1143 ost << yesindent;
1144 put_one_n(ost);
1145 file << ost.str();
1146 }
1147 indn.n -= 2;
1148}
1149
1150template <class T>
1151void print_adr_DynLinArr(std::ostream& file, const DynLinArr<T>& f, int l,
1152 long q) {
1153 // mfunnamep("template<class T> void print_adr_DynLinArr(std::ostream& file,
1154 // const DynLinArr<T>& f, int l, long q)");
1155 Ifile << "DynLinArr<T>: qel=" << f.get_qel() << " q to print is " << q
1156 << '\n';
1157 f.check();
1158 if (q > f.get_qel()) {
1159 mcerr << "print_adr_DynLinArr(...): q>f.get_qel(), q=" << q
1160 << " f.get_qel()=" << f.get_qel() << '\n';
1161 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1162 << '\n';
1163 spexit(mcerr);
1164 }
1165 long n;
1166 indn.n += 2;
1167 for (n = 0; n < q; n++) {
1168 // Ifile<<"n="<<n<<" el[n]="<<noindent; f[n]->print(file, l);
1169 // file<<yesindent;
1170 Ifile << "n=" << n << " el[n]=" << noindent;
1171 std::ostringstream ost;
1172 f[n]->print(ost, l);
1173 ost << yesindent;
1174 put_one_n(ost);
1175 file << ost.str();
1176 }
1177 indn.n -= 2;
1178}
1179
1181
1182void print_DynLinArr_int(std::ostream& file, const DynLinArr<int>& f);
1183void print_DynLinArr_long(std::ostream& file, const DynLinArr<long>& f);
1184void print_DynLinArr_float(std::ostream& file, const DynLinArr<float>& f);
1185void print_DynLinArr_double(std::ostream& file, const DynLinArr<double>& f);
1186// See AbsArrD for similar function with DoubleAc
1187
1188void print_DynLinArr_double2(std::ostream& file, const DynLinArr<double>& f1,
1189 const DynLinArr<double>& f2);
1190// Print two arrays in two colums side-by-side.
1191// Good for arrays of equal dimensions.
1192
1193void print_DynLinArr_int_double(std::ostream& file, const DynLinArr<int>& iar,
1194 const DynLinArr<double>& dar);
1195
1196void print_DynLinArr_int_double3(std::ostream& file, const DynLinArr<int>& iar,
1197 const DynLinArr<double>& dar1,
1198 const DynLinArr<double>& dar2,
1199 const DynLinArr<double>& dar3);
1200// Print 4 arrays in two colums side-by-side.
1201// Good for arrays of equal dimensions.
1202
1203#define Iprintdla_int(file, name) \
1204 file << indn << #name << "=" << noindent; \
1205 print_DynLinArr_int(file, name);
1206#define Iprintdla_long(file, name) \
1207 file << indn << #name << "=" << noindent; \
1208 print_DynLinArr_long(file, name);
1209#define Iprintdla_float(file, name) \
1210 file << indn << #name << "=" << noindent; \
1211 print_DynLinArr_float(file, name);
1212#define Iprintdla_double(file, name) \
1213 file << indn << #name << "=" << noindent; \
1214 print_DynLinArr_double(file, name);
1215// See AbsArrD for similar function with DoubleAc
1216
1217template <class T, class X>
1218void copy_DynLinArr(const T& s, X& d) {
1219 mfunnamep("template<class T, class X> void copy_DynLinArr(const T& s, X& d)");
1220 s.check();
1221 d.check();
1222 long q = s.get_qel();
1223 d.put_qel(q);
1224 long n;
1225 for (n = 0; n < q; n++) {
1226 d[n] = s[n];
1227 }
1228}
1229
1230// Covert to another compatible type
1231template <class T, class X>
1232void convert_DynLinArr(const T& s, X& d) {
1233 long q = s.get_qel();
1234 d.put_qel(q);
1235 long n;
1236 for (n = 0; n < q; n++) {
1237 d[n] = X(s[n]);
1238 }
1239}
1240
1241template <class T>
1242void put_qel_1(DynLinArr<T>& f, long fq) // change dimensions of arrays
1243 // which are elements of the main one
1244{
1245 long q = f.get_qel();
1246 long n;
1247 for (n = 0; n < q; n++) f[n].put_qel(fq);
1248}
1249
1250template <class T, class T1>
1251void assignAll_1(DynLinArr<T>& f, const T1& ft) // assign ft to all elements
1252 // of arrays which are elements of the main one
1253{
1254 long q = f.get_qel();
1255 long n;
1256 for (n = 0; n < q; n++) f[n].assignAll(ft);
1257}
1258
1259template <class T>
1261 public:
1262 IterDynLinArr(DynLinArr<T>* fdar) : dar(fdar), ncur(-1) { ; }
1263 T* more(void) {
1264 if (ncur < dar->get_qel() - 1)
1265 return &((*dar)[++ncur]);
1266 else
1267 ncur = dar->get_qel();
1268 return NULL;
1269 }
1270 T* current(void) {
1271 if (ncur >= 0 || ncur < dar->get_qel())
1272 return &((*dar)[ncur]);
1273 else
1274 return NULL;
1275 }
1276 T* less(void) // switch current to previous
1277 {
1278 if (ncur >= 1)
1279 return &((*dar)[--ncur]);
1280 else
1281 ncur = -1;
1282 return NULL;
1283 }
1284 long get_ncur(void) { return ncur; }
1285
1286 private:
1287 long ncur;
1288 DynLinArr<T>* dar;
1289};
1290
1291int gconfirm_ind(const DynLinArr<long>& qel, const DynLinArr<long>& ind);
1292int gconfirm_ind_ext(const DynLinArr<long>& qel, const DynLinArr<long>& ind);
1293
1294// The following function checks whether the arrays or their first qfirst
1295// elements are equal.
1296// In the first case this means that their dimensions and all elements
1297// should be equal to each other.
1298// In the second case if either of the dimensions is less than qfirst,
1299// the result is negative (0), so the arrays are considered different.
1300// If the dimensions are equal or more than qfirst,
1301// the function compares that number of first elements.
1302// If to put here just equal, the program may not be compiled since
1303// instead of this function the program will insert
1304// template <class InputIterator1, class InputIterator2>
1305// inline bool equal(InputIterator1 first1, InputIterator1 last1,
1306// InputIterator2 first2) {
1307// Therefore I substituted it to ifequal.
1308template <class T>
1309int ifequal(const DynLinArr<T>& fd1, const DynLinArr<T>& fd2,
1310 long qfirst = -1) {
1311 long n;
1312 if (qfirst == -1) {
1313 if ((qfirst = fd1.get_qel()) != fd2.get_qel()) return 0;
1314 // qfirst=fd1.get_qel();
1315 } else {
1316 if (qfirst > fd1.get_qel() || qfirst > fd2.get_qel()) return 0;
1317 }
1318 // Iprintn(mcout, qfirst);
1319 for (n = 0; n < qfirst; n++) {
1320 // Iprint3n(mcout, n, fd1[n], fd2[n]);
1321 if (!(fd1[n] == fd2[n])) return 0;
1322 }
1323 return 1;
1324}
1325
1326// The same as above, but compares DynLinArr with ordinary array.
1327template <class T>
1328int ifequal(const DynLinArr<T>& fd1, const T* fd2, long qfirst = -1) {
1329 long n;
1330 if (qfirst == -1) {
1331 qfirst = fd1.get_qel();
1332 } else {
1333 if (qfirst > fd1.get_qel()) return 0;
1334 }
1335 for (n = 0; n < qfirst; n++)
1336 if (!(fd1[n] == fd2[n])) return 0;
1337 return 1;
1338}
1339
1340template <class T>
1341int ifequal(T* fd1, T* fd2, long qfirst) {
1342 long n;
1343 for (n = 0; n < qfirst; n++)
1344 if (!(fd1[n] == fd2[n])) return 0;
1345 return 1;
1346}
1347
1348template <class T>
1349DynLinArr<T> merge(const DynLinArr<T>& fd1, long qfd1, const DynLinArr<T>& fd2,
1350 long qfd2) {
1351 long n;
1352 if (qfd1 < 0) {
1353 qfd1 = fd1.get_qel();
1354 }
1355 if (qfd2 < 0) {
1356 qfd2 = fd2.get_qel();
1357 }
1358 DynLinArr<T> ret(qfd1 + qfd2);
1359 if (qfd1 + qfd2 == 0) return ret;
1360 for (n = 0; n < qfd1; n++) {
1361 ret[n] = fd1[n];
1362 }
1363 for (n = 0; n < qfd2; n++) {
1364 ret[qfd1 + n] = fd2[n];
1365 }
1366 return ret;
1367}
1368
1369template <class T>
1370class DynArr : public RegPassivePtr {
1371 public:
1372 // Constructors
1373 DynArr(void) { ; }
1374 // For one-dimensional array:
1375 explicit DynArr(long fqel, T* val = NULL)
1376 : qel(DynLinArr<long>(1)),
1377 cum_qel(DynLinArr<long>(1)),
1378 el(DynLinArr<T>(fqel)) {
1379#ifdef DEBUG_DYNARR
1380 mcout << "explicit DynArr(long fqel, T* val=NULL) is called\n";
1381#endif
1382 qel[0] = fqel;
1383 cum_qel[0] = 1;
1384 if (val != NULL) assignAll(*val);
1385 }
1386 DynArr(long fqel, T val, ArgInterp_Val /*t*/)
1387 : qel(DynLinArr<long>(1)),
1388 cum_qel(DynLinArr<long>(1)),
1389 el(DynLinArr<T>(fqel)) {
1390#ifdef DEBUG_DYNARR
1391 mcout << "explicit DynArr(long fqel, T* val=NULL) is called\n";
1392#endif
1393 qel[0] = fqel;
1394 cum_qel[0] = 1;
1395 assignAll(val);
1396 }
1397 DynArr(long fqel, const T* ar, ArgInterp_Arr /*t*/)
1398 : qel(DynLinArr<long>(1)), cum_qel(DynLinArr<long>(1)), el(fqel) {
1399 qel[0] = fqel;
1400 cum_qel[0] = 1;
1401 long n;
1402 for (n = 0; n < fqel; n++) el.acu(n) = ar[n];
1403 }
1404 // Another variant for one-dimensional array
1405 // Attention: if the T is long, this might be mixed with array of dimensions.
1406 // To avoid this the latter should be accompanied by address, see below.
1408 : qel(DynLinArr<long>(1)), cum_qel(DynLinArr<long>(1)), el(f.get_qel()) {
1409 qel[0] = f.get_qel();
1410 cum_qel[0] = 1;
1411 for (long n = 0; n < qel[0]; n++) ac(n) = f[n];
1412 }
1413
1414 // For two-dimensional array:
1415 DynArr(long fqel1, long fqel2, T* val = NULL)
1416 : qel(DynLinArr<long>(2)),
1417 cum_qel(DynLinArr<long>(2)),
1418 el(fqel1 * fqel2) {
1419#ifdef DEBUG_DYNARR
1420 mcout << "DynArr(long fqel1, long fqel2, T* val=NULL) is called\n";
1421#endif
1422 qel[0] = fqel1;
1423 qel[1] = fqel2;
1424 cum_qel[0] = fqel2;
1425 cum_qel[1] = 1;
1426 if (val != NULL) assignAll(*val);
1427 }
1428
1429 DynArr(long fqel1, long fqel2, T val, ArgInterp_Val /*t*/)
1430 : qel(DynLinArr<long>(2)),
1431 cum_qel(DynLinArr<long>(2)),
1432 el(fqel1 * fqel2) {
1433#ifdef DEBUG_DYNARR
1434 mcout
1435 << "DynArr(long fqel1, long fqel2, T val, ArgInterp_Val t) is called\n";
1436#endif
1437 qel[0] = fqel1;
1438 qel[1] = fqel2;
1439 cum_qel[0] = fqel2;
1440 cum_qel[1] = 1;
1441 assignAll(val);
1442 }
1443
1444 // For three-dimensional array:
1445 DynArr(long fqel1, long fqel2, long fqel3, T* val = NULL)
1446 : qel(DynLinArr<long>(3)),
1447 cum_qel(DynLinArr<long>(3)),
1448 el(fqel1 * fqel2 * fqel3) {
1449 qel[0] = fqel1;
1450 qel[1] = fqel2;
1451 qel[2] = fqel3;
1452 cum_qel[0] = fqel2 * fqel3;
1453 cum_qel[1] = fqel3;
1454 cum_qel[2] = 1;
1455 if (val != NULL) assignAll(*val);
1456 }
1457
1458 // For four-dimensional array:
1459 DynArr(long fqel1, long fqel2, long fqel3, long fqel4, T* val = NULL)
1460 : qel(DynLinArr<long>(4)),
1461 cum_qel(DynLinArr<long>(4)),
1462 el(fqel1 * fqel2 * fqel3 * fqel4) {
1463 qel[0] = fqel1;
1464 qel[1] = fqel2;
1465 qel[2] = fqel3;
1466 qel[3] = fqel4;
1467 cum_qel[0] = fqel2 * fqel3 * fqel4;
1468 cum_qel[1] = fqel3 * fqel4;
1469 cum_qel[2] = fqel4;
1470 cum_qel[3] = 1;
1471 if (val != NULL) assignAll(*val);
1472 }
1473
1474 // Default value is removed in order to avoid confusions with copy
1475 // constructor from DynLinArr at T = long.
1476 // If initialization of values is not necessary, just put NULL as argument.
1477 // It creates array with structure determined by fqel.
1478
1479 DynArr(const DynLinArr<long>& fqel, T val, ArgInterp_Val /*t*/) : qel(fqel) {
1480 long qdim = qel.get_qel();
1481 if (qdim <= 0) return;
1482 cum_qel.put_qel(qdim);
1483 long ndim;
1484 long size = qel[0];
1485 for (ndim = 1; ndim < qdim; ndim++) size *= qel[ndim];
1486 el.put_qel(size);
1487 cum_qel[qdim - 1] = 1;
1488 for (ndim = qdim - 2; ndim >= 0; ndim--)
1489 cum_qel[ndim] = qel[ndim + 1] * cum_qel[ndim + 1];
1490 assignAll(val);
1491 }
1492
1493 explicit DynArr(const DynLinArr<long>& fqel, T* val) : qel(fqel) {
1494 // fqel: array of dimensions
1495 // val: address of value to fill, may be NULL
1496 long qdim = qel.get_qel();
1497 if (qdim <= 0) return;
1498 cum_qel.put_qel(qdim);
1499 long ndim;
1500 long size = qel[0];
1501 for (ndim = 1; ndim < qdim; ndim++) size *= qel[ndim];
1502 el.put_qel(size);
1503 cum_qel[qdim - 1] = 1;
1504 for (ndim = qdim - 2; ndim >= 0; ndim--)
1505 cum_qel[ndim] = qel[ndim + 1] * cum_qel[ndim + 1];
1506 if (val != NULL) assignAll(*val);
1507 }
1508
1510#ifdef DEBUG_DYNARR
1511 mcout << "DynArr(const DynArr<T>& f) is working\n";
1512#endif
1513 *this = f;
1514 }
1516 : qel(f.qel, steal), cum_qel(f.cum_qel, steal), el(f.el, steal) {
1517#ifdef DEBUG_DYNARR
1518 mcout << "DynArr( DynArr<T>& f, Pilfer) is working\n";
1519#endif
1520 }
1521
1522 void pilfer(const DynArr<T>& f) {
1523#ifdef DEBUG_DYNARR
1524 mcout << "DynArr::pilfer is called\n";
1525#endif
1526 if (this != &f) {
1527 if (qel.get_qel() != 0) {
1528 if (f.qel.get_qel() != 0) {
1529 mcerr << "ERROR in DynArr::pilfer(...):\n";
1530 mcerr << "Both the destination and source arrays are not empty\n";
1531 // For explanations why it is dangerous, see similar function
1532 // of ActivePtr.
1533 spexit(mcerr);
1534 } else {
1535 qel.clear();
1536 cum_qel.clear();
1537 el.clear();
1538 }
1539 }
1540 qel.pilfer(f.qel);
1541 cum_qel.pilfer(f.cum_qel);
1542 el.pilfer(f.el);
1543 f.qel.clear();
1544 f.cum_qel.clear();
1545 f.el.clear();
1546 }
1547 }
1548
1550 template <class D>
1552
1553 void pass(long q, DynLinArr<long> fqel, DynLinArr<long> fcum_qel, T* fel)
1554 // Do not call directly! Is to be used only
1555 // from assignment operator above
1556 {
1557 clear();
1558 qel = fqel;
1559 cum_qel = fcum_qel;
1560 el.pass(q, fel);
1561 }
1562
1563 // Auxiliary class that provides indexing through ordinary way
1564 // It is perhaps quite slow.
1565 template <class D>
1567 public:
1569 mutable long q_deref_ind;
1570 mutable long current_pos;
1571 IndexingProvider(DynArr<D>& farr, long fq_deref_ind, long fcurrent_pos)
1572 : arr(farr), q_deref_ind(fq_deref_ind), current_pos(fcurrent_pos) {}
1573 operator D&() const {
1574 if (q_deref_ind != arr.qel.get_qel()) {
1575 mcerr << "ERROR in IndexingProvider::operator D& (): q_deref_ind != "
1576 "qel.get_qel()\n";
1578 mcerr << "Type of T is (in internal notations) " << typeid(D).name()
1579 << '\n';
1580 spexit(mcerr);
1581 }
1582#ifdef ALR_CHECK_BOUND
1583 return arr.el[current_pos];
1584#else
1585 return arr.el.acu(current_pos);
1586#endif
1587 }
1588 D& operator=(const D& f) {
1589 if (q_deref_ind != arr.get_qel().get_qel()) {
1590 mcerr << "ERROR in T& IndexingProvider::operator=(T& f): q_deref_ind "
1591 "!= arr.get_qel().get_qel()\n";
1593 mcerr << "Type of T is (in internal notations) " << typeid(D).name()
1594 << '\n';
1595 spexit(mcerr);
1596 }
1597#ifdef ALR_CHECK_BOUND
1598 arr.ac_lin(current_pos) = f;
1599#else
1600 arr.acu_lin(current_pos) = f;
1601#endif
1602 // return arr.el[current_pos];
1603 }
1604
1606 if (q_deref_ind >= arr.get_qel().get_qel()) {
1607 mcerr << "ERROR in DynArr::IndexingProvider& DynArr::operator[](long "
1608 "n): q_deref_ind >= arr.get_qel().get_qel()\n";
1610 mcerr << "Type of T is (in internal notations) " << typeid(D).name()
1611 << '\n';
1612 spexit(mcerr);
1613 }
1614#ifdef ALR_CHECK_EACH_BOUND
1615 if (n >= 0 && n < arr.qel.acu(q_deref_ind)) {
1616#endif
1618 q_deref_ind++;
1619 return *this;
1620#ifdef ALR_CHECK_EACH_BOUND
1621 } else {
1622 mcerr << "Error in IndexingProvider<D>& "
1623 "IndexingProvider::operator[](long n): n < 0 || n >= "
1624 "qel.acu(q_deref_ind)\n";
1625 Iprint2n(mcout, n, arr.qel.acu(q_deref_ind));
1626 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1627 << '\n';
1628 spexit(mcerr);
1629 }
1630#endif
1631 }
1632
1633 inline const IndexingProvider<D>& operator[](long n) const {
1634 if (q_deref_ind >= arr.get_qel().get_qel()) {
1635 mcerr << "ERROR in DynArr::IndexingProvider& DynArr::operator[](long "
1636 "n): q_deref_ind >= arr.get_qel().get_qel()\n";
1638 mcerr << "Type of T is (in internal notations) " << typeid(D).name()
1639 << '\n';
1640 spexit(mcerr);
1641 }
1642#ifdef ALR_CHECK_EACH_BOUND
1643 if (n >= 0 && n < arr.qel.acu(q_deref_ind)) {
1644#endif
1646 q_deref_ind++;
1647 return *this;
1648#ifdef ALR_CHECK_EACH_BOUND
1649 } else {
1650 mcerr << "Error in IndexingProvider<D>& "
1651 "IndexingProvider::operator[](long n): n < 0 || n >= "
1652 "qel.acu(q_deref_ind)\n";
1653 Iprint2n(mcout, n, arr.qel.acu(q_deref_ind));
1654 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1655 << '\n';
1656 spexit(mcerr);
1657 }
1658#endif
1659 }
1660 };
1661
1662 // This operator can be used to provide ordinary indexing [][][]... .
1663 // It is perhaps quite slow compared with ac() functions.
1664 // It is provided only for the use in contexts in which [][][]...
1665 // is needed.
1667 if (qel.get_qel() < 1) {
1668 mcerr << "ERROR in DynArr::IndexingProvider DynArr::operator[](long n): "
1669 "qel.get_qel()< 1, qel.get_qel()=" << qel.get_qel() << '\n';
1670 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1671 << '\n';
1672 spexit(mcerr);
1673 }
1674#ifdef ALR_CHECK_EACH_BOUND
1675 if (n >= 0 && n < qel.acu(0)) {
1676#endif
1677 return IndexingProvider<T>(*this, 1, n * cum_qel.acu(0));
1678#ifdef ALR_CHECK_EACH_BOUND
1679 } else {
1680 mcerr << "Error in IndexingProvider<T> DynArr::operator[](long n): n < 0 "
1681 "|| n >= qel.acu(0)\n";
1682 Iprint2n(mcout, n, qel.acu(0));
1683 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1684 << '\n';
1685 spexit(mcerr);
1686 }
1687#endif
1688 }
1689
1690 inline const IndexingProvider<T> operator[](long n) const {
1691 if (qel.get_qel() < 1) {
1692 mcerr << "ERROR in DynArr::IndexingProvider DynArr::operator[](long n): "
1693 "qel.get_qel()< 1, qel.get_qel()=" << qel.get_qel() << '\n';
1694 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1695 << '\n';
1696 spexit(mcerr);
1697 }
1698#ifdef ALR_CHECK_EACH_BOUND
1699 if (n >= 0 && n < qel.acu(0)) {
1700#endif
1701 // DynArr<T>* temp = static_cast<DynArr<T>* >(this);
1702 DynArr<T>* temp = const_cast<DynArr<T>*>(this);
1703 // static_cast<const IndexingProvider<T> >(*this);
1704 return IndexingProvider<T>(*temp, 1, n * cum_qel.acu(0));
1705#ifdef ALR_CHECK_EACH_BOUND
1706 } else {
1707 mcerr << "Error in IndexingProvider<T> DynArr::operator[](long n): n < 0 "
1708 "|| n >= qel.acu(0)\n";
1709 Iprint2n(mcout, n, qel.acu(0));
1710 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1711 << '\n';
1712 spexit(mcerr);
1713 }
1714#endif
1715 }
1716
1717 T& ac(long i) {
1718 // for 1-dimensional array
1719 if (qel.get_qel() == 1) return el[i];
1720 mcerr << "ERROR in DynArr::ac(long i): qel.get_qel()!= 1, qel.get_qel()="
1721 << qel.get_qel() << '\n';
1722 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1723 << '\n';
1724 spexit(mcerr);
1725 return el[0];
1726 }
1727 const T& ac(long i) const {
1728 // for 1-dimensional array
1729 if (qel.get_qel() == 1) return el[i];
1730 mcerr << "ERROR in DynArr::ac(long i): qel.get_qel()!= 1, qel.get_qel()="
1731 << qel.get_qel() << '\n';
1732 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1733 << '\n';
1734 spexit(mcerr);
1735 return el[0];
1736 }
1737 inline T& acu(long i1) // for 1-dimensional array, completely unchecked
1738 {
1739 return el.acu(i1);
1740 }
1741 inline const T& acu(long i1) const // for 1-dimensional array, completely
1742 // unchecked
1743 {
1744 return el.acu(i1);
1745 }
1746
1747 T& ac(const DynLinArr<long>& ind) // for arbitrary number of dimensions
1748 // but the number of them in array should be equal to size of ind.
1749 // ind is array of indexes. Its first element if the first index,
1750 // second is second, etc.
1751 {
1752 long q;
1753 if ((q = qel.get_qel()) != ind.get_qel()) {
1754 mcerr << "ERROR in DynArr::ac(const DynLinArr<long>& ind): "
1755 << "qel.get_qel()!= ind.get_qel()\n"
1756 << "qel.get_qel()=" << qel.get_qel()
1757 << " ind.get_qel()=" << ind.get_qel() << '\n';
1758 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1759 << '\n';
1760 spexit(mcerr);
1761 }
1762#ifdef ALR_CHECK_EACH_BOUND
1763#ifdef DEBUG_DYNARR
1764 if (q == 1) // faster for this case
1765 return el[ind.acu(0)];
1766 else
1767 return el[calc_lin_ind(ind)];
1768#else
1769 if (q == 1)
1770 return el[ind.acu(0)];
1771 else
1772 return el.acu(calc_lin_ind(ind));
1773#endif
1774#else
1775 if (q == 1)
1776 return el[ind.acu(0)];
1777 else
1778 return el[calc_lin_ind(ind)];
1779#endif
1780 }
1781 const T& ac(const DynLinArr<long>& ind) const // the same as above
1782 {
1783 long q;
1784 if ((q = qel.get_qel()) != ind.get_qel()) {
1785 mcerr << "ERROR in DynArr::ac(const DynLinArr<long>& ind): "
1786 << "qel.get_qel()!= ind.get_qel()\n"
1787 << "qel.get_qel()=" << qel.get_qel()
1788 << " ind.get_qel()=" << ind.get_qel() << '\n';
1789 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1790 << '\n';
1791 spexit(mcerr);
1792 }
1793/*
1794#ifdef ALR_CHECK_EACH_BOUND
1795#ifdef DEBUG_DYNARR
1796 return el[calc_lin_ind(ind)];
1797#else
1798 return el.acu(calc_lin_ind(ind));
1799#endif
1800#else
1801 return el[calc_lin_ind(ind)];
1802#endif
1803 //return el[calc_lin_ind(ind)];
1804 */
1805
1806#ifdef ALR_CHECK_EACH_BOUND
1807#ifdef DEBUG_DYNARR
1808 if (q == 1) // faster for this case
1809 return el[ind.acu(0)];
1810 else
1811 return el[calc_lin_ind(ind)];
1812#else
1813 if (q == 1)
1814 return el[ind.acu(0)];
1815 else
1816 return el.acu(calc_lin_ind(ind));
1817#endif
1818#else
1819 if (q == 1)
1820 return el[ind.acu(0)];
1821 else
1822 return el[calc_lin_ind(ind)];
1823#endif
1824 }
1825
1826 T& acp(const DynLinArr<long>& ind) // the same as above, but
1827 // the size of ind can be more than the number of indexes
1828 // (the rest is unused)
1829 {
1830 long q;
1831 if ((q = qel.get_qel()) > ind.get_qel()) {
1832 mcerr << "ERROR in DynArr::acp(const DynLinArr<long>& ind): "
1833 << "qel.get_qel()!= ind.get_qel()\n"
1834 << "qel.get_qel()=" << qel.get_qel()
1835 << " ind.get_qel()=" << ind.get_qel() << '\n';
1836 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1837 << '\n';
1838 spexit(mcerr);
1839 }
1840
1841#ifdef ALR_CHECK_EACH_BOUND
1842#ifdef DEBUG_DYNARR
1843 if (q == 1) // faster for this case
1844 return el[ind.acu(0)];
1845 else
1846 return el[calc_lin_ind(ind)];
1847#else
1848 if (q == 1)
1849 return el[ind.acu(0)];
1850 else
1851 return el.acu(calc_lin_ind(ind));
1852#endif
1853#else
1854 if (q == 1)
1855 return el[ind.acu(0)];
1856 else
1857 return el[calc_lin_ind(ind)];
1858#endif
1859 }
1860
1861 const T& acp(const DynLinArr<long>& ind) const {
1862 long q;
1863 if ((q = qel.get_qel()) > ind.get_qel()) {
1864 mcerr << "ERROR in DynArr::acp(const DynLinArr<long>& ind): "
1865 << "qel.get_qel()!= ind.get_qel()\n"
1866 << "qel.get_qel()=" << qel.get_qel()
1867 << " ind.get_qel()=" << ind.get_qel() << '\n';
1868 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1869 << '\n';
1870 spexit(mcerr);
1871 }
1872#ifdef ALR_CHECK_EACH_BOUND
1873#ifdef DEBUG_DYNARR
1874 if (q == 1) // faster for this case
1875 return el[ind.acu(0)];
1876 else
1877 return el[calc_lin_ind(ind)];
1878#else
1879 if (q == 1)
1880 return el[ind.acu(0)];
1881 else
1882 return el.acu(calc_lin_ind(ind));
1883#endif
1884#else
1885 if (q == 1)
1886 return el[ind.acu(0)];
1887 else
1888 return el[calc_lin_ind(ind)];
1889#endif
1890 }
1891
1892 T& acu(const DynLinArr<long>& ind) // unchecked
1893 {
1894 if (qel.get_qel() == 1)
1895 return el.acu(ind.acu(0));
1896 else
1897 return el.acu(calc_lin_ind(ind));
1898 }
1899 const T& acu(const DynLinArr<long>& ind) const // unchecked
1900 {
1901 if (qel.get_qel() == 1)
1902 return el.acu(ind.acu(0));
1903 else
1904 return el.acu(calc_lin_ind(ind));
1905 }
1906
1907 T& ac(long i1, long i2) // for 2-dimensional array
1908 {
1909 if (qel.get_qel() == 2) {
1910#ifdef ALR_CHECK_EACH_BOUND
1911 if (i1 >= 0 && i1 < qel.acu(0)) {
1912 if (i2 >= 0 && i2 < qel.acu(1)) {
1913#ifdef DEBUG_DYNARR
1914 return el[i1 * cum_qel.acu(0) + i2];
1915#else
1916 return el.acu(i1 * cum_qel.acu(0) + i2);
1917#endif
1918 } else {
1919 mcerr << "Error in DynArr::ac(long i1, long i2): i2 < 0 || i2 >= "
1920 "qel.acu(1)\n";
1921 Iprint2n(mcout, i2, qel[1]);
1922 }
1923 } else {
1924 mcerr << "Error in DynArr::ac(long i1, long i2): i1 < 0 || i1 >= "
1925 "qel.acu(0)\n";
1926 Iprint2n(mcout, i1, qel[0]);
1927 }
1928 } else {
1929 mcerr << "ERROR in DynArr::ac(long i1, long i2): qel.get_qel()!= 2,"
1930 << " qel.get_qel()=" << qel.get_qel() << '\n';
1931 }
1932 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
1933 << '\n';
1934 spexit(mcerr);
1935 return el[0];
1936#else // for ifdef ALR_CHECK_EACH_BOUND
1937 return el[i1 * cum_qel.acu(0) + i2];
1938
1939#endif
1940 }
1941
1942 /*
1943 {
1944 if(qel.get_qel() != 2)
1945 { mcerr<<"ERROR in DynArr::ac(long i1, long i2): qel.get_qel()!= 2,"
1946 <<" qel.get_qel()=" <<qel.get_qel()<<'\n';
1947 mcerr<<"Type of T is (in internal notations) "<<typeid(T).name()<<'\n';
1948 spexit(mcerr); }
1949#ifdef ALR_CHECK_EACH_BOUND
1950 if(i1 < 0 || i1 >= qel.acu(0))
1951 {
1952 mcerr<<"Error in DynArr::ac(long i1, long i2): i1 < 0 || i1 >=
1953qel.acu(0)\n";
1954 Iprint2n(mcout, i1, qel[0]);
1955 spexit(mcerr);
1956 }
1957 if(i2 < 0 || i2 >= qel.acu(1))
1958 {
1959 mcerr<<"Error in DynArr::ac(long i1, long i2): i2 < 0 || i2 >=
1960qel.acu(1)\n";
1961 Iprint2n(mcout, i2, qel[1]);
1962 spexit(mcerr);
1963 }
1964#ifdef DEBUG_DYNARR
1965 return el[i1*cum_qel.acu(0) + i2];
1966#else
1967 return el.acu(i1*cum_qel.acu(0) + i2);
1968#endif
1969#else
1970 return el[i1*cum_qel.acu(0) + i2];
1971#endif
1972 }
1973 */
1974 const T& ac(long i1, long i2) const // for 2-dimensional array
1975 {
1976 if (qel.get_qel() == 2) {
1977#ifdef ALR_CHECK_EACH_BOUND
1978 if (i1 >= 0 && i1 < qel.acu(0)) {
1979 if (i2 >= 0 && i2 < qel.acu(1)) {
1980#ifdef DEBUG_DYNARR
1981 return el[i1 * cum_qel.acu(0) + i2];
1982#else
1983 return el.acu(i1 * cum_qel.acu(0) + i2);
1984#endif
1985 } else {
1986 mcerr << "Error in DynArr::ac(long i1, long i2): i2 < 0 || i2 >= "
1987 "qel.acu(1)\n";
1988 Iprint2n(mcout, i2, qel[1]);
1989 }
1990 } else {
1991 mcerr << "Error in DynArr::ac(long i1, long i2): i1 < 0 || i1 >= "
1992 "qel.acu(0)\n";
1993 Iprint2n(mcout, i1, qel[0]);
1994 }
1995 } else {
1996 mcerr << "ERROR in DynArr::ac(long i1, long i2): qel.get_qel()!= 2,"
1997 << " qel.get_qel()=" << qel.get_qel() << '\n';
1998 }
1999 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
2000 << '\n';
2001 spexit(mcerr);
2002 return el[0];
2003#else // for ifdef ALR_CHECK_EACH_BOUND
2004 return el[i1 * cum_qel.acu(0) + i2];
2005
2006#endif
2007 }
2008 /*
2009 {
2010 if(qel.get_qel() != 2)
2011 { mcerr<<"ERROR in DynArr::ac(long i1, long i2): qel.get_qel()!= 2,"
2012 <<" qel.get_qel()=" <<qel.get_qel()<<'\n';
2013 mcerr<<"Type of T is (in internal notations) "<<typeid(T).name()<<'\n';
2014 spexit(mcerr); }
2015#ifdef ALR_CHECK_EACH_BOUND
2016 if(i1 < 0 || i1 >= qel.acu(0))
2017 {
2018 mcerr<<"Error in DynArr::ac(long i1, long i2): i1 < 0 || i1 >=
2019qel.acu(0)\n";
2020 Iprint2n(mcout, i1, qel[0]);
2021 spexit(mcerr);
2022 }
2023 if(i2 < 0 || i2 >= qel.acu(1))
2024 {
2025 mcerr<<"Error in DynArr::ac(long i1, long i2): i2 < 0 || i2 >=
2026qel.acu(1)\n";
2027 Iprint2n(mcout, i2, qel[1]);
2028 spexit(mcerr);
2029 }
2030#ifdef DEBUG_DYNARR
2031 return el.acu(i1*cum_qel.acu(0) + i2);
2032#else
2033 return el[i1*cum_qel.acu(0) + i2];
2034#endif
2035#else
2036 return el[i1*cum_qel.acu(0) + i2];
2037#endif
2038 //return el[i1*cum_qel[0] + i2];
2039 }
2040 */
2041 inline T& acu(long i1,
2042 long i2) // for 2-dimensional array, completely unchecked
2043 {
2044 return el.acu(i1 * cum_qel.acu(0) + i2);
2045 }
2046 inline const T& acu(long i1, long i2) const // for 2-dimensional array
2047 {
2048 return el.acu(i1 * cum_qel.acu(0) + i2);
2049 }
2050
2051 T& ac(long i1, long i2, long i3) // for 3-dimensional array
2052 {
2053 if (qel.get_qel() != 3) {
2054 mcerr << "ERROR in DynArr::ac(long i1, long i2, long i3): "
2055 "qel.get_qel()!= 3,"
2056 << " qel.get_qel()=" << qel.get_qel() << '\n';
2057 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
2058 << '\n';
2059 spexit(mcerr);
2060 }
2061#ifdef ALR_CHECK_EACH_BOUND
2062 if (i1 < 0 || i1 >= qel.acu(0)) {
2063 mcerr << "Error in DynArr::ac(long i1, long i2, long i3): i1 < 0 || i1 "
2064 ">= qel.acu(0)\n";
2065 Iprint2n(mcout, i1, qel[0]);
2066 spexit(mcerr);
2067 }
2068 if (i2 < 0 || i2 >= qel.acu(1)) {
2069 mcerr << "Error in DynArr::ac(long i1, long i2, long i3): i2 < 0 || i2 "
2070 ">= qel.acu(1)\n";
2071 Iprint2n(mcout, i2, qel[1]);
2072 spexit(mcerr);
2073 }
2074 if (i3 < 0 || i3 >= qel.acu(2)) {
2075 mcerr << "Error in DynArr::ac(long i1, long i2, long i3): i3 < 0 || i3 "
2076 ">= qel.acu(2)\n";
2077 Iprint2n(mcout, i3, qel[2]);
2078 spexit(mcerr);
2079 }
2080#ifdef DEBUG_DYNARR
2081 return el.acu(i1 * cum_qel.acu(0) + i2 * cum_qel.acu(1) + i3);
2082#else
2083 return el[i1 * cum_qel.acu(0) + i2 * cum_qel[1] + i3];
2084#endif
2085#else
2086 return el[i1 * cum_qel.acu(0) + i2 * cum_qel[1] + i3];
2087#endif
2088 // return el[i1*cum_qel[0] + i2*cum_qel[1] + i3];
2089 }
2090
2091 const T& ac(long i1, long i2, long i3) const // for 3-dimensional array
2092 {
2093 if (qel.get_qel() != 3) {
2094 mcerr << "ERROR in DynArr::ac(long i1, long i2, long i3): "
2095 "qel.get_qel()!= 3,"
2096 << " qel.get_qel()=" << qel.get_qel() << '\n';
2097 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
2098 << '\n';
2099 spexit(mcerr);
2100 }
2101#ifdef ALR_CHECK_EACH_BOUND
2102 if (i1 < 0 || i1 >= qel.acu(0)) {
2103 mcerr << "Error in DynArr::ac(long i1, long i2, long i3): i1 < 0 || i1 "
2104 ">= qel.acu(0)\n";
2105 Iprint2n(mcout, i1, qel[0]);
2106 spexit(mcerr);
2107 }
2108 if (i2 < 0 || i2 >= qel.acu(1)) {
2109 mcerr << "Error in DynArr::ac(long i1, long i2, long i3): i2 < 0 || i2 "
2110 ">= qel.acu(1)\n";
2111 Iprint2n(mcout, i2, qel[1]);
2112 spexit(mcerr);
2113 }
2114 if (i3 < 0 || i3 >= qel.acu(2)) {
2115 mcerr << "Error in DynArr::ac(long i1, long i2, long i3): i3 < 0 || i3 "
2116 ">= qel.acu(2)\n";
2117 Iprint2n(mcout, i3, qel[2]);
2118 spexit(mcerr);
2119 }
2120#ifdef DEBUG_DYNARR
2121 return el.acu(i1 * cum_qel.acu(0) + i2 * cum_qel.acu(1) + i3);
2122#else
2123 return el[i1 * cum_qel.acu(0) + i2 * cum_qel[1] + i3];
2124#endif
2125#else
2126 return el[i1 * cum_qel.acu(0) + i2 * cum_qel[1] + i3];
2127#endif
2128 // return el[i1*cum_qel[0] + i2*cum_qel[1] + i3];
2129 }
2130
2131 long get_qel_lin(void) const { return el.get_qel(); }
2132
2133 // access to array as linear array
2134 inline T& ac_lin(long n) {
2135 long qelln = el.get_qel();
2136#ifdef ALR_CHECK_BOUND
2137 if (n >= 0 && n < qelln) return el[n];
2138 mcerr << "ERROR in T& DynArr::ac_lin(long n): "
2139 << "n is out of bounds, n=" << n << " qelln=" << qelln << '\n';
2140 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
2141 << '\n';
2142 spexit(mcerr);
2143 return el[0];
2144#else
2145 return el[n];
2146#endif
2147 }
2148 inline const T& ac_lin(long n) const {
2149 long qelln = el.get_qel();
2150#ifdef ALR_CHECK_BOUND
2151 if (n >= 0 && n < qelln) return el[n];
2152 mcerr << "ERROR in T& DynArr::ac_lin(long n): "
2153 << "n is out of bounds, n=" << n << " qelln=" << qelln << '\n';
2154 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
2155 << '\n';
2156 spexit(mcerr);
2157 return el[0];
2158#else
2159 return el[n];
2160#endif
2161 }
2162 // access to array as linear array always without check
2163 inline T& acu_lin(long n) { return el[n]; }
2164 inline const T& acu_lin(long n) const { return el[n]; }
2165
2166 void assignAll(const T& val);
2167
2168 long get_qdim(void) const { return qel.get_qel(); }
2169 const DynLinArr<long>& get_qel(void) const { return qel; }
2170 const DynLinArr<T>& get_el(void) const { return el; }
2171
2172 // The following is mainly for debug (diagnostic print):
2173 const DynLinArr<long>& get_cum_qel(void) const { return cum_qel; }
2174
2175 // void put_qel(const DynLinArr<long>& fqel, T* val=NULL);
2176 void put_qel(T* val = NULL);
2177 // 25.10.2006: Today I do not understand these following comments.
2178 // They looks like simple copy from these in DynLinArr.
2179 // creates array with size fqel
2180 // If old array existed, then
2181 // If it was less than fqel, it all is copied to new array
2182 // and the other elements are either remains not inited
2183 // or assignned *val.
2184 // else its fqel part is copyed to new array.
2185
2186 void clear(void) {
2187 qel.clear();
2188 cum_qel.clear();
2189 el.clear();
2190 }
2191
2192 int confirm_ind(const DynLinArr<long>& ind) { return gconfirm_ind(qel, ind); }
2194 return gconfirm_ind_ext(qel, ind);
2195 }
2197
2198 // Apply any function of one argument (of type T) to each element.
2199 template <class P>
2200 friend void apply1(DynArr<P>& ar, void (*fun)(P& f));
2201
2202 // Apply any function of two arguments
2203 // (first of which is of type T and the second is of type of address
2204 // of another function (possibly apply1) to each element.
2205 template <class P, class X>
2206 friend void apply2(DynArr<P>& ar, void (*fun1)(P& f, void (*fun21)(X& f)),
2207 void (*fun2)(X& f));
2208
2209 void check(void) const {
2210 qel.check();
2211 cum_qel.check();
2212 el.check();
2213 }
2214 int get_s_non_emplty(void) const {
2215 long q = qel.get_qel();
2216 if (q == 0) return 0;
2217 long n;
2218 for (n = 0; n < q; n++) {
2219 if (qel[n] <= 0) return 0;
2220 }
2221 return 1;
2222 }
2223 virtual DynArr* copy() const { return new DynArr(*this); }
2224 virtual ~DynArr() {}
2225
2226 private:
2227 mutable DynLinArr<long> qel;
2228 // Linear array with number of elements by each dimension
2229 mutable DynLinArr<long> cum_qel;
2230 // "cumulative qel": each element contains product
2231 // of next elements of qel.
2232 // The last element is always 1.
2233 // Used for fast search of proper element in el.
2234
2235 mutable DynLinArr<T> el;
2236 // Contains all elements.
2237 // The last index varies faster.
2238
2239 long calc_lin_ind(const DynLinArr<long>& ind) const {
2240 long i = 0;
2241 long n;
2242 long qdim1 = qel.get_qel() - 1;
2243 /*
2244 // This check is not necessary by two reasons
2245 // 1. The checks of this condition are made in calling functions.
2246 // 2. The correct condition is not != but >.
2247 if(qdim1 != ind.get_qel() - 1)
2248 {
2249 mcerr<<"ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& ind)
2250const\n";
2251 mcerr<<"qdim1 != ind.get_qel() - 1\n";
2252 Iprint2n(mcerr, qdim1, (ind.get_qel() - 1));
2253 spexit(mcerr);
2254 }
2255 */
2256 for (n = 0; n < qdim1; n++) {
2257#ifdef ALR_CHECK_EACH_BOUND
2258#ifdef DEBUG_DYNARR
2259 if (ind[n] < 0 || ind[n] >= qel[n]) {
2260 mcerr << "ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& "
2261 "ind) const\n";
2262 mcerr << "ind[n] < 0 || ind[n] >= qel[n]\n";
2263 Iprint3n(mcout, n, ind[n], qel[n]);
2264 Iprintn(mcout, qel);
2265 spexit(mcerr);
2266 }
2267#else
2268 if (ind.acu(n) < 0 || ind.acu(n) >= qel.acu(n)) {
2269 mcerr << "ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& "
2270 "ind) const\n";
2271 mcerr << "ind.acu(n) < 0 || ind.acu(n) >= qel.acu(n)\n";
2272 Iprint3n(mcout, n, ind[n], qel[n]);
2273 Iprintn(mcout, qel);
2274 spexit(mcerr);
2275 }
2276#endif
2277#endif
2278 i += ind[n] * cum_qel[n];
2279 }
2280#ifdef ALR_CHECK_EACH_BOUND
2281#ifdef DEBUG_DYNARR
2282 if (ind[qdim1] < 0 || ind[qdim1] >= qel[qdim1]) {
2283 mcerr << "ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& ind) "
2284 "const\n";
2285 mcerr << "ind[qdim1] < 0 || ind[qdim1] >= qel[qdim1]\n";
2286 Iprint3n(mcout, n, ind[qdim1], qel[qdim1]);
2287 Iprintn(mcout, qel);
2288 spexit(mcerr);
2289 }
2290#else
2291 if (ind.acu(qdim1) < 0 || ind.acu(qdim1) >= qel.acu(qdim1)) {
2292 mcerr << "ERROR in long DynArr::calc_lin_ind(const DynLinArr<long>& ind) "
2293 "const\n";
2294 mcerr << "ind.acu(qdim1) < 0 || ind.acu(qdim1) >= qel.acu(qdim1)\n";
2295 Iprint3n(mcout, n, ind[qdim1], qel[qdim1]);
2296 Iprintn(mcout, qel);
2297 spexit(mcerr);
2298 }
2299#endif
2300#endif
2301 i += ind[qdim1]; // the last index, for which multiplication by cum_qel
2302 // is not necessary.
2303 return i;
2304 }
2305};
2306
2307template <class T>
2309#ifdef DEBUG_DYNARR
2310 mcout << "DynArr<T>& DynArr<T>::operator=(const DynArr<T>& f)\n";
2311#endif
2312 if (this != &f) {
2313 // mcout<<"DynLinArr<T>& operator=(const DynLinArr<T>& f): long(el)="
2314 //<<long(el)<<'\n';
2315 check();
2316 f.check();
2317 qel = f.qel;
2318 cum_qel = f.cum_qel;
2319 el = f.el;
2320 }
2321 return *this;
2322}
2323
2324template <class T>
2325template <class D>
2327#ifdef DEBUG_DYNLINARR
2328 mcout << "DynArr<T>& DynArr<T>::operator=(const DynArr<D>& f)\n";
2329#endif
2330 check();
2331 f.check();
2332 DynLinArr<long> fqel = f.get_qel();
2333 DynLinArr<long> fcum_qel = f.get_cum_qel();
2334 // for example, one of its elements.
2335 const long q = f.get_qel_lin();
2336 T* temp_el = (q > 0) ? (new T[q]) : (T*)NULL;
2337 for (long n = 0; n < q; n++) temp_el[n] = f.acu_lin(n);
2338 pass(q, fqel, fcum_qel, temp_el);
2339 return *this;
2340}
2341
2342template <class T>
2343void apply1(DynArr<T>& ar, void (*fun)(T& f)) {
2344 const long q = ar.el.get_qel();
2345 for (long n = 0; n < q; n++) (*fun)(ar.el[n]);
2346}
2347template <class T, class X>
2348void apply2(DynArr<T>& ar, void (*fun1)(T& f, void (*fun21)(X& f)),
2349 void (*fun2)(X& f)) {
2350 const long q = ar.el.get_qel();
2351 for (long n = 0; n < q; n++) (*fun1)(ar.el[n], fun2);
2352}
2353
2354int find_next_comb(const DynLinArr<long>& qel, DynLinArr<long>& f);
2355int find_prev_comb(const DynLinArr<long>& qel, DynLinArr<long>& f);
2356int find_next_comb_not_less(const DynLinArr<long>& qel, DynLinArr<long>& f);
2357
2358template <class T>
2360 public:
2362 : ncur(fdar->get_qdim()), dar((DynArr<T>*)fdar) {
2363 long n;
2364 long qdim1 = ncur.get_qel() - 1;
2365 if (qdim1 >= 0) {
2366 for (n = 0; n < qdim1; n++) ncur[n] = 0;
2367 ncur[qdim1] = -1;
2368 }
2369 }
2370 T* more(void) // Just next element. Why not "next", do not remember.
2371 {
2372 if (find_next_comb(dar->get_qel(), ncur))
2373 return &(dar->ac(ncur));
2374 else
2375 return NULL;
2376 }
2377
2378 T* current(void) // Element currently pointed by ncut.
2379 {
2380 long n;
2381 long qdim = ncur.get_qel();
2382 if (qdim <= 0) return NULL;
2383 for (n = 0; n < qdim; n++) {
2384 if (ncur[n] < 0 || ncur[n] >= dar->get_qel()[n]) return NULL;
2385 }
2386 return &(dar->ac(ncur));
2387 }
2388
2389 T* less(void) // Switch current to previous.
2390 // Again do not remember why not" prev"
2391 {
2392 if (find_prev_comb(dar->get_qel(), ncur))
2393 return &(dar->ac(ncur));
2394 else
2395 return NULL;
2396 }
2397
2398 const DynLinArr<long>& get_ncur(void) const { return ncur; }
2399
2400 private:
2401 DynLinArr<long> ncur;
2402 DynArr<T>* dar;
2403};
2404
2405extern DynLinArr<long> qel_communicat;
2406
2407template <class T>
2409 // by default val=NULL
2410{
2411 check();
2412 if (qel.get_qel() == 0) {
2413 *this = DynArr<T>(qel_communicat, val);
2414 return;
2415 }
2416
2417 DynArr<T> datemp(qel_communicat, val); // all init to val
2418 IterDynArr<T> iter(&datemp);
2419 T* at;
2420 while ((at = iter.more()) != NULL) {
2421 if (confirm_ind_ext(iter.get_ncur()))
2422 *at = acp(iter.get_ncur()); // change to old values where they were
2423 }
2424 *this = datemp;
2425}
2426
2427template <class T>
2428int operator==(const DynLinArr<T>& f1, const DynLinArr<T>& f2) {
2429 if (f1.get_qel() != f2.get_qel()) return 0;
2430 long q = f1.get_qel();
2431 long n;
2432 for (n = 0; n < q; n++) {
2433 if (!(f1.acu(n) == f2.acu(n))) return 0;
2434 }
2435 return 1;
2436}
2437
2438template <class T, class P>
2439int apeq_mant(const DynLinArr<T>& f1, const DynLinArr<T>& f2, P prec) {
2440 if (f1.get_qel() != f2.get_qel()) return 0;
2441 long q = f1.get_qel();
2442 long n;
2443 for (n = 0; n < q; n++) {
2444 if (!apeq_mant(f1.acu(n), f2.acu(n), prec)) return 0;
2445 }
2446 return 1;
2447}
2448
2449template <class T>
2450int operator!=(const DynLinArr<T>& f1, const DynLinArr<T>& f2) {
2451 if (f1 == f2)
2452 return 0;
2453 else
2454 return 1;
2455}
2456
2457template <class T>
2458int operator==(const DynArr<T>& f1, const DynArr<T>& f2) {
2459 if (f1.get_qel() != f2.get_qel()) return 0;
2460 if (f1.get_el() != f2.get_el()) return 0;
2461 return 1;
2462}
2463
2464template <class T, class P>
2465int apeq_mant(const DynArr<T>& f1, const DynArr<T>& f2, P prec) {
2466 if (f1.get_qel() != f2.get_qel()) return 0;
2467 if (!apeq_mant(f1.get_el(), f2.get_el(), prec)) return 0;
2468 return 1;
2469}
2470
2471template <class T>
2472int operator!=(const DynArr<T>& f1, const DynArr<T>& f2) {
2473 if (f1.get_qel() == f2.get_qel()) return 0;
2474 if (f1.get_el() == f2.get_el()) return 0;
2475 return 1;
2476}
2477
2478template <class T>
2479void DynArr<T>::assignAll(const T& val) {
2480 check();
2481 // try faster and simpler way (30.10.2006):
2482 el.assignAll(val);
2483 /*
2484 IterDynArr<T> iter(this);
2485 T* at;
2486 while( (at=iter.more()) != NULL )
2487 {
2488 *at=val;
2489 }
2490 */
2491}
2492
2493template <class T, class X>
2494void copy_DynArr(const DynArr<T>& s, DynArr<X>& d) {
2495 mfunnamep(
2496 "template<class T, class X> void copy_DynArr(const DynArr<T>& s, "
2497 "DynArr<X>& d)");
2498 s.check();
2499 d.check();
2500 d = DynArr<X>(s.get_qel(), NULL);
2501 IterDynArr<T> iter(&s);
2502 T* at;
2503 while ((at = iter.more()) != NULL) {
2504 const DynLinArr<long>& ncur = iter.get_ncur();
2505 d.ac(ncur) = *at;
2506 }
2507}
2508
2509// Convert types of elements from T to X.
2510template <class T, class X>
2512 mfunnamep(
2513 "template<class T, class X> void convert_DynArr(const DynArr<T>& "
2514 "s, DynArr<X>& d)");
2515 s.check();
2516 d.check();
2517 d = DynArr<X>(s.get_qel(), NULL);
2518 IterDynArr<T> iter(&s);
2519 T* at;
2520 while ((at = iter.more()) != NULL) {
2521 const DynLinArr<long>& ncur = iter.get_ncur();
2522 d.ac(ncur) = X(*at);
2523 }
2524}
2525
2526template <class T>
2528 check();
2529 DynArr<T> r(1, qel);
2530 long n;
2531 for (n = 0; n < qel; n++) {
2532 r.ac(0, n) = el[n];
2533 }
2534 return r;
2535}
2536template <class T>
2538 mfunnamep("template<class T> DynArr<T> DynArr<T>::top(void)");
2539 check();
2540 long qdim = get_qdim();
2541 check_econd11(qdim, != 2, mcerr);
2542 long n1, n2;
2543 DynArr<T> r(qel[1], qel[0]);
2544 for (n1 = 0; n1 < qel[0]; n1++) {
2545 for (n2 = 0; n2 < qel[1]; n2++) {
2546 r.ac(n2, n1) = ac(n1, n2);
2547 }
2548 }
2549 return r;
2550}
2551
2552template <class T>
2554 // mcout<<"template<class T> DynLinArr<T>::DynLinArr(const DynArr<T>& f):\n";
2555 f.check();
2556 long qdim = f.get_qdim();
2557 if (qdim != 1) {
2558 mcerr << "ERROR in DynLinArr<T>::DynLinArr(const DynArr<T>& f):\n"
2559 << "f.get_qdim() != 1, f.get_qdim()=" << f.get_qdim() << '\n';
2560 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
2561 << '\n';
2562 spexit(mcerr);
2563 }
2564 const DynLinArr<long>& qelem = f.get_qel();
2565 qel = qelem[0];
2566 // mcout<<"qel="<<qel<<'\n';
2567 if (qel > 0) {
2568 el = new T[qel];
2569 for (long n = 0; n < qel; n++) el[n] = f.ac(n);
2570 } else
2571 el = NULL;
2572}
2573
2574template <class T>
2575DynLinArr<T>::DynLinArr(const DynArr<T>& f, int n_of_dim,
2576 // 0 - first dim) 1 - second dim)
2577 long roc_number)
2578 // takes only mentioned raw or column.
2579{
2580 f.check();
2581 long qdim = f.get_qdim();
2582 if (qdim != 2) {
2583 mcerr << "ERROR in DynLinArr<T>::DynLinArr(const DynArr<T>& f, int "
2584 "n_of_dim,long roc_number):\n"
2585 << "f.get_qdim() != 2, f.get_qdim()=" << f.get_qdim() << '\n';
2586 mcerr << "Type of T is (in internal notations) " << typeid(T).name()
2587 << '\n';
2588 spexit(mcerr);
2589 }
2590 const DynLinArr<long>& qelem = f.get_qel();
2591 if (n_of_dim == 0) {
2592 qel = qelem[1];
2593 } else {
2594 qel = qelem[0];
2595 }
2596 // mcout<<"qel="<<qel<<'\n';
2597 if (qel > 0) {
2598 el = new T[qel];
2599 long n;
2600 if (n_of_dim == 0) {
2601 for (n = 0; n < qel; n++) el[n] = f.ac(roc_number, n);
2602 } else {
2603 for (n = 0; n < qel; n++) el[n] = f.ac(n, roc_number);
2604 }
2605 }
2606}
2607
2608template <class T>
2609std::ostream& operator<<(std::ostream& file, const DynArr<T>& f) {
2610 // mfunnamep("template<class T> std::ostream& operator<<(std::ostream& file,
2611 // const DynArr<T>& f)");
2612 f.check();
2613 Ifile << "DynArr<T>: qdim=" << f.get_qdim() << '\n';
2614 indn.n += 2;
2615 if (s_short_output > 0) {
2616 Ifile << noindent << f.get_qel() << yesindent;
2617 } else {
2618 Ifile << "qel=" << noindent << f.get_qel() << yesindent;
2619 Ifile << "cum_qel=" << noindent << f.get_cum_qel() << yesindent;
2620 }
2621 if (f.get_s_non_emplty() == 1) {
2622 if (s_short_output == 0) {
2623 Ifile << "Content element by element:\n";
2624 Ifile << "(The first number is sequencial number, then there are "
2625 "indexes, the last is the element)\n";
2626 // DynArr<T>& ff(f);
2627 }
2628 long nseq = 0;
2629 IterDynArr<T> iter_f(&((DynArr<T>&)f));
2630 T* at;
2631 while ((at = iter_f.more()) != NULL) {
2632 std::ostringstream ost;
2633 if (s_short_output == 0) {
2634 // Ifile<<"ncur="<<noindent<<iter_f.get_ncur()<<yesindent;
2635 Ifile << "nseq=" << std::setw(5) << nseq << " ncur=";
2636 long n;
2637 for (n = 0; n < iter_f.get_ncur().get_qel(); n++) {
2638 file << ' ' << std::setw(5) << iter_f.get_ncur()[n];
2639 }
2640 ost << indn << " element=" << noindent << (*at) << yesindent;
2641 } else {
2642 ost << indn << noindent << (*at) << yesindent;
2643 }
2644 put_one_n(ost);
2645 file << ost.str();
2646 nseq++;
2647 }
2648 file << yesindent;
2649 } else {
2650 if (s_short_output == 0) {
2651 Ifile << "Content is empty.\n";
2652 }
2653 }
2654 indn.n -= 2;
2655 return file;
2656}
2657/*
2658template<class T>
2659void DybArr<T>::short_output(std::ostream& file)
2660{
2661 mfunnamep("template<class T> void DybArr<T>::short_output(std::ostream&
2662file))");
2663 f.check();
2664 Ifile<<"DynArr<T>: qdim="<<f.get_qdim()<<'\n';
2665 indn.n+=2;
2666 qel.short_output(file);
2667 if(f.get_s_non_emplty() == 1)
2668 {
2669 long nseq=0;
2670 IterDynArr<T> iter_f( &((DynArr<T>&) f));
2671 T* at;
2672 while( (at=iter_f.more()) != NULL )
2673 {
2674 std::ostringstream ost;
2675 ost<<indn<<noindent<<(*at)<<yesindent;
2676 put_one_n(ost);
2677 file<<ost.str();
2678 nseq++;
2679 }
2680 file<<yesindent;
2681 }
2682 indn.n-=2;
2683 return file;
2684}
2685*/
2686template <class T>
2687std::istream& operator>>(std::istream& file, DynArr<T>& f) {
2688 mfunnamep(
2689 "template<class T> istream& operator>>(istream& file, DynArr<T>& f)");
2690 definp_endpar dep(&file, 0, 1, 0, s_short_output);
2691 long qdim = 0;
2692 dep.s_short = 0;
2693 DEFINPAP(qdim);
2694 dep.s_short = s_short_output;
2695 check_econd11(qdim, < 0, mcerr);
2696 if (s_short_output == 0) {
2697 set_position("qel=DynLinArr<T>:", *dep.istrm, dep.s_rewind, dep.s_req_sep);
2698 } else {
2699 set_position("DynLinArr<T>:", *dep.istrm, dep.s_rewind, dep.s_req_sep);
2700 }
2701 DynLinArr<long> qel_loc;
2702 // mcout<<"now will read qel_loc\n";
2703 file >> qel_loc;
2704 // mcout<<"qel_loc is read\n";
2705 if (s_short_output == 0) {
2706 set_position("cum_qel=DynLinArr<T>:", *dep.istrm, dep.s_rewind,
2707 dep.s_req_sep);
2708 DynLinArr<long> cum_qel_loc;
2709 file >> cum_qel_loc; // this is in general unnecessary
2710 }
2711 if (qel_loc.get_qel() > 0) {
2712 f.pilfer(DynArr<T>(qel_loc, NULL));
2713 long nseq;
2714 long n;
2715 long qseq = qel_loc[0];
2716 for (n = 1; n < qel_loc.get_qel(); n++) {
2717 qseq *= qel_loc[n];
2718 }
2719 for (n = 0; n < qseq; n++) {
2720 if (s_short_output == 0) {
2721 DEFINPAP(nseq);
2722 check_econd12(nseq, !=, n, mcerr);
2723 DynLinArr<long> ncur(qel_loc.get_qel());
2724 set_position("ncur=", *dep.istrm, dep.s_rewind, dep.s_req_sep);
2725 long m;
2726 for (m = 0; m < qel_loc.get_qel(); m++) {
2727 file >> ncur[m];
2728 }
2729 // T element;
2730 // DEFINPAP(element);
2731 // f.ac(ncur) = element;
2732 set_position("element=", *dep.istrm, dep.s_rewind, dep.s_req_sep);
2733 }
2734 file >> f.ac_lin(n);
2735 }
2736 } else {
2737 if (s_short_output == 0) {
2738 // just pass to end
2739 set_position("Content is empty.", *dep.istrm, dep.s_rewind,
2740 dep.s_req_sep);
2741 }
2742 f.pilfer(DynArr<T>());
2743 }
2744 return file;
2745}
2746
2747/*
2748template<class T>
2749void DynArr<T>::short_read(istream& file)
2750{
2751 mfunnamep("template<class T> void DynArr<T>::short_read(istream& file)");
2752 definp_endpar dep(&file, 0, 1, 0);
2753 long qdim=0;
2754 DEFINPAP(qdim);
2755 check_econd11(qdim, < 0 , mcerr);
2756 DynLinArr<long> qel_loc;
2757 qel_loc.short_read(file);
2758 // generate cum
2759 if(qel_loc.get_qel() > 0 )
2760 {
2761 f.pilfer(DynArr<T>(qel_loc, NULL));
2762 long nseq;
2763 long n;
2764 long qseq=qel[0];
2765 for(n=1; n<el.get_qel(); n++)
2766 {
2767 qseq*=el[n];
2768 }
2769 for(n=0; n<qseq; n++)
2770 {
2771 file>>f.ac(ncur);
2772 }
2773 }
2774 else
2775 {
2776 // just pass to end
2777 set_position("Content is empty.",
2778 *dep.istrm, dep.s_rewind, dep.s_req_sep);
2779 }
2780 return file;
2781}
2782*/
2783
2784template <class T>
2785void print_DynArr(std::ostream& file, const DynArr<T>& f, int l) {
2786 // mfunnamep("template<class T> oid print_DynArr(std::ostream& file, const
2787 // DynArr<T>& f, int l)");
2788 f.check();
2789 // Ifile<<"DynArr<T>: qdim="<<f.get_qdim()
2790 // <<" qel="<<noindent<<f.get_qel()<<yesindent<<'\n';
2791 Ifile << "DynArr<T>: qdim=" << f.get_qdim() << '\n';
2792 indn.n += 2;
2793 Ifile << "qel=" << noindent << f.get_qel() << yesindent;
2794 Ifile << "cum_qel=" << noindent << f.get_cum_qel() << yesindent;
2795 Ifile << "Content element by element:\n";
2796 Ifile << "(The first number is sequencial number, then there are indexes, "
2797 "the last is the element)\n";
2798 // DynArr<T>& ff(f);
2799 long nseq = 0;
2800 IterDynArr<T> iter_f(&((DynArr<T>&)f));
2801 T* at;
2802 while ((at = iter_f.more()) != NULL) {
2803 // Ifile<<"ncur="<<noindent<<iter_f.get_ncur()<<yesindent;
2804 Ifile << "nseq=" << std::setw(5) << nseq << " ncur=";
2805 long n;
2806 for (n = 0; n < iter_f.get_ncur().get_qel(); n++) {
2807 file << ' ' << std::setw(5) << iter_f.get_ncur()[n];
2808 }
2809 // file<<'\n';
2810 // Ifile<<"element="<<noindent; at->print(file, l);
2811 // file<<yesindent<<'\n';
2812 std::ostringstream ost;
2813 ost << indn << " element=" << noindent;
2814 at->print(ost, l);
2815 ost << yesindent;
2816 put_one_n(ost);
2817 file << ost.str();
2818 }
2819 file << yesindent;
2820 indn.n -= 2;
2821}
2822
2823// New experimental approach.
2824// give the width of field, which is put in setw().
2825// Whether the array will be printed in single lines
2826// or by columns, is determined by whether 80 symbols are enough
2827void print_DynArr_int_w(std::ostream& file, const DynArr<int>& f, int w);
2828
2829void print_DynArr_float(std::ostream& file, const DynArr<float>& f);
2830void print_DynArr_double(std::ostream& file, const DynArr<double>& f);
2831// ^Identical functions
2832// See AbsArrD for similar function with DoubleAc
2833
2834#define Iprintda_double(file, name) \
2835 file << indn << #name << "=" << noindent; \
2836 print_DynArr_double(file, name);
2837// See AbsArrD for similar function with DoubleAc
2838
2839}
2840
2841#endif
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define mfunnamep(string)
Definition: FunNameStack.h:49
#define spexit(stream)
Definition: FunNameStack.h:256
#define check_econd12(a, sign, b, stream)
Definition: FunNameStack.h:163
IndexingProvider(DynArr< D > &farr, long fq_deref_ind, long fcurrent_pos)
Definition: AbsArr.h:1571
IndexingProvider< D > & operator[](long n)
Definition: AbsArr.h:1605
const IndexingProvider< D > & operator[](long n) const
Definition: AbsArr.h:1633
D & operator=(const D &f)
Definition: AbsArr.h:1588
const T & ac(long i1, long i2, long i3) const
Definition: AbsArr.h:2091
int confirm_ind(const DynLinArr< long > &ind)
Definition: AbsArr.h:2192
DynArr(long fqel1, long fqel2, long fqel3, T *val=NULL)
Definition: AbsArr.h:1445
const DynLinArr< T > & get_el(void) const
Definition: AbsArr.h:2170
void clear(void)
Definition: AbsArr.h:2186
const T & acp(const DynLinArr< long > &ind) const
Definition: AbsArr.h:1861
DynArr(const DynArr< T > &f)
Definition: AbsArr.h:1509
DynArr(const DynLinArr< long > &fqel, T *val)
Definition: AbsArr.h:1493
DynArr(long fqel, T val, ArgInterp_Val)
Definition: AbsArr.h:1386
T & ac(long i1, long i2)
Definition: AbsArr.h:1907
T & acu(long i1, long i2)
Definition: AbsArr.h:2041
const T & ac(const DynLinArr< long > &ind) const
Definition: AbsArr.h:1781
DynArr(long fqel, const T *ar, ArgInterp_Arr)
Definition: AbsArr.h:1397
T & acu(long i1)
Definition: AbsArr.h:1737
int confirm_ind_ext(const DynLinArr< long > &ind)
Definition: AbsArr.h:2193
IndexingProvider< T > operator[](long n)
Definition: AbsArr.h:1666
virtual DynArr * copy() const
Definition: AbsArr.h:2223
const DynLinArr< long > & get_cum_qel(void) const
Definition: AbsArr.h:2173
void check(void) const
Definition: AbsArr.h:2209
const T & ac(long i) const
Definition: AbsArr.h:1727
T & ac(long i)
Definition: AbsArr.h:1717
DynArr(const DynArr< T > &f, Pilfer)
Definition: AbsArr.h:1515
DynArr(long fqel1, long fqel2, long fqel3, long fqel4, T *val=NULL)
Definition: AbsArr.h:1459
const T & acu(long i1) const
Definition: AbsArr.h:1741
void pilfer(const DynArr< T > &f)
Definition: AbsArr.h:1522
DynArr< T > & operator=(const DynArr< T > &f)
Definition: AbsArr.h:2308
DynArr(long fqel1, long fqel2, T val, ArgInterp_Val)
Definition: AbsArr.h:1429
long get_qel_lin(void) const
Definition: AbsArr.h:2131
T & ac_lin(long n)
Definition: AbsArr.h:2134
const IndexingProvider< T > operator[](long n) const
Definition: AbsArr.h:1690
void assignAll(const T &val)
Definition: AbsArr.h:2479
const T & acu(const DynLinArr< long > &ind) const
Definition: AbsArr.h:1899
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)
Definition: AbsArr.h:2326
const T & acu(long i1, long i2) const
Definition: AbsArr.h:2046
DynArr(void)
Definition: AbsArr.h:1373
const T & ac(long i1, long i2) const
Definition: AbsArr.h:1974
const DynLinArr< long > & get_qel(void) const
Definition: AbsArr.h:2169
friend void apply1(DynArr< P > &ar, void(*fun)(P &f))
DynArr(long fqel, T *val=NULL)
Definition: AbsArr.h:1375
DynArr(long fqel1, long fqel2, T *val=NULL)
Definition: AbsArr.h:1415
DynArr(const DynLinArr< long > &fqel, T val, ArgInterp_Val)
Definition: AbsArr.h:1479
DynArr< T > top(void)
Definition: AbsArr.h:2537
void put_qel(T *val=NULL)
Definition: AbsArr.h:2408
T & acu_lin(long n)
Definition: AbsArr.h:2163
T & ac(long i1, long i2, long i3)
Definition: AbsArr.h:2051
int get_s_non_emplty(void) const
Definition: AbsArr.h:2214
long get_qdim(void) const
Definition: AbsArr.h:2168
virtual ~DynArr()
Definition: AbsArr.h:2224
T & ac(const DynLinArr< long > &ind)
Definition: AbsArr.h:1747
void pass(long q, DynLinArr< long > fqel, DynLinArr< long > fcum_qel, T *fel)
Definition: AbsArr.h:1553
DynArr(const DynLinArr< T > &f)
Definition: AbsArr.h:1407
const T & acu_lin(long n) const
Definition: AbsArr.h:2164
T & acu(const DynLinArr< long > &ind)
Definition: AbsArr.h:1892
const T & ac_lin(long n) const
Definition: AbsArr.h:2148
T & acp(const DynLinArr< long > &ind)
Definition: AbsArr.h:1826
const T & last_el(void) const
Definition: AbsArr.h:269
DynLinArr(const DynLinArr< T > &f, Pilfer)
Definition: AbsArr.h:192
virtual DynLinArr * copy() const
Definition: AbsArr.h:417
void clear(void)
Definition: AbsArr.h:313
void sort_select_decreasing(DynLinArr< long > &sort_ind, long q_to_sort=0) const
Definition: AbsArr.h:809
DynLinArr(long fqel, const T *ar, ArgInterp_Arr)
Definition: AbsArr.h:146
long get_qel(void) const
Definition: AbsArr.h:283
void put_qel(long fqel)
Definition: AbsArr.h:530
DynLinArr< T > & operator=(const DynLinArr< D > &f)
Definition: AbsArr.h:494
T & acu(long n)
Definition: AbsArr.h:247
void sort(DynLinArr< long > &sort_ind, long q_to_sort=0) const
Definition: AbsArr.h:689
const T & acu(long n) const
Definition: AbsArr.h:251
void put_qel(long fqel, const T *val, ArgInterp_SingleAdr t)
Definition: AbsArr.h:572
DynLinArr(long fqel, const T &val)
Definition: AbsArr.h:126
void pilfer(const DynLinArr< T > &f)
Definition: AbsArr.h:315
friend void apply1(DynLinArr< P > &ar, void(*fun)(P &f))
void pass(long fqel, T *fel)
Definition: AbsArr.h:183
DynLinArr(const DynArr< T > &f)
Definition: AbsArr.h:2553
void increment(const T &val)
Definition: AbsArr.h:308
void sort(long q_to_sort=0)
Definition: AbsArr.h:628
void check(void) const
Definition: AbsArr.h:433
void increment(const T *val=NULL)
Definition: AbsArr.h:303
DynLinArr(const DynArr< T > &f, int n_of_dim, long roc_number)
Definition: AbsArr.h:2575
T & operator[](long n)
Definition: AbsArr.h:221
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)
Definition: AbsArr.h:300
DynLinArr & assignAll(const T &f)
Definition: AbsArr.h:207
DynLinArr< T > & operator=(const DynLinArr< T > &f)
Definition: AbsArr.h:468
void sort_select_increasing(DynLinArr< long > &sort_ind, long q_to_sort=0) const
Definition: AbsArr.h:745
const T & operator[](long n) const
Definition: AbsArr.h:234
T & last_el(void)
Definition: AbsArr.h:255
virtual ~DynLinArr()
Definition: AbsArr.h:406
DynLinArr(long fqel)
Definition: AbsArr.h:106
DynLinArr< T > & assignAll1(const X &f)
Definition: AbsArr.h:213
DynLinArr(const DynLinArr< T > &f)
Definition: AbsArr.h:519
DynArr< T > top(void)
Definition: AbsArr.h:2527
DynLinArr(void)
Definition: AbsArr.h:105
IterDynArr(const DynArr< T > *fdar)
Definition: AbsArr.h:2361
T * current(void)
Definition: AbsArr.h:2378
const DynLinArr< long > & get_ncur(void) const
Definition: AbsArr.h:2398
T * less(void)
Definition: AbsArr.h:2389
T * more(void)
Definition: AbsArr.h:2370
IterDynLinArr(DynLinArr< T > *fdar)
Definition: AbsArr.h:1262
T * less(void)
Definition: AbsArr.h:1276
T * current(void)
Definition: AbsArr.h:1270
T * more(void)
Definition: AbsArr.h:1263
long get_ncur(void)
Definition: AbsArr.h:1284
virtual void print(std::ostream &file, int l=1) const
Definition: AbsPtr.cpp:152
std::istream * istrm
Definition: definp.h:34
#define DEFINPAP(name)
Definition: definp.h:78
Definition: BGMesh.cpp:6
void print_DynArr_double(std::ostream &file, const DynArr< double > &f)
Definition: AbsArr.cpp:315
void print_DynLinArr(std::ostream &file, const DynLinArr< T > &f, int l)
Definition: AbsArr.h:1101
DynLinArr< T > merge(const DynLinArr< T > &fd1, long qfd1, const DynLinArr< T > &fd2, long qfd2)
Definition: AbsArr.h:1349
int s_short_output
Definition: prstream.cpp:25
void print_DynArr(std::ostream &file, const DynArr< T > &f, int l)
Definition: AbsArr.h:2785
std::istream & operator>>(std::istream &file, EqualStepCoorMesh< T > &f)
Definition: tline.h:230
std::ostream & noindent(std::ostream &f)
Definition: prstream.cpp:17
long max_qel_DynLinArr
Definition: AbsArr.cpp:17
void apply2(DynLinArr< T > &ar, void(*fun1)(T &f, void(*fun21)(X &f)), void(*fun2)(X &f))
Definition: AbsArr.h:427
void print_DynArr_float(std::ostream &file, const DynArr< float > &f)
Definition: AbsArr.cpp:367
void print_DynLinArr_int_double3(std::ostream &file, const DynLinArr< int > &iar, const DynLinArr< double > &dar1, const DynLinArr< double > &dar2, const DynLinArr< double > &dar3)
Definition: AbsArr.cpp:174
int operator!=(manip_absvol_treeid &tid1, manip_absvol_treeid &tid2)
Definition: volume.h:61
std::ostream & operator<<(std::ostream &file, const BGMesh &bgm)
Definition: BGMesh.cpp:37
Pilfer
Definition: AbsPtr.h:184
@ steal
Definition: AbsPtr.h:185
int ifequal(const DynLinArr< T > &fd1, const DynLinArr< T > &fd2, long qfirst=-1)
Definition: AbsArr.h:1309
const int pq_arrelem_in_line
Definition: AbsArr.h:1180
void print_DynLinArr_long(std::ostream &file, const DynLinArr< long > &f)
Definition: AbsArr.cpp:37
void print_DynLinArr_int_double(std::ostream &file, const DynLinArr< int > &iar, const DynLinArr< double > &dar)
Definition: AbsArr.cpp:141
int find_prev_comb(const DynLinArr< long > &qel, DynLinArr< long > &f)
Definition: AbsArr.cpp:501
void print_DynLinArr_double2(std::ostream &file, const DynLinArr< double > &f1, const DynLinArr< double > &f2)
Definition: AbsArr.cpp:97
int gconfirm_ind_ext(const DynLinArr< long > &qel, const DynLinArr< long > &ind)
Definition: AbsArr.cpp:433
void put_one_n(std::ostringstream &ost)
Definition: String.h:73
void print_DynLinArr_float(std::ostream &file, const DynLinArr< float > &f)
Definition: AbsArr.cpp:57
int operator==(const circumf &f1, const circumf &f2)
Definition: circumf.cpp:34
void apply1(DynLinArr< T > &ar, void(*fun)(T &f))
Definition: AbsArr.h:422
void copy_DynLinArr(const T &s, X &d)
Definition: AbsArr.h:1218
long append(const T &t, DynLinArr< T > &dla, long &qael, T *tempt=NULL, long new_qel=0)
Definition: AbsArr.h:954
long set_position(const std::string &word, std::istream &istrm, int s_rewind, int s_req_sep)
Definition: definp.cpp:23
int gconfirm_ind(const DynLinArr< long > &qel, const DynLinArr< long > &ind)
Definition: AbsArr.cpp:418
void print_DynLinArr_double(std::ostream &file, const DynLinArr< double > &f)
Definition: AbsArr.cpp:77
void print_DynArr_int_w(std::ostream &file, const DynArr< int > &f, int w)
Definition: AbsArr.cpp:225
void convert_DynLinArr(const T &s, X &d)
Definition: AbsArr.h:1232
void print_adr_DynLinArr(std::ostream &file, const DynLinArr< T > &f, int l, long q)
Definition: AbsArr.h:1151
int find_next_comb(const DynLinArr< long > &qel, DynLinArr< long > &f)
Definition: AbsArr.cpp:450
int find_next_comb_not_less(const DynLinArr< long > &qel, DynLinArr< long > &f)
Definition: AbsArr.cpp:483
void definp_any_par(T &inp, const std::string &word, const definp_endpar &dep, int fs_short=0)
Definition: definp.h:55
void assignAll_1(DynLinArr< T > &f, const T1 &ft)
Definition: AbsArr.h:1251
void convert_DynArr(const DynArr< T > &s, DynArr< X > &d)
Definition: AbsArr.h:2511
int apeq_mant(const T &x1, const T &x2, T prec)
Definition: minmax.h:55
indentation indn
Definition: prstream.cpp:15
void copy_DynArr(const DynArr< T > &s, DynArr< X > &d)
Definition: AbsArr.h:2494
void print_DynLinArr_int(std::ostream &file, const DynLinArr< int > &f)
Definition: AbsArr.cpp:19
std::ostream & yesindent(std::ostream &f)
Definition: prstream.cpp:21
DynLinArr< long > qel_communicat
Definition: AbsArr.cpp:519
void put_qel_1(DynLinArr< T > &f, long fq)
Definition: AbsArr.h:1242
#define mcout
Definition: prstream.h:126
#define Iprint3n(file, name1, name2, name3)
Definition: prstream.h:233
#define Ifile
Definition: prstream.h:196
#define mcerr
Definition: prstream.h:128
#define Iprintn(file, name)
Definition: prstream.h:205
#define Iprint2n(file, name1, name2)
Definition: prstream.h:220