queso-0.51.1
Protected Member Functions | Protected Attributes | List of all members
QUESO::Vector Class Referenceabstract

Class for vector operations (virtual). More...

#include <Vector.h>

Inheritance diagram for QUESO::Vector:
Inheritance graph
[legend]
Collaboration diagram for QUESO::Vector:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 Vector ()
 Default Constructor. More...
 
 Vector (const BaseEnvironment &env, const Map &map)
 Shaped Constructor. More...
 
 Vector (const Vector &rhs)
 Copy Constructor. More...
 
virtual ~Vector ()
 Virtual Destructor. More...
 
Set methods
Vectoroperator= (const Vector &rhs)
 Operator for copying a vector. More...
 
Vectoroperator*= (double a)
 Operator for multiplication of the vector by a scalar. More...
 
Vectoroperator/= (double a)
 Operator for division of the vector by a scalar. More...
 
Vectoroperator+= (const Vector &rhs)
 Operator for addition (element-wise) of two vectors. More...
 
Vectoroperator-= (const Vector &rhs)
 Operator for subtraction (element-wise) of two vectors. More...
 
Environment and Map methods
const BaseEnvironmentenv () const
 
const Mapmap () const
 
unsigned int numOfProcsForStorage () const
 
Attribute methods
virtual unsigned int sizeLocal () const =0
 Returns the local size of the vector. More...
 
virtual unsigned int sizeGlobal () const =0
 Returns the global size of the vector. More...
 
Get/Set methods
virtual void cwSet (double value)=0
 Component-wise set the values of the vector to value. More...
 
virtual void cwSetGaussian (double mean, double stdDev)=0
 Component-wise set the values of the vector to a random number from a Gaussian distribution. More...
 
virtual void cwInvert ()=0
 Component-wise invert the values of the vector. More...
 
I/O and Miscellaneous methods
virtual void sort ()=0
 Sort the elements. More...
 
virtual void print (std::ostream &os) const =0
 Print this vector. More...
 
void setPrintHorizontally (bool value) const
 Determines whether vector should be printed horizontally. More...
 
bool getPrintHorizontally () const
 Checks if vector is printed horizontally. More...
 
void setPrintScientific (bool value) const
 Determines whether vector should be printed in Scientific Notation. More...
 
bool getPrintScientific () const
 Checks if the vector should be printed in Scientific Notation. More...
 

Protected Member Functions

virtual void copy (const Vector &src)
 Copies vector src to this matrix. More...
 

Protected Attributes

const BaseEnvironmentm_env
 Environment variable. More...
 
const Mapm_map
 Mapping variable. More...
 
bool m_printHorizontally
 Flag for either or not print this matrix horizontally. More...
 
bool m_printScientific
 Flag for either or not print this matrix in scientific notation. More...
 

Detailed Description

Class for vector operations (virtual).

Base vector class. The vector class is an abstract class designed to be used as a base class for different vector implementations (all actual vector classes in QUESO).

Definition at line 47 of file Vector.h.

Constructor & Destructor Documentation

QUESO::Vector::Vector ( )

Default Constructor.

Definition at line 32 of file Vector.C.

References m_env, UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

33  :
34  m_env(*(new EmptyEnvironment()) ),
35  m_map(*(new Map( 1,0,*(new MpiComm(m_env,RawValue_MPI_COMM_SELF)) ) )) // avoid using MPI_COMM_WORLD
36 {
38  m_env.worldRank(),
39  "Vector::constructor(), default",
40  "should not be used by user");
41 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
#define RawValue_MPI_COMM_SELF
Definition: MpiComm.h:43
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:142
const Map & m_map
Mapping variable.
Definition: Vector.h:151
QUESO::Vector::Vector ( const BaseEnvironment env,
const Map map 
)

Shaped Constructor.

Definition at line 44 of file Vector.C.

45  :
46  m_env (env),
47  m_map (map),
48  m_printHorizontally(true),
49  m_printScientific (false) // for compatibility with previous regression tests
50 {
51  //std::cout << "Entering Vector::constructor(env,map)" << std::endl;
52 
53  //std::cout << "In Vector::constructor(env,map)" // mox
54  // << ", m_map.NumMyElements() = " << m_map.NumMyElements()
55  // << std::endl;
56 
57  //std::cout << "Leaving Vector::constructor(env,map)" << std::endl;
58 }
const Map & map() const
Definition: Vector.C:143
const BaseEnvironment & env() const
Definition: Vector.C:136
bool m_printHorizontally
Flag for either or not print this matrix horizontally.
Definition: Vector.h:155
bool m_printScientific
Flag for either or not print this matrix in scientific notation.
Definition: Vector.h:158
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:142
const Map & m_map
Mapping variable.
Definition: Vector.h:151
QUESO::Vector::Vector ( const Vector rhs)

Copy Constructor.

Definition at line 61 of file Vector.C.

References m_env, UQ_FATAL_TEST_MACRO, QUESO::UQ_INVALID_INTERNAL_STATE_RC, and QUESO::BaseEnvironment::worldRank().

62  :
63  m_env(rhs.m_env),
64  m_map(rhs.m_map)
65 {
67  m_env.worldRank(),
68  "Vector::constructor(), copy",
69  "code should not execute through here");
70 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:142
const Map & m_map
Mapping variable.
Definition: Vector.h:151
QUESO::Vector::~Vector ( )
virtual

Virtual Destructor.

Definition at line 73 of file Vector.C.

74 {
75 }

Member Function Documentation

void QUESO::Vector::copy ( const Vector src)
protectedvirtual

Copies vector src to this matrix.

Definition at line 183 of file Vector.C.

References m_printHorizontally, and m_printScientific.

Referenced by QUESO::GslVector::copy().

184 {
185  //m_env = src.env;
186  //m_map = src.map; // prudenci 2010-06-17
187  m_printHorizontally = src.m_printHorizontally;
188  m_printScientific = src.m_printScientific;
189 
190  return;
191 }
bool m_printHorizontally
Flag for either or not print this matrix horizontally.
Definition: Vector.h:155
bool m_printScientific
Flag for either or not print this matrix in scientific notation.
Definition: Vector.h:158
virtual void QUESO::Vector::cwInvert ( )
pure virtual

Component-wise invert the values of the vector.

Implemented in QUESO::GslVector.

virtual void QUESO::Vector::cwSet ( double  value)
pure virtual

Component-wise set the values of the vector to value.

Implemented in QUESO::GslVector.

virtual void QUESO::Vector::cwSetGaussian ( double  mean,
double  stdDev 
)
pure virtual

Component-wise set the values of the vector to a random number from a Gaussian distribution.

Implemented in QUESO::GslVector.

const BaseEnvironment & QUESO::Vector::env ( ) const

Definition at line 136 of file Vector.C.

References m_env.

Referenced by QUESO::matrixProduct(), QUESO::operator==(), and QUESO::scalarProduct().

137 {
138  return m_env;
139 }
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:142
bool QUESO::Vector::getPrintHorizontally ( ) const

Checks if vector is printed horizontally.

Definition at line 164 of file Vector.C.

References m_printHorizontally.

Referenced by QUESO::GslVector::subWriteContents().

165 {
166  return m_printHorizontally;
167 }
bool m_printHorizontally
Flag for either or not print this matrix horizontally.
Definition: Vector.h:155
bool QUESO::Vector::getPrintScientific ( ) const

Checks if the vector should be printed in Scientific Notation.

Definition at line 177 of file Vector.C.

References m_printScientific.

Referenced by QUESO::GslVector::subWriteContents().

178 {
179  return m_printScientific;
180 }
bool m_printScientific
Flag for either or not print this matrix in scientific notation.
Definition: Vector.h:158
const Map & QUESO::Vector::map ( ) const

Definition at line 143 of file Vector.C.

References m_map.

Referenced by QUESO::GslVector::GslVector(), and QUESO::matrixProduct().

144 {
145  return m_map;
146 }
const Map & m_map
Mapping variable.
Definition: Vector.h:151
unsigned int QUESO::Vector::numOfProcsForStorage ( ) const

Definition at line 150 of file Vector.C.

References QUESO::Map::Comm(), m_map, and QUESO::MpiComm::NumProc().

Referenced by QUESO::GslVector::subReadContents(), and QUESO::GslVector::subWriteContents().

151 {
152  return m_map.Comm().NumProc();
153 }
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:121
const MpiComm & Comm() const
Access function for MpiComm communicator.
Definition: Map.C:142
const Map & m_map
Mapping variable.
Definition: Vector.h:151
Vector & QUESO::Vector::operator*= ( double  a)

Operator for multiplication of the vector by a scalar.

Definition at line 90 of file Vector.C.

References m_env, UQ_FATAL_TEST_MACRO, QUESO::UQ_INVALID_INTERNAL_STATE_RC, and QUESO::BaseEnvironment::worldRank().

91 {
93  m_env.worldRank(),
94  "Vector::operator*=()",
95  "code should not execute through here");
96  double tmpA = a; tmpA += 1.; // Just to avoid icpc warnings
97  return *this;
98 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:142
Vector & QUESO::Vector::operator+= ( const Vector rhs)

Operator for addition (element-wise) of two vectors.

Definition at line 114 of file Vector.C.

References m_env, UQ_FATAL_TEST_MACRO, QUESO::UQ_INVALID_INTERNAL_STATE_RC, and QUESO::BaseEnvironment::worldRank().

115 {
117  rhs.m_env.worldRank(),
118  "Vector::operator+=()",
119  "code should not execute through here");
120  return *this;
121 }
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
Vector & QUESO::Vector::operator-= ( const Vector rhs)

Operator for subtraction (element-wise) of two vectors.

Definition at line 125 of file Vector.C.

References m_env, UQ_FATAL_TEST_MACRO, QUESO::UQ_INVALID_INTERNAL_STATE_RC, and QUESO::BaseEnvironment::worldRank().

126 {
128  rhs.m_env.worldRank(),
129  "Vector::operator-=()",
130  "code should not execute through here");
131  return *this;
132 }
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
Vector & QUESO::Vector::operator/= ( double  a)

Operator for division of the vector by a scalar.

Definition at line 102 of file Vector.C.

References m_env, UQ_FATAL_TEST_MACRO, QUESO::UQ_INVALID_INTERNAL_STATE_RC, and QUESO::BaseEnvironment::worldRank().

103 {
105  m_env.worldRank(),
106  "Vector::operator/=()",
107  "code should not execute through here");
108  double tmpA = a; tmpA += 1.; // Just to avoid icpc warnings
109  return *this;
110 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:142
Vector & QUESO::Vector::operator= ( const Vector rhs)

Operator for copying a vector.

Definition at line 79 of file Vector.C.

References m_env, UQ_FATAL_TEST_MACRO, QUESO::UQ_INVALID_INTERNAL_STATE_RC, and QUESO::BaseEnvironment::worldRank().

80 {
82  rhs.m_env.worldRank(),
83  "Vector::operator=()",
84  "code should not execute through here");
85  return *this;
86 }
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
virtual void QUESO::Vector::print ( std::ostream &  os) const
pure virtual

Print this vector.

Implemented in QUESO::GslVector.

void QUESO::Vector::setPrintHorizontally ( bool  value) const

Determines whether vector should be printed horizontally.

Definition at line 157 of file Vector.C.

References m_printHorizontally.

Referenced by QUESO::GslVector::subWriteContents().

158 {
159  m_printHorizontally = value;
160  return;
161 }
bool m_printHorizontally
Flag for either or not print this matrix horizontally.
Definition: Vector.h:155
void QUESO::Vector::setPrintScientific ( bool  value) const

Determines whether vector should be printed in Scientific Notation.

Definition at line 170 of file Vector.C.

References m_printScientific.

Referenced by QUESO::GslVector::subWriteContents().

171 {
172  m_printScientific = value;
173  return;
174 }
bool m_printScientific
Flag for either or not print this matrix in scientific notation.
Definition: Vector.h:158
virtual unsigned int QUESO::Vector::sizeGlobal ( ) const
pure virtual

Returns the global size of the vector.

Implemented in QUESO::GslVector.

virtual unsigned int QUESO::Vector::sizeLocal ( ) const
pure virtual

Returns the local size of the vector.

Implemented in QUESO::GslVector.

virtual void QUESO::Vector::sort ( )
pure virtual

Sort the elements.

Implemented in QUESO::GslVector.

Member Data Documentation

const BaseEnvironment& QUESO::Vector::m_env
protected
const Map& QUESO::Vector::m_map
protected
bool QUESO::Vector::m_printHorizontally
mutableprotected

Flag for either or not print this matrix horizontally.

Definition at line 155 of file Vector.h.

Referenced by copy(), getPrintHorizontally(), QUESO::GslVector::print(), and setPrintHorizontally().

bool QUESO::Vector::m_printScientific
mutableprotected

Flag for either or not print this matrix in scientific notation.

Definition at line 158 of file Vector.h.

Referenced by copy(), getPrintScientific(), QUESO::GslVector::print(), and setPrintScientific().


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

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