Dune Core Modules (unstable)
Hybrid utility functions that work on homogeneous as well as heterogeneous containers. More...
Classes | |
class | Dune::Hybrid::HybridFunctor< Functor > |
Adapter of a hybrid functor that maintains results hybrid. More... | |
Functions | |
template<class T > | |
constexpr auto | Dune::Hybrid::size (const T &t) |
Size query. More... | |
template<class Container , class Index > | |
constexpr decltype(auto) | Dune::Hybrid::elementAt (Container &&c, Index &&i) |
Get element at given position from container. More... | |
template<class Begin , class End > | |
constexpr auto | Dune::Hybrid::integralRange (const Begin &begin, const End &end) |
Create an integral range. More... | |
template<class End > | |
constexpr auto | Dune::Hybrid::integralRange (const End &end) |
Create an integral range starting from 0. More... | |
template<class Range , class F > | |
constexpr void | Dune::Hybrid::forEach (Range &&range, F &&f) |
Range based for loop. More... | |
template<class Range , class T , class F > | |
constexpr T | Dune::Hybrid::accumulate (Range &&range, T value, F &&f) |
Accumulate values. More... | |
template<class Condition , class IfFunc , class ElseFunc > | |
decltype(auto) | Dune::Hybrid::ifElse (const Condition &condition, IfFunc &&ifFunc, ElseFunc &&elseFunc) |
A conditional expression. More... | |
template<class Condition , class IfFunc > | |
void | Dune::Hybrid::ifElse (const Condition &condition, IfFunc &&ifFunc) |
A conditional expression. More... | |
template<class... Args> | |
constexpr decltype(auto) | Dune::Hybrid::HybridFunctor< Functor >::operator() (const Args &... args) const |
Adapter of a hybrid functor that keeps results hybrid. More... | |
template<class T1 , class T2 > | |
constexpr auto | Dune::Hybrid::equals (T1 &&t1, T2 &&t2) |
Equality comparison. More... | |
template<class Cases , class Value , class Branches , class ElseBranch > | |
constexpr decltype(auto) | Dune::Hybrid::switchCases (const Cases &cases, const Value &value, Branches &&branches, ElseBranch &&elseBranch) |
Switch statement. More... | |
template<class Cases , class Value , class Branches > | |
constexpr void | Dune::Hybrid::switchCases (const Cases &cases, const Value &value, Branches &&branches) |
Switch statement. More... | |
template<class T , class Value , class Branches > | |
constexpr void | Dune::Hybrid::switchCases (IntegralRange< T > range, const Value &value, Branches &&branches) |
Switch statement. More... | |
Variables | |
constexpr auto | Dune::Hybrid::max = hybridFunctor(Impl::Max{}) |
Function object that returns the greater of the given values. More... | |
constexpr auto | Dune::Hybrid::min = hybridFunctor(Impl::Min{}) |
Function object that returns the smaller of the given values. More... | |
constexpr auto | Dune::Hybrid::plus = hybridFunctor(std::plus<>{}) |
Function object for performing addition. More... | |
constexpr auto | Dune::Hybrid::minus = hybridFunctor(std::minus<>{}) |
Function object for performing subtraction. More... | |
constexpr auto | Dune::Hybrid::equal_to = hybridFunctor(std::equal_to<>{}) |
Function object for performing equality comparison. More... | |
Detailed Description
Hybrid utility functions that work on homogeneous as well as heterogeneous containers.
Function Documentation
◆ accumulate()
|
constexpr |
Accumulate values.
- Template Parameters
-
Range Type of given range T Type of accumulated value F Type of binary accumulation operator
- Parameters
-
range The range of values to accumulate value Initial value for accumulation f Binary operator for accumulation
This supports looping over the same ranges as Hybrid::forEach
References Dune::Hybrid::forEach().
Referenced by Dune::BCRSMatrix< B, A >::nonzeroes(), Dune::MultiTypeBlockVector< Args >::one_norm(), Dune::MultiTypeBlockVector< Args >::one_norm_real(), Dune::BDFMCubeLocalBasis< D, R, 2, 1 >::partial(), Dune::BDFMCubeLocalBasis< D, R, 2, 2 >::partial(), Dune::BDFMCubeLocalBasis< D, R, 2, 3 >::partial(), Dune::BDM1Cube2DLocalBasis< D, R >::partial(), Dune::BDM1Simplex2DLocalBasis< D, R >::partial(), Dune::BDM2Cube2DLocalBasis< D, R >::partial(), Dune::BDM2Simplex2DLocalBasis< D, R >::partial(), Dune::HierarchicalSimplexP2LocalBasis< D, R, 2 >::partial(), Dune::RT02DLocalBasis< D, R >::partial(), Dune::RT0Cube2DLocalBasis< D, R >::partial(), Dune::RT12DLocalBasis< D, R >::partial(), Dune::RT1Cube2DLocalBasis< D, R >::partial(), Dune::RT2Cube2DLocalBasis< D, R >::partial(), Dune::RT3Cube2DLocalBasis< D, R >::partial(), Dune::RT4Cube2DLocalBasis< D, R >::partial(), Dune::RefinedP1LocalBasis< D, R, 2 >::partial(), Dune::BDM1Cube3DLocalBasis< D, R >::partial(), Dune::HierarchicalSimplexP2LocalBasis< D, R, 3 >::partial(), Dune::RT03DLocalBasis< D, R >::partial(), Dune::RT0Cube3DLocalBasis< D, R >::partial(), Dune::RT0PrismLocalBasis< D, R >::partial(), Dune::RT0PyramidLocalBasis< D, R >::partial(), Dune::RT1Cube3DLocalBasis< D, R >::partial(), Dune::RefinedP1LocalBasis< D, R, 3 >::partial(), Dune::PowerBasis< Backend, dimR >::partial(), Dune::P0LocalBasis< D, R, d >::partial(), Dune::EdgeS0_5Basis< Geometry, RF >::partial(), Dune::DualP1LocalBasis< D, R, dim, faceDualT >::partial(), Dune::DualQ1LocalBasis< D, R, dim >::partial(), Dune::RefinedP0LocalBasis< D, R, dim >::partial(), Dune::PolynomialBasis< Eval, CM, D, R >::partial(), and Dune::MultiTypeBlockVector< Args >::two_norm2().
◆ elementAt()
|
constexpr |
Get element at given position from container.
- Template Parameters
-
Container Type of given container Index Type of index
- Parameters
-
c Given container i Index of element to obtain
- Returns
- The element at position i, i.e. c[i]
If this returns the i-th entry of c. It supports the following containers
- Containers providing dynamic access via operator[]
- Heterogeneous containers providing access via operator[](integral_constant<...>)
- std::tuple<...>
- std::integer_sequence
References Dune::Hybrid::elementAt().
Referenced by Dune::Hybrid::elementAt(), Dune::RandomAccessIteratorFacade< T, V, R, D >::operator[](), and Dune::ArrayList< T, N, A >::operator[]().
◆ equals()
|
constexpr |
Equality comparison.
If both types have a static member value, the result of comparing these is returned as std::integral_constant<bool, *>. Otherwise the result of a runtime comparison of t1 and t2 is directly returned.
References Dune::Hybrid::equal_to.
Referenced by Dune::BitSetVectorConstReference< block_size, Alloc >::operator!=(), Dune::operator!=(), Dune::BitSetVectorConstReference< block_size, Alloc >::operator==(), and Dune::operator==().
◆ forEach()
|
constexpr |
Range based for loop.
- Template Parameters
-
Range Type of given range F Type of given predicate
- Parameters
-
range The range to loop over f A predicate that will be called with each entry of the range
This supports looping over the following ranges
- ranges obtained from integralRange()
- all ranges that provide Hybrid::size() and Hybrid::elementAt()
This especially included instances of std::integer_sequence, std::tuple, Dune::TupleVector, and Dune::MultiTypeBlockVector.
References Dune::Hybrid::forEach().
Referenced by Dune::Hybrid::accumulate(), Dune::MultiTypeBlockVector< Args >::axpy(), Dune::MultiTypeBlockVector< Args >::dim(), Dune::fillGridViewInfoSerial(), Dune::flatVectorForEach(), Dune::Hybrid::forEach(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::frobenius_norm2(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm(), Dune::MultiTypeBlockVector< Args >::infinity_norm(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm_real(), Dune::MultiTypeBlockVector< Args >::infinity_norm_real(), Dune::LocalFiniteElementVariantCache< Base >::LocalFiniteElementVariantCache(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator*=(), Dune::MultiTypeBlockVector< Args >::operator*=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator+=(), Dune::MultiTypeBlockVector< Args >::operator+=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator-=(), Dune::MultiTypeBlockVector< Args >::operator-=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator/=(), Dune::MultiTypeBlockVector< Args >::operator/=(), Dune::operator<<(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator=(), Dune::MultiTypeBlockVector< Args >::operator=(), Dune::operator>>(), and Dune::SizeCache< GridImp >::size().
◆ ifElse() [1/2]
void Dune::Hybrid::ifElse | ( | const Condition & | condition, |
IfFunc && | ifFunc | ||
) |
A conditional expression.
This provides an ifElse conditional with empty else clause.
References Dune::Hybrid::ifElse().
Referenced by Dune::Hybrid::ifElse().
◆ ifElse() [2/2]
decltype(auto) Dune::Hybrid::ifElse | ( | const Condition & | condition, |
IfFunc && | ifFunc, | ||
ElseFunc && | elseFunc | ||
) |
A conditional expression.
This will call either ifFunc or elseFunc depending on the condition. In any case a single argument will be passed to the called function. This will always be the identity function. Passing an expression through this function will lead to lazy evaluation. This way both 'branches' can contain expressions that are only valid within this branch if the condition is a std::integral_constant<bool,*>.
In order to do this, the passed functors must have a single argument of type auto.
Due to the lazy evaluation mechanism and support for std::integral_constant<bool,*> this allows to emulate a static if statement.
References Dune::Hybrid::ifElse().
◆ integralRange() [1/2]
|
constexpr |
Create an integral range.
- Template Parameters
-
Begin Type of begin entry of the range End Type of end entry of the range
- Parameters
-
begin First entry of the range end One past the last entry of the range
- Returns
- An object encoding the given range
If Begin and End are both instances of type std::integral_constant, the returned range encodes begin and end statically.
References Dune::Hybrid::integralRange().
Referenced by Dune::MultiTypeBlockVector< Args >::axpy(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::frobenius_norm2(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm_real(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator*=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator+=(), Dune::MultiTypeBlockVector< Args >::operator+=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator-=(), Dune::MultiTypeBlockVector< Args >::operator-=(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator/=(), Dune::operator<<(), and Dune::MultiTypeBlockMatrix< FirstRow, Args >::operator=().
◆ integralRange() [2/2]
|
constexpr |
Create an integral range starting from 0.
- Template Parameters
-
End Type of end entry of the range
- Parameters
-
end One past the last entry of the range
- Returns
- An object encoding the given range
This is a short cut for integralRange(_0, end).
References Dune::Indices::_0, and Dune::Hybrid::integralRange().
Referenced by Dune::Hybrid::integralRange().
◆ operator()()
|
inlineconstexpr |
Adapter of a hybrid functor that keeps results hybrid.
Implements an operator that promotes the results of the underlying functor to an integral constant if all the function arguments are integral constants, otherwise, usual promotion rules apply.
◆ size()
|
constexpr |
Size query.
- Template Parameters
-
T Type of container whose size is queried
- Parameters
-
t Container whose size is queried
- Returns
- Size of t
If the size of t is known at compile type the size is returned as std::integral_constant<std::size_t, size>. Otherwise the result of t.size() is returned.
Supported types for deriving the size at compile time are:
- instances of std::integer_sequence
- all types std::tuple_size is implemented for
- all types that have a static constexpr method size() The latter e.g. includes Dune::FieldVector
References Dune::Hybrid::size().
Referenced by Dune::Hybrid::size().
◆ switchCases() [1/3]
|
constexpr |
Switch statement.
- Template Parameters
-
Cases Type of case range Value Type of value to check against the cases Branches Type of branch function
- Parameters
-
cases A range of cases to check for value The value to check against the cases branches A callback that will be executed with matching entry from case list
Value is checked against all entries of the given range. If one matches, then branches is executed with the matching value as single argument. If the range is an std::integer_sequence, or StaticIntegralRange, the value is passed as std::integral_constant. If non of the entries matches, the behavior is undefined.
◆ switchCases() [2/3]
|
constexpr |
Switch statement.
- Template Parameters
-
Cases Type of case range Value Type of value to check against the cases Branches Type of branch function ElseBranch Type of branch function
- Parameters
-
cases A range of cases to check for value The value to check against the cases branches A callback that will be executed with matching entry from case list elseBranch A callback that will be executed if no other entry matches
Value is checked against all entries of the given range. If one matches, then branches is executed with the matching value as single argument. If the range is an std::integer_sequence, or StaticIntegralRange, the value is passed as std::integral_constant. If non of the entries matches, then elseBranch is executed without any argument.
Notice that this short circuits, e.g., if one case matches, the others are no longer evaluated.
The return value will be deduced from the else branch.
◆ switchCases() [3/3]
|
constexpr |
Switch statement.
- Template Parameters
-
T The type of the cases Value Type of value to check against the cases Branches Type of branch function
- Parameters
-
range A dynamic range of cases to check for value The value to check against the cases branches A callback that will be executed with matching entry from case list
This overload of the switchCases
utility is selected if the range of cases is passed as an IntegralRange
. If the value
is contained in that range
, it is passed as single argument to the callback branches
. If not, the behavior is undefined.
References Dune::IntegralRange< T >::contains().
Variable Documentation
◆ equal_to
|
inlineconstexpr |
Function object for performing equality comparison.
- See also
- HybridFunctor
If both arguments have a static member value, the result of comparing these for equality is returned as std::integral_constant<bool, *>. Otherwise the result of a comparison of the two arguments is directly returned.
Referenced by Dune::Hybrid::equals().
◆ max
|
inlineconstexpr |
Function object that returns the greater of the given values.
- See also
- HybridFunctor
If all arguments have a static member value, the maximum value of these is returned as std::integral_constant<*, *>. Otherwise the result of a direct max of the arguments is returned.
Referenced by Dune::Cholmod< Vector, Index >::apply(), checkElementDataMapper(), checkMixedDataMapper(), checkVertexDataMapper(), Dune::fillGridViewInfoSerial(), Dune::Amg::MatrixHierarchy< M, PI, A >::getCoarsestAggregatesOnFinest(), Dune::DenseMatrix< MAT >::infinity_norm(), Dune::DenseVector< V >::infinity_norm(), Dune::BCRSMatrix< B, A >::infinity_norm(), Dune::Matrix< T, A >::infinity_norm(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm(), Dune::MultiTypeBlockVector< Args >::infinity_norm(), Dune::DenseMatrix< MAT >::infinity_norm_real(), Dune::DenseVector< V >::infinity_norm_real(), Dune::BCRSMatrix< B, A >::infinity_norm_real(), Dune::Matrix< T, A >::infinity_norm_real(), Dune::MultiTypeBlockMatrix< FirstRow, Args >::infinity_norm_real(), Dune::MultiTypeBlockVector< Args >::infinity_norm_real(), Dune::BDFMCubeLocalInterpolation< D, R, dim, order >::interior(), Dune::YGridComponent< Coordinates >::intersection(), Dune::MultiLinearGeometry< ct, mydim, cdim, Traits >::LocalCoordinate(), Dune::YaspGrid< dim, Coordinates >::mark(), and Dune::IndicesSyncer< T >::DefaultNumberer::operator()().
◆ min
|
inlineconstexpr |
Function object that returns the smaller of the given values.
- See also
- HybridFunctor
If all arguments have a static member value, the minimum value of these is returned as std::integral_constant<*, *>. Otherwise the result of a direct min of the arguments is returned.
Referenced by Dune::GeneralizedPCGSolver< X >::apply(), Dune::RestartedFCGSolver< X >::apply(), checkElementDataMapper(), checkMixedDataMapper(), checkVertexDataMapper(), Dune::fillGridViewInfoSerial(), Dune::DenseVector< V >::find(), Dune::MatrixImp::DenseMatrixBase< B, A >::find(), Dune::VariableBlockVector< B, A >::find(), Dune::YGridComponent< Coordinates >::intersection(), Dune::ReservedVector< T, n >::operator<(), Dune::SubsamplingVTKWriter< GridView >::writeGridPoints(), Dune::VTKWriter< GridView >::writeGridPoints(), and Dune::YaspHierarchicIterator< GridImp >::YaspHierarchicIterator().
◆ minus
|
inlineconstexpr |
Function object for performing subtraction.
- See also
- HybridFunctor
If all arguments have a static member value, the subtracted value of these is returned as std::integral_constant<*, *>. Otherwise the result of a direct subtraction of the arguments is returned.
◆ plus
|
inlineconstexpr |
Function object for performing addition.
- See also
- HybridFunctor
If all arguments have a static member value, the added value of these is returned as std::integral_constant<*, *>. Otherwise the result of a direct addition of the arguments is returned.