search for: directionless_circular_permutations

Displaying 4 results from an estimated 4 matches for "directionless_circular_permutations".

2018 Mar 30
2
getting all circular arrangements without accounting for order
...to let you know that your function is faster than generating the directional circular permutations and weeding. Here is the time for n = 10. I compared with just doing the permutations, there is no point in proceeding further with the weeding since it is slower at the start itself. system.time(directionless_circular_permutations(10)) user system elapsed 1.576 0.000 1.579 system.time(permutations(9,9)) user system elapsed 3.030 0.000 3.037 Repeats keep the values similar. All computations on a 10-core processor @3.1GHz with 20 threads (using only one thread) and running the Fedora 27 with 4.15.9...
2018 Mar 30
0
getting all circular arrangements without accounting for order
New function below is a bit faster due to more efficent memory handling. for-loop FTW! directionless_circular_permutations2 <- function( n ) { n1 <- n - 1L v <- seq.int( n1 ) ix <- combinations( n1, 2L ) jx <- permutations( n-3L, n-3L ) jxrows <- nrow( jx ) jxoffsets <- seq.int( jxrows ) result <- matrix( n, nrow = factorial( n1 )/2L, ncol = n ) k <- seq( 2L, n - 2L )...
2018 Mar 30
0
getting all circular arrangements without accounting for order
I don't know if this is more efficient than enumerating with distinct directions and weeding... it seems kind of heavyweight to me: ####### library(gtools) directionless_circular_permutations <- function( n ) { v <- seq.int( n-1 ) ix <- combinations( n-1, 2 ) jx <- permutations( n-3, n-3 ) x <- lapply( seq.int( nrow( ix ) ) , function( i ) { cbind( ix[ i, 1 ] , permutations( n-3...
2018 Mar 30
3
getting all circular arrangements without accounting for order
Thanks! Yes, however, this seems a bit wasteful. Just wondering if there are other, more efficient options possible. Best wishes, Ranjan On Thu, 29 Mar 2018 22:20:19 -0400 Boris Steipe <boris.steipe at utoronto.ca> wrote: > If one is equal to the reverse of another, keep only one of the pair. > > B. > > > > > On Mar 29, 2018, at 9:48 PM, Ranjan Maitra