queso-0.53.0
StdOneDGrid.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-2015 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/StdOneDGrid.h>
26 
27 namespace QUESO {
28 
29 template<class T>
31  const BaseEnvironment& env,
32  const char* prefix,
33  const std::vector<T>& points)
34  :
35  BaseOneDGrid<T>(env,prefix),
36  m_points (points)
37 {
38  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
39  *m_env.subDisplayFile() << "Entering StdOneDGrid<T>::constructor()"
40  << ": prefix = " << m_prefix
41  << std::endl;
42  }
43 
44  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
45  *m_env.subDisplayFile() << "Leaving StdOneDGrid<T>::constructor()"
46  << ": prefix = " << m_prefix
47  << std::endl;
48  }
49 }
50 
51 template<class T>
53 {
54 }
55 
56 template<class T>
57 unsigned int
59 {
60  return m_points.size();
61 }
62 
63 template<class T>
64 T
65 StdOneDGrid<T>::operator[](unsigned int i) const
66 {
67  queso_require_less_msg(i, m_points.size(), "too large i");
68 
69  return m_points[i];
70 }
71 
72 template<class T>
73 unsigned int
74 StdOneDGrid<T>::findIntervalId(const T& paramValue) const
75 {
76  queso_require_msg(!((paramValue < m_points[0]) || (m_points[m_points.size()-1] < paramValue)), "paramValue is out of domain");
77 
78  unsigned int iMax = m_points.size();
79  unsigned int i = 1; // Yes, '1'
80  for (i = 1; i < iMax; ++i) { // Yes, '1'
81  if (paramValue < m_points[i]) {
82  i--;
83  break;
84  }
85  }
86 
87  return i;
88 }
89 
90 } // End namespace QUESO
unsigned int displayVerbosity() const
Definition: Environment.C:396
std::string m_prefix
Definition: OneDGrid.h:83
unsigned int size() const
Grid size; the amount of points which defines the grid.
Definition: StdOneDGrid.C:58
const BaseEnvironment & m_env
Definition: OneDGrid.h:82
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
StdOneDGrid(const BaseEnvironment &env, const char *prefix, const std::vector< T > &points)
Default constructor.
Definition: StdOneDGrid.C:30
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
#define queso_require_less_msg(expr1, expr2, msg)
Definition: asserts.h:87
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:193
Base class for accommodating one-dimensional grids.
Definition: OneDGrid.h:46
unsigned int findIntervalId(const T &paramValue) const
Finds the ID of an interval. See template specialization.
Definition: StdOneDGrid.C:74
~StdOneDGrid()
Destructor.
Definition: StdOneDGrid.C:52
T operator[](unsigned int i) const
Returns the position of the i-th point in the grid.
Definition: StdOneDGrid.C:65

Generated on Thu Jun 11 2015 13:52:32 for queso-0.53.0 by  doxygen 1.8.5