Commit 055454af authored by Nabil Chouika's avatar Nabil Chouika
Browse files

Functors documentation partons/core/partons#4

parent f341ee72
......@@ -42,6 +42,8 @@ namespace NumA {
*
* See also FunctorUtils documentation.
*
* See also Integrator1D documentation for the specific case of integration routines.
*
* For multi-dimensional functions, see FunctionTypeMD.
*/
......
......@@ -30,7 +30,7 @@ namespace NumA {
* Example:
* ```cpp
* NumA::Integrator1D* integrator = NumA::Integrator1D::newIntegrator(NumA::IntegratorType1D::GaussLegendre); // Using Gauss-Legendre quadrature.
* NumA::FunctionType1D* functor = NumA::FunctorUtils::newFunctor1D(this, &MyClass::myFunction); // See FunctionType1D documentation.
* NumA::FunctionType1D* functor = NumA::FunctorUtils::newFunctor1D(pointerMyClass, &MyClass::myFunction); // See FunctionType1D documentation.
* double integral = integrator.integrate(functor, -1., 1.); // We integrate a function on [-1,1].
* ```
*/
......
......@@ -16,16 +16,38 @@ namespace NumA {
/**
* @class FunctorUtils
*
* @brief
* @brief Utilities for Functors.
*/
class FunctorUtils {
public:
/**
* Defines a new functor with the given one-dimensional function.
*
* See FunctionType1D documentation for an example.
* @param object Pointer to the object instantiating a class where the function is defined as a method.
* @param function Reference to the function defining the functor. Should have the following signature:
* ```cpp
* double MyClass::myFunction(double variable, std::vector<double>& parameters);
* ```
* @return Functor pointer.
*/
template<typename PointerToObj, typename PointerToMemFn>
static Functor1D<PointerToObj, PointerToMemFn>* newFunctor1D(
PointerToObj* object, PointerToMemFn function) {
return new Functor1D<PointerToObj, PointerToMemFn>(object, function);
}
/**
* Defines a new functor with the given multi-dimensional function.
*
* See FunctionTypeMD documentation for an example.
* @param object Pointer to the object instantiating a class where the function is defined as a method.
* @param function Reference to the function defining the functor. Should have the signature:
* ```cpp
* double MyClass::myFunction(NumA::VectorD& variables, std::vector<double>& parameters);
* ```
* @return Functor pointer.
*/
template<typename PointerToObj, typename PointerToMemFn>
static FunctorMD<PointerToObj, PointerToMemFn>* newFunctorMD(
PointerToObj* object, PointerToMemFn function) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment