← Back to team overview

ufl team mailing list archive

Re: diagonal of a tensor

 

So I couldn't resist and implemented it :)

To be on the safe side because of the beta I only added
functions diag and diag_vector which use other ufl operators,
so this does not introduce any new types to UFL and does
not pose any risk for existing code.

See docstrings and tests for usage.

Martin


On 3 November 2011 07:38, Martin Sandve Alnæs <martinal@xxxxxxxxx> wrote:
> There is no such operator, but it would make sense yes.
>
> Just define it yourself for now with def diag(A), should be trivial to add
> to ufl.
>
> Martin
>
> Den 3. nov. 2011 00.13 skrev "Johan Hake" <johan.hake@xxxxxxxxx> følgende:
>>
>> Hello!
>>
>> Is there an easy way to extract the diagonal of a square tensor in ufl? I
>> know
>> I can do:
>>
>>  diag = as_vector([A[0][0], A[1][1]])
>>
>> but it would make sense to have something like:
>>
>>  diag(A), A.diag()
>>
>> Johan
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~ufl
>> Post to     : ufl@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~ufl
>> More help   : https://help.launchpad.net/ListHelp
>


Follow ups

References