help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: multiplying matrices into tensors?


From: Jordi Gutiérrez Hermoso
Subject: Re: multiplying matrices into tensors?
Date: Wed, 3 Aug 2011 19:14:59 -0500

Tenser, said the tensor...

On 3 August 2011 17:23, James Cloos <address@hidden> wrote:
> I have a pair of matrices, such as:
>
> a = [  0  20  10 -10 -20   0 ;
>     -25  -5  15  15  -5 -25 ;
>       0   0   0   0   0   0 ;
>       5   1   1   1   1   5 ]
>
> b = [ 0  100  100    0   0  100  100    0   0  100 ;
>      0    0  100  100   0    0  100  100   0    0 ;
>      0    0    0    0   0    0    0    0   0    0 ;
>      1    1    1    1   1    1    1    1   1    1 ]
>
> representing lists of points where each column is an xyzw point in
> R³P.
>
> (In this case they are actually lists of points in R²P, but the
> underlying storage always stores in R³P and wants them ordered
> as above.)
>
> I need to mupliply the points together piecewise to generate a 3-d
> tensor representing a 2-d array of xywz points, using the typical:
>
>             $[ c_{i,j} = a_i × b_j $]
>
> formulation.

I'm not sure if I understand, but I imagine you want something like
this:

     c = bsxfun(@times, permute(a,[3,2,1]), permute(b,[2,3,1]))

The multiplication of points is elementwise, right? You didn't intend
to contract indices? You can do sum(c,3) if you wanted a 10 by 6
matrix of the (real) inner products. If you wanted some other
generalised transpose of c, just play around with permute until you
get the dimensions in the order you want.

HTH,
- Jordi G. H.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]