Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-02 08:48:24

0001 #ifndef FUNCTOR_UTILS_H
0002 #define FUNCTOR_UTILS_H
0003 
0004 /**
0005  * @file FunctorUtils.h
0006  * @author Bryan BERTHOU (SPhN / CEA Saclay)
0007  * @date October 07, 2016
0008  * @version 1.0
0009  */
0010 
0011 #include "../functor/multi_dimension/FunctorMD.h"
0012 #include "../functor/one_dimension/Functor1D.h"
0013 
0014 namespace NumA {
0015 
0016 /**
0017  * @class FunctorUtils
0018  *
0019  * @brief Utilities for Functors.
0020  */
0021 class FunctorUtils {
0022 public:
0023     /**
0024      * Defines a new functor with the given one-dimensional function.
0025      *
0026      * See FunctionType1D documentation for an example.
0027      * @param object Pointer to the object instantiating a class where the function is defined as a method.
0028      * @param function Reference to the function defining the functor. Should have the following signature:
0029      * ```cpp
0030      * double MyClass::myFunction(double variable, std::vector<double>& parameters);
0031      * ```
0032      * @return Functor pointer.
0033      */
0034     template<typename PointerToObj, typename PointerToMemFn>
0035     static Functor1D<PointerToObj, PointerToMemFn>* newFunctor1D(
0036             PointerToObj* object, PointerToMemFn function) {
0037         return new Functor1D<PointerToObj, PointerToMemFn>(object, function);
0038     }
0039 
0040     /**
0041      * Defines a new functor with the given multi-dimensional function.
0042      *
0043      * See FunctionTypeMD documentation for an example.
0044      * @param object Pointer to the object instantiating a class where the function is defined as a method.
0045      * @param function Reference to the function defining the functor. Should have the signature:
0046      * ```cpp
0047      * double MyClass::myFunction(NumA::VectorD& variables, std::vector<double>& parameters);
0048      * ```
0049      * @return Functor pointer.
0050      */
0051     template<typename PointerToObj, typename PointerToMemFn>
0052     static FunctorMD<PointerToObj, PointerToMemFn>* newFunctorMD(
0053             PointerToObj* object, PointerToMemFn function) {
0054         return new FunctorMD<PointerToObj, PointerToMemFn>(object, function);
0055     }
0056 };
0057 
0058 } /* namespace NumA */
0059 
0060 #endif /* FUNCTOR_UTILS_H */