This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

How to write matrices in fenics

+1 vote

Hi,

say I wanted to write a 3x2 matrix of the form

[1 0]
[0 1]
[0 0]

how would I go about it?

I've tried using the as_tensor function and writing something like

F = as_tensor([1 0] [0 1] [0 0], (i, j))

Any help would be appreciated.

asked Jul 4, 2017 by woolyabyss FEniCS Novice (420 points)

1 Answer

+2 votes
 
Best answer

Did you try

F = as_tensor([[1, 0],
               [0, 1],
               [0, 0]])

or are you looking for something more complicated?

answered Jul 4, 2017 by nate FEniCS Expert (17,050 points)
selected Jul 5, 2017 by woolyabyss

Thats perfect, thanks.

...