[R] vectorized code

2015-05-29 Thread zeynab jibril
HI I was working on online example, where virus is spread through a graph. The example is sufficient for small graph i.e. small number of edges and nodes. But I tried it on very large graph i.e. 1 nodes and 2 edges, but the below function is not sufficient for large graph because its slow.

Re: [R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Ravi Varadhan
Ravi Varadhan; 'r-help@r-project.org' Subject: Re: [R] Vectorized code for generating the Kac (Clement) matrix On 26-04-2013, at 14:42, Enrico Schumann wrote: > On Thu, 25 Apr 2013, Ravi Varadhan writes: > >> Hi, I am generating large Kac matrices (also known as Clement mat

Re: [R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Berend Hasselman
On 26-04-2013, at 14:42, Enrico Schumann wrote: > On Thu, 25 Apr 2013, Ravi Varadhan writes: > >> Hi, I am generating large Kac matrices (also known as Clement matrix). >> This a tridiagonal matrix. I was wondering whether there is a >> vectorized solution that avoids the `for' loops to the f

Re: [R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Enrico Schumann
On Thu, 25 Apr 2013, Ravi Varadhan writes: > Hi, I am generating large Kac matrices (also known as Clement matrix). > This a tridiagonal matrix. I was wondering whether there is a > vectorized solution that avoids the `for' loops to the following code: > > n <- 1000 > > Kacmat <- matrix(0, n+1,

Re: [R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Berend Hasselman
On 25-04-2013, at 17:18, Ravi Varadhan wrote: > Hi, > I am generating large Kac matrices (also known as Clement matrix). This a > tridiagonal matrix. I was wondering whether there is a vectorized solution > that avoids the `for' loops to the following code: > > n <- 1000 > > Kacmat <- matr

[R] Vectorized code for generating the Kac (Clement) matrix

2013-04-26 Thread Ravi Varadhan
Hi, I am generating large Kac matrices (also known as Clement matrix). This a tridiagonal matrix. I was wondering whether there is a vectorized solution that avoids the `for' loops to the following code: n <- 1000 Kacmat <- matrix(0, n+1, n+1) for (i in 1:n) Kacmat[i, i+1] <- n - i + 1 for