[dune-functions] [Dune-functions-commit] [Commit] dune-functions - c7b3989: Resize must now be done manually before interpolate()

Carsten Gräser graeser at mi.fu-berlin.de
Tue Sep 15 01:28:29 CEST 2015


OK, here's a proposal to allow nested vectors while keeping
simple things simple:

a)We derive MultiIndex<class size_type, size_type i> from e.g.
  array and implement the cast to size_type for i=1.
b)The result of basis.size() without prefix is no longer
  the same as the one with an empty prefix, but an object
  providing operator()(Prefix) and a cast to size_type.
  In the trivial case the result of this cast should be
  either the same as for an empty prefix or as dimension.

Then we can use a simple vector if the index is flat
or a wrapped hierarchic one in other cases.

Carsten

Am 15.09.2015 um 00:49 schrieb Carsten Gräser:
> Hi Oliver,
> 
> Am 14.09.2015 um 22:55 schrieb Carsten Gräser:
> [...]
>>> ... which is kind-of ugly, as a matter of fact.  I keep thinking that maybe
>>> we should replace array<size_t,1> by size_t whenever that appears as
>>> a multi-index.
>> But this would mean to teach users things that will not work
>> in general. Even worse you cannot write code that works in both,
>> the simple and not so simple cases. If you really think it's so ugly
>> we may consider to derive from array and add a cast to size_t
>> in the simple case. However I'd prefer to hide the complicated
>> multiindex stuff in a simple wrapper (that's the backend) that
>> can also be explained easily.
>>
>> Best,
>> Carsten
>>
>>>> Maybe a cleaner solution would be, to provide some kind of vector
>>>> adaptor providing operator()(MultiIndex) and a hierachic resize.
>>>> Then we would write
>>>>
>>>>   SomeVector v;
>>>>   auto&& v_coeff = basisCoefficients(v, basis);
>>>>   v_coeff.resize();
>>>>   interpolate(v_coeff, treePath, f);
>>>>
>>>> This would also allow to exchange the now hard wired backend
>>>> more easily.
>>> Possibly.
> if this is implemented as operator[] instead and the cast proposed
> above is also implemented it has the nice side effect, that we can
> (almost) use a flat vector in simple cases and a wrapped one in the
> complicated ones. It's only 'almost', because we have to write
> 
>   v.resize(basis.size());
> 
> in the simple case, whereas we need something like
> 
>   v.resize(basis);
> 
> in the complicated ones. If we change the interface of basis.size()
> without prefix to return some object that provides all size information
> we can even get around this.
> 
> Best,
> Carsten
> 
> 
> 
>>>
>>> Best,
>>> Oliver
>>>
>>>> Best,
>>>> Carsten
>>
>>
>>
>> _______________________________________________
>> dune-functions mailing list
>> dune-functions at dune-project.org
>> http://lists.dune-project.org/mailman/listinfo/dune-functions
>>
> 
> 
> 
> 
> _______________________________________________
> dune-functions mailing list
> dune-functions at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune-functions
> 


-- 
Prof. Dr. Carsten Gräser
Freie Universität Berlin
Institut für Mathematik
Arnimallee 6
14195 Berlin, Germany
phone: +49 30 838 72637
fax  : +49 30 838 472637
email: graeser at mi.fu-berlin.de
URL  : http://page.mi.fu-berlin.de/graeser

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.dune-project.org/pipermail/dune-functions/attachments/20150915/12477719/attachment.sig>


More information about the dune-functions mailing list