← Back to team overview

dolfin team mailing list archive

Re: Mathematical operations in GenericMatrix/Vector interfaces?

 



Martin Sandve Alnæs wrote:
Would it be ok now to add arithmetic operations in the Generic*
interfaces? They can be limited to objects of the same type, using a
type assertion like init already must do for the sparsity pattern. A
fairly small set of operations will allow us to write many linear
algebra algorithms in PyDolfin for any backend, great for
application-specialized algorithms and rapid prototyping.

Vectors:
v+u
a*v

Matrices:
A+B
a*A

Matrix-vector:
A*v


I can't comment on integration pyDOLFIN, but we went to uBlas to get this type of functionality for free. The problem we had with adding a lot of operators to Generic* is that the code for each back-end really grows, especially if the back-end is not well suited to the operation (this was often the case for PETSc).

Garth


If there are any good reasons to avoid this (f.ex. virtual operators
in C++ doesn't exist), I suggest either defining separate interfaces
for arithmetic operations (f.ex. a GenericOperator could be something
with a matrix-vector product) or at the very least defining
conventions for these operations, which would allow PyDolfin apps to
use this by "duck-typing" (since Python is dynamically typed).

--
Martin
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev

--
Dr Garth N Wells
Department of Engineering
University of Cambridge
Trumpington Street
Cambridge CB2 1PZ
United Kingdom

tel.   +44 1223 3 32743
fax.   +44 1223 3 32662
e-mail gnw20@xxxxxxxxx



Follow ups

References