Blame view

build3/apps/graph/cartesian_function.h 2.49 KB
6663b6c9   adorian   projet complet av...
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
31
32
33
34
35
36
37
38
39
40
41
  #ifndef GRAPH_CARTESIAN_FUNCTION_H
  #define GRAPH_CARTESIAN_FUNCTION_H
  
  #include "../shared/function.h"
  
  namespace Graph {
  
  class CartesianFunction : public Shared::Function {
  public:
    using Shared::Function::Function;
    CartesianFunction(const char * text = nullptr, KDColor color = KDColorBlack);
    bool displayDerivative();
    void setDisplayDerivative(bool display);
    double approximateDerivative(double x, Poincare::Context * context) const;
    double sumBetweenBounds(double start, double end, Poincare::Context * context) const override;
    struct Point {
      double abscissa;
      double value;
    };
    Point nextMinimumFrom(double start, double step, double max, Poincare::Context * context) const;
    Point nextMaximumFrom(double start, double step, double max, Poincare::Context * context) const;
    double nextRootFrom(double start, double step, double max, Poincare::Context * context) const;
    Point nextIntersectionFrom(double start, double step, double max, Poincare::Context * context, const Shared::Function * function) const;
    char symbol() const override;
  private:
    constexpr static double k_precision = 1.0E-5;
    constexpr static double k_sqrtEps = 1.4901161193847656E-8; // sqrt(DBL_EPSILON)
    constexpr static double k_goldenRatio = 0.381966011250105151795413165634361882279690820194237137864; // (3-sqrt(5))/2
    typedef double (*Evaluation)(double abscissa, Poincare::Context * context, const Shared::Function * function0, const Shared::Function * function1);
    Point nextMinimumOfFunction(double start, double step, double max, Evaluation evaluation, Poincare::Context * context, const Shared::Function * function = nullptr, bool lookForRootMinimum = false) const;
    void bracketMinimum(double start, double step, double max, double result[3], Evaluation evaluation, Poincare::Context * context, const Shared::Function * function= nullptr) const;
    Point brentMinimum(double ax, double bx, Evaluation evaluation, Poincare::Context * context, const Shared::Function * function = nullptr) const;
    double nextIntersectionWithFunction(double start, double step, double max, Evaluation evaluation, Poincare::Context * context, const Shared::Function * function) const;
    void bracketRoot(double start, double step, double max, double result[2], Evaluation evaluation, Poincare::Context * context, const Shared::Function * function) const;
    double brentRoot(double ax, double bx, double precision, Evaluation evaluation, Poincare::Context * context, const Shared::Function * function) const;
    bool m_displayDerivative;
  };
  
  }
  
  #endif