Re: [R] Multiple matrix multiplication with two 3-dimensional arrays

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Sat 09 Sep 2006 - 13:44:42 GMT


On Sat, 9 Sep 2006, Anupam Tyagi wrote:

> Sophie Baillargeon <Sophie.Baillargeon <at> mat.ulaval.ca> writes:

>> Maybe I could use an "apply" or something but I
>> can't figure out how. I would have hoped that simply doing
>>
>> array1%*%array2
>
> would work, but it doesn’t…

>I think one of the issues is that algebra for N-Dimentional arrays are not well
>defined. Think how would you define the above operartion on two 3x3x3 arrays.

We have the tensor package to handle this. A simple binary operator has non-uniqueness problems, so you do have to specify which margins to sum over. With two-dimensions (matrices) there are only four possible sums over one margin: x %*% y, y%*%x, crossprod(x,y), tcrossprod(x,y), but with rank-3 tensors there are a lot more options.

         -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley@u.washington.edu	University of Washington, Seattle

______________________________________________
R-help@stat.math.ethz.ch 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 Sat Sep 09 23:49:02 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 09 Sep 2006 - 14:30:04 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.