ARTS 2.5.4 (git: 31ce4f0e)
minimize.cc
Go to the documentation of this file.
1#include "minimize.h"
2
3namespace Minimize {
5 for (Index i=0; i<m_values; i++) {
6 f[i] = p[0] - Y[i];
7 Numeric x = 1;
8 for (int j=1; j<m_inputs; j++) {
9 x *= X[i];
10 f[i] += p[j] * x;
11 }
12 }
13 return 0;
14}
15
17 for (Index i=0; i<m_values; i++) {
18 J(i, 0) = 1;
19 Numeric x = 1;
20 for (int j=1; j<m_inputs; j++) {
21 x *= X[i];
22 J(i, j) = x;
23 }
24 }
25 return 0;
26}
27
30 for (int j=0; j<m_inputs; j++) {
31 out[j] = 1;
32 }
33 return out;
34}
35
37 for (Index i=0; i<m_values; i++) {
38 const Numeric G = T0 / T[i];
39 const Numeric GX = std::pow(G, p[2]);
40 f[i] = (p[0] + p[1] * (G - 1)) * GX - Y[i];
41 }
42 return 0;
43}
44
45int T4::df(const T4::InputType& p, T4::JacobianType& J) const {
46 for (Index i=0; i<m_values; i++) {
47 const Numeric G = T0 / T[i];
48 const Numeric GX = std::pow(G, p[2]);
49 J(i, 0) = GX;
50 J(i, 1) = (G - 1) * GX;
51 J(i, 2) = (p[0] + p[1] * (G - 1)) * GX * std::log(G);
52 }
53 return 0;
54}
55
57 const Numeric mean_y = mean(Y);
59 out << mean_y, -0.01*mean_y, mean_y < 0 ? -EXP0 : EXP0;
60 return out;
61}
62
64 for (Index i=0; i<m_values; i++) {
65 const Numeric G = T0 / T[i];
66 const Numeric GX1 = std::pow(G, p[1]);
67 const Numeric GX3 = std::pow(G, p[3]);
68 f[i] = p[0] * GX1 + p[2] * GX3 - Y[i];
69 }
70 return 0;
71}
72
73int DPL::df(const DPL::InputType& p, DPL::JacobianType& J) const {
74 for (Index i=0; i<m_values; i++) {
75 const Numeric G = T0 / T[i];
76 const Numeric lG = std::log(G);
77 const Numeric GX1 = std::pow(G, p[1]);
78 const Numeric GX3 = std::pow(G, p[3]);
79 J(i, 0) = GX1;
80 J(i, 1) = p[0] * GX1 * lG;
81 J(i, 2) = GX3;
82 J(i, 3) = p[2] * GX3 * lG;
83 }
84 return 0;
85}
86
88 const Numeric mean_y = mean(Y);
90 out << mean_y, mean_y < 0 ? -EXP0 : EXP0, -0.01*mean_y, mean_y < 0 ? EXP0 : -EXP0;
91 return out;
92}
93}
TimeStep mean(const ArrayOfTimeStep &dt)
Returns the mean time step.
Definition: artstime.cc:190
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Numeric pow(const Rational base, Numeric exp)
Power of.
Definition: rational.h:713
InputType x0() const
start values helper function, operator()(...) must be not too bad
Definition: minimize.cc:87
const int m_values
Definition: minimize.h:155
int df(const InputType &p, JacobianType &J) const
Definition: minimize.cc:73
const Numeric T0
Reference temperature.
Definition: minimize.h:164
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > InputType
Definition: minimize.h:146
const Numeric EXP0
Reference start exponent.
Definition: minimize.h:167
static constexpr int m_inputs
Definition: minimize.h:152
int operator()(const InputType &p, ValueType &f) const
Definition: minimize.cc:63
const ConstVectorView & T
Temperature grid.
Definition: minimize.h:158
const ConstVectorView & Y
Spectroscopic values at grid.
Definition: minimize.h:161
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > ValueType
Definition: minimize.h:147
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > JacobianType
Definition: minimize.h:148
const ConstVectorView & X
Temperature grid.
Definition: minimize.h:32
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > InputType
Definition: minimize.h:20
int df(const InputType &p, JacobianType &J) const
Definition: minimize.cc:16
int operator()(const InputType &p, ValueType &f) const
Definition: minimize.cc:4
const ConstVectorView & Y
Spectroscopic values at grid.
Definition: minimize.h:35
InputType x0() const
start values helper function, operator()(...) must be not too bad
Definition: minimize.cc:28
const int m_inputs
Definition: minimize.h:26
const int m_values
Definition: minimize.h:29
const Numeric EXP0
Reference start exponent.
Definition: minimize.h:100
const ConstVectorView & T
Temperature grid.
Definition: minimize.h:91
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > InputType
Definition: minimize.h:79
static constexpr int m_inputs
Definition: minimize.h:85
const Numeric T0
Reference temperature.
Definition: minimize.h:97
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > ValueType
Definition: minimize.h:80
InputType x0() const
start values helper function, operator()(...) must be not too bad
Definition: minimize.cc:56
Eigen::Matrix< Scalar, Eigen::Dynamic, Eigen::Dynamic > JacobianType
Definition: minimize.h:81
const int m_values
Definition: minimize.h:88
const ConstVectorView & Y
Spectroscopic values at grid.
Definition: minimize.h:94
int operator()(const InputType &p, ValueType &f) const
Definition: minimize.cc:36
int df(const InputType &p, JacobianType &J) const
Definition: minimize.cc:45