queso-0.53.0
Private Member Functions | Private Attributes | List of all members
QUESO::ArrayOfSequences< V, M > Class Template Reference

Class for handling array samples (arrays of scalar sequences). More...

#include <ArrayOfSequences.h>

Inheritance diagram for QUESO::ArrayOfSequences< V, M >:
Inheritance graph
[legend]
Collaboration diagram for QUESO::ArrayOfSequences< V, M >:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 ArrayOfSequences (const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
 Default constructor. More...
 
 ~ArrayOfSequences ()
 Destructor. More...
 
Sequence methods
unsigned int subSequenceSize () const
 Size of the sub-sequence of arrays. 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 of vec at position posId of the 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 mean (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 unifiedMean (unsigned int initialPos, unsigned int numPos, V &unifiedMeanVec) const
 Finds the mean value of the unified sequence of numPos positions starting at position initialPos. See template specialization. More...
 
void sampleVariance (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 unifiedSampleVariance (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const
 Finds the sample variance of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec. More...
 
void populationVariance (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 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 autocorrelation via definition. More...
 
void autoCorrViaFft (unsigned int initialPos, unsigned int numPos, const std::vector< unsigned int > &lags, std::vector< V * > &corrVecs) const
 
void autoCorrViaFft (unsigned int initialPos, unsigned int numPos, unsigned int numSum, V &autoCorrsSumVec) const
 
void minMax (unsigned int initialPos, V &minVec, V &maxVec) const
 Given an initial position initialPos, finds the minimum and the maximum values of the sequence. More...
 
void histogram (unsigned int initialPos, const V &minVec, const V &maxVec, std::vector< V * > &centersForAllBins, std::vector< V * > &quanttsForAllBins) const
 Calculates the histogram of the sequence. More...
 
void interQuantileRange (unsigned int initialPos, V &iqrs) const
 Returns the interquartile range of the values in the sequence. More...
 
void scalesForKDE (unsigned int initialPos, const V &iqrs, unsigned int kdeDimension, V &scales) const
 Selects the scales (bandwidth, scaleVec) for the kernel density estimation, of the sequence. More...
 
void gaussianKDE (const V &evaluationParamVec, V &densityVec) const
 Gaussian kernel for the KDE estimate of the sequence. More...
 
void gaussianKDE (unsigned int initialPos, const V &scales, const std::vector< V * > &evaluationParamVecs, std::vector< V * > &densityVecs) const
 TODO: Gaussian kernel for the KDE of the sequence. More...
 
void writeContents (std::ofstream &ofsvar) const
 Write contents of the chain to a file. More...
 
void unifiedWriteContents (std::ofstream &ofsvar) const
 Writes info of the unified sequence to a file. More...
 
void unifiedWriteContents (const std::string &fileName, const std::string &fileType) const
 Writes info of the unified sequence to a file. More...
 
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)
 Select positions in the sequence of vectors. More...
 
void filter (unsigned int initialPos, unsigned int spacing)
 Filters positions in the sequence of vectors, starting at initialPos, and with spacing given by spacing. More...
 
void extractScalarSeq (unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
 Extracts a sequence of scalars of size numPos, from position paramId of the array of sequences. More...
 
- 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...
 
virtual void subMeanExtra (unsigned int initialPos, unsigned int numPos, V &meanVec) const =0
 Finds the mean value of the sub-sequence, considering numPos positions starting at position initialPos. See template specialization. More...
 
virtual void unifiedMeanExtra (unsigned int initialPos, unsigned int numPos, V &unifiedMeanVec) const =0
 Finds the mean value of the unified sequence of numPos positions starting at position initialPos. See template specialization. More...
 
virtual void subMedianExtra (unsigned int initialPos, unsigned int numPos, V &medianVec) const =0
 Finds the median value of the sub-sequence, considering numPos positions starting at position initialPos. See template specialization. More...
 
virtual void unifiedMedianExtra (unsigned int initialPos, unsigned int localNumPos, V &unifiedMedianVec) const =0
 Finds the median value of the unified sequence, considering numPos positions starting at position initialPos. See template specialization. More...
 
virtual void subSampleVarianceExtra (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &samVec) const =0
 Finds the sample variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec. See template specialization. More...
 
virtual void unifiedSampleVarianceExtra (unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedSamVec) const =0
 Finds the sample variance of the unified sequence, considering numPos positions starting at position initialPos and of mean meanVec. See template specialization. More...
 
virtual void subPopulationVariance (unsigned int initialPos, unsigned int numPos, const V &meanVec, V &popVec) const =0
 Finds the population variance of the sub-sequence, considering numPos positions starting at position initialPos and of mean meanVec. See template specialization. More...
 
virtual void unifiedPopulationVariance (unsigned int initialPos, unsigned int numPos, const V &unifiedMeanVec, V &unifiedPopVec) const =0
 Finds the population variance of the unified-sequence, considering numPos positions starting at position initialPos and of mean meanVec. See template specialization. More...
 
virtual void subMinMaxExtra (unsigned int initialPos, unsigned int numPos, V &minVec, V &maxVec) const =0
 Finds the minimum and the maximum values of the sub-sequence, considering numPos positions starting at position initialPos. See template specialization. More...
 
virtual void unifiedMinMaxExtra (unsigned int initialPos, unsigned int numPos, V &unifiedMinVec, V &unifiedMaxVec) const =0
 Finds the minimum and the maximum values of the unified sequence, considering numPos positions starting at position initialPos. See template specialization. More...
 
virtual void subHistogram (unsigned int initialPos, const V &minVec, const V &maxVec, std::vector< V * > &centersForAllBins, std::vector< V * > &quanttsForAllBins) const =0
 Calculates the histogram of the sub-sequence. See template specialization. More...
 
virtual void unifiedHistogram (unsigned int initialPos, const V &unifiedMinVec, const V &unifiedMaxVec, std::vector< V * > &unifiedCentersForAllBins, std::vector< V * > &unifiedQuanttsForAllBins) const =0
 Calculates the histogram of the unified sequence. See template specialization. More...
 
virtual void subInterQuantileRange (unsigned int initialPos, V &iqrVec) const =0
 Returns the interquartile range of the values in the sub-sequence. See template specialization. More...
 
virtual void unifiedInterQuantileRange (unsigned int initialPos, V &unifiedIqrVec) const =0
 Returns the interquartile range of the values in the unified sequence. See template specialization. More...
 
virtual void subScalesForKde (unsigned int initialPos, const V &iqrVec, unsigned int kdeDimension, V &scaleVec) const =0
 Selects the scales (bandwidth, scaleVec) for the kernel density estimation, considering only the sub-sequence. See template specialization. More...
 
virtual void unifiedScalesForKde (unsigned int initialPos, const V &unifiedIqrVec, unsigned int kdeDimension, V &unifiedScaleVec) const =0
 Selects the scales (bandwidth) for the kernel density estimation, considering the unified sequence. See template specialization. More...
 
virtual void subGaussian1dKde (unsigned int initialPos, const V &scaleVec, const std::vector< V * > &evaluationParamVecs, std::vector< V * > &densityVecs) const =0
 Gaussian kernel for the KDE estimate of the sub-sequence. See template specialization. More...
 
virtual void unifiedGaussian1dKde (unsigned int initialPos, const V &unifiedScaleVec, const std::vector< V * > &unifiedEvaluationParamVecs, std::vector< V * > &unifiedDensityVecs) const =0
 Gaussian kernel for the KDE estimate of the unified sequence. See template specialization. More...
 
virtual void subWriteContents (unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const =0
 Writes info of the sub-sequence to a file. See template specialization. More...
 
virtual void subWriteContents (unsigned int initialPos, unsigned int numPos, std::ofstream &ofsvar, const std::string &fileType) const =0
 Writes info of the sub-sequence to a file. See template specialization. More...
 
void computeFilterParams (std::ofstream *passedOfs, unsigned int &initialPos, unsigned int &spacing)
 Computes the filtering parameters spacing for the sequence of vectors. More...
 
virtual double estimateConvBrooksGelman (unsigned int initialPos, unsigned int numPos) const =0
 Estimates convergence rate using Brooks & Gelman method. See template specialization. More...
 

Private Member Functions

void extractRawData (unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, std::vector< double > &rawData) const
 Extracts the raw data. More...
 

Private Attributes

DistArray< ScalarSequence
< double > * > 
m_scalarSequences
 Sequence of scalars. More...
 

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...
 
- 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::ArrayOfSequences< V, M >

Class for handling array samples (arrays of scalar sequences).

This class handles array of sequences (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 47 of file ArrayOfSequences.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 32 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::m_env, QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and QUESO::ArrayOfSequences< V, M >::subSequenceSize().

35  : BaseVectorSequence<V,M>(vectorSpace,subSequenceSize,name),
37 {
38 
39  //if (m_env.subDisplayFile()) {
40  // *m_env.subDisplayFile() << "Entering ArrayOfSequences<V,M>::constructor()"
41  // << std::endl;
42  //}
43 
44  //if (m_env.subDisplayFile()) {
45  // *m_env.subDisplayFile() << "In ArrayOfSequences<V,M>::constructor()"
46  // << "\n subSequenceSize = " << subSequenceSize
47  // << "\n m_scalarSequences.MyLength() = " << m_scalarSequences.MyLength()
48  // << std::endl;
49  //}
50 
51  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
52  m_scalarSequences(i,0) = new ScalarSequence<double>(m_env,subSequenceSize);
53  }
54 
55  //if (m_env.subDisplayFile()) {
56  // *m_env.subDisplayFile() << "Leaving ArrayOfSequences<V,M>::constructor()"
57  // << std::endl;
58  //}
59 }
const BaseEnvironment & m_env
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
const VectorSpace< V, M > & m_vectorSpace
const VectorSpace< V, M > & vectorSpace() const
Vector space; access to protected attribute VectorSpace&lt;V,M&gt;&amp; m_vectorSpace.
const std::string & name() const
Access to protected attribute m_name: name of the sequence of vectors.
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
QUESO::ArrayOfSequences< V, M >::~ArrayOfSequences ( )

Destructor.

Definition at line 63 of file ArrayOfSequences.C.

64 {
65  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
66  if (m_scalarSequences(i,0)) delete m_scalarSequences(i,0);
67  }
68 }
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.

Member Function Documentation

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

Calculates autocorrelation via definition.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 310 of file ArrayOfSequences.C.

314 {
315  V subChainMean (m_vectorSpace.zeroVector());
316  V subChainAutoCovarianceLag0(m_vectorSpace.zeroVector());
317 
318  this->mean(initialPos,
319  numPos,
320  subChainMean);
321  this->autoCovariance(initialPos,
322  numPos,
323  subChainMean,
324  0, // lag
325  subChainAutoCovarianceLag0);
326 
327  this->autoCovariance(initialPos,
328  numPos,
329  subChainMean,
330  lag,
331  corrVec);
332  corrVec /= subChainAutoCovarianceLag0;
333 
334  return;
335 }
void autoCovariance(unsigned int initialPos, unsigned int numPos, const V &meanVec, unsigned int lag, V &covVec) const
Calculates the autocovariance.
const VectorSpace< V, M > & m_vectorSpace
void mean(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::ArrayOfSequences< V, M >::autoCorrViaFft ( unsigned int  initialPos,
unsigned int  numPos,
const std::vector< unsigned int > &  lags,
std::vector< V * > &  corrVecs 
) const
virtual

Calculates autocorrelation via Fast Fourier transforms (FFT). TODO: Implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 338 of file ArrayOfSequences.C.

342 {
343  return;
344 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::autoCorrViaFft ( unsigned int  initialPos,
unsigned int  numPos,
unsigned int  numSum,
V &  autoCorrsSumVec 
) const
virtual

Calculates autocorrelation via Fast Fourier transforms (FFT). TODO: Implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 347 of file ArrayOfSequences.C.

References QUESO::ScalarSequence< T >::autoCorrViaFft(), and queso_require_msg.

351 {
352 #if 0
353  bool bRC = ((initialPos < this->subSequenceSize()) &&
354  (0 < numPos ) &&
355  ((initialPos+numPos) <= this->subSequenceSize()) &&
356  (autoCorrsSumVec.size() == this->vectorSize() ));
357  queso_require_msg(bRC, "invalid input data");
358 
359  ScalarSequence<double> data(m_env,0);
360 
361  unsigned int numParams = this->vectorSize();
362  for (unsigned int i = 0; i < numParams; ++i) {
363  this->extractScalarSeq(initialPos,
364  1, // spacing
365  numPos,
366  i,
367  data);
368 
369  data.autoCorrViaFft(0,
370  numPos,
371  autoCorrsSumVec[i]);
372  }
373 #endif
374  return;
375 }
const BaseEnvironment & m_env
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
void extractScalarSeq(unsigned int initialPos, unsigned int spacing, unsigned int numPos, unsigned int paramId, ScalarSequence< double > &scalarSeq) const
Extracts a sequence of scalars of size numPos, from position paramId of the array of sequences...
template<class V , class M >
void QUESO::ArrayOfSequences< 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 arrays with initial position initialPos, considering numPos positions, a lag of lag, with mean given by meanVec. The results are saved in the output vector covVec/

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 268 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and queso_require_msg.

273 {
274  bool bRC = ((0 <= initialPos ) &&
275  (0 < numPos ) &&
276  ((initialPos+numPos-1) <= (this->subSequenceSize()-1)));
277  queso_require_msg(bRC, "invalid initial position or number of positions");
278 
279  bRC = (numPos > lag);
280  queso_require_msg(bRC, "lag is too large");
281 
282  bRC = (this->vectorSize() == covVec.size());
283  queso_require_msg(bRC, "incompatible sizes between covVec vector and vectors in sequence");
284 
285  bRC = (this->vectorSize() == meanVec.size());
286  queso_require_msg(bRC, "incompatible sizes between meanVec vector and vectors in sequence");
287 
288  unsigned int loopSize = numPos - lag;
289  unsigned int finalPosPlus1 = initialPos + loopSize;
290  double doubleLoopSize = (double) loopSize;
291  covVec.cwSet(0.);
292 
293  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
294  for (unsigned int i = 0; i < covVec.size(); ++i) {
295  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
296  double meanValue = meanVec[i];
297  double result = 0;
298  for (unsigned int j = initialPos; j < finalPosPlus1; ++j) {
299  double diff1 = seq[j] - meanValue;
300  double diff2 = seq[j+lag] - meanValue;
301  result += diff1*diff2;
302  }
303  covVec[i] = result/doubleLoopSize;
304  }
305 
306  return;
307 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< 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 106 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors(), and QUESO::ScalarSequence< T >::erasePositions().

108 {
109  if (initialPos < this->subSequenceSize()) {
110  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
111  ScalarSequence<double>& seq = *(m_scalarSequences(i,0));
112  seq.erasePositions(initialPos,numPos);
113  }
114  }
115 
117 
118  return;
119 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< 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.

Extracts the data from sequence of array at position paramId, with spacing spacing, and saves is in rawData. The vector rawData will have size numPos. Note that, in fact, spacing = 1.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 622 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

627 {
628  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
629  ScalarSequence<double>& seq = *(tmp->m_scalarSequences(paramId,0));
630 
631  rawData.resize(numPos);
632  if (spacing == 1) {
633  for (unsigned int j = 0; j < numPos; ++j) {
634  rawData[j] = seq[paramId];
635  }
636  }
637  else {
638  for (unsigned int j = 0; j < numPos; ++j) {
639  rawData[j] = seq[paramId];
640  }
641  }
642 
643  return;
644 }
template<class V , class M >
void QUESO::ArrayOfSequences< 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 of size numPos, from position paramId of the array of sequences.

In this method, the parameter initialPos is unused and the parameter spacing is always equal to one

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 596 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and QUESO::ScalarSequence< T >::resizeSequence().

601 {
602  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
603  ScalarSequence<double>& seq = *(tmp->m_scalarSequences(paramId,0));
604 
605  scalarSeq.resizeSequence(numPos);
606  if (spacing == 1) {
607  for (unsigned int j = 0; j < numPos; ++j) {
608  scalarSeq[j] = seq[paramId];
609  }
610  }
611  else {
612  for (unsigned int j = 0; j < numPos; ++j) {
613  scalarSeq[j] = seq[paramId];
614  }
615  }
616 
617  return;
618 }
void resizeSequence(unsigned int newSequenceSize)
Resizes the size of the sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::filter ( unsigned int  initialPos,
unsigned int  spacing 
)
virtual

Filters positions in the sequence of vectors, starting at initialPos, and with spacing given by spacing.

TODO: implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 589 of file ArrayOfSequences.C.

591 {
592  return;
593 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::gaussianKDE ( const V &  evaluationParamVec,
V &  densityVec 
) const

Gaussian kernel for the KDE estimate of the sequence.

TODO: implement me!

Definition at line 497 of file ArrayOfSequences.C.

499 {
500  return;
501 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::gaussianKDE ( unsigned int  initialPos,
const V &  scales,
const std::vector< V * > &  evaluationParamVecs,
std::vector< V * > &  densityVecs 
) const

TODO: Gaussian kernel for the KDE of the sequence.

Todo:
: implement me! The density estimator will be:

\[ \hat{f}(x) = \frac{1}{nh} \sum_{j=1}^n K\Big(\frac{x-x_j}{h}\Big),\]

where $ K $ is a Gaussian kernel.

Definition at line 504 of file ArrayOfSequences.C.

References k, and QUESO::MiscGaussianDensity().

508 {
509 #if 0
510  unsigned int dataSize = sequence.size() - initialPos;
511  unsigned int numEstimationsPerParam = evaluationParamVecs.size();
512 
513  for (unsigned int j = 0; j < numEstimationsPerParam; ++j) {
514  densityVecs[j] = new V(*(sequence[0]));
515  }
516 
517  unsigned int numParams = sequence[0]->size();
518  for (unsigned int i = 0; i < numParams; ++i) {
519  double scaleInv = 1./scales[i];
520  for (unsigned int j = 0; j < numEstimationsPerParam; ++j) {
521  double x = (*(evaluationParamVecs[j]))[i];
522  double value = 0.;
523  for (unsigned int k = 0; k < dataSize; ++k) {
524  double xk = (*(sequence[initialPos+k]))[i];
525  value += MiscGaussianDensity((x-xk)*scaleInv,0.,1.);
526  }
527  (*(densityVecs[j]))[i] = scaleInv * (value/(double) numEstimationsPerParam);
528  }
529  }
530 
531 #endif
532  return;
533 }
double MiscGaussianDensity(double x, double mu, double sigma)
int k
Definition: ann_sample.cpp:53
template<class V , class M >
void QUESO::ArrayOfSequences< 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 122 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

123 {
124  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
125  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
126  vec[i] = (*(tmp->m_scalarSequences(i,0)))[posId];
127  }
128 
129  return;
130 }
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::histogram ( unsigned int  initialPos,
const V &  minVec,
const V &  maxVec,
std::vector< V * > &  centersForAllBins,
std::vector< V * > &  quanttsForAllBins 
) const

Calculates the histogram of the sequence.

TODO: implement me!

Definition at line 393 of file ArrayOfSequences.C.

References queso_require_equal_to_msg.

398 {
399 #if 0
400  queso_require_equal_to_msg(centersForAllBins.size(), quanttsForAllBins.size(), "vectors 'centers' and 'quantts' have different sizes");
401 
402  for (unsigned int j = 0; j < quanttsForAllBins.size(); ++j) {
403  centersForAllBins[j] = new V(*(sequence[0]));
404  quanttsForAllBins [j] = new V(*(sequence[0]));
405  }
406 
407  unsigned int dataSize = sequence.size() - initialPos;
408  unsigned int numParams = sequence[0]->size();
409  for (unsigned int i = 0; i < numParams; ++i) {
410  ScalarSequence<double> data(dataSize,0.);
411  for (unsigned int j = 0; j < dataSize; ++j) {
412  data[j] = (*(sequence[initialPos+j]))[i];
413  }
414 
415  std::vector<double> centers(centersForAllBins.size(),0.);
416  std::vector<double> quantts(quanttsForAllBins.size(),0.);
417  data.histogram(minVec[i],
418  maxVec[i],
419  centers,
420  quantts);
421 
422  for (unsigned int j = 0; j < quantts.size(); ++j) {
423  (*(centersForAllBins[j]))[i] = centers[j];
424  (*(quanttsForAllBins[j]))[i] = quantts[j];
425  }
426  }
427 
428 #endif
429  return;
430 }
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::interQuantileRange ( unsigned int  initialPos,
V &  iqrs 
) const

Returns the interquartile range of the values in the sequence.

TODO: implement me!

Definition at line 433 of file ArrayOfSequences.C.

435 {
436 #if 0
437  unsigned int dataSize = sequence.size() - initialPos;
438 
439  ArrayOfSequences sortedSequence(dataSize,m_vectorSpace.zeroVector());
440  this->sort(initialPos,
441  sortedSequence);
442 
443  unsigned int pos1 = (unsigned int) ( (((double) dataSize) + 1.)*1./4. - 1. );
444  unsigned int pos3 = (unsigned int) ( (((double) dataSize) + 1.)*3./4. - 1. );
445 
446  double fraction1 = (((double) dataSize) + 1.)*1./4. - 1. - ((double) pos1);
447  double fraction3 = (((double) dataSize) + 1.)*3./4. - 1. - ((double) pos3);
448 
449  unsigned int numParams = sequence[0]->size();
450  for (unsigned int i = 0; i < numParams; ++i) {
451  double value1 = (1.-fraction1) * (*sortedSequence[pos1])[i] + fraction1 * (*sortedSequence[pos1+1])[i];
452  double value3 = (1.-fraction3) * (*sortedSequence[pos3])[i] + fraction3 * (*sortedSequence[pos3+1])[i];
453  iqrs[i] = value3 - value1;
454  }
455 
456 #endif
457  return;
458 }
ArrayOfSequences(const VectorSpace< V, M > &vectorSpace, unsigned int subSequenceSize, const std::string &name)
Default constructor.
const VectorSpace< V, M > & m_vectorSpace
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::mean ( unsigned int  initialPos,
unsigned int  numPos,
V &  meanVec 
) const

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

Definition at line 172 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, queso_require_msg, and QUESO::ScalarSequence< T >::subMeanExtra().

174 {
175  bool bRC = ((0 <= initialPos ) &&
176  (0 < numPos ) &&
177  ((initialPos+numPos-1) <= (this->subSequenceSize()-1)));
178  queso_require_msg(bRC, "invalid initial position or number of positions");
179 
180  bRC = (this->vectorSize() == meanVec.size());
181  queso_require_msg(bRC, "incompatible sizes between meanVec vector and vectors in sequence");
182 
183  meanVec.cwSet(0.);
184  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
185  for (unsigned int i = 0; i < meanVec.size(); ++i) {
186  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
187  meanVec[i] = seq.subMeanExtra(initialPos, numPos);
188  }
189 
190  return;
191 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::minMax ( unsigned int  initialPos,
V &  minVec,
V &  maxVec 
) const

Given an initial position initialPos, finds the minimum and the maximum values of the sequence.

Definition at line 378 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and QUESO::ScalarSequence< T >::subMinMaxExtra().

380 {
381  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
382 
383  unsigned int numParams = this->vectorSize();
384  for (unsigned int i = 0; i < numParams; ++i) {
385  ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
386  seq.subMinMaxExtra(initialPos,minVec[i],maxVec[i]);
387  }
388 
389  return;
390 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::populationVariance ( 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.

Definition at line 231 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and queso_require_msg.

235 {
236  bool bRC = ((0 <= initialPos ) &&
237  (0 < numPos ) &&
238  ((initialPos+numPos-1) <= (this->subSequenceSize()-1)));
239  queso_require_msg(bRC, "invalid initial position or number of positions");
240 
241  bRC = (this->vectorSize() == popVec.size());
242  queso_require_msg(bRC, "incompatible sizes between popVec vector and vectors in sequence");
243 
244  bRC = (this->vectorSize() == meanVec.size());
245  queso_require_msg(bRC, "incompatible sizes between meanVec vector and vectors in sequence");
246 
247  unsigned int loopSize = numPos;
248  unsigned int finalPosPlus1 = initialPos + loopSize;
249  double doubleLoopSize = (double) loopSize;
250  popVec.cwSet(0.);
251 
252  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
253  for (unsigned int i = 0; i < popVec.size(); ++i) {
254  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
255  double tmpMean = meanVec[i];
256  double result = 0.;
257  for (unsigned int j = initialPos; j < finalPosPlus1; ++j) {
258  double diff = seq[j] - tmpMean;
259  result += diff*diff;
260  }
261  popVec[i] = result/doubleLoopSize;
262  }
263 
264  return;
265 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< 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 93 of file ArrayOfSequences.C.

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

95 {
96  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
97  m_scalarSequences(i,0)->resetValues(initialPos,numPos);
98  }
99 
101 
102  return;
103 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::resizeSequence ( unsigned int  newSubSequenceSize)
virtual

Resizes the sequence.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 80 of file ArrayOfSequences.C.

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

81 {
82  if (newSubSequenceSize != this->subSequenceSize()) {
83  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
84  m_scalarSequences(i,0)->resizeSequence(newSubSequenceSize);
85  }
86  }
87 
89  return;
90 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::sampleVariance ( 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.

Definition at line 194 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences, and queso_require_msg.

198 {
199  bool bRC = ((0 <= initialPos ) &&
200  (0 < numPos ) &&
201  ((initialPos+numPos-1) <= (this->subSequenceSize()-1)));
202  queso_require_msg(bRC, "invalid initial position or number of positions");
203 
204  bRC = (this->vectorSize() == samVec.size());
205  queso_require_msg(bRC, "incompatible sizes between samVec vector and vectors in sequence");
206 
207  bRC = (this->vectorSize() == meanVec.size());
208  queso_require_msg(bRC, "incompatible sizes between meanVec vector and vectors in sequence");
209 
210  unsigned int loopSize = numPos;
211  unsigned int finalPosPlus1 = initialPos + loopSize;
212  double doubleLoopSize = (double) loopSize;
213  samVec.cwSet(0.);
214 
215  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
216  for (unsigned int i = 0; i < samVec.size(); ++i) {
217  const ScalarSequence<double>& seq = *(tmp->m_scalarSequences(i,0));
218  double tmpMean = meanVec[i];
219  double result = 0.;
220  for (unsigned int j = initialPos; j < finalPosPlus1; ++j) {
221  double diff = seq[j] - tmpMean;
222  result += diff*diff;
223  }
224  samVec[i] = result/(doubleLoopSize - 1.);
225  }
226 
227  return;
228 }
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::scalesForKDE ( unsigned int  initialPos,
const V &  iqrs,
unsigned int  kdeDimension,
V &  scales 
) const

Selects the scales (bandwidth, scaleVec) for the kernel density estimation, of the sequence.

TODO: implement me!

Definition at line 461 of file ArrayOfSequences.C.

465 {
466 #if 0
467  unsigned int dataSize = sequence.size() - initialPos;
468 
469  V mean(*(sequence[0]));
470  VectorSequenceMean(sequence,
471  initialPos,
472  dataSize,
473  mean);
474 
475  V samVec(*(sequence[0]));
476  VectorSequenceSampleVariance(sequence,
477  initialPos,
478  dataSize,
479  mean,
480  samVec);
481 
482  unsigned int numParams = sequence[0]->size();
483  for (unsigned int i = 0; i < numParams; ++i) {
484  if (iqrs[i] <= 0.) {
485  scales[i] = 1.06*std::sqrt(samVec[i])/std::pow(dataSize,1./5.);
486  }
487  else {
488  scales[i] = 1.06*std::min(std::sqrt(samVec[i]),iqrs[i]/1.34)/std::pow(dataSize,1./5.);
489  }
490  }
491 
492 #endif
493  return;
494 }
void mean(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::ArrayOfSequences< V, M >::select ( const std::vector< unsigned int > &  idsOfUniquePositions)
virtual

Select positions in the sequence of vectors.

TODO: implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 582 of file ArrayOfSequences.C.

584 {
585  return;
586 }
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::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.

This routine deletes all stored computed vectors

Definition at line 146 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors(), and QUESO::ScalarSequence< T >::setGaussian().

147 {
148  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
149  ScalarSequence<double>& seq = *(m_scalarSequences(i,0));
150  seq.setGaussian(meanVec[i],stdDevVec[i]);
151  }
152 
154 
155  return;
156 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::setPositionValues ( unsigned int  posId,
const V &  vec 
)
virtual

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

This routine deletes all stored computed vectors

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 133 of file ArrayOfSequences.C.

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

134 {
135  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
136  ScalarSequence<double>& seq = *(m_scalarSequences(i,0));
137  seq[posId] = vec[i];
138  }
139 
141 
142  return;
143 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::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.

This routine deletes all stored computed vectors

Definition at line 159 of file ArrayOfSequences.C.

References QUESO::BaseVectorSequence< V, M >::deleteStoredVectors(), and QUESO::ScalarSequence< T >::setUniform().

160 {
161  for (unsigned int i = 0; i < (unsigned int) m_scalarSequences.MyLength(); ++i) {
162  ScalarSequence<double>& seq = *(m_scalarSequences(i,0));
163  seq.setUniform(aVec[i],bVec[i]);
164  }
165 
167 
168  return;
169 }
void deleteStoredVectors()
Deletes all the stored vectors.
DistArray< ScalarSequence< double > * > m_scalarSequences
Sequence of scalars.
template<class V , class M >
unsigned int QUESO::ArrayOfSequences< V, M >::subSequenceSize ( ) const
virtual

Size of the sub-sequence of arrays.

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 72 of file ArrayOfSequences.C.

References QUESO::ArrayOfSequences< V, M >::m_scalarSequences.

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

73 {
74  ArrayOfSequences<V,M>* tmp = const_cast<ArrayOfSequences<V,M>*>(this);
75 
76  return tmp->m_scalarSequences(0,0)->subSequenceSize();
77 }
template<class V = GslVector, class M = GslMatrix>
void QUESO::ArrayOfSequences< V, M >::unifiedMean ( unsigned int  initialPos,
unsigned int  numPos,
V &  unifiedMeanVec 
) const

Finds the mean value of the unified sequence of numPos positions starting at position initialPos. See template specialization.

template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::unifiedReadContents ( const std::string &  fileName,
const std::string &  fileType,
const unsigned int  subSequenceSize 
)
virtual

Reads the unified sequence from a file.

TODO: implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 573 of file ArrayOfSequences.C.

References queso_not_implemented.

576 {
578  return;
579 }
#define queso_not_implemented()
Definition: asserts.h:56
template<class V = GslVector, class M = GslMatrix>
void QUESO::ArrayOfSequences< V, M >::unifiedSampleVariance ( unsigned int  initialPos,
unsigned int  numPos,
const V &  meanVec,
V &  samVec 
) const

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

template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::unifiedWriteContents ( std::ofstream &  ofsvar) const

Writes info of the unified sequence to a file.

TODO: implement me!

Definition at line 558 of file ArrayOfSequences.C.

References queso_not_implemented.

559 {
561  return;
562 }
#define queso_not_implemented()
Definition: asserts.h:56
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::unifiedWriteContents ( const std::string &  fileName,
const std::string &  fileType 
) const
virtual

Writes info of the unified sequence to a file.

TODO: implement me!

Implements QUESO::BaseVectorSequence< V, M >.

Definition at line 565 of file ArrayOfSequences.C.

References queso_not_implemented.

567 {
569  return;
570 }
#define queso_not_implemented()
Definition: asserts.h:56
template<class V , class M >
void QUESO::ArrayOfSequences< V, M >::writeContents ( std::ofstream &  ofsvar) const

Write contents of the chain to a file.

Definition at line 536 of file ArrayOfSequences.C.

537 {
538  // Write chain
539  ofsvar << m_name << "_sub" << m_env.subIdString() << " = zeros(" << this->subSequenceSize()
540  << "," << this->vectorSize()
541  << ");"
542  << std::endl;
543  ofsvar << m_name << "_sub" << m_env.subIdString() << " = [";
544 
545  V tmpVec(m_vectorSpace.zeroVector());
546  unsigned int chainSize = this->subSequenceSize();
547  for (unsigned int j = 0; j < chainSize; ++j) {
548  this->getPositionValues(j,tmpVec);
549  ofsvar << tmpVec
550  << std::endl;
551  }
552  ofsvar << "];\n";
553 
554  return;
555 }
const BaseEnvironment & m_env
const VectorSpace< V, M > & m_vectorSpace
const std::string & subIdString() const
Access to the attribute m_subIdString; which stores the string for the sub-environment, and it will be used, for instance, to create the output files for each sub-environment.
Definition: Environment.C:301
void getPositionValues(unsigned int posId, V &vec) const
Gets the values of the sequence at position posId and stores them at vec.
unsigned int subSequenceSize() const
Size of the sub-sequence of arrays.

Member Data Documentation

template<class V = GslVector, class M = GslMatrix>
DistArray<ScalarSequence<double>*> QUESO::ArrayOfSequences< V, M >::m_scalarSequences
private

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

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