queso-0.51.1
BoxSubset.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,2009,2010,2011,2012,2013 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/VectorSpace.h>
26 #include <queso/BoxSubset.h>
27 #include <queso/GslVector.h>
28 #include <queso/GslMatrix.h>
29 
30 namespace QUESO {
31 
32 // Default, shaped constructor
33 template<class V, class M>
34 BoxSubset<V,M>::BoxSubset(const char* prefix,
35  const VectorSpace<V,M>& vectorSpace,
36  const V& minValues,
37  const V& maxValues)
38  : VectorSubset<V,M>(prefix,vectorSpace,0.),
39  m_minValues(minValues),
40  m_maxValues(maxValues)
41 {
42  UQ_FATAL_TEST_MACRO(minValues.sizeLocal() != maxValues.sizeLocal(),
43  m_env.worldRank(),
44  "BoxSubset<V,M>::BoxSubset()",
45  "vectors 'minValues' and 'maxValues' should have the same size");
46  UQ_FATAL_TEST_MACRO(minValues.sizeLocal() != vectorSpace.dimLocal(),
47  m_env.worldRank(),
48  "BoxSubset<V,M>::BoxSubset()",
49  "sizes of vectors 'minValues' and 'maxValues' should be equal to dimension of the vector space");
50  for (unsigned int i = 0; i < m_vectorSpace->dimLocal(); ++i) {
51  UQ_FATAL_TEST_MACRO(minValues[i] > maxValues[i],
52  m_env.worldRank(),
53  "BoxSubset<V,M>::BoxSubset()",
54  "it should happen minValue <= maxValue for all dimensions");
55  }
56 
57  m_volume = 1.;
58  for (unsigned int i = 0; i < m_vectorSpace->dimLocal(); ++i) {
59  m_volume *= (m_maxValues[i] - m_minValues[i]);
60  }
61 }
62 
63 // Destructor
64 template<class V, class M>
66 {
67 }
68 
69 // Math methods
70 template<class V, class M>
71 bool BoxSubset<V,M>::contains(const V& vec) const
72 {
73  // prudenci, 2012-09-26: allow boundary values because of 'beta' realizer, which can generate a sample with boundary value '1'
74  //return (!vec.atLeastOneComponentSmallerOrEqualThan(m_minValues) &&
75  // !vec.atLeastOneComponentBiggerOrEqualThan (m_maxValues));
76  return (!vec.atLeastOneComponentSmallerThan(m_minValues) &&
77  !vec.atLeastOneComponentBiggerThan (m_maxValues));
78 }
79 
80 
81 template<class V, class M>
82 const V& BoxSubset<V,M>::minValues() const
83 {
84  return m_minValues;
85 }
86 
87 template<class V, class M>
88 const V& BoxSubset<V,M>::maxValues() const
89 {
90  return m_maxValues;
91 }
92 
93 // I/O method
94 template <class V, class M>
95 void BoxSubset<V,M>::print(std::ostream& os) const
96 {
97  os << "In BoxSubset<V,M>::print()"
98  << ": m_minValues = " << m_minValues
99  << ", m_maxValues = " << m_maxValues
100  << ", m_volume = " << m_volume
101  << std::endl;
102 
103  return;
104 }
105 
106 } // End namespace QUESO
107 
unsigned int dimLocal() const
Definition: VectorSpace.C:199
~BoxSubset()
Destructor.
Definition: BoxSubset.C:65
const V & minValues() const
Vector of the minimum values of the box subset.
Definition: BoxSubset.C:82
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
BoxSubset(const char *prefix, const VectorSpace< V, M > &vectorSpace, const V &minValues, const V &maxValues)
Shaped, default constructor.
Definition: BoxSubset.C:34
void print(std::ostream &os) const
Prints the volume, the minimum and the maximum values of this.
Definition: BoxSubset.C:95
const V & maxValues() const
Vector of the maximum values of the box subset.
Definition: BoxSubset.C:88
A templated class for handling subsets.
Definition: VectorSubset.h:44
const BaseEnvironment & m_env
Definition: VectorSet.h:99
Class representing a subset of a vector space shaped like a hypercube.
Definition: BoxSubset.h:41
A class representing a vector space.
Definition: VectorSet.h:46
bool contains(const V &vec) const
Checks whether this box subset contains vector vec.
Definition: BoxSubset.C:71
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
V m_maxValues
Vector of templated type V to store the maximum values of the box subset class.
Definition: BoxSubset.h:86
const VectorSpace< V, M > * m_vectorSpace
Definition: VectorSubset.h:79
V m_minValues
Vector of templated type V to store the minimum values of the box subset class.
Definition: BoxSubset.h:83

Generated on Thu Apr 23 2015 19:26:14 for queso-0.51.1 by  doxygen 1.8.5