queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
ExponentialScalarCovarianceFunction.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2017 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
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.
17 //
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. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include <queso/ExponentialScalarCovarianceFunction.h>
26 
27 namespace QUESO {
28 
29 // Default constructor -----------------------------
30 template<class V,class M>
32  const char* prefix,
33  const VectorSet<V,M>& basicDomainSet,
34  double sigma,
35  double a)
36  :
37  BaseScalarCovarianceFunction<V,M>(prefix,basicDomainSet),
38  m_sigma(sigma),
39  m_a (a)
40 {
41  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
42  *m_env.subDisplayFile() << "Entering ExponentialScalarCovarianceFunction<V,M>::constructor()"
43  << ": prefix = " << m_prefix
44  << std::endl;
45  }
46 
47  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
48  *m_env.subDisplayFile() << "Leaving ExponentialScalarCovarianceFunction<V,M>::constructor()"
49  << ": prefix = " << m_prefix
50  << std::endl;
51  }
52 }
53 // Destructor ---------------------------------------
54 template<class V,class M>
56 {
57  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
58  *m_env.subDisplayFile() << "Entering ExponentialScalarCovarianceFunction<V,M>::destructor()"
59  << ": prefix = " << m_prefix
60  << std::endl;
61  }
62 
63  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
64  *m_env.subDisplayFile() << "Leaving ExponentialScalarCovarianceFunction<V,M>::destructor()"
65  << ": prefix = " << m_prefix
66  << std::endl;
67  }
68 }
69 // Math methods -------------------------------------
70 template<class V,class M>
71 double
72 ExponentialScalarCovarianceFunction<V,M>::value(const V& domainVector1, const V& domainVector2) const
73 {
74  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
75  *m_env.subDisplayFile() << "Entering ExponentialScalarCovarianceFunction<V,M>::value()"
76  << std::endl;
77  }
78 
79  double result = 0.;
80 
81  double exponent = -(domainVector1 - domainVector2).norm2Sq()/(m_sigma*m_sigma);
82 
83  result = m_a*std::exp(exponent);
84 
85  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 54)) {
86  *m_env.subDisplayFile() << "Leaving ExponentialScalarCovarianceFunction<V,M>::value()"
87  << std::endl;
88  }
89 
90  return result;
91 }
92 
93 } // End namespace QUESO
A templated class for handling sets.
Definition: VectorSet.h:52
A templated (base) class to accommodate scalar covariance functions (of random variables).
double value(const V &domainVector1, const V &domainVector2) const
Calculates the value of the exponential covariance function.
unsigned int displayVerbosity() const
Definition: Environment.C:450
ExponentialScalarCovarianceFunction(const char *prefix, const VectorSet< V, M > &basicDomainSet, double sigma, double a)
Default constructor.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320

Generated on Tue Jun 5 2018 19:48:55 for queso-0.57.1 by  doxygen 1.8.5