RobinHankin / permutations

https://robinhankin.github.io/permutations/
5 stars 3 forks source link

orbit() bug #50

Closed RobinHankin closed 5 months ago

RobinHankin commented 5 months ago

Not sure if it is a "bug" as such, but orbit() returns NULL if the element in question is unaltered by the permutation:

library("permutations")
#> 
#> Attaching package: 'permutations'
#> The following object is masked from 'package:stats':
#> 
#>     cycle
orbit(as.cycle(1:3),5)
#> NULL

Arguably it should return 5 here; in any case this behaviour is not documented.

RobinHankin commented 5 months ago

Following is a more clear example:

library("permutations")
#> 
#> Attaching package: 'permutations'
#> The following object is masked from 'package:stats':
#> 
#>     cycle
orbit(as.cycle("(145)(29)"),3)
#> NULL

by any reasonable criterion, the orbit of 3 should be 3. In the previous example it might be argued that the cycle (123) is an element of $S_3$ and as such the permutation's effect on element 5 is undefined.

RobinHankin commented 5 months ago

Reopening; orbit() has difficulty with the identity permutation:

library("permutations")
#> 
#> Attaching package: 'permutations'
#> The following object is masked from 'package:stats':
#> 
#>     cycle
orbit(c(as.cycle("(145)(29)"),id),3)
#> Error in which(unlist(lapply(c1, function(x) {: argument to 'which' is not logical

Created on 2024-03-14 with reprex v2.1.0