queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::ConcatenationSubset< V, M > Class Template Reference

A templated class representing the concatenation of two vector subsets. More...

#include <ConcatenationSubset.h>

Inheritance diagram for QUESO::ConcatenationSubset< V, M >:
QUESO::VectorSubset< V, M > QUESO::VectorSet< V, M >

Public Member Functions

Constructor/Destructor methods.
 ConcatenationSubset (const char *prefix, const VectorSpace< V, M > &vectorSpace, const VectorSet< V, M > &set1, const VectorSet< V, M > &set2)
 Constructor - two sets only. More...
 
 ConcatenationSubset (const char *prefix, const VectorSpace< V, M > &vectorSpace, double volume, const std::vector< const VectorSet< V, M > * > &sets)
 Constructor - collection of sets. More...
 
 ~ConcatenationSubset ()
 Destructor. More...
 
Mathematical methods.
bool contains (const V &vec) const
 Determines whether each one of the subsets m_sets (class' private attributes) contains vector vec. More...
 
virtual void centroid (V &vec) const
 Returns the set centroid in the vector vec. More...
 
virtual void moments (M &mat) const
 Returns the set moments of inertia in the matrix mat. More...
 
I/O methods.
void print (std::ostream &os) const
 Prints the subsets (via protected attribute m_sets). More...
 
- Public Member Functions inherited from QUESO::VectorSubset< V, M >
 VectorSubset ()
 Default Constructor. More...
 
 VectorSubset (const char *prefix, const VectorSpace< V, M > &vectorSpace, double volume)
 Shaped constructor (with volume). More...
 
virtual ~VectorSubset ()
 Destructor. More...
 
const VectorSpace< V, M > & vectorSpace () const
 Vector space to which this set belongs to. See template specialization. More...
 
- Public Member Functions inherited from QUESO::VectorSet< V, M >
 VectorSet (const BaseEnvironment &env, const char *prefix, double volume)
 Shaped constructor. More...
 
virtual ~VectorSet ()
 Virtual destructor. More...
 
const BaseEnvironmentenv () const
 Environment. Access to private attribute m_env. More...
 
const std::string & prefix () const
 Access to private attribute m_prefix. More...
 
double volume () const
 Set volume; access to private attribute m_volume. More...
 

Protected Attributes

std::vector< const VectorSet
< V, M > * > 
m_sets
 
- Protected Attributes inherited from QUESO::VectorSubset< V, M >
const VectorSpace< V, M > * m_vectorSpace
 
- Protected Attributes inherited from QUESO::VectorSet< V, M >
const BaseEnvironmentm_env
 
std::string m_prefix
 
double m_volume
 

Detailed Description

template<class V = GslVector, class M = GslMatrix>
class QUESO::ConcatenationSubset< V, M >

A templated class representing the concatenation of two vector subsets.

This class is used to represent the concatenation of two subsets. It allows concatenation of both two subsets as well as a collection of subsets into one.

Definition at line 43 of file ConcatenationSubset.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::ConcatenationSubset< V, M >::ConcatenationSubset ( const char *  prefix,
const VectorSpace< V, M > &  vectorSpace,
const VectorSet< V, M > &  set1,
const VectorSet< V, M > &  set2 
)

Constructor - two sets only.

It concatenates set1 and set2 into a new set, m_set, of volume given by set1.volume()*set2.volume().

Definition at line 35 of file ConcatenationSubset.C.

References QUESO::ConcatenationSubset< V, M >::m_sets.

39  : VectorSubset<V,M>(prefix, vectorSpace, set1.volume()*set2.volume()),
40  m_sets(2, (const VectorSet<V,M>*) NULL)
41 {
42  m_sets[0] = &set1;
43  m_sets[1] = &set2;
44 }
const std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:84
std::vector< const VectorSet< V, M > * > m_sets
const VectorSpace< V, M > & vectorSpace() const
Vector space to which this set belongs to. See template specialization.
Definition: VectorSubset.C:68
template<class V , class M >
QUESO::ConcatenationSubset< V, M >::ConcatenationSubset ( const char *  prefix,
const VectorSpace< V, M > &  vectorSpace,
double  volume,
const std::vector< const VectorSet< V, M > * > &  sets 
)

Constructor - collection of sets.

It concatenates a collection of n subsets (using the std::vector to represent such collection) into a new set, m_set, of volume given by sets[0].volume()*sets[1].volume()*...*sets[n-1].volume().

Definition at line 48 of file ConcatenationSubset.C.

References QUESO::ConcatenationSubset< V, M >::m_sets.

52  : VectorSubset<V,M>(prefix, vectorSpace, volume),
53  m_sets(sets.size(), (const VectorSet<V,M>*) NULL)
54 {
55  for (unsigned int i = 0; i < m_sets.size(); ++i) {
56  m_sets[i] = sets[i];
57  }
58 }
const std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:84
double volume() const
Set volume; access to private attribute m_volume.
Definition: VectorSet.C:91
std::vector< const VectorSet< V, M > * > m_sets
const VectorSpace< V, M > & vectorSpace() const
Vector space to which this set belongs to. See template specialization.
Definition: VectorSubset.C:68
template<class V , class M >
QUESO::ConcatenationSubset< V, M >::~ConcatenationSubset ( )

Destructor.

Definition at line 62 of file ConcatenationSubset.C.

63 {
64 }

Member Function Documentation

template<class V , class M >
void QUESO::ConcatenationSubset< V, M >::centroid ( V &  vec) const
virtual

Returns the set centroid in the vector vec.

Implements QUESO::VectorSet< V, M >.

Definition at line 96 of file ConcatenationSubset.C.

References QUESO::queso_require_equal_to_msg.

97 {
98  unsigned int cumulativeSize = 0;
99  for (unsigned int i = 0; i < m_sets.size(); ++i) {
100  V subvec(m_sets[i]->vectorSpace().zeroVector());
101  m_sets[i]->centroid(subvec);
102  vec.cwSet(cumulativeSize,subvec);
103 
104  cumulativeSize += subvec.sizeLocal();
105  }
106 
107  queso_require_equal_to_msg(vec.sizeLocal(), cumulativeSize, "incompatible vector sizes");
108 }
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
std::vector< const VectorSet< V, M > * > m_sets
const VectorSpace< V, M > & vectorSpace() const
Vector space to which this set belongs to. See template specialization.
Definition: VectorSubset.C:68
template<class V , class M >
bool QUESO::ConcatenationSubset< V, M >::contains ( const V &  vec) const
virtual

Determines whether each one of the subsets m_sets (class' private attributes) contains vector vec.

Implements QUESO::VectorSubset< V, M >.

Definition at line 68 of file ConcatenationSubset.C.

References QUESO::queso_require_equal_to_msg.

69 {
70  bool result = true;
71 
72  std::vector<V*> vecs(m_sets.size(),(V*) NULL);
73  for (unsigned int i = 0; i < vecs.size(); ++i) {
74  vecs[i] = new V(m_sets[i]->vectorSpace().zeroVector());
75  }
76 
77  unsigned int cummulativeSize = 0;
78  for (unsigned int i = 0; i < vecs.size(); ++i) {
79  vec.cwExtract(cummulativeSize,*(vecs[i]));
80  cummulativeSize += vecs[i]->sizeLocal();
81  }
82 
83  queso_require_equal_to_msg(vec.sizeLocal(), cummulativeSize, "incompatible vector sizes");
84 
85  for (unsigned int i = 0; i < m_sets.size(); ++i) {
86  result = result && m_sets[i]->contains(*(vecs[i]));
87  }
88  for (unsigned int i = 0; i < vecs.size(); ++i) {
89  delete vecs[i];
90  }
91 
92  return (result);
93 }
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
std::vector< const VectorSet< V, M > * > m_sets
const VectorSpace< V, M > & vectorSpace() const
Vector space to which this set belongs to. See template specialization.
Definition: VectorSubset.C:68
template<class V , class M >
void QUESO::ConcatenationSubset< V, M >::moments ( M &  mat) const
virtual

Returns the set moments of inertia in the matrix mat.

Implements QUESO::VectorSet< V, M >.

Definition at line 111 of file ConcatenationSubset.C.

References QUESO::Map::NumGlobalElements(), and QUESO::queso_require_equal_to_msg.

112 {
113  unsigned int cumulativeSize = 0;
114  for (unsigned int i = 0; i < m_sets.size(); ++i) {
115  const Map & map = m_sets[i]->vectorSpace().map();
116  const unsigned int n_columns = map.NumGlobalElements();
117  M submat(m_sets[i]->vectorSpace().env(),
118  map, n_columns);
119  m_sets[i]->moments(submat);
120  mat.cwSet(cumulativeSize,cumulativeSize,submat);
121 
122  cumulativeSize += n_columns;
123  }
124 
125  queso_require_equal_to_msg(mat.numCols(), cumulativeSize, "incompatible vector sizes");
126 }
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
std::vector< const VectorSet< V, M > * > m_sets
const VectorSpace< V, M > & vectorSpace() const
Vector space to which this set belongs to. See template specialization.
Definition: VectorSubset.C:68
const BaseEnvironment & env() const
Environment. Access to private attribute m_env.
Definition: VectorSet.C:78
template<class V , class M >
void QUESO::ConcatenationSubset< V, M >::print ( std::ostream &  os) const
virtual

Prints the subsets (via protected attribute m_sets).

Reimplemented from QUESO::VectorSubset< V, M >.

Definition at line 130 of file ConcatenationSubset.C.

131 {
132  os << "In ConcatenationSubset<V,M>::print()"
133  << ": m_sets.size() = " << m_sets.size()
134  << std::endl;
135  for (unsigned int i = 0; i < m_sets.size(); ++i) {
136  os << "m_sets[" << i << "] = " << *(m_sets[i]);
137  if (i < (m_sets.size()-1)) {
138  os << ", ";
139  }
140  }
141  os << std::endl;
142 
143  return;
144 }
std::vector< const VectorSet< V, M > * > m_sets

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
std::vector<const VectorSet<V,M>* > QUESO::ConcatenationSubset< V, M >::m_sets
protected

The documentation for this class was generated from the following files:

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