[R] Need help writing a faster code

2007-02-01 Thread Ravi Varadhan
Hi, I apologize for this repeat posting, which I first posted yesterday. I would appreciate any hints on solving this problem: I have two matrices A (m x 2) and B (n x 2), where m and n are large integers (on the order of 10^4). I am looking for an efficient way to create another matrix, W

Re: [R] Need help writing a faster code

2007-02-01 Thread Dimitris Rizopoulos
sage - From: "Ravi Varadhan" <[EMAIL PROTECTED]> To: Sent: Thursday, February 01, 2007 4:10 PM Subject: [R] Need help writing a faster code > Hi, > > > > I apologize for this repeat posting, which I first posted yesterday. > I would > appreciate any hints o

Re: [R] Need help writing a faster code

2007-02-01 Thread Robin Hankin
Hi > A <- matrix(runif(10),ncol=2) > B <- matrix(runif(10),ncol=2) > g <- function(i4){theta <- atan2( (i4[4]-i4[2]),(i4[3]-i4[1])) + return(theta + 2*pi*(theta<0))} > apply(A,1,function(x){apply(B,1,function(y){g(c(x,y))})}) [,1] [,2] [,3][,4] [,5] [1,] 1.17

Re: [R] Need help writing a faster code

2007-02-01 Thread Ravi Varadhan
ssage- From: Dimitris Rizopoulos [mailto:[EMAIL PROTECTED] Sent: Thursday, February 01, 2007 10:33 AM To: Ravi Varadhan Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Need help writing a faster code the following seems to be a first improvement: m <- 2000 n <- 5000 A <- matrix(rnorm(2

Re: [R] Need help writing a faster code

2007-02-01 Thread Ravi Varadhan
Varadhan Cc: r-help@stat.math.ethz.ch Subject: Re: [R] Need help writing a faster code the following seems to be a first improvement: m <- 2000 n <- 5000 A <- matrix(rnorm(2*m), ncol=2) B <- matrix(rnorm(2*n), ncol=2) W1 <- W2 &l