码迷,mamicode.com
首页 > 其他好文 > 详细

[从头学数学] 第200节 对称与群

时间:2016-04-29 15:55:35      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:

剧情提要:
[机器小伟]在[工程师阿伟]的陪同下进入了[九转金丹]之第六转的修炼。
这一转的名字叫做[千古风流浪淘沙],属于流字门,特点是诸子百家,
热闹非凡,若论真传,浪里淘沙。这次要研究的是[对称与群]。

正剧开始:

星历2016年04月28日 10:41:37, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究[对称与群]。


技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

<span style="font-size:18px;">>>> 
乘法表:首行顺序
I  --- r1  --- r2  --- r3  --- ρ1  --- ρ2  --- 结果:

I  --- ,r1  --- ,r2  --- ,r3  --- ,ρ1  --- ,ρ2  --- ,
r1  --- ,I  --- ,ρ1  --- ,ρ2  --- ,r2  --- ,r3  --- ,
r2  --- ,ρ2  --- ,I  --- ,ρ1  --- ,r3  --- ,r1  --- ,
r3  --- ,ρ1  --- ,ρ2  --- ,I  --- ,r1  --- ,r2  --- ,
ρ1  --- ,r3  --- ,r1  --- ,r2  --- ,ρ2  --- ,I  --- ,
ρ2  --- ,r2  --- ,r3  --- ,r1  --- ,I  --- ,ρ1  --- ,


#三角形所有变换
def tmp():
    a0 = [1, 2, 3];

    allTransfer = [# = C(3, 2)
        [1, 2, 3],#I
        [1, 3, 2], #r1
        [3, 2, 1], #r2
        [2, 1, 3], #r3
        [2, 3, 1], #rou1
        [3, 1, 2], #rou2
    ];
    sTable = ['I', 'r1', 'r2', 'r3', 'ρ1', 'ρ2'];

    #总变化数
    N = 6;

    print('乘法表:首行顺序');
    for i in range(N):
        print(sTable[i], ' --- ', end = '');

    print('结果:');
    
    #乘法表
    for n in range(N):
        print('');
        for m in range(N):
            a1 = allTransfer[n];
            a2 = allTransfer[m];
            
            b0 = [0]*len(a0);

            for i in range(len(b0)):
                b0[i] = a0[a1[i]-1];

            b1 = [0]*len(a0);
            for i in range(len(b1)):
                b1[i] = b0[a2[i]-1];

            for i in range(N):
                if (b1 == allTransfer[i]):
                    print(sTable[i], ' --- ',  end = ',');
                    break;</span>


技术分享

<span style="font-size:18px;">乘法表:首行顺序
I  --- r1  --- r2  --- r3  --- r4  --- ρ1  --- ρ2  --- ρ3  --- 结果:

I  --- ,r1  --- ,r2  --- ,r3  --- ,r4  --- ,ρ1  --- ,ρ2  --- ,ρ3  --- ,
r1  --- ,I  --- ,ρ3  --- ,ρ2  --- ,ρ1  --- ,r4  --- ,r3  --- ,r2  --- ,
r2  --- ,ρ1  --- ,I  --- ,ρ3  --- ,ρ2  --- ,r1  --- ,r4  --- ,r3  --- ,
r3  --- ,ρ2  --- ,ρ1  --- ,I  --- ,ρ3  --- ,r2  --- ,r1  --- ,r4  --- ,
r4  --- ,ρ3  --- ,ρ2  --- ,ρ1  --- ,I  --- ,r3  --- ,r2  --- ,r1  --- ,
ρ1  --- ,r2  --- ,r3  --- ,r4  --- ,r1  --- ,ρ2  --- ,ρ3  --- ,I  --- ,
ρ2  --- ,r3  --- ,r4  --- ,r1  --- ,r2  --- ,ρ3  --- ,I  --- ,ρ1  --- ,
ρ3  --- ,r4  --- ,r1  --- ,r2  --- ,r3  --- ,I  --- ,ρ1  --- ,ρ2  --- ,

#正方形所有变换
def tmp2():
    a0 = [1, 2, 3, 4];

    allTransfer = [
        [1, 2, 3, 4],#I
        [3,2,1,4], #r1
        [4,3,2,1], #r2
        [1,4,3,2], #r3
        [2,1,4,3], #r4
        [2,3,4,1], #rou1
        [3,4,1,2], #rou2
        [4,1,2,3], #rou3
    ];
    sTable = ['I', 'r1', 'r2', 'r3','r4','ρ1', 'ρ2', 'ρ3'];

    #总变化数
    N = 8;

    print('乘法表:首行顺序');
    for i in range(N):
        print(sTable[i], ' --- ', end = '');

    print('结果:');
    
    #乘法表
    for n in range(N):
        print('');
        for m in range(N):
            a1 = allTransfer[n];
            a2 = allTransfer[m];
            
            b0 = [0]*len(a0);

            for i in range(len(b0)):
                b0[i] = a0[a1[i]-1];

            b1 = [0]*len(a0);
            for i in range(len(b1)):
                b1[i] = b0[a2[i]-1];

            for i in range(N):
                if (b1 == allTransfer[i]):
                    print(sTable[i], ' --- ',  end = ',');
                    break;</span>

技术分享

技术分享

技术分享

技术分享

<span style="font-size:18px;">def tmp():
    N = 4;
    originArray = [0]*N;

    for i in range(N):
        originArray[i] = i+1;

    result = flip(originArray, 2);
    print('原:',originArray);
    print('变:', result);

    for i in range(1, 4):
        result = rotate(originArray, i);
        print('原:',originArray);
        print('变:', result);
    

#翻转(反射)
#array 和 不动的顶点序号,从1计数
#如三角形是1, 2, 3
def flip(array, vertex):
    if (vertex <= 0):
        return array;
    vertex -= 1;
    size = len(array);

    newArray = [0]*size;

    if (size == 3):
        for i in range(size):
            newArray[(vertex-i)%size] = array[(vertex+i)%size];
    elif (size == 4):
        #正方形,实在看不出映射规律,只能穷举
        if (vertex == 1):
            return [array[2], array[1], array[0], array[3]];
        elif (vertex == 2):
            return [array[3], array[2], array[1], array[0]];
        elif (vertex == 3):
            return [array[0], array[3], array[2], array[1]];
        elif (vertex == 4):
            return [array[1], array[0], array[3], array[2]];
        else:
            return array;
        
        
    return newArray;

#旋转
#顶点数指从原位置逆时针旋转过几个顶点
#取值范围是从1 ~ 顶点数-1
def rotate(array, vertex):
    if (vertex <= 0):
        return array;

    size = len(array);

    newArray = [0]*size;

    for i in range(size):
        newArray[i] = array[(vertex+i)%size];
    return newArray;




if __name__ == '__main__':
    tmp();</span>


技术分享

技术分享

<span style="font-size:18px;">>>> 
[3, 1, 2]

#例
def tmp():
    a0 = [1, 2, 3];
    a1 = [1, 3, 2];
    a2 = [2, 1, 3];

    b0 = [0]*len(a0);

    for i in range(len(b0)):
        b0[i] = a0[a1[i]-1];

    b1 = [0]*len(a0);
    for i in range(len(b1)):
        b1[i] = b0[a2[i]-1];

    print(b1);
	
#######

>>> 
[2, 3, 1]

    a0 = [1, 2, 3];
    a1 = [2, 1,3];
    a2 = [1, 3, 2];
	</span>
技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

技术分享

<span style="font-size:18px;">>>> 
首行是:  0 ---- 1 ---- 2 ---- 3 结果:

0  ---- 1  ---- 2  ---- 3  ---- 
1  ---- 2  ---- 3  ---- 0  ---- 
2  ---- 3  ---- 0  ---- 1  ---- 
3  ---- 0  ---- 1  ---- 2  ---- 

def tmp3():
    a = [0, 1, 2, 3];
    b = a;

    print('首行是:', ' 0 ---- 1 ---- 2 ---- 3', '结果:');
    for i in range(4):
        print('');
        for j in range(4):
            print((a[i]+b[j])%4, ' ---- ', end = '');


if __name__ == '__main__':
    tmp3();</span>

技术分享

<span style="font-size:18px;">>>> 

[0, 0]  --- [0, 1]  --- [0, 2]  --- [1, 0]  --- [1, 1]  --- [1, 2]  --- 
[0, 1]  --- [0, 2]  --- [0, 0]  --- [1, 1]  --- [1, 2]  --- [1, 0]  --- 
[0, 2]  --- [0, 0]  --- [0, 1]  --- [1, 2]  --- [1, 0]  --- [1, 1]  --- 
[1, 0]  --- [1, 1]  --- [1, 2]  --- [0, 0]  --- [0, 1]  --- [0, 2]  --- 
[1, 1]  --- [1, 2]  --- [1, 0]  --- [0, 1]  --- [0, 2]  --- [0, 0]  --- 
[1, 2]  --- [1, 0]  --- [1, 1]  --- [0, 2]  --- [0, 0]  --- [0, 1]  --- 

def tmp4():
    a = [[0, 0], [0, 1], [0, 2], [1, 0], [1, 1], [1, 2]];
    b = a;

    
    for i in range(6):
        print('');
        for j in range(6):
            x = (a[i][0]+b[j][0])%2;
            y = (a[i][1]+b[j][1])%3;
            print([x, y], ' --- ', end='');
			
			</span>

技术分享

技术分享

技术分享

[人叫板老师]是很让小伟无语的,就这功法的难度,要是结丹期修士不被弄晕,

那绝对是个天才。


本节到此结束,欲知后事如何,请看下回分解。

[从头学数学] 第200节 对称与群

标签:

原文地址:http://blog.csdn.net/mwsister/article/details/51272401

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!