GiNaC 1.8.10
utils_multi_iterator.h
Go to the documentation of this file.
1
5/*
6 * GiNaC Copyright (C) 1999-2026 Johannes Gutenberg University Mainz, Germany
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef GINAC_UTILS_MULTI_ITERATOR_H
23#define GINAC_UTILS_MULTI_ITERATOR_H
24
25#include <cstddef>
26#include <vector>
27#include <ostream>
28#include <iterator>
29
30namespace GiNaC {
31
37template <typename T> class has_distance {
38private:
39 typedef char yes_type[1];
40 typedef char no_type[2];
41
42 template <typename C> static yes_type & test( decltype(std::distance<C>) ) ;
43 template <typename C> static no_type & test(...);
44
45public:
46 enum { value = sizeof(test<T>(0)) == sizeof(yes_type) };
47};
48
56template<typename T> typename std::enable_if<has_distance<T>::value, typename std::iterator_traits<T>::difference_type>::type format_index_value(const T & a, const T & b) {
57 return std::distance(a,b);
58}
59
65template<typename T> typename std::enable_if<!has_distance<T>::value, T>::type format_index_value(const T & a, const T & b) {
66 return b;
67}
68
96template<class T> class basic_multi_iterator {
97
98 // ctors
99public :
101 explicit basic_multi_iterator(T B, T N, size_t k);
102 explicit basic_multi_iterator(T B, T N, const std::vector<T> & vv);
103
104 // dtor
105 virtual ~basic_multi_iterator();
106
107 // functions
108public :
109 size_t size(void) const;
110 bool overflow(void) const;
111 const std::vector<T> & get_vector(void) const;
112
113 // subscripting
114public :
115 T operator[](size_t i) const;
116 T & operator[](size_t i);
117
118 T operator()(size_t i) const;
119 T & operator()(size_t i);
120
121 // virtual functions
122public :
123 // initialization
124 virtual basic_multi_iterator<T> & init(void);
125 // postfix increment
127
128 // I/O operators
129 template <class TT> friend std::ostream & operator<< (std::ostream & os, const basic_multi_iterator<TT> & v);
130
131 // member variables :
132protected :
133 T N;
134 T B;
135 std::vector<T> v;
137
138};
139
154template<class T> class multi_iterator_ordered : public basic_multi_iterator<T> {
155
156 // ctors
157public :
159 explicit multi_iterator_ordered(T B, T N, size_t k);
160 explicit multi_iterator_ordered(T B, T N, const std::vector<T> & vv);
161
162 // overriding virtual functions from base class
163public :
164 // initialization
166 // postfix increment
168
169 // I/O operators
170 template <class TT> friend std::ostream & operator<< (std::ostream & os, const multi_iterator_ordered<TT> & v);
171
172};
173
188template<class T> class multi_iterator_ordered_eq : public basic_multi_iterator<T> {
189
190 // ctors
191public :
193 explicit multi_iterator_ordered_eq(T B, T N, size_t k);
194 explicit multi_iterator_ordered_eq(T B, T N, const std::vector<T> & vv);
195
196 // overriding virtual functions from base class
197public :
198 // initialization
200 // postfix increment
202
203 // I/O operators
204 template <class TT> friend std::ostream & operator<< (std::ostream & os, const multi_iterator_ordered_eq<TT> & v);
205
206};
207
221template<class T> class multi_iterator_ordered_eq_indv : public basic_multi_iterator<T> {
222
223 // ctors
224public :
226 explicit multi_iterator_ordered_eq_indv(T B, const std::vector<T> & Nv, size_t k);
227 explicit multi_iterator_ordered_eq_indv(T B, const std::vector<T> & Nv, const std::vector<T> & vv);
228
229 // overriding virtual functions from base class
230public :
231 // initialization
233 // postfix increment
235
236 // I/O operators
237 template <class TT> friend std::ostream & operator<< (std::ostream & os, const multi_iterator_ordered_eq_indv<TT> & v);
238
239 // member variables :
240protected :
241 std::vector<T> Nv;
242};
243
253template<class T> class multi_iterator_counter : public basic_multi_iterator<T> {
254
255 // ctors
256public :
258 explicit multi_iterator_counter(T B, T N, size_t k);
259 explicit multi_iterator_counter(T B, T N, const std::vector<T> & vv);
260
261 // overriding virtual functions from base class
262public :
263 // initialization
265 // postfix increment
267
268 // I/O operators
269 template <class TT> friend std::ostream & operator<< (std::ostream & os, const multi_iterator_counter<TT> & v);
270
271};
272
282template<class T> class multi_iterator_counter_indv : public basic_multi_iterator<T> {
283
284 // ctors
285public :
287 explicit multi_iterator_counter_indv(T B, const std::vector<T> & Nv, size_t k);
288 explicit multi_iterator_counter_indv(T B, const std::vector<T> & Nv, const std::vector<T> & vv);
289
290 // overriding virtual functions from base class
291public :
292 // initialization
294 // postfix increment
296
297 // I/O operators
298 template <class TT> friend std::ostream & operator<< (std::ostream & os, const multi_iterator_counter_indv<TT> & v);
299
300 // member variables :
301protected :
302 std::vector<T> Nv;
303};
304
320template<class T> class multi_iterator_permutation : public basic_multi_iterator<T> {
321
322 // ctors
323public :
325 explicit multi_iterator_permutation(T B, T N, size_t k);
326 explicit multi_iterator_permutation(T B, T N, const std::vector<T> & vv);
327
328 // overriding virtual functions from base class
329public :
330 // initialization
332 // postfix increment
334
335 // new functions in this class
336 int get_sign(void) const;
337
338 // I/O operators
339 template <class TT> friend std::ostream & operator<< (std::ostream & os, const multi_iterator_permutation<TT> & v);
340
341};
342
349template<class T> class multi_iterator_shuffle : public basic_multi_iterator<T> {
350
351 // ctors
352public :
354 explicit multi_iterator_shuffle(const std::vector<T> & a, const std::vector<T> & b);
355
356 // overriding virtual functions from base class
357public :
358 // initialization
360 // postfix increment
362
363 // I/O operators
364 template <class TT> friend std::ostream & operator<< (std::ostream & os, const multi_iterator_shuffle<TT> & v);
365
366 // member variables :
367protected :
369 std::vector<size_t> v_internal;
370 std::vector<T> v_orig;
371};
372
379template<class T> class multi_iterator_shuffle_prime : public multi_iterator_shuffle<T> {
380
381 // ctors
382public :
384 explicit multi_iterator_shuffle_prime(const std::vector<T> & a, const std::vector<T> & b);
385
386 // overriding virtual functions from base class
387public :
388 // initialization
390
391 // I/O operators
392 template <class TT> friend std::ostream & operator<< (std::ostream & os, const multi_iterator_shuffle_prime<TT> & v);
393};
394
395// ----------------------------------------------------------------------------------------------------------------
396
397// ctors
398
404template<class T> inline basic_multi_iterator<T>::basic_multi_iterator(void) : N(), B(), v(), flag_overflow(false)
405{}
406
412template<class T> inline basic_multi_iterator<T>::basic_multi_iterator(T BB, T NN, size_t k) : N(NN), B(BB), v(k), flag_overflow(false)
413{}
414
420template<class T> inline basic_multi_iterator<T>::basic_multi_iterator(T BB, T NN, const std::vector<T> & vv) : N(NN), B(BB), v(vv), flag_overflow(false)
421{}
422
429{}
430
431// functions
432
438template<class T> inline size_t basic_multi_iterator<T>::size(void) const
439{
440 return v.size();
441}
442
452{
453 flag_overflow = false;
454
455 for ( size_t i=0; i<v.size(); i++) {
456 v[i] = B;
457 }
458 return *this;
459}
460
466template<class T> inline bool basic_multi_iterator<T>::overflow(void) const
467{
468 return flag_overflow;
469}
470
476template<class T> inline const std::vector<T> & basic_multi_iterator<T>::get_vector(void) const
477{
478 return v;
479}
480
481// subscripting
482
488template<class T> inline T basic_multi_iterator<T>::operator[](size_t i) const
489{
490 return v[i];
491}
492
498template<class T> inline T & basic_multi_iterator<T>::operator[](size_t i)
499{
500 return v[i];
501}
502
508template<class T> inline T basic_multi_iterator<T>::operator()(size_t i) const
509{
510 return v[i];
511}
512
518template<class T> inline T & basic_multi_iterator<T>::operator()(size_t i)
519{
520 return v[i];
521}
522
523
530{
531 return *this;
532}
533
534// I/O operators
535
542template<class T> inline std::ostream & operator<< (std::ostream & os, const basic_multi_iterator<T> & v)
543{
544 os << "basic_multi_iterator(";
545 for ( size_t i=0; i<v.size(); i++) {
546 if (i>0) {
547 os << ",";
548 }
549 os << format_index_value(v.B,v(i));
550 }
551
552 return os << ")";
553}
554
555
556
557// ctors
558
566
572template<class T> inline multi_iterator_ordered<T>::multi_iterator_ordered(T B, T N, size_t k) : basic_multi_iterator<T>(B,N,k)
573{}
574
580template<class T> inline multi_iterator_ordered<T>::multi_iterator_ordered(T B, T N, const std::vector<T> & v) : basic_multi_iterator<T>(B,N,v)
581{}
582
583// functions
584
594{
595 this->flag_overflow = false;
596 T it = this->B;
597
598 for ( size_t i=0; i < this->v.size(); i++) {
599 this->v[i] = it;
600 it++;
601 }
602 return *this;
603}
604
617{
618 int k = this->size();
619 int j = k - 1;
620 T Upper_limit = this->N;
621
622 while ( j>0 ) {
623 this->v[j]++;
624 if ( this->v[j] == Upper_limit ) {
625 j--;
626 Upper_limit--;
627 }
628 else {
629 break;
630 }
631 }
632
633 if (j==0) {
634 this->v[j]++;
635 if (this->v[j] == Upper_limit) this->flag_overflow=true;
636 }
637
638 if ( j>= 0) {
639 for (int jj=j+1;jj<k;jj++) {
640 this->v[jj] = this->v[jj-1];
641 this->v[jj]++;
642 }
643 }
644
645 return *this;
646}
647
648// I/O operators
649
656template<class T> inline std::ostream & operator<< (std::ostream & os, const multi_iterator_ordered<T> & v)
657{
658 os << "multi_iterator_ordered(";
659 for ( size_t i=0; i<v.size(); i++) {
660 if (i>0) {
661 os << ",";
662 }
663 os << format_index_value(v.B,v(i));
664 }
665
666 return os << ")";
667}
668
669
670
671// ctors
672
680
686template<class T> inline multi_iterator_ordered_eq<T>::multi_iterator_ordered_eq(T B, T N, size_t k) : basic_multi_iterator<T>(B,N,k)
687{}
688
694template<class T> inline multi_iterator_ordered_eq<T>::multi_iterator_ordered_eq(T B, T N, const std::vector<T> & v) : basic_multi_iterator<T>(B,N,v)
695{}
696
697// functions
698
708{
709 this->flag_overflow = false;
710
711 for ( size_t i=0; i < this->v.size(); i++) {
712 this->v[i] = this->B;
713 }
714 return *this;
715}
716
729{
730 int k = this->size();
731 int j = k - 1;
732
733 while ( j>0 ) {
734 this->v[j]++;
735 if ( this->v[j] == this->N ) {
736 j--;
737 }
738 else {
739 break;
740 }
741 }
742
743 if (j==0) {
744 this->v[j]++;
745 if (this->v[j] == this->N) {
746 this->flag_overflow=true;
747 }
748 }
749
750 if ( j>= 0) {
751 for (int jj=j+1;jj<k;jj++) {
752 this->v[jj] = this->v[jj-1];
753 }
754 }
755
756 return *this;
757}
758
759// I/O operators
760
767template<class T> inline std::ostream & operator<< (std::ostream & os, const multi_iterator_ordered_eq<T> & v)
768{
769 os << "multi_iterator_ordered_eq(";
770 for ( size_t i=0; i<v.size(); i++) {
771 if (i>0) {
772 os << ",";
773 }
774 os << format_index_value(v.B,v(i));
775 }
776
777 return os << ")";
778}
779
780
781
782
783// ctors
784
792
798template<class T> inline multi_iterator_ordered_eq_indv<T>::multi_iterator_ordered_eq_indv(T B, const std::vector<T> & Nvv, size_t k) : basic_multi_iterator<T>(B,B,k), Nv(Nvv)
799{}
800
806template<class T> inline multi_iterator_ordered_eq_indv<T>::multi_iterator_ordered_eq_indv(T B, const std::vector<T> & Nvv, const std::vector<T> & v) : basic_multi_iterator<T>(B,B,v), Nv(Nvv)
807{}
808
809// functions
810
820{
821 this->flag_overflow = false;
822
823 for ( size_t i=0; i < this->v.size(); i++) {
824 this->v[i] = this->B;
825 }
826 return *this;
827}
828
841{
842 int k = this->size();
843 int j = k - 1;
844
845 while ( j>0 ) {
846 this->v[j]++;
847 if ( this->v[j] == Nv[j] ) {
848 j--;
849 }
850 else {
851 break;
852 }
853 }
854
855 if (j==0) {
856 this->v[j]++;
857 if (this->v[j] == Nv[j]) {
858 this->flag_overflow=true;
859 }
860 }
861
862 if ( j>= 0) {
863 for (int jj=j+1;jj<k;jj++) {
864 this->v[jj] = this->v[jj-1];
865 }
866 }
867
868 return *this;
869}
870
871// I/O operators
872
879template<class T> inline std::ostream & operator<< (std::ostream & os, const multi_iterator_ordered_eq_indv<T> & v)
880{
881 os << "multi_iterator_ordered_eq_indv(";
882 for ( size_t i=0; i<v.size(); i++) {
883 if (i>0) {
884 os << ",";
885 }
886 os << format_index_value(v.B,v(i));
887 }
888
889 return os << ")";
890}
891
892
893
894
895// ctors
896
904
910template<class T> inline multi_iterator_counter<T>::multi_iterator_counter(T B, T N, size_t k) : basic_multi_iterator<T>(B,N,k)
911{}
912
918template<class T> inline multi_iterator_counter<T>::multi_iterator_counter(T B, T N, const std::vector<T> & v) : basic_multi_iterator<T>(B,N,v)
919{}
920
921// functions
922
932{
933 this->flag_overflow = false;
934
935 for ( size_t i=0; i < this->v.size(); i++) {
936 this->v[i] = this->B;
937 }
938 return *this;
939}
940
953{
954 int k = this->size();
955 int j = k - 1;
956
957 while ( j>0 ) {
958 this->v[j]++;
959 if ( this->v[j] == this->N ) {
960 this->v[j] = this->B;
961 j--;
962 }
963 else {
964 break;
965 }
966 }
967
968 if (j==0) {
969 this->v[j]++;
970 if (this->v[j] == this->N) {
971 this->v[j] = this->B;
972 this->flag_overflow=true;
973 }
974 }
975
976 return *this;
977}
978
979// I/O operators
980
987template<class T> inline std::ostream & operator<< (std::ostream & os, const multi_iterator_counter<T> & v)
988{
989 os << "multi_iterator_counter(";
990 for ( size_t i=0; i<v.size(); i++) {
991 if (i>0) {
992 os << ",";
993 }
994 os << format_index_value(v.B,v(i));
995 }
996
997 return os << ")";
998}
999
1000
1001
1002
1003// ctors
1004
1012
1018template<class T> inline multi_iterator_counter_indv<T>::multi_iterator_counter_indv(T B, const std::vector<T> & Nvv, size_t k) : basic_multi_iterator<T>(B,B,k), Nv(Nvv)
1019{}
1020
1026template<class T> inline multi_iterator_counter_indv<T>::multi_iterator_counter_indv(T B, const std::vector<T> & Nvv, const std::vector<T> & v) : basic_multi_iterator<T>(B,B,v), Nv(Nvv)
1027{}
1028
1029// functions
1030
1040{
1041 this->flag_overflow = false;
1042
1043 for ( size_t i=0; i < this->v.size(); i++) {
1044 this->v[i] = this->B;
1045 }
1046 return *this;
1047}
1048
1061{
1062 int k = this->size();
1063 int j = k - 1;
1064
1065 while ( j>0 ) {
1066 this->v[j]++;
1067 if ( this->v[j] == Nv[j] ) {
1068 this->v[j] = this->B;
1069 j--;
1070 }
1071 else {
1072 break;
1073 }
1074 }
1075
1076 if (j==0) {
1077 this->v[j]++;
1078 if (this->v[j] == Nv[j]) {
1079 this->v[j] = this->B;
1080 this->flag_overflow=true;
1081 }
1082 }
1083
1084 return *this;
1085}
1086
1087// I/O operators
1088
1095template<class T> inline std::ostream & operator<< (std::ostream & os, const multi_iterator_counter_indv<T> & v)
1096{
1097 os << "multi_iterator_counter_indv(";
1098 for ( size_t i=0; i<v.size(); i++) {
1099 if (i>0) {
1100 os << ",";
1101 }
1102 os << format_index_value(v.B,v(i));
1103 }
1104
1105 return os << ")";
1106}
1107
1108
1109
1110
1111// ctors
1112
1120
1126template<class T> inline multi_iterator_permutation<T>::multi_iterator_permutation(T B, T N, size_t k) : basic_multi_iterator<T>(B,N,k)
1127{}
1128
1134template<class T> inline multi_iterator_permutation<T>::multi_iterator_permutation(T B, T N, const std::vector<T> & v) : basic_multi_iterator<T>(B,N,v)
1135{}
1136
1137// functions
1138
1148{
1149 this->flag_overflow = false;
1150 T it = this->B;
1151
1152 for ( size_t i=0; i < this->v.size(); i++) {
1153 this->v[i] = it;
1154 it++;
1155 }
1156 return *this;
1157}
1158
1171{
1172 int k = this->size();
1173 int j = k - 1;
1174
1175 while ( j>=0 ) {
1176 bool flag_have_already = true;
1177 while ( flag_have_already ) {
1178 this->v[j]++;
1179
1180 // update flag_have_already
1181 flag_have_already = false;
1182 for (int ii=0; ii<j; ii++) {
1183 if (this->v[j] == this->v[ii]) {
1184 flag_have_already = true;
1185 }
1186 }
1187 }
1188
1189 if ( this->v[j] == this->N ) {
1190 j--;
1191 }
1192 else {
1193 break;
1194 }
1195 }
1196
1197 for (int l=j+1; l<k; l++) {
1198 this->v[l] = this->B;
1199
1200 bool flag_have_already;
1201 do {
1202 flag_have_already = false;
1203 for (int ii=0; ii<l; ii++) {
1204 if (this->v[l] == this->v[ii]) {
1205 flag_have_already = true;
1206 }
1207 }
1208 if (flag_have_already) {
1209 this->v[l]++;
1210 }
1211 }
1212 while (flag_have_already);
1213 }
1214
1215 // check for overflow
1216 this->flag_overflow = true;
1217 T it = this->B;
1218 for (int ii=0; ii<k; ii++) {
1219 if (this->v[ii] != it) {
1220 this->flag_overflow = false;
1221 }
1222 it++;
1223 }
1224
1225 return *this;
1226}
1227
1241template<class T> inline int multi_iterator_permutation<T>::get_sign() const
1242{
1243 int sign = 1;
1244 int k = this->size();
1245
1246 for ( int i=0; i<k; i++) {
1247 for ( int j=i+1; j<k; j++) {
1248 // works only for random-access iterators
1249 if ( this->v[i] > this->v[j] ) {
1250 sign = -sign;
1251 }
1252 }
1253 }
1254
1255 return sign;
1256}
1257
1258
1259// I/O operators
1260
1267template<class T> inline std::ostream & operator<< (std::ostream & os, const multi_iterator_permutation<T> & v)
1268{
1269 os << "multi_iterator_permutation(";
1270 for ( size_t i=0; i<v.size(); i++) {
1271 if (i>0) {
1272 os << ",";
1273 }
1274 os << format_index_value(v.B,v(i));
1275 }
1276
1277 return os << ")";
1278}
1279
1280
1281
1282// ctors
1283
1289template<class T> inline multi_iterator_shuffle<T>::multi_iterator_shuffle(void) : basic_multi_iterator<T>(), N_internal(), v_internal(), v_orig()
1290{}
1291
1297template<class T> inline multi_iterator_shuffle<T>::multi_iterator_shuffle(const std::vector<T> & a, const std::vector<T> & b) : basic_multi_iterator<T>(), N_internal(), v_internal(), v_orig()
1298{
1299 this->B = a[0];
1300
1301 for (size_t i=0; i<a.size(); i++) {
1302 this->v.push_back( a[i] );
1303 this->v_orig.push_back( a[i] );
1304 this->v_internal.push_back( i );
1305 }
1306 for (size_t i=0; i<b.size(); i++) {
1307 this->v.push_back( b[i] );
1308 this->v_orig.push_back( b[i] );
1309 }
1310 this->N_internal = this->v.size();
1311}
1312
1313// functions
1314
1321{
1322 this->flag_overflow = false;
1323
1324 for ( size_t i=0; i < this->v_internal.size(); i++) {
1325 this->v_internal[i] = i;
1326 }
1327 for ( size_t i=0; i < this->v.size(); i++) {
1328 this->v[i] = this->v_orig[i];
1329 }
1330 return *this;
1331}
1332
1345{
1346 int k = this->v_internal.size();
1347 int j = k - 1;
1348 size_t Upper_limit = this->N_internal;
1349
1350 while ( j>0 ) {
1351 this->v_internal[j]++;
1352 if ( this->v_internal[j] == Upper_limit ) {
1353 j--;
1354 Upper_limit--;
1355 }
1356 else {
1357 break;
1358 }
1359 }
1360
1361 if (j==0) {
1362 this->v_internal[j]++;
1363 if (this->v_internal[j] == Upper_limit) {
1364 this->flag_overflow=true;
1365 }
1366 }
1367
1368 if ( j>= 0) {
1369 for (int jj=j+1;jj<k;jj++) {
1370 this->v_internal[jj] = this->v_internal[jj-1];
1371 this->v_internal[jj]++;
1372 }
1373 }
1374
1375 // update v
1376 if ( !(this->flag_overflow) ) {
1377 size_t i_a = 0;
1378 size_t i_b = 0;
1379 size_t i_all = 0;
1380 for (size_t j=0; j<k; j++) {
1381 for (size_t i=i_all; i < this->v_internal[j]; i++) {
1382 this->v[i_all] = this->v_orig[k+i_b];
1383 i_b++;
1384 i_all++;
1385 }
1386 this->v[i_all] = this->v_orig[i_a];
1387 i_a++;
1388 i_all++;
1389 }
1390 for (size_t i = this->v_internal[k-1]+1; i < this->v.size(); i++) {
1391 this->v[i_all] = this->v_orig[k+i_b];
1392 i_b++;
1393 i_all++;
1394 }
1395 }
1396
1397 return *this;
1398}
1399
1400// I/O operators
1401
1408template<class T> inline std::ostream & operator<< (std::ostream & os, const multi_iterator_shuffle<T> & v)
1409{
1410 os << "multi_iterator_shuffle(";
1411 for ( size_t i=0; i<v.size(); i++) {
1412 if (i>0) {
1413 os << ",";
1414 }
1415 os << format_index_value(v.B,v(i));
1416 }
1417
1418 return os << ")";
1419}
1420
1421
1422
1423// ctors
1424
1432
1438template<class T> inline multi_iterator_shuffle_prime<T>::multi_iterator_shuffle_prime(const std::vector<T> & a, const std::vector<T> & b) : multi_iterator_shuffle<T>(a,b)
1439{}
1440
1441// functions
1442
1449{
1450 this->flag_overflow = false;
1451
1452 for ( size_t i=0; i < this->v_internal.size(); i++) {
1453 this->v_internal[i] = i;
1454 }
1455 for ( size_t i=0; i < this->v.size(); i++) {
1456 this->v[i] = this->v_orig[i];
1457 }
1458
1459 (*this)++;
1460
1461 return *this;
1462}
1463
1464// I/O operators
1465
1472template<class T> inline std::ostream & operator<< (std::ostream & os, const multi_iterator_shuffle_prime<T> & v)
1473{
1474 os << "multi_iterator_shuffle_prime(";
1475 for ( size_t i=0; i<v.size(); i++) {
1476 if (i>0) {
1477 os << ",";
1478 }
1479 os << format_index_value(v.B,v(i));
1480 }
1481
1482 return os << ")";
1483}
1484
1485} // namespace GiNaC
1486
1487#endif // ndef GINAC_UTILS_MULTI_ITERATOR_H
basic_multi_iterator is a base class.
T operator[](size_t i) const
Subscription via [].
size_t size(void) const
Returns the size of a multi_iterator.
basic_multi_iterator(void)
Default constructor.
T operator()(size_t i) const
Subscription via ()
friend std::ostream & operator<<(std::ostream &os, const basic_multi_iterator< TT > &v)
virtual basic_multi_iterator< T > & operator++(int)
No effect for basic_multi_iterator.
virtual basic_multi_iterator< T > & init(void)
Initialize the multi-index to.
virtual ~basic_multi_iterator()
Destructor.
bool overflow(void) const
Return the overflow flag.
const std::vector< T > & get_vector(void) const
Returns a reference to the vector v.
SFINAE test for distance.
static no_type & test(...)
static yes_type & test(decltype(std::distance< C >))
The class multi_iterator_counter_indv defines a multi_iterator , such that.
basic_multi_iterator< T > & init(void)
Initialize the multi-index to.
multi_iterator_counter_indv(void)
Default constructor.
basic_multi_iterator< T > & operator++(int)
The postfix increment operator allows to write for a multi-index n++, which will update n to the next...
friend std::ostream & operator<<(std::ostream &os, const multi_iterator_counter_indv< TT > &v)
The class multi_iterator_counter defines a multi_iterator , such that.
basic_multi_iterator< T > & operator++(int)
The postfix increment operator allows to write for a multi-index n++, which will update n to the next...
multi_iterator_counter(void)
Default constructor.
friend std::ostream & operator<<(std::ostream &os, const multi_iterator_counter< TT > &v)
basic_multi_iterator< T > & init(void)
Initialize the multi-index to.
The class multi_iterator_ordered_eq_indv defines a multi_iterator , such that.
friend std::ostream & operator<<(std::ostream &os, const multi_iterator_ordered_eq_indv< TT > &v)
basic_multi_iterator< T > & init(void)
Initialize the multi-index to.
multi_iterator_ordered_eq_indv(void)
Default constructor.
basic_multi_iterator< T > & operator++(int)
The postfix increment operator allows to write for a multi-index n++, which will update n to the next...
The class multi_iterator_ordered_eq defines a multi_iterator , such that.
basic_multi_iterator< T > & operator++(int)
The postfix increment operator allows to write for a multi-index n++, which will update n to the next...
basic_multi_iterator< T > & init(void)
Initialize the multi-index to.
friend std::ostream & operator<<(std::ostream &os, const multi_iterator_ordered_eq< TT > &v)
multi_iterator_ordered_eq(void)
Default constructor.
The class multi_iterator_ordered defines a multi_iterator , such that.
basic_multi_iterator< T > & operator++(int)
The postfix increment operator allows to write for a multi-index n++, which will update n to the next...
basic_multi_iterator< T > & init(void)
Initialize the multi-index to.
friend std::ostream & operator<<(std::ostream &os, const multi_iterator_ordered< TT > &v)
multi_iterator_ordered(void)
Default constructor.
The class multi_iterator_permutation defines a multi_iterator , for which.
int get_sign(void) const
Returns the sign of the permutation, defined by.
basic_multi_iterator< T > & operator++(int)
The postfix increment operator allows to write for a multi-index n++, which will update n to the next...
basic_multi_iterator< T > & init(void)
Initialize the multi-index to.
multi_iterator_permutation(void)
Default constructor.
friend std::ostream & operator<<(std::ostream &os, const multi_iterator_permutation< TT > &v)
The class multi_iterator_shuffle_prime defines a multi_iterator, which runs over all shuffles of a an...
multi_iterator_shuffle_prime(void)
Default constructor.
basic_multi_iterator< T > & init(void)
Initialize the multi-index to the first shuffle.
friend std::ostream & operator<<(std::ostream &os, const multi_iterator_shuffle_prime< TT > &v)
The class multi_iterator_shuffle defines a multi_iterator, which runs over all shuffles of a and b.
basic_multi_iterator< T > & operator++(int)
The postfix increment operator allows to write for a multi-index n++, which will update n to the next...
friend std::ostream & operator<<(std::ostream &os, const multi_iterator_shuffle< TT > &v)
multi_iterator_shuffle(void)
Default constructor.
basic_multi_iterator< T > & init(void)
Initialize the multi-index to the first shuffle.
vector< int > k
Definition factor.cpp:1434
Definition add.cpp:35
std::ostream & operator<<(std::ostream &os, const archive_node &n)
Write archive_node to binary data stream.
Definition archive.cpp:198
std::enable_if< has_distance< T >::value, typenamestd::iterator_traits< T >::difference_type >::type format_index_value(const T &a, const T &b)
For printing a multi-index: If the templates are used, where T is an iterator, printing the address w...

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.