update
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -74,8 +74,8 @@ static const int perm_failure = -1;
|
||||
int factorial(int n);
|
||||
|
||||
//Iteratable Permutation Class
|
||||
//Provides an object for iterating over permutations of low dimension
|
||||
//These can be stepped along
|
||||
//Provides an object for iterating over permutations of low order (<=12)
|
||||
//These can be stepped along in a loop
|
||||
class ipermutation
|
||||
{
|
||||
public:
|
||||
@ -172,8 +172,6 @@ class permutation
|
||||
int& at(const int ind);
|
||||
const int& at(const int ind) const;
|
||||
|
||||
|
||||
|
||||
static permutation first(int length);
|
||||
static permutation last(int length);
|
||||
|
||||
@ -182,8 +180,11 @@ class permutation
|
||||
|
||||
int _intl_calculate_mindex(int *mindex, int *wrk);
|
||||
int levi_civita();
|
||||
|
||||
void print(int style);
|
||||
};
|
||||
|
||||
void test_permutation1();
|
||||
|
||||
}; //end namespace perm
|
||||
}; //end namespace ams
|
||||
|
@ -356,5 +356,32 @@ const int& permutation::at(const int ind) const
|
||||
return data[ind];
|
||||
}
|
||||
|
||||
void permutation::print(int style)
|
||||
{
|
||||
int I;
|
||||
if(style==0)
|
||||
{
|
||||
printf("{");
|
||||
for(I=0;I<length-1;I++) printf("%d,",data[I]);
|
||||
printf("%d}",data[length-1]);
|
||||
}
|
||||
else if(style==1)
|
||||
{
|
||||
printf("permutation:{");
|
||||
for(I=0;I<length-1;I++) printf("%d,",data[I]);
|
||||
printf("%d}",data[length-1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void test_permutation1()
|
||||
{
|
||||
permutation a = permutation(5);
|
||||
|
||||
a.print(1);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}; //end namespace perm
|
||||
}; //end namespace ams
|
@ -6,6 +6,7 @@ int main(int argc, char* argv[])
|
||||
printf("ams c++ permutation library tests.\n");
|
||||
//amsperm1_test_basicperm1();
|
||||
//ams::perm::test_ipermutation1();
|
||||
ams::perm::test_ipermutation2();
|
||||
//ams::perm::test_ipermutation2();
|
||||
ams::perm::test_permutation1();
|
||||
return ret;
|
||||
}
|
Reference in New Issue
Block a user