Dune Core Modules (2.8.0)

Hybrid Utilities

Hybrid utility functions that work on homogeneous as well as heterogeneous containers. 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 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...
 

Detailed Description

Hybrid utility functions that work on homogeneous as well as heterogeneous containers.

Function Documentation

◆ accumulate()

template<class Range , class T , class F >
constexpr T Dune::Hybrid::accumulate ( Range &&  range,
value,
F &&  f 
)
constexpr

Accumulate values.

Template Parameters
RangeType of given range
TType of accumulated value
FType of binary accumulation operator
Parameters
rangeThe range of values to accumulate
valueInitial value for accumulation
fBinary operator for accumulation

This supports looping over the same ranges as Hybrid::forEach

References Dune::Hybrid::forEach().

Referenced by Dune::Functions::BSplinePreBasis< GV, MI >::BSplinePreBasis(), 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::HierarchicalSimplexP2WithElementBubbleLocalBasis< 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::HierarchicalSimplexP2WithElementBubbleLocalBasis< D, R, 3 >::partial(), Dune::RT03DLocalBasis< D, R >::partial(), Dune::RT0Cube3DLocalBasis< 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(), Dune::Functions::BSplineLocalCoefficients< dim >::size(), and Dune::MultiTypeBlockVector< Args >::two_norm2().

◆ elementAt()

template<class Container , class Index >
constexpr decltype(auto) Dune::Hybrid::elementAt ( Container &&  c,
Index &&  i 
)
constexpr

Get element at given position from container.

Template Parameters
ContainerType of given container
IndexType of index
Parameters
cGiven container
iIndex 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()

template<class T1 , class T2 >
constexpr auto Dune::Hybrid::equals ( T1 &&  t1,
T2 &&  t2 
)
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::equals().

Referenced by Dune::Hybrid::equals(), Dune::BitSetVectorConstReference< block_size, Alloc >::operator!=(), Dune::operator!=(), Dune::BitSetVectorConstReference< block_size, Alloc >::operator==(), and Dune::operator==().

◆ forEach()

template<class Range , class F >
constexpr void Dune::Hybrid::forEach ( Range &&  range,
F &&  f 
)
constexpr

Range based for loop.

Template Parameters
RangeType of given range
FType of given predicate
Parameters
rangeThe range to loop over
fA predicate that will be called with each entry of the range

This supports looping over the following ranges

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::Functions::CompositePreBasis< MI, IMS, SPB >::CompositePreBasis(), Dune::MultiTypeBlockVector< Args >::dim(), Dune::Functions::CompositePreBasis< MI, IMS, SPB >::dimension(), Dune::TypeTree::HybridTreePath< T >::element(), 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::Functions::CompositePreBasis< MI, IMS, SPB >::initializeIndices(), Dune::LocalFiniteElementVariantCache< Base >::LocalFiniteElementVariantCache(), Dune::Functions::CompositePreBasis< MI, IMS, SPB >::makeNode(), Dune::Functions::CompositePreBasis< MI, IMS, SPB >::maxNodeSize(), 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>>(), Dune::TypeTree::HybridTreePath< T >::operator[](), Dune::SizeCache< GridImp >::size(), and Dune::Functions::CompositePreBasis< MI, IMS, SPB >::update().

◆ ifElse() [1/2]

template<class Condition , class IfFunc >
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]

template<class Condition , class IfFunc , class ElseFunc >
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]

template<class Begin , class End >
constexpr auto Dune::Hybrid::integralRange ( const Begin &  begin,
const End &  end 
)
constexpr

◆ integralRange() [2/2]

template<class End >
constexpr auto Dune::Hybrid::integralRange ( const End &  end)
constexpr

Create an integral range starting from 0.

Template Parameters
EndType of end entry of the range
Parameters
endOne 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().

◆ size()

template<class T >
constexpr auto Dune::Hybrid::size ( const T &  t)
constexpr

Size query.

Template Parameters
TType of container whose size is queried
Parameters
tContainer 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 typed that have a static method size()
  • instances of Dune::FieldVector

References Dune::Hybrid::size().

Referenced by Dune::Hybrid::size().

◆ switchCases() [1/2]

template<class Cases , class Value , class Branches >
constexpr void Dune::Hybrid::switchCases ( const Cases &  cases,
const Value &  value,
Branches &&  branches 
)
constexpr

Switch statement.

Template Parameters
CasesType of case range
ValueType of value to check against the cases
BranchesType of branch function
Parameters
casesA range of cases to check for
valueThe value to check against the cases
branchesA 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, the value is passed as std::integral_constant. If non of the entries matches, then elseBranch is executed without any argument.

◆ switchCases() [2/2]

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 
)
constexpr

Switch statement.

Template Parameters
CasesType of case range
ValueType of value to check against the cases
BranchesType of branch function
ElseBranchType of branch function
Parameters
casesA range of cases to check for
valueThe value to check against the cases
branchesA callback that will be executed with matching entry from case list
elseBranchA 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, 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.

Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)