queso-0.53.0
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-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/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  queso_require_equal_to_msg(minValues.sizeLocal(), maxValues.sizeLocal(), "vectors 'minValues' and 'maxValues' should have the same size");
43  queso_require_equal_to_msg(minValues.sizeLocal(), vectorSpace.dimLocal(), "sizes of vectors 'minValues' and 'maxValues' should be equal to dimension of the vector space");
44  for (unsigned int i = 0; i < m_vectorSpace->dimLocal(); ++i) {
45  queso_require_less_equal_msg(minValues[i], maxValues[i], "it should happen minValue <= maxValue for all dimensions");
46  }
47 
48  m_volume = 1.;
49  for (unsigned int i = 0; i < m_vectorSpace->dimLocal(); ++i) {
50  m_volume *= (m_maxValues[i] - m_minValues[i]);
51  }
52 }
53 
54 // Destructor
55 template<class V, class M>
57 {
58 }
59 
60 // Math methods
61 template<class V, class M>
62 bool BoxSubset<V,M>::contains(const V& vec) const
63 {
64  // prudenci, 2012-09-26: allow boundary values because of 'beta' realizer, which can generate a sample with boundary value '1'
65  //return (!vec.atLeastOneComponentSmallerOrEqualThan(m_minValues) &&
66  // !vec.atLeastOneComponentBiggerOrEqualThan (m_maxValues));
67  return (!vec.atLeastOneComponentSmallerThan(m_minValues) &&
68  !vec.atLeastOneComponentBiggerThan (m_maxValues));
69 }
70 
71 
72 template<class V, class M>
73 const V& BoxSubset<V,M>::minValues() const
74 {
75  return m_minValues;
76 }
77 
78 template<class V, class M>
79 const V& BoxSubset<V,M>::maxValues() const
80 {
81  return m_maxValues;
82 }
83 
84 // I/O method
85 template <class V, class M>
86 void BoxSubset<V,M>::print(std::ostream& os) const
87 {
88  os << "In BoxSubset<V,M>::print()"
89  << ": m_minValues = " << m_minValues
90  << ", m_maxValues = " << m_maxValues
91  << ", m_volume = " << m_volume
92  << std::endl;
93 
94  return;
95 }
96 
97 } // End namespace QUESO
98 
unsigned int dimLocal() const
Definition: VectorSpace.C:170
bool contains(const V &vec) const
Checks whether this box subset contains vector vec.
Definition: BoxSubset.C:62
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:89
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
void print(std::ostream &os) const
Prints the volume, the minimum and the maximum values of this.
Definition: BoxSubset.C:86
const V & maxValues() const
Vector of the maximum values of the box subset.
Definition: BoxSubset.C:79
A templated class for handling subsets.
Definition: VectorSubset.h:46
const V & minValues() const
Vector of the minimum values of the box subset.
Definition: BoxSubset.C:73
V m_minValues
Vector of templated type V to store the minimum values of the box subset class.
Definition: BoxSubset.h:86
const VectorSpace< V, M > * m_vectorSpace
Definition: VectorSubset.h:81
V m_maxValues
Vector of templated type V to store the maximum values of the box subset class.
Definition: BoxSubset.h:89
BoxSubset(const char *prefix, const VectorSpace< V, M > &vectorSpace, const V &minValues, const V &maxValues)
Shaped, default constructor.
Definition: BoxSubset.C:34
Class representing a subset of a vector space shaped like a hypercube.
Definition: BoxSubset.h:44
~BoxSubset()
Destructor.
Definition: BoxSubset.C:56
A class representing a vector space.
Definition: VectorSet.h:49

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