[R] triangular matrix

Uwe Ligges ligges at statistik.uni-dortmund.de
Wed Nov 1 16:36:05 CET 2000


Cesar Augusto de Freitas Anselmo wrote:
> 
> How I make the below matrix
> 
> | a^0   0       0       ...     0   |
> | a^1   a^0     0       ...     0   |
> | a^2   a^1     a^0     ...     0   |
> |       .                           |
> |       .                           |
> |       .                           |
> | a^n   a^(n-1) a^(n-2) ...     a^0 |
> 
> with no loops, where "a" is a constant?

What about
  ma <- matrix(rep(c(a^(0:n), 0), n+1), nrow=n+1, ncol=n+1)
  ma[upper.tri(ma)] <- 0


Uwe Ligges
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list