Skip to contents

The outer product of two vectors of permutations is the pairwise product of each element of the first with each element of the second.

Details

It works in much the same way as base::outer(). The third argument, FUN, as in outer(X,Y,FUN="*") is regular group-theoretic multiplication but can be replaced with + if you are sure that the cycles of X and Y are distinct, see the examples. Each element of the returned matrix is a one-element list.

The print method may have room for improvement.

Author

Robin K. S. Hankin

Examples


(M <- outer(rperm(),rperm()))
#>       [,1]          [,2]          [,3]          [,4]          [,5]         
#>  [1,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [2,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [3,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [4,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [5,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [6,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [7,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [8,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [9,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#> [10,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>       [,6]          [,7]          [,8]          [,9]          [,10]        
#>  [1,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [2,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [3,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [4,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [5,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [6,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [7,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [8,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#>  [9,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
#> [10,] permutation,7 permutation,7 permutation,7 permutation,7 permutation,7
outer(cyc_len(4) + 0:3, cyc_len(4) + 100:101,"+")  # OK because the cycles are distinct
#>      [,1]                           [,2]                          
#> [1,] 1, 2, 3, 4, 101, 102, 103, 104 1, 2, 3, 4, 102, 103, 104, 105
#> [2,] 2, 3, 4, 5, 101, 102, 103, 104 2, 3, 4, 5, 102, 103, 104, 105
#> [3,] 3, 4, 5, 6, 101, 102, 103, 104 3, 4, 5, 6, 102, 103, 104, 105
#> [4,] 4, 5, 6, 7, 101, 102, 103, 104 4, 5, 6, 7, 102, 103, 104, 105

do.call("c",M) # c(M) gives a list and unlist(a) gives a numeric vector
#>   [1] (1367)        (15)(27)(36)  (1352)(467)   (134)(67)     (26)(345)    
#>   [6] (1524736)     (162453)      (1357462)     (176243)      (1546327)    
#>  [11] (142)(3675)   (136427)      (146725)      (14532)(67)   (154326)     
#>  [16] (1365)(47)    (16)(354)     (146)(257)    (176)(35)     (13)(275)(46)
#>  [21] (15)(2476)    (47)(56)      (1543)(26)    (15)(246)(37) (164)(237)   
#>  [26] (2754)        (1364)(27)    (152643)      (1273645)     (34)(576)    
#>  [31] (253)(467)    (1327546)     (24)(67)      (25367)       (14365)      
#>  [36] (132647)      (1265)(34)    (24)(576)     (1726534)     (1356)(274)  
#>  [41] (13267)       (15)(2763)    (1356742)     (134)(267)    (345)        
#>  [46] (156)(2473)   (12453)       (135742)      (17243)       (15427)(36)  
#>  [51] (12)(34)(57)  (17)(26)(34)  (125)(37)     (12)(457)     (152476)     
#>  [56] (1723465)     (1476)(235)   (1256)(37)    (16)(23574)   (1753)(26)   
#>  [61] (26)(35)      (13576)       (27456)       (26)(3475)    (1725)(34)   
#>  [66] (13567)(24)   (15)(2437)    (2745)        (124)(375)    (136)(45)    
#>  [71] (12)(3465)    (1346257)     (12765)       (12)(365)(47) (1752436)    
#>  [76] (1345)(267)   (1437526)     (1276)        (1537426)     (13)(256)    
#>  [81] (157)(2634)   (1765)(234)   (156372)      (1574)(263)   (2473)       
#>  [86] (1756)(34)    (1473)        (15372)       (13)(457)     (17)(2365)   
#>  [91] (15637)(24)   (165)(2374)   (15472)(36)   (156324)      (273)(46)    
#>  [96] (16)(3754)    (173)(46)     (1536472)     (13)(456)     (1652347)    
#> [coerced from word form]