Permutations testes avec Scilab

Discutez d'informatique ici !
Avatar de l’utilisateur
ortollj
Membre Rationnel
Messages: 554
Enregistré le: 13 Mai 2009, 10:28

permutations testes avec Scilab

par ortollj » 25 Sep 2016, 23:53

Bonjour
du fait que le site Youtube ne distingue pas le code des commentaires
mon message ci dessous a l'air d'un vrai foutoir, et je doute que quelqun me reponde jamais !
aussi je le reposte ici ca devrait etre plus clair.
peut etre quelqu'un pourra me dire si j'ai fait une (ou plusieurs :oops: )erreurs dans le script ?
comment dit on coset en Français, peut etre co-ensemble ?
https://www.youtube.com/watch?v=AwYCNUF4UE0&index=5&list=PLL0ATV5XYF8DTGAPKRPtYa4E8rOLcw88y
video a 5min24 sec
Hello Matthew
because me too I did mistakes when I Computed the cyclic permutations.
I made a little Scilab script to test permutations .
But The fact remains, however, that I do not find the same result as yours.
But may be there are now some errors in my Scilab script :)
I find that the coset <1 3>*H is equal to the coset H*<1, 3>

Scilab

ci dessous les deux fontions
Code: Tout sélectionner
/######### the 2 Scilab functions for testing permutations
//input ThisS in this form ThisS=['A', 'B', 'C', 'D'] ;
//or in this form ThisS=['ABCD'] ;
// ; (must be natural number)
//Times=1;
//[S SS]= PermuteThis(ThisS,LikeThat,Times)
function [S,SS]  = PermuteThis(ThisS,LikeThat,Times)
   
   tt=type(ThisS) ;
   
   // test if This is Matrix of Letter
 if tt==10 then
     // convert This in number
     This=ascii(ThisS) ;
     This=This-64 ;
 end 

S=[This ] ;

LThis=length(S) ;
LikeThat=[LikeThat] ;
L=length(LikeThat) ;

for j = 1 : Times
   for i = 1 : L-1
       S(LikeThat(i+1))=This(LikeThat(i));   
       // disp('copy number: ' + string(i) +' = '+ string(This(LikeThat(i))) ..
       // + ' Goes to ' + string(This(LikeThat(i+1))) );
    end
    // replace first element of LikeThat
    // with the last element of the sequence LikeThat
    S(LikeThat(1))=This(LikeThat(L)) ;
    //disp('copy number: ' + string(L) +' = '+ string(This(LikeThat(L))) ..
    //    + ' Goes to ' + string(This(LikeThat(1))) );

end     
if tt==10 then
// convert S in letter
 // convert S in letter
   ttt=S+64 ;
   SS=ascii(ttt);
end

endfunction


// execute all permutation (one per row) contained in LikeThat List)
// example : if you want to apply  < <1 2 3 >, <3 4 > >
// on a Sequence of 4 letters ABCD which means
// first < 1 2 3 > and then < 3 4 >
// you must input
//ThisS=['ABCD'] ; LikeThat=list( [ 1 2 3 ],[ 3 4 ]) ; Times=1
// [S,SS]  = SequencePermuteThis(ThisS,SeqLikeThat,Times)
function [SL,SSL]  = ListPermuteThis(ThisS,ListLikeThat,Times)
 SizeListLikeThat=size(ListLikeThat) ;
 TSSL=ThisS;
 for j = 1 : Times // repeat it Times Value
    for i = 1 : SizeListLikeThat(1)
        [SL,SSL]=PermuteThis(TSSL,ListLikeThat(i),1);
         TSSL= SSL ;
    end
 end
endfunction


partie test du code

Code: Tout sélectionner
/############### Below the test script
//ThisS=['A', 'B', 'C', 'D'] ;
ThisS=['ABCD'] ;
LikeThat=[ 1 2 3 ] ;
Times=1;
SS=['   '];
TSS=ThisS ;
Classe=0 ;
AllThisS=ThisS ;
while SS ~= ThisS
    [S SS]= PermuteThis(TSS,LikeThat,Times);
    disp('SS=' + SS);
    TSS=SS ;
    Classe=Classe+1 ;
    AllThisS=[AllThisS ; SS] ;
end
ListLikeThat=list( [ 1 2  ],[ 3 4 ]) ;
[S,SS]  = ListPermuteThis(ThisS,ListLikeThat,Times) ;
disp(SS);
ListLikeThat=list([1 2],[3 4],[1 3]);
[S,SS]  = ListPermuteThis(ThisS,ListLikeThat,Times) ;
disp(SS);
ListLikeThat=list( [1 3],[3 4],[1 2]);
[S,SS]  = ListPermuteThis(ThisS,ListLikeThat,Times) ;
disp(SS);

// #####################  1 2 Left
ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]))
for i=1 :size(ListListLikeThat)
 ListListLikeThat(i)= lstcat( list([1 2]),ListListLikeThat(i) ) ;
 disp(ListListLikeThat(i)) ; 
end

ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]))
for i=1 :size(ListListLikeThat)
 [S,SS]  = ListPermuteThis(ThisS,ListListLikeThat(i),1) ;
 disp(SS  ) ; 
 disp( string(S) ) ; 
end

// #####################  1 2 Right

ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]))
for i=1 :size(ListListLikeThat)
 ListListLikeThat(i)= lstcat( ListListLikeThat(i),list([1 2]) ) ;
 disp(ListListLikeThat(i)) ; 
end

ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]))
for i=1 :size(ListListLikeThat)
 [S,SS]  = ListPermuteThis(ThisS,ListListLikeThat(i),1) ;
 disp(SS  ) ; 
 disp( string(S) ) ; 
end


// #####################  1 3 Left
ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]))
for i=1 :size(ListListLikeThat)
 ListListLikeThat(i)= lstcat( list([ 1 3 ]),ListListLikeThat(i) ) ;
 disp(ListListLikeThat(i)) ; 
end

ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]))
for i=1 :size(ListListLikeThat)
 [S,SS]  = ListPermuteThis(ThisS,ListListLikeThat(i),1) ;
 disp(SS  ) ; 
 disp( string(S) ) ; 
end

// #####################  1 3 Right

ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]))
for i=1 :size(ListListLikeThat)
 ListListLikeThat(i)= lstcat( ListListLikeThat(i),list([1 3]) ) ;
 disp(ListListLikeThat(i)) ; 
end

ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]))
for i=1 :size(ListListLikeThat)
 [S,SS]  = ListPermuteThis(ThisS,ListListLikeThat(i),1) ;
 disp(SS  ) ; 
 disp( string(S) ) ; 
end
si j'avais su j'aurais pas venu.



Avatar de l’utilisateur
ortollj
Membre Rationnel
Messages: 554
Enregistré le: 13 Mai 2009, 10:28

Re: permutations testes avec Scilab

par ortollj » 26 Sep 2016, 20:58

en fait je viens de revérifier ce soir, et je m'aperçois que je m'etais pris les pieds dans le tapis quand j'ai testé hier soir :(
(je ne sais pas trop ce que j'ai fais comme fausse manip hier soir !!)
ce soir je trouve bien H*(1 3) <> (1 3)*H :pleur4:
désolé.

Code: Tout sélectionner
// #####################  1 3 Left
BACD !2  1  3  4  !

ABCD !1  2  3  4  !

BADC !2  1  4  3  !

ABDC !1  2  4  3  !

// #####################  1 3 Right
BACD !2  1  3  4  !

BCAD !2  3  1  4  !

DACB !4  1  3  2  !

DCAB !4  3  1  2  !
si j'avais su j'aurais pas venu.

Avatar de l’utilisateur
ortollj
Membre Rationnel
Messages: 554
Enregistré le: 13 Mai 2009, 10:28

Re: permutations testes avec Scilab

par ortollj » 29 Sep 2016, 09:16

attention il manque un ';' a la fin de chaque ligne ListListLikeThat=
dans la partie test du code.

je pense que c'est ca qui me donnait des résultats différents parfois !

heureusement pour moi le ridicule ne tue pas :mrgreen:
bon finalement je trouve ca:

H=(),(1 2),(3 4),(1 2)*(3 4)


1 2 Left = (1 2)*H)
SS:ABCD S:1234 ()
SS:BACD S:2134 (1 2)
SS:ABDC S:1243 (3 4)
SS:BADC S:2143 (1 2)*(3 4)

1 2 Right = H*(1 2)
SS:ABCD S:1234 ()
SS:BACD S:2134 (1 2)
SS:ABDC S:1243 (3 4)
SS:BADC S:2143 (1 2)*(3 4)

1 3 Left = (1 3)*H)
SS:CBAD S:3214 (1 3)
SS:BCAD S:2314 (1 3 2)
SS:CBDA S:3241 (1 4 3)
SS:BCDA S:2341 (1 4 3 2)

1 3 Right = H*(1 3)
SS:CBAD S:3214 (1 3)
SS:CABD S:3124 (1 2 3)
SS:DBAC S:4213 (1 3 4)
SS:DABC S:4123 (1 2 3 4)


Matthew result:
(1 3)*H = (1 3),(1 2 3),(1 3 4),(1 2 3 4)
H*(1 3) = (1 3),(1 3 2),(1 4 3),(1 4 2 3)


voila le code utilisé pour tester:
Code: Tout sélectionner
// create dir Scilab if it does not exist
sc=createdir("Scilab") ;
cd Scilab ;
sc=createdir("TestPermute") ;
cd TestPermute ;
sc=createdir("Work");
WorkPath = pwd() ;
WorkPath = WorkPath  + "\Work" ;
exec("Permute.sci");
CsvDelimiter=',' ;
d=getdate();
fd_w = mopen(WorkPath +'\ListPermutations-'+string(d(7))+'H'+string(d(8))+'m'+'.txt', 'at');
// #####################  1 2 Left
SstrH='1 2 Left = (1 2)*H)' ;
mfprintf(fd_w," %s\n",SstrH);
ThisS=['ABCD'] ;
ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]));
for i=1 :size(ListListLikeThat)
 ListListLikeThat(i)= lstcat( list([1 2]),ListListLikeThat(i) ) ;
 disp(ListListLikeThat(i)) ; 
end

for i=1 :size(ListListLikeThat)
 [S,SS]  = ListPermuteThis(ThisS,ListListLikeThat(i),1) ;
 disp(SS  ) ; 
 disp( string(S) ) ;
     Sstr='';
    for j=size(S)(2):-1 :1
        Sstr=string(S(j)) +Sstr;
    end
    mfprintf(fd_w," SS:%s  S:%s  \n",string(SS(1)),Sstr);   
end

// #####################  1 2 Right
SstrH='1 2 Right = H*(1 2)' ;
mfprintf(fd_w," %s\n",SstrH);
ThisS=['ABCD'] ;
ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]));
for i=1 :size(ListListLikeThat)
 ListListLikeThat(i)= lstcat( ListListLikeThat(i),list([1 2]) ) ;
 disp(ListListLikeThat(i)) ; 
end


for i=1 :size(ListListLikeThat)
 [S,SS]  = ListPermuteThis(ThisS,ListListLikeThat(i),1) ;
 disp(SS  ) ; 
 disp( string(S) ) ;
     Sstr='';
    for j=size(S)(2):-1 : 1
        Sstr=string(S(j)) +Sstr;
    end
    mfprintf(fd_w," SS:%s  S:%s  \n",string(SS(1)),Sstr);   
end


// #####################  1 3 Left
SstrH='1 3 Left = (1 3)*H)' ;
mfprintf(fd_w," %s\n",SstrH);
ThisS=['ABCD'] ;
ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4]));
for i=1 :size(ListListLikeThat)
 ListListLikeThat(i)= lstcat( list([ 1 3 ]),ListListLikeThat(i) ) ;
 disp(ListListLikeThat(i)) ; 
end


for i=1 :size(ListListLikeThat)
 [S,SS]  = ListPermuteThis(ThisS,ListListLikeThat(i),1) ;
 disp(SS  ) ; 
 disp( string(S) ) ;
     Sstr='';
    for j=size(S)(2):-1 :1
        Sstr=string(S(j)) +Sstr;
    end
    mfprintf(fd_w," SS:%s  S:%s  \n",string(SS(1)),Sstr);   
end


// #####################  1 3 Right
SstrH='1 3 Right = H*(1 3)' ;
mfprintf(fd_w," %s\n",SstrH);
ThisS=['ABCD'] ;
ListListLikeThat=list(list([]), list([1 2]),list([3 4]),list([1 2],[3 4])) ;
for i=1 :size(ListListLikeThat)
 ListListLikeThat(i)= lstcat( ListListLikeThat(i),list([1 3]) ) ;
 disp(ListListLikeThat(i)) ; 
end

for i=1 :size(ListListLikeThat)
 [S,SS]  = ListPermuteThis(ThisS,ListListLikeThat(i),1) ;
 disp(SS  ) ; 
 disp( string(S) ) ;
    Sstr='';
    for j=size(S)(2):-1 :1
        Sstr=string(S(j)) +Sstr;
    end
    mfprintf(fd_w," SS:%s  S:%s  \n",string(SS(1)),Sstr); 
end

mclose(fd_w);




Git Hub Scilab Test cyclic permutations
si j'avais su j'aurais pas venu.

Avatar de l’utilisateur
ortollj
Membre Rationnel
Messages: 554
Enregistré le: 13 Mai 2009, 10:28

Re: permutations testes avec Scilab

par ortollj » 12 Oct 2016, 20:21

un script qui génère les tables *,+ et les polynômes caractéristiques de GF(p^n) pas trop grand ! :rouge:


Scilab Git Hub Education
si j'avais su j'aurais pas venu.

 

Retourner vers ϟ Informatique

Qui est en ligne

Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 6 invités

Tu pars déja ?



Fais toi aider gratuitement sur Maths-forum !

Créé un compte en 1 minute et pose ta question dans le forum ;-)
Inscription gratuite

Identification

Pas encore inscrit ?

Ou identifiez-vous :

Inscription gratuite