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

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

#include <Matrix.h>

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

Public Member Functions

Constructor/Destructor methods
 Matrix ()
 Default constructor. More...
 
 Matrix (const BaseEnvironment &env, const Map &map)
 Shaped constructor. More...
 
 Matrix (const Matrix &rhs)
 Copy constructor. More...
 
virtual ~Matrix ()
 Virtual Destructor. More...
 
Set methods
Matrixoperator= (const Matrix &rhs)
 Operator for copying a matrix. More...
 
Matrixoperator*= (double a)
 Operator for multiplication of the matrix by a scalar. More...
 
Matrixoperator+= (const Matrix &rhs)
 Operator for addition (element-wise) of two matrices. More...
 
Matrixoperator-= (const Matrix &rhs)
 Operator for subtraction (element-wise) of two matrices. More...
 
Environment and Map methods
const BaseEnvironmentenv () const
 
const Mapmap () const
 
unsigned int numOfProcsForStorage () const
 
Attribute methods
virtual unsigned int numRowsLocal () const =0
 Returns the number of rows local of the matrix. More...
 
virtual unsigned int numRowsGlobal () const =0
 Returns the number of rows global of the matrix. More...
 
virtual unsigned int numCols () const =0
 Returns the number of columns local of the matrix. More...
 
Mathematical methods
virtual int chol ()=0
 Performs Cholesky factorization of the matrix. More...
 
Get/Set methods
virtual void zeroLower (bool includeDiagonal=false)=0
 Sets to zero all the elements bellow (including or not) the diagonal of the matrix. More...
 
virtual void zeroUpper (bool includeDiagonal=false)=0
 Sets to zero all the elements above (including or not) the diagonal of the matrix. More...
 
I/O and Miscellaneous methods
virtual void print (std::ostream &os) const =0
 Print this matrix. More...
 
void setPrintHorizontally (bool value) const
 Determines whether the matrix should be printed horizontally. More...
 
bool getPrintHorizontally () const
 Checks if matrix will be is printed horizontally. More...
 
void setInDebugMode (bool value) const
 Determines whether QUESO will run through this class in debug mode. More...
 
bool getInDebugMode () const
 Checks if QUESO will run through this class in debug mode. More...
 

Protected Member Functions

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

Protected Attributes

const BaseEnvironmentm_env
 QUESO environment variable. More...
 
const Mapm_map
 Mapping variable. More...
 
bool m_printHorizontally
 Flag for either or not print this matrix. More...
 
bool m_inDebugMode
 Flag for either or not QUESO is in debug mode. More...
 

Detailed Description

Class for matrix operations (virtual).

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

Definition at line 46 of file Matrix.h.

Constructor & Destructor Documentation

QUESO::Matrix::Matrix ( )

Default constructor.

Definition at line 31 of file Matrix.C.

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

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 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const Map & m_map
Mapping variable.
Definition: Matrix.h:147
#define RawValue_MPI_COMM_SELF
Definition: MpiComm.h:43
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:137
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
QUESO::Matrix::Matrix ( const BaseEnvironment env,
const Map map 
)

Shaped constructor.

Definition at line 43 of file Matrix.C.

44  :
45  m_env (env),
46  m_map (map),
47  m_printHorizontally(true),
48  m_inDebugMode (false)
49 {
50 }
const BaseEnvironment & env() const
Definition: Matrix.C:116
bool m_inDebugMode
Flag for either or not QUESO is in debug mode.
Definition: Matrix.h:155
const Map & m_map
Mapping variable.
Definition: Matrix.h:147
bool m_printHorizontally
Flag for either or not print this matrix.
Definition: Matrix.h:152
const Map & map() const
Definition: Matrix.C:123
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:137
QUESO::Matrix::Matrix ( const Matrix rhs)

Copy constructor.

Definition at line 53 of file Matrix.C.

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

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 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
const Map & m_map
Mapping variable.
Definition: Matrix.h:147
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:137
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
QUESO::Matrix::~Matrix ( )
virtual

Virtual Destructor.

Definition at line 65 of file Matrix.C.

66 {
67 }

Member Function Documentation

virtual int QUESO::Matrix::chol ( )
pure virtual

Performs Cholesky factorization of the matrix.

Implemented in QUESO::GslMatrix.

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

Copies matrix src to this matrix.

Definition at line 168 of file Matrix.C.

References m_inDebugMode, and m_printHorizontally.

Referenced by QUESO::GslMatrix::GslMatrix().

169 {
170  //m_env = src.env;
171  //m_map = src.map;
172  m_printHorizontally = src.m_printHorizontally;
173  m_inDebugMode = src.m_inDebugMode;
174 
175  return;
176 }
bool m_inDebugMode
Flag for either or not QUESO is in debug mode.
Definition: Matrix.h:155
bool m_printHorizontally
Flag for either or not print this matrix.
Definition: Matrix.h:152
const BaseEnvironment & QUESO::Matrix::env ( ) const
bool QUESO::Matrix::getInDebugMode ( ) const

Checks if QUESO will run through this class in debug mode.

Definition at line 161 of file Matrix.C.

References m_inDebugMode.

162 {
163  return m_inDebugMode;
164 }
bool m_inDebugMode
Flag for either or not QUESO is in debug mode.
Definition: Matrix.h:155
bool QUESO::Matrix::getPrintHorizontally ( ) const

Checks if matrix will be is printed horizontally.

Definition at line 146 of file Matrix.C.

References m_printHorizontally.

147 {
148  return m_printHorizontally;
149 }
bool m_printHorizontally
Flag for either or not print this matrix.
Definition: Matrix.h:152
const Map & QUESO::Matrix::map ( ) const

Definition at line 123 of file Matrix.C.

References m_map.

Referenced by QUESO::GslMatrix::internalSvd(), QUESO::operator*(), and QUESO::GslMatrix::svdSolve().

124 {
125  return m_map;
126  //return (const Map&) (m_mat->Map());
127 }
const Map & m_map
Mapping variable.
Definition: Matrix.h:147
virtual unsigned int QUESO::Matrix::numCols ( ) const
pure virtual

Returns the number of columns local of the matrix.

Implemented in QUESO::GslMatrix.

unsigned int QUESO::Matrix::numOfProcsForStorage ( ) const

Definition at line 131 of file Matrix.C.

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

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

132 {
133  return m_map.Comm().NumProc();
134 }
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: Matrix.h:147
virtual unsigned int QUESO::Matrix::numRowsGlobal ( ) const
pure virtual

Returns the number of rows global of the matrix.

Implemented in QUESO::GslMatrix.

virtual unsigned int QUESO::Matrix::numRowsLocal ( ) const
pure virtual

Returns the number of rows local of the matrix.

Implemented in QUESO::GslMatrix.

Matrix & QUESO::Matrix::operator*= ( double  a)

Operator for multiplication of the matrix by a scalar.

Definition at line 82 of file Matrix.C.

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

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 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
const BaseEnvironment & m_env
QUESO environment variable.
Definition: Matrix.h:137
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
Matrix & QUESO::Matrix::operator+= ( const Matrix rhs)

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

Definition at line 94 of file Matrix.C.

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

95 {
97  rhs.m_env.worldRank(),
98  "Matrix::operator+=()",
99  "code should not execute through here");
100  return *this;
101 }
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
Matrix & QUESO::Matrix::operator-= ( const Matrix rhs)

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

Definition at line 105 of file Matrix.C.

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

106 {
108  rhs.m_env.worldRank(),
109  "Matrix::operator-=()",
110  "code should not execute through here");
111  return *this;
112 }
const int UQ_INVALID_INTERNAL_STATE_RC
Definition: Defines.h:82
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
Matrix & QUESO::Matrix::operator= ( const Matrix rhs)

Operator for copying a matrix.

Definition at line 71 of file Matrix.C.

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

72 {
74  rhs.m_env.worldRank(),
75  "Matrix::operator=()",
76  "code should not execute through here");
77  return *this;
78 }
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::Matrix::print ( std::ostream &  os) const
pure virtual

Print this matrix.

Implemented in QUESO::GslMatrix.

void QUESO::Matrix::setInDebugMode ( bool  value) const

Determines whether QUESO will run through this class in debug mode.

Definition at line 153 of file Matrix.C.

References m_inDebugMode.

154 {
155  m_inDebugMode = value;
156  return;
157 }
bool m_inDebugMode
Flag for either or not QUESO is in debug mode.
Definition: Matrix.h:155
void QUESO::Matrix::setPrintHorizontally ( bool  value) const

Determines whether the matrix should be printed horizontally.

Definition at line 138 of file Matrix.C.

References m_printHorizontally.

139 {
140  m_printHorizontally = value;
141  return;
142 }
bool m_printHorizontally
Flag for either or not print this matrix.
Definition: Matrix.h:152
virtual void QUESO::Matrix::zeroLower ( bool  includeDiagonal = false)
pure virtual

Sets to zero all the elements bellow (including or not) the diagonal of the matrix.

Implemented in QUESO::GslMatrix.

virtual void QUESO::Matrix::zeroUpper ( bool  includeDiagonal = false)
pure virtual

Sets to zero all the elements above (including or not) the diagonal of the matrix.

Implemented in QUESO::GslMatrix.

Member Data Documentation

const BaseEnvironment& QUESO::Matrix::m_env
protected
bool QUESO::Matrix::m_inDebugMode
mutableprotected

Flag for either or not QUESO is in debug mode.

Definition at line 155 of file Matrix.h.

Referenced by copy(), getInDebugMode(), QUESO::GslMatrix::invertMultiply(), and setInDebugMode().

const Map& QUESO::Matrix::m_map
protected
bool QUESO::Matrix::m_printHorizontally
mutableprotected

Flag for either or not print this matrix.

Definition at line 152 of file Matrix.h.

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


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

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