queso-0.53.0
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 48 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  //std::cout << "Leaving GslVector::constructor(1)" << std::endl;
55 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
const BaseEnvironment & env() const
Definition: Vector.C:54
const Map & map() const
Definition: Vector.C:61
Vector()
Default Constructor.
int NumGlobalElements() const
Returns the total number of elements across all processors.
Definition: Map.C:85
const Map & m_map
Mapping variable.
Definition: Vector.h:126
QUESO::GslVector::GslVector ( const BaseEnvironment env,
const Map map,
double  value 
)

Definition at line 57 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.

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

Definition at line 77 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.

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

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

Definition at line 123 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.

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

Destructor.

Definition at line 144 of file GslVector.C.

References m_vec.

145 {
146  if (m_vec) gsl_vector_free(m_vec);
147 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
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 1094 of file GslVector.C.

References sizeLocal().

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

1095 {
1096  GslVector abs_of_this_vec( *this );
1097 
1098  unsigned int size = abs_of_this_vec.sizeLocal();
1099 
1100  for( unsigned int i = 0; i < size; ++i )
1101  {
1102  abs_of_this_vec[i] = std::fabs( (*this)[i] );
1103  }
1104 
1105  return abs_of_this_vec;
1106 
1107 }
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 1036 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

1037 {
1038  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");
1039 
1040  bool result = false;
1041  unsigned int i = 0;
1042  unsigned int size = this->sizeLocal();
1043  while ((i < size) && (result == false)) {
1044  result = ( (*this)[i] >= rhs[i] ); // prudencio 2012-02-06
1045  i++;
1046  };
1047 
1048  return result;
1049 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
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 1004 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

1005 {
1006  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");
1007 
1008  bool result = false;
1009  unsigned int i = 0;
1010  unsigned int size = this->sizeLocal();
1011  while ((i < size) && (result == false)) {
1012  result = ( (*this)[i] > rhs[i] );
1013  i++;
1014  };
1015 
1016  return result;
1017 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
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 1020 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

1021 {
1022  queso_require_equal_to_msg(this->sizeLocal(), rhs.sizeLocal(), "vectors have different sizes");
1023 
1024  bool result = false;
1025  unsigned int i = 0;
1026  unsigned int size = this->sizeLocal();
1027  while ((i < size) && (result == false)) {
1028  result = ( (*this)[i] <= rhs[i] ); // prudencio 2012-02-06
1029  i++;
1030  };
1031 
1032  return result;
1033 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
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 988 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

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

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

Definition at line 242 of file GslVector.C.

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

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

243 {
244  this->Vector::base_copy(src);
245  int iRC;
246  iRC = gsl_vector_memcpy(this->m_vec, src.m_vec);
247  queso_require_msg(!(iRC), "failed");
248 
249  return;
250 }
virtual void base_copy(const Vector &src)
Copies base data from vector src to this vector.
Definition: Vector.C:101
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
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 508 of file GslVector.C.

References queso_require_less_equal_msg, queso_require_less_msg, and sizeLocal().

509 {
510  queso_require_less_msg(initialPos, this->sizeLocal(), "invalid initialPos");
511 
512  queso_require_less_equal_msg((initialPos +vec.sizeLocal()), this->sizeLocal(), "invalid vec.sizeLocal()");
513 
514  for (unsigned int i = 0; i < vec.sizeLocal(); ++i) {
515  vec[i] = (*this)[initialPos+i];
516  }
517 
518  return;
519 }
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:89
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_less_msg(expr1, expr2, msg)
Definition: asserts.h:87
void QUESO::GslVector::cwInvert ( )
virtual

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

Implements QUESO::Vector.

Definition at line 522 of file GslVector.C.

References sizeLocal().

Referenced by QUESO::operator/().

523 {
524  unsigned int size = this->sizeLocal();
525  for (unsigned int i = 0; i < size; ++i) {
526  (*this)[i] = 1./(*this)[i];
527  }
528 
529  return;
530 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
void QUESO::GslVector::cwSet ( double  value)
virtual

Component-wise sets all values to this with value.

Implements QUESO::Vector.

Definition at line 339 of file GslVector.C.

References sizeLocal().

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

340 {
341  unsigned int size = this->sizeLocal();
342  for (unsigned int i = 0; i < size; ++i) {
343  (*this)[i] = value;
344  }
345 
346  return;
347 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
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 494 of file GslVector.C.

References queso_require_less_equal_msg, queso_require_less_msg, and sizeLocal().

495 {
496  queso_require_less_msg(initialPos, this->sizeLocal(), "invalid initialPos");
497 
498  queso_require_less_equal_msg((initialPos +vec.sizeLocal()), this->sizeLocal(), "invalid vec.sizeLocal()");
499 
500  for (unsigned int i = 0; i < vec.sizeLocal(); ++i) {
501  (*this)[initialPos+i] = vec[i];
502  }
503 
504  return;
505 }
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:89
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_less_msg(expr1, expr2, msg)
Definition: asserts.h:87
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 378 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().

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

This function concatenates GslVector v1 and GslVector v2 into this.

Definition at line 461 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

462 {
463  queso_require_equal_to_msg(this->sizeLocal(), v1.sizeLocal() + v2.sizeLocal(), "incompatible vector sizes");
464 
465  for (unsigned int i = 0; i < v1.sizeLocal(); ++i) {
466  (*this)[i] = v1[i];
467  }
468 
469  for (unsigned int i = 0; i < v2.sizeLocal(); ++i) {
470  (*this)[v1.sizeLocal()+i] = v2[i];
471  }
472 
473  return;
474 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
void QUESO::GslVector::cwSetConcatenated ( const std::vector< const GslVector * > &  vecs)

This function concatenates vectors v1 and v2 into this vector.

Definition at line 477 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

478 {
479  unsigned int cummulativeSize = 0;
480  for (unsigned int i = 0; i < vecs.size(); ++i) {
481  GslVector tmpVec(*(vecs[i]));
482  for (unsigned int j = 0; j < vecs[i]->sizeLocal(); ++j) {
483  (*this)[cummulativeSize+j] = tmpVec[j];
484  }
485  cummulativeSize += vecs[i]->sizeLocal();
486  }
487 
488  queso_require_equal_to_msg(this->sizeLocal(), cummulativeSize, "incompatible vector sizes");
489  return;
490 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
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 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(), a.sizeLocal(), "incompatible a size");
438 
439  queso_require_equal_to_msg(this->sizeLocal(), b.sizeLocal(), "incompatible b size");
440 
441  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
442  (*this)[i] = m_env.rngObject()->gammaSample(a[i],b[i]);
443  }
444  return;
445 }
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
virtual double gammaSample(double a, double b) const =0
Samples a value from a Gamma distribution.
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:417
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 350 of file GslVector.C.

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

351 {
352  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
353  (*this)[i] = mean + m_env.rngObject()->gaussianSample(stdDev);
354  }
355 
356  return;
357 }
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
virtual double gaussianSample(double stdDev) const =0
Samples a value from a Gaussian distribution with standard deviation given by stdDev.
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:417
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 360 of file GslVector.C.

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

361 {
362  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
363  (*this)[i] = meanVec[i] + m_env.rngObject()->gaussianSample(stdDevVec[i]);
364  }
365  return;
366 }
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
virtual double gaussianSample(double stdDev) const =0
Samples a value from a Gaussian distribution with standard deviation given by stdDev.
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:417
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 448 of file GslVector.C.

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

449 {
450  queso_require_equal_to_msg(this->sizeLocal(), alpha.sizeLocal(), "incompatible alpha size");
451 
452  queso_require_equal_to_msg(this->sizeLocal(), beta.sizeLocal(), "incompatible beta size");
453 
454  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
455  (*this)[i] = 1./m_env.rngObject()->gammaSample(alpha[i],1./beta[i]);
456  }
457  return;
458 }
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
virtual double gammaSample(double a, double b) const =0
Samples a value from a Gamma distribution.
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:417
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 369 of file GslVector.C.

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

370 {
371  for (unsigned int i = 0; i < this->sizeLocal(); ++i) {
372  (*this)[i] = aVec[i] + (bVec[i]-aVec[i])*m_env.rngObject()->uniformSample();
373  }
374  return;
375 }
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
const RngBase * rngObject() const
Access to the RNG object.
Definition: Environment.C:417
virtual double uniformSample() const =0
Samples a value from a uniform distribution.
void QUESO::GslVector::cwSqrt ( )

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

Definition at line 533 of file GslVector.C.

References sizeLocal().

534 {
535  unsigned int size = this->sizeLocal();
536  for (unsigned int i = 0; i < size; ++i) {
537  (*this)[i] = sqrt((*this)[i]);
538  }
539 
540  return;
541 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
gsl_vector * QUESO::GslVector::data ( ) const
double QUESO::GslVector::getMaxValue ( ) const

Returns the maximum value in the vector this.

Definition at line 1052 of file GslVector.C.

References m_vec.

Referenced by getMaxValueAndIndex().

1053 {
1054  return gsl_vector_max( m_vec );
1055 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
void QUESO::GslVector::getMaxValueAndIndex ( double &  value,
int &  index 
)

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

Definition at line 1076 of file GslVector.C.

References getMaxValue(), and getMaxValueIndex().

1077 {
1078  max_value = this->getMaxValue();
1079  max_value_index = this->getMaxValueIndex();
1080 
1081  return;
1082 }
int getMaxValueIndex() const
This function returns the index of the maximum value in the vector this.
Definition: GslVector.C:1064
double getMaxValue() const
Returns the maximum value in the vector this.
Definition: GslVector.C:1052
int QUESO::GslVector::getMaxValueIndex ( ) const

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

Definition at line 1064 of file GslVector.C.

References m_vec.

Referenced by getMaxValueAndIndex().

1065 {
1066  return gsl_vector_max_index( m_vec );
1067 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
double QUESO::GslVector::getMinValue ( ) const

Returns minimum value in the vector this.

Definition at line 1058 of file GslVector.C.

References m_vec.

Referenced by getMinValueAndIndex().

1059 {
1060  return gsl_vector_min( m_vec );
1061 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
void QUESO::GslVector::getMinValueAndIndex ( double &  value,
int &  index 
)

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

Definition at line 1085 of file GslVector.C.

References getMinValue(), and getMinValueIndex().

1086 {
1087  min_value = this->getMinValue();
1088  min_value_index = this->getMinValueIndex();
1089 
1090  return;
1091 }
double getMinValue() const
Returns minimum value in the vector this.
Definition: GslVector.C:1058
int getMinValueIndex() const
This function returns the index of the minimum value in the vector this.
Definition: GslVector.C:1070
int QUESO::GslVector::getMinValueIndex ( ) const

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

Definition at line 1070 of file GslVector.C.

References m_vec.

Referenced by getMinValueAndIndex().

1071 {
1072  return gsl_vector_min_index( m_vec );
1073 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
void QUESO::GslVector::matlabDiff ( unsigned int  firstPositionToStoreDiff,
double  valueForRemainderPosition,
GslVector outputVec 
) const

Definition at line 544 of file GslVector.C.

References queso_require_equal_to_msg, queso_require_less_equal_msg, and sizeLocal().

548 {
549  unsigned int size = this->sizeLocal();
550 
551  queso_require_less_equal_msg(firstPositionToStoreDiff, 1, "invalid firstPositionToStoreDiff");
552 
553  queso_require_equal_to_msg(size, outputVec.sizeLocal(), "invalid size of outputVecs");
554 
555  for (unsigned int i = 0; i < (size-1); ++i) {
556  outputVec[firstPositionToStoreDiff+i] = (*this)[i+1]-(*this)[i];
557  }
558  if (firstPositionToStoreDiff == 0) {
559  outputVec[size-1] = valueForRemainderPosition;
560  }
561  else {
562  outputVec[0] = valueForRemainderPosition;
563  }
564 
565  return;
566 }
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:89
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
void QUESO::GslVector::matlabLinearInterpExtrap ( const GslVector x1Vec,
const GslVector y1Vec,
const GslVector x2Vec 
)

Definition at line 569 of file GslVector.C.

References queso_require_equal_to_msg, queso_require_greater_msg, and sizeLocal().

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

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

Definition at line 723 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().

724 {
725  // Filter out those nodes that should not participate
726  if (opComm.MyPID() < 0) return;
727 
728  queso_require_msg(!((probability < 0.) || (1. < probability)), "invalid input");
729 
730  unsigned int size = this->sizeLocal();
731  queso_require_equal_to_msg(size, resultVec.sizeLocal(), "different vector sizes");
732 
733  for (unsigned int i = 0; i < size; ++i) {
734  double auxDouble = (int) (*this)[i];
735  std::vector<double> vecOfDoubles(opComm.NumProc(),0.);
736  opComm.Gather((void *) &auxDouble, 1, RawValue_MPI_DOUBLE, (void *) &vecOfDoubles[0], (int) 1, RawValue_MPI_DOUBLE, 0,
737  "GslVector::mpiAllQuantile()",
738  "failed MPI.Gather()");
739 
740  std::sort(vecOfDoubles.begin(), vecOfDoubles.end());
741 
742  double result = vecOfDoubles[(unsigned int)( probability*((double)(vecOfDoubles.size()-1)) )];
743 
744  opComm.Bcast((void *) &result, (int) 1, RawValue_MPI_DOUBLE, 0,
745  "GslVector::mpiAllQuantile()",
746  "failed MPI.Bcast()");
747 
748  resultVec[i] = result;
749  }
750 
751  return;
752 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
#define RawValue_MPI_DOUBLE
Definition: MpiComm.h:48
void QUESO::GslVector::mpiAllReduce ( RawType_MPI_Op  mpiOperation,
const MpiComm opComm,
GslVector resultVec 
) const

Definition at line 702 of file GslVector.C.

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

703 {
704  // Filter out those nodes that should not participate
705  if (opComm.MyPID() < 0) return;
706 
707  unsigned int size = this->sizeLocal();
708  queso_require_equal_to_msg(size, resultVec.sizeLocal(), "different vector sizes");
709 
710  for (unsigned int i = 0; i < size; ++i) {
711  double srcValue = (*this)[i];
712  double resultValue = 0.;
713  opComm.Allreduce((void *) &srcValue, (void *) &resultValue, (int) 1, RawValue_MPI_DOUBLE, mpiOperation,
714  "GslVector::mpiAllReduce()",
715  "failed MPI.Allreduce()");
716  resultVec[i] = resultValue;
717  }
718 
719  return;
720 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
#define RawValue_MPI_DOUBLE
Definition: MpiComm.h:48
void QUESO::GslVector::mpiBcast ( int  srcRank,
const MpiComm bcastComm 
)

Definition at line 647 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().

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

Returns the 1-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  for (unsigned int i = 0; i < size; ++i) {
305  result += fabs((*this)[i]);
306  }
307 
308  return result;
309 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
double QUESO::GslVector::norm2 ( ) const

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

Definition at line 293 of file GslVector.C.

References norm2Sq().

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

294 {
295  return std::sqrt(this->norm2Sq());
296 }
double norm2Sq() const
Returns the 2-norm squared of this vector.
Definition: GslVector.C:287
double QUESO::GslVector::norm2Sq ( ) const

Returns the 2-norm squared of this vector.

Definition at line 287 of file GslVector.C.

References QUESO::scalarProduct().

Referenced by norm2().

288 {
289  return scalarProduct(*this,*this);
290 }
double scalarProduct(const GslVector &x, const GslVector &y)
Definition: GslVector.C:1150
double QUESO::GslVector::normInf ( ) const

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

Definition at line 312 of file GslVector.C.

References sizeLocal().

313 {
314  double result = 0.;
315 
316  unsigned int size = this->sizeLocal();
317  double aux = 0.;
318  for (unsigned int i = 0; i < size; ++i) {
319  aux = fabs((*this)[i]);
320  if (aux > result) result = aux;
321  }
322 
323  return result;
324 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
GslVector & QUESO::GslVector::operator*= ( double  a)

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

Definition at line 166 of file GslVector.C.

References m_vec, and queso_require_msg.

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

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

Definition at line 183 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

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

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

Definition at line 211 of file GslVector.C.

References m_vec, and queso_require_msg.

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

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

Definition at line 220 of file GslVector.C.

References m_vec, and queso_require_msg.

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

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

Definition at line 175 of file GslVector.C.

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

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

Definition at line 197 of file GslVector.C.

References queso_require_equal_to_msg, and sizeLocal().

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

Copies values from vector rhs to this.

Definition at line 150 of file GslVector.C.

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

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

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 230 of file GslVector.C.

References m_vec.

231 {
232  return *gsl_vector_ptr(m_vec,i);
233 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
const double & QUESO::GslVector::operator[] ( unsigned int  i) const

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 236 of file GslVector.C.

References m_vec.

237 {
238  return *gsl_vector_const_ptr(m_vec,i);
239 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
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 755 of file GslVector.C.

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

Referenced by QUESO::operator<<().

756 {
757  //std::cout << "In GslVector::print(): before sizelocal()"
758  // << std::endl;
759  unsigned int size = this->sizeLocal();
760  //std::cout << "In GslVector::print(): after sizelocal()"
761  // << std::endl;
762 
763  //std::cout << "In GslVector::print(): before os.flags()"
764  // << std::endl;
765  std::ostream::fmtflags curr_fmt = os.flags();
766  //std::cout << "In GslVector::print(): after os.flags()"
767  // << std::endl;
768 
769  if (m_printScientific) {
770  unsigned int savedPrecision = os.precision();
771  os.precision(16);
772 
773  if (m_printHorizontally) {
774  for (unsigned int i = 0; i < size; ++i) {
775  os << std::scientific << (*this)[i]
776  << " ";
777  }
778  }
779  else {
780  for (unsigned int i = 0; i < size; ++i) {
781  os << std::scientific << (*this)[i]
782  << std::endl;
783  }
784  }
785 
786  os.precision(savedPrecision);
787  }
788  else {
789  if (m_printHorizontally) {
790  //std::cout << "In GslVector::print(): where expected"
791  // << std::endl;
792  for (unsigned int i = 0; i < size; ++i) {
793  os << std::dec << (*this)[i]
794  << " ";
795  }
796  }
797  else {
798  for (unsigned int i = 0; i < size; ++i) {
799  os << std::dec << (*this)[i]
800  << std::endl;
801  }
802  }
803  }
804 
805  //std::cout << "In GslVector::print(): before os.flags(curr_fmt)"
806  // << std::endl;
807  os.flags(curr_fmt);
808  //std::cout << "In GslVector::print(): after os.flags(curr_fmt)"
809  // << std::endl;
810 
811  return;
812 }
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:253
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 279 of file GslVector.C.

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

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

Returns the length of this vector.

Implements QUESO::Vector.

Definition at line 253 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().

254 {
255  // mox
256  //std::cout << "Entering GslVector::sizeLocal()"
257  // << ": &m_map = " << &m_map
258  // << std::endl;
259  //std::cout << ", m_map.NumMyElements() = " << m_map.NumMyElements()
260  // << std::endl;
261  //std::cout << ", m_vec = " << m_vec
262  // << std::endl;
263  //std::cout << ", m_vec->size = " << m_vec->size
264  // << std::endl;
265 
266  queso_require_equal_to_msg(m_vec->size, (unsigned int) m_map.NumMyElements(), "incompatible vec size");
267 
268  //std::cout << "Leaving GslVector::sizeLocal()"
269  // << ": m_vec = " << m_vec
270  // << ", m_vec->size = " << m_vec->size
271  // << ", &m_map = " << &m_map
272  // << ", m_map.NumMyElements() = " << m_map.NumMyElements()
273  // << std::endl;
274 
275  return m_vec->size;
276 }
int NumMyElements() const
Returns the number of elements owned by the calling processor.
Definition: Map.C:107
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
const Map & m_map
Mapping variable.
Definition: Vector.h:126
void QUESO::GslVector::sort ( )
virtual

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

Implements QUESO::Vector.

Definition at line 639 of file GslVector.C.

References m_vec.

640 {
641  gsl_sort_vector(m_vec);
642 
643  return;
644 }
gsl_vector * m_vec
GSL vector.
Definition: GslVector.h:244
void QUESO::GslVector::subReadContents ( const std::string &  fileName,
const std::string &  fileType,
const std::set< unsigned int > &  allowedSubEnvIds 
)

Definition at line 855 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().

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

820 {
821  queso_require_greater_equal_msg(m_env.subRank(), 0, "unexpected subRank");
822 
823  queso_require_less_equal_msg(this->numOfProcsForStorage(), 1, "implemented just for sequential vectors for now");
824 
825  FilePtrSetStruct filePtrSet;
826  if (m_env.openOutputFile(fileName,
827  fileType, // "m or hdf"
828  allowedSubEnvIds,
829  false,
830  filePtrSet)) {
831  *filePtrSet.ofsVar << varNamePrefix << "_sub" << m_env.subIdString() << " = zeros(" << this->sizeLocal()
832  << "," << 1
833  << ");"
834  << std::endl;
835  *filePtrSet.ofsVar << varNamePrefix << "_sub" << m_env.subIdString() << " = [";
836 
837  bool savedVectorPrintScientific = this->getPrintScientific();
838  bool savedVectorPrintHorizontally = this->getPrintHorizontally();
839  this->setPrintScientific (true);
840  this->setPrintHorizontally(false);
841  *filePtrSet.ofsVar << *this;
842  //<< std::endl; // No need for 'endl' because horizontally = 'false'
843  this->setPrintHorizontally(savedVectorPrintHorizontally);
844  this->setPrintScientific (savedVectorPrintScientific);
845 
846  *filePtrSet.ofsVar << "];\n";
847 
848  m_env.closeFile(filePtrSet,fileType);
849  }
850 
851  return;
852 }
int subRank() const
Access function for sub-rank.
Definition: Environment.C:241
const BaseEnvironment & m_env
Environment variable.
Definition: Vector.h:117
#define queso_require_less_equal_msg(expr1, expr2, msg)
Definition: asserts.h:89
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253
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:301
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1020
bool getPrintHorizontally() const
Checks if vector is printed horizontally.
Definition: Vector.C:82
void setPrintHorizontally(bool value) const
Determines whether vector should be printed horizontally.
Definition: Vector.C:75
bool getPrintScientific() const
Checks if the vector should be printed in Scientific Notation.
Definition: Vector.C:95
unsigned int numOfProcsForStorage() const
Definition: Vector.C:68
void setPrintScientific(bool value) const
Determines whether vector should be printed in Scientific Notation.
Definition: Vector.C:88
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:467
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:90
double QUESO::GslVector::sumOfComponents ( ) const

Returns the sum of the components of the vector.

Definition at line 327 of file GslVector.C.

References sizeLocal().

328 {
329  double result = 0.;
330  unsigned int size = this->sizeLocal();
331  for (unsigned int i = 0; i < size; ++i) {
332  result += (*this)[i];
333  }
334 
335  return result;
336 }
unsigned int sizeLocal() const
Returns the length of this vector.
Definition: GslVector.C:253

Member Data Documentation

gsl_vector* QUESO::GslVector::m_vec
private

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

Generated on Thu Jun 11 2015 13:52:34 for queso-0.53.0 by  doxygen 1.8.5