queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::SequenceOfVectors< V, M > Class Template Reference

Class for handling vector samples (sequence of vectors). More...

#include <SequenceOfVectors.h>

Inheritance diagram for QUESO::SequenceOfVectors< V, M >:
QUESO::BaseVectorSequence< V, M >

Public Types

Class typedefs
typedef std::vector< const V * >
::const_iterator 
seqVectorPositionConstIteratorTypedef
 
typedef std::vector< const V * >
::iterator 
seqVectorPositionIteratorTypedef
 

Public Member Functions

Constructor/Destructor methods
 SequenceOfVectors (const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
 Default constructor. More...
 
 ~SequenceOfVectors ()
 Destructor. More...
 
Set methods
SequenceOfVectors< V, M > & operator= (const SequenceOfVectors< V, M > &rhs)
 Copies values from rhs to this. More...
 
Sequence methods
unsigned int subSequenceSize () const
 Size of the sub-sequence of vectors. More...
 
void resizeSequence (unsigned int newSubSequenceSize)
 Resizes the sequence. More...
 
void resetValues (unsigned int initialPos, unsigned int numPos)
 Resets a total of numPos values of the sequence starting at position initialPos. More...
 
void erasePositions (unsigned int initialPos, unsigned int numPos)
 Erases numPos elements of the sequence starting at position initialPos. More...
 
void getPositionValues (unsigned int posId, V &vec) const
 Gets the values of the sequence at position posId and stores them at vec. More...
 
void setPositionValues (unsigned int posId, const V &vec)
 Set the values in vec at position posId of the sequence. More...
 
void subUniformlySampledCdf (const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &cdfGrids, ArrayOfOneDTables< V, M > &cdfValues) const
 Uniformly samples from the CDF from the sub-sequence. More...
 
void unifiedUniformlySampledCdf (const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &unifiedCdfGrids, ArrayOfOneDTables< V, M > &unifiedCdfValues) const
 Uniformly samples from the CDF from the sub-sequence. More...
 
void subMeanExtra (unsigned int initialPos, unsigned int numPos, V &meanVec) const
 Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPos. More...
 
void unifiedMeanExtra (unsigned int initialPos, unsigned int numPos, V &unifiedMeanVec) const
 Finds the mean value of the unified sequence, considering numPos positions starting at position initialPos. More...
 
void subMedianExtra (unsigned int initialPos, unsigned int numPos, V &medianVec) const
 Finds the median value of the sub-sequence, considering numPos positions starting at position initialPos. More...
 
void unifiedMedianExtra (unsigned int initialPos, unsigned int numPos, V &unifiedMedianVec) const
 Finds the median value of the unfed sequence, considering numPos positions starting at position initialPos. More...
 
void subSampleVarianceExtra (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const
 Finds the sample variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void unifiedSampleVarianceExtra (unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedSamVec) const
 Finds the sample variance of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void subSampleStd (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &stdVec) const
 Finds the sample standard deviation of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void unifiedSampleStd (unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedStdVec) const
 Finds the sample standard deviation of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void subPopulationVariance (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &popVec) const
 Finds the population variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void unifiedPopulationVariance (unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedPopVec) const
 Finds the population variance of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void autoCovariance (unsigned int initialPos, unsigned int numPos, const V &meanVec, unsigned int lag, V &covVec) const
 Calculates the autocovariance. More...
 
void autoCorrViaDef (unsigned int initialPos, unsigned int numPos, unsigned int lag, V &corrVec) const
 Calculates the autocorrelation via definition. More...
 
void autoCorrViaFft (unsigned int initialPos, unsigned int numPos, const std::vector< unsigned int > &lags, std::vector< V * > &corrVecs) const
 Calculates the autocorrelation via Fast Fourier transforms (FFT). More...
 
void autoCorrViaFft (unsigned int initialPos, unsigned int numPos, unsigned int numSum, V &autoCorrsSumVec) const
 Calculates the autocorrelation via Fast Fourier transforms (FFT). More...
 
void subMinMaxExtra (unsigned int initialPos, unsigned int numPos, V &minVec, V &maxVec) const
 Finds the minimum and the maximum values of the sub-sequence, considering numPos positions starting at position initialPos. More...
 
void unifiedMinMaxExtra (unsigned int initialPos, unsigned int numPos, V &unifiedMinVec, V &unifiedMaxVec) const
 Finds the minimum and the maximum values of the unified sequence, considering numPos positions starting at position initialPos. More...
 
void subHistogram (unsigned int initialPos, const V &minVec, const V &maxVec, std::vector< V * > &centersForAllBins, std::vector< V * > &quanttsForAllBins) const
 Calculates the histogram of the sub-sequence. More...
 
void unifiedHistogram (unsigned int initialPos, const V &unifiedMinVec, const V &unifiedMaxVec, std::vector< V * > &unifiedCentersForAllBins, std::vector< V * > &unifiedQuanttsForAllBins) const
 Calculates the histogram of the unified sequence. More...
 
void subInterQuantileRange (unsigned int initialPos, V &iqrVec) const
 Returns the interquartile range of the values in the sub-sequence. More...
 
void unifiedInterQuantileRange (unsigned int initialPos, V &unifiedIqrVec) const
 Returns the interquartile range of the values in the unified sequence. More...
 
void subScalesForKde (unsigned int initialPos, const V &iqrVec, unsigned int kdeDimension, V &scaleVec) const
 Selects the scales (bandwidth, scaleVec) for the kernel density estimation, considering only the sub-sequence. More...
 
void unifiedScalesForKde (unsigned int initialPos, const V &unifiedIqrVec, unsigned int kdeDimension, V &unifiedScaleVec) const
 Selects the scales (bandwidth) for the kernel density estimation, considering the unified sequence. More...
 
void subGaussian1dKde (unsigned int initialPos, const V &scaleVec, const std::vector< V * > &evalParamVecs, std::vector< V * > &densityVecs) const
 Gaussian kernel for the KDE estimate of the sub-sequence. More...
 
void unifiedGaussian1dKde (unsigned int initialPos, const V &unifiedScaleVec, const std::vector< V * > &unifiedEvalParamVecs, std::vector< V * > &unifiedDensityVecs) const
 Gaussian kernel for the KDE estimate of the unified sequence. More...
 
void subWriteContents (unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
 Writes the sub-sequence to a file. More...
 
void subWriteContents (unsigned int initialPos, unsigned int numPos, FilePtrSetStruct &filePtrSet, const std::string &fileType) const
 Writes the sub-sequence to a file. More...
 
void subWriteContents (unsigned int initialPos, unsigned int numPos, std::ofstream &ofs, const std::string &fileType) const
 Writes the sub-sequence to a file. More...
 
void unifiedWriteContents (const std::string &fileName, const std::string &fileType) const
 
void unifiedReadContents (const std::string &fileName, const std::string &fileType, const unsigned int subSequenceSize)
 Reads the unified sequence from a file. More...
 
void select (const std::vector< unsigned int > &idsOfUniquePositions)
 TODO: It shall select positions in the sequence of vectors. More...
 
void filter (unsigned int initialPos, unsigned int spacing)
 Filters positions in the sequence of vectors. More...
 
double estimateConvBrooksGelman (unsigned int initialPos, unsigned int numPos) const
 Estimates convergence rate using Brooks & Gelman method. More...
 
void extractScalarSeq (unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
 Extracts a sequence of scalars. More...
 
const V * operator[] (unsigned int posId) const
 
const V *& operator[] (unsigned int posId)
 
void subUniformlySampledMdf (const V &numEvaluationPointsVec, ArrayOfOneDGrids< V, M > &mdfGrids, ArrayOfOneDTables< V, M > &mdfValues) const
 
void subMeanCltStd (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const
 
void unifiedMeanCltStd (unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedSamVec) const
 
void bmm (unsigned int initialPos, unsigned int batchLength, V &bmmVec) const
 
void fftForward (unsigned int initialPos, unsigned int fftSize, unsigned int paramId, std::vector< std::complex< double > > &fftResult) const
 
void psd (unsigned int initialPos, unsigned int numBlocks, double hopSizeRatio, unsigned int paramId, std::vector< double > &psdResult) const
 
void psdAtZero (unsigned int initialPos, unsigned int numBlocks, double hopSizeRatio, V &psdVec) const
 
void geweke (unsigned int initialPos, double ratioNa, double ratioNb, V &gewVec) const
 
void meanStacc (unsigned int initialPos, V &meanStaccVec) const
 
void subCdfPercentageRange (unsigned int initialPos, unsigned int numPos, double range, V &lowerVec, V &upperVec) const
 
void unifiedCdfPercentageRange (unsigned int initialPos, unsigned int numPos, double range, V &lowerVec, V &upperVec) const
 
void subCdfStacc (unsigned int initialPos, std::vector< V * > &cdfStaccVecs, std::vector< V * > &cdfStaccVecsUp, std::vector< V * > &cdfStaccVecsLow, std::vector< V * > &sortedDataVecs) const
 
void subCdfStacc (unsigned int initialPos, const std::vector< V * > &evalPositionsVecs, std::vector< V * > &cdfStaccVecs) const
 
- Public Member Functions inherited from QUESO::BaseVectorSequence< V, M >
 BaseVectorSequence (const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
 Default constructor. More...
 
virtual ~BaseVectorSequence ()
 Destructor. More...
 
unsigned int unifiedSequenceSize () const
 Calculates the size of the unified sequence of vectors. More...
 
unsigned int vectorSizeLocal () const
 Local dimension (size) of the vector space. More...
 
unsigned int vectorSizeGlobal () const
 Global dimension (size) of the vector space. More...
 
const VectorSpace< V, M > & vectorSpace () const
 Vector space; access to protected attribute VectorSpace<V,M>& m_vectorSpace. More...
 
const std::string & name () const
 Access to protected attribute m_name: name of the sequence of vectors. More...
 
void setName (const std::string &newName)
 Changes the name of the sequence of vectors. More...
 
void clear ()
 Reset the values and the size of the sequence of vectors. More...
 
const V & subMinPlain () const
 Finds the minimum value of the sub-sequence. More...
 
const V & unifiedMinPlain () const
 Finds the minimum value of the unified sequence. More...
 
const V & subMaxPlain () const
 Finds the maximum value of the sub-sequence. More...
 
const V & unifiedMaxPlain () const
 Finds the maximum value of the unified sequence. More...
 
const V & subMeanPlain () const
 Finds the mean value of the sub-sequence. More...
 
const V & unifiedMeanPlain () const
 Finds the mean value of the unified sequence. More...
 
const V & subMedianPlain () const
 Finds the median value of the sub-sequence. More...
 
const V & unifiedMedianPlain () const
 Finds the median value of the unified sequence. More...
 
const V & subSampleVariancePlain () const
 Finds the variance of a sample of the sub-sequence. More...
 
const V & unifiedSampleVariancePlain () const
 Finds the variance of a sample of the unified sequence. More...
 
const BoxSubset< V, M > & subBoxPlain () const
 Finds a box subset of the sub-sequence (given by its min and max values calculated via subMinPlain and subMaxPlain). More...
 
const BoxSubset< V, M > & unifiedBoxPlain () const
 Finds a box subset of the unified-sequence (given by the min and max values of the unified sequence calculated via unifiedMinPlain and unifiedMaxPlain). More...
 
void deleteStoredVectors ()
 Deletes all the stored vectors. More...
 
void append (const BaseVectorSequence< V, M > &src, unsigned int initialPos, unsigned int numPos)
 Appends the vector src to this vector. More...
 
double subPositionsOfMaximum (const ScalarSequence< double > &subCorrespondingScalarValues, BaseVectorSequence< V, M > &subPositionsOfMaximum)
 Finds the positions where the maximum element occurs in the sub-sequence. More...
 
double unifiedPositionsOfMaximum (const ScalarSequence< double > &subCorrespondingScalarValues, BaseVectorSequence< V, M > &unifiedPositionsOfMaximum)
 Finds the positions where the maximum element occurs in the unified sequence. More...
 
void setGaussian (const V &meanVec, const V &stdDevVec)
 Sets the values of the sequence as a Gaussian distribution of mean given by meanVec and standard deviation by stdDevVec. More...
 
void setUniform (const V &aVec, const V &bVec)
 Sets the values of the sequence as a uniform distribution between the values given by vectors aVec and bVec. More...
 
void computeFilterParams (std::ofstream *passedOfs, unsigned int &initialPos, unsigned int &spacing)
 Computes the filtering parameters spacing for the sequence of vectors. More...
 
void computeHistCdfstaccKde (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
 
void computeStatistics (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
 
void computeHistCdfstaccKde (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs)
 
void computeStatistics (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs)
 

Private Member Functions

void copy (const SequenceOfVectors< V, M > &src)
 Copies vector sequence src to this. More...
 
void extractRawData (unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, std::vector< double > &rawData) const
 Extracts the raw data. More...
 
void writeSubMatlabHeader (std::ofstream &ofs, double sequenceSize, double vectorSizeLocal) const
 Helper function to write matlab-specific header info for vectors. More...
 
void writeUnifiedMatlabHeader (std::ofstream &ofs, double sequenceSize, double vectorSizeLocal) const
 
void writeTxtHeader (std::ofstream &ofs, double sequenceSize, double vectorSizeLocal) const
 Helper function to write plain txt info for vectors. More...
 
void subMeanMonitorAlloc (unsigned int numberOfMonitorPositions)
 
void subMeanInter0MonitorAlloc (unsigned int numberOfMonitorPositions)
 
void unifiedMeanMonitorAlloc (unsigned int numberOfMonitorPositions)
 
void subMeanMonitorRun (unsigned int monitorPosition, V &subMeanVec, V &subMeanCltStd)
 
void subMeanInter0MonitorRun (unsigned int currentPosition, V &subMeanInter0Mean, V &subMeanInter0Clt95, V &subMeanInter0Empirical90, V &subMeanInter0Min, V &subMeanInter0Max)
 
void unifiedMeanMonitorRun (unsigned int currentPosition, V &unifiedMeanVec, V &unifiedMeanCltStd)
 
void subMeanMonitorStore (unsigned int i, unsigned int monitorPosition, const V &subMeanVec, const V &subMeanCltStd)
 
void subMeanInter0MonitorStore (unsigned int i, unsigned int monitorPosition, const V &subMeanInter0Mean, const V &subMeanInter0Clt95, const V &subMeanInter0Empirical90, const V &subMeanInter0Min, const V &subMeanInter0Max)
 
void unifiedMeanMonitorStore (unsigned int i, unsigned int monitorPosition, V &unifiedMeanVec, V &unifiedMeanCltStd)
 
void subMeanMonitorFree ()
 
void subMeanInter0MonitorFree ()
 
void unifiedMeanMonitorFree ()
 
void subMeanMonitorWrite (std::ofstream &ofs)
 
void subMeanInter0MonitorWrite (std::ofstream &ofs)
 
void unifiedMeanMonitorWrite (std::ofstream &ofs)
 

Private Attributes

std::vector< const V * > m_seq
 Sequence of vectors. More...
 
ScalarSequence< double > * m_subMeanMonitorPosSeq
 
SequenceOfVectors< V, M > * m_subMeanVecSeq
 
SequenceOfVectors< V, M > * m_subMeanCltStdSeq
 
ScalarSequence< double > * m_subMeanInter0MonitorPosSeq
 
SequenceOfVectors< V, M > * m_subMeanInter0Mean
 
SequenceOfVectors< V, M > * m_subMeanInter0Clt95
 
SequenceOfVectors< V, M > * m_subMeanInter0Empirical90
 
SequenceOfVectors< V, M > * m_subMeanInter0Min
 
SequenceOfVectors< V, M > * m_subMeanInter0Max
 
ScalarSequence< double > * m_unifiedMeanMonitorPosSeq
 
SequenceOfVectors< V, M > * m_unifiedMeanVecSeq
 
SequenceOfVectors< V, M > * m_unifiedMeanCltStdSeq
 

Additional Inherited Members

- Protected Member Functions inherited from QUESO::BaseVectorSequence< V, M >
void copy (const BaseVectorSequence< V, M > &src)
 Copies vector sequence src to this. More...
 
void computeMeanEvolution (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
 
void computeMeanEvolution (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs)
 
void computeBMM (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeFFT (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computePSD (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computePSDAtZero (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeGeweke (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeMeanStacc (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeBMM (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeFFT (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computePSD (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computePSDAtZero (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeGeweke (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeMeanStacc (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, std::ofstream *passedOfs)
 
void computeMeanVars (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs, V *subMeanPtr, V *subMedianPtr, V *subSampleVarPtr, V *subPopulVarPtr)
 
void computeAutoCorrViaDef (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
 
void computeAutoCorrViaFFT (const SequenceStatisticalOptions &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
 
void computeCovCorrMatrices (const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
 
void computeMeanVars (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs, V *subMeanPtr, V *subMedianPtr, V *subSampleVarPtr, V *subPopulVarPtr)
 
void computeAutoCorrViaDef (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
 
void computeAutoCorrViaFFT (const SsOptionsValues &statisticalOptions, const std::vector< unsigned int > &initialPosForStatistics, const std::vector< unsigned int > &lagsForCorrs, std::ofstream *passedOfs)
 
void computeCovCorrMatrices (const SsOptionsValues &statisticalOptions, std::ofstream *passedOfs)
 
- Protected Attributes inherited from QUESO::BaseVectorSequence< V, M >
const BaseEnvironmentm_env
 
const VectorSpace< V, M > & m_vectorSpace
 
std::string m_name
 
Fft< double > * m_fftObj
 
V * m_subMinPlain
 
V * m_unifiedMinPlain
 
V * m_subMaxPlain
 
V * m_unifiedMaxPlain
 
V * m_subMeanPlain
 
V * m_unifiedMeanPlain
 
V * m_subMedianPlain
 
V * m_unifiedMedianPlain
 
V * m_subSampleVariancePlain
 
V * m_unifiedSampleVariancePlain
 
BoxSubset< V, M > * m_subBoxPlain
 
BoxSubset< V, M > * m_unifiedBoxPlain
 

Detailed Description

template<class V = GslVector, class M = GslMatrix>
class QUESO::SequenceOfVectors< V, M >

Class for handling vector samples (sequence of vectors).

This class handles vector samples generated by an algorithm, as well as operations that can be carried over them, e.g., calculation of means, correlation and covariance matrices. It is derived from and implements BaseVectorSequence<V,M>.

Definition at line 49 of file SequenceOfVectors.h.

Member Typedef Documentation

template<class V = GslVector, class M = GslMatrix>
typedef std::vector<const V*>::const_iterator QUESO::SequenceOfVectors< V, M >::seqVectorPositionConstIteratorTypedef

Definition at line 55 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
typedef std::vector<const V*>::iterator QUESO::SequenceOfVectors< V, M >::seqVectorPositionIteratorTypedef

Definition at line 56 of file SequenceOfVectors.h.

Constructor & Destructor Documentation

template<class V , class M >
QUESO::SequenceOfVectors< V, M >::SequenceOfVectors ( const VectorSpace< V, M > &  vectorSpace,
unsigned int  subSequenceSize,
const std::string &  name 
)

Default constructor.

Definition at line 33 of file SequenceOfVectors.C.

37  :
38  BaseVectorSequence<V,M>(vectorSpace,subSequenceSize,name),
39  m_seq (subSequenceSize,NULL)
40 #ifdef UQ_CODE_HAS_MONITORS
41  ,
43  m_subMeanVecSeq (NULL),
44  m_subMeanCltStdSeq (NULL),
46  m_subMeanInter0Mean (NULL),
47  m_subMeanInter0Clt95 (NULL),
49  m_subMeanInter0Min (NULL),
50  m_subMeanInter0Max (NULL),
52  m_unifiedMeanVecSeq (NULL),
54 #endif
55 {
56  //if (m_env.subDisplayFile()) {
57  // *m_env.subDisplayFile() << "Entering SequenceOfVectors<V,M>::constructor()"
58  // << std::endl;
59  //}
60 
61  //if (m_env.subDisplayFile()) {
62  // *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::constructor()"
63  // << std::endl;
64  //}
65 }
66 // Destructor ---------------------------------------
67 template <class V, class M>
69 {
70 #ifdef UQ_CODE_HAS_MONITORS
72  if (m_subMeanVecSeq ) delete m_subMeanVecSeq;
74 
81 
85 #endif
86 
87  for (unsigned int i = 0; i < (unsigned int) m_seq.size(); ++i) {
88  if (m_seq[i]) delete m_seq[i];
89  }
90 }
SequenceOfVectors< V, M > * m_subMeanInter0Clt95
SequenceOfVectors< V, M > * m_unifiedMeanVecSeq
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
SequenceOfVectors< V, M > * m_subMeanInter0Empirical90
SequenceOfVectors< V, M > * m_subMeanCltStdSeq
SequenceOfVectors< V, M > * m_subMeanVecSeq
const std::string & name() const
Access to protected attribute m_name: name of the sequence of vectors.
~SequenceOfVectors()
Destructor.
std::vector< const V * > m_seq
Sequence of vectors.
SequenceOfVectors< V, M > * m_subMeanInter0Mean
SequenceOfVectors< V, M > * m_subMeanInter0Min
const VectorSpace< V, M > & vectorSpace() const
Vector space; access to protected attribute VectorSpace&lt;V,M&gt;&amp; m_vectorSpace.
ScalarSequence< double > * m_subMeanInter0MonitorPosSeq
ScalarSequence< double > * m_subMeanMonitorPosSeq
SequenceOfVectors< V, M > * m_unifiedMeanCltStdSeq
ScalarSequence< double > * m_unifiedMeanMonitorPosSeq
SequenceOfVectors< V, M > * m_subMeanInter0Max
template<class V = GslVector, class M = GslMatrix>
QUESO::SequenceOfVectors< V, M >::~SequenceOfVectors ( )

Destructor.

Member Function Documentation

template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::autoCorrViaDef ( unsigned int  initialPos,
unsigned int  numPos,
unsigned int  lag,
V &  corrVec 
) const
virtual

Calculates the autocorrelation via definition.

Autocorrelation is the cross-correlation of a variable with itself; it describes the correlation between values of the process at different times, as a function of the two times. It is calculated over a sequence of vectors with initial position initialPos, considering numPos positions, a lag of lag, with mean given by meanVec. Output:

Parameters
corrVecis the vector of the calculated autocorrelations of the sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 766 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::autoCorrViaDef().

771 {
772  bool bRC = ((initialPos < this->subSequenceSize()) &&
773  (0 < numPos ) &&
774  ((initialPos+numPos) <= this->subSequenceSize()) &&
775  (lag < numPos ) && // lag should not be too large
776  (this->vectorSizeLocal() == corrVec.sizeLocal() ));
777  queso_require_msg(bRC, "invalid input data");
778 
779  ScalarSequence<double> data(m_env,0,"");
780 
781  unsigned int numParams = this->vectorSizeLocal();
782  for (unsigned int i = 0; i < numParams; ++i) {
783  this->extractScalarSeq(initialPos,
784  1, // spacing
785  numPos,
786  i,
787  data);
788  corrVec[i] = data.autoCorrViaDef(0,
789  numPos,
790  lag);
791  }
792 
793  return;
794 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::autoCorrViaFft ( unsigned int  initialPos,
unsigned int  numPos,
const std::vector< unsigned int > &  lags,
std::vector< V * > &  corrVecs 
) const
virtual

Calculates the autocorrelation via Fast Fourier transforms (FFT).

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 798 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::autoCorrViaFft().

803 {
804  bool bRC = ((initialPos < this->subSequenceSize()) &&
805  (0 < numPos ) &&
806  ((initialPos+numPos) <= this->subSequenceSize()) &&
807  (0 < lags.size() ) &&
808  (lags[lags.size()-1] < numPos )); // lag should not be too large
809  queso_require_msg(bRC, "invalid input data");
810 
811  for (unsigned int j = lags.size(); j < corrVecs.size(); ++j) {
812  if (corrVecs[j] != NULL) {
813  delete corrVecs[j];
814  corrVecs[j] = NULL;
815  }
816  }
817  corrVecs.resize(lags.size(),NULL);
818  for (unsigned int j = 0; j < corrVecs.size(); ++j) {
819  if (corrVecs[j] == NULL) corrVecs[j] = new V(m_vectorSpace.zeroVector());
820  }
821 
822  ScalarSequence<double> data(m_env,0,"");
823  unsigned int maxLag = lags[lags.size()-1];
824  std::vector<double> autoCorrs(maxLag+1,0.); // Yes, +1
825 
826  unsigned int numParams = this->vectorSizeLocal();
827  for (unsigned int i = 0; i < numParams; ++i) {
828  this->extractScalarSeq(initialPos,
829  1, // spacing
830  numPos,
831  i,
832  data);
833 
834  //if (m_env.subDisplayFile()) {
835  // *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::autoCorrViaFft()"
836  // << ": about to call data.autoCorrViaFft() for paramId = " << i
837  // << ", with numPos = " << numPos
838  // << ", maxLag = " << maxLag
839  // << ", autoCorrs.size() = " << autoCorrs.size()
840  // << std::endl;
841  //}
842  data.autoCorrViaFft(0,
843  numPos,
844  maxLag,
845  autoCorrs);
846 
847  for (unsigned int j = 0; j < lags.size(); ++j) {
848  (*(corrVecs[j]))[i] = autoCorrs[lags[j]];
849  }
850  }
851 
852  return;
853 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::autoCorrViaFft ( unsigned int  initialPos,
unsigned int  numPos,
unsigned int  numSum,
V &  autoCorrsSumVec 
) const
virtual

Calculates the autocorrelation via Fast Fourier transforms (FFT).

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 857 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::autoCorrViaFft().

862 {
863  bool bRC = ((initialPos < this->subSequenceSize()) &&
864  (0 < numPos ) &&
865  ((initialPos+numPos) <= this->subSequenceSize()) &&
866  (0 < numSum ) &&
867  (numSum <= numPos ) &&
868  (autoCorrsSumVec.sizeLocal() == this->vectorSizeLocal()));
869  queso_require_msg(bRC, "invalid input data");
870 
871  ScalarSequence<double> data(m_env,0,"");
872 
873  unsigned int numParams = this->vectorSizeLocal();
874  for (unsigned int i = 0; i < numParams; ++i) {
875  this->extractScalarSeq(initialPos,
876  1, // spacing
877  numPos,
878  i,
879  data);
880 
881  data.autoCorrViaFft(0,
882  numPos,
883  numSum,
884  autoCorrsSumVec[i]);
885  }
886 
887  return;
888 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::autoCovariance ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
unsigned int  lag,
V &  covVec 
) const
virtual

Calculates the autocovariance.

The autocovariance is the covariance of a variable with itself at some other time. It is calculated over a sequence of vectors with initial position initialPos, considering numPos positions, a lag of lag, with mean given by meanVec. Output:

Parameters
covVecis the vector of the calculated autocovariances of the sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 731 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::autoCovariance().

737 {
738  bool bRC = ((initialPos < this->subSequenceSize()) &&
739  (0 < numPos ) &&
740  ((initialPos+numPos) <= this->subSequenceSize()) &&
741  (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
742  (lag < numPos ) && // lag should not be too large
743  (this->vectorSizeLocal() == covVec.sizeLocal() ));
744  queso_require_msg(bRC, "invalid input data");
745 
746  ScalarSequence<double> data(m_env,0,"");
747 
748  unsigned int numParams = this->vectorSizeLocal();
749  for (unsigned int i = 0; i < numParams; ++i) {
750  this->extractScalarSeq(initialPos,
751  1, // spacing
752  numPos,
753  i,
754  data);
755  covVec[i] = data.autoCovariance(0,
756  numPos,
757  meanVec[i],
758  lag);
759  }
760 
761  return;
762 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::bmm ( unsigned int  initialPos,
unsigned int  batchLength,
V &  bmmVec 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2412 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::bmm().

2416 {
2417  bool bRC = ((initialPos < this->subSequenceSize() ) &&
2418  (batchLength < (this->subSequenceSize()-initialPos)) &&
2419  (this->vectorSizeLocal() == bmmVec.sizeLocal() ));
2420  queso_require_msg(bRC, "invalid input data");
2421 
2422  ScalarSequence<double> data(m_env,0,"");
2423 
2424  unsigned int numParams = this->vectorSizeLocal();
2425  for (unsigned int i = 0; i < numParams; ++i) {
2426  this->extractScalarSeq(initialPos,
2427  1, // spacing
2428  this->subSequenceSize()-initialPos,
2429  i,
2430  data);
2431  bmmVec[i] = data.bmm(0,
2432  batchLength);
2433  }
2434 
2435  return;
2436 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::copy ( const SequenceOfVectors< V, M > &  src)
private

Copies vector sequence src to this.

Definition at line 2234 of file SequenceOfVectors.C.

References QUESO::BaseVectorSequence< V, M >::copy(), QUESO::SequenceOfVectors< V, M >::m_seq, and QUESO::SequenceOfVectors< V, M >::subSequenceSize().

2235 {
2237  for (unsigned int i = 0; i < (unsigned int) m_seq.size(); ++i) {
2238  if (m_seq[i]) {
2239  delete m_seq[i];
2240  m_seq[i] = NULL;
2241  }
2242  }
2243  m_seq.resize(src.subSequenceSize(),NULL);
2244  for (unsigned int i = 0; i < m_seq.size(); ++i) {
2245  m_seq[i] = new V(*(src.m_seq[i]));
2246  }
2247 
2248  return;
2249 }
void copy(const BaseVectorSequence< V, M > &src)
Copies vector sequence src to this.
std::vector< const V * > m_seq
Sequence of vectors.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::erasePositions ( unsigned int  initialPos,
unsigned int  numPos 
)
virtual

Erases numPos elements of the sequence starting at position initialPos.

This routine deletes all stored computed vectors

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 154 of file SequenceOfVectors.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors(), and QUESO::queso_require_equal_to_msg.

155 {
156  bool bRC = ((initialPos < this->subSequenceSize()) &&
157  (0 < numPos ) &&
158  ((initialPos+numPos) <= this->subSequenceSize()));
159  queso_require_msg(bRC, "invalid input data");
160 
161  for (unsigned int j = 0; j < numPos; ++j) {
162  if (m_seq[initialPos+j] != NULL) {
163  delete m_seq[initialPos+j];
164  m_seq[initialPos+j] = NULL;
165  }
166  }
167 
168  seqVectorPositionIteratorTypedef posIteratorBegin = m_seq.begin();
169  if (initialPos < this->subSequenceSize()) std::advance(posIteratorBegin,initialPos);
170  else posIteratorBegin = m_seq.end();
171 
172  unsigned int posEnd = initialPos + numPos;
173  seqVectorPositionIteratorTypedef posIteratorEnd = m_seq.begin();
174  if (posEnd < this->subSequenceSize()) std::advance(posIteratorEnd,posEnd);
175  else posIteratorEnd = m_seq.end();
176 
177  unsigned int oldSubSequenceSize = this->subSequenceSize();
178  m_seq.erase(posIteratorBegin,posIteratorEnd);
179  queso_require_equal_to_msg((oldSubSequenceSize - numPos), this->subSequenceSize(), "(oldSubSequenceSize - numPos) != this->subSequenceSize()");
180 
182 
183  return;
184 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void deleteStoredVectors()
Deletes all the stored vectors.
std::vector< const V * > m_seq
Sequence of vectors.
std::vector< const V * >::iterator seqVectorPositionIteratorTypedef
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
template<class V , class M >
double QUESO::SequenceOfVectors< V, M >::estimateConvBrooksGelman ( unsigned int  initialPos,
unsigned int  numPos 
) const
virtual

Estimates convergence rate using Brooks & Gelman method.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2083 of file SequenceOfVectors.C.

References QUESO::matrixProduct().

2086 {
2087  // This method requires *at least* two sequences. Error if there is only one.
2088  queso_require_greater_equal_msg(m_env.numSubEnvironments(), 2, "At least two sequences required for Brooks-Gelman convergence test.");
2089 
2090  // TODO: Need special case for 1-dimensional parameter space.
2091 
2092  // Initialize with garbage to give the user a clue something is funky.
2093  double convMeasure = -1.0;
2094 
2095  // We only do the work on the subenvironment where the sequence data
2096  // is stashed.
2097  if( m_env.inter0Rank() >= 0 )
2098  {
2099  // Sanity Checks
2100 
2101  // REMEMBER: \psi is a *vector* of parameters
2102  // Get quantities we will use several times
2103  V psi_j_dot = m_vectorSpace.zeroVector();
2104  V psi_dot_dot = m_vectorSpace.zeroVector();
2105  V work = m_vectorSpace.zeroVector();
2106 
2107  // m = number of chains > 1
2108  // n = number of steps for which we are computing the metric
2109  int m = m_env.numSubEnvironments();
2110  int n = numPos;
2111 
2112  this->subMeanExtra ( initialPos, numPos, psi_j_dot );
2113  this->unifiedMeanExtra( initialPos, numPos, psi_dot_dot );
2114 
2115 #if 0
2116  std::cout << "psi_j_dot = " << psi_j_dot << std::endl;
2117  std::cout << "psi_dot_dot = " << psi_dot_dot << std::endl;
2118 #endif
2119 
2120  /* W = \frac{1}{m*(n-1)}*\sum_{j=1}^m \sum{t=1}^n
2121  (\psi_{jt} - \overline{\psi_{j\cdot}})*(\psi_{jt} - \overline{\psi_{j\cdot}})^T
2122  This corresponds to the "within-sequence" covariance matrix. */
2123  M* W_local = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2124  M* W = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2125  V psi_j_t = m_vectorSpace.zeroVector();
2126 
2127  // Sum within the chain
2128  for( unsigned int t = initialPos; t < initialPos+numPos; ++t )
2129  {
2130  psi_j_t = *(m_seq[t]);
2131 
2132  work = psi_j_t - psi_j_dot;
2133 
2134  (*W_local) += matrixProduct( work, work );
2135  }
2136 
2137  // Now do the sum over the chains
2138  // W will be available on all inter0 processors
2139  W_local->mpiSum( m_env.inter0Comm(), (*W) );
2140 
2141  (*W) = 1.0/(double(m)*(double(n)-1.0)) * (*W);
2142 
2143 #if 0
2144  std::cout << "n, m = " << n << ", " << m << std::endl;
2145  std::cout << "W_local = " << *W_local << std::endl;
2146  std::cout << "W = " << *W << std::endl;
2147 #endif
2148 
2149  // Need to delete pointers to temporary covariance matrices
2150  delete W_local;
2151 
2152  /* B/n = \frac{1}{m-1}\sum_{j=1}^m
2153  (\overline{\psi_{j\cdot}} - \overline{\psi_{\cdot \cdot}})*
2154  (\overline{\psi_{j\cdot}} - \overline{\psi_{\cdot \cdot}})^T
2155  This corresponds to the "between-sequence" covariance matrix. */
2156  M* B_over_n_local = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2157  M* B_over_n = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2158 
2159  work = psi_j_dot - psi_dot_dot;
2160  (*B_over_n_local) = matrixProduct( work, work );
2161 
2162  B_over_n_local->mpiSum( m_env.inter0Comm(), (*B_over_n) );
2163 
2164  // Need to delete pointers to temporary covariance matrices
2165  delete B_over_n_local;
2166 
2167  (*B_over_n) = 1.0/(double(m)-1.0) * (*B_over_n);
2168 
2169 #if 0
2170  std::cout << "B_over_n = " << *B_over_n << std::endl;
2171 #endif
2172 
2173 
2174  /* R_p = (n-1)/n + (m+1)/m * \lambda
2175  \lambda = largest eigenvalue of W^{-1}*B/n */
2176  M* A = m_vectorSpace.newDiagMatrix( m_vectorSpace.zeroVector() );
2177 
2178  W->invertMultiply( *B_over_n, *A );
2179 
2180 #if 0
2181  std::cout << "A = " << *A << std::endl;
2182  std::cout.flush();
2183 #endif
2184  // Need to delete pointers to temporary covariance matrices
2185  delete W;
2186  delete B_over_n;
2187 
2188  double eigenValue;
2189  V eigenVector = m_vectorSpace.zeroVector();
2190 
2191  A->largestEigen( eigenValue, eigenVector );
2192 
2193  // Need to delete pointers to temporary covariance matrices
2194  delete A;
2195 
2196  // Now, finally compute the final convMeasure
2197  convMeasure = (double(n)-1.0)/double(n) + (double(m)+1.0)/double(m)*eigenValue;
2198 
2199  } // End of check on inter0Rank
2200 
2201  //TODO: Do we need a Barrier here?
2202  //TODO: Error checking on MPI.
2203  //m_env.fullComm().Barrier(); // Dangerous to barrier on fullComm ...
2204 
2205  return convMeasure;
2206 }
const MpiComm & inter0Comm() const
Access function for MpiComm communicator for processes with subRank() 0.
Definition: Environment.C:313
void subMeanExtra(unsigned int initialPos, unsigned int numPos, V &meanVec) const
Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPo...
const VectorSpace< V, M > & m_vectorSpace
std::vector< const V * > m_seq
Sequence of vectors.
GslMatrix matrixProduct(const GslVector &v1, const GslVector &v2)
Definition: GslMatrix.C:2036
void unifiedMeanExtra(unsigned int initialPos, unsigned int numPos, V &unifiedMeanVec) const
Finds the mean value of the unified sequence, considering numPos positions starting at position initi...
const BaseEnvironment & m_env
unsigned int numSubEnvironments() const
Access function to the number of sub-environments.
Definition: Environment.C:335
int inter0Rank() const
Returns the process inter0 rank.
Definition: Environment.C:307
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::extractRawData ( unsigned int  initialPos,
unsigned int  spacing,
unsigned int  numPos,
unsigned int  paramId,
std::vector< double > &  rawData 
) const
privatevirtual

Extracts the raw data.

This method saves in rawData the data from the sequence of vectors (in private attribute m_seq) starting at position (initialPos,paramId) , with a spacing of spacing until numPos positions have been extracted.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2253 of file SequenceOfVectors.C.

2259 {
2260  rawData.resize(numPos);
2261  if (spacing == 1) {
2262  for (unsigned int j = 0; j < numPos; ++j) {
2263  rawData[j] = (*(m_seq[initialPos+j ]))[paramId];
2264  }
2265  }
2266  else {
2267  for (unsigned int j = 0; j < numPos; ++j) {
2268  rawData[j] = (*(m_seq[initialPos+j*spacing]))[paramId];
2269  }
2270  }
2271 
2272  return;
2273 }
std::vector< const V * > m_seq
Sequence of vectors.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::extractScalarSeq ( unsigned int  initialPos,
unsigned int  spacing,
unsigned int  numPos,
unsigned int  paramId,
ScalarSequence< double > &  scalarSeq 
) const
virtual

Extracts a sequence of scalars.

The sequence of scalars has size numPos, and it will be extracted starting at position (initialPos, paramId ) of this sequences of vectors, given spacing spacing.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2210 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::resizeSequence().

2216 {
2217  scalarSeq.resizeSequence(numPos);
2218  if (spacing == 1) {
2219  for (unsigned int j = 0; j < numPos; ++j) {
2220  scalarSeq[j] = (*(m_seq[initialPos+j ]))[paramId];
2221  }
2222  }
2223  else {
2224  for (unsigned int j = 0; j < numPos; ++j) {
2225  scalarSeq[j] = (*(m_seq[initialPos+j*spacing]))[paramId];
2226  }
2227  }
2228 
2229  return;
2230 }
void resizeSequence(unsigned int newSequenceSize)
Resizes the size of the sequence of scalars.
std::vector< const V * > m_seq
Sequence of vectors.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::fftForward ( unsigned int  initialPos,
unsigned int  fftSize,
unsigned int  paramId,
std::vector< std::complex< double > > &  fftResult 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2440 of file SequenceOfVectors.C.

2445 {
2446  bool bRC = ((initialPos < this->subSequenceSize()) &&
2447  (paramId < this->vectorSizeLocal()) &&
2448  (0 < fftSize ) &&
2449  ((initialPos+fftSize) <= this->subSequenceSize()) &&
2450  (fftSize < this->subSequenceSize()));
2451  queso_require_msg(bRC, "invalid input data");
2452 
2453  std::vector<double> rawData(fftSize,0.);
2454  this->extractRawData(initialPos,
2455  1, // spacing
2456  fftSize,
2457  paramId,
2458  rawData);
2459 
2460  m_fftObj->forward(rawData,fftSize,fftResult);
2461 
2462  return;
2463 }
void forward(const std::vector< T > &data, unsigned int fftSize, std::vector< std::complex< double > > &result)
Calculates the forward Fourier transform (for real data. TODO: complex data).
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractRawData(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, std::vector< double > &rawData) const
Extracts the raw data.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::filter ( unsigned int  initialPos,
unsigned int  spacing 
)
virtual

Filters positions in the sequence of vectors.

Filtered positions will starting at initialPos, and with spacing given by spacing.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2042 of file SequenceOfVectors.C.

Referenced by QUESO::MLSampling< P_V, P_M >::generateSequence(), and QUESO::MLSampling< P_V, P_M >::generateSequence_Step11_inter0().

2045 {
2046  if (m_env.subDisplayFile()) {
2047  *m_env.subDisplayFile() << "Entering SequenceOfVectors<V,M>::filter()"
2048  << ": initialPos = " << initialPos
2049  << ", spacing = " << spacing
2050  << ", subSequenceSize = " << this->subSequenceSize()
2051  << std::endl;
2052  }
2053 
2054  unsigned int i = 0;
2055  unsigned int j = initialPos;
2056  unsigned int originalSubSequenceSize = this->subSequenceSize();
2057  while (j < originalSubSequenceSize) {
2058  if (i != j) {
2059  //*m_env.subDisplayFile() << i << "--" << j << " ";
2060  delete m_seq[i];
2061  m_seq[i] = new V(*(m_seq[j]));
2062  }
2063  i++;
2064  j += spacing;
2065  }
2066 
2067  this->resetValues(i,originalSubSequenceSize-i);
2068  this->resizeSequence(i);
2069 
2070  if (m_env.subDisplayFile()) {
2071  *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::filter()"
2072  << ": initialPos = " << initialPos
2073  << ", spacing = " << spacing
2074  << ", subSequenceSize = " << this->subSequenceSize()
2075  << std::endl;
2076  }
2077 
2078  return;
2079 }
void resetValues(unsigned int initialPos, unsigned int numPos)
Resets a total of numPos values of the sequence starting at position initialPos.
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
std::vector< const V * > m_seq
Sequence of vectors.
void resizeSequence(unsigned int newSubSequenceSize)
Resizes the sequence.
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::getPositionValues ( unsigned int  posId,
V &  vec 
) const
virtual

Gets the values of the sequence at position posId and stores them at vec.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 188 of file SequenceOfVectors.C.

Referenced by QUESO::MLSampling< P_V, P_M >::generateBalLinkedChains_all(), QUESO::MLSampling< P_V, P_M >::generateSequence(), QUESO::MetropolisHastingsSG< P_V, P_M >::generateSequence(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step02_inter0(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step04_inter0(), QUESO::MLSampling< P_V, P_M >::generateUnbLinkedChains_all(), and QUESO::MLSampling< P_V, P_M >::mpiExchangePositions_inter0().

189 {
190  queso_require_less_msg(posId, this->subSequenceSize(), "posId > subSequenceSize()");
191 
192  queso_require_msg(m_seq[posId], "posId is NULL");
193 
194  //if (posId == 0) { // mox
195  // std::cout << "In SequenceOfVectors<V,M>::getPositionValues(): m_seq[0] = " << m_seq[0] << ", *(m_seq[0]) = " << *(m_seq[0])
196  // << std::endl;
197  //}
198 
199  vec = *(m_seq[posId]); // *(const_cast<V*>(m_seq[posId])); // prudenci 2010-06-17 mox
200 
201  return;
202 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
std::vector< const V * > m_seq
Sequence of vectors.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::geweke ( unsigned int  initialPos,
double  ratioNa,
double  ratioNb,
V &  gewVec 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2528 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::geweke().

2533 {
2534  bool bRC = ((initialPos < this->subSequenceSize()) &&
2535  (this->vectorSizeLocal() == gewVec.sizeLocal() ));
2536  queso_require_msg(bRC, "invalid input data");
2537 
2538  unsigned int numPos = this->subSequenceSize() - initialPos;
2539  ScalarSequence<double> data(m_env,0,"");
2540 
2541  unsigned int numParams = this->vectorSizeLocal();
2542  for (unsigned int i = 0; i < numParams; ++i) {
2543  this->extractScalarSeq(initialPos,
2544  1, // spacing
2545  numPos,
2546  i,
2547  data);
2548  gewVec[i] = data.geweke(0,
2549  ratioNa,
2550  ratioNb);
2551  }
2552 
2553  return;
2554 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::meanStacc ( unsigned int  initialPos,
V &  meanStaccVec 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2558 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::meanStacc().

2561 {
2562  bool bRC = ((initialPos < this->subSequenceSize() ) &&
2563  (this->vectorSizeLocal() == meanStaccVec.sizeLocal()));
2564  queso_require_msg(bRC, "invalid input data");
2565 
2566  unsigned int numPos = this->subSequenceSize() - initialPos;
2567  ScalarSequence<double> data(m_env,0,"");
2568 
2569  unsigned int numParams = this->vectorSizeLocal();
2570  for (unsigned int i = 0; i < numParams; ++i) {
2571  this->extractScalarSeq(initialPos,
2572  1, // spacing
2573  numPos,
2574  i,
2575  data);
2576  meanStaccVec[i] = data.meanStacc(0);
2577  }
2578 
2579  return;
2580 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
SequenceOfVectors< V, M > & QUESO::SequenceOfVectors< V, M >::operator= ( const SequenceOfVectors< V, M > &  rhs)

Copies values from rhs to this.

Definition at line 94 of file SequenceOfVectors.C.

95 {
96  this->copy(rhs);
97  return *this;
98 }
void copy(const SequenceOfVectors< V, M > &src)
Copies vector sequence src to this.
template<class V , class M >
const V * QUESO::SequenceOfVectors< V, M >::operator[] ( unsigned int  posId) const

Definition at line 2282 of file SequenceOfVectors.C.

2283 {
2284  queso_require_less_msg(posId, this->subSequenceSize(), "posId > subSequenceSize()");
2285 
2286  return (const V*) (m_seq[posId]);
2287 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
std::vector< const V * > m_seq
Sequence of vectors.
template<class V , class M >
const V *& QUESO::SequenceOfVectors< V, M >::operator[] ( unsigned int  posId)

Definition at line 2291 of file SequenceOfVectors.C.

2292 {
2293  queso_require_less_msg(posId, this->subSequenceSize(), "posId > subSequenceSize()");
2294 
2295  return m_seq[posId];
2296 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
std::vector< const V * > m_seq
Sequence of vectors.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::psd ( unsigned int  initialPos,
unsigned int  numBlocks,
double  hopSizeRatio,
unsigned int  paramId,
std::vector< double > &  psdResult 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2467 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::psd().

2473 {
2474  bool bRC = ((initialPos < this->subSequenceSize()) &&
2475  (paramId < this->vectorSizeLocal()));
2476  queso_require_msg(bRC, "invalid input data");
2477 
2478  ScalarSequence<double> data(m_env,0,"");
2479 
2480  this->extractScalarSeq(initialPos,
2481  1, // spacing
2482  this->subSequenceSize()-initialPos,
2483  paramId,
2484  data);
2485  data.psd(0,
2486  numBlocks,
2487  hopSizeRatio,
2488  psdResult);
2489 
2490  return;
2491 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::psdAtZero ( unsigned int  initialPos,
unsigned int  numBlocks,
double  hopSizeRatio,
V &  psdVec 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2495 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::psd().

2500 {
2501  bool bRC = ((initialPos < this->subSequenceSize()) &&
2502  (this->vectorSizeLocal() == psdVec.sizeLocal()));
2503  queso_require_msg(bRC, "invalid input data");
2504 
2505  ScalarSequence<double> data(m_env,0,"");
2506  std::vector<double> psdResult(0,0.); // size will be determined by 'data.psd()'
2507 
2508  unsigned int numParams = this->vectorSizeLocal();
2509  for (unsigned int i = 0; i < numParams; ++i) {
2510  this->extractScalarSeq(initialPos,
2511  1, // spacing
2512  this->subSequenceSize()-initialPos,
2513  i,
2514  data);
2515  data.psd(0,
2516  numBlocks,
2517  hopSizeRatio,
2518  psdResult);
2519  psdVec[i] = psdResult[0];
2520  //*m_env.subDisplayFile() << "psdResult[0] = " << psdResult[0] << std::endl;
2521  }
2522 
2523  return;
2524 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::resetValues ( unsigned int  initialPos,
unsigned int  numPos 
)
virtual

Resets a total of numPos values of the sequence starting at position initialPos.

This routine deletes all stored computed vectors

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 126 of file SequenceOfVectors.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors().

127 {
128  bool bRC = ((initialPos < this->subSequenceSize()) &&
129  (0 < numPos ) &&
130  ((initialPos+numPos) <= this->subSequenceSize()));
131  if ((bRC == false) && (m_env.subDisplayFile())) {
132  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::resetValues()"
133  << ", initialPos = " << initialPos
134  << ", this->subSequenceSize() = " << this->subSequenceSize()
135  << ", numPos = " << numPos
136  << std::endl;
137  }
138  queso_require_msg(bRC, "invalid input data");
139 
140  for (unsigned int j = 0; j < numPos; ++j) {
141  if (m_seq[initialPos+j] != NULL) {
142  delete m_seq[initialPos+j];
143  m_seq[initialPos+j] = NULL;
144  }
145  }
146 
148 
149  return;
150 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void deleteStoredVectors()
Deletes all the stored vectors.
std::vector< const V * > m_seq
Sequence of vectors.
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::resizeSequence ( unsigned int  newSubSequenceSize)
virtual

Resizes the sequence.

This routine deletes all stored computed vectors

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 110 of file SequenceOfVectors.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors().

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::adapt(), and QUESO::MLSampling< P_V, P_M >::generateSequence_Level0_all().

111 {
112  if (newSubSequenceSize != this->subSequenceSize()) {
113  if (newSubSequenceSize < this->subSequenceSize()) {
114  this->resetValues(newSubSequenceSize,this->subSequenceSize()-newSubSequenceSize);
115  }
116  m_seq.resize(newSubSequenceSize,NULL);
117  std::vector<const V*>(m_seq).swap(m_seq);
119  }
120 
121  return;
122 }
void resetValues(unsigned int initialPos, unsigned int numPos)
Resets a total of numPos values of the sequence starting at position initialPos.
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void deleteStoredVectors()
Deletes all the stored vectors.
std::vector< const V * > m_seq
Sequence of vectors.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::select ( const std::vector< unsigned int > &  idsOfUniquePositions)
virtual

TODO: It shall select positions in the sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2033 of file SequenceOfVectors.C.

2034 {
2035  queso_error_msg("Code is not complete yet");
2036 
2037  return;
2038 }
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::setPositionValues ( unsigned int  posId,
const V &  vec 
)
virtual

Set the values in vec at position posId of the sequence.

This routine deletes all stored computed vectors

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 206 of file SequenceOfVectors.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors(), and QUESO::queso_require_equal_to_msg.

Referenced by QUESO::MetropolisHastingsSG< P_V, P_M >::adapt(), and QUESO::MLSampling< P_V, P_M >::generateSequence_Level0_all().

207 {
208  queso_require_less_msg(posId, this->subSequenceSize(), "posId > subSequenceSize()");
209 
210  queso_require_equal_to_msg(vec.sizeLocal(), m_vectorSpace.zeroVector().sizeLocal(), "invalid vec");
211 
212  if (m_seq[posId] != NULL) delete m_seq[posId];
213  m_seq[posId] = new V(vec);
214 
215  //if (posId == 0) { // mox
216  // std::cout << "In SequenceOfVectors<V,M>::setPositionValues(): m_seq[0] = " << m_seq[0] << ", *(m_seq[0]) = " << *(m_seq[0])
217  // << std::endl;
218  //}
219 
221 
222  return;
223 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void deleteStoredVectors()
Deletes all the stored vectors.
const VectorSpace< V, M > & m_vectorSpace
std::vector< const V * > m_seq
Sequence of vectors.
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subCdfPercentageRange ( unsigned int  initialPos,
unsigned int  numPos,
double  range,
V &  lowerVec,
V &  upperVec 
) const

Definition at line 2584 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subCdfPercentageRange().

2590 {
2591  bool bRC = ((0 < numPos ) &&
2592  ((initialPos+numPos) <= this->subSequenceSize()) &&
2593  (this->vectorSizeLocal() == lowerVec.sizeLocal() ) &&
2594  (this->vectorSizeLocal() == upperVec.sizeLocal() ));
2595  queso_require_msg(bRC, "invalid input data");
2596 
2597  unsigned int numParams = this->vectorSizeLocal();
2598  ScalarSequence<double> data(m_env,0,"");
2599 
2600  for (unsigned int i = 0; i < numParams; ++i) {
2601  this->extractScalarSeq(initialPos,
2602  1, // spacing
2603  numPos,
2604  i,
2605  data);
2606  data.subCdfPercentageRange(0,
2607  numPos,
2608  range,
2609  lowerVec[i],
2610  upperVec[i]);
2611  }
2612 
2613  return;
2614 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subCdfStacc ( unsigned int  initialPos,
std::vector< V * > &  cdfStaccVecs,
std::vector< V * > &  cdfStaccVecsUp,
std::vector< V * > &  cdfStaccVecsLow,
std::vector< V * > &  sortedDataVecs 
) const

Definition at line 2653 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subCdfStacc(), and QUESO::ScalarSequence< T >::subSort().

2659 {
2660  bool bRC = (initialPos < this->subSequenceSize());
2661  queso_require_msg(bRC, "invalid input data");
2662 
2663  unsigned int numPos = this->subSequenceSize() - initialPos;
2664  unsigned int numEvals = numPos;
2665  for (unsigned int j = 0; j < numEvals; ++j) {
2666  cdfStaccVecs [j] = new V(m_vectorSpace.zeroVector());
2667  cdfStaccVecsUp [j] = new V(m_vectorSpace.zeroVector());
2668  cdfStaccVecsLow[j] = new V(m_vectorSpace.zeroVector());
2669  sortedDataVecs [j] = new V(m_vectorSpace.zeroVector());
2670  }
2671  std::vector<double> cdfStaccs (numEvals,0.);
2672  std::vector<double> cdfStaccsup (numEvals,0.);
2673  std::vector<double> cdfStaccslow(numEvals,0.);
2674 
2675  ScalarSequence<double> data (m_env,0,"");
2676  ScalarSequence<double> sortedData(m_env,0,"");
2677  unsigned int numParams = this->vectorSizeLocal();
2678  for (unsigned int i = 0; i < numParams; ++i) {
2679  this->extractScalarSeq(initialPos,
2680  1, // spacing
2681  numPos,
2682  i,
2683  data);
2684  //std::cout << "x-data" << data<< std::endl;
2685  data.subSort(initialPos,sortedData);
2686  data.subCdfStacc(initialPos,
2687  cdfStaccs,
2688  cdfStaccsup,
2689  cdfStaccslow,
2690  sortedData);
2691 
2692  for (unsigned int j = 0; j < numEvals; ++j) {
2693  (*sortedDataVecs [j])[i] = sortedData [j];
2694  (*cdfStaccVecs [j])[i] = cdfStaccs [j];
2695  (*cdfStaccVecsUp [j])[i] = cdfStaccsup [j];
2696  (*cdfStaccVecsLow[j])[i] = cdfStaccslow[j];
2697  }
2698  }
2699 
2700  return;
2701 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subCdfStacc ( unsigned int  initialPos,
const std::vector< V * > &  evalPositionsVecs,
std::vector< V * > &  cdfStaccVecs 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2705 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subCdfStacc().

2709 {
2710  bool bRC = ((initialPos < this->subSequenceSize() ) &&
2711  (0 < evalPositionsVecs.size()) &&
2712  (evalPositionsVecs.size() == cdfStaccVecs.size() ));
2713  queso_require_msg(bRC, "invalid input data");
2714 
2715  unsigned int numPos = this->subSequenceSize() - initialPos;
2716  ScalarSequence<double> data(m_env,0,"");
2717 
2718  unsigned int numEvals = evalPositionsVecs.size();
2719  for (unsigned int j = 0; j < numEvals; ++j) {
2720  cdfStaccVecs[j] = new V(m_vectorSpace.zeroVector());
2721  }
2722  std::vector<double> evalPositions(numEvals,0.);
2723  std::vector<double> cdfStaccs (numEvals,0.);
2724 
2725  unsigned int numParams = this->vectorSizeLocal();
2726  for (unsigned int i = 0; i < numParams; ++i) {
2727  this->extractScalarSeq(initialPos,
2728  1, // spacing
2729  numPos,
2730  i,
2731  data);
2732 
2733  for (unsigned int j = 0; j < numEvals; ++j) {
2734  evalPositions[j] = (*evalPositionsVecs[j])[i];
2735  }
2736 
2737  data.subCdfStacc(0,
2738  evalPositions,
2739  cdfStaccs);
2740 
2741  for (unsigned int j = 0; j < numEvals; ++j) {
2742  (*cdfStaccVecs[j])[i] = cdfStaccs[j];
2743  }
2744  }
2745 
2746  return;
2747 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subGaussian1dKde ( unsigned int  initialPos,
const V &  scaleVec,
const std::vector< V * > &  evalParamVecs,
std::vector< V * > &  densityVecs 
) const
virtual

Gaussian kernel for the KDE estimate of the sub-sequence.

Computes a probability density estimate of the sample in this sub-sequence, starting at position initialPos. densityVecs is the vector of density values evaluated at the points in evaluationParamVecs. The estimate is based on Gaussian (normal) kernel function, using a window parameter (scaleVec).

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1165 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subGaussian1dKde().

1170 {
1171  bool bRC = ((initialPos < this->subSequenceSize()) &&
1172  (this->vectorSizeLocal() == scaleVec.sizeLocal() ) &&
1173  (0 < evalParamVecs.size() ) &&
1174  (evalParamVecs.size() == densityVecs.size() ));
1175  queso_require_msg(bRC, "invalid input data");
1176 
1177  unsigned int numPos = this->subSequenceSize() - initialPos;
1178  ScalarSequence<double> data(m_env,0,"");
1179 
1180  unsigned int numEvals = evalParamVecs.size();
1181  for (unsigned int j = 0; j < numEvals; ++j) {
1182  densityVecs[j] = new V(m_vectorSpace.zeroVector());
1183  }
1184  std::vector<double> evalParams(numEvals,0.);
1185  std::vector<double> densities (numEvals,0.);
1186 
1187  unsigned int numParams = this->vectorSizeLocal();
1188  for (unsigned int i = 0; i < numParams; ++i) {
1189  this->extractScalarSeq(initialPos,
1190  1, // spacing
1191  numPos,
1192  i,
1193  data);
1194 
1195  for (unsigned int j = 0; j < numEvals; ++j) {
1196  evalParams[j] = (*evalParamVecs[j])[i];
1197  }
1198 
1199  data.subGaussian1dKde(0,
1200  scaleVec[i],
1201  evalParams,
1202  densities);
1203 
1204  for (unsigned int j = 0; j < numEvals; ++j) {
1205  (*densityVecs[j])[i] = densities[j];
1206  }
1207  }
1208 
1209  return;
1210 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subHistogram ( unsigned int  initialPos,
const V &  minVec,
const V &  maxVec,
std::vector< V * > &  centersForAllBins,
std::vector< V * > &  quanttsForAllBins 
) const
virtual

Calculates the histogram of the sub-sequence.

It requires the specification of the number of bins that the histogram will have, the center of each bin and the initial position where the data will be considered.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 956 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subHistogram().

962 {
963  bool bRC = ((initialPos < this->subSequenceSize() ) &&
964  (this->vectorSizeLocal() == minVec.sizeLocal() ) &&
965  (this->vectorSizeLocal() == maxVec.sizeLocal() ) &&
966  (0 < centersForAllBins.size()) &&
967  (centersForAllBins.size() == quanttsForAllBins.size()));
968  queso_require_msg(bRC, "invalid input data");
969 
970  for (unsigned int j = 0; j < quanttsForAllBins.size(); ++j) {
971  centersForAllBins[j] = new V(m_vectorSpace.zeroVector());
972  quanttsForAllBins [j] = new V(m_vectorSpace.zeroVector());
973  }
974 
975  unsigned int dataSize = this->subSequenceSize() - initialPos;
976  unsigned int numParams = this->vectorSizeLocal();
977  for (unsigned int i = 0; i < numParams; ++i) {
978  ScalarSequence<double> data(m_env,dataSize,"");
979  for (unsigned int j = 0; j < dataSize; ++j) {
980  data[j] = (*(m_seq[initialPos+j]))[i];
981  }
982 
983  std::vector<double > centers(centersForAllBins.size(),0.);
984  std::vector<unsigned int> quantts(quanttsForAllBins.size(), 0 );
985  data.subHistogram(0,
986  minVec[i],
987  maxVec[i],
988  centers,
989  quantts);
990 
991  for (unsigned int j = 0; j < quantts.size(); ++j) {
992  (*(centersForAllBins[j]))[i] = centers[j];
993  (*(quanttsForAllBins[j]))[i] = (double) quantts[j];
994  }
995  }
996 
997  return;
998 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
std::vector< const V * > m_seq
Sequence of vectors.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subInterQuantileRange ( unsigned int  initialPos,
V &  iqrVec 
) const
virtual

Returns the interquartile range of the values in the sub-sequence.

The IQR is a robust estimate of the spread of the data, since changes in the upper and lower 25% of the data do not affect it. If there are outliers in the data, then the IQR is more representative than the standard deviation as an estimate of the spread of the body of the data. The IQR is less efficient than the standard deviation as an estimate of the spread when the data is all from the normal distribution. (from Matlab)

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1049 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subInterQuantileRange().

1052 {
1053  bool bRC = ((initialPos < this->subSequenceSize()) &&
1054  (this->vectorSizeLocal() == iqrVec.sizeLocal() ));
1055  queso_require_msg(bRC, "invalid input data");
1056 
1057  unsigned int numPos = this->subSequenceSize() - initialPos;
1058  ScalarSequence<double> data(m_env,0,"");
1059 
1060  unsigned int numParams = this->vectorSizeLocal();
1061  for (unsigned int i = 0; i < numParams; ++i) {
1062  this->extractScalarSeq(initialPos,
1063  1, // spacing
1064  numPos,
1065  i,
1066  data);
1067  iqrVec[i] = data.subInterQuantileRange(0);
1068  }
1069 
1070  return;
1071 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanCltStd ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
V &  samVec 
) const

Definition at line 2347 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subMeanCltStd().

2352 {
2353  bool bRC = ((initialPos < this->subSequenceSize()) &&
2354  (0 < numPos ) &&
2355  ((initialPos+numPos) <= this->subSequenceSize()) &&
2356  (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
2357  (this->vectorSizeLocal() == stdVec.sizeLocal() ));
2358  queso_require_msg(bRC, "invalid input data");
2359 
2360  ScalarSequence<double> data(m_env,0,"");
2361 
2362  unsigned int numParams = this->vectorSizeLocal();
2363  for (unsigned int i = 0; i < numParams; ++i) {
2364  this->extractScalarSeq(initialPos,
2365  1, // spacing
2366  numPos,
2367  i,
2368  data);
2369  stdVec[i] = data.subMeanCltStd(0,
2370  numPos,
2371  meanVec[i]);
2372  }
2373 
2374  return;
2375 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanExtra ( unsigned int  initialPos,
unsigned int  numPos,
V &  meanVec 
) const
virtual

Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPos.

Output:

Parameters
meanVecis the vector of the calculated means of the sub-sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 308 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subMeanExtra().

312 {
313  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
314  *m_env.subDisplayFile() << "Entering SequenceOfVectors<V,M>::subMeanExtra()"
315  << ": initialPos = " << initialPos
316  << ", numPos = " << numPos
317  << ", sub sequence size = " << this->subSequenceSize()
318  << std::endl;
319  }
320 
321  bool bRC = ((initialPos < this->subSequenceSize()) &&
322  (0 < numPos ) &&
323  ((initialPos+numPos) <= this->subSequenceSize()) &&
324  (this->vectorSizeLocal() == meanVec.sizeLocal() ));
325  if ((bRC == false) && (m_env.subDisplayFile())) {
326  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::subMeanExtra()"
327  << ", initialPos = " << initialPos
328  << ", this->subSequenceSize() = " << this->subSequenceSize()
329  << ", numPos = " << numPos
330  << ", this->vectorSizeLocal() = " << this->vectorSizeLocal()
331  << ", meanVec.sizeLocal() = " << meanVec.sizeLocal()
332  << std::endl;
333  }
334  queso_require_msg(bRC, "invalid input data");
335 
336  ScalarSequence<double> data(m_env,0,"");
337 
338  unsigned int numParams = this->vectorSizeLocal();
339  for (unsigned int i = 0; i < numParams; ++i) {
340  this->extractScalarSeq(initialPos,
341  1, // spacing
342  numPos,
343  i,
344  data);
345  meanVec[i] = data.subMeanExtra(0,
346  numPos);
347  }
348 
349  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
350  *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::subMeanExtra()"
351  << ": initialPos = " << initialPos
352  << ", numPos = " << numPos
353  << ", sub sequence size = " << this->subSequenceSize()
354  << ", meanVec = " << meanVec
355  << std::endl;
356  }
357 
358  return;
359 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int displayVerbosity() const
Definition: Environment.C:450
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanInter0MonitorAlloc ( unsigned int  numberOfMonitorPositions)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2768 of file SequenceOfVectors.C.

2769 {
2770  m_subMeanInter0MonitorPosSeq = new ScalarSequence<double>(m_env, numberOfMonitorPositions,(m_name+"_subMeanInter0MonitorPosSeq").c_str() );
2771  m_subMeanInter0Mean = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_subMeanInter0MeanSeq").c_str() );
2772  m_subMeanInter0Clt95 = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_subMeanInter0Clt95Seq").c_str() );
2773  m_subMeanInter0Empirical90 = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_subMeanInter0Empirical90Seq").c_str());
2774  m_subMeanInter0Min = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_subMeanInter0MinSeq").c_str() );
2775  m_subMeanInter0Max = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_subMeanInter0MaxSeq").c_str() );
2776 
2777  return;
2778 }
SequenceOfVectors< V, M > * m_subMeanInter0Clt95
SequenceOfVectors< V, M > * m_subMeanInter0Empirical90
const VectorSpace< V, M > & m_vectorSpace
SequenceOfVectors< V, M > * m_subMeanInter0Mean
SequenceOfVectors< V, M > * m_subMeanInter0Min
ScalarSequence< double > * m_subMeanInter0MonitorPosSeq
const BaseEnvironment & m_env
SequenceOfVectors< V, M > * m_subMeanInter0Max
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanInter0MonitorFree ( )
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2966 of file SequenceOfVectors.C.

2967 {
2970  delete m_subMeanInter0Mean;
2971  m_subMeanInter0Mean = NULL;
2972  delete m_subMeanInter0Clt95;
2973  m_subMeanInter0Clt95 = NULL;
2976  delete m_subMeanInter0Min;
2977  m_subMeanInter0Min = NULL;
2978  delete m_subMeanInter0Max;
2979  m_subMeanInter0Max = NULL;
2980 
2981  return;
2982 }
SequenceOfVectors< V, M > * m_subMeanInter0Clt95
SequenceOfVectors< V, M > * m_subMeanInter0Empirical90
SequenceOfVectors< V, M > * m_subMeanInter0Mean
SequenceOfVectors< V, M > * m_subMeanInter0Min
ScalarSequence< double > * m_subMeanInter0MonitorPosSeq
SequenceOfVectors< V, M > * m_subMeanInter0Max
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanInter0MonitorRun ( unsigned int  currentPosition,
V &  subMeanInter0Mean,
V &  subMeanInter0Clt95,
V &  subMeanInter0Empirical90,
V &  subMeanInter0Min,
V &  subMeanInter0Max 
)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2811 of file SequenceOfVectors.C.

2817 {
2818  V subMeanVec(m_vectorSpace.zeroVector());
2819  this->subMeanExtra(0,
2820  monitorPosition,
2821  subMeanVec);
2822 
2823  subMeanVec.mpiAllReduce(RawValue_MPI_SUM,m_env.inter0Comm(),subMeanInter0Mean);
2824  subMeanInter0Mean /= ((double) m_env.inter0Comm().NumProc());
2825 
2826  V subMeanInter0CltVariance = subMeanVec-subMeanInter0Mean;
2827  subMeanInter0CltVariance *= subMeanInter0CltVariance;
2828  subMeanInter0CltVariance.mpiAllReduce(RawValue_MPI_SUM,m_env.inter0Comm(),subMeanInter0Clt95);
2829  subMeanInter0Clt95 /= ((double) (m_env.inter0Comm().NumProc()-1));
2830  subMeanInter0Clt95 /= ((double) (m_env.inter0Comm().NumProc()-1));
2831  subMeanInter0Clt95.cwSqrt();
2832  subMeanInter0Clt95 *= 3.;
2833 
2834  V subMeanInter0Quantile5(m_vectorSpace.zeroVector());
2835  subMeanVec.mpiAllQuantile(.05,m_env.inter0Comm(),subMeanInter0Quantile5);
2836  V subMeanInter0Quantile95(m_vectorSpace.zeroVector());
2837  subMeanVec.mpiAllQuantile(.95,m_env.inter0Comm(),subMeanInter0Quantile95);
2838  subMeanInter0Empirical90 = subMeanInter0Quantile95 - subMeanInter0Quantile5;
2839 
2840  subMeanVec.mpiAllReduce(RawValue_MPI_MIN,m_env.inter0Comm(),subMeanInter0Min);
2841 
2842  subMeanVec.mpiAllReduce(RawValue_MPI_MAX,m_env.inter0Comm(),subMeanInter0Max);
2843 
2844  return;
2845 }
const MpiComm & inter0Comm() const
Access function for MpiComm communicator for processes with subRank() 0.
Definition: Environment.C:313
void subMeanExtra(unsigned int initialPos, unsigned int numPos, V &meanVec) const
Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPo...
const VectorSpace< V, M > & m_vectorSpace
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:133
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanInter0MonitorStore ( unsigned int  i,
unsigned int  monitorPosition,
const V &  subMeanInter0Mean,
const V &  subMeanInter0Clt95,
const V &  subMeanInter0Empirical90,
const V &  subMeanInter0Min,
const V &  subMeanInter0Max 
)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2880 of file SequenceOfVectors.C.

2887 {
2888  (*m_subMeanInter0MonitorPosSeq)[i] = monitorPosition;
2889  m_subMeanInter0Mean->setPositionValues(i,subMeanInter0Mean);
2890  m_subMeanInter0Clt95->setPositionValues(i,subMeanInter0Clt95);
2891  m_subMeanInter0Empirical90->setPositionValues(i,subMeanInter0Empirical90);
2892  m_subMeanInter0Min->setPositionValues(i,subMeanInter0Min);
2893  m_subMeanInter0Max->setPositionValues(i,subMeanInter0Max);
2894 
2895  return;
2896 }
SequenceOfVectors< V, M > * m_subMeanInter0Clt95
SequenceOfVectors< V, M > * m_subMeanInter0Empirical90
SequenceOfVectors< V, M > * m_subMeanInter0Mean
SequenceOfVectors< V, M > * m_subMeanInter0Min
SequenceOfVectors< V, M > * m_subMeanInter0Max
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanInter0MonitorWrite ( std::ofstream &  ofs)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2925 of file SequenceOfVectors.C.

2926 {
2927  m_subMeanInter0MonitorPosSeq->subWriteContents(0,m_subMeanInter0MonitorPosSeq->subSequenceSize(),ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2928  m_subMeanInter0Mean->subWriteContents (0,m_subMeanInter0Mean->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2929  m_subMeanInter0Clt95->subWriteContents (0,m_subMeanInter0Clt95->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2930  m_subMeanInter0Empirical90->subWriteContents (0,m_subMeanInter0Empirical90->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2931  m_subMeanInter0Min->subWriteContents (0,m_subMeanInter0Min->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2932  m_subMeanInter0Max->subWriteContents (0,m_subMeanInter0Max->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2933 
2934  return;
2935 }
SequenceOfVectors< V, M > * m_subMeanInter0Clt95
SequenceOfVectors< V, M > * m_subMeanInter0Empirical90
SequenceOfVectors< V, M > * m_subMeanInter0Mean
SequenceOfVectors< V, M > * m_subMeanInter0Min
ScalarSequence< double > * m_subMeanInter0MonitorPosSeq
void subWriteContents(unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
Writes the sub-sequence to a file.
unsigned int subSequenceSize() const
Size of the sub-sequence of scalars.
SequenceOfVectors< V, M > * m_subMeanInter0Max
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanMonitorAlloc ( unsigned int  numberOfMonitorPositions)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2757 of file SequenceOfVectors.C.

2758 {
2759  m_subMeanMonitorPosSeq = new ScalarSequence<double>(m_env, numberOfMonitorPositions,(m_name+"_subMeanMonitorPosSeq").c_str());
2760  m_subMeanVecSeq = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_subMeanVecSeq").c_str() );
2761  m_subMeanCltStdSeq = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_subMeanCltStdSeq").c_str() );
2762 
2763  return;
2764 }
SequenceOfVectors< V, M > * m_subMeanCltStdSeq
SequenceOfVectors< V, M > * m_subMeanVecSeq
const VectorSpace< V, M > & m_vectorSpace
ScalarSequence< double > * m_subMeanMonitorPosSeq
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanMonitorFree ( )
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2952 of file SequenceOfVectors.C.

2953 {
2954  delete m_subMeanMonitorPosSeq;
2955  m_subMeanMonitorPosSeq = NULL;
2956  delete m_subMeanVecSeq;
2957  m_subMeanVecSeq = NULL;
2958  delete m_subMeanCltStdSeq;
2959  m_subMeanCltStdSeq = NULL;
2960 
2961  return;
2962 }
SequenceOfVectors< V, M > * m_subMeanCltStdSeq
SequenceOfVectors< V, M > * m_subMeanVecSeq
ScalarSequence< double > * m_subMeanMonitorPosSeq
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanMonitorRun ( unsigned int  monitorPosition,
V &  subMeanVec,
V &  subMeanCltStd 
)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2793 of file SequenceOfVectors.C.

2796 {
2797  this->subMeanExtra(0,
2798  monitorPosition,
2799  subMeanVec);
2800 
2801  this->subMeanCltStd(0,
2802  monitorPosition,
2803  subMeanVec,
2804  subMeanCltStd);
2805 
2806  return;
2807 }
void subMeanCltStd(unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const
void subMeanExtra(unsigned int initialPos, unsigned int numPos, V &meanVec) const
Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPo...
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanMonitorStore ( unsigned int  i,
unsigned int  monitorPosition,
const V &  subMeanVec,
const V &  subMeanCltStd 
)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2866 of file SequenceOfVectors.C.

2870 {
2871  (*m_subMeanMonitorPosSeq)[i] = monitorPosition;
2872  m_subMeanVecSeq->setPositionValues(i,subMeanVec);
2873  m_subMeanCltStdSeq->setPositionValues(i,subMeanCltStd);
2874 
2875  return;
2876 }
void subMeanCltStd(unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const
SequenceOfVectors< V, M > * m_subMeanCltStdSeq
SequenceOfVectors< V, M > * m_subMeanVecSeq
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMeanMonitorWrite ( std::ofstream &  ofs)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2914 of file SequenceOfVectors.C.

2915 {
2916  m_subMeanMonitorPosSeq->subWriteContents(0,m_subMeanMonitorPosSeq->subSequenceSize(),ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2917  m_subMeanVecSeq->subWriteContents (0,m_subMeanVecSeq->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2918  m_subMeanCltStdSeq->subWriteContents (0,m_subMeanCltStdSeq->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m"
2919 
2920  return;
2921 }
SequenceOfVectors< V, M > * m_subMeanCltStdSeq
SequenceOfVectors< V, M > * m_subMeanVecSeq
void subWriteContents(unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
Writes the sub-sequence to a file.
ScalarSequence< double > * m_subMeanMonitorPosSeq
unsigned int subSequenceSize() const
Size of the sub-sequence of scalars.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMedianExtra ( unsigned int  initialPos,
unsigned int  numPos,
V &  medianVec 
) const
virtual

Finds the median value of the sub-sequence, considering numPos positions starting at position initialPos.

Output:

Parameters
medianVecis the vector of the calculated medians of the sub-sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 422 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subMedianExtra().

426 {
427  if (this->subSequenceSize() == 0) return;
428 
429  bool bRC = ((initialPos < this->subSequenceSize()) &&
430  (0 < numPos ) &&
431  ((initialPos+numPos) <= this->subSequenceSize()));
432  if (bRC == false) {
433  std::cerr << "In SequenceOfVectors<V,M>::subMedianExtra()"
434  << ": ERROR at fullRank " << m_env.fullRank()
435  << ", initialPos = " << initialPos
436  << ", numPos = " << numPos
437  << ", this->subSequenceSize() = " << this->subSequenceSize()
438  << std::endl;
439  if (m_env.subDisplayFile()) {
440  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::subMedianExtra()"
441  << ": ERROR at fullRank " << m_env.fullRank()
442  << ", initialPos = " << initialPos
443  << ", numPos = " << numPos
444  << ", this->subSequenceSize() = " << this->subSequenceSize()
445  << std::endl;
446  }
447  }
448  queso_require_msg(bRC, "invalid input data");
449 
450  ScalarSequence<double> data(m_env,0,"");
451 
452  unsigned int numParams = this->vectorSizeLocal();
453  for (unsigned int i = 0; i < numParams; ++i) {
454  this->extractScalarSeq(initialPos,
455  1, // spacing
456  numPos,
457  i,
458  data);
459  medianVec[i] = data.subMedianExtra(0,
460  numPos);
461  }
462 
463  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
464  *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::subMedianExtra()"
465  << ": initialPos = " << initialPos
466  << ", numPos = " << numPos
467  << ", sub sequence size = " << this->subSequenceSize()
468  << ", medianVec = " << medianVec
469  << std::endl;
470  }
471 
472  return;
473 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
int fullRank() const
Returns the rank of the MPI process in QUESO&#39;s full communicator.
Definition: Environment.C:268
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int displayVerbosity() const
Definition: Environment.C:450
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subMinMaxExtra ( unsigned int  initialPos,
unsigned int  numPos,
V &  minVec,
V &  maxVec 
) const
virtual

Finds the minimum and the maximum values of the sub-sequence, considering numPos positions starting at position initialPos.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 892 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subMinMaxExtra().

897 {
898  bool bRC = ((0 < numPos ) &&
899  ((initialPos+numPos) <= this->subSequenceSize()) &&
900  (this->vectorSizeLocal() == minVec.sizeLocal() ) &&
901  (this->vectorSizeLocal() == maxVec.sizeLocal() ));
902  queso_require_msg(bRC, "invalid input data");
903 
904  //unsigned int numPos = this->subSequenceSize() - initialPos;
905  unsigned int numParams = this->vectorSizeLocal();
906  ScalarSequence<double> data(m_env,0,"");
907 
908  for (unsigned int i = 0; i < numParams; ++i) {
909  this->extractScalarSeq(initialPos,
910  1, // spacing
911  numPos,
912  i,
913  data);
914  data.subMinMaxExtra(0,numPos,minVec[i],maxVec[i]);
915  }
916 
917  return;
918 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subPopulationVariance ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
V &  popVec 
) const
virtual

Finds the population variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec.

Output:

Parameters
popVecis the vector of the calculated population variance of the sub-sequence of vectors. The population variance \( \sigma^2 \) is defined by \( \sigma^2 = \frac{1}{n-1} \sum_{i=1}^n \left(y_i - \mu \right)^2 \), where \( \mu \) is the sample mean and \( n \) is the sample size. This procedure lets the users choose the initial position and the number of elements of the sequence which will be used to evaluate the population variance .

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 666 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subPopulationVariance().

671 {
672  bool bRC = ((initialPos < this->subSequenceSize()) &&
673  (0 < numPos ) &&
674  ((initialPos+numPos) <= this->subSequenceSize()) &&
675  (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
676  (this->vectorSizeLocal() == popVec.sizeLocal() ));
677  queso_require_msg(bRC, "invalid input data");
678 
679  ScalarSequence<double> data(m_env,0,"");
680 
681  unsigned int numParams = this->vectorSizeLocal();
682  for (unsigned int i = 0; i < numParams; ++i) {
683  this->extractScalarSeq(initialPos,
684  1, // spacing
685  numPos,
686  i,
687  data);
688  popVec[i] = data.subPopulationVariance(0,
689  numPos,
690  meanVec[i]);
691  }
692 
693  return;
694 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subSampleStd ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
V &  stdVec 
) const

Finds the sample standard deviation of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec.

Output:

Parameters
stdVecis the vector of the calculated sample standard deviation of the sub-sequence of vectors.

Definition at line 601 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subSampleStd().

606 {
607  bool bRC = ((initialPos < this->subSequenceSize()) &&
608  (0 < numPos ) &&
609  ((initialPos+numPos) <= this->subSequenceSize()) &&
610  (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
611  (this->vectorSizeLocal() == stdvec.sizeLocal() ));
612  queso_require_msg(bRC, "invalid input data");
613 
614  ScalarSequence<double> data(m_env,0,"");
615 
616  unsigned int numParams = this->vectorSizeLocal();
617  for (unsigned int i = 0; i < numParams; ++i) {
618  this->extractScalarSeq(initialPos,
619  1, // spacing
620  numPos,
621  i,
622  data);
623  stdvec[i] = data.subSampleStd(0,
624  numPos,
625  meanVec[i]);
626  }
627 
628  return;
629 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subSampleVarianceExtra ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
V &  samVec 
) const
virtual

Finds the sample variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec.

Output:

Parameters
samVecis the vector of the calculated sample variance of the sub-sequence of vectors. The sample variance \( \sigma_y^2 \) is the second sample central moment and is defined by \( \sigma_y^2 = \frac{1}{n} \sum_{i=1}^n \left(y_i - \mu \right)^2 \), where \( \mu \) is the sample mean and \( n \) is the sample size. This procedure lets the users choose the initial position and the number of elements of the sequence which will be used to evaluate the sample variance.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 536 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subSampleVarianceExtra().

541 {
542  bool bRC = ((initialPos < this->subSequenceSize()) &&
543  (0 < numPos ) &&
544  ((initialPos+numPos) <= this->subSequenceSize()) &&
545  (this->vectorSizeLocal() == meanVec.sizeLocal() ) &&
546  (this->vectorSizeLocal() == samVec.sizeLocal() ));
547  queso_require_msg(bRC, "invalid input data");
548 
549  ScalarSequence<double> data(m_env,0,"");
550 
551  unsigned int numParams = this->vectorSizeLocal();
552  for (unsigned int i = 0; i < numParams; ++i) {
553  this->extractScalarSeq(initialPos,
554  1, // spacing
555  numPos,
556  i,
557  data);
558  samVec[i] = data.subSampleVarianceExtra(0,
559  numPos,
560  meanVec[i]);
561  }
562 
563  return;
564 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subScalesForKde ( unsigned int  initialPos,
const V &  iqrVec,
unsigned int  kdeDimension,
V &  scaleVec 
) const
virtual

Selects the scales (bandwidth, scaleVec) for the kernel density estimation, considering only the sub-sequence.

The bandwidth of the kernel is a free parameter which exhibits a strong influence on the resulting estimate. Silverman (1986) suggests the following normal-based estimates: S1 = 1.06 × (standard deviation) × n^{-1/5} S2 = 0.79 × (iqrVec) × n^{-1/5}, where iqrVec is the interquartile range scaleVec = 0.90 × minimum(standard deviation, iqrVec /1.34) × n^{-1/5}. These estimates are popular due to their simplicity, and are used in QUESO with the adaptation of the exponent oven the sample size n (-1/5) with -1/(4 + kdeDimension) where kdeDimension is the KDE dimension.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1102 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::subScaleForKde().

1107 {
1108  bool bRC = ((initialPos < this->subSequenceSize()) &&
1109  (this->vectorSizeLocal() == iqrVec.sizeLocal() ) &&
1110  (this->vectorSizeLocal() == scaleVec.sizeLocal() ));
1111  queso_require_msg(bRC, "invalid input data");
1112 
1113  unsigned int numPos = this->subSequenceSize() - initialPos;
1114  ScalarSequence<double> data(m_env,0,"");
1115 
1116  unsigned int numParams = this->vectorSizeLocal();
1117  for (unsigned int i = 0; i < numParams; ++i) {
1118  this->extractScalarSeq(initialPos,
1119  1, // spacing
1120  numPos,
1121  i,
1122  data);
1123  scaleVec[i] = data.subScaleForKde(0,
1124  iqrVec[i],
1125  kdeDimension);
1126  }
1127 
1128  return;
1129 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subUniformlySampledCdf ( const V &  numEvaluationPointsVec,
ArrayOfOneDGrids< V, M > &  cdfGrids,
ArrayOfOneDTables< V, M > &  cdfValues 
) const
virtual

Uniformly samples from the CDF from the sub-sequence.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 227 of file SequenceOfVectors.C.

References QUESO::ArrayOfOneDTables< V, M >::setOneDTable(), and QUESO::ArrayOfOneDGrids< V, M >::setUniformGrids().

Referenced by QUESO::StatisticalForwardProblem< P_V, P_M, Q_V, Q_M >::solveWithMonteCarlo().

231 {
232  V minDomainValues(m_vectorSpace.zeroVector());
233  V maxDomainValues(m_vectorSpace.zeroVector());
234 
235  ScalarSequence<double> data(m_env,0,"");
236 
237  unsigned int numParams = this->vectorSizeLocal();
238  for (unsigned int i = 0; i < numParams; ++i) {
239  this->extractScalarSeq(0, // initialPos
240  1, // spacing
241  subSequenceSize(), // numPos
242  i,
243  data);
244 
245  std::vector<double> aCdf(0);
246  data.subUniformlySampledCdf((unsigned int) numEvaluationPointsVec[i],
247  minDomainValues[i],
248  maxDomainValues[i],
249  aCdf);
250  cdfValues.setOneDTable(i,aCdf);
251  }
252 
253  cdfGrids.setUniformGrids(numEvaluationPointsVec,
254  minDomainValues,
255  maxDomainValues);
256 
257  return;
258 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subUniformlySampledMdf ( const V &  numEvaluationPointsVec,
ArrayOfOneDGrids< V, M > &  mdfGrids,
ArrayOfOneDTables< V, M > &  mdfValues 
) const
virtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2306 of file SequenceOfVectors.C.

References QUESO::ArrayOfOneDTables< V, M >::setOneDTable(), and QUESO::ArrayOfOneDGrids< V, M >::setUniformGrids().

Referenced by QUESO::StatisticalForwardProblem< P_V, P_M, Q_V, Q_M >::solveWithMonteCarlo().

2310 {
2311  V minDomainValues(m_vectorSpace.zeroVector());
2312  V maxDomainValues(m_vectorSpace.zeroVector());
2313 
2314  ScalarSequence<double> data(m_env,0,"");
2315 
2316  unsigned int numParams = this->vectorSizeLocal();
2317  for (unsigned int i = 0; i < numParams; ++i) {
2318  this->extractScalarSeq(0, // initialPos
2319  1, // spacing
2320  subSequenceSize(), // numPos
2321  i,
2322  data);
2323 
2324  std::vector<double> aMdf(0);
2325  data.subUniformlySampledMdf((unsigned int) numEvaluationPointsVec[i],
2326  minDomainValues[i],
2327  maxDomainValues[i],
2328  aMdf);
2329  mdfValues.setOneDTable(i,aMdf);
2330  }
2331 
2332  mdfGrids.setUniformGrids(numEvaluationPointsVec,
2333  minDomainValues,
2334  maxDomainValues);
2335 
2336  return;
2337 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subWriteContents ( unsigned int  initialPos,
unsigned int  numPos,
const std::string &  fileName,
const std::string &  fileType,
const std::set< unsigned int > &  allowedSubEnvIds 
) const
virtual

Writes the sub-sequence to a file.

Given the allowed sub environments (allowedSubEnvIds) that are allowed to write to file, together with the file name and type (fileName, fileType), it writes the entire sub- sequence to the file. The sum of the initial position of the sequence (initialPos) with the number of positions that will be written (numPos) must equal the size of the sequence. This procedure calls void subWriteContents (unsigned int initialPos, unsigned int numPos, FilePtrSetStruct& filePtrSet, const std::string& fileType).

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1264 of file SequenceOfVectors.C.

1270 {
1271  queso_require_greater_equal_msg(m_env.subRank(), 0, "unexpected subRank");
1272 
1273  FilePtrSetStruct filePtrSet;
1274  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1275  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::subWriteContents()"
1276  << ": about to try to open file '" << fileName << "." << fileType
1277  << "'"
1278  << ", initialPos = " << initialPos
1279  << ", numPos = " << numPos
1280  << std::endl;
1281  }
1282  if (m_env.openOutputFile(fileName,
1283  fileType,
1284  allowedSubEnvIds,
1285  false, // A 'true' causes problems when the user chooses (via options
1286  // in the input file) to use just one file for all outputs.
1287  filePtrSet)) {
1288  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1289  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::subWriteContents()"
1290  << ": successfully opened file '" << fileName << "." << fileType
1291  << "'"
1292  << std::endl;
1293  }
1294  this->subWriteContents(initialPos,
1295  numPos,
1296  filePtrSet,
1297  fileType);
1298  m_env.closeFile(filePtrSet,fileType);
1299  }
1300  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
1301  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::subWriteContents()"
1302  << ": before Barrier()"
1303  << std::endl;
1304  }
1305  m_env.subComm().Barrier();
1306 
1307  return;
1308 }
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
Definition: MpiComm.C:174
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1084
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
const MpiComm & subComm() const
Access function for each sub-environment&#39;s communicator.
Definition: Environment.C:293
void subWriteContents(unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
Writes the sub-sequence to a file.
unsigned int displayVerbosity() const
Definition: Environment.C:450
const BaseEnvironment & m_env
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:521
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subWriteContents ( unsigned int  initialPos,
unsigned int  numPos,
FilePtrSetStruct filePtrSet,
const std::string &  fileType 
) const

Writes the sub-sequence to a file.

Uses additional variable of the type FilePtrSetStruct& to operate on files.

Definition at line 1312 of file SequenceOfVectors.C.

References QUESO::FilePtrSetStruct::h5Var, and QUESO::FilePtrSetStruct::ofsVar.

1317 {
1318  if (fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT ||
1319  fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT) {
1320  queso_require_msg(filePtrSet.ofsVar, "filePtrSet.ofsVar should not be NULL");
1321  this->subWriteContents(initialPos,
1322  numPos,
1323  *filePtrSet.ofsVar,
1324  fileType);
1325  }
1326 #ifdef QUESO_HAS_HDF5
1327  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1328 
1329  // Check the file is still legit
1330  queso_require_greater_equal_msg(
1331  filePtrSet.h5Var,
1332  0,
1333  "filePtrSet.h5Var should not be non-negative");
1334 
1335  // Sanity check extent
1336  queso_require_less_equal_msg(
1337  (initialPos+numPos),
1338  this->subSequenceSize(),
1339  "invalid routine input parameters");
1340 
1341  unsigned int numParams = m_vectorSpace.dimLocal();
1342  unsigned int chainSize = this->subSequenceSize();
1343  hsize_t dims[2] = { chainSize, numParams };
1344 
1345  // Create dataspace
1346  hid_t dataspace_id = H5Screate_simple(2, dims, dims);
1347 
1348  // Sanity check dataspace
1349  queso_require_greater_equal_msg(
1350  dataspace_id,
1351  0,
1352  "error creating dataspace with id: " << dataspace_id);
1353 
1354  // Create dataset
1355  hid_t dataset_id = H5Dcreate(filePtrSet.h5Var,
1356  "data",
1357  H5T_IEEE_F64LE,
1358  dataspace_id,
1359  H5P_DEFAULT,
1360  H5P_DEFAULT,
1361  H5P_DEFAULT);
1362 
1363  // Sanity check dataset
1364  queso_require_greater_equal_msg(
1365  dataset_id,
1366  0,
1367  "error creating dataset with id: " << dataset_id);
1368 
1369  // This is so egregiously awfully badly terribly horrific I want to die.
1370  //
1371  // And, of course, if any of the subsequent H5* sanity check fail we
1372  // throw an exception and leak a metric fuckton of memory.
1373  double * data = (double *)malloc(numParams * chainSize * sizeof(double));
1374 
1375  for (unsigned int i = 0; i < chainSize; i++) {
1376  V tmpVec(*(m_seq[i]));
1377  for (unsigned int j = 0; j < numParams; j++) {
1378  data[numParams*i+j] = tmpVec[j];
1379  }
1380  }
1381 
1382  // Write the dataset
1383  herr_t status = H5Dwrite(
1384  dataset_id,
1385  H5T_NATIVE_DOUBLE, // The type in memory
1386  H5S_ALL, // The dataspace in memory
1387  dataspace_id, // The file dataspace
1388  H5P_DEFAULT, // Xfer property list
1389  data);
1390 
1391  // Sanity check the write
1392  queso_require_greater_equal_msg(
1393  status,
1394  0,
1395  "error writing dataset to file with id: " << filePtrSet.h5Var);
1396 
1397  // Clean up
1398  free(data);
1399  H5Dclose(dataset_id);
1400  H5Sclose(dataspace_id);
1401 
1402  // Should we close the file too? It's unclear.
1403 
1404  }
1405 #endif
1406  else {
1407  queso_error_msg("invalid file type");
1408  }
1409 
1410  return;
1411 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
std::vector< const V * > m_seq
Sequence of vectors.
void subWriteContents(unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
Writes the sub-sequence to a file.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::subWriteContents ( unsigned int  initialPos,
unsigned int  numPos,
std::ofstream &  ofs,
const std::string &  fileType 
) const
virtual

Writes the sub-sequence to a file.

Uses object of the type std::ofstream.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1415 of file SequenceOfVectors.C.

1420 {
1421  queso_require_less_equal_msg((initialPos+numPos), this->subSequenceSize(), "invalid routine input parameters");
1422 
1423  if (initialPos == 0) {
1424  if (fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) {
1425  // Need sub matlab header here since this is subWriteContents
1426  this->writeSubMatlabHeader(ofs,
1427  this->subSequenceSize(),
1428  this->vectorSizeLocal());
1429  }
1430  else if (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT) {
1431  this->writeTxtHeader(ofs,
1432  this->subSequenceSize(),
1433  this->vectorSizeLocal());
1434  }
1435  }
1436 
1437  for (unsigned int j = initialPos; j < initialPos+numPos; ++j) {
1438  bool savedVectorPrintScientific = m_seq[j]->getPrintScientific();
1439  bool savedVectorPrintState = m_seq[j]->getPrintHorizontally();
1440  m_seq[j]->setPrintScientific (true);
1441  m_seq[j]->setPrintHorizontally(true);
1442 
1443  ofs << *(m_seq[j])
1444  << std::endl;
1445 
1446  m_seq[j]->setPrintHorizontally(savedVectorPrintState);
1447  m_seq[j]->setPrintScientific (savedVectorPrintScientific);
1448  }
1449 
1450  // Write Matlab-specific ending if desired
1451  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) &&
1452  ((initialPos + numPos) == this->subSequenceSize())) {
1453  ofs << "];\n";
1454  }
1455 }
void writeSubMatlabHeader(std::ofstream &ofs, double sequenceSize, double vectorSizeLocal) const
Helper function to write matlab-specific header info for vectors.
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
std::vector< const V * > m_seq
Sequence of vectors.
void writeTxtHeader(std::ofstream &ofs, double sequenceSize, double vectorSizeLocal) const
Helper function to write plain txt info for vectors.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedCdfPercentageRange ( unsigned int  initialPos,
unsigned int  numPos,
double  range,
V &  lowerVec,
V &  upperVec 
) const

Definition at line 2618 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedCdfPercentageRange().

2624 {
2625  bool bRC = ((0 < numPos ) &&
2626  ((initialPos+numPos) <= this->subSequenceSize()) &&
2627  (this->vectorSizeLocal() == lowerVec.sizeLocal() ) &&
2628  (this->vectorSizeLocal() == upperVec.sizeLocal() ));
2629  queso_require_msg(bRC, "invalid input data");
2630 
2631  unsigned int numParams = this->vectorSizeLocal();
2632  ScalarSequence<double> data(m_env,0,"");
2633 
2634  for (unsigned int i = 0; i < numParams; ++i) {
2635  this->extractScalarSeq(initialPos,
2636  1, // spacing
2637  numPos,
2638  i,
2639  data);
2640  data.unifiedCdfPercentageRange(m_vectorSpace.numOfProcsForStorage() == 1,
2641  0,
2642  numPos,
2643  range,
2644  lowerVec[i],
2645  upperVec[i]);
2646  }
2647 
2648  return;
2649 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedGaussian1dKde ( unsigned int  initialPos,
const V &  unifiedScaleVec,
const std::vector< V * > &  unifiedEvalParamVecs,
std::vector< V * > &  unifiedDensityVecs 
) const
virtual

Gaussian kernel for the KDE estimate of the unified sequence.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1214 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedGaussian1dKde().

1219 {
1220  bool bRC = ((initialPos < this->subSequenceSize() ) &&
1221  (this->vectorSizeLocal() == unifiedScaleVec.sizeLocal()) &&
1222  (0 < unifiedEvalParamVecs.size()) &&
1223  (unifiedEvalParamVecs.size() == unifiedDensityVecs.size() ));
1224  queso_require_msg(bRC, "invalid input data");
1225 
1226  unsigned int numPos = this->subSequenceSize() - initialPos;
1227  ScalarSequence<double> data(m_env,0,"");
1228 
1229  unsigned int numEvals = unifiedEvalParamVecs.size();
1230  for (unsigned int j = 0; j < numEvals; ++j) {
1231  unifiedDensityVecs[j] = new V(m_vectorSpace.zeroVector());
1232  }
1233  std::vector<double> unifiedEvalParams(numEvals,0.);
1234  std::vector<double> unifiedDensities (numEvals,0.);
1235 
1236  unsigned int numParams = this->vectorSizeLocal();
1237  for (unsigned int i = 0; i < numParams; ++i) {
1238  this->extractScalarSeq(initialPos,
1239  1, // spacing
1240  numPos,
1241  i,
1242  data);
1243 
1244  for (unsigned int j = 0; j < numEvals; ++j) {
1245  unifiedEvalParams[j] = (*unifiedEvalParamVecs[j])[i];
1246  }
1247 
1248  data.unifiedGaussian1dKde(m_vectorSpace.numOfProcsForStorage() == 1,
1249  0,
1250  unifiedScaleVec[i],
1251  unifiedEvalParams,
1252  unifiedDensities);
1253 
1254  for (unsigned int j = 0; j < numEvals; ++j) {
1255  (*unifiedDensityVecs[j])[i] = unifiedDensities[j];
1256  }
1257  }
1258 
1259  return;
1260 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedHistogram ( unsigned int  initialPos,
const V &  unifiedMinVec,
const V &  unifiedMaxVec,
std::vector< V * > &  unifiedCentersForAllBins,
std::vector< V * > &  unifiedQuanttsForAllBins 
) const
virtual

Calculates the histogram of the unified sequence.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1002 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedHistogram().

1008 {
1009  bool bRC = ((initialPos < this->subSequenceSize() ) &&
1010  (this->vectorSizeLocal() == unifiedMinVec.sizeLocal() ) &&
1011  (this->vectorSizeLocal() == unifiedMaxVec.sizeLocal() ) &&
1012  (0 < unifiedCentersForAllBins.size()) &&
1013  (unifiedCentersForAllBins.size() == unifiedQuanttsForAllBins.size()));
1014  queso_require_msg(bRC, "invalid input data");
1015 
1016  for (unsigned int j = 0; j < unifiedQuanttsForAllBins.size(); ++j) {
1017  unifiedCentersForAllBins[j] = new V(m_vectorSpace.zeroVector());
1018  unifiedQuanttsForAllBins [j] = new V(m_vectorSpace.zeroVector());
1019  }
1020 
1021  unsigned int dataSize = this->subSequenceSize() - initialPos;
1022  unsigned int numParams = this->vectorSizeLocal();
1023  for (unsigned int i = 0; i < numParams; ++i) {
1024  ScalarSequence<double> data(m_env,dataSize,"");
1025  for (unsigned int j = 0; j < dataSize; ++j) {
1026  data[j] = (*(m_seq[initialPos+j]))[i];
1027  }
1028 
1029  std::vector<double > unifiedCenters(unifiedCentersForAllBins.size(),0.);
1030  std::vector<unsigned int> unifiedQuantts(unifiedQuanttsForAllBins.size(), 0 );
1031  data.unifiedHistogram(m_vectorSpace.numOfProcsForStorage() == 1,
1032  0,
1033  unifiedMinVec[i],
1034  unifiedMaxVec[i],
1035  unifiedCenters,
1036  unifiedQuantts);
1037 
1038  for (unsigned int j = 0; j < unifiedQuantts.size(); ++j) {
1039  (*(unifiedCentersForAllBins[j]))[i] = unifiedCenters[j];
1040  (*(unifiedQuanttsForAllBins[j]))[i] = (double) unifiedQuantts[j];
1041  }
1042  }
1043 
1044  return;
1045 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
std::vector< const V * > m_seq
Sequence of vectors.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedInterQuantileRange ( unsigned int  initialPos,
V &  unifiedIqrVec 
) const
virtual

Returns the interquartile range of the values in the unified sequence.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1075 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedInterQuantileRange().

1078 {
1079  bool bRC = ((initialPos < this->subSequenceSize() ) &&
1080  (this->vectorSizeLocal() == unifiedIqrVec.sizeLocal()));
1081  queso_require_msg(bRC, "invalid input data");
1082 
1083  unsigned int numPos = this->subSequenceSize() - initialPos;
1084  ScalarSequence<double> data(m_env,0,"");
1085 
1086  unsigned int numParams = this->vectorSizeLocal();
1087  for (unsigned int i = 0; i < numParams; ++i) {
1088  this->extractScalarSeq(initialPos,
1089  1, // spacing
1090  numPos,
1091  i,
1092  data);
1093  unifiedIqrVec[i] = data.unifiedInterQuantileRange(m_vectorSpace.numOfProcsForStorage() == 1,
1094  0);
1095  }
1096 
1097  return;
1098 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMeanCltStd ( unsigned int  initialPos,
unsigned int  numPos,
const V &  unifiedMeanVec,
V &  unifiedSamVec 
) const

Definition at line 2379 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedMeanCltStd().

2384 {
2385  bool bRC = ((initialPos < this->subSequenceSize() ) &&
2386  (0 < numPos ) &&
2387  ((initialPos+numPos) <= this->subSequenceSize() ) &&
2388  (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()) &&
2389  (this->vectorSizeLocal() == unifiedSamVec.sizeLocal() ));
2390  queso_require_msg(bRC, "invalid input data");
2391 
2392  ScalarSequence<double> data(m_env,0,"");
2393 
2394  unsigned int numParams = this->vectorSizeLocal();
2395  for (unsigned int i = 0; i < numParams; ++i) {
2396  this->extractScalarSeq(initialPos,
2397  1, // spacing
2398  numPos,
2399  i,
2400  data);
2401  unifiedSamVec[i] = data.unifiedMeanCltStd(m_vectorSpace.numOfProcsForStorage() == 1,
2402  0,
2403  numPos,
2404  unifiedMeanVec[i]);
2405  }
2406 
2407  return;
2408 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMeanExtra ( unsigned int  initialPos,
unsigned int  numPos,
V &  unifiedMeanVec 
) const
virtual

Finds the mean value of the unified sequence, considering numPos positions starting at position initialPos.

Output:

Parameters
meanVecis the vector of the calculated means of the unified sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 363 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedMeanExtra().

367 {
368  unsigned int tmpUnif = this->unifiedSequenceSize();
369  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
370  *m_env.subDisplayFile() << "Entering SequenceOfVectors<V,M>::unifiedMeanExtra()"
371  << ": initialPos = " << initialPos
372  << ", numPos = " << numPos
373  << ", sub sequence size = " << this->subSequenceSize()
374  << ", unified sequence size = " << tmpUnif
375  << std::endl;
376  }
377 
378  bool bRC = ((initialPos < this->subSequenceSize() ) &&
379  (0 < numPos ) &&
380  ((initialPos+numPos) <= this->subSequenceSize() ) &&
381  (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()));
382  if ((bRC == false) && (m_env.subDisplayFile())) {
383  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedMeanExtra()"
384  << ", initialPos = " << initialPos
385  << ", this->subSequenceSize() = " << this->subSequenceSize()
386  << ", numPos = " << numPos
387  << ", this->vectorSizeLocal() = " << this->vectorSizeLocal()
388  << ", unifiedMeanVec.sizeLocal() = " << unifiedMeanVec.sizeLocal()
389  << std::endl;
390  }
391  queso_require_msg(bRC, "invalid input data");
392 
393  ScalarSequence<double> data(m_env,0,"");
394 
395  unsigned int numParams = this->vectorSizeLocal();
396  for (unsigned int i = 0; i < numParams; ++i) {
397  this->extractScalarSeq(initialPos,
398  1, // spacing
399  numPos,
400  i,
401  data);
402  unifiedMeanVec[i] = data.unifiedMeanExtra(m_vectorSpace.numOfProcsForStorage() == 1,
403  0,
404  numPos);
405  }
406 
407  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
408  *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::unifiedMeanExtra()"
409  << ": initialPos = " << initialPos
410  << ", numPos = " << numPos
411  << ", sub sequence size = " << this->subSequenceSize()
412  << ", unified sequence size = " << tmpUnif
413  << ", unifiedMeanVec = " << unifiedMeanVec
414  << std::endl;
415  }
416 
417  return;
418 }
unsigned int unifiedSequenceSize() const
Calculates the size of the unified sequence of vectors.
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int displayVerbosity() const
Definition: Environment.C:450
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMeanMonitorAlloc ( unsigned int  numberOfMonitorPositions)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2782 of file SequenceOfVectors.C.

2783 {
2784  m_unifiedMeanMonitorPosSeq = new ScalarSequence<double>(m_env, numberOfMonitorPositions,(m_name+"_unifiedMeanMonitorPosSeq").c_str());
2785  m_unifiedMeanVecSeq = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_unifiedMeanVecSeq").c_str() );
2786  m_unifiedMeanCltStdSeq = new SequenceOfVectors<V,M>(m_vectorSpace,numberOfMonitorPositions,(m_name+"_unifiedMeanCltStdSeq").c_str() );
2787 
2788  return;
2789 }
SequenceOfVectors< V, M > * m_unifiedMeanVecSeq
const VectorSpace< V, M > & m_vectorSpace
SequenceOfVectors< V, M > * m_unifiedMeanCltStdSeq
const BaseEnvironment & m_env
ScalarSequence< double > * m_unifiedMeanMonitorPosSeq
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMeanMonitorFree ( )
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2986 of file SequenceOfVectors.C.

2987 {
2990  delete m_unifiedMeanVecSeq;
2991  m_unifiedMeanVecSeq = NULL;
2992  delete m_unifiedMeanCltStdSeq;
2993  m_unifiedMeanCltStdSeq = NULL;
2994 
2995  return;
2996 }
SequenceOfVectors< V, M > * m_unifiedMeanVecSeq
SequenceOfVectors< V, M > * m_unifiedMeanCltStdSeq
ScalarSequence< double > * m_unifiedMeanMonitorPosSeq
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMeanMonitorRun ( unsigned int  currentPosition,
V &  unifiedMeanVec,
V &  unifiedMeanCltStd 
)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2849 of file SequenceOfVectors.C.

2852 {
2853  this->unifiedMeanExtra(0,
2854  monitorPosition,
2855  unifiedMeanVec);
2856 
2857  this->unifiedMeanCltStd(0,
2858  monitorPosition,
2859  unifiedMeanVec,
2861  return;
2862 }
void unifiedMeanCltStd(unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedSamVec) const
void unifiedMeanExtra(unsigned int initialPos, unsigned int numPos, V &unifiedMeanVec) const
Finds the mean value of the unified sequence, considering numPos positions starting at position initi...
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMeanMonitorStore ( unsigned int  i,
unsigned int  monitorPosition,
V &  unifiedMeanVec,
V &  unifiedMeanCltStd 
)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2900 of file SequenceOfVectors.C.

2904 {
2905  (*m_unifiedMeanMonitorPosSeq)[i] = monitorPosition;
2906  m_unifiedMeanVecSeq->setPositionValues(i,unifiedMeanVec);
2907  m_unifiedMeanCltStdSeq->setPositionValues(i,unifiedMeanCltStd);
2908 
2909  return;
2910 }
void unifiedMeanCltStd(unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedSamVec) const
SequenceOfVectors< V, M > * m_unifiedMeanVecSeq
SequenceOfVectors< V, M > * m_unifiedMeanCltStdSeq
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMeanMonitorWrite ( std::ofstream &  ofs)
privatevirtual

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 2939 of file SequenceOfVectors.C.

2940 {
2941  // std::set<unsigned int> tmpSet;
2942  // tmpSet.insert(0);
2943  m_unifiedMeanMonitorPosSeq->subWriteContents(0,m_unifiedMeanMonitorPosSeq->subSequenceSize(),ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m" // Yes, 'subWriteContents()'
2944  m_unifiedMeanVecSeq->subWriteContents (0,m_unifiedMeanVecSeq->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m" // Yes, 'subWriteContents()'
2945  m_unifiedMeanCltStdSeq->subWriteContents (0,m_unifiedMeanCltStdSeq->subSequenceSize(), ofs,UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT); // Yes, always ".m" // Yes, 'subWriteContents()'
2946 
2947  return;
2948 }
SequenceOfVectors< V, M > * m_unifiedMeanVecSeq
void subWriteContents(unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const
Writes the sub-sequence to a file.
SequenceOfVectors< V, M > * m_unifiedMeanCltStdSeq
ScalarSequence< double > * m_unifiedMeanMonitorPosSeq
unsigned int subSequenceSize() const
Size of the sub-sequence of scalars.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMedianExtra ( unsigned int  initialPos,
unsigned int  numPos,
V &  unifiedMedianVec 
) const
virtual

Finds the median value of the unfed sequence, considering numPos positions starting at position initialPos.

Output:

Parameters
medianVecis the vector of the calculated medians of the unified sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 477 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedMedianExtra().

481 {
482  unsigned int tmpUnif = this->unifiedSequenceSize();
483  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
484  *m_env.subDisplayFile() << "Entering SequenceOfVectors<V,M>::unifiedMedianExtra()"
485  << ": initialPos = " << initialPos
486  << ", numPos = " << numPos
487  << ", sub sequence size = " << this->subSequenceSize()
488  << ", unified sequence size = " << tmpUnif
489  << std::endl;
490  }
491 
492  bool bRC = ((initialPos < this->subSequenceSize() ) &&
493  (0 < numPos ) &&
494  ((initialPos+numPos) <= this->subSequenceSize() ) &&
495  (this->vectorSizeLocal() == unifiedMedianVec.sizeLocal()));
496  if ((bRC == false) && (m_env.subDisplayFile())) {
497  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedMedianExtra()"
498  << ", initialPos = " << initialPos
499  << ", this->subSequenceSize() = " << this->subSequenceSize()
500  << ", numPos = " << numPos
501  << ", this->vectorSizeLocal() = " << this->vectorSizeLocal()
502  << ", unifiedMedianVec.sizeLocal() = " << unifiedMedianVec.sizeLocal()
503  << std::endl;
504  }
505  queso_require_msg(bRC, "invalid input data");
506 
507  ScalarSequence<double> data(m_env,0,"");
508 
509  unsigned int numParams = this->vectorSizeLocal();
510  for (unsigned int i = 0; i < numParams; ++i) {
511  this->extractScalarSeq(initialPos,
512  1, // spacing
513  numPos,
514  i,
515  data);
516  unifiedMedianVec[i] = data.unifiedMedianExtra(m_vectorSpace.numOfProcsForStorage() == 1,
517  0,
518  numPos);
519  }
520 
521  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
522  *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::unifiedMedianExtra()"
523  << ": initialPos = " << initialPos
524  << ", numPos = " << numPos
525  << ", sub sequence size = " << this->subSequenceSize()
526  << ", unified sequence size = " << tmpUnif
527  << ", unifiedMedianVec = " << unifiedMedianVec
528  << std::endl;
529  }
530 
531  return;
532 }
unsigned int unifiedSequenceSize() const
Calculates the size of the unified sequence of vectors.
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int displayVerbosity() const
Definition: Environment.C:450
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedMinMaxExtra ( unsigned int  initialPos,
unsigned int  numPos,
V &  unifiedMinVec,
V &  unifiedMaxVec 
) const
virtual

Finds the minimum and the maximum values of the unified sequence, considering numPos positions starting at position initialPos.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 922 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedMinMaxExtra().

927 {
928  bool bRC = ((0 < numPos ) &&
929  ((initialPos+numPos) <= this->subSequenceSize() ) &&
930  (this->vectorSizeLocal() == unifiedMinVec.sizeLocal()) &&
931  (this->vectorSizeLocal() == unifiedMaxVec.sizeLocal()));
932  queso_require_msg(bRC, "invalid input data");
933 
934  //unsigned int numPos = this->subSequenceSize() - initialPos;
935  unsigned int numParams = this->vectorSizeLocal();
936  ScalarSequence<double> data(m_env,0,"");
937 
938  for (unsigned int i = 0; i < numParams; ++i) {
939  this->extractScalarSeq(initialPos,
940  1, // spacing
941  numPos,
942  i,
943  data);
944  data.unifiedMinMaxExtra(m_vectorSpace.numOfProcsForStorage() == 1,
945  0,
946  numPos,
947  unifiedMinVec[i],
948  unifiedMaxVec[i]);
949  }
950 
951  return;
952 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedPopulationVariance ( unsigned int  initialPos,
unsigned int  numPos,
const V &  unifiedMeanVec,
V &  unifiedPopVec 
) const
virtual

Finds the population variance of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec.

Output:

Parameters
popVecis the vector of the calculated population variance of the unified sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 698 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedPopulationVariance().

703 {
704  bool bRC = ((initialPos < this->subSequenceSize() ) &&
705  (0 < numPos ) &&
706  ((initialPos+numPos) <= this->subSequenceSize() ) &&
707  (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()) &&
708  (this->vectorSizeLocal() == unifiedPopVec.sizeLocal() ));
709  queso_require_msg(bRC, "invalid input data");
710 
711  ScalarSequence<double> data(m_env,0,"");
712 
713  unsigned int numParams = this->vectorSizeLocal();
714  for (unsigned int i = 0; i < numParams; ++i) {
715  this->extractScalarSeq(initialPos,
716  1, // spacing
717  numPos,
718  i,
719  data);
720  unifiedPopVec[i] = data.unifiedPopulationVariance(m_vectorSpace.numOfProcsForStorage() == 1,
721  0,
722  numPos,
723  unifiedMeanVec[i]);
724  }
725 
726  return;
727 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedReadContents ( const std::string &  fileName,
const std::string &  fileType,
const unsigned int  subSequenceSize 
)
virtual

Reads the unified sequence from a file.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1763 of file SequenceOfVectors.C.

References QUESO::FilePtrSetStruct::h5Var, QUESO::FilePtrSetStruct::ifsVar, QUESO::MiscGetEllapsedSeconds(), QUESO::queso_require_equal_to_msg, and QUESO::UQ_OK_RC.

Referenced by QUESO::MLSampling< P_V, P_M >::restartML().

1767 {
1768  std::string fileType(inputFileType);
1769 #ifdef QUESO_HAS_HDF5
1770  // Do nothing
1771 #else
1772  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1773  if (m_env.subDisplayFile()) {
1774  *m_env.subDisplayFile() << "WARNING in SequenceOfVectors<V,M>::unifiedReadContents()"
1775  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1776  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1777  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1778  << "' instead..."
1779  << std::endl;
1780  }
1781  if (m_env.subRank() == 0) {
1782  std::cerr << "WARNING in SequenceOfVectors<V,M>::unifiedReadContents()"
1783  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1784  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1785  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1786  << "' instead..."
1787  << std::endl;
1788  }
1789  fileType = UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT;
1790  }
1791 #endif
1792 
1793  //m_env.fullComm().Barrier(); // Dangerous to barrier on fullComm ...
1794  if (m_env.subDisplayFile()) {
1795  *m_env.subDisplayFile() << "Entering SequenceOfVectors<V,M>::unifiedReadContents()"
1796  << ": worldRank " << m_env.worldRank()
1797  << ", fullRank " << m_env.fullRank()
1798  << ", subEnvironment " << m_env.subId()
1799  << ", subRank " << m_env.subRank()
1800  << ", inter0Rank " << m_env.inter0Rank()
1801  //<< ", m_env.inter0Comm().NumProc() = " << m_env.inter0Comm().NumProc()
1802  << ", fileName = " << fileName
1803  << ", subReadSize = " << subReadSize
1804  //<< ", unifiedReadSize = " << unifiedReadSize
1805  << std::endl;
1806  }
1807 
1808  this->resizeSequence(subReadSize);
1809 
1810  if (m_env.inter0Rank() >= 0) {
1811  double unifiedReadSize = subReadSize*m_env.inter0Comm().NumProc();
1812 
1813  // In the logic below, the id of a line' begins with value 0 (zero)
1814  unsigned int idOfMyFirstLine = 1 + m_env.inter0Rank()*subReadSize;
1815  unsigned int idOfMyLastLine = (1 + m_env.inter0Rank())*subReadSize;
1816  unsigned int numParams = this->vectorSizeLocal();
1817 
1818  for (unsigned int r = 0; r < (unsigned int) m_env.inter0Comm().NumProc(); ++r) { // "m or hdf"
1819  if (m_env.inter0Rank() == (int) r) {
1820  // My turn
1821  FilePtrSetStruct unifiedFilePtrSet;
1822  if (m_env.openUnifiedInputFile(fileName,
1823  fileType,
1824  unifiedFilePtrSet)) {
1825  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
1826  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
1827  if (r == 0) {
1828  // Read number of chain positions in the file by taking care of the first line,
1829  // which resembles something like 'variable_name = zeros(n_positions,m_params);'
1830  std::string tmpString;
1831 
1832  // Read 'variable name' string
1833  *unifiedFilePtrSet.ifsVar >> tmpString;
1834  //std::cout << "Just read '" << tmpString << "'" << std::endl;
1835 
1836  // Read '=' sign
1837  *unifiedFilePtrSet.ifsVar >> tmpString;
1838  //std::cout << "Just read '" << tmpString << "'" << std::endl;
1839  queso_require_equal_to_msg(tmpString, std::string("="), std::string("string should be the '=' sign"));
1840 
1841  // Read 'zeros(n_positions,n_params)' string
1842  *unifiedFilePtrSet.ifsVar >> tmpString;
1843  //std::cout << "Just read '" << tmpString << "'" << std::endl;
1844  unsigned int posInTmpString = 6;
1845 
1846  // Isolate 'n_positions' in a string
1847  //char nPositionsString[tmpString.size()-posInTmpString+1]; // avoid compiler warning
1848  std::string nPositionsString((size_t) (tmpString.size()-posInTmpString+1),' ');
1849  unsigned int posInPositionsString = 0;
1850  do {
1851  queso_require_less_msg(posInTmpString, tmpString.size(), "symbol ',' not found in first line of file");
1852  nPositionsString[posInPositionsString++] = tmpString[posInTmpString++];
1853  } while (tmpString[posInTmpString] != ',');
1854  nPositionsString[posInPositionsString] = '\0';
1855 
1856  // Isolate 'n_params' in a string
1857  posInTmpString++; // Avoid reading ',' char
1858  //char nParamsString[tmpString.size()-posInTmpString+1]; // avoid compiler warning
1859  std::string nParamsString((size_t) (tmpString.size()-posInTmpString+1),' ');
1860  unsigned int posInParamsString = 0;
1861  do {
1862  queso_require_less_msg(posInTmpString, tmpString.size(), "symbol ')' not found in first line of file");
1863  nParamsString[posInParamsString++] = tmpString[posInTmpString++];
1864  } while (tmpString[posInTmpString] != ')');
1865  nParamsString[posInParamsString] = '\0';
1866 
1867  // Convert 'n_positions' and 'n_params' strings to numbers
1868  unsigned int sizeOfChainInFile = (unsigned int) strtod(nPositionsString.c_str(),NULL);
1869  unsigned int numParamsInFile = (unsigned int) strtod(nParamsString.c_str(), NULL);
1870  if (m_env.subDisplayFile()) {
1871  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedReadContents()"
1872  << ": worldRank " << m_env.worldRank()
1873  << ", fullRank " << m_env.fullRank()
1874  << ", sizeOfChainInFile = " << sizeOfChainInFile
1875  << ", numParamsInFile = " << numParamsInFile
1876  << std::endl;
1877  }
1878 
1879  // Check if [size of chain in file] >= [requested unified sequence size]
1880  queso_require_greater_equal_msg(sizeOfChainInFile, unifiedReadSize, "size of chain in file is not big enough");
1881 
1882  // Check if [num params in file] == [num params in current chain]
1883  queso_require_equal_to_msg(numParamsInFile, numParams, "number of parameters of chain in file is different than number of parameters in this chain object");
1884  } // if (r == 0)
1885 
1886  // Code common to any core in 'inter0Comm', including core of rank 0
1887  unsigned int maxCharsPerLine = 64*numParams; // Up to about 60 characters to represent each parameter value
1888 
1889  unsigned int lineId = 0;
1890  while (lineId < idOfMyFirstLine) {
1891  unifiedFilePtrSet.ifsVar->ignore(maxCharsPerLine,'\n');
1892  lineId++;
1893  };
1894 
1895  if (r == 0) {
1896  // Take care of initial part of the first data line,
1897  // which resembles something like 'variable_name = [value1 value2 ...'
1898  std::string tmpString;
1899 
1900  // Read 'variable name' string
1901  *unifiedFilePtrSet.ifsVar >> tmpString;
1902  //std::cout << "Core 0 just read '" << tmpString << "'" << std::endl;
1903 
1904  // Read '=' sign
1905  *unifiedFilePtrSet.ifsVar >> tmpString;
1906  //std::cout << "Core 0 just read '" << tmpString << "'" << std::endl;
1907  queso_require_equal_to_msg(tmpString, std::string("="), std::string("in core 0, string should be the '=' sign"));
1908 
1909  // Take into account the ' [' portion
1910  std::streampos tmpPos = unifiedFilePtrSet.ifsVar->tellg();
1911  unifiedFilePtrSet.ifsVar->seekg(tmpPos+(std::streampos)2);
1912  }
1913 
1914  V tmpVec(m_vectorSpace.zeroVector());
1915  while (lineId <= idOfMyLastLine) {
1916  for (unsigned int i = 0; i < numParams; ++i) {
1917  *unifiedFilePtrSet.ifsVar >> tmpVec[i];
1918  }
1919  this->setPositionValues(lineId - idOfMyFirstLine, tmpVec);
1920  lineId++;
1921  };
1922  }
1923 #ifdef QUESO_HAS_HDF5
1924  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1925  if (r == 0) {
1926  hid_t dataset = H5Dopen2(unifiedFilePtrSet.h5Var,
1927  "data",
1928  H5P_DEFAULT); // Dataset access property list
1929  hid_t datatype = H5Dget_type(dataset);
1930  H5T_class_t t_class = H5Tget_class(datatype);
1931  queso_require_equal_to_msg(t_class, H5T_FLOAT, "t_class is not H5T_DOUBLE");
1932  hid_t dataspace = H5Dget_space(dataset);
1933  int rank = H5Sget_simple_extent_ndims(dataspace);
1934  queso_require_equal_to_msg(rank, 2, "hdf rank is not 2");
1935  hsize_t dims_in[2];
1936  int status_n;
1937  status_n = H5Sget_simple_extent_dims(dataspace, dims_in, NULL);
1938  if (status_n) {}; // just to remover compiler warning
1939  //std::cout << "In SequenceOfVectors<V,M>::unifiedReadContents()"
1940  // << ": dims_in[0] = " << dims_in[0]
1941  // << ", dims_in[1] = " << dims_in[1]
1942  // << std::endl;
1943  queso_require_equal_to_msg(dims_in[0], numParams, "dims_in[0] is not equal to 'numParams'");
1944  queso_require_greater_equal_msg(dims_in[1], subReadSize, "dims_in[1] is smaller that requested 'subReadSize'");
1945 
1946  struct timeval timevalBegin;
1947  int iRC = UQ_OK_RC;
1948  iRC = gettimeofday(&timevalBegin,NULL);
1949  if (iRC) {}; // just to remover compiler warning
1950 
1951  unsigned int chainSizeIn = (unsigned int) dims_in[1];
1952  //double* dataIn[numParams]; // avoid compiler warning
1953  std::vector<double*> dataIn((size_t) numParams,NULL);
1954  dataIn[0] = (double*) malloc(numParams*chainSizeIn*sizeof(double));
1955  for (unsigned int i = 1; i < numParams; ++i) { // Yes, from '1'
1956  dataIn[i] = dataIn[i-1] + chainSizeIn; // Yes, just 'chainSizeIn', not 'chainSizeIn*sizeof(double)'
1957  }
1958  //std::cout << "In SequenceOfVectors<V,M>::unifiedReadContents(): h5 case, memory allocated" << std::endl;
1959  herr_t status;
1960  status = H5Dread(dataset,
1961  H5T_NATIVE_DOUBLE,
1962  H5S_ALL,
1963  dataspace,
1964  H5P_DEFAULT,
1965  dataIn[0]);
1966  if (status) {}; // just to remover compiler warning
1967  //std::cout << "In SequenceOfVectors<V,M>::unifiedReadContents(): h5 case, data read" << std::endl;
1968  V tmpVec(m_vectorSpace.zeroVector());
1969  for (unsigned int j = 0; j < subReadSize; ++j) { // Yes, 'subReadSize', not 'chainSizeIn'
1970  for (unsigned int i = 0; i < numParams; ++i) {
1971  tmpVec[i] = dataIn[i][j];
1972  }
1973  this->setPositionValues(j, tmpVec);
1974  }
1975 
1976  double readTime = MiscGetEllapsedSeconds(&timevalBegin);
1977  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1978  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedReadContents()"
1979  << ": worldRank " << m_env.worldRank()
1980  << ", fullRank " << m_env.fullRank()
1981  << ", subEnvironment " << m_env.subId()
1982  << ", subRank " << m_env.subRank()
1983  << ", inter0Rank " << m_env.inter0Rank()
1984  << ", fileName = " << fileName
1985  << ", numParams = " << numParams
1986  << ", chainSizeIn = " << chainSizeIn
1987  << ", subReadSize = " << subReadSize
1988  << ", readTime = " << readTime << " seconds"
1989  << std::endl;
1990  }
1991 
1992  H5Sclose(dataspace);
1993  H5Tclose(datatype);
1994  H5Dclose(dataset);
1995  //free(dataIn[0]); // related to the changes above for compiler warning
1996  for (unsigned int tmpIndex = 0; tmpIndex < dataIn.size(); tmpIndex++) {
1997  free (dataIn[tmpIndex]);
1998  }
1999  }
2000  else {
2001  queso_error_msg("hdf file type not supported for multiple sub-environments yet");
2002  }
2003  }
2004 #endif
2005  else {
2006  queso_error_msg("invalid file type");
2007  }
2008  m_env.closeFile(unifiedFilePtrSet,fileType);
2009  } // if (m_env.openUnifiedInputFile())
2010  } // if (m_env.inter0Rank() == (int) r)
2011  m_env.inter0Comm().Barrier();
2012  } // for r
2013  } // if (m_env.inter0Rank() >= 0)
2014  else {
2015  V tmpVec(m_vectorSpace.zeroVector());
2016  for (unsigned int i = 1; i < subReadSize; ++i) {
2017  this->setPositionValues(i,tmpVec);
2018  }
2019  }
2020 
2021  if (m_env.subDisplayFile()) {
2022  *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::unifiedReadContents()"
2023  << ", fileName = " << fileName
2024  << std::endl;
2025  }
2026  //m_env.fullComm().Barrier(); // Dangerous to barrier on fullComm ...
2027 
2028  return;
2029 }
unsigned int subId() const
Access function to the number of each sub-environment Id: m_subId.
Definition: Environment.C:342
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
Definition: MpiComm.C:174
const int UQ_OK_RC
Definition: Defines.h:92
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1084
const MpiComm & inter0Comm() const
Access function for MpiComm communicator for processes with subRank() 0.
Definition: Environment.C:313
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
void setPositionValues(unsigned int posId, const V &vec)
Set the values in vec at position posId of the sequence.
int worldRank() const
Returns the same thing as fullRank()
Definition: Environment.C:262
int fullRank() const
Returns the rank of the MPI process in QUESO&#39;s full communicator.
Definition: Environment.C:268
const VectorSpace< V, M > & m_vectorSpace
bool openUnifiedInputFile(const std::string &fileName, const std::string &fileType, FilePtrSetStruct &filePtrSet) const
Opens the unified input file.
Definition: Environment.C:991
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:133
void resizeSequence(unsigned int newSubSequenceSize)
Resizes the sequence.
unsigned int displayVerbosity() const
Definition: Environment.C:450
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
double MiscGetEllapsedSeconds(struct timeval *timeval0)
int inter0Rank() const
Returns the process inter0 rank.
Definition: Environment.C:307
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedSampleStd ( unsigned int  initialPos,
unsigned int  numPos,
const V &  unifiedMeanVec,
V &  unifiedStdVec 
) const

Finds the sample standard deviation of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec.

Output:

Parameters
stdVecis the vector of the calculated sample standard deviation of the unified sequence of vectors.

Definition at line 633 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedSampleStd().

638 {
639  bool bRC = ((initialPos < this->subSequenceSize() ) &&
640  (0 < numPos ) &&
641  ((initialPos+numPos) <= this->subSequenceSize() ) &&
642  (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()) &&
643  (this->vectorSizeLocal() == unifiedStdVec.sizeLocal() ));
644  queso_require_msg(bRC, "invalid input data");
645 
646  ScalarSequence<double> data(m_env,0,"");
647 
648  unsigned int numParams = this->vectorSizeLocal();
649  for (unsigned int i = 0; i < numParams; ++i) {
650  this->extractScalarSeq(initialPos,
651  1, // spacing
652  numPos,
653  i,
654  data);
655  unifiedStdVec[i] = data.unifiedSampleStd(m_vectorSpace.numOfProcsForStorage() == 1,
656  0,
657  numPos,
658  unifiedMeanVec[i]);
659  }
660 
661  return;
662 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedSampleVarianceExtra ( unsigned int  initialPos,
unsigned int  numPos,
const V &  unifiedMeanVec,
V &  unifiedSamVec 
) const
virtual

Finds the sample variance of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec.

Output:

Parameters
samVecis the vector of the calculated sample variance of the unified sequence of vectors.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 568 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedSampleVarianceExtra().

573 {
574  bool bRC = ((initialPos < this->subSequenceSize() ) &&
575  (0 < numPos ) &&
576  ((initialPos+numPos) <= this->subSequenceSize() ) &&
577  (this->vectorSizeLocal() == unifiedMeanVec.sizeLocal()) &&
578  (this->vectorSizeLocal() == unifiedSamVec.sizeLocal() ));
579  queso_require_msg(bRC, "invalid input data");
580 
581  ScalarSequence<double> data(m_env,0,"");
582 
583  unsigned int numParams = this->vectorSizeLocal();
584  for (unsigned int i = 0; i < numParams; ++i) {
585  this->extractScalarSeq(initialPos,
586  1, // spacing
587  numPos,
588  i,
589  data);
590  unifiedSamVec[i] = data.unifiedSampleVarianceExtra(m_vectorSpace.numOfProcsForStorage() == 1,
591  0,
592  numPos,
593  unifiedMeanVec[i]);
594  }
595 
596  return;
597 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedScalesForKde ( unsigned int  initialPos,
const V &  unifiedIqrVec,
unsigned int  kdeDimension,
V &  unifiedScaleVec 
) const
virtual

Selects the scales (bandwidth) for the kernel density estimation, considering the unified sequence.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1133 of file SequenceOfVectors.C.

References QUESO::ScalarSequence< T >::unifiedScaleForKde().

1138 {
1139  bool bRC = ((initialPos < this->subSequenceSize() ) &&
1140  (this->vectorSizeLocal() == unifiedIqrVec.sizeLocal() ) &&
1141  (this->vectorSizeLocal() == unifiedScaleVec.sizeLocal()));
1142  queso_require_msg(bRC, "invalid input data");
1143 
1144  unsigned int numPos = this->subSequenceSize() - initialPos;
1145  ScalarSequence<double> data(m_env,0,"");
1146 
1147  unsigned int numParams = this->vectorSizeLocal();
1148  for (unsigned int i = 0; i < numParams; ++i) {
1149  this->extractScalarSeq(initialPos,
1150  1, // spacing
1151  numPos,
1152  i,
1153  data);
1154  unifiedScaleVec[i] = data.unifiedScaleForKde(m_vectorSpace.numOfProcsForStorage() == 1,
1155  0,
1156  unifiedIqrVec[i],
1157  kdeDimension);
1158  }
1159 
1160  return;
1161 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedUniformlySampledCdf ( const V &  numEvaluationPointsVec,
ArrayOfOneDGrids< V, M > &  unifiedCdfGrids,
ArrayOfOneDTables< V, M > &  unifiedCdfValues 
) const
virtual

Uniformly samples from the CDF from the sub-sequence.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 262 of file SequenceOfVectors.C.

References QUESO::ArrayOfOneDTables< V, M >::setOneDTable(), and QUESO::ArrayOfOneDGrids< V, M >::setUniformGrids().

Referenced by QUESO::StatisticalForwardProblem< P_V, P_M, Q_V, Q_M >::solveWithMonteCarlo().

266 {
267  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
268  *m_env.subDisplayFile() << "Entering SequenceOfVectors<V,M>::unifiedUniformlySampledCdf()"
269  << std::endl;
270  }
271 
272  V unifiedMinDomainValues(m_vectorSpace.zeroVector());
273  V unifiedMaxDomainValues(m_vectorSpace.zeroVector());
274 
275  ScalarSequence<double> data(m_env,0,"");
276 
277  unsigned int numParams = this->vectorSizeLocal();
278  for (unsigned int i = 0; i < numParams; ++i) {
279  this->extractScalarSeq(0, // initialPos
280  1, // spacing
281  subSequenceSize(), // numPos
282  i,
283  data);
284 
285  std::vector<double> aCdf(0);
286  data.unifiedUniformlySampledCdf(m_vectorSpace.numOfProcsForStorage() == 1,
287  (unsigned int) numEvaluationPointsVec[i],
288  unifiedMinDomainValues[i],
289  unifiedMaxDomainValues[i],
290  aCdf);
291  unifiedCdfValues.setOneDTable(i,aCdf);
292  }
293 
294  unifiedCdfGrids.setUniformGrids(numEvaluationPointsVec,
295  unifiedMinDomainValues,
296  unifiedMaxDomainValues);
297 
298  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
299  *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::unifiedUniformlySampledCdf()"
300  << std::endl;
301  }
302 
303  return;
304 }
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
const VectorSpace< V, M > & m_vectorSpace
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars.
unsigned int displayVerbosity() const
Definition: Environment.C:450
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::unifiedWriteContents ( const std::string &  fileName,
const std::string &  fileType 
) const
virtual

Writes the unfed sequence to a file. Writes the unified sequence in Matlab/Octave format or, if enabled, in HDF5 format.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 1493 of file SequenceOfVectors.C.

References QUESO::FilePtrSetStruct::h5Var, QUESO::MiscGetEllapsedSeconds(), QUESO::FilePtrSetStruct::ofsVar, and QUESO::UQ_OK_RC.

Referenced by QUESO::MLSampling< P_V, P_M >::checkpointML(), QUESO::MLSampling< P_V, P_M >::generateSequence(), QUESO::MLSampling< P_V, P_M >::generateSequence_Level0_all(), and QUESO::MLSampling< P_V, P_M >::generateSequence_Step11_inter0().

1496 {
1497  std::string fileType(inputFileType);
1498 #ifdef QUESO_HAS_HDF5
1499  // Do nothing
1500 #else
1501  if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1502  if (m_env.subDisplayFile()) {
1503  *m_env.subDisplayFile() << "WARNING in SequenceOfVectors<V,M>::unifiedWriteContents()"
1504  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1505  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1506  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1507  << "' instead..."
1508  << std::endl;
1509  }
1510  if (m_env.subRank() == 0) {
1511  std::cerr << "WARNING in SequenceOfVectors<V,M>::unifiedWriteContents()"
1512  << ": file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1513  << "' has been requested, but this QUESO library has not been built with 'hdf5'"
1514  << ". Code will therefore process the file format '" << UQ_FILE_EXTENSION_FOR_HDF_FORMAT
1515  << "' instead..."
1516  << std::endl;
1517  }
1518  fileType = UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT;
1519  }
1520 #endif
1521 
1522  // All processors in 'fullComm' should call this routine...
1523 
1524  //m_env.fullComm().Barrier(); // Dangerous to barrier on fullComm ... // prudenci-2011-01-17
1525  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1526  *m_env.subDisplayFile() << "Entering SequenceOfVectors<V,M>::unifiedWriteContents()"
1527  << ": worldRank " << m_env.worldRank()
1528  << ", fullRank " << m_env.fullRank()
1529  << ", subEnvironment " << m_env.subId()
1530  << ", subRank " << m_env.subRank()
1531  << ", inter0Rank " << m_env.inter0Rank()
1532  //<< ", m_env.inter0Comm().NumProc() = " << m_env.inter0Comm().NumProc()
1533  << ", fileName = " << fileName
1534  << std::endl;
1535  }
1536 
1537  if (m_env.inter0Rank() >= 0) {
1538  for (unsigned int r = 0; r < (unsigned int) m_env.inter0Comm().NumProc(); ++r) {
1539  if (m_env.inter0Rank() == (int) r) {
1540  // My turn
1541  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1542  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedWriteContents()"
1543  << ": worldRank " << m_env.worldRank()
1544  << ", fullRank " << m_env.fullRank()
1545  << ", subEnvironment " << m_env.subId()
1546  << ", subRank " << m_env.subRank()
1547  << ", inter0Rank " << m_env.inter0Rank()
1548  //<< ", m_env.inter0Comm().NumProc() = " << m_env.inter0Comm().NumProc()
1549  << ", fileName = " << fileName
1550  << ", about to open file for r = " << r
1551  << std::endl;
1552  }
1553 
1554  // bool writeOver = (r == 0);
1555  bool writeOver = false; // A 'true' causes problems when the user chooses (via options
1556  // in the input file) to use just one file for all outputs.
1557  FilePtrSetStruct unifiedFilePtrSet;
1558  if (m_env.openUnifiedOutputFile(fileName,
1559  fileType, // "m or hdf"
1560  writeOver,
1561  unifiedFilePtrSet)) {
1562  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) { // 2013-02-23
1563  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedWriteContents()"
1564  << ": worldRank " << m_env.worldRank()
1565  << ", fullRank " << m_env.fullRank()
1566  << ", subEnvironment " << m_env.subId()
1567  << ", subRank " << m_env.subRank()
1568  << ", inter0Rank " << m_env.inter0Rank()
1569  //<< ", m_env.inter0Comm().NumProc() = " << m_env.inter0Comm().NumProc()
1570  << ", fileName = " << fileName
1571  << ", just opened file for r = " << r
1572  << std::endl;
1573  }
1574 
1575  unsigned int chainSize = this->subSequenceSize();
1576  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
1577  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
1578  if (r == 0) {
1579  if (fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) {
1580  // Need unified matlab header here since this is unifiedWriteContents
1581  writeUnifiedMatlabHeader(*unifiedFilePtrSet.ofsVar,
1582  this->subSequenceSize()*m_env.inter0Comm().NumProc(),
1583  this->vectorSizeLocal());
1584  }
1585  else { // If we get here it's definitely a txt file not matlab
1586  writeTxtHeader(*unifiedFilePtrSet.ofsVar,
1587  this->subSequenceSize()*m_env.inter0Comm().NumProc(),
1588  this->vectorSizeLocal());
1589  }
1590  }
1591 
1592  for (unsigned int j = 0; j < chainSize; ++j) { // 2013-02-23
1593  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): m_seq[" << j << "] = " << m_seq[j]
1594  // << std::endl;
1595  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): &(m_seq[" << j << "].map()) = " << &(m_seq[j]->map())
1596  // << std::endl;
1597  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): (m_seq[" << j << "].map().NumMyElements = " << m_seq[j]->map().NumMyElements()
1598  // << std::endl;
1599  //V tmpVec(*(m_seq[j]));
1600  //std::cout << "*(m_seq[" << j << "]) = " << tmpVec
1601  // << std::endl;
1602  //std::cout << "*(m_seq[" << j << "]) = " << *(m_seq[j])
1603  // << std::endl;
1604 
1605  bool savedVectorPrintScientific = m_seq[j]->getPrintScientific();
1606  bool savedVectorPrintState = m_seq[j]->getPrintHorizontally();
1607  m_seq[j]->setPrintScientific (true);
1608  m_seq[j]->setPrintHorizontally(true);
1609 
1610  *unifiedFilePtrSet.ofsVar << *(m_seq[j])
1611  << std::endl;
1612 
1613  m_seq[j]->setPrintHorizontally(savedVectorPrintState);
1614  m_seq[j]->setPrintScientific (savedVectorPrintScientific);
1615  }
1616  }
1617 #ifdef QUESO_HAS_HDF5
1618  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1619  unsigned int numParams = m_vectorSpace.dimLocal();
1620  if (r == 0) {
1621  hid_t datatype = H5Tcopy(H5T_NATIVE_DOUBLE);
1622  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): h5 case, data type created" << std::endl;
1623  hsize_t dimsf[2];
1624  dimsf[0] = chainSize;
1625  dimsf[1] = numParams;
1626  hid_t dataspace = H5Screate_simple(2, dimsf, NULL); // HDF5_rank = 2
1627  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): h5 case, data space created" << std::endl;
1628  hid_t dataset = H5Dcreate2(unifiedFilePtrSet.h5Var,
1629  "data",
1630  datatype,
1631  dataspace,
1632  H5P_DEFAULT, // Link creation property list
1633  H5P_DEFAULT, // Dataset creation property list
1634  H5P_DEFAULT); // Dataset access property list
1635  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): h5 case, data set created" << std::endl;
1636 
1637  struct timeval timevalBegin;
1638  int iRC = UQ_OK_RC;
1639  iRC = gettimeofday(&timevalBegin,NULL);
1640  if (iRC) {}; // just to remover compiler warning
1641 
1642  double * data;
1643  data = (double *)malloc(numParams * chainSize * sizeof(double));
1644 
1645  for (unsigned int i = 0; i < chainSize; ++i) {
1646  V tmpVec(*(m_seq[i]));
1647  for (unsigned int j = 0; j < numParams; ++j) {
1648  data[numParams*i+j] = tmpVec[j];
1649  }
1650  }
1651 
1652  herr_t status;
1653  status = H5Dwrite(dataset,
1654  H5T_NATIVE_DOUBLE,
1655  H5S_ALL,
1656  H5S_ALL,
1657  H5P_DEFAULT,
1658  data);
1659  if (status) {}; // just to remover compiler warning
1660  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): h5 case, data written" << std::endl;
1661 
1662  double writeTime = MiscGetEllapsedSeconds(&timevalBegin);
1663  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
1664  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedWriteContents()"
1665  << ": worldRank " << m_env.worldRank()
1666  << ", fullRank " << m_env.fullRank()
1667  << ", subEnvironment " << m_env.subId()
1668  << ", subRank " << m_env.subRank()
1669  << ", inter0Rank " << m_env.inter0Rank()
1670  << ", fileName = " << fileName
1671  << ", numParams = " << numParams
1672  << ", chainSize = " << chainSize
1673  << ", writeTime = " << writeTime << " seconds"
1674  << std::endl;
1675  }
1676 
1677  H5Dclose(dataset);
1678  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): h5 case, data set closed" << std::endl;
1679  H5Sclose(dataspace);
1680  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): h5 case, data space closed" << std::endl;
1681  H5Tclose(datatype);
1682  //std::cout << "In SequenceOfVectors<V,M>::unifiedWriteContents(): h5 case, data type closed" << std::endl;
1683  free(data);
1684  }
1685  else {
1686  queso_error_msg("hdf file type not supported for multiple sub-environments yet");
1687  }
1688  }
1689 #endif
1690  else {
1691  queso_error_msg("invalid file type");
1692  }
1693 
1694  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1695  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedWriteContents()"
1696  << ": worldRank " << m_env.worldRank()
1697  << ", fullRank " << m_env.fullRank()
1698  << ", subEnvironment " << m_env.subId()
1699  << ", subRank " << m_env.subRank()
1700  << ", inter0Rank " << m_env.inter0Rank()
1701  //<< ", m_env.inter0Comm().NumProc() = " << m_env.inter0Comm().NumProc()
1702  << ", fileName = " << fileName
1703  << ", about to close file for r = " << r
1704  << std::endl;
1705  }
1706 
1707  m_env.closeFile(unifiedFilePtrSet,fileType);
1708 
1709  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1710  *m_env.subDisplayFile() << "In SequenceOfVectors<V,M>::unifiedWriteContents()"
1711  << ": worldRank " << m_env.worldRank()
1712  << ", fullRank " << m_env.fullRank()
1713  << ", subEnvironment " << m_env.subId()
1714  << ", subRank " << m_env.subRank()
1715  << ", inter0Rank " << m_env.inter0Rank()
1716  //<< ", m_env.inter0Comm().NumProc() = " << m_env.inter0Comm().NumProc()
1717  << ", fileName = " << fileName
1718  << ", just closed file for r = " << r
1719  << std::endl;
1720  }
1721  } // if (m_env.openUnifiedOutputFile())
1722  } // if (m_env.inter0Rank() == (int) r)
1723  m_env.inter0Comm().Barrier();
1724  } // for r
1725 
1726  if (m_env.inter0Rank() == 0) {
1727  if ((fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) ||
1728  (fileType == UQ_FILE_EXTENSION_FOR_TXT_FORMAT)) {
1729  FilePtrSetStruct unifiedFilePtrSet;
1730  if (m_env.openUnifiedOutputFile(fileName,
1731  fileType,
1732  false, // Yes, 'writeOver = false' in order to close the array for matlab
1733  unifiedFilePtrSet)) {
1734 
1735  if (fileType == UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT) {
1736  *unifiedFilePtrSet.ofsVar << "];\n";
1737  }
1738 
1739  m_env.closeFile(unifiedFilePtrSet,fileType);
1740  }
1741  }
1742  else if (fileType == UQ_FILE_EXTENSION_FOR_HDF_FORMAT) {
1743  // Do nothing
1744  }
1745  else {
1746  queso_error_msg("invalid file type");
1747  }
1748  }
1749  } // if (m_env.inter0Rank() >= 0)
1750 
1751  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 10)) {
1752  *m_env.subDisplayFile() << "Leaving SequenceOfVectors<V,M>::unifiedWriteContents()"
1753  << ", fileName = " << fileName
1754  << std::endl;
1755  }
1756  //m_env.fullComm().Barrier(); // Dangerous to barrier on fullComm ... // prudenci-2011-01-17
1757 
1758  return;
1759 }
unsigned int subId() const
Access function to the number of each sub-environment Id: m_subId.
Definition: Environment.C:342
void Barrier() const
Pause every process in *this communicator until all the processes reach this point.
Definition: MpiComm.C:174
const int UQ_OK_RC
Definition: Defines.h:92
void closeFile(FilePtrSetStruct &filePtrSet, const std::string &fileType) const
Closes the file.
Definition: Environment.C:1084
const MpiComm & inter0Comm() const
Access function for MpiComm communicator for processes with subRank() 0.
Definition: Environment.C:313
int subRank() const
Returns the rank of the MPI process in the sub-communicator subComm()
Definition: Environment.C:287
unsigned int subSequenceSize() const
Size of the sub-sequence of vectors.
int worldRank() const
Returns the same thing as fullRank()
Definition: Environment.C:262
int fullRank() const
Returns the rank of the MPI process in QUESO&#39;s full communicator.
Definition: Environment.C:268
void writeUnifiedMatlabHeader(std::ofstream &ofs, double sequenceSize, double vectorSizeLocal) const
const VectorSpace< V, M > & m_vectorSpace
std::vector< const V * > m_seq
Sequence of vectors.
bool openUnifiedOutputFile(const std::string &fileName, const std::string &fileType, bool writeOver, FilePtrSetStruct &filePtrSet) const
Opens a unified output file, that will contain data from all sub-environments.
Definition: Environment.C:726
void writeTxtHeader(std::ofstream &ofs, double sequenceSize, double vectorSizeLocal) const
Helper function to write plain txt info for vectors.
int NumProc() const
Returns total number of processes.
Definition: MpiComm.C:133
unsigned int displayVerbosity() const
Definition: Environment.C:450
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
double MiscGetEllapsedSeconds(struct timeval *timeval0)
int inter0Rank() const
Returns the process inter0 rank.
Definition: Environment.C:307
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::writeSubMatlabHeader ( std::ofstream &  ofs,
double  sequenceSize,
double  vectorSizeLocal 
) const
private

Helper function to write matlab-specific header info for vectors.

Definition at line 1459 of file SequenceOfVectors.C.

1461 {
1462  ofs << m_name << "_sub" << m_env.subIdString() << " = zeros(" << sequenceSize
1463  << "," << vectorSizeLocal
1464  << ");"
1465  << std::endl;
1466  ofs << m_name << "_sub" << m_env.subIdString() << " = [";
1467 }
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:348
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
const BaseEnvironment & m_env
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::writeTxtHeader ( std::ofstream &  ofs,
double  sequenceSize,
double  vectorSizeLocal 
) const
private

Helper function to write plain txt info for vectors.

Definition at line 1483 of file SequenceOfVectors.C.

1485 {
1486  ofs << sequenceSize << " " << vectorSizeLocal
1487  << std::endl;
1488 }
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
template<class V , class M >
void QUESO::SequenceOfVectors< V, M >::writeUnifiedMatlabHeader ( std::ofstream &  ofs,
double  sequenceSize,
double  vectorSizeLocal 
) const
private

Definition at line 1471 of file SequenceOfVectors.C.

1473 {
1474  ofs << m_name << "_unified" << " = zeros(" << sequenceSize
1475  << "," << vectorSizeLocal
1476  << ");"
1477  << std::endl;
1478  ofs<< m_name << "_unified" << " = [";
1479 }
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
std::vector<const V*> QUESO::SequenceOfVectors< V, M >::m_seq
private

Sequence of vectors.

Definition at line 435 of file SequenceOfVectors.h.

Referenced by QUESO::SequenceOfVectors< V, M >::copy().

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_subMeanCltStdSeq
private

Definition at line 479 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_subMeanInter0Clt95
private

Definition at line 483 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_subMeanInter0Empirical90
private

Definition at line 484 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_subMeanInter0Max
private

Definition at line 486 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_subMeanInter0Mean
private

Definition at line 482 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_subMeanInter0Min
private

Definition at line 485 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
ScalarSequence<double>* QUESO::SequenceOfVectors< V, M >::m_subMeanInter0MonitorPosSeq
private

Definition at line 481 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
ScalarSequence<double>* QUESO::SequenceOfVectors< V, M >::m_subMeanMonitorPosSeq
private

Definition at line 477 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_subMeanVecSeq
private

Definition at line 478 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_unifiedMeanCltStdSeq
private

Definition at line 490 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
ScalarSequence<double>* QUESO::SequenceOfVectors< V, M >::m_unifiedMeanMonitorPosSeq
private

Definition at line 488 of file SequenceOfVectors.h.

template<class V = GslVector, class M = GslMatrix>
SequenceOfVectors<V,M>* QUESO::SequenceOfVectors< V, M >::m_unifiedMeanVecSeq
private

Definition at line 489 of file SequenceOfVectors.h.


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

Generated on Tue Jun 5 2018 19:49:01 for queso-0.57.1 by  doxygen 1.8.5