dune-functions  2.5.0
functionfromcallable.hh
Go to the documentation of this file.
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 
6 #include <dune/common/function.hh>
7 
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> >
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
Definition: functionfromcallable.hh:20
Definition: polynomial.hh:7
FunctionFromCallable(const F &f)
Create VirtualFunction from callable object.
Definition: functionfromcallable.hh:64
void evaluate(const Domain &x, Range &y) const
Evaluate function.
Definition: functionfromcallable.hh:73
FunctionFromCallable(F &&f)
Create VirtualFunction from callable object.
Definition: functionfromcallable.hh:52