← Back to team overview

ffc team mailing list archive

Re: outer products

 

On Tue, Sep 26, 2006 at 05:11:24PM +0200, Dag Lindbo wrote:
> Hi all,
> 
> As I've been told, it shoud be possible in FFC to compute an outer product
> between a vector valued function and its transpose:
> 
> T = mult(vec(n), transp(vec(n)))
> 
> a = (...)
> L = dot(v,div(T))
> 
> Here, n is on a 'Vector Lagrange' element and so is v (test func).
> 
> I'm a bit concerned that it's not working: If I put the transpose on the
> first term instead I should get something totally different (a rank 0
> tensor instead of rank 2, I guess). But when I compute in DOLFIN,
> impelmenting the two variants I get the same results.
> 
> Have I toatally misunderstood something here?
> 
> Regards,
> Dag Lindbo

Yes, this seems to be a bug. Transpose and matrix multiplications are
handled in FFC by the Python package Numeric and it does not look like
Numeric is aware of the transpose of a vector.

You can try this out yourself in Python:

>>> from Numeric import *
>>> x = array([1,1,1])
>>> matrixmultiply(transpose(x), x)
3
>>> matrixmultiply(x, transpose(x))
3

In both cases, the scalar product is computed and not the outer
product.

One option would be to add an operator outer() in FFC. If you like,
take a look in the file operators.py and see if you can get something
that works. You can either use FFC directly from within Python:

from ffc import *

or put things like this in a .form file:

element = FiniteElement("Vector Lagrange", "triangle", 1)
v = BasisFunction(element)
print mult(transp(vec(v)), vec(v))

and then compile with FFC as usual.

The set of operators defined in operators.py is not as robust and
complete as I would hope and my plan is to replace the form language
with something better (UFL). In the meantime, I'll be happy to accept
any fixes to operators.py. 

/Anders


Follow ups

References