[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:41:24 -0500 |
2010/9/1 Jordi Gutiérrez Hermoso <address@hidden>:
> 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?
Oops, off-by-one error. Should be:
omega = rho.^toeplitz(0:n-1)