Re: [R] Avoiding two loops

2011-02-04 Thread Petr Savicky
On Fri, Feb 04, 2011 at 02:03:22PM -0500, sudhir cr wrote: > Hello, > > I have a R code for doing convolution of two functions: > > convolveSlow <- function(x, y) { > nx <- length(x); ny <- length(y) > xy <- numeric(nx + ny - 1) > for(i in seq(length = nx)) { > xi <- x[[i]] >

Re: [R] Avoiding two loops

2011-02-04 Thread Dirk Eddelbuettel
On 4 February 2011 at 14:03, sudhir cr wrote: | Hello, | | I have a R code for doing convolution of two functions: | | convolveSlow <- function(x, y) { | nx <- length(x); ny <- length(y) | xy <- numeric(nx + ny - 1) | for(i in seq(length = nx)) { | xi <- x[[i]] | for(

[R] Avoiding two loops

2011-02-04 Thread sudhir cr
Hello, I have a R code for doing convolution of two functions: convolveSlow <- function(x, y) { nx <- length(x); ny <- length(y) xy <- numeric(nx + ny - 1) for(i in seq(length = nx)) { xi <- x[[i]] for(j in seq(length = ny)) { ij <- i+j-1 xy[[ij