[Dune] [Dune-Commit] dune-istl r929 - trunk/istl
Carsten Graeser
graeser at math.fu-berlin.de
Tue Jul 29 16:01:16 CEST 2008
Hi,
obviously casting to FieldMatrix as well as returning a temporary
FieldVector from operator[] is not the optimal solution.
As far as I know there is nothing that could be done with
the old version and that is slower with the new one.
However if you only use ScaledIdMatrix as it was possible before
you basically solve several scalar problems in parallel.
I introduced the cast, since we want to benefit from the
reduced memory usage if possible on the one hand. On the other
hand FieldMatrix and ScaledIdMatrix should interact.
For example I would like to use 'A+=B;' for a FieldMatrix A
and a ScaledIdMatrix B while the code does not depend on
B to be a ScaledIdMatrix. And operator+= would have to be
a member of FieldMatrix.
A better solution would be highly appreciated.
By the way, how can I write a cast which can only be called explicitly ?
Best regards
Carsten
> I have a few comments on this patch.
>
> On Mon, Jul 28, 2008 at 09:49:55AM +0200, sander at dune-project.org wrote:
>> Modified:
>> trunk/istl/scaledidmatrix.hh
>> Log:
>> - Disable operator K
>> - add cast to FieldMatrix
>> - add operator[]
>
> This cast operator returns a value in contrast to a pointer or
> reference or just a copy of internal data.
>
> One usually assumes that no temporaries are created when using
> type conversion operators. In contrast now memory is allocated on the
> stack each time the type conversion occurs.
> The type conversion operator makes it possible to call all methods
> for a FiedMatrix with a ScaledIdMatrix. Resulting in programs being slower
> with ScaledIdMatrix than when using FieldMatrix. This might come as a
> surprise to users.
>
> Why and where is this operator needed? What about making it explicit?
--
----------------------------------------------------------------------
Carsten Gräser | phone: +49-30 / 838-75349
Freie Universität Berlin | fax : +49-30 / 838-54977
Institut für Mathematik | email: graeser at math.fu-berlin.de
Arnimallee 6 |
14195 Berlin, Germany | URL : http://page.mi.fu-berlin.de/graeser
----------------------------------------------------------------------
More information about the Dune
mailing list