Displaying 2 results from an estimated 2 matches for "summatrices".
Did you mean:
submatrices
2008 Jul 21
2
avoid loop with three-dimensional array
...to do:
*d=3
k=2
T=4
X = array(rnorm(d*k*T),dim=c(d,k,T))
A = matrix(rnorm(d*d),d,d)
e1 = list()
for (t in 1:T){ #I would like to avoid this
e1[[t]] = t(X[,,t])%*%A%*%X[,,t]
}
##############################
#Function for doing the sum of matrices in a list
##############################
sumMatrices <- function(matrices){
if (length(matrices) > 2) matrices[[1]] + Recall(matrices[-1])
else matrices[[1]] + matrices[[2]]
}
##############################
result = sumMatrices(e1)
*
Thank you in advance for all your help,
best
Michela
[[alternative HTML version deleted]]
2003 Apr 23
9
sum
Dear helpers
I have a list where each element is a matrix (the list is
obtained with lapply). I want to sum those matrices. Is there a
function to do that? The sum function sums all the elements...
--
http://adsl.sapo.pt