Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
JHesseMatrix.hh
Go to the documentation of this file.
1 #ifndef __JTOOLS__JHESSEMATRIX__
2 #define __JTOOLS__JHESSEMATRIX__
3 
4 #include "JTools/JTable2D.hh"
5 #include "JTools/JResult.hh"
6 
7 
8 /**
9  * \author mdejong
10  */
11 
12 namespace JTOOLS {}
13 namespace JPP { using namespace JTOOLS; }
14 
15 namespace JTOOLS {
16 
17 
18  /**
19  * Hessian matrix.
20  */
21  template<unsigned int N, class JData_t = double>
22  struct JHesseMatrix :
23  public JTable2D<N, N, JData_t>
24  {
25  /**
26  * Default constructor.
27  */
29  {}
30 
31 
32  /**
33  * Constructor.
34  *
35  * \param result Hesse result
36  */
37  template<class JResult_t>
39  {
40  set(result);
41  }
42 
43 
44  /**
45  * Set matrix according given result.
46  *
47  * \param result Hesse result
48  */
49  template<class JResult_t>
51  {
52  set(0, result);
53 
54  for (unsigned int i = 1; i != N; ++i) {
55  for (unsigned int j = 0; j != i; ++j) {
56  this->data[i][j] = this->data[j][i];
57  }
58  }
59  }
60 
61  private:
62  /**
63  * Set final element.
64  *
65  * \param pivot pivot
66  * \param result Hesse result
67  */
68  void set(unsigned int pivot,
70  {
71  this->data[pivot][pivot] = result.fpp;
72  }
73 
74 
75  /**
76  * Set final element.
77  *
78  * \param row row
79  * \param col col
80  * \param result Hesse result
81  */
82  void set(unsigned int row,
83  unsigned int col,
85  {
86  this->data[row][col] = result.fp;
87  }
88 
89 
90  /**
91  * Recursivaly set elements.
92  *
93  * \param pivot pivot
94  * \param result Hesse result
95  */
96  template<class JResult_t>
97  void set(unsigned int pivot,
99  {
100  this->data[pivot][pivot] = get_value(result.fpp);
101 
102  set(pivot, pivot + 1, result.fp);
103  set(pivot + 1, result.f);
104  }
105 
106 
107  /**
108  * Recursivaly set elements.
109  *
110  * \param row row
111  * \param col col
112  * \param result Hesse result
113  */
114  template<class JResult_t>
115  void set(unsigned int row,
116  unsigned int col,
118  {
119  this->data[row][col] = get_value(result.fp);
120 
121  set(row, col + 1, result.f);
122  }
123  };
124 }
125 
126 #endif
This include file containes various data structures that can be used as specific return types for the...
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for multi-dimensional interpolations and histograms.
JResultEvaluator< JResult_t >::result_type get_value(const JResult_t &value)
Helper method to recursively evaluate a to function value.
Definition: JResult.hh:998
int j
Definition: JPolint.hh:792
Hessian matrix.
Definition: JHesseMatrix.hh:24
void set(unsigned int pivot, const JResultHesse< JResult_t > &result)
Recursivaly set elements.
Definition: JHesseMatrix.hh:97
void set(unsigned int pivot, const JResultHesse< JData_t > &result)
Set final element.
Definition: JHesseMatrix.hh:68
void set(unsigned int row, unsigned int col, const JResultHesse< JData_t > &result)
Set final element.
Definition: JHesseMatrix.hh:82
JHesseMatrix(const JResultHesse< JResult_t > &result)
Constructor.
Definition: JHesseMatrix.hh:38
JHesseMatrix()
Default constructor.
Definition: JHesseMatrix.hh:28
void set(const JResultHesse< JResult_t > &result)
Set matrix according given result.
Definition: JHesseMatrix.hh:50
void set(unsigned int row, unsigned int col, const JResultHesse< JResult_t > &result)
Recursivaly set elements.
Data structure for result including value and first derivative of function.
Definition: JResult.hh:215
2D table with arithmetic capabilities.
Definition: JTable2D.hh:29