[R] matrix exponential: M^0
John Fox
jfox at mcmaster.ca
Tue Jan 20 17:02:26 CET 2004
Dear Federico,
The common arithmetic operators such as ^ operate on the elements of
matrices (or vectors or arrays). Similarly, * gives the element-wise
product and not the matrix product.
I hope that this helps,
John
At 04:40 PM 1/20/2004 +0000, Federico Calboli wrote:
>Dear All,
>
>I would like to ask why the zeroeth power of a matrix gives me a matrix
>of ones rather than the identity matrix:
>
> > D<-rbind(c(0,0,0),c(0,0,0),c(0,0,0))
> > D<-as.matrix(D)
> > D
> [,1] [,2] [,3]
>[1,] 0 0 0
>[2,] 0 0 0
>[3,] 0 0 0
>
> > D^0
> [,1] [,2] [,3]
>[1,] 1 1 1
>[2,] 1 1 1
>[3,] 1 1 1
>
>I would have expected the identity matrix here.
>
>I find the same result with every other square matrix I used.
>BTW, I am using R 1.8.1 on Linux Mandrake 9.1
>
>Cheers,
>
>Federico Calboli
____________________________
John Fox
Department of Sociology
McMaster University
email: jfox at mcmaster.ca
web: http://www.socsci.mcmaster.ca/jfox
More information about the R-help
mailing list