### GenericVector.abs() returns NoneType

226

views

0

The GenericVector() class provides some useful operations for vectors. I would like to use the `abs()`

method but somehow it returns `None`

. The `sum()`

method, however, seems to work fine.

I get the output

```
None
5.0
```

when I run the following minimal example:

```
from fenics import *
mesh = UnitSquareMesh(3,3)
fe = FiniteElement('Lagrange',mesh.ufl_cell(),1)
V = FunctionSpace(mesh, fe)
v = TestFunction(V)
f = Constant(5.0)
rhs = f*v*dx
b = assemble(rhs)
print b.abs()
print b.sum()
```

Is anyone able to reproduce this behaviour?

Community: FEniCS Project

### 1 Answer

1

Hi,

this is expected behavior: the abs() method on a GenericVector object replaces all entries of a vector by their absolute values, and returns you nothing (contrary to the sum(), min(), max(), etc. methods).

See the documentation

this is expected behavior: the abs() method on a GenericVector object replaces all entries of a vector by their absolute values, and returns you nothing (contrary to the sum(), min(), max(), etc. methods).

See the documentation

Please login to add an answer/comment or follow this question.

Thanks for the quick reply!