> On Aug 4, 2018, at 10:01 AM, Eric Berger <ericjber...@gmail.com> wrote:
> 
> Hi Rolf,
> A few edits because (i) nrow(a) should be nrow(A) and (ii) you have
> calculated C[j,k,i] = A[i,j]*B[i,k], (iii) minor style change on lapply.
> 
> library(abind)
> xxx <- lapply(1:nrow(A),function(i){A[i,]%o%B[i,]})
> yyy <- do.call(abind,c(xxx,list(along=3)))

Or use the simplify="array" gambit in sapply:

yyy <- sapply(1:nrow(A), function(i) A[i,] %o% B[i,], simplify="array")

> zzz <- aperm(yyy,c(3,1,2))
> 

HTH, 

Chuck

______________________________________________
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.

Reply via email to