自己写的计算群论工具

随机生成置换群2015-09-26 09:55:59
有限生成置换群工具的C++程序实现(2014-6-28)2014-07-23 15:47:25
按定义求群的中心、换位子群2014-06-06 10:10:40
有限域上的矩阵乘法、行列式、矩阵求逆2014-04-25 10:44:52
判断n元置换集合是否构成S_n的子群的C++程序实现2013-07-16 22:00:46

生成n阶对称群群元集合的稳定算法——穷举搜索法
12!=479001600
using System;
namespace Sn
{
 class MainClass
 {   
  public static void S12(){
   System.IO.StreamWriter file = new System.IO.StreamWriter(@"S12.txt", false);
   file.AutoFlush = true;
   file.WriteLine("static char *abcdefghijkl[] = {");
   int nCount = 0;
   int n=12;
   int a,b,c,d,e,f,g,h,i,j,k,l; 
   for (a=1;a<=n;a++)    
   for (b=1;b<=n;b++)      { 
    if (b==a)      continue; 
    for (c=1;c<=n;c++)      { 
     if(c==a||c==b)   continue;
     for (d=1;d<=n;d++)      { 
      if (d==a||d==b||d==c)    continue;
      for (e=1;e<=n;e++)      { 
       if (e==a||e==b||e==c||e==d)    continue;
       for (f=1;f<=n;f++)      { 
        if (f==a||f==b||f==c||f==d||f==e)    continue;
        for (g=1;g<=n;g++)      { 
         if (g==a||g==b||g==c||g==d||g==e||g==f)    continue;
         for (h=1;h<=n;h++)      { 
          if (h==a||h==b||h==c||h==d||h==e||h==f||h==g)    continue;
          for (i=1;i<=n;i++)      { 
           if (i==a||i==b||i==c||i==d||i==e||i==f||i==g||i==h)    continue;
           for (j=1;j<=n;j++)      { 
            if (j==a||j==b||j==c||j==d||j==e||j==f||j==g||j==h||j==i)    continue;
            for (k=1;k<=n;k++)      { 
             if (k==a||k==b||k==c||k==d||k==e||k==f||k==g||k==h||k==i||k==j) continue;
             for (l=1;l<=n;l++)      { 
              if (l==a||l==b||l==c||l==d||l==e||l==f||l==g||l==h||l==i||l==j||l==k) continue;
         string line=string.Format("\"{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}\",",a,b,c,d,e,f,g,h,i,j,k,l);
         file.WriteLine(line);// 直接追加文件末尾,换行
         nCount++;
             }
            }
           }
          }
         }
        }
       } 
      } 
     } 
    }
   }
   file.WriteLine("};");
   Console.WriteLine ("nCount="+nCount);
   Console.ReadLine ();
  }
  public static void Main (string[] args)
  {
   S12();
  }
 }
}
生成n阶对称群群元集合的不稳定算法
// abcdef.exe
#include <time.h>
#include <fstream>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <algorithm>
using namespace std;
vector<int> v6;
vector<string> s6;
// 整型转变为字符串
string itos(int i)
{
 stringstream s;
 s << i;
 return s.str();
}
int GetRand(int a,int b){
 if(a>=b)
  return a;
 int iRet=rand()%(b-a+1)+a;
 return iRet;
}
string GenS6Element()
{
    string str;
    vector<int> v6c=v6;
    while(v6c.size()>0)
    {
  int i=GetRand(0,v6c.size()-1);
  if(v6c.size()==v6.size())
   str=str+"\"";
        str=str+itos(v6c[i]);
  if(v6c.size()==1)
   str=str+"\"";
  str=str+",";
  v6c.erase(v6c.begin()+i);
    }
    return str;
}
bool GenS6()
{
    while(s6.size()<720)
    {
  string str=GenS6Element();
  vector<string>::iterator iter = find(s6.begin(),s6.end(),str);
  if(iter!=s6.end()){
   //找到了
  }
  else{
  //找不到
   s6.push_back(str);
  }
    }
    return true;
}
 
int main() {
 time_t now=time(0);
 srand(now);
 for(int i=0;i<6;i++)
  v6.push_back(i+1);
 bool bRet=GenS6();
 string fn="abcdef"+itos(now)+".txt";
 ofstream fout(fn);
 fout << "static char *abcdef[] = {"<<endl;
 for(int i=0;i<s6.size();i++){
  fout<<s6[i]<<endl;
 }
 fout<<"};"<<endl;
 cout<<"bRet="<<bRet<<endl;
 system("pause");
 return 0;
}
S6_2_14.9.txt
0,0,0,0,0,0
4,2,3,6,1,5
3,5,4,1,6,2
用FG.exe分析它是一个24阶群,并得到它的凯莱表,输出S6_2_14.9.txt.txt
再用calG.exe分析,得到S6_2_14.9.txt_ElementToOrder.txt
G24ElementToOrder(0)=1
G24ElementToOrder(1)=4
G24ElementToOrder(2)=3
G24ElementToOrder(3)=2
G24ElementToOrder(4)=4
G24ElementToOrder(5)=4
G24ElementToOrder(6)=3
G24ElementToOrder(7)=4
G24ElementToOrder(8)=3
G24ElementToOrder(9)=3
G24ElementToOrder(10)=2
G24ElementToOrder(11)=3
G24ElementToOrder(12)=2
G24ElementToOrder(13)=2
G24ElementToOrder(14)=2
G24ElementToOrder(15)=3
G24ElementToOrder(16)=2
G24ElementToOrder(17)=2
G24ElementToOrder(18)=2
G24ElementToOrder(19)=4
G24ElementToOrder(20)=3
G24ElementToOrder(21)=4
G24ElementToOrder(22)=3
G24ElementToOrder(23)=2
S6_2_14.9.txt有1个1阶元,9个2阶元,8个3阶元,6个4阶元,0个6阶元,0个8阶元,0个12阶元,0个24阶元

证明偶数阶群必含2阶元。
构造法证明:群阶为偶数(设为2n),则群中必有一元素a,a的2n阶为e, a 的1阶,2阶,一直到2n阶必在群中,a的n阶即为阶为2的元素。
正常方法:根据Sylow第一定理:G是有限群,p是素数,如果p^k||G|,k>=0,那么G中一定有一个阶为p^k的子群。令p=2,k=1,则G有一个2阶子群,所以G中一定有2阶元。

// RandMakeS6SubGroup.exe
#include <time.h>
#include <fstream>
using namespace std;
   
static char *abcdef[] = {
 "1,4,6,5,2,3",
 "1,5,6,3,4,2",
 "1,6,5,2,4,3",
 "1,6,4,3,2,5",
 "2,3,5,6,5,1",
 "2,5,3,4,1,6",
 "2,6,4,1,5,3",
 "3,2,6,5,4,1",
 "3,4,5,2,6,1",
 "3,5,4,1,6,2",
 "3,6,2,1,4,5",
 "4,1,5,6,3,2",
 "4,3,2,5,1,6",
 "4,5,1,2,3,6",
 "4,2,3,6,1,5",
 "5,1,3,6,2,4",
 "5,2,4,3,6,1",
 "5,3,1,4,2,6",
 "5,4,2,1,6,3",
 "6,1,3,4,5,2",
 "6,1,2,5,3,4",
 "6,2,1,4,3,5",    
 "6,3,1,2,5,4"
};
int GetRand(int a,int b){
 if(a>=b)
  return a;
 int iRet=rand()%(b-a+1)+a;
 return iRet;
}
int main() {
 srand(time(0));
 int n=sizeof(abcdef)/sizeof(abcdef[0]);
 int m=GetRand(2,4);
 int* p=new int[m];
 char sz[100]={0};
 sprintf(sz,"S6_%d_",m);
 for(int i=0;i<m;i++){
  p[i]=GetRand(0,n-1);
  char sz1[100]={0};
  sprintf(sz1,"%d.",p[i]);
  strcat(sz,sz1);
 }
 strcat(sz,"txt");
 ofstream fout(sz);
 fout << "0,0,0,0,0,0"<<endl;
 for(int i=0;i<m;i++){
  fout<<abcdef[p[i]]<<endl;
 }
 delete[] p;
 puts(sz);
 system("pause");
 return 0;
}

S_3=<(1,4,3,2,5),(1,2,3,5,4)>,S_3扩张为S_4

----24阶非交换群S_4群元的阶----

S_4=<(2,3,5,4,1),(1,3,2,4,5)>=<(2,4,6,1,3,5),(1,3,5,2,4,6)>=<(1,4,3,2,5),(1,2,3,5,4),(2,1,3,4,5)>有1个1阶元,9个2阶元,8个3阶元,6个4阶元,0个6阶元,0个8阶元,0个12阶元,0个24阶元

----24阶非交换群A_4×C_2=<(6,5,1,2,3,4),(1,2,3,4,6,5)>=<(6,5,1,2,3,4),(2,1,3,4,5,6)>==<(6,5,1,2,3,4),(1,2,4,3,5,6)>群元的阶----

//1个1阶元,7个2阶元,8个3阶元,8个6阶元
G20_4=F_20(Frobenius group F_20)=<(1,3,2,5,4),(2,3,4,1,5)>有1个1阶元,5个2阶元,10个4阶元,4个5阶元,0个10阶元,0个20阶元
S_4=<(1,2,3,5,4),(1,3,4,2,5)>有1个1阶元,9个2阶元,8个3阶元,6个4阶元,0个6阶元,0个8阶元,0个12阶元,0个24阶元

20140628工具11:根据R个N次置换生成元计算有限生成置换群的凯莱表的小工具FG.exe
/*
#include "stdafx.h"
#include <iostream>
#include <vector>
using namespace std;
*/
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

std::vector<string> split( const std::string& str, const std::string& delims, unsigned int maxSplits = 0)
{
std::vector<string> ret;
unsigned int numSplits = 0;
// Use STL methods
size_t start, pos;
start = 0;
do
{
pos = str.find_first_of(delims, start);
if (pos == start)
{
// Do nothing
start = pos + 1;
}
else if (pos == std::string::npos || (maxSplits && numSplits == maxSplits))
{
// Copy the rest of the std::string
ret.push_back( str.substr(start) );
break;
}
else
{
// Copy up to delimiter
ret.push_back( str.substr(start, pos - start) );
start = pos + 1;
}
// parse up to next real data
start = str.find_first_not_of(delims, start);
++numSplits;
} while (pos != std::string::npos);
return ret;
}

// S_N中置换乘法m*n
vector<int> Mul(int N,const vector<int> & m,const vector<int> & n)
{
vector<int> tArr(N);
vector<int> aArr(N);
vector<int> taArr(N);
memcpy(&tArr[0],&m[0],sizeof(tArr[0])*N);
memcpy(&aArr[0],&n[0],sizeof(aArr[0])*N);
for(int i=0;i<N;i++)
taArr[i]=aArr[tArr[i]-1];
vector<int> ret(N);
memcpy(&ret[0],&taArr[0],sizeof(taArr[0])*N);
return ret;
}

vector<vector<int>> Order(int N,const vector<int> & m)
{
vector<vector<int>> ret;
vector<int> mi=m;
vector<int> m0(N);
for(int i=0;i<N;i++)
{
m0[i]=i+1;
}
while(memcmp(&mi[0],&m0[0],sizeof(int)*N)!=0)
{
ret.push_back(mi);
mi=Mul(N,mi,m);
}
ret.push_back(mi);
return ret;
}

int IsInFG(int N,const vector<vector<int>> FG,const vector<int> & m)
{
for(int i=0;i<FG.size();i++)
{
if(memcmp(&m[0],&FG[i][0],sizeof(int)*N)==0)
return i;
}
return -1;
}

//M9的秩2有限生成置换群表示
//int g_FG[72][9]=
//{
//{1,2,3,4,5,6,7,8,9},
//{4,5,6,9,3,2,7,1,8},//4阶元a
//{6,1,7,4,2,5,9,3,8},//4阶元b
//{9,3,2,8,6,5,7,4,1},//2阶元a^2
//{8,6,5,1,2,3,7,9,4},//4阶元a^3
//{5,6,9,4,1,2,8,7,3},//2阶元b^2
//{2,5,8,4,6,1,3,9,7},//4阶元b^3
//{4,2,5,8,7,1,9,6,3},//4阶元ab
//{4,1,2,3,9,6,8,5,7},//4阶元abb
//{4,6,1,7,8,5,3,2,9},//4阶元abbb
//{8,7,1,3,5,2,9,4,6},//4阶元aab
//{3,9,6,7,2,1,8,4,5},//3阶元aabb
//{7,8,5,9,1,6,3,4,2},//4阶元aabbb
//{3,5,2,6,1,7,9,8,4},//4阶元aaab
//{7,2,1,5,6,9,8,3,4},//4阶元aaabb
//{9,1,6,2,5,8,3,7,4},//4阶元aaabbb
//{2,4,7,9,5,3,8,6,1},//4阶元ba=aaabbbaaabbbaaabbb
//{5,9,7,8,3,6,1,2,4},//4阶元baa=aabbbaabbbaabbb
//{3,8,7,1,6,2,4,5,9},//4阶元baaa=abbbabbbabbb
//{3,2,8,9,4,5,1,7,6},//4阶元bba=aaabbaaabbaaabb
//{6,5,1,8,9,3,4,7,2},//3阶元bbaa=aabbaabb
//{2,3,4,1,8,6,9,7,5},//4阶元bbaaa=abbabbabb
//{5,3,1,9,2,4,6,8,7},//4阶元bbba=aaabaaabaaab
//{3,6,4,8,5,9,2,1,7},//4阶元bbbaa=aabaabaab
//{6,2,9,1,3,8,5,4,7},//4阶元bbbaaa=ababab
//{8,2,7,6,9,4,3,1,5},//2阶元abab=aaabbaaabb
//{3,4,1,2,7,6,5,9,8},//2阶元abbabb=aabbbaabbb
//{7,5,4,3,2,8,1,6,9},//2阶元abbbabbb
//{4,9,8,1,5,7,6,3,2},//2阶元aabaab=aaabbbaaabbb
//{2,1,5,7,3,9,4,8,6},//2阶元aaabaaab
//{9,5,3,1,7,4,8,2,6},//30=1*16
//{8,3,6,4,7,9,1,5,2},//31=1*17
//{1,6,2,9,7,8,4,3,5},//32=1*18
//{9,4,5,6,8,2,1,3,7},//33=1*19
//{8,9,3,2,1,5,4,6,7},//34=1*20
//{1,8,6,5,4,3,9,2,7},//35=1*21
//{9,2,4,7,1,3,6,5,8},//36=1*22
//{8,5,9,7,4,6,2,3,1},//37=1*23
//{1,3,8,7,9,2,5,6,4},//38=1*24
//{6,9,4,5,7,2,3,8,1},//39=1*25
//{2,7,6,8,1,4,5,3,9},//40=1*26
//{1,5,7,2,8,9,6,4,3},//41=1*28
//{7,3,9,6,5,1,4,2,8},//42=1*29
//{1,4,9,8,2,7,3,5,6},//43=2*7
//{6,4,8,3,1,9,7,2,5},//44=2*8
//{5,4,3,7,6,8,9,1,2},//45=2*9
//{2,8,9,3,7,5,6,1,4},//46=2*10
//{6,7,3,9,8,1,2,5,4},//47=2*12
//{9,7,8,5,2,6,4,1,3},//48=2*14
//{4,8,3,6,2,9,5,7,1},//49=2*25
//{6,3,5,2,4,7,8,1,9},//50=2*26
//{7,4,6,1,9,5,2,8,3},//51=2*28
//{1,7,4,6,3,5,8,9,2},//52=3*16
//{4,7,9,2,6,3,1,8,5},//53=3*17
//{6,8,2,7,5,4,1,9,3},//54=3*19
//{7,1,3,8,4,2,6,9,5},//55=3*22
//{7,9,2,4,8,3,5,1,6},//56=3*24
//{5,7,2,1,4,9,3,6,8},//57=3*25
//{8,1,4,9,6,7,5,2,3},//58=3*26
//{2,6,3,5,9,7,1,4,8},//59=4*17
//{5,2,6,3,8,7,4,9,1},//60=4*18
//{7,6,8,2,3,4,9,5,1},//61=4*21
//{8,4,2,5,3,1,6,7,9},//62=4*22
//{1,9,5,3,6,4,2,7,8},//63=4*23
//{9,6,7,3,4,1,5,8,2},//64=4*26
//{3,7,5,4,9,8,6,2,1},//65=4*28
//{5,8,4,2,9,1,7,3,6},//66=5*15
//{5,1,8,6,7,3,2,4,9},//67=6*13
//{2,9,1,6,4,8,7,5,3},//68=6*25
//{3,1,9,5,8,4,7,6,2},//69=7*8
//{9,8,1,4,3,7,2,6,5},//70=7*12
//{4,3,7,5,1,8,2,9,6},//71=10*12
//};

/*
int main()
{
vector<vector<int>> FG;
int N=9;
int R=2;
int S[2][9]=
{
//{1,2,3,4,5,6,7,8,9},
{4,5,6,9,3,2,7,1,8},//4阶元a
{6,1,7,4,2,5,9,3,8},//4阶元b
};
    vector<int> E;
for(int i=0;i<N;i++)
{
E.push_back(i+1);
}
FG.push_back(E);

for(int i=0;i<R;i++)
{
vector<int> I(N);
memcpy(&I[0],&S[i][0],sizeof(int)*N);
FG.push_back(I);
}

int cnt=R+1;
int cnt1=R+1;
do{
cnt=FG.size();
for(int i=1;i<cnt;i++)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值