Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jakub.both/dune-common
  • samuel.burbulla/dune-common
  • patrick.jaap/dune-common
  • tobias.leibner/dune-common
  • alexander.mueller/dune-common
  • pipping/dune-common
  • Xinyun.Li/dune-common
  • felix.schindler/dune-common
  • simon.praetorius/dune-common
  • ani.anciaux-sedrakian/dune-common
  • henrik.stolzmann/dune-common
  • matthew.t.collins/dune-common
  • liam.keegan/dune-common
  • felix.mueller/dune-common
  • ansgar/dune-common
  • dominic/dune-common
  • lars.lubkoll/dune-common
  • exadune/dune-common
  • felix.gruber/dune-common
  • govind.sahai/dune-common
  • michael.sghaier/dune-common
  • core/dune-common
  • kilian.weishaupt/dune-common
  • markus.blatt/dune-common
  • joscha.podlesny/dune-common
  • tobias.meyer.andersen/dune-common
  • andreas.thune/dune-common
  • lars.bilke/dune-common
  • daniel.kienle/dune-common
  • lukas.renelt/dune-common
  • smuething/dune-common
  • stephan.hilb/dune-common
  • tkoch/dune-common
  • nils.dreier/dune-common
  • rene.milk/dune-common
  • lasse.hinrichsen/dune-common
  • yunus.sevinchan/dune-common
  • lisa_julia.nebel/dune-common
  • claus-justus.heine/dune-common
  • lorenzo.cerrone/dune-common
  • eduardo.bueno/dune-common
41 results
Show changes
Commits on Source (17)
  • Santiago Ospina De Los Ríos's avatar
    Move include of config.h from source to header · a6966c99
    Santiago Ospina De Los Ríos authored and Simon Praetorius's avatar Simon Praetorius committed
    a6966c99
  • Simon Praetorius's avatar
    Add explanation for config.h include · 3c0897c3
    Simon Praetorius authored
    3c0897c3
  • Simon Praetorius's avatar
    add config header in python module · 04b31440
    Simon Praetorius authored
    04b31440
  • Andreas Dedner's avatar
    [python] move to pybind11 2.12.0 · ce66d16b
    Andreas Dedner authored
    ce66d16b
  • Carsten Gräser's avatar
    Introduce new class IteratorFacade · 604c7636
    Carsten Gräser authored
    The new CRTP-mixin class `IteratorFacade` is parameterized
    by implementation, iterator category, `value_type`, `reference`,
    `pointer`, and `difference_type`. Discussion of the changes:
    
    * Making the iterator category a template parameter, allows to
      work with the facades class in a more uniform way. E.g.
      comparisons only need to be defined once for all categories.
    * Being able to customize `pointer` allows to use the facade
      classes for proxy-iterators. This was not possible before,
      because it is not sufficient to simply exchange the `reference`
      type to support proxies.
    * The design is in line with the `std::iterator_interface`
      proposal, in the sense that the template parameters have
      the same order to avoid surprises. Notice however, that
      this is not a drop-in replacement because
      `srd::iterator_interface` avoids classic CRTP by deducing `this`.
    * Additionally to the old facade classes, `IteratorFacade`
      also allows to implement the raw analouges of the
      methods used in the old classes, i.e.
      * `operator*` instead of `dereference()`,
      * `operator++` instead of `increment()`,
      * `operator--` instead of `decrement()`,
      * `operator+=` instead of `advance()`,
      * `operator==` instead of `equals()`,
      * `operator- instead of `distanceTo()`.
    * If the implementation class provides a `baseIterator()`
      method returning an underlying internal iterator, the
      operators of the returned iterator will be used if not
      dedicated implementation is provided.
    
    A major consequence of this change is, that it allows to
    use the new `IteratorFacade` for proxy-iterators,
    like e.g. `TransformedRangeIterator`.
    In this case you have to specify a suitable proxy-type for
    the pointer. In this case the new helper `Dune::ProxyArrowResult` can
    be used. This was adopted from the `TransformedRangeIterator`, but
    the name was adjusted to the `std::iterator_interface` proposal.
    604c7636
  • Carsten Gräser's avatar
    [test] Add check of new IteratorFacade · 3c903f3d
    Carsten Gräser authored
    3c903f3d
  • Carsten Gräser's avatar
    4c1066d8
  • Carsten Gräser's avatar
    Implement TransformedRangeIterator using IteratorFacade · 9ac6cb1f
    Carsten Gräser authored
    This comes with a slight change: The old helper
    `Dune::Impl::PointerProxy` was dropped in favor of the new
    `Dune::ProxyArrowResult`. The latter no longer supports storing
    raw references. This change is deliberately: In the no-proxy
    case, we can simply use raw pointers instead of the helper
    to avoid indirection and keep simple cases simple.
    
    Furthermore it this make `TransformedRangeIterator` simpler
    and allows to make it more flexible:
    
    * All iterator operations despite dereferencing
      are now autogenerated, by exporting `baseIterator()`.
    * Allow to either store a function or a pointer to function.
      The transformation is evaluated conditionally, if a call
      `f(z)` is valid, this is used, else `(*f)(z)` is used.
    * Use `Dune::AutonomousValue` instead of `std::decay_t`
      to deduce `value_type`. This improves support for types
      using this mechanism.
    * Store `reference` instead of `value_type` in `ProxyArrowResult`.
      This is important if both types are different and the `reference`
      proxy e.g. forwards to some other storage.
    * Add checks for free `TransformedRangeIterator` storing functions
      with value and pointer semantics.
    9ac6cb1f
  • Carsten Gräser's avatar
  • Carsten Gräser's avatar
  • Carsten Gräser's avatar
  • Simon Praetorius's avatar
    Merge branch 'feature/move-config-h-to-headers' into 'master' · 20eb0c9e
    Simon Praetorius authored
    Move include of config.h from source to some header files
    
    See merge request !1313
    20eb0c9e
  • Carsten Gräser's avatar
    Improve static diagnostics for IteratorFacade · b356d377
    Carsten Gräser authored
    We now give detailed error messages for each required feature
    that is missing in the derived class. To get early diagnotics
    the static assertions are even issued in the constructor even
    if the corresponding methods are not called. I.e. whenever
    you derive from `IteratorFacade<...>` and miss to implement
    a feature a static assertion will fail listing which methods
    are missing, if they should be const or mutable, for which
    iterator category they are required.
    
    To make this work from the constructor we have to enforce
    instanciation of the methods by letting their return type deduce.
    Otherwise this would fail late, only if the corresponding
    method is used. Alternatively we could enforce instanciation
    by obtaining the address of the methods in the constructor.
    This however would be over-restrictive, since it fixes
    the full signature and does not leave freedom for automatic
    conversion of in- and output parameters.
    b356d377
  • Simon Praetorius's avatar
  • Simon Praetorius's avatar
    Merge branch 'revert/move-config-h-to-headers-python' into 'master' · 5e843d96
    Simon Praetorius authored
    Revert changes to python-bindings from "Move include of config.h from source to some header files"
    
    See merge request !1402
    5e843d96
  • Carsten Gräser's avatar
    Merge branch 'feature/iterator-facades-proxy-support' into 'master' · baba6e63
    Carsten Gräser authored
    Introduce new class IteratorFacade and add proxy iterator support
    
    See merge request !1396
    baba6e63
  • Andreas Dedner's avatar
    Merge branch 'feature/newPybind11' into 'master' · 1a5d581f
    Andreas Dedner authored
    [python] move to pybind11 2.12.0
    
    See merge request !1393
    1a5d581f
Showing
with 753 additions and 262 deletions
......@@ -15,6 +15,12 @@ In order to build the DUNE core modules you need at least the following software
## Changelog
- There is a new base class `IteratorFacade` that unifies `ForwardIteratorFacade`,
`BidirectionalIteratorFacade`, `RandomAccessIteratorFacade` by making the iterator
category a template. Furthermore the new `IteratorFacade` class allows to specify
a `pointer` type other than `value_type*` to support proxy-iterators.
The old facade classes remain unchanged for backward compatibility reasons.
- Add utilities `Std::span`, `Std::mdspan`, `Std::mdarray` and all its related classes into the `Dune::Std` namespace
for working with multidimensional arrays. See core/dune-common!1334 for further details.
......
......@@ -2,9 +2,6 @@
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#include <config.h>
#include <cstddef>
#include <cstdlib>
#include <functional>
......
......@@ -2,9 +2,6 @@
// vi: set et ts=4 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "debugallocator.hh"
......
......@@ -8,6 +8,8 @@
#include <algorithm>
#include <memory>
#include <dune-common-config.hh> // HAVE_LAPACK
#include "dynmatrix.hh"
#include "fmatrixev.hh"
......
......@@ -5,15 +5,14 @@
#ifndef DUNE_FMATRIXEIGENVALUES_CC
#define DUNE_FMATRIXEIGENVALUES_CC
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream>
#include <cmath>
#include <cassert>
#include <dune-common-config.hh> // HAVE_LAPACK, LAPACK_NEEDS_UNDERLINE
#include <dune/common/exceptions.hh>
#include <dune/common/fmatrixev.hh>
#if HAVE_LAPACK
......
......@@ -14,6 +14,7 @@
#include <cmath>
#include <cassert>
#include <dune-common-config.hh> // HAVE_LAPACK
#include <dune/common/exceptions.hh>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
......
......@@ -3,10 +3,6 @@
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <dune/common/ios_state.hh>
namespace Dune {
......
This diff is collapsed.
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#include <config.h>
#include <cassert>
#include <iostream>
#include <vector>
......
......@@ -3,10 +3,6 @@
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <cstdlib>
#include <iostream>
#include <ostream>
......
......@@ -3,10 +3,6 @@
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include "parametertreeparser.hh"
#include <cstdlib>
......
......@@ -3,10 +3,6 @@
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <algorithm>
#include <iterator>
#include <string>
......
......@@ -5,12 +5,14 @@
#ifndef DUNE_COMMON_RANGE_UTILITIES_HH
#define DUNE_COMMON_RANGE_UTILITIES_HH
#include <dune/common/typetraits.hh>
#include <algorithm>
#include <utility>
#include <type_traits>
#include <bitset>
#include <dune/common/typetraits.hh>
#include <dune/common/iteratorfacades.hh>
/**
* \file
*
......@@ -333,57 +335,84 @@ namespace Dune
namespace Impl
{
// Helper class to mimic a pointer for proxy objects.
// This is needed to implement operator-> on an iterator
// using proxy-values. It stores the proxy value but
// provides operator-> like a pointer.
template<class ProxyType>
class PointerProxy
{
public:
PointerProxy(ProxyType&& p) : p_(p)
{}
std::add_pointer_t<ProxyType> operator->()
{
return &p_;
}
ProxyType p_;
};
// An iterator transforming a wrapped iterator using
// an unary function. It inherits the iterator-category
// of the underlying iterator.
template <class I, class F, class TransformationType, class C = typename std::iterator_traits<I>::iterator_category>
//
// \tparam I Type of the underlying iterator
// \tparam F Type of transformation function that can either be applied directly or after dereferencing
// \tparam TT Type of transformation (ValueTransformationTag or IteratorTransformationTag)
// \tparam C An iterator category tag, defaults to the one of I
template <class I, class F, class TT, class C = typename std::iterator_traits<I>::iterator_category>
class TransformedRangeIterator;
template <class I, class F, class TransformationType>
class TransformedRangeIterator<I,F,TransformationType,std::forward_iterator_tag>
template<class I, class F, class TT, class C>
struct TransformationRangeIteratorTraits
{
protected:
template<class FF>
static decltype(auto) transform(FF&& f, const I& it) {
if constexpr (std::is_same_v<TransformationType,IteratorTransformationTag>)
return f(it);
if constexpr (std::is_same_v<TT,IteratorTransformationTag>)
{
if constexpr (Dune::IsCallable<FF(const I&)>::value)
return f(it);
else
return (*f)(it);
}
else
return f(*it);
{
if constexpr (Dune::IsCallable<FF(decltype(*it))>::value)
return f(*it);
else
return (*f)(*it);
}
}
using reference = decltype(transform(std::declval<F>(), std::declval<I>()));
using value_type = Dune::AutonomousValue<reference>;
using pointer = std::conditional_t<std::is_lvalue_reference_v<reference>, value_type*, ProxyArrowResult<reference>>;
using difference_type = typename std::iterator_traits<I>::difference_type;
using Facade = Dune::IteratorFacade<TransformedRangeIterator<I,F,TT,C>, C, value_type, reference, pointer, difference_type>;
};
template <class I, class F, class TT, class C>
class TransformedRangeIterator :
public TransformationRangeIteratorTraits<I,F, TT, C>::Facade
{
using Traits = TransformationRangeIteratorTraits<I,F, TT, C>;
using Facade = typename Traits::Facade;
static constexpr bool isBidirectional = std::is_convertible_v<C, std::bidirectional_iterator_tag>;
static constexpr bool isRandomAccess = std::is_convertible_v<C, std::random_access_iterator_tag>;
public:
using iterator_category = std::forward_iterator_tag;
using reference = decltype(transform(*std::declval<F>(), std::declval<I>()));
using value_type = std::decay_t<reference>;
using pointer = PointerProxy<reference>;
// The template parameter F should be pointer like since it
// will always be accessed using unary operator*.
using FunctionPointer = F;
constexpr TransformedRangeIterator(const I& it, FunctionPointer f) noexcept :
it_(it),
f_(f)
using Function = F;
using reference = typename Facade::reference;
using difference_type = typename Facade::difference_type;
template<class II, class FF>
constexpr TransformedRangeIterator(II&& it, FF&& f) noexcept :
it_(std::forward<II>(it)),
f_(std::forward<FF>(f))
{}
template<class II,
disableCopyMove<TransformedRangeIterator,II> =0,
std::enable_if_t<std::is_convertible_v<II, I> and std::is_default_constructible_v<F>, int> =0>
constexpr TransformedRangeIterator(II&& it) noexcept :
it_(std::forward<II>(it)),
f_()
{}
template<class FF,
disableCopyMove<TransformedRangeIterator,FF> =0,
std::enable_if_t<std::is_convertible_v<FF, F> and std::is_default_constructible_v<I>, int> =0>
constexpr TransformedRangeIterator(FF&& f) noexcept :
it_(),
f_(std::forward<FF>(f))
{}
// Explicitly initialize members. Using a plain
......@@ -405,193 +434,28 @@ namespace Dune
// Dereferencing returns a value created by the function
constexpr reference operator*() const noexcept {
return transform(*f_, it_);
}
// Dereferencing returns a value created by the function
pointer operator->() const noexcept {
return transform(*f_, it_);
}
constexpr TransformedRangeIterator& operator=(const TransformedRangeIterator& other) = default;
constexpr bool operator==(const TransformedRangeIterator& other) const noexcept {
return (it_ == other.it_);
}
constexpr bool operator!=(const TransformedRangeIterator& other) const noexcept {
return (it_ != other.it_);
}
TransformedRangeIterator& operator++() noexcept {
++it_;
return *this;
}
TransformedRangeIterator operator++(int) noexcept {
TransformedRangeIterator copy(*this);
++(*this);
return copy;
}
protected:
I it_;
FunctionPointer f_;
};
template <class I, class F, class T>
class TransformedRangeIterator<I,F,T,std::bidirectional_iterator_tag> :
public TransformedRangeIterator<I,F,T,std::forward_iterator_tag>
{
protected:
using Base = TransformedRangeIterator<I,F,T,std::forward_iterator_tag>;
using Base::it_;
using Base::f_;
public:
using iterator_category = std::bidirectional_iterator_tag;
using reference = typename Base::reference;
using value_type = typename Base::value_type;
using pointer = typename Base::pointer;
using FunctionPointer = typename Base::FunctionPointer;
using Base::Base;
// Member functions of the forward_iterator that need
// to be redefined because the base class methods return a
// forward_iterator.
constexpr TransformedRangeIterator& operator=(const TransformedRangeIterator& other) = default;
TransformedRangeIterator& operator++() noexcept {
++it_;
return *this;
}
TransformedRangeIterator operator++(int) noexcept {
TransformedRangeIterator copy(*this);
++(*this);
return copy;
}
// Additional member functions of bidirectional_iterator
TransformedRangeIterator& operator--() noexcept {
--(this->it_);
return *this;
}
TransformedRangeIterator operator--(int) noexcept {
TransformedRangeIterator copy(*this);
--(*this);
return copy;
return Traits::transform(f_, it_);
}
};
template <class I, class F, class T>
class TransformedRangeIterator<I,F,T,std::random_access_iterator_tag> :
public TransformedRangeIterator<I,F,T,std::bidirectional_iterator_tag>
{
protected:
using Base = TransformedRangeIterator<I,F,T,std::bidirectional_iterator_tag>;
using Base::it_;
using Base::f_;
public:
using iterator_category = std::random_access_iterator_tag;
using reference = typename Base::reference;
using value_type = typename Base::value_type;
using pointer = typename Base::pointer;
using difference_type = typename std::iterator_traits<I>::difference_type;
using FunctionPointer = typename Base::FunctionPointer;
using Base::Base;
// Member functions of the forward_iterator that need
// to be redefined because the base class methods return a
// forward_iterator.
constexpr TransformedRangeIterator& operator=(const TransformedRangeIterator& other) = default;
TransformedRangeIterator& operator++() noexcept {
++it_;
return *this;
}
TransformedRangeIterator operator++(int) noexcept {
TransformedRangeIterator copy(*this);
++(*this);
return copy;
}
friend class Dune::IteratorFacadeAccess;
// Member functions of the bidirectional_iterator that need
// to be redefined because the base class methods return a
// bidirectional_iterator.
TransformedRangeIterator& operator--() noexcept {
--(this->it_);
return *this;
// Export base iterator, such that equalilty comparison,
// differences, and inequality comparisons are automatically
// forwarded to the base iterator by the facade.
const I& baseIterator() const noexcept {
return it_;
}
TransformedRangeIterator operator--(int) noexcept {
TransformedRangeIterator copy(*this);
--(*this);
return copy;
I& baseIterator() noexcept {
return it_;
}
// Additional member functions of random_access_iterator
TransformedRangeIterator& operator+=(difference_type n) noexcept {
it_ += n;
return *this;
}
TransformedRangeIterator& operator-=(difference_type n) noexcept {
it_ -= n;
return *this;
}
bool operator<(const TransformedRangeIterator& other) const noexcept {
return it_<other.it_;
}
bool operator<=(const TransformedRangeIterator& other) const noexcept {
return it_<=other.it_;
}
bool operator>(const TransformedRangeIterator& other) const noexcept {
return it_>other.it_;
}
bool operator>=(const TransformedRangeIterator& other) const noexcept {
return it_>=other.it_;
}
reference operator[](difference_type n) noexcept {
return Base::transform(*f_, it_+n);
}
friend
TransformedRangeIterator operator+(const TransformedRangeIterator& it, difference_type n) noexcept {
return TransformedRangeIterator(it.it_+n, it.f_);
}
friend
TransformedRangeIterator operator+(difference_type n, const TransformedRangeIterator& it) noexcept {
return TransformedRangeIterator(n+it.it_, it.f_);
}
friend
TransformedRangeIterator operator-(const TransformedRangeIterator& it, difference_type n) noexcept {
return TransformedRangeIterator(it.it_-n, it.f_);
}
friend
difference_type operator-(const TransformedRangeIterator& first, const TransformedRangeIterator& second) noexcept {
return first.it_-second.it_;
}
I it_;
Function f_;
};
} // namespace Impl
......
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
#include <config.h>
#include <ostream>
#include <string>
......
......@@ -2,10 +2,6 @@
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// @GENERATED_SOURCE@
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <cstdlib>
#include <type_traits>
......
......@@ -2,8 +2,6 @@
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// @GENERATED_SOURCE@
#include <config.h>
#include <dune/common/simd/test/looptest.hh>
namespace Dune {
......
......@@ -2,10 +2,6 @@
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// @GENERATED_SOURCE@
#if HAVE_CONFIG_H
#include "config.h"
#endif
#include <cstdlib>
#include <type_traits>
......
......@@ -2,8 +2,6 @@
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// @GENERATED_SOURCE@
#include <config.h>
#include <dune/common/simd/test.hh>
#include <dune/common/simd/test/standardtest.hh>
......
......@@ -2,10 +2,6 @@
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// @GENERATED_SOURCE@
#if HAVE_CONFIG_H
#include "config.h"
#endif
#if !HAVE_VC
#error Inconsistent buildsystem. This program should not be built in the \
absence of Vc.
......
......@@ -2,8 +2,6 @@
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// @GENERATED_SOURCE@
#include <config.h>
#include <dune/common/simd/test/vcvectortest.hh>
namespace Dune {
......