diagonals of tensors

Thomas Lumley tlumley@u.washington.edu
Fri, 26 Jul 2002 11:58:47 -0700 (PDT)



 Is there a simple and efficient way of extract `diagonals' from arrays
(tensors)

That is, suppose  A is a 20x10x2 array, B is 10x5 and C is 20x5 I would
like the 2x5 matrix whose i,j entry is

      sum_k sum_l  A(k,l,i)B(l,j)C(k,j)


Using tensor() (or outer and matrix multiplication) it's easy to construct
the 2x5x5 matrix with i,j,J entry

       sum_k sum_l  A(k,l,i)B(l,j)C(k,J)

[eg tensor(tensor(A,B,2,1),C,1,1) ]
and I'm looking for the j==J `diagonal', ideally without constructing the
whole thing.


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._