I have a 2x2x10 array of identity matrices, created with
arr = array(diag(2), dim=c(2,2,10))
I'm looking to multiply each 2x2 matrix within that array by a scalar c(1:10)
z = arr[,,1:10] * c(1:10)
However, I'm getting unexpected results. The first three 2x2 matrices of z shown below
, , 1
[,1] [,2]
[1,] 1 0
[2,] 0 4
, , 2
[,1] [,2]
[1,] 5 0
[2,] 0 8
, , 3
[,1] [,2]
[1,] 9 0
[2,] 0 2
Am I missing something?