On 16-Aug-07 03:10:17, [EMAIL PROTECTED] wrote:
> Hi,
> Sorry if this is a repost. I searched but found no results.
> I am wondering if it is an easy way to construct the following matrix:
> 
> r     1    0    0    0
> r^2   r    1    0    0
> r^3   r^2  r    1    0
> r^4   r^3  r^2  r    1
> 
> where r could be any number. Thanks.
> Wen

I dare say there's an even simpler way (and I feel certain
someone will post one ... ); but (example):

r<-0.1
r1<-r^((-3):0); r2<-r^(3:0)
R<-r1%*%t(r2)
R
##      [,1]  [,2]  [,3] [,4]
##[1,] 1.000 10.00 100.0 1000
##[2,] 0.100  1.00  10.0  100
##[3,] 0.010  0.10   1.0   10
##[4,] 0.001  0.01   0.1    1

R[upper.tri(R)]<-0
R
##      [,1] [,2] [,3] [,4]
##[1,] 1.000 0.00  0.0    0
##[2,] 0.100 1.00  0.0    0
##[3,] 0.010 0.10  1.0    0
##[4,] 0.001 0.01  0.1    1

Best wishes,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
Fax-to-email: +44 (0)870 094 0861
Date: 16-Aug-07                                       Time: 09:37:28
------------------------------ XFMail ------------------------------

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to