proj home

Files   Classes   Functions   Hierarchy  

binoppropertiestest.cpp

Go to the documentation of this file.
00001 #include <iostream>
00002 using namespace std;
00003 
00004 #include <permutationfunc.h>
00005 #include <binopproperties.h>
00006 #include <binoppropertiestest.h>
00007 
00008 
00009 uint binoppropertiestest::fop[] = 
00010 {
00011   0,1,2,
00012   1,2,0,
00013   2,0,1,
00014   0,2,1,
00015   2,1,0,
00016   1,0,2
00017 };
00018 
00019 
00020 void binoppropertiestest::test01()
00021 {
00022   cout << "Enter i k to calculate  k(i(w)). " << endl;
00023   uint i;
00024   uint k;
00025 
00026   //i=1; k=3;
00027   cin >> i;
00028   cin >> k;
00029 
00030   uint x[3];
00031 
00032   for (uint w=0; w<3; ++w)
00033     x[w] = fop[i*3+w];
00034 
00035   for (uint w=0; w<3; ++w)
00036     cout << x[w] << " ";
00037   cout << endl; 
00038 
00039   uint x2[3];
00040   
00041   for (uint w=0; w<3; ++w)
00042     x2[w] = fop[ i*3 + fop[ k*3 + w ] ];
00043 
00044   for (uint w=0; w<3; ++w)
00045     cout << x2[w] << " ";
00046   cout << endl; 
00047 
00048 }
00049 
00050 
00051 void binoppropertiestest::test02()
00052 {
00053   cout << "Generate the Binary Operator Table" << endl;
00054 
00055   uint x2[3];
00056 
00057   for (uint i=0; i<6; ++i)
00058   {
00059     for (uint k=0; k<6; ++k)
00060     { 
00061       cout << "{";
00062       for (uint w=0; w<3; ++w)
00063       {
00064         x2[w] = fop[ i*3 + fop[ k*3 + w ] ];
00065         cout << x2[w] << " "; 
00066       }
00067       cout << "}";
00068     }
00069     cout << endl;
00070   }
00071 
00072 }
00073 
00074 
00075 void binoppropertiestest::test03()
00076 {
00077   permutationfunc pf(fop,6,3);
00078 
00079   uint k;
00080 
00081   bool found;
00082   cout << "Test the inverse function" << endl;
00083   cout << "Iterate over the states, the numbers 0..5 should";
00084   cout <<  " be displayed where the state is matched with an";
00085   cout <<  " integer." << endl;
00086   for (uint i=0; i<6; ++i)
00087   {
00088     k = pf.inverse(found,fop + 3*i);
00089     cout << k << endl;
00090   }
00091 
00092   cout << endl << endl;
00093 }
00094 
00095 
00096 void binoppropertiestest::test04()
00097 {
00098   cout << "Investigating (i+k) mod 6." << endl;
00099   uint mat[] = 
00100   {
00101     0,1,2,3,4,5,
00102     1,2,3,4,5,0,
00103     2,3,4,5,0,1,
00104     3,4,5,0,1,2,
00105     4,5,0,1,2,3,
00106     5,0,1,2,3,4
00107   };
00108 
00109   binopproperties gt(mat,6);
00110 
00111   cout << "isClosed()=" << gt.isClosed() << endl;
00112   cout << "isCommutative()=" << gt.isCommutative() << endl;
00113   cout << "isAssociative()=" << gt.isAssociative() << endl;
00114   cout << "isGroup()=" << gt.isGroup() << endl;
00115   bool found;
00116   cout << "identityfind(found)=" << gt.identityfind(found) << endl;
00117   cout << "  found=" << found << endl;
00118 }
00119 
00120 
00121 void binoppropertiestest::test05()
00122 {
00123   cout << "Test if flipping a triange and rotating it form a group." << endl;
00124 
00125   cout << "The rotation and flip operators described by 6 permutation." << endl;
00126 
00127   permutationfunc pf(fop,6,3);
00128 
00129   cout << "Generate the binary table from the operators." << endl;
00130 
00131   uint mat[6*6];
00132 
00133   bool result;
00134   pf.writeBinaryOperator(result,mat);
00135   if (result==false)
00136   {
00137     cout << "Failed to form a binary operator." << endl;
00138     return;
00139   }
00140 
00141   for (uint i=0; i<6; ++i)
00142   {
00143     for (uint k=0; k<6; ++k)
00144     { 
00145       cout << " ";
00146       cout << mat[i*6+k];
00147       cout << " ";
00148     }
00149     cout << endl;
00150   }
00151 
00152   binopproperties gt(mat,6);
00153 
00154   cout << "isClosed()=" << gt.isClosed() << endl;
00155   cout << "isCommutative()=" << gt.isCommutative() << endl;
00156   cout << "isAssociative()=" << gt.isAssociative() << endl;
00157   cout << "isGroup()=" << gt.isGroup() << endl;
00158   bool found;
00159   cout << "identityfind(found)=" << gt.identityfind(found) << endl;
00160   cout << "  found=" << found << endl;
00161 }
00162 

Generated on Fri Mar 4 00:49:28 2011 for Chelton Evans Source by  doxygen 1.5.8