queso-0.53.0
Protected Attributes | List of all members
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 >:
Inheritance graph
[legend]
Collaboration diagram for QUESO::ConcatenationSubset< V, M >:
Collaboration graph
[legend]

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...
 
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 }
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 std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:84
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 }
std::vector< const VectorSet< V, M > * > m_sets
double volume() const
Set volume; access to private attribute m_volume.
Definition: VectorSet.C:91
const VectorSpace< V, M > & vectorSpace() const
Vector space to which this set belongs to. See template specialization.
Definition: VectorSubset.C:68
const std::string & prefix() const
Access to private attribute m_prefix.
Definition: VectorSet.C:84
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 >
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_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 }
std::vector< const VectorSet< V, M > * > m_sets
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
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 >::print ( std::ostream &  os) const
virtual

Prints the subsets (via protected attribute m_sets).

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

Definition at line 97 of file ConcatenationSubset.C.

98 {
99  os << "In ConcatenationSubset<V,M>::print()"
100  << ": m_sets.size() = " << m_sets.size()
101  << std::endl;
102  for (unsigned int i = 0; i < m_sets.size(); ++i) {
103  os << "m_sets[" << i << "] = " << *(m_sets[i]);
104  if (i < (m_sets.size()-1)) {
105  os << ", ";
106  }
107  }
108  os << std::endl;
109 
110  return;
111 }
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 Thu Jun 11 2015 13:52:33 for queso-0.53.0 by  doxygen 1.8.5