Files Classes Functions Hierarchy
00001 00002 #include <binopproperties.h> 00003 00004 00005 uintc binopproperties::identityfind(bool & found) const 00006 { 00007 uint k; 00008 for (uint i=0; i<N; ++i) 00009 { 00010 found=true; 00011 for (k=0; k<N; ++k) 00012 { 00013 if ((matik(i,k)==k) && (matik(k,i)==k)) 00014 continue; 00015 00016 found=false; 00017 k=N; 00018 } 00019 00020 if (found) 00021 return i; 00022 } 00023 00024 return 0; 00025 } 00026 00027 bool const binopproperties::isClosed() const 00028 { 00029 uint x; 00030 for (uint i=0; i<N; ++i) 00031 { 00032 for (uint k=0; k<N; ++k) 00033 { 00034 x = matik(i,k); 00035 if (x>=N) 00036 return false; 00037 } 00038 } 00039 00040 return true; 00041 } 00042 00043 boolc binopproperties::isCommutative() const 00044 { 00045 for (uint i=0; i<N; ++i) 00046 { 00047 for (uint k=0; k<N/2; ++k) 00048 { 00049 if (matik(i,k)!=matik(k,i)) 00050 return false; 00051 } 00052 } 00053 00054 return true; 00055 } 00056 00057 boolc binopproperties::isGroup() const 00058 { 00059 if (isClosed()==false) 00060 return false; 00061 00062 if (isAssociative()==false) 00063 return false; 00064 00065 bool found; 00066 uint id = identityfind(found); 00067 if (found==false) 00068 return false; 00069 00070 for (uint i=0; i<N; ++i) 00071 { 00072 inverseright(found,i,id); 00073 if (found==false) 00074 return false; 00075 } 00076 00077 for (uint i=0; i<N; ++i) 00078 { 00079 inverseleft(found,i,id); 00080 if (found==false) 00081 return false; 00082 } 00083 00084 return true; 00085 } 00086 00087 boolc binopproperties::isGroupAbelian() const 00088 { 00089 if (isGroup()==false) 00090 return false; 00091 00092 if (isCommutative()==false) 00093 return false; 00094 00095 return true; 00096 } 00097 00098 boolc binopproperties::isAssociative() const 00099 { 00100 uint i; 00101 uint k; 00102 uint w; 00103 00104 uint a1; 00105 uint a2; 00106 for ( i=0; i<N; ++i) 00107 { 00108 for (k=0; k<N; ++k) 00109 { 00110 for (w=0; w<N; ++w) 00111 { 00112 a2 = matik(k,w); 00113 a2 = matik(i,a2); 00114 00115 a1 = matik(i,k); 00116 a1 = matik(a1,w); 00117 00118 if (a2!=a1) 00119 return false; 00120 } 00121 } 00122 } 00123 00124 return true; 00125 } 00126 00127 00128 00129 uintc binopproperties::inverseright 00130 ( 00131 bool & found, 00132 uintc i, 00133 uintc e 00134 ) const 00135 { 00136 found=true; 00137 for (uint w=0; w<N; ++w) 00138 { 00139 if (matik(i,w)==e) 00140 return w; 00141 } 00142 00143 found=false; 00144 return 0; 00145 } 00146 00147 uintc binopproperties::inverseleft 00148 ( 00149 bool & found, 00150 uintc k, 00151 uintc e 00152 ) const 00153 { 00154 found=true; 00155 for (uint w=0; w<N; ++w) 00156 { 00157 if (matik(w,k)==e) 00158 return w; 00159 } 00160 00161 found=false; 00162 return 0; 00163 } 00164 00165 00166 00167
1.5.8