20 if(i >= (
int) _v.size() || i < 0){
21 cout <<
"Permutation::y_of_x for x = " << i
22 <<
" out of range [0," << (_v.size()-1) <<
"]." 29 if(i >= (
int) _v.size() || i < 0){
30 cout <<
"Permutation::y_of_x for x = " << i
31 <<
" out of range [0," << (_v.size()-1) <<
"]." 43 for(
unsigned int i=0; i < size(); i++){
48 for(
unsigned int i=0; i < size(); i++){
49 if (_v[i] != (
int) i)
return false;
56 y_of_x(x1) = y_of_x(x2);
67 _v.resize(1); (*this)[0]=a;
70 _v.resize(2); (*this)[0]=a; (*this)[1]=b;
73 _v.resize(3); (*this)[0]=a; (*this)[1]=b; (*this)[2]=c;
76 _v.resize(4); (*this)[0]=a; (*this)[1]=b; (*this)[2]=c; (*this)[3]=d;
79 _v.resize(4); (*this)[0]=a; (*this)[1]=b; (*this)[2]=c; (*this)[3]=d; (*this)[4]=e;
86 for(
unsigned int i=0; i< this->size(); i++){
87 int newIndex = (*this)[i];
88 if(newIndex < 0 || newIndex >= (
int) this->size()){
89 cout <<
"ERROR in Permutation::getInverse(): " 90 <<
" found that I am an invalid permutation when trying to" 91 <<
" invert myself. This is me:\n" << *
this << endl;
92 cout <<
" Will carry on as best as I can..." <<endl;
102 for(
unsigned int i=0; i< size()-1; ++i){
103 for(
unsigned int j=i+1; j< size(); j++){
104 if( y_of_x(i) > y_of_x(j) ) ++n;
112 for(
unsigned int i=0; i < size(); i++){
116 for(
unsigned int i=0; i < size(); i++){
117 os <<
'\t' << (*this)[i];
123 unsigned int newSize = this->size();
124 if(rhs.
size() > newSize) newSize = rhs.
size();
127 for(
unsigned int i=0; i < newSize; i++){
134 if(rhsMapping > (
int) this->size() || rhsMapping < 0){
135 newP[i] = rhsMapping;
137 newP[i] = (*this)[rhsMapping];
149 if(this->size() < rhs.
size())
return true;
150 if(this->size() > rhs.
size())
return false;
152 for(
unsigned int i=0; i< this->size(); i++){
153 if( (*
this)[i] < rhs[i] )
return true;
154 if( (*
this)[i] > rhs[i] )
return false;
161 if(this->size() != rhs.
size())
return false;
163 for(
unsigned int i=0; i< this->size(); i++){
164 if( (*
this)[i] != rhs[i] )
return false;
169 return ( (*
this) < rhs || (*
this) == rhs);
172 return ! ((*this) <= rhs);
175 return ! ((*this) < rhs);
int nPermutations() const
void swap(int x1, int x2, int sgn=1)
void print(std::ostream &os=std::cout) const
bool operator<=(const Permutation &rhs) const
Permutation operator *(const Permutation &rhs) const
bool operator>=(const Permutation &rhs) const
static const Permutation & unity()
unsigned int size() const
std::ostream & operator<<(std::ostream &os, const Permutation &p)
bool operator==(const Permutation &rhs) const
bool operator<(const Permutation &rhs) const
void set(const std::vector< int > &v, int sgn=1)
bool operator>(const Permutation &rhs) const
static Permutation * __unit
Permutation operator/(const Permutation &rhs) const
Permutation getInverse() const