[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: efficient way to fill a matrix based on a pattern?
From: |
Jordi Gutiérrez Hermoso |
Subject: |
Re: efficient way to fill a matrix based on a pattern? |
Date: |
Wed, 1 Sep 2010 17:39:20 -0500 |
On 1 September 2010 17:07, justin.cress <address@hidden> wrote:
> omega <- matrix(nrow=dim(indata)[1],ncol=dim(indata)[1])
> for (i in 1:dim(indata)[1])
> {
> for (j in 1:dim(indata)[1])
> {
> omega[i,j]=rho^(abs(i-j))
> }
> }
How about something like
omega = rho.^toeplitz(1:n)
where you've previously defined rho and n?
HTH,
- Jordi G. H.p