queso-0.56.1
Public Member Functions | Private Member Functions | Private Attributes | List of all members
QUESO::GslVector Class Reference

Class for vector operations using GSL library. More...

#include <GslVector.h>

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

Public Member Functions

void sort ()
 This function sorts the elements of the vector this in ascending numerical order. More...
 
void matlabDiff (unsigned int firstPositionToStoreDiff, double valueForRemainderPosition, GslVector &outputVec) const
 
void matlabLinearInterpExtrap (const GslVector &x1Vec, const GslVector &y1Vec, const GslVector &x2Vec)
 
void mpiBcast (int srcRank, const MpiComm &bcastComm)
 
void mpiAllReduce (RawType_MPI_Op mpiOperation, const MpiComm &opComm, GslVector &resultVec) const
 
void mpiAllQuantile (double probability, const MpiComm &opComm, GslVector &resultVec) const
 
void subWriteContents (const std::string &varNamePrefix, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
 
void subReadContents (const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds)
 
gsl_vector * data () const
 
Constructor/Destructor methods.
 GslVector (const BaseEnvironment &env, const Map &map)
 
 GslVector (const BaseEnvironment &env, const Map &map, double value)
 
 GslVector (const BaseEnvironment &env, double d1, double d2, const Map &map)
 
 GslVector (const GslVector &v, double start, double end)
 Construct a vector, with length the same as v, with evenly spaced numbers from start to end, inclusive. More...
 
 GslVector (const GslVector &y)
 
 ~GslVector ()
 Destructor. More...
 
Set methods.
GslVectoroperator= (const GslVector &rhs)
 Copies values from vector rhs to this. More...
 
GslVectoroperator*= (double a)
 Stores in this the coordinate-wise multiplication of this and a. More...
 
GslVectoroperator/= (double a)
 Stores in this the coordinate-wise division of this by a. More...
 
GslVectoroperator*= (const GslVector &rhs)
 Stores in this the coordinate-wise multiplication of this with rhs. More...
 
GslVectoroperator/= (const GslVector &rhs)
 Stores in this the coordinate-wise division of this by rhs. More...
 
GslVectoroperator+= (const GslVector &rhs)
 Stores in this the coordinate-wise addition of this and rhs. More...
 
GslVectoroperator-= (const GslVector &rhs)
 Stores in this the coordinate-wise subtraction of this by rhs. More...
 
void cwSet (double value)
 Component-wise sets all values to this with value. More...
 
void cwSetGaussian (double mean, double stdDev)
 This function sets component-wise Gaussian random variates, with mean mean and standard deviation stdDev. More...
 
void cwSetGaussian (const GslVector &meanVec, const GslVector &stdDevVec)
 This function sets component-wise Gaussian random variates, with vectors for mean and standard deviation. More...
 
void cwSetUniform (const GslVector &aVec, const GslVector &bVec)
 This function sets component-wise a number uniformly distributed in the range of elements of [aVec,bVec]. More...
 
void cwSetBeta (const GslVector &alpha, const GslVector &beta)
 This function returns a random variate from the beta distribution, with vector parameters alpha and beta. More...
 
void cwSetGamma (const GslVector &a, const GslVector &b)
 This function returns a random variate from the gamma distribution with vector parameters a and b. More...
 
void cwSetInverseGamma (const GslVector &alpha, const GslVector &beta)
 This function returns a random variate from the inverse gamma distribution with vector parameters alpha and beta. More...
 
void cwSetConcatenated (const GslVector &v1, const GslVector &v2)
 This function concatenates GslVector v1 and GslVector v2 into this. More...
 
void cwSetConcatenated (const std::vector< const GslVector * > &vecs)
 This function concatenates vectors v1 and v2 into this vector. More...
 
void cwSet (unsigned int initialPos, const GslVector &vec)
 This function sets the vector vec into this starting at position initialPos. More...
 
void cwExtract (unsigned int initialPos, GslVector &vec) const
 This function sets the values of this starting at position initialPos ans saves them in vector vec. More...
 
void cwInvert ()
 This function inverts component-wise the element values of this. More...
 
void cwSqrt ()
 This function returns component-wise the square-root of this. More...
 
Accessor methods.
double & operator[] (unsigned int i)
 Element access method (non-const). More...
 
const double & operator[] (unsigned int i) const
 Element access method (const). More...
 
Attribute methods.
unsigned int sizeLocal () const
 Returns the length of this vector. More...
 
unsigned int sizeGlobal () const
 Returns the global length of this vector. More...
 
double getMaxValue () const
 Returns the maximum value in the vector this. More...
 
double getMinValue () const
 Returns minimum value in the vector this. More...
 
int getMaxValueIndex () const
 This function returns the index of the maximum value in the vector this. More...
 
int getMinValueIndex () const
 This function returns the index of the minimum value in the vector this. More...
 
void getMaxValueAndIndex (double &value, int &index)
 This function returns maximum value in the vector this and its the index. More...
 
void getMinValueAndIndex (double &value, int &index)
 This function returns minimum value in the vector this and its the index. More...
 
GslVector abs () const
 This function returns absolute value of elements in this. More...
 
Mathematical methods.
double norm2Sq () const
 Returns the 2-norm squared of this vector. More...
 
double norm2 () const
 Returns the 2-norm (Euclidean norm) of the vector. More...
 
double norm1 () const
 Returns the 1-norm of the vector. More...
 
double normInf () const
 Returns the infinity-norm (maximum norm) of the vector. More...
 
double sumOfComponents () const
 Returns the sum of the components of the vector. More...
 
I/O methods.
void print (std::ostream &os) const
 Print method. Defines the behavior of the std::ostream << operator inherited from the Object class. More...
 
Comparison methods.
bool atLeastOneComponentSmallerThan (const GslVector &rhs) const
 This function returns true if at least one component of this is smaller than the respective component of rhs. More...
 
bool atLeastOneComponentBiggerThan (const GslVector &rhs) const
 This function returns true if at least one component of this is bigger than the respective component of rhs. More...
 
bool atLeastOneComponentSmallerOrEqualThan (const GslVector &rhs) const
 This function returns true if at least one component of this is smaller than or equal to the respective component of rhs. More...
 
bool atLeastOneComponentBiggerOrEqualThan (const GslVector &rhs) const
 This function returns true if at least one component of this is bigger than or equal to the respective component of rhs. More...
 
- Public Member Functions inherited from QUESO::Vector
 Vector (const BaseEnvironment &env, const Map &map)
 Shaped Constructor. More...
 
virtual ~Vector ()
 Virtual Destructor. More...
 
const BaseEnvironmentenv () const
 
const Mapmap () const
 
unsigned int numOfProcsForStorage () const
 
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...
 

Private Member Functions

 GslVector ()
 Default Constructor. More...
 
void copy (const GslVector &src)
 This function copies the elements of the vector src into this. More...
 

Private Attributes

gsl_vector * m_vec
 GSL vector. More...
 

Additional Inherited Members

- Protected Member Functions inherited from QUESO::Vector
virtual void base_copy (const Vector &src)
 Copies base data from vector src to this vector. More...
 
- Protected Attributes inherited from QUESO::Vector
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 using GSL library.

This class creates and provides basic support for vectors of templated type as a specialization of Vector using GSL vectors, which are defined by an encapsulated gsl_vector structure.

Definition at line 49 of file GslVector.h.

Constructor & Destructor Documentation

QUESO::GslVector::GslVector ( const BaseEnvironment env,
const Map map 
)

Definition at line 33 of file GslVector.C.

References QUESO::Vector::m_map, m_vec, QUESO::Map::NumGlobalElements(), QUESO::Map::NumMyElements(), queso_require_equal_to_msg, and queso_require_msg.

34  :
35  Vector(env,map),
36  m_vec (gsl_vector_calloc(map.NumGlobalElements()))
37 {
38  //std::cout << "Entering GslVector::constructor(1)" << std::endl;
39 
40  queso_require_msg(m_vec, "null vector generated");
41 
42  queso_require_equal_to_msg(m_vec->size, (unsigned int) map.NumMyElements(), "incompatible local vec size");
43 
44  queso_require_equal_to_msg(m_vec->size, (unsigned int) map.NumGlobalElements(), "incompatible global vec size");
45 
46  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumMyElements(), "incompatible own vec size");
47 
48  //std::cout << "In GslVector::constructor(env,map)"
49  // << "\n m_vec->size = " << m_vec->size
50  // << "\n map.NumGlobalElements() = " << map.NumGlobalElements()
51  // << "\n map.NumMyElements() = " << map.NumMyElements()
52  // << std::endl;
53 
54 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
const Map & m_map
Mapping variable.
Definition: Vector.h:126
const Map & map() const
Definition: Vector.C:61
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
const BaseEnvironment & env() const
Definition: Vector.C:54
Vector()
Default Constructor.
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
QUESO::GslVector::GslVector ( const BaseEnvironment env,
const Map map,
double  value 
)

Definition at line 56 of file GslVector.C.

References cwSet(), QUESO::Vector::m_map, m_vec, QUESO::Map::NumGlobalElements(), QUESO::Map::NumMyElements(), queso_require_equal_to_msg, and queso_require_msg.

57  :
58  Vector(env,map),
59  m_vec (gsl_vector_calloc(map.NumGlobalElements()))
60 {
61  //std::cout << "Entering GslVector::constructor(2)" << std::endl;
62 
63  queso_require_msg(m_vec, "null vector generated");
64 
65  queso_require_equal_to_msg(m_vec->size, (unsigned int) map.NumMyElements(), "incompatible local vec size");
66 
67  queso_require_equal_to_msg(m_vec->size, (unsigned int) map.NumGlobalElements(), "incompatible global vec size");
68 
69  this->cwSet(value);
70 
71  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumMyElements(), "incompatible own vec size");
72 
73  //std::cout << "Leaving GslVector::constructor(2)" << std::endl;
74 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
const Map & m_map
Mapping variable.
Definition: Vector.h:126
const Map & map() const
Definition: Vector.C:61
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
const BaseEnvironment & env() const
Definition: Vector.C:54
void cwSet(double value)
Component-wise sets all values to this with value.
Definition: GslVector.C:326
Vector()
Default Constructor.
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
QUESO::GslVector::GslVector ( const BaseEnvironment env,
double  d1,
double  d2,
const Map map 
)

Definition at line 76 of file GslVector.C.

References QUESO::Vector::m_map, m_vec, QUESO::Map::NumGlobalElements(), QUESO::Map::NumMyElements(), queso_require_equal_to_msg, and queso_require_msg.

77  :
78  Vector(env,map),
79  m_vec (gsl_vector_calloc(map.NumGlobalElements()))
80 {
81  //std::cout << "Entering GslVector::constructor(3)" << std::endl;
82 
83  queso_require_msg(m_vec, "null vector generated");
84 
85  queso_require_equal_to_msg(m_vec->size, (unsigned int) map.NumMyElements(), "incompatible local vec size");
86 
87  queso_require_equal_to_msg(m_vec->size, (unsigned int) map.NumGlobalElements(), "incompatible global vec size");
88 
89  for (unsigned int i = 0; i < m_vec->size; ++i) {
90  double alpha = (double) i / ((double) m_vec->size - 1.);
91  (*this)[i] = (1.-alpha)*d1 + alpha*d2;
92  }
93 
94  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumMyElements(), "incompatible own vec size");
95 
96  //std::cout << "Leaving GslVector::constructor(3)" << std::endl;
97 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
const Map & m_map
Mapping variable.
Definition: Vector.h:126
const Map & map() const
Definition: Vector.C:61
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
const BaseEnvironment & env() const
Definition: Vector.C:54
Vector()
Default Constructor.
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
QUESO::GslVector::GslVector ( const GslVector v,
double  start,
double  end 
)

Construct a vector, with length the same as v, with evenly spaced numbers from start to end, inclusive.

Definition at line 99 of file GslVector.C.

References QUESO::Vector::m_map, m_vec, QUESO::Vector::map(), QUESO::Map::NumGlobalElements(), QUESO::Map::NumMyElements(), queso_require_equal_to_msg, and queso_require_msg.

100  :
101  Vector(v.env(),v.map()),
102  m_vec (gsl_vector_calloc(v.sizeLocal()))
103 {
104  //std::cout << "Entering GslVector::constructor(4)" << std::endl;
105 
106  queso_require_msg(m_vec, "null vector generated");
107 
108  queso_require_equal_to_msg(m_vec->size, (unsigned int) v.map().NumMyElements(), "incompatible local vec size");
109 
110  queso_require_equal_to_msg(m_vec->size, (unsigned int) v.map().NumGlobalElements(), "incompatible global vec size");
111 
112  for (unsigned int i = 0; i < m_vec->size; ++i) {
113  double alpha = (double) i / ((double) m_vec->size - 1.);
114  (*this)[i] = (1. - alpha) * start + alpha * end;
115  }
116 
117  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumMyElements(), "incompatible own vec size");
118 
119  //std::cout << "Leaving GslVector::constructor(4)" << std::endl;
120 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
const Map & m_map
Mapping variable.
Definition: Vector.h:126
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
Vector()
Default Constructor.
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
QUESO::GslVector::GslVector ( const GslVector y)

Definition at line 122 of file GslVector.C.

References copy(), QUESO::Vector::m_map, m_vec, QUESO::Vector::map(), QUESO::Map::NumGlobalElements(), QUESO::Map::NumMyElements(), queso_require_equal_to_msg, and queso_require_msg.

123  :
124  Vector(v.env(),v.map()),
125  m_vec (gsl_vector_calloc(v.sizeLocal()))
126 {
127  //std::cout << "Entering GslVector::constructor(5)" << std::endl;
128 
129  // prudenci 2010-06-17 mox
130  queso_require_msg(m_vec, "null vector generated");
131 
132  queso_require_equal_to_msg(m_vec->size, (unsigned int) v.map().NumMyElements(), "incompatible local vec size");
133 
134  queso_require_equal_to_msg(m_vec->size, (unsigned int) v.map().NumGlobalElements(), "incompatible global vec size");
135 
136  this->copy(v);
137 
138  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumMyElements(), "incompatible own vec size");
139 
140  //std::cout << "Leaving GslVector::constructor(5)" << std::endl;
141 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
const Map & m_map
Mapping variable.
Definition: Vector.h:126
void copy(const GslVector &src)
This function copies the elements of the vector src into this.
Definition: GslVector.C:229
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
Vector()
Default Constructor.
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
QUESO::GslVector::~GslVector ( )

Destructor.

Definition at line 143 of file GslVector.C.

References m_vec.

144 {
145  if (m_vec) gsl_vector_free(m_vec);
146 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
QUESO::GslVector::GslVector ( )
private

Default Constructor.

Creates an empty vector of no length.

Member Function Documentation

GslVector QUESO::GslVector::abs ( ) const

This function returns absolute value of elements in this.

Definition at line 1081 of file GslVector.C.

References sizeLocal().

Referenced by QUESO::GslMatrix::largestEigen(), and QUESO::GslMatrix::smallestEigen().

1082 {
1083  GslVector abs_of_this_vec( *this );
1084 
1085  unsigned int size = abs_of_this_vec.sizeLocal();
1086 
1087  for( unsigned int i = 0; i < size; ++i )
1088  {
1089  abs_of_this_vec[i] = std::fabs( (*this)[i] );
1090  }
1091 
1092  return abs_of_this_vec;
1093 }
GslVector()
Default Constructor.
bool QUESO::GslVector::atLeastOneComponentBiggerOrEqualThan ( const GslVector rhs) const

This function returns true if at least one component of this is bigger than or equal to the respective component of rhs.

Definition at line 1023 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

1024 {
1025  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");
1026 
1027  bool result = false;
1028  unsigned int i = 0;
1029  unsigned int size = this->sizeLocal();
1030  while ((i < size) && (result == false)) {
1031  result = ( (*this)[i] >= rhs[i] ); // prudencio 2012-02-06
1032  i++;
1033  };
1034 
1035  return result;
1036 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
bool QUESO::GslVector::atLeastOneComponentBiggerThan ( const GslVector rhs) const

This function returns true if at least one component of this is bigger than the respective component of rhs.

Definition at line 991 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

992 {
993  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");
994 
995  bool result = false;
996  unsigned int i = 0;
997  unsigned int size = this->sizeLocal();
998  while ((i < size) && (result == false)) {
999  result = ( (*this)[i] > rhs[i] );
1000  i++;
1001  };
1002 
1003  return result;
1004 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
bool QUESO::GslVector::atLeastOneComponentSmallerOrEqualThan ( const GslVector rhs) const

This function returns true if at least one component of this is smaller than or equal to the respective component of rhs.

Definition at line 1007 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

1008 {
1009  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");
1010 
1011  bool result = false;
1012  unsigned int i = 0;
1013  unsigned int size = this->sizeLocal();
1014  while ((i < size) && (result == false)) {
1015  result = ( (*this)[i] <= rhs[i] ); // prudencio 2012-02-06
1016  i++;
1017  };
1018 
1019  return result;
1020 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
bool QUESO::GslVector::atLeastOneComponentSmallerThan ( const GslVector rhs) const

This function returns true if at least one component of this is smaller than the respective component of rhs.

Definition at line 975 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

976 {
977  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");
978 
979  bool result = false;
980  unsigned int i = 0;
981  unsigned int size = this->sizeLocal();
982  while ((i < size) && (result == false)) {
983  result = ( (*this)[i] < rhs[i] );
984  i++;
985  };
986 
987  return result;
988 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::copy ( const GslVector src)
private

This function copies the elements of the vector src into this.

Definition at line 229 of file GslVector.C.

References QUESO::Vector::base_copy(), m_vec, and queso_require_msg.

Referenced by GslVector(), and operator=().

230 {
231  this->Vector::base_copy(src);
232  int iRC;
233  iRC = gsl_vector_memcpy(this->m_vec, src.m_vec);
234  queso_require_msg(!(iRC), "failed");
235 
236  return;
237 }
virtual void base_copy(const Vector &src)
Copies base data from vector src to this vector.
Definition: Vector.C:101
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
void QUESO::GslVector::cwExtract ( unsigned int  initialPos,
GslVector vec 
) const

This function sets the values of this starting at position initialPos ans saves them in vector vec.

Definition at line 495 of file GslVector.C.

References queso_require_less_equal_msg, queso_require_less_msg, and sizeLocal().

496 {
497  queso_require_less_msg(initialPos, this->sizeLocal(), "invalid initialPos");
498 
499  queso_require_less_equal_msg((initialPos +vec.sizeLocal()), this->sizeLocal(), "invalid vec.sizeLocal()");
500 
501  for (unsigned int i = 0; i < vec.sizeLocal(); ++i) {
502  vec[i] = (*this)[initialPos+i];
503  }
504 
505  return;
506 }
#define queso_require_less_msg(expr1, expr2, msg)
Definition: asserts.h:75
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:77
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::cwInvert ( )
virtual

This function inverts component-wise the element values of this.

Implements QUESO::Vector.

Definition at line 509 of file GslVector.C.

References sizeLocal().

Referenced by QUESO::operator/().

510 {
511  unsigned int size = this->sizeLocal();
512  for (unsigned int i = 0; i < size; ++i) {
513  (*this)[i] = 1./(*this)[i];
514  }
515 
516  return;
517 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::cwSet ( double  value)
virtual

Component-wise sets all values to this with value.

Implements QUESO::Vector.

Definition at line 326 of file GslVector.C.

References sizeLocal().

Referenced by QUESO::GslOptimizer::GslOptimizer(), GslVector(), QUESO::GslMatrix::inverse(), and QUESO::GslOptimizer::setFstepSize().

327 {
328  unsigned int size = this->sizeLocal();
329  for (unsigned int i = 0; i < size; ++i) {
330  (*this)[i] = value;
331  }
332 
333  return;
334 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::cwSet ( unsigned int  initialPos,
const GslVector vec 
)

This function sets the vector vec into this starting at position initialPos.

Definition at line 481 of file GslVector.C.

References queso_require_less_equal_msg, queso_require_less_msg, and sizeLocal().

482 {
483  queso_require_less_msg(initialPos, this->sizeLocal(), "invalid initialPos");
484 
485  queso_require_less_equal_msg((initialPos +vec.sizeLocal()), this->sizeLocal(), "invalid vec.sizeLocal()");
486 
487  for (unsigned int i = 0; i < vec.sizeLocal(); ++i) {
488  (*this)[initialPos+i] = vec[i];
489  }
490 
491  return;
492 }
#define queso_require_less_msg(expr1, expr2, msg)
Definition: asserts.h:75
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:77
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::cwSetBeta ( const GslVector alpha,
const GslVector beta 
)

This function returns a random variate from the beta distribution, with vector parameters alpha and beta.

Definition at line 365 of file GslVector.C.

References QUESO::RngBase::betaSample(), QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseEnvironment::fullRank(), QUESO::Vector::m_env, queso_require_equal_to_msg, QUESO::BaseEnvironment::rngObject(), sizeLocal(), and QUESO::BaseEnvironment::subDisplayFile().

366 {
367  queso_require_equal_to_msg(this->sizeLocal(), alpha.sizeLocal(), "incompatible alpha size");
368 
369  queso_require_equal_to_msg(this->sizeLocal(), beta.sizeLocal(), "incompatible beta size");
370 
371  double tmpSample = 0.;
372  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
373  tmpSample = m_env.rngObject()->betaSample(alpha[i],beta[i]);
374  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
375  *m_env.subDisplayFile() << "In GslVector::cwSetBeta()"
376  << ": fullRank " << m_env.fullRank()
377  << ", i = " << i
378  << ", alpha[i] = " << alpha[i]
379  << ", beta[i] = " << beta[i]
380  << ", sample = " << tmpSample
381  << std::endl;
382  }
383  if ((alpha[i] == 1. ) &&
384  (beta [i] == 0.1)) {
385  if (tmpSample == 1.) {
386  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
387  *m_env.subDisplayFile() << "Hitting 'sampe = 1' in GslVector::cwSetBeta()"
388  << ": fullRank " << m_env.fullRank()
389  << ", i = " << i
390  << ", alpha[i] = " << alpha[i]
391  << ", beta[i] = " << beta[i]
392  << ", sample = " << tmpSample
393  << std::endl;
394  }
395 #if 1
396  std::cerr << "Hitting 'sample = 1' in GslVector::cwSetBeta()"
397  << ": fullRank " << m_env.fullRank()
398  << ", i = " << i
399  << ", alpha[i] = " << alpha[i]
400  << ", beta[i] = " << beta[i]
401  << ", sample = " << tmpSample
402  << std::endl;
403  do {
404  tmpSample = m_env.rngObject()->betaSample(alpha[i],beta[i]);
405  } while (tmpSample == 1.);
406  std::cerr << "Code was able to get 'sample != 1' in GslVector::cwSetBeta()"
407  << ": fullRank " << m_env.fullRank()
408  << ", i = " << i
409  << ", alpha[i] = " << alpha[i]
410  << ", beta[i] = " << beta[i]
411  << ", sample = " << tmpSample
412  << std::endl;
413  }
414 #endif
415  }
416  (*this)[i] = tmpSample;
417  }
418  return;
419 }
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:470
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
virtual double betaSample(double alpha, double beta) const =0
Samples a value from a Beta distribution.
int fullRank() const
Returns the process full rank.
Definition: Environment.C:268
unsigned int displayVerbosity() const
Definition: Environment.C:449
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::cwSetConcatenated ( const GslVector v1,
const GslVector v2 
)

This function concatenates GslVector v1 and GslVector v2 into this.

Definition at line 448 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

449 {
450  queso_require_equal_to_msg(this->sizeLocal(), v1.sizeLocal() + v2.sizeLocal(), "incompatible vector sizes");
451 
452  for (unsigned int i = 0; i < v1.sizeLocal(); ++i) {
453  (*this)[i] = v1[i];
454  }
455 
456  for (unsigned int i = 0; i < v2.sizeLocal(); ++i) {
457  (*this)[v1.sizeLocal()+i] = v2[i];
458  }
459 
460  return;
461 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::cwSetConcatenated ( const std::vector< const GslVector * > &  vecs)

This function concatenates vectors v1 and v2 into this vector.

Definition at line 464 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

465 {
466  unsigned int cummulativeSize = 0;
467  for (unsigned int i = 0; i < vecs.size(); ++i) {
468  GslVector tmpVec(*(vecs[i]));
469  for (unsigned int j = 0; j < vecs[i]->sizeLocal(); ++j) {
470  (*this)[cummulativeSize+j] = tmpVec[j];
471  }
472  cummulativeSize += vecs[i]->sizeLocal();
473  }
474 
475  queso_require_equal_to_msg(this->sizeLocal(), cummulativeSize, "incompatible vector sizes");
476  return;
477 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
GslVector()
Default Constructor.
void QUESO::GslVector::cwSetGamma ( const GslVector a,
const GslVector b 
)

This function returns a random variate from the gamma distribution with vector parameters a and b.

Definition at line 422 of file GslVector.C.

References QUESO::RngBase::gammaSample(), QUESO::Vector::m_env, queso_require_equal_to_msg, QUESO::BaseEnvironment::rngObject(), and sizeLocal().

423 {
424  queso_require_equal_to_msg(this->sizeLocal(), a.sizeLocal(), "incompatible a size");
425 
426  queso_require_equal_to_msg(this->sizeLocal(), b.sizeLocal(), "incompatible b size");
427 
428  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
429  (*this)[i] = m_env.rngObject()->gammaSample(a[i],b[i]);
430  }
431  return;
432 }
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:470
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
virtual double gammaSample(double a, double b) const =0
Samples a value from a Gamma distribution.
void QUESO::GslVector::cwSetGaussian ( double  mean,
double  stdDev 
)
virtual

This function sets component-wise Gaussian random variates, with mean mean and standard deviation stdDev.

Implements QUESO::Vector.

Definition at line 337 of file GslVector.C.

References QUESO::RngBase::gaussianSample(), QUESO::Vector::m_env, QUESO::BaseEnvironment::rngObject(), and sizeLocal().

338 {
339  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
340  (*this)[i] = mean + m_env.rngObject()->gaussianSample(stdDev);
341  }
342 
343  return;
344 }
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:470
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
virtual double gaussianSample(double stdDev) const =0
Samples a value from a Gaussian distribution with standard deviation given by stdDev.
void QUESO::GslVector::cwSetGaussian ( const GslVector meanVec,
const GslVector stdDevVec 
)

This function sets component-wise Gaussian random variates, with vectors for mean and standard deviation.

Definition at line 347 of file GslVector.C.

References QUESO::RngBase::gaussianSample(), QUESO::Vector::m_env, QUESO::BaseEnvironment::rngObject(), and sizeLocal().

348 {
349  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
350  (*this)[i] = meanVec[i] + m_env.rngObject()->gaussianSample(stdDevVec[i]);
351  }
352  return;
353 }
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:470
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
virtual double gaussianSample(double stdDev) const =0
Samples a value from a Gaussian distribution with standard deviation given by stdDev.
void QUESO::GslVector::cwSetInverseGamma ( const GslVector alpha,
const GslVector beta 
)

This function returns a random variate from the inverse gamma distribution with vector parameters alpha and beta.

Definition at line 435 of file GslVector.C.

References QUESO::RngBase::gammaSample(), QUESO::Vector::m_env, queso_require_equal_to_msg, QUESO::BaseEnvironment::rngObject(), and sizeLocal().

436 {
437  queso_require_equal_to_msg(this->sizeLocal(), alpha.sizeLocal(), "incompatible alpha size");
438 
439  queso_require_equal_to_msg(this->sizeLocal(), beta.sizeLocal(), "incompatible beta size");
440 
441  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
442  (*this)[i] = 1./m_env.rngObject()->gammaSample(alpha[i],1./beta[i]);
443  }
444  return;
445 }
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:470
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
virtual double gammaSample(double a, double b) const =0
Samples a value from a Gamma distribution.
void QUESO::GslVector::cwSetUniform ( const GslVector aVec,
const GslVector bVec 
)

This function sets component-wise a number uniformly distributed in the range of elements of [aVec,bVec].

Definition at line 356 of file GslVector.C.

References QUESO::Vector::m_env, QUESO::BaseEnvironment::rngObject(), sizeLocal(), and QUESO::RngBase::uniformSample().

357 {
358  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
359  (*this)[i] = aVec[i] + (bVec[i]-aVec[i])*m_env.rngObject()->uniformSample();
360  }
361  return;
362 }
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:470
virtual double uniformSample() const =0
Samples a value from a uniform distribution.
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::cwSqrt ( )

This function returns component-wise the square-root of this.

Definition at line 520 of file GslVector.C.

References sizeLocal().

521 {
522  unsigned int size = this->sizeLocal();
523  for (unsigned int i = 0; i < size; ++i) {
524  (*this)[i] = sqrt((*this)[i]);
525  }
526 
527  return;
528 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
gsl_vector * QUESO::GslVector::data ( ) const
double QUESO::GslVector::getMaxValue ( ) const

Returns the maximum value in the vector this.

Definition at line 1039 of file GslVector.C.

References m_vec.

Referenced by getMaxValueAndIndex().

1040 {
1041  return gsl_vector_max( m_vec );
1042 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
void QUESO::GslVector::getMaxValueAndIndex ( double &  value,
int &  index 
)

This function returns maximum value in the vector this and its the index.

Definition at line 1063 of file GslVector.C.

References getMaxValue(), and getMaxValueIndex().

1064 {
1065  max_value = this->getMaxValue();
1066  max_value_index = this->getMaxValueIndex();
1067 
1068  return;
1069 }
int getMaxValueIndex() const
This function returns the index of the maximum value in the vector this.
Definition: GslVector.C:1051
double getMaxValue() const
Returns the maximum value in the vector this.
Definition: GslVector.C:1039
int QUESO::GslVector::getMaxValueIndex ( ) const

This function returns the index of the maximum value in the vector this.

Definition at line 1051 of file GslVector.C.

References m_vec.

Referenced by getMaxValueAndIndex().

1052 {
1053  return gsl_vector_max_index( m_vec );
1054 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
double QUESO::GslVector::getMinValue ( ) const

Returns minimum value in the vector this.

Definition at line 1045 of file GslVector.C.

References m_vec.

Referenced by getMinValueAndIndex().

1046 {
1047  return gsl_vector_min( m_vec );
1048 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
void QUESO::GslVector::getMinValueAndIndex ( double &  value,
int &  index 
)

This function returns minimum value in the vector this and its the index.

Definition at line 1072 of file GslVector.C.

References getMinValue(), and getMinValueIndex().

1073 {
1074  min_value = this->getMinValue();
1075  min_value_index = this->getMinValueIndex();
1076 
1077  return;
1078 }
int getMinValueIndex() const
This function returns the index of the minimum value in the vector this.
Definition: GslVector.C:1057
double getMinValue() const
Returns minimum value in the vector this.
Definition: GslVector.C:1045
int QUESO::GslVector::getMinValueIndex ( ) const

This function returns the index of the minimum value in the vector this.

Definition at line 1057 of file GslVector.C.

References m_vec.

Referenced by getMinValueAndIndex().

1058 {
1059  return gsl_vector_min_index( m_vec );
1060 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
void QUESO::GslVector::matlabDiff ( unsigned int  firstPositionToStoreDiff,
double  valueForRemainderPosition,
GslVector outputVec 
) const

Definition at line 531 of file GslVector.C.

References queso_require_equal_to_msg, queso_require_less_equal_msg, and sizeLocal().

535 {
536  unsigned int size = this->sizeLocal();
537 
538  queso_require_less_equal_msg(firstPositionToStoreDiff, 1, "invalid firstPositionToStoreDiff");
539 
540  queso_require_equal_to_msg(size, outputVec.sizeLocal(), "invalid size of outputVecs");
541 
542  for (unsigned int i = 0; i < (size-1); ++i) {
543  outputVec[firstPositionToStoreDiff+i] = (*this)[i+1]-(*this)[i];
544  }
545  if (firstPositionToStoreDiff == 0) {
546  outputVec[size-1] = valueForRemainderPosition;
547  }
548  else {
549  outputVec[0] = valueForRemainderPosition;
550  }
551 
552  return;
553 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:77
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::matlabLinearInterpExtrap ( const GslVector x1Vec,
const GslVector y1Vec,
const GslVector x2Vec 
)

Definition at line 556 of file GslVector.C.

References queso_require_equal_to_msg, queso_require_greater_msg, and sizeLocal().

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

560 {
561  queso_require_greater_msg(x1Vec.sizeLocal(), 1, "invalid 'x1' size");
562 
563  queso_require_equal_to_msg(x1Vec.sizeLocal(), y1Vec.sizeLocal(), "invalid 'x1' and 'y1' sizes");
564 
565  queso_require_equal_to_msg(x2Vec.sizeLocal(), this->sizeLocal(), "invalid 'x2' and 'this' sizes");
566 
567  for (unsigned int i = 1; i < x1Vec.sizeLocal(); ++i) { // Yes, '1'
568  queso_require_greater_msg(x1Vec[i], x1Vec[i-1], "invalid 'x1' values");
569  }
570 
571  for (unsigned int id2 = 0; id2 < x2Vec.sizeLocal(); ++id2) {
572  double x2 = x2Vec[id2];
573  unsigned int id1 = 0;
574  bool found1 = false;
575  for (id1 = 0; id1 < x1Vec.sizeLocal(); ++id1) {
576  if (x2 <= x1Vec[id1]) {
577  found1 = true;
578  break;
579  }
580  }
581  bool makeLinearModel = false;
582  double xa = 0.;
583  double xb = 0.;
584  double ya = 0.;
585  double yb = 0.;
586  if (x2 == x1Vec[id1]) {
587  (*this)[id2] = y1Vec[id1];
588  }
589  else if (x2 < x1Vec[0]) {
590  // Extrapolation case
591  makeLinearModel = true;
592  xa = x1Vec[0];
593  xb = x1Vec[1];
594  ya = y1Vec[0];
595  yb = y1Vec[1];
596  }
597  else if (found1 == true) {
598  // Interpolation case
599  makeLinearModel = true;
600  xa = x1Vec[id1-1];
601  xb = x1Vec[id1];
602  ya = y1Vec[id1-1];
603  yb = y1Vec[id1];
604  }
605  else {
606  // Extrapolation case
607  makeLinearModel = true;
608  xa = x1Vec[x1Vec.sizeLocal()-2];
609  xb = x1Vec[x1Vec.sizeLocal()-1];
610  ya = y1Vec[x1Vec.sizeLocal()-2];
611  yb = y1Vec[x1Vec.sizeLocal()-1];
612  }
613 
614  if (makeLinearModel) {
615  double rate = (yb-ya)/(xb-xa);
616  (*this)[id2] = ya + (x2-xa)*rate;
617  }
618  }
619 
620 
621 
622  return;
623 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:76
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::mpiAllQuantile ( double  probability,
const MpiComm opComm,
GslVector resultVec 
) const

Definition at line 710 of file GslVector.C.

References QUESO::MpiComm::Bcast(), QUESO::MpiComm::Gather(), QUESO::MpiComm::MyPID(), QUESO::MpiComm::NumProc(), queso_require_equal_to_msg, queso_require_msg, RawValue_MPI_DOUBLE, and sizeLocal().

711 {
712  // Filter out those nodes that should not participate
713  if (opComm.MyPID() < 0) return;
714 
715  queso_require_msg(!((probability < 0.) || (1. < probability)), "invalid input");
716 
717  unsigned int size = this->sizeLocal();
718  queso_require_equal_to_msg(size, resultVec.sizeLocal(), "different vector sizes");
719 
720  for (unsigned int i = 0; i < size; ++i) {
721  double auxDouble = (int) (*this)[i];
722  std::vector<double> vecOfDoubles(opComm.NumProc(),0.);
723  opComm.Gather<double>(&auxDouble, 1, &vecOfDoubles[0], (int) 1, 0,
724  "GslVector::mpiAllQuantile()",
725  "failed MPI.Gather()");
726 
727  std::sort(vecOfDoubles.begin(), vecOfDoubles.end());
728 
729  double result = vecOfDoubles[(unsigned int)( probability*((double)(vecOfDoubles.size()-1)) )];
730 
731  opComm.Bcast((void *) &result, (int) 1, RawValue_MPI_DOUBLE, 0,
732  "GslVector::mpiAllQuantile()",
733  "failed MPI.Bcast()");
734 
735  resultVec[i] = result;
736  }
737 
738  return;
739 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
#define RawValue_MPI_DOUBLE
Definition: MpiComm.h:67
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
void QUESO::GslVector::mpiAllReduce ( RawType_MPI_Op  mpiOperation,
const MpiComm opComm,
GslVector resultVec 
) const

Definition at line 689 of file GslVector.C.

References QUESO::MpiComm::Allreduce(), QUESO::MpiComm::MyPID(), queso_require_equal_to_msg, and sizeLocal().

690 {
691  // Filter out those nodes that should not participate
692  if (opComm.MyPID() < 0) return;
693 
694  unsigned int size = this->sizeLocal();
695  queso_require_equal_to_msg(size, resultVec.sizeLocal(), "different vector sizes");
696 
697  for (unsigned int i = 0; i < size; ++i) {
698  double srcValue = (*this)[i];
699  double resultValue = 0.;
700  opComm.Allreduce<double>(&srcValue, &resultValue, (int) 1, mpiOperation,
701  "GslVector::mpiAllReduce()",
702  "failed MPI.Allreduce()");
703  resultVec[i] = resultValue;
704  }
705 
706  return;
707 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::mpiBcast ( int  srcRank,
const MpiComm bcastComm 
)

Definition at line 634 of file GslVector.C.

References QUESO::MpiComm::Allreduce(), QUESO::MpiComm::Barrier(), QUESO::MpiComm::Bcast(), QUESO::MpiComm::MyPID(), QUESO::MpiComm::NumProc(), queso_require_equal_to_msg, queso_require_msg, RawValue_MPI_DOUBLE, RawValue_MPI_SUM, and sizeLocal().

635 {
636  // Filter out those nodes that should not participate
637  if (bcastComm.MyPID() < 0) return;
638 
639  // Check 'srcRank'
640  queso_require_msg(!((srcRank < 0) || (srcRank >= bcastComm.NumProc())), "invalud srcRank");
641 
642  // Check number of participant nodes
643  double localNumNodes = 1.;
644  double totalNumNodes = 0.;
645  bcastComm.Allreduce<double>(&localNumNodes, &totalNumNodes, (int) 1, RawValue_MPI_SUM,
646  "GslVector::mpiBcast()",
647  "failed MPI.Allreduce() for numNodes");
648  queso_require_equal_to_msg(((int) totalNumNodes), bcastComm.NumProc(), "inconsistent numNodes");
649 
650  // Check that all participant nodes have the same vector size
651  double localVectorSize = this->sizeLocal();
652  double sumOfVectorSizes = 0.;
653  bcastComm.Allreduce<double>(&localVectorSize, &sumOfVectorSizes, (int) 1, RawValue_MPI_SUM,
654  "GslVector::mpiBcast()",
655  "failed MPI.Allreduce() for vectorSize");
656 
657  if ( ((unsigned int) sumOfVectorSizes) != ((unsigned int)(totalNumNodes*localVectorSize)) ) {
658  std::cerr << "rank " << bcastComm.MyPID()
659  << ": sumOfVectorSizes = " << sumOfVectorSizes
660  << ", totalNumNodes = " << totalNumNodes
661  << ", localVectorSize = " << localVectorSize
662  << std::endl;
663  }
664  bcastComm.Barrier();
665  queso_require_equal_to_msg(((unsigned int) sumOfVectorSizes), ((unsigned int)(totalNumNodes*localVectorSize)), "inconsistent vectorSize");
666 
667  // Ok, bcast data
668  std::vector<double> dataBuffer((unsigned int) localVectorSize, 0.);
669  if (bcastComm.MyPID() == srcRank) {
670  for (unsigned int i = 0; i < dataBuffer.size(); ++i) {
671  dataBuffer[i] = (*this)[i];
672  }
673  }
674 
675  bcastComm.Bcast((void *) &dataBuffer[0], (int) localVectorSize, RawValue_MPI_DOUBLE, srcRank,
676  "GslVector::mpiBcast()",
677  "failed MPI.Bcast()");
678 
679  if (bcastComm.MyPID() != srcRank) {
680  for (unsigned int i = 0; i < dataBuffer.size(); ++i) {
681  (*this)[i] = dataBuffer[i];
682  }
683  }
684 
685  return;
686 }
#define RawValue_MPI_SUM
Definition: MpiComm.h:71
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
#define RawValue_MPI_DOUBLE
Definition: MpiComm.h:67
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
double QUESO::GslVector::norm1 ( ) const

Returns the 1-norm of the vector.

Definition at line 286 of file GslVector.C.

References sizeLocal().

287 {
288  double result = 0.;
289 
290  unsigned int size = this->sizeLocal();
291  for (unsigned int i = 0; i < size; ++i) {
292  result += fabs((*this)[i]);
293  }
294 
295  return result;
296 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
double QUESO::GslVector::norm2 ( ) const

Returns the 2-norm (Euclidean norm) of the vector.

Definition at line 280 of file GslVector.C.

References norm2Sq().

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

281 {
282  return std::sqrt(this->norm2Sq());
283 }
double norm2Sq() const
Returns the 2-norm squared of this vector.
Definition: GslVector.C:274
double QUESO::GslVector::norm2Sq ( ) const

Returns the 2-norm squared of this vector.

Definition at line 274 of file GslVector.C.

References QUESO::scalarProduct().

Referenced by norm2().

275 {
276  return scalarProduct(*this,*this);
277 }
double scalarProduct(const GslVector &x, const GslVector &y)
Definition: GslVector.C:1136
double QUESO::GslVector::normInf ( ) const

Returns the infinity-norm (maximum norm) of the vector.

Definition at line 299 of file GslVector.C.

References sizeLocal().

300 {
301  double result = 0.;
302 
303  unsigned int size = this->sizeLocal();
304  double aux = 0.;
305  for (unsigned int i = 0; i < size; ++i) {
306  aux = fabs((*this)[i]);
307  if (aux > result) result = aux;
308  }
309 
310  return result;
311 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
GslVector & QUESO::GslVector::operator*= ( double  a)

Stores in this the coordinate-wise multiplication of this and a.

Definition at line 165 of file GslVector.C.

References m_vec, and queso_require_msg.

166 {
167  int iRC;
168  iRC = gsl_vector_scale(m_vec,a);
169  queso_require_msg(!(iRC), "failed");
170  return *this;
171 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
GslVector & QUESO::GslVector::operator*= ( const GslVector rhs)

Stores in this the coordinate-wise multiplication of this with rhs.

Definition at line 182 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

183 {
184  unsigned int size1 = this->sizeLocal();
185  unsigned int size2 = rhs.sizeLocal();
186  queso_require_equal_to_msg(size1, size2, "different sizes of this and rhs");
187 
188  for (unsigned int i = 0; i < size1; ++i) {
189  (*this)[i] *= rhs[i];
190  }
191 
192  return *this;
193 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
GslVector & QUESO::GslVector::operator+= ( const GslVector rhs)

Stores in this the coordinate-wise addition of this and rhs.

Definition at line 210 of file GslVector.C.

References m_vec, and queso_require_msg.

211 {
212  int iRC;
213  iRC = gsl_vector_add(m_vec,rhs.m_vec);
214  queso_require_msg(!(iRC), "failed");
215  return *this;
216 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
GslVector & QUESO::GslVector::operator-= ( const GslVector rhs)

Stores in this the coordinate-wise subtraction of this by rhs.

Definition at line 219 of file GslVector.C.

References m_vec, and queso_require_msg.

220 {
221  int iRC;
222  iRC = gsl_vector_sub(m_vec,rhs.m_vec);
223  queso_require_msg(!(iRC), "failed");
224 
225  return *this;
226 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
GslVector & QUESO::GslVector::operator/= ( double  a)

Stores in this the coordinate-wise division of this by a.

Definition at line 174 of file GslVector.C.

175 {
176  *this *= (1./a);
177 
178  return *this;
179 }
GslVector & QUESO::GslVector::operator/= ( const GslVector rhs)

Stores in this the coordinate-wise division of this by rhs.

Definition at line 196 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

197 {
198  unsigned int size1 = this->sizeLocal();
199  unsigned int size2 = rhs.sizeLocal();
200  queso_require_equal_to_msg(size1, size2, "different sizes of this and rhs");
201 
202  for (unsigned int i = 0; i < size1; ++i) {
203  (*this)[i] /= rhs[i];
204  }
205 
206  return *this;
207 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
GslVector & QUESO::GslVector::operator= ( const GslVector rhs)

Copies values from vector rhs to this.

Definition at line 149 of file GslVector.C.

References copy(), queso_require_equal_to_msg, and sizeLocal().

150 {
151  //std::cout << "In GslVector::operator=()" // mox
152  // << ": setting size1"
153  // << std::endl;
154  unsigned int size1 = this->sizeLocal();
155  //std::cout << "In GslVector::operator=()" // mox
156  // << ": setting size2"
157  // << std::endl;
158  unsigned int size2 = rhs.sizeLocal();
159  queso_require_equal_to_msg(size1, size2, "sizes are not compatible");
160  this->copy(rhs);
161  return *this;
162 }
void copy(const GslVector &src)
This function copies the elements of the vector src into this.
Definition: GslVector.C:229
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
double & QUESO::GslVector::operator[] ( unsigned int  i)
inline

Element access method (non-const).

Returns the i-th element if x[i] is specified, the expression x(i) will return the same element.

Definition at line 263 of file GslVector.h.

References m_vec.

264 {
265  return *gsl_vector_ptr(m_vec,i);
266 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
const double & QUESO::GslVector::operator[] ( unsigned int  i) const
inline

Element access method (const).

Returns the i-th element if x[i] is specified, the expression x(i) will return the same element.

Definition at line 271 of file GslVector.h.

References m_vec.

272 {
273  return *gsl_vector_const_ptr(m_vec,i);
274 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
void QUESO::GslVector::print ( std::ostream &  os) const
virtual

Print method. Defines the behavior of the std::ostream << operator inherited from the Object class.

Implements QUESO::Vector.

Definition at line 742 of file GslVector.C.

References QUESO::Vector::m_printHorizontally, QUESO::Vector::m_printScientific, and sizeLocal().

Referenced by QUESO::operator<<().

743 {
744  //std::cout << "In GslVector::print(): before sizelocal()"
745  // << std::endl;
746  unsigned int size = this->sizeLocal();
747  //std::cout << "In GslVector::print(): after sizelocal()"
748  // << std::endl;
749 
750  //std::cout << "In GslVector::print(): before os.flags()"
751  // << std::endl;
752  std::ostream::fmtflags curr_fmt = os.flags();
753  //std::cout << "In GslVector::print(): after os.flags()"
754  // << std::endl;
755 
756  if (m_printScientific) {
757  unsigned int savedPrecision = os.precision();
758  os.precision(16);
759 
760  if (m_printHorizontally) {
761  for (unsigned int i = 0; i < size; ++i) {
762  os << std::scientific << (*this)[i]
763  << " ";
764  }
765  }
766  else {
767  for (unsigned int i = 0; i < size; ++i) {
768  os << std::scientific << (*this)[i]
769  << std::endl;
770  }
771  }
772 
773  os.precision(savedPrecision);
774  }
775  else {
776  if (m_printHorizontally) {
777  //std::cout << "In GslVector::print(): where expected"
778  // << std::endl;
779  for (unsigned int i = 0; i < size; ++i) {
780  os << std::dec << (*this)[i]
781  << " ";
782  }
783  }
784  else {
785  for (unsigned int i = 0; i < size; ++i) {
786  os << std::dec << (*this)[i]
787  << std::endl;
788  }
789  }
790  }
791 
792  //std::cout << "In GslVector::print(): before os.flags(curr_fmt)"
793  // << std::endl;
794  os.flags(curr_fmt);
795  //std::cout << "In GslVector::print(): after os.flags(curr_fmt)"
796  // << std::endl;
797 
798  return;
799 }
bool m_printHorizontally
Flag for either or not print this matrix horizontally.
Definition: Vector.h:130
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
bool m_printScientific
Flag for either or not print this matrix in scientific notation.
Definition: Vector.h:133
unsigned int QUESO::GslVector::sizeGlobal ( ) const
virtual

Returns the global length of this vector.

Implements QUESO::Vector.

Definition at line 266 of file GslVector.C.

References QUESO::Vector::m_map, m_vec, QUESO::Map::NumGlobalElements(), and queso_require_equal_to_msg.

267 {
268  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumGlobalElements(), "incompatible vec size");
269 
270  return m_vec->size;
271 }
const Map & m_map
Mapping variable.
Definition: Vector.h:126
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
unsigned int QUESO::GslVector::sizeLocal ( ) const
virtual

Returns the length of this vector.

Implements QUESO::Vector.

Definition at line 240 of file GslVector.C.

References QUESO::Vector::m_map, m_vec, QUESO::Map::NumMyElements(), and queso_require_equal_to_msg.

Referenced by abs(), atLeastOneComponentBiggerOrEqualThan(), atLeastOneComponentBiggerThan(), atLeastOneComponentSmallerOrEqualThan(), atLeastOneComponentSmallerThan(), cwExtract(), cwInvert(), cwSet(), cwSetBeta(), cwSetConcatenated(), cwSetGamma(), cwSetGaussian(), cwSetInverseGamma(), cwSetUniform(), cwSqrt(), QUESO::GslMatrix::eigen(), QUESO::GslMatrix::fillWithTensorProduct(), QUESO::GslMatrix::getColumn(), QUESO::GslMatrix::getRow(), QUESO::GslMatrix::GslMatrix(), QUESO::GslBlockMatrix::invertMultiply(), QUESO::GslMatrix::invertMultiply(), QUESO::GslMatrix::invertMultiplyForceLU(), QUESO::GslMatrix::largestEigen(), QUESO::leftDiagScaling(), matlabDiff(), matlabLinearInterpExtrap(), QUESO::GslMatrix::matlabLinearInterpExtrap(), QUESO::matrixProduct(), mpiAllQuantile(), mpiAllReduce(), mpiBcast(), QUESO::GslMatrix::multiply(), norm1(), normInf(), operator*=(), operator/=(), operator=(), QUESO::operator==(), print(), QUESO::GslMatrix::rank(), QUESO::rightDiagScaling(), QUESO::scalarProduct(), QUESO::GslMatrix::setColumn(), QUESO::GslOptimizer::setInitialPoint(), QUESO::GslMatrix::setRow(), QUESO::GslMatrix::smallestEigen(), subReadContents(), subWriteContents(), sumOfComponents(), QUESO::GslMatrix::svd(), and QUESO::GslMatrix::svdSolve().

241 {
242  // mox
243  //std::cout << "Entering GslVector::sizeLocal()"
244  // << ": &m_map = " << &m_map
245  // << std::endl;
246  //std::cout << ", m_map.NumMyElements() = " << m_map.NumMyElements()
247  // << std::endl;
248  //std::cout << ", m_vec = " << m_vec
249  // << std::endl;
250  //std::cout << ", m_vec->size = " << m_vec->size
251  // << std::endl;
252 
253  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumMyElements(), "incompatible vec size");
254 
255  //std::cout << "Leaving GslVector::sizeLocal()"
256  // << ": m_vec = " << m_vec
257  // << ", m_vec->size = " << m_vec->size
258  // << ", &m_map = " << &m_map
259  // << ", m_map.NumMyElements() = " << m_map.NumMyElements()
260  // << std::endl;
261 
262  return m_vec->size;
263 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
const Map & m_map
Mapping variable.
Definition: Vector.h:126
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
void QUESO::GslVector::sort ( )
virtual

This function sorts the elements of the vector this in ascending numerical order.

Implements QUESO::Vector.

Definition at line 626 of file GslVector.C.

References m_vec.

627 {
628  gsl_sort_vector(m_vec);
629 
630  return;
631 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:245
void QUESO::GslVector::subReadContents ( const std::string &  fileName,
const std::string &  fileType,
const std::set< unsigned int > &  allowedSubEnvIds 
)

Definition at line 842 of file GslVector.C.

References QUESO::BaseEnvironment::closeFile(), QUESO::BaseEnvironment::fullRank(), QUESO::FilePtrSetStruct::ifsVar, QUESO::Vector::m_env, QUESO::Vector::numOfProcsForStorage(), QUESO::BaseEnvironment::openInputFile(), queso_require_equal_to_msg, queso_require_greater_equal_msg, queso_require_less_equal_msg, queso_require_less_msg, sizeLocal(), QUESO::BaseEnvironment::subDisplayFile(), and QUESO::BaseEnvironment::subRank().

846 {
847  queso_require_greater_equal_msg(m_env.subRank(), 0, "unexpected subRank");
848 
849  queso_require_less_equal_msg(this->numOfProcsForStorage(), 1, "implemented just for sequential vectors for now");
850 
851  FilePtrSetStruct filePtrSet;
852  if (m_env.openInputFile(fileName,
853  fileType, // "m or hdf"
854  allowedSubEnvIds,
855  filePtrSet)) {
856  double subReadSize = this->sizeLocal();
857 
858  // In the logic below, the id of a line' begins with value 0 (zero)
859  unsigned int idOfMyFirstLine = 1;
860  unsigned int idOfMyLastLine = this->sizeLocal();
861  unsigned int numParams = 1; // Yes, just '1'
862 
863  // Read number of chain positions in the file by taking care of the first line,
864  // which resembles something like 'variable_name = zeros(n_positions,m_params);'
865  std::string tmpString;
866 
867  // Read 'variable name' string
868  *filePtrSet.ifsVar >> tmpString;
869  //std::cout << "Just read '" << tmpString << "'" << std::endl;
870 
871  // Read '=' sign
872  *filePtrSet.ifsVar >> tmpString;
873  //std::cout << "Just read '" << tmpString << "'" << std::endl;
874  queso_require_equal_to_msg(tmpString, std::string("="), std::string("string should be the '=' sign"));
875 
876  // Read 'zeros(n_positions,n_params)' string
877  *filePtrSet.ifsVar >> tmpString;
878  //std::cout << "Just read '" << tmpString << "'" << std::endl;
879  unsigned int posInTmpString = 6;
880 
881  // Isolate 'n_positions' in a string
882  char nPositionsString[tmpString.size()-posInTmpString+1];
883  unsigned int posInPositionsString = 0;
884  do {
885  queso_require_less_msg(posInTmpString, tmpString.size(), "symbol ',' not found in first line of file");
886  nPositionsString[posInPositionsString++] = tmpString[posInTmpString++];
887  } while (tmpString[posInTmpString] != ',');
888  nPositionsString[posInPositionsString] = '\0';
889 
890  // Isolate 'n_params' in a string
891  posInTmpString++; // Avoid reading ',' char
892  char nParamsString[tmpString.size()-posInTmpString+1];
893  unsigned int posInParamsString = 0;
894  do {
895  queso_require_less_msg(posInTmpString, tmpString.size(), "symbol ')' not found in first line of file");
896  nParamsString[posInParamsString++] = tmpString[posInTmpString++];
897  } while (tmpString[posInTmpString] != ')');
898  nParamsString[posInParamsString] = '\0';
899 
900  // Convert 'n_positions' and 'n_params' strings to numbers
901  unsigned int sizeOfVecInFile = (unsigned int) strtod(nPositionsString,NULL);
902  unsigned int numParamsInFile = (unsigned int) strtod(nParamsString, NULL);
903  if (m_env.subDisplayFile()) {
904  *m_env.subDisplayFile() << "In GslVector::subReadContents()"
905  << ": fullRank " << m_env.fullRank()
906  << ", sizeOfVecInFile = " << sizeOfVecInFile
907  << ", numParamsInFile = " << numParamsInFile
908  << ", this->sizeLocal() = " << this->sizeLocal()
909  << std::endl;
910  }
911 
912  // Check if [size of vec in file] >= [requested sub vec size]
913  queso_require_greater_equal_msg(sizeOfVecInFile, subReadSize, "size of vec in file is not big enough");
914 
915  // Check if [num params in file] == [num params in current vec]
916  queso_require_equal_to_msg(numParamsInFile, numParams, "number of parameters of vec in file is different than number of parameters in this vec object");
917 
918  // Code common to any core in a communicator
919  unsigned int maxCharsPerLine = 64*numParams; // Up to about 60 characters to represent each parameter value
920 
921  unsigned int lineId = 0;
922  while (lineId < idOfMyFirstLine) {
923  filePtrSet.ifsVar->ignore(maxCharsPerLine,'\n');
924  lineId++;
925  };
926 
927  if (m_env.subDisplayFile()) {
928  *m_env.subDisplayFile() << "In GslVector::subReadContents()"
929  << ": beginning to read input actual data"
930  << std::endl;
931  }
932 
933  // Take care of initial part of the first data line,
934  // which resembles something like 'variable_name = [value1 value2 ...'
935  // Read 'variable name' string
936  *filePtrSet.ifsVar >> tmpString;
937  //std::cout << "Core 0 just read '" << tmpString << "'" << std::endl;
938 
939  // Read '=' sign
940  *filePtrSet.ifsVar >> tmpString;
941  //std::cout << "Core 0 just read '" << tmpString << "'" << std::endl;
942  queso_require_equal_to_msg(tmpString, std::string("="), std::string("in core 0, string should be the '=' sign"));
943 
944  // Take into account the ' [' portion
945  std::streampos tmpPos = filePtrSet.ifsVar->tellg();
946  filePtrSet.ifsVar->seekg(tmpPos+(std::streampos)2);
947 
948  if (m_env.subDisplayFile()) {
949  *m_env.subDisplayFile() << "In GslVector::subReadContents()"
950  << ": beginning to read lines with numbers only"
951  << ", lineId = " << lineId
952  << ", idOfMyFirstLine = " << idOfMyFirstLine
953  << ", idOfMyLastLine = " << idOfMyLastLine
954  << std::endl;
955  }
956 
957  while (lineId <= idOfMyLastLine) {
958  *filePtrSet.ifsVar >> (*this)[lineId - idOfMyFirstLine];
959  lineId++;
960  };
961 
962  m_env.closeFile(filePtrSet,fileType);
963  }
964 
965  return;
966 }
unsigned int numOfProcsForStorage() const
Definition: Vector.C:68
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:78
int subRank() const
Access function for sub-rank.
Definition: Environment.C:287
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
bool openInputFile(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, FilePtrSetStruct &filePtrSet) const
Opens an input file.
Definition: Environment.C:895
#define queso_require_less_msg(expr1, expr2, msg)
Definition: asserts.h:75
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1083
int fullRank() const
Returns the process full rank.
Definition: Environment.C:268
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:77
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
void QUESO::GslVector::subWriteContents ( const std::string &  varNamePrefix,
const std::string &  fileName,
const std::string &  fileType,
const std::set< unsigned int > &  allowedSubEnvIds 
) const

Definition at line 802 of file GslVector.C.

References QUESO::BaseEnvironment::closeFile(), QUESO::Vector::getPrintHorizontally(), QUESO::Vector::getPrintScientific(), QUESO::Vector::m_env, QUESO::Vector::numOfProcsForStorage(), QUESO::FilePtrSetStruct::ofsVar, QUESO::BaseEnvironment::openOutputFile(), queso_require_greater_equal_msg, queso_require_less_equal_msg, QUESO::Vector::setPrintHorizontally(), QUESO::Vector::setPrintScientific(), sizeLocal(), QUESO::BaseEnvironment::subIdString(), and QUESO::BaseEnvironment::subRank().

807 {
808  queso_require_greater_equal_msg(m_env.subRank(), 0, "unexpected subRank");
809 
810  queso_require_less_equal_msg(this->numOfProcsForStorage(), 1, "implemented just for sequential vectors for now");
811 
812  FilePtrSetStruct filePtrSet;
813  if (m_env.openOutputFile(fileName,
814  fileType, // "m or hdf"
815  allowedSubEnvIds,
816  false,
817  filePtrSet)) {
818  *filePtrSet.ofsVar << varNamePrefix << "_sub" << m_env.subIdString() << " = zeros(" << this->sizeLocal()
819  << "," << 1
820  << ");"
821  << std::endl;
822  *filePtrSet.ofsVar << varNamePrefix << "_sub" << m_env.subIdString() << " = [";
823 
824  bool savedVectorPrintScientific = this->getPrintScientific();
825  bool savedVectorPrintHorizontally = this->getPrintHorizontally();
826  this->setPrintScientific (true);
827  this->setPrintHorizontally(false);
828  *filePtrSet.ofsVar << *this;
829  //<< std::endl; // No need for 'endl' because horizontally = 'false'
830  this->setPrintHorizontally(savedVectorPrintHorizontally);
831  this->setPrintScientific (savedVectorPrintScientific);
832 
833  *filePtrSet.ofsVar << "];\n";
834 
835  m_env.closeFile(filePtrSet,fileType);
836  }
837 
838  return;
839 }
unsigned int numOfProcsForStorage() const
Definition: Vector.C:68
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:78
int subRank() const
Access function for sub-rank.
Definition: Environment.C:287
bool getPrintHorizontally() const
Checks if vector is printed horizontally.
Definition: Vector.C:82
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
const std::string & subIdString() const
Access to the attribute m_subIdString; which stores the string for the sub-environment, and it will be used, for instance, to create the output files for each sub-environment.
Definition: Environment.C:347
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1083
bool openOutputFile(const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds, bool writeOver, FilePtrSetStruct &filePtrSet) const
Opens an output file for each sub-environment that was chosen to send data to the file...
Definition: Environment.C:520
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:77
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240
bool getPrintScientific() const
Checks if the vector should be printed in Scientific Notation.
Definition: Vector.C:95
void setPrintHorizontally(bool value) const
Determines whether vector should be printed horizontally.
Definition: Vector.C:75
void setPrintScientific(bool value) const
Determines whether vector should be printed in Scientific Notation.
Definition: Vector.C:88
double QUESO::GslVector::sumOfComponents ( ) const

Returns the sum of the components of the vector.

Definition at line 314 of file GslVector.C.

References sizeLocal().

315 {
316  double result = 0.;
317  unsigned int size = this->sizeLocal();
318  for (unsigned int i = 0; i < size; ++i) {
319  result += (*this)[i];
320  }
321 
322  return result;
323 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:240

Member Data Documentation

gsl_vector* QUESO::GslVector::m_vec
private

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

Generated on Thu Dec 15 2016 13:23:13 for queso-0.56.1 by  doxygen 1.8.5