search for: vloop

Displaying 6 results from an estimated 6 matches for "vloop".

Did you mean: loop
2024 Jun 16
1
slowness when I use a list comprehension
This can be vectorized. Try ix <- seq_along(vec2) S_diff2 <- sapply(seq_len(N1-(N2-1)*ratio_sampling), \(j) sum((vec1[(ix-1)*ratio_sampling+j] - vec2[ix])**2)) On Sun, Jun 16, 2024 at 11:27?AM Laurent Rhelp <laurentRHelp at free.fr> wrote: > > Dear RHelp-list, > > I try to use the package comprehenr to replace a for loop by a list > comprehension. > > I
2024 Jun 16
1
slowness when I use a list comprehension
...o_sampling ) for( j in 1:length(S_diff2) ) { sum_squares <- 0 for( i in 1:length(vec2)){ sum_squares <- ( sum_squares + ( vec1[ (i-1)*ratio_sampling+j ] - vec2[i] )**2 ) } S_diff2[j] <- sum_squares } S_diff2 } vloop <- function( N1, M2, ratio_sampling, vec1, vec2 ) { S_diff3 <- numeric( N1-(N2-1)*ratio_sampling ) i <- seq_along( vec2 ) k <- (i-1)*ratio_sampling for( j in seq_along( S_diff3 ) ) { S_diff3[j] <- sum( ( vec1[ j + k ] - vec2 )^2 ) }...
2024 Jun 16
1
slowness when I use a list comprehension
...o_sampling ) for( j in 1:length(S_diff2) ) { sum_squares <- 0 for( i in 1:length(vec2)){ sum_squares <- ( sum_squares + ( vec1[ (i-1)*ratio_sampling+j ] - vec2[i] )**2 ) } S_diff2[j] <- sum_squares } S_diff2 } vloop <- function( N1, M2, ratio_sampling, vec1, vec2 ) { S_diff3 <- numeric( N1-(N2-1)*ratio_sampling ) i <- seq_along( vec2 ) k <- (i-1)*ratio_sampling for( j in seq_along( S_diff3 ) ) { S_diff3[j] <- sum( ( vec1[ j + k ] - vec2 )^2 ) }...
2024 Jun 16
1
slowness when I use a list comprehension
Laurent, Thank you for introducing me to a package I did not know existed as I use features like list comprehension in python all the time and could see using it in R now that I know it is available. As to why you see your example as slow, I see you used a fairly complex and nested expression and wonder if it was a better way to go. As you are dealing with an interpreter doing delayed
2008 Dec 09
4
Slideshow with Ken-Burns Effect
Hi everybody, I've had some time and so I added a slideshow creator with the Ken-Burns-Effect to the Ogg Video Tools. Feel free to visit the following page: http://www.server.streamnik.de:88/test.html It's best viewed with the Mozilla Firefox 3.1 Beta 2, but a Cortado Player is also available for the other browsers. The code is actually not publically available, as I would like to add
2008 Dec 09
4
Slideshow with Ken-Burns Effect
Hi everybody, I've had some time and so I added a slideshow creator with the Ken-Burns-Effect to the Ogg Video Tools. Feel free to visit the following page: http://www.server.streamnik.de:88/test.html It's best viewed with the Mozilla Firefox 3.1 Beta 2, but a Cortado Player is also available for the other browsers. The code is actually not publically available, as I would like to add