forked from sPHENIX-Collaboration/coresoftware
/
SquareGradient.h
36 lines (24 loc) · 1.02 KB
/
SquareGradient.h
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
#ifndef FITNEWTON_SQUAREGRADIENT_H
#define FITNEWTON_SQUAREGRADIENT_H
#include "FunctionGradHessian.h"
#include <Eigen/Core>
namespace FitNewton
{
class SquareGradient : public FunctionGradHessian
{
public:
SquareGradient(FunctionGradHessian* func);
~SquareGradient();
// this class is intended to be used only with line-search, and so this function doesn't fill the Hessian, and really should not be called
bool calcValGradHessian(const Eigen::VectorXd& x, double& val, Eigen::VectorXd& grad, Eigen::MatrixXd& hessian);
// fill the gradient of this function based on "function"
// this class represents the square of the magnitude of the gradient of "function",
// so we can calculate the val and grad from the val,grad,hessian of function
bool calcValGrad(const Eigen::VectorXd& x, double& val, Eigen::VectorXd& grad);
FunctionGradHessian* Clone() const;
bool verbose;
protected:
FunctionGradHessian* function;
};
}
#endif