Geophysical Inversion and Modelling Library v1.5.4
Loading...
Searching...
No Matches
curvefitting.h
1/******************************************************************************
2 * Copyright (C) 2009-2024 by the GIMLi development team *
3 * Carsten Rücker carsten@resistivity.net *
4 * *
5 * Licensed under the Apache License, Version 2.0 (the "License"); *
6 * you may not use this file except in compliance with the License. *
7 * You may obtain a copy of the License at *
8 * *
9 * http://www.apache.org/licenses/LICENSE-2.0 *
10 * *
11 * Unless required by applicable law or agreed to in writing, software *
12 * distributed under the License is distributed on an "AS IS" BASIS, *
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 * See the License for the specific language governing permissions and *
15 * limitations under the License. *
16 * *
17 ******************************************************************************/
18
19#ifndef _GIMLI_CURVEFITTING__H
20#define _GIMLI_CURVEFITTING__H
21
22#include "gimli.h"
23
24#include "polynomial.h"
25
26namespace GIMLI{
27
29template < class ArgType , class ValueType > class DLLEXPORT Function {
30public:
31 Function() { }
32
33 virtual ~Function() { }
34
35 Function(const Function & funct){ copy_(funct); }
36
37 Function & operator = (const Function & funct){
38 if (this != & funct){
39 copy_(funct);
40 } return * this;
41 }
42
43 inline ValueType operator() (const ArgType & arg) const { return this->getValue(arg); }
44
45 inline Vector < ValueType > operator() (const Vector < ArgType > & arg) const { return this->getValue(arg); }
46
47 virtual ValueType getValue(const ArgType & arg) const = 0;
48
49 virtual Vector < ValueType > getValue(const Vector < ArgType > & arg) const = 0;
50
51protected:
52 virtual void copy_(const Function & funct) { };
53};
54
55class DLLEXPORT HarmonicFunction : public Function< double, double >{
56public:
57 HarmonicFunction(const RVector & coeff, double xmin, double xmax);
58
59 virtual ~HarmonicFunction();
60
61 virtual double getValue(const double & arg) const;
62
63 virtual RVector getValue(const RVector & arg) const;
64
65 void setCoefficients(const RVector & coeff);
66
67 inline const RVector & coefficients() const { return coeff_; }
68
69 inline void setXMin(double xmin){ xMin_ = xmin; }
70
71 inline double xMin() const { return xMin_; }
72
73 inline void setXMax(double xmax){ xMax_ = xmax; }
74
75 inline double xMax() const { return xMax_; }
76
77protected:
78 virtual void copy_(const HarmonicFunction & funct);
79
80 RVector coeff_;
81 size_t nHarmonic_;
82 double xMin_;
83 double xMax_;
84};
85
86class DLLEXPORT HarmonicModelling : public ModellingBase {
87public:
89 HarmonicModelling(size_t nh, const RVector & tvec, bool verbose = false);
90
91 virtual ~HarmonicModelling(){ }
92
94 virtual RVector response(const RVector & par);
95
97 virtual RVector response(const RVector & par, const RVector tvec);
98
100 virtual void createJacobian(const RVector & model);
101
103 inline virtual RVector startModel(){ return RVector(np_, 0.0); }
104
105protected:
106
107 RVector t_;
108 RMatrix A_;
109 double tMin_;
110 double tMax_;
111 size_t nh_, nt_, np_;
112};
113
115
116class DLLEXPORT PolynomialModelling : public ModellingBase {
117public:
118
119 PolynomialModelling(uint dim, uint nCoeffizient, const std::vector < RVector3 > & referencePoints,
120 const RVector & startModel);
121
122 virtual RVector response(const RVector & par);
123
129 virtual RVector startModel();
130
133
135 void setPascalsStyle(bool is) { pascalTriangle_ = is; }
136
140 void setSerendipityStyle(bool is) { serendipityStyle_ = is; }
141
142 void setPowCombinationTmp(int i) { powCombination_ = i; }
143
144protected:
145 uint dim_;
146 std::vector < RVector3 > referencePoints_;
147
148 PolynomialFunction< double > f_;
149
150 bool pascalTriangle_;
151 bool serendipityStyle_;
152 uint powCombination_;
153};
154
155} // namespace GIMLI{
156
157#endif // _GIMLI_CURVEFITTING__H
virtual RVector response(const RVector &par)
Definition curvefitting.cpp:111
RMatrix A_
abscissa vector x
Definition curvefitting.h:108
virtual void createJacobian(const RVector &model)
Definition curvefitting.cpp:129
double tMin_
function matrix
Definition curvefitting.h:109
HarmonicModelling(size_t nh, const RVector &tvec, bool verbose=false)
Definition curvefitting.cpp:83
virtual RVector startModel()
Definition curvefitting.h:103
bool verbose() const
Definition modellingbase.h:48
virtual RVector startModel()
Definition curvefitting.cpp:162
void setSerendipityStyle(bool is)
Definition curvefitting.h:140
const PolynomialFunction< double > & polynomialFunction() const
Definition curvefitting.h:132
void setPascalsStyle(bool is)
Definition curvefitting.h:135
GIMLi main namespace for the Geophyiscal Inversion and Modelling Library.
Definition baseentity.h:24