[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: multiplying matrices into tensors?
From: |
James Cloos |
Subject: |
Re: multiplying matrices into tensors? |
Date: |
Thu, 04 Aug 2011 02:48:00 -0400 |
User-agent: |
Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) |
>>>>> "JGH" == Jordi Gutiérrez Hermoso <address@hidden> writes:
JGH> I'm not sure if I understand, but I imagine you want something like
JGH> this:
JGH> c = bsxfun(@times, permute(a,[3,2,1]), permute(b,[2,3,1]))
I have to confirm each element, but, based on the above, it looks like
c = bsxfun(@times, permute(a,[1,2,3]), permute(b,[1,3,2]))
might have been the solution, but testing reminded me that the
multiplication needs to be done a bit differently:
c(1,u,v) = a(1,u) * b(4,v) + b(1,v) * a(4,u)
c(2,u,v) = a(2,u) * b(4,v) + b(2,v) * a(4,u)
c(3,u,v) = a(3,u) * b(4,v) + b(3,v) * a(4,u)
c(4,u,v) = a(4,u) * b(4,v)
u loops over the 2nd dim of a and v over the 2nd dim of b.
I presume I can still use bsxfun() and just need to write a function
which takes a pair of column vectors representing homogeneous coordinates
and returns their product by way of the above algo, yes?
Said multiplication perhaps should be followed by something akin to
what c /= gcd(c) looks like it might do, if that syntax were legal.
Is their an efficient way of doing that?
-JimC
--
James Cloos <address@hidden> OpenPGP: 1024D/ED7DAEA6