queso-0.51.1
Matrix.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/Matrix.h>
26 #include <queso/Defines.h>
27 
28 namespace QUESO {
29 
30 // Default constructor ------------------------------
32  :
33  m_env(*(new EmptyEnvironment()) ),
34  m_map(*(new Map( 1,0,*(new MpiComm(m_env,RawValue_MPI_COMM_SELF)) ) )) // avoid using MPI_COMM_WORLD
35 {
37  m_env.worldRank(),
38  "Matrix::constructor(), default",
39  "should not be used by user");
40 }
41 
42 // Shaped constructor --------------------------------
43 Matrix::Matrix(const BaseEnvironment& env, const Map& map)
44  :
45  m_env (env),
46  m_map (map),
47  m_printHorizontally(true),
48  m_inDebugMode (false)
49 {
50 }
51 
52 // Copy constructor -----------------------------------
54  :
55  m_env(rhs.m_env),
56  m_map(rhs.m_map)
57 {
59  m_env.worldRank(),
60  "Matrix::constructor(), copy",
61  "code should not execute through here");
62 }
63 
64 // Destructor ---------------------------------------
66 {
67 }
68 
69 // Set methods --------------------------------------
70 Matrix&
72 {
74  rhs.m_env.worldRank(),
75  "Matrix::operator=()",
76  "code should not execute through here");
77  return *this;
78 }
79 
80 // --------------------------------------------------
81 Matrix&
83 {
85  m_env.worldRank(),
86  "Matrix::operator*=()",
87  "code should not execute through here");
88  double tmpA = a; tmpA += 1.; // Just to avoid icpc warnings
89  return *this;
90 }
91 
92 // --------------------------------------------------
93 Matrix&
95 {
97  rhs.m_env.worldRank(),
98  "Matrix::operator+=()",
99  "code should not execute through here");
100  return *this;
101 }
102 
103 // --------------------------------------------------
104 Matrix&
106 {
108  rhs.m_env.worldRank(),
109  "Matrix::operator-=()",
110  "code should not execute through here");
111  return *this;
112 }
113 
114 // Environment and Map methods ----------------------
115 const BaseEnvironment&
116 Matrix::env() const
117 {
118  return m_env;
119 }
120 
121 // --------------------------------------------------
122 const Map&
123 Matrix::map() const
124 {
125  return m_map;
126  //return (const Map&) (m_mat->Map());
127 }
128 
129 // --------------------------------------------------
130 unsigned int
132 {
133  return m_map.Comm().NumProc();
134 }
135 
136 // I/O and Miscellaneous methods --------------------
137 void
139 {
140  m_printHorizontally = value;
141  return;
142 }
143 
144 // --------------------------------------------------
145 bool
147 {
148  return m_printHorizontally;
149 }
150 
151 // --------------------------------------------------
152 void
153 Matrix::setInDebugMode(bool value) const
154 {
155  m_inDebugMode = value;
156  return;
157 }
158 
159 // --------------------------------------------------
160 bool
162 {
163  return m_inDebugMode;
164 }
165 
166 // --------------------------------------------------
167 void
168 Matrix::copy(const Matrix& src)
169 {
170  //m_env = src.env;
171  //m_map = src.map;
174 
175  return;
176 }
177 
178 } // End namespace QUESO
The QUESO MPI Communicator Class.
Definition: MpiComm.h:75
A class for partitioning vectors and matrices.
Definition: Map.h:49
const BaseEnvironment & env() const
Definition: Matrix.C:116
Matrix & operator*=(double a)
Operator for multiplication of the matrix by a scalar.
Definition: Matrix.C:82
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
Matrix & operator-=(const Matrix &rhs)
Operator for subtraction (element-wise) of two matrices.
Definition: Matrix.C:105
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:121
Matrix()
Default constructor.
Definition: Matrix.C:31
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
virtual void copy(const Matrix &src)
Copies matrix src to this matrix.
Definition: Matrix.C:168
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:187
Class for matrix operations (virtual).
Definition: Matrix.h:46
const MpiComm & Comm() const
Access function for MpiComm communicator.
Definition: Map.C:142
bool m_inDebugMode
Flag for either or not QUESO is in debug mode.
Definition: Matrix.h:155
Matrix & operator=(const Matrix &rhs)
Operator for copying a matrix.
Definition: Matrix.C:71
virtual ~Matrix()
Virtual Destructor.
Definition: Matrix.C:65
const Map & m_map
Mapping variable.
Definition: Matrix.h:147
bool getInDebugMode() const
Checks if QUESO will run through this class in debug mode.
Definition: Matrix.C:161
bool m_printHorizontally
Flag for either or not print this matrix.
Definition: Matrix.h:152
const Map & map() const
Definition: Matrix.C:123
#define RawValue_MPI_COMM_SELF
Definition: MpiComm.h:43
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:137
bool getPrintHorizontally() const
Checks if matrix will be is printed horizontally.
Definition: Matrix.C:146
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
Matrix & operator+=(const Matrix &rhs)
Operator for addition (element-wise) of two matrices.
Definition: Matrix.C:94
void setInDebugMode(bool value) const
Determines whether QUESO will run through this class in debug mode.
Definition: Matrix.C:153
unsigned int numOfProcsForStorage() const
Definition: Matrix.C:131
void setPrintHorizontally(bool value) const
Determines whether the matrix should be printed horizontally.
Definition: Matrix.C:138

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