23#ifndef GINAC_UTILS_MULTI_ITERATOR_H
24#define GINAC_UTILS_MULTI_ITERATOR_H
43 template <
typename C>
static yes_type &
test(
decltype(std::distance<C>) ) ;
58 return std::distance(a,b);
110 size_t size(
void)
const;
112 const std::vector<T> &
get_vector(
void)
const;
454 flag_overflow =
false;
456 for (
size_t i=0; i<v.size(); i++) {
469 return flag_overflow;
545 os <<
"basic_multi_iterator(";
546 for (
size_t i=0; i<v.
size(); i++) {
596 this->flag_overflow =
false;
599 for (
size_t i=0; i < this->v.size(); i++) {
619 int k = this->size();
621 T Upper_limit = this->N;
625 if ( this->v[j] == Upper_limit ) {
636 if (this->v[j] == Upper_limit) this->flag_overflow=
true;
640 for (
int jj=j+1;jj<
k;jj++) {
641 this->v[jj] = this->v[jj-1];
659 os <<
"multi_iterator_ordered(";
660 for (
size_t i=0; i<v.
size(); i++) {
710 this->flag_overflow =
false;
712 for (
size_t i=0; i < this->v.size(); i++) {
713 this->v[i] = this->B;
731 int k = this->size();
736 if ( this->v[j] == this->N ) {
746 if (this->v[j] == this->N) {
747 this->flag_overflow=
true;
752 for (
int jj=j+1;jj<
k;jj++) {
753 this->v[jj] = this->v[jj-1];
770 os <<
"multi_iterator_ordered_eq(";
771 for (
size_t i=0; i<v.
size(); i++) {
822 this->flag_overflow =
false;
824 for (
size_t i=0; i < this->v.size(); i++) {
825 this->v[i] = this->B;
843 int k = this->size();
848 if ( this->v[j] == Nv[j] ) {
858 if (this->v[j] == Nv[j]) {
859 this->flag_overflow=
true;
864 for (
int jj=j+1;jj<
k;jj++) {
865 this->v[jj] = this->v[jj-1];
882 os <<
"multi_iterator_ordered_eq_indv(";
883 for (
size_t i=0; i<v.
size(); i++) {
934 this->flag_overflow =
false;
936 for (
size_t i=0; i < this->v.size(); i++) {
937 this->v[i] = this->B;
955 int k = this->size();
960 if ( this->v[j] == this->N ) {
961 this->v[j] = this->B;
971 if (this->v[j] == this->N) {
972 this->v[j] = this->B;
973 this->flag_overflow=
true;
990 os <<
"multi_iterator_counter(";
991 for (
size_t i=0; i<v.
size(); i++) {
1042 this->flag_overflow =
false;
1044 for (
size_t i=0; i < this->v.size(); i++) {
1045 this->v[i] = this->B;
1063 int k = this->size();
1068 if ( this->v[j] == Nv[j] ) {
1069 this->v[j] = this->B;
1079 if (this->v[j] == Nv[j]) {
1080 this->v[j] = this->B;
1081 this->flag_overflow=
true;
1098 os <<
"multi_iterator_counter_indv(";
1099 for (
size_t i=0; i<v.
size(); i++) {
1150 this->flag_overflow =
false;
1153 for (
size_t i=0; i < this->v.size(); i++) {
1173 int k = this->size();
1177 bool flag_have_already =
true;
1178 while ( flag_have_already ) {
1182 flag_have_already =
false;
1183 for (
int ii=0; ii<j; ii++) {
1184 if (this->v[j] == this->v[ii]) {
1185 flag_have_already =
true;
1190 if ( this->v[j] == this->N ) {
1198 for (
int l=j+1; l<
k; l++) {
1199 this->v[l] = this->B;
1201 bool flag_have_already;
1203 flag_have_already =
false;
1204 for (
int ii=0; ii<l; ii++) {
1205 if (this->v[l] == this->v[ii]) {
1206 flag_have_already =
true;
1209 if (flag_have_already) {
1213 while (flag_have_already);
1217 this->flag_overflow =
true;
1219 for (
int ii=0; ii<
k; ii++) {
1220 if (this->v[ii] != it) {
1221 this->flag_overflow =
false;
1245 int k = this->size();
1247 for (
int i=0; i<
k; i++) {
1248 for (
int j=i+1; j<
k; j++) {
1250 if ( this->v[i] > this->v[j] ) {
1270 os <<
"multi_iterator_permutation(";
1271 for (
size_t i=0; i<v.
size(); i++) {
1302 for (
size_t i=0; i<a.size(); i++) {
1303 this->
v.push_back( a[i] );
1304 this->
v_orig.push_back( a[i] );
1307 for (
size_t i=0; i<b.size(); i++) {
1308 this->
v.push_back( b[i] );
1309 this->
v_orig.push_back( b[i] );
1323 this->flag_overflow =
false;
1325 for (
size_t i=0; i < this->v_internal.size(); i++) {
1326 this->v_internal[i] = i;
1328 for (
size_t i=0; i < this->v.size(); i++) {
1329 this->v[i] = this->v_orig[i];
1347 int k = this->v_internal.size();
1349 size_t Upper_limit = this->N_internal;
1352 this->v_internal[j]++;
1353 if ( this->v_internal[j] == Upper_limit ) {
1363 this->v_internal[j]++;
1364 if (this->v_internal[j] == Upper_limit) {
1365 this->flag_overflow=
true;
1370 for (
int jj=j+1;jj<
k;jj++) {
1371 this->v_internal[jj] = this->v_internal[jj-1];
1372 this->v_internal[jj]++;
1377 if ( !(this->flag_overflow) ) {
1381 for (
size_t j=0; j<
k; j++) {
1382 for (
size_t i=i_all; i < this->v_internal[j]; i++) {
1383 this->v[i_all] = this->v_orig[
k+i_b];
1387 this->v[i_all] = this->v_orig[i_a];
1391 for (
size_t i = this->v_internal[
k-1]+1; i < this->v.size(); i++) {
1392 this->v[i_all] = this->v_orig[
k+i_b];
1411 os <<
"multi_iterator_shuffle(";
1412 for (
size_t i=0; i<v.
size(); i++) {
1451 this->flag_overflow =
false;
1453 for (
size_t i=0; i < this->v_internal.size(); i++) {
1454 this->v_internal[i] = i;
1456 for (
size_t i=0; i < this->v.size(); i++) {
1457 this->v[i] = this->v_orig[i];
1475 os <<
"multi_iterator_shuffle_prime(";
1476 for (
size_t i=0; i<v.
size(); i++) {
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...
std::vector< size_t > v_internal
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.
std::ostream & operator<<(std::ostream &os, const archive_node &n)
Write archive_node to binary data stream.
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...