[R] speeding up a special product of three arrays

From: Giuseppe Paleologo <paleologo_at_gmail.com>
Date: Thu, 08 May 2008 17:20:52 -0400


I am struggling with R code optimization, a recurrent topic on this list.

I have three arrays, say A, B and C, all having the same number of columns. I need to compute an array D whose generic element is

D[i, j, k] <- sum_n A[i, n]*B[j, n]*C[k, n]

Cycling over the three indices and subsetting the columns won't do. Is there any way to implement this efficiently in R or should I resign to do this in C?

Thanks,

Giuseppe

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
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. Received on Thu 08 May 2008 - 21:23:28 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 09 May 2008 - 08:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive