GeostatisticalModelExponential.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/sa/core/GeostatisticalModelExponential.cpp
22 
23  \brief This file contains a class that represents the geostatistical exponential model.
24 
25  \reference Adapted from TerraLib4.
26 */
27 
28 // Terralib Includes
30 
32 {
34 }
35 
37  default;
38 
39 boost::numeric::ublas::matrix<double> te::sa::GeostatisticalModelExponential::calculate(boost::numeric::ublas::matrix<double> matrix)
40 {
41  //get the number of lags used
42  std::size_t nLags = matrix.size1();
43 
44  //create the model matrix
45  boost::numeric::ublas::matrix<double> m(nLags, 2);
46 
47  //fill matrix
48  std::vector<double> exponentialValues;
49 
50  for(std::size_t t= 0; t < nLags; ++t)
51  {
52  if(matrix(t, 0) == 0.)
53  {
54  exponentialValues.push_back(m_nugget);
55  }
56  else
57  {
58  exponentialValues.push_back(m_nugget + (m_sill - m_nugget) * (1 - exp(- (3. * matrix(t, 0)) / m_range)));
59  }
60 
61  m(t, 0) = matrix(t, 0);
62  m(t, 1) = exponentialValues[t];
63  }
64 
65  return m;
66 }
double m_nugget
The height of the jump of the semivariogram at the discontinuity at the origin.
double m_sill
Limit of the variogram tending to infinity lag distances.
virtual boost::numeric::ublas::matrix< double > calculate(boost::numeric::ublas::matrix< double > matrix)
Function to calculate the geostatistical information from model.
virtual ~GeostatisticalModelExponential()
Virtual destructor.
This file contains a class that represents the geostatistical exponential model.
te::sa::GeostatisticalModelType m_type
Attribute used to define the model type used.
double m_range
The distance in which the difference of the variogram from the sill becomes negligible.