gradient.h 1012 Bytes
Newer Older
Sergi Hernandez's avatar
Sergi Hernandez committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef _GRADIENT_H
#define _GRADIENT_H

#include <vector>
#include <boost/function.hpp>
#include <functional>

#define DEFAULT_MAX_INC       0.1

class CGradient
{
  private:
    double max_coord_inc; 
    boost::function<double (double)> p_function;
    boost::function<double (double)> p_function_der; 
    double max_coord;
    double min_coord;
    double value; 
    double coordinate;
  protected:
    
  public:
    CGradient();
    CGradient(double max_coord_inc);
    void set_max_coord_inc(double max_inc);
    double get_max_coord_inc(void);
    void set_coord_constraints(double max,double min);
    void get_coord_constraints(double &max,double &min);
    void set_function(boost::function<double (double)> p_function);
    void set_function_der(boost::function<double (double)> p_function);
31
    bool compute(double max_func_error,unsigned int max_iter,double start_point,bool &beyond_limits,bool max=true);
Sergi Hernandez's avatar
Sergi Hernandez committed
32
33
34
35
36
37
    double get_value(void);
    double get_coordinate(void);
    ~CGradient();
};

#endif