Can anyone think of a sexy way of forming following "product"?
Given matrices A and B, both with m rows, form a 3 dimensional array C
such that:
C[i,j,k] = A[i,j]*B[i,k]
I *think* that the following does what I want. (I keep confusing
myself, so I'm not sure!)
library(abind)
xxx <- lapply(1:nrow(a),function(i,a,b){a[i,]%o%b[i,]},a=A,b=B)
do.call(abind,c(xxx,list(along=3)))
Is there a cleverer way?
cheers,
Rolf Turner
--
Technical Editor ANZJS
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.