Here are two solutions.  In the first lo has TRUE on the lower diagonal
and diagonal. Then we compute the exponents, multiplying by lo to zero
out the upper triangle.  In the second rn is a matrix of row numbers
and rn >= t(rn) is the same as lo in the first solution.

r <- 2; n <- 5 # test data

lo <- lower.tri(diag(n), diag = TRUE)
lo * r ^ (row(lo) - col(lo) + 1)

Here is another one:

rn <- row(diag(n))
(rn >= t(rn)) * r ^ (rn - t(rn) + 1)

On 8/15/07, [EMAIL PROTECTED] <[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

______________________________________________
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