← Back to team overview

ufl team mailing list archive

Re: Evaluating tensor expressions

 

On Tue, Oct 21, 2008 at 05:27:55PM +0200, Anders Logg wrote:
> Is there a simple way to evaluate tensor expressions? For example, if
> 
>  a = dot(v, u)*dx
> 
> is there then a way to convert this to
> 
>  v[0]*u[0] + v[1]*u[1] + ...
> 
> ?

I found the following in Dot:

  def as_basic(self, dim, a, b):
      ii = Index()
      aa = a[ii] if (a.rank() == 1) else a[...,ii]
      bb = b[ii] if (b.rank() == 1) else b[ii,...]
      return aa*bb

Why are the arguments dim, a and b required? A Dot already knows its
operands.

-- 
Anders

Attachment: signature.asc
Description: Digital signature


Follow ups

References