Dune Core Modules (2.9.0)

functionfromcallable.hh
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_FUNCTIONS_COMMON_FUNCTION_FROM_CALLABLE_HH
4 #define DUNE_FUNCTIONS_COMMON_FUNCTION_FROM_CALLABLE_HH
5 
7 
8 #include <dune/functions/common/signature.hh>
9 
10 
11 namespace Dune {
12 namespace Functions {
13 
14 
15 
16 template<class Signature, class F,
17  class FunctionInterface = typename Dune::VirtualFunction<
18  typename SignatureTraits<Signature>::RawDomain,
19  typename SignatureTraits<Signature>::RawRange> >
20 class FunctionFromCallable;
21 
37 template<class Range, class Domain, class F, class FunctionInterface>
38 class FunctionFromCallable<Range(Domain), F, FunctionInterface> :
39  public FunctionInterface
40 {
41 public:
42 
53  f_(f)
54  {}
55 
64  FunctionFromCallable(const F& f) :
65  f_(f)
66  {}
67 
73  void evaluate(const Domain& x, Range&y) const
74  {
75  y = f_(x);
76  }
77 
78 private:
79  F f_;
80 };
81 
82 
83 
84 } // namespace Functions
85 } // namespace Dune
86 
87 #endif //DUNE_FUNCTIONS_COMMON_FUNCTION_FROM_CALLABLE_HH
FunctionFromCallable(F &&f)
Create VirtualFunction from callable object.
Definition: functionfromcallable.hh:52
void evaluate(const Domain &x, Range &y) const
Evaluate function.
Definition: functionfromcallable.hh:73
FunctionFromCallable(const F &f)
Create VirtualFunction from callable object.
Definition: functionfromcallable.hh:64
Virtual base class template for function classes.
Definition: function.hh:87
Simple base class templates for functions.
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (Apr 25, 22:37, 2024)