3
* @file QuadraticTaylor.cxx
4
* @brief Second order polynomial response surface by Taylor expansion
6
* (C) Copyright 2005-2007 EDF-EADS-Phimeca
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License.
13
* This library is distributed in the hope that it will be useful
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
* @author: $LastChangedBy: dutka $
23
* @date: $LastChangedDate: 2008-09-13 22:37:56 +0200 (sam 13 sep 2008) $
24
* Id: $Id: QuadraticTaylor.cxx 929 2008-09-13 20:37:56Z dutka $
26
#include "QuadraticTaylor.hxx"
27
#include "QuadraticNumericalMathEvaluationImplementation.hxx"
28
#include "LinearNumericalMathGradientImplementation.hxx"
29
#include "ConstantNumericalMathHessianImplementation.hxx"
33
namespace Uncertainty {
37
typedef Base::Func::QuadraticNumericalMathEvaluationImplementation QuadraticNumericalMathEvaluationImplementation;
38
typedef Base::Func::LinearNumericalMathGradientImplementation LinearNumericalMathGradientImplementation;
39
typedef Base::Func::ConstantNumericalMathHessianImplementation ConstantNumericalMathHessianImplementation;
41
CLASSNAMEINIT(QuadraticTaylor);
43
QuadraticTaylor::QuadraticTaylor(const String & name):
44
PersistentObject(name)
49
/* Constructor with parameters */
50
QuadraticTaylor::QuadraticTaylor(const NumericalPoint & center,
51
const NumericalMathFunction & inputFunction,
53
PersistentObject(name),
55
inputFunction_(inputFunction)
60
/* Virtual constructor */
61
QuadraticTaylor * QuadraticTaylor::clone() const
63
return new QuadraticTaylor(*this);
66
/* String converter */
67
String QuadraticTaylor::str() const
70
oss << "class=" << GetClassName()
71
<< " name=" << getName()
72
<< " center=" << center_
73
<< " function=" << inputFunction_
74
<< " responseSurface=" << responseSurface_
75
<< " constant=" << constant_
76
<< " linear=" << linear_
77
<< " quadratic=" << quadratic_;
81
/* Response surface computation */
82
void QuadraticTaylor::run()
84
/* Compute the three first terms of the Taylor expansion */
85
constant_ = inputFunction_(center_);
86
linear_ = inputFunction_.gradient(center_);
87
quadratic_ = inputFunction_.hessian(center_);
88
/* Build the several implementations and set it into the response surface */
89
responseSurface_.setEvaluationImplementation(new QuadraticNumericalMathEvaluationImplementation(center_, constant_, linear_, quadratic_));
90
responseSurface_.setGradientImplementation(new LinearNumericalMathGradientImplementation(center_, linear_, quadratic_));
91
responseSurface_.setHessianImplementation(new ConstantNumericalMathHessianImplementation(quadratic_));
92
responseSurface_.setDescription(inputFunction_.getDescription());
96
QuadraticTaylor::NumericalPoint QuadraticTaylor::getCenter() const
101
/* Constant accessor */
102
QuadraticTaylor::NumericalPoint QuadraticTaylor::getConstant() const
107
/* Linear accessor */
108
QuadraticTaylor::Matrix QuadraticTaylor::getLinear() const
113
/* Quadratic accessor */
114
QuadraticTaylor::SymmetricTensor QuadraticTaylor::getQuadratic() const
119
/* Function accessor */
120
QuadraticTaylor::NumericalMathFunction QuadraticTaylor::getInputFunction() const
122
return inputFunction_;
125
/* Response surface accessor */
126
QuadraticTaylor::NumericalMathFunction QuadraticTaylor::getResponseSurface() const
128
return responseSurface_;
131
} /* namespace Algorithm */
132
} /* namespace Uncertainty */
133
} /* namespace OpenTURNS */