queso-0.51.1
Vector.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/Vector.h>
26 #include <queso/Defines.h>
27 
28 namespace QUESO {
29 
30 // Default constructor ------------------------------
31 
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 }
42 
43 // Shaped constructor --------------------------------
44 Vector::Vector(const BaseEnvironment& env, const Map& map)
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 }
59 
60 // Copy constructor -----------------------------------
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 }
71 
72 // Destructor ---------------------------------------
74 {
75 }
76 
77 // Set methods --------------------------------------
78 Vector&
80 {
82  rhs.m_env.worldRank(),
83  "Vector::operator=()",
84  "code should not execute through here");
85  return *this;
86 }
87 
88 // --------------------------------------------------
89 Vector&
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 }
99 
100 // --------------------------------------------------
101 Vector&
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 }
111 
112 // --------------------------------------------------
113 Vector&
115 {
117  rhs.m_env.worldRank(),
118  "Vector::operator+=()",
119  "code should not execute through here");
120  return *this;
121 }
122 
123 // --------------------------------------------------
124 Vector&
126 {
128  rhs.m_env.worldRank(),
129  "Vector::operator-=()",
130  "code should not execute through here");
131  return *this;
132 }
133 
134 // Environment and Map methods ----------------------
135 const BaseEnvironment&
136 Vector::env() const
137 {
138  return m_env;
139 }
140 
141 // --------------------------------------------------
142 const Map&
143 Vector::map() const
144 {
145  return m_map;
146 }
147 
148 // --------------------------------------------------
149 unsigned int
151 {
152  return m_map.Comm().NumProc();
153 }
154 
155 // I/O and Miscellaneous methods --------------------
156 void
158 {
159  m_printHorizontally = value;
160  return;
161 }
162 // --------------------------------------------------
163 bool
165 {
166  return m_printHorizontally;
167 }
168 // --------------------------------------------------
169 void
170 Vector::setPrintScientific(bool value) const
171 {
172  m_printScientific = value;
173  return;
174 }
175 // --------------------------------------------------
176 bool
178 {
179  return m_printScientific;
180 }
181 // --------------------------------------------------
182 void
183 Vector::copy(const Vector& src)
184 {
185  //m_env = src.env;
186  //m_map = src.map; // prudenci 2010-06-17
189 
190  return;
191 }
192 
193 } // End namespace QUESO
The QUESO MPI Communicator Class.
Definition: MpiComm.h:75
A class for partitioning vectors and matrices.
Definition: Map.h:49
const Map & map() const
Definition: Vector.C:143
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:121
bool getPrintScientific() const
Checks if the vector should be printed in Scientific Notation.
Definition: Vector.C:177
This class sets up the environment underlying the use of the QUESO library by an executable.
Definition: Environment.h:396
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
const BaseEnvironment & env() const
Definition: Vector.C:136
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:187
Vector & operator*=(double a)
Operator for multiplication of the vector by a scalar.
Definition: Vector.C:90
Vector & operator=(const Vector &rhs)
Operator for copying a vector.
Definition: Vector.C:79
Vector()
Default Constructor.
Definition: Vector.C:32
bool m_printHorizontally
Flag for either or not print this matrix horizontally.
Definition: Vector.h:155
const MpiComm & Comm() const
Access function for MpiComm communicator.
Definition: Map.C:142
Vector & operator+=(const Vector &rhs)
Operator for addition (element-wise) of two vectors.
Definition: Vector.C:114
bool getPrintHorizontally() const
Checks if vector is printed horizontally.
Definition: Vector.C:164
void setPrintHorizontally(bool value) const
Determines whether vector should be printed horizontally.
Definition: Vector.C:157
#define RawValue_MPI_COMM_SELF
Definition: MpiComm.h:43
virtual void copy(const Vector &src)
Copies vector src to this matrix.
Definition: Vector.C:183
Vector & operator/=(double a)
Operator for division of the vector by a scalar.
Definition: Vector.C:102
unsigned int numOfProcsForStorage() const
Definition: Vector.C:150
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
Class for vector operations (virtual).
Definition: Vector.h:47
Vector & operator-=(const Vector &rhs)
Operator for subtraction (element-wise) of two vectors.
Definition: Vector.C:125
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
virtual ~Vector()
Virtual Destructor.
Definition: Vector.C:73
void setPrintScientific(bool value) const
Determines whether vector should be printed in Scientific Notation.
Definition: Vector.C:170
const Map & m_map
Mapping variable.
Definition: Vector.h:151

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