queso-0.50.1
Classes | Typedefs | Functions | Variables
QUESO Namespace Reference

Classes

class  BasicPdfsBase
 TODO: Base class for basic PDFs (via either GSL or Boost). More...
 
class  BasicPdfsBoost
 TODO: Base class for basic PDFs using Boost library. More...
 
class  BasicPdfsGsl
 TODO: Base class for basic PDFs using Gsl library. More...
 
class  EnvOptionsValues
 This class provides a suite options one can pass to a QUESO environment. More...
 
class  DistArray
 A class for partitioning vectors and matrices. More...
 
struct  FilePtrSetStruct
 Struct for handling data input and output from files. More...
 
class  BaseEnvironment
 This (virtual) class sets up the environment underlying the use of the QUESO library by an executable. More...
 
class  EmptyEnvironment
 This class sets up the environment underlying the use of the QUESO library by an executable. More...
 
class  FullEnvironment
 This class sets up the full environment underlying the use of the QUESO library by an executable. More...
 
class  EnvironmentOptions
 This class reads options one can pass to a QUESO environment through an input file. More...
 
class  LogicError
 
class  NotImplemented
 
class  FileError
 
class  FunctionBase
 Abstract base class for function objects. More...
 
class  FunctionOperatorBuilder
 
class  GslMatrix
 Class for matrix operations using GSL library. More...
 
class  GslVector
 Class for vector operations using GSL library. More...
 
class  InfiniteDimensionalGaussian
 Class defining infinite dimensional Gaussian measures. More...
 
class  InfiniteDimensionalLikelihoodBase
 Abstract class representing the likelihood. Users must subclass this. More...
 
class  InfiniteDimensionalMCMCSamplerOptions
 This class defines the options that specify the behaviour of the MCMC sampler. More...
 
class  InfiniteDimensionalMeasureBase
 Abstract base class for infinite dimensional measures. More...
 
class  Map
 A class for partitioning vectors and matrices. More...
 
class  Matrix
 Class for matrix operations (virtual). More...
 
class  MpiComm
 The QUESO MPI Communicator Class. More...
 
class  OperatorBase
 Abstract base class for operator objects. Operators are assumed to be symmetric and positive-definite. More...
 
class  RngBase
 Class for random number generation (base class for either GSL or Boost RNG). More...
 
class  RngBoost
 
class  RngGsl
 
class  Vector
 Class for vector operations (virtual). More...
 
class  Base1D1DFunction
 Class for one-dimensional functions. More...
 
class  Generic1D1DFunction
 Class for generic one-dimensional functions. More...
 
class  Constant1D1DFunction
 Class for constant one-dimensional functions. More...
 
class  Linear1D1DFunction
 Class for linear one-dimensional functions. More...
 
class  PiecewiseLinear1D1DFunction
 Class for piecewise-linear one-dimensional functions. More...
 
class  Quadratic1D1DFunction
 Class for one-dimensional quadratic functions. More...
 
class  Sampled1D1DFunction
 Class for one-dimensional sampled functions. More...
 
class  ScalarTimesFunc1D1DFunction
 Class for multiplication of a one-dimensional function by a scalar. More...
 
class  FuncTimesFunc1D1DFunction
 Class for multiplication of a one-dimensional function by another. More...
 
class  FuncPlusFunc1D1DFunction
 Class for addition of a one-dimensional function with another. More...
 
class  LagrangePolynomial1D1DFunction
 Class for one-dimensional Lagrange polynomials. More...
 
class  LagrangeBasis1D1DFunction
 Class for Lagrange polynomial basis. More...
 
class  Base1DQuadrature
 Base class for one-dimensional quadrature rules (numerical integration of functions). More...
 
class  Generic1DQuadrature
 Class for one-dimensional generic quadrature rules (numerical integration of functions). More...
 
class  UniformLegendre1DQuadrature
 Class for Legendre-Gauss quadrature rule for one-dimensional functions. More...
 
class  GaussianHermite1DQuadrature
 Class for Hermite-Gauss quadrature rule for one-dimensional functions. More...
 
class  WignerInverseChebyshev1st1DQuadrature
 Class for first type Chebyshev-Gauss quadrature rule for one-dimensional functions. More...
 
class  WignerChebyshev2nd1DQuadrature
 Class for second type Chebyshev-Gauss quadrature rule for one-dimensional functions. More...
 
class  TwoDArray
 Class for handling arrays of generic data. More...
 
class  ArrayOfOneDGrids
 Class to accommodate arrays of one-dimensional grid. More...
 
class  ArrayOfOneDTables
 Class to accommodate arrays of one-dimensional tables. More...
 
class  AsciiTable
 Class for reading ASCII values from a table in a file. More...
 
class  Fft
 Class for a Fast Fourier Transform (FFT) algorithm. More...
 
class  BaseOneDGrid
 Base class for accommodating one-dimensional grids. More...
 
class  StdOneDGrid
 Class for accommodating standard one-dimensional grids. More...
 
class  UniformOneDGrid
 Class for accommodating uniform one-dimensional grids. More...
 
class  ArrayOfSequences
 Class for handling array samples (arrays of scalar sequences). More...
 
class  BoxSubset
 Class representing a subset of a vector space shaped like a hypercube. More...
 
class  ConcatenationSubset
 A templated class representing the concatenation of two vector subsets. More...
 
class  ConstantScalarFunction
 A class for handling scalar functions which image is a constant (real number). More...
 
class  ConstantVectorFunction
 A class for handling vector functions which image is constant. More...
 
class  DiscreteSubset
 A templated class representing the discrete vector subsets. More...
 
class  GenericScalarFunction
 A class for handling generic scalar functions. More...
 
class  GenericVectorFunction
 A class for handling generic vector functions. More...
 
class  IntersectionSubset
 A templated class representing the intersection of two vector sets. More...
 
class  BaseScalarFunction
 A templated (base) class for handling scalar functions. More...
 
class  ScalarFunctionSynchronizer
 A templated class for synchronizing the calls of scalar functions (BaseScalarFunction and derived classes). More...
 
class  ScalarSequence
 Class for handling scalar samples. More...
 
class  SequenceOfVectors
 Class for handling vector samples (sequence of vectors). More...
 
class  BaseVectorFunction
 A templated (base) class for handling vector functions. More...
 
class  VectorFunctionSynchronizer
 A templated class for synchronizing the calls of vector-valued functions. More...
 
class  BaseVectorSequence
 Base class for handling vector and array samples (sequence of vectors or arrays). More...
 
class  VectorSpace
 A class representing a vector space. More...
 
class  VectorSet
 A templated class for handling sets. More...
 
class  VectorSubset
 A templated class for handling subsets. More...
 
class  BayesianJointPdf
 A class for handling Bayesian joint PDFs. More...
 
class  BetaJointPdf
 A class for handling Beta joint PDFs. More...
 
class  BetaVectorRealizer
 A class for handling sampling from a Beta probability density distribution. More...
 
class  BetaVectorRV
 A class representing a vector RV constructed via Beta distribution. More...
 
class  ConcatenatedJointPdf
 A class for handling concatenated PDFs. More...
 
class  ConcatenatedVectorRealizer
 A class for handling sampling from concatenated probability density distributions. More...
 
class  ConcatenatedVectorRV
 A class representing concatenated vector RVs. More...
 
class  ExponentialMatrixCovarianceFunction
 A class for exponential covariance matrices. More...
 
class  ExponentialScalarCovarianceFunction
 A class for exponential covariances. More...
 
class  FiniteDistribution
 A templated class for a finite distribution. More...
 
class  GammaJointPdf
 A class for handling Gamma joint PDFs. More...
 
class  GammaVectorRealizer
 A class for handling sampling from a Gamma probability density distribution. More...
 
class  GammaVectorRV
 A class representing a vector RV constructed via Gamma distribution. More...
 
class  GaussianJointPdf
 A class for handling Gaussian joint PDFs. More...
 
class  GaussianVectorCdf
 TODO: A class for handling Gaussian CDFs. More...
 
class  GaussianVectorMdf
 TODO: A class for handling Gaussian MDFs. More...
 
class  GaussianVectorRealizer
 A class for handling sampling from Gaussian probability density distributions. More...
 
class  GaussianVectorRV
 A class representing a Gaussian vector RV. More...
 
class  GenericJointPdf
 A class for handling generic joint PDFs. More...
 
class  GenericMatrixCovarianceFunction
 A class for generic covariance matrices. More...
 
class  GenericScalarCovarianceFunction
 A class for generic covariances. More...
 
class  GenericVectorCdf
 A class for handling generic vector CDFs. More...
 
class  GenericVectorMdf
 A class for handling generic MDFs of vector functions. More...
 
class  GenericVectorRealizer
 A class for handling sampling from generic probability density distributions. More...
 
class  GenericVectorRV
 A templated class for handling generic vector RVs. More...
 
class  HessianCovMatricesTKGroup
 This class allows the representation of a transition kernel with Hessians. More...
 
class  InverseGammaJointPdf
 A class for handling Inverse Gamma joint PDFs. More...
 
class  InverseGammaVectorRealizer
 A class for handling sampling from an Inverse Gamma probability density distribution. More...
 
class  InverseGammaVectorRV
 A class representing a vector RV constructed via Inverse Gamma distribution. More...
 
class  BaseJointPdf
 A templated (base) class for handling joint PDFs. More...
 
class  LogNormalJointPdf
 A class for handling Log-Normal joint PDFs. More...
 
class  LogNormalVectorRealizer
 A class for handling sampling from a Log-Normal probability density distribution. More...
 
class  LogNormalVectorRV
 A class representing a LogNormal vector RV. More...
 
class  MarkovChainPositionData
 A templated class that represents a Markov Chain. More...
 
class  BaseMatrixCovarianceFunction
 A templated (base) class to accommodate covariance matrix of (random) vector functions. More...
 
struct  MHRawChainInfoStruct
 A struct that represents a Metropolis-Hastings sample. More...
 
class  MetropolisHastingsSG
 A templated class that represents a Metropolis-Hastings generator of samples. More...
 
class  MhOptionsValues
 This class provides options for the Metropolis-Hastings generator of samples if no input file is available. More...
 
class  MetropolisHastingsSGOptions
 This class reads the options for the Metropolis-Hastings generator of samples from an input file. More...
 
struct  ExchangeInfoStruct
 
struct  BalancedLinkedChainControlStruct
 
struct  BalancedLinkedChainsPerNodeStruct
 
struct  UnbalancedLinkedChainControlStruct
 
struct  UnbalancedLinkedChainsPerNodeStruct
 
class  MLSampling
 A templated class that represents a Multilevel generator of samples. More...
 
class  MLSamplingLevelOptions
 This class provides options for each level of the Multilevel sequence generator if no input file is available. More...
 
class  MLSamplingOptions
 This class provides options for the Multilevel sequence generator if no input file is available. More...
 
class  ModelValidation
 A templated class for model validation of the example validationPyramid. More...
 
class  MonteCarloSG
 A templated class that implements a Monte Carlo generator of samples. More...
 
class  McOptionsValues
 This class provides options for the Monte Carlo sequence generator if no input file is available. More...
 
class  MonteCarloSGOptions
 This class reads the options for the Monte Carlo sequence generator from an input file. More...
 
class  PoweredJointPdf
 A class for handling a powered joint PDFs. More...
 
class  SampledScalarCdf
 A class for handling sampled CDFs. More...
 
class  SampledVectorCdf
 A class for handling sampled vector CDFs. More...
 
class  SampledVectorMdf
 A class for handling sampled vector MDFs. More...
 
class  BaseScalarCdf
 A templated (base) class for handling CDFs. More...
 
class  BaseScalarCovarianceFunction
 A templated (base) class to accommodate scalar covariance functions (of random variables). More...
 
class  ScalarGaussianRandomField
 A class for handling scalar Gaussian random fields (GRF). More...
 
class  ScaledCovMatrixTKGroup
 This class allows the representation of a transition kernel with a scaled covariance matrix. More...
 
class  SequentialVectorRealizer
 A class for handling sequential draws (sampling) from probability density distributions. More...
 
class  StatisticalForwardProblem
 This templated class represents a Statistical Forward Problem. More...
 
class  SfpOptionsValues
 This class provides options for a Statistical Forward Problem if no input file is available. More...
 
class  StatisticalForwardProblemOptions
 This class reads option values for a Statistical Forward Problem from an input file. More...
 
class  StatisticalInverseProblem
 This templated class represents a Statistical Inverse Problem. More...
 
class  SipOptionsValues
 This class provides options for a Statistical Inverse Problem if no input file is available. More...
 
class  StatisticalInverseProblemOptions
 This class reads option values for a Statistical Inverse Problem from an input file. More...
 
class  StdScalarCdf
 A class for handling standard CDFs. More...
 
class  BaseTKGroup
 This base class allows the representation of a transition kernel. More...
 
class  UniformJointPdf
 A class for handling uniform joint PDFs. More...
 
class  UniformVectorRealizer
 A class for handling sampling from a Uniform probability density distribution. More...
 
class  UniformVectorRV
 A class representing a uniform vector RV. More...
 
class  ValidationCycle
 A templated class for validation cycle of the examples validationCycle and validationCycle2. More...
 
class  BaseVectorCdf
 A templated (base) class for handling CDFs of vector functions. More...
 
class  VectorGaussianRandomField
 A class for handling vector Gaussian random fields (GRF). More...
 
class  BaseVectorMdf
 A templated (base) class for handling MDFs of vector functions. More...
 
class  BaseVectorRealizer
 A templated (base) class for handling sampling from vector RVs. More...
 
class  BaseVectorRV
 A templated base class for handling vector RV. More...
 
class  WignerJointPdf
 A class for handling Wigner joint PDFs. More...
 
class  WignerVectorRealizer
 A class for handling sampling from a Wigner probability density distribution. More...
 
class  WignerVectorRV
 A class representing a vector RV constructed via Wigner distribution. More...
 

Typedefs

typedef MPI_Comm RawType_MPI_Comm
 
typedef MPI_Group RawType_MPI_Group
 
typedef MPI_Datatype RawType_MPI_Datatype
 
typedef MPI_Op RawType_MPI_Op
 
typedef MPI_Status RawType_MPI_Status
 

Functions

int MyWorldfullRank ()
 Returns the rank of the calling process in the communicator. More...
 
void queso_terminate_handler ()
 Function for unhandled exceptions in Queso. More...
 
void QUESO_version_print (std::ostream &os)
 
int QUESO_get_numeric_version ()
 
std::ostream & operator<< (std::ostream &os, const BaseEnvironment &obj)
 
std::ostream & operator<< (std::ostream &os, const EnvironmentOptions &obj)
 Print values of the options chosen. More...
 
GslMatrix operator* (double a, const GslMatrix &mat)
 
GslVector operator* (const GslMatrix &mat, const GslVector &vec)
 
GslMatrix operator* (const GslMatrix &m1, const GslMatrix &m2)
 
GslMatrix operator+ (const GslMatrix &m1, const GslMatrix &m2)
 
GslMatrix operator- (const GslMatrix &m1, const GslMatrix &m2)
 
GslMatrix matrixProduct (const GslVector &v1, const GslVector &v2)
 
GslMatrix leftDiagScaling (const GslVector &vec, const GslMatrix &mat)
 
GslMatrix rightDiagScaling (const GslMatrix &mat, const GslVector &vec)
 
std::ostream & operator<< (std::ostream &os, const GslMatrix &obj)
 
GslVector operator/ (double a, const GslVector &x)
 
GslVector operator/ (const GslVector &x, const GslVector &y)
 
GslVector operator* (double a, const GslVector &x)
 
GslVector operator* (const GslVector &x, const GslVector &y)
 
double scalarProduct (const GslVector &x, const GslVector &y)
 
GslVector operator+ (const GslVector &x, const GslVector &y)
 
GslVector operator- (const GslVector &x, const GslVector &y)
 
bool operator== (const GslVector &lhs, const GslVector &rhs)
 
std::ostream & operator<< (std::ostream &os, const GslVector &obj)
 
std::ostream & operator<< (std::ostream &os, const InfiniteDimensionalMCMCSamplerOptions &opts)
 
template<class T >
double SubF1F2Gaussian2dKdeIntegral (const ScalarSequence< T > &scalarSeq1, const ScalarSequence< T > &scalarSeq2, unsigned int initialPos, double scaleValue1, double scaleValue2, const Base1D1DFunction &func1, const Base1D1DFunction &func2, unsigned int quadratureOrder)
 Calculates the integral of a 2D Gaussian KDE. More...
 
template<class V , class M >
void CovCond (double condNumber, const V &direction, M &covMatrix, M &precMatrix)
 
void MiscReadDoublesFromString (const std::string &inputString, std::vector< double > &outputDoubles)
 
void MiscReadWordsFromString (const std::string &inputString, std::vector< std::string > &outputWords)
 
int MiscReadStringAndDoubleFromFile (std::ifstream &ifs, std::string &termString, double *termValue)
 
int MiscReadCharsAndDoubleFromFile (std::ifstream &ifs, std::string &termString, double *termValue, bool &endOfLineAchieved)
 
double MiscGammar (double a, double b, const RngBase *rngObject)
 
double MiscGetEllapsedSeconds (struct timeval *timeval0)
 
double MiscHammingWindow (unsigned int N, unsigned int j)
 
double MiscGaussianDensity (double x, double mu, double sigma)
 
unsigned int MiscUintDebugMessage (unsigned int value, const char *message)
 
int MiscIntDebugMessage (int value, const char *message)
 
double MiscDoubleDebugMessage (double value, const char *message)
 
int CheckFilePath (const char *path)
 
int GRVY_CheckDir (const char *dirname)
 
template<class T >
bool MiscCheckForSameValueInAllNodes (T &inputValue, double acceptableTreshold, const MpiComm &comm, const char *whereString)
 
template<class V >
void MiscComputePositionsBetweenMinMax (V minValues, V maxValues, std::vector< V * > &positions)
 
template<class V1 , class V2 >
void MiscCheckTheParallelEnvironment (const V1 &vec1, const V2 &vec2)
 
template<class V , class M >
std::ostream & operator<< (std::ostream &os, const ArrayOfOneDTables< V, M > &obj)
 
template<class V , class M >
std::ostream & operator<< (std::ostream &os, const AsciiTable< V, M > &obj)
 
template<class V , class M >
VectorSet< V, M > * InstantiateIntersection (const VectorSet< V, M > &domain1, const VectorSet< V, M > &domain2)
 This method calculates the intersection of domain1 and domain2. More...
 
template<class T >
void ComputeSubGaussian2dKde (const ScalarSequence< T > &scalarSeq1, const ScalarSequence< T > &scalarSeq2, unsigned int initialPos, double scaleValue1, double scaleValue2, const std::vector< T > &evaluationPositions1, const std::vector< T > &evaluationPositions2, std::vector< double > &densityValues)
 
template<class T >
void ComputeUnifiedGaussian2dKde (bool useOnlyInter0Comm, const ScalarSequence< T > &scalarSeq1, const ScalarSequence< T > &scalarSeq2, unsigned int initialPos, double unifiedScaleValue1, double unifiedScaleValue2, const std::vector< T > &unifiedEvaluationPositions1, const std::vector< T > &unifiedEvaluationPositions2, std::vector< double > &unifiedDensityValues)
 
template<class T >
void ComputeCovCorrBetweenScalarSequences (const ScalarSequence< T > &subPSeq, const ScalarSequence< T > &subQSeq, unsigned int subNumSamples, T &covValue, T &corrValue)
 
template<class P_V , class P_M , class Q_V , class Q_M >
void ComputeCovCorrMatricesBetweenVectorSequences (const BaseVectorSequence< P_V, P_M > &subPSeq, const BaseVectorSequence< Q_V, Q_M > &subQSeq, unsigned int subNumSamples, P_M &pqCovMatrix, P_M &pqCorrMatrix)
 
template<class V , class M >
void ComputeConditionalGaussianVectorRV (const V &muVec1, const V &muVec2, const M &sigmaMat11, const M &sigmaMat12, const M &sigmaMat21, const M &sigmaMat22, const V &sampleVec2, V &muVec1_cond_on_2, M &sigmaMat11_cond_on_2)
 
std::ostream & operator<< (std::ostream &os, const MetropolisHastingsSGOptions &obj)
 
std::ostream & operator<< (std::ostream &os, const MLSamplingLevelOptions &obj)
 
std::ostream & operator<< (std::ostream &os, const MLSamplingOptions &obj)
 
std::ostream & operator<< (std::ostream &os, const MonteCarloSGOptions &obj)
 Prints the object obj, overloading an operator. More...
 
template<class T >
double horizontalDistance (const BaseScalarCdf< T > &cdf1, const BaseScalarCdf< T > &cdf2, double epsilon)
 It calculated the maximum horizontal distance between two CDFs. More...
 
std::ostream & operator<< (std::ostream &os, const StatisticalForwardProblemOptions &obj)
 Prints the object obj, overloading an operator. More...
 
std::ostream & operator<< (std::ostream &os, const StatisticalInverseProblemOptions &obj)
 Prints the object obj, overloading an operator. More...
 
template<class V , class M >
void horizontalDistances (const BaseVectorCdf< V, M > &cdf1, const BaseVectorCdf< V, M > &cdf2, const V &epsilonVec, V &distances)
 It calculated the maximum horizontal distances between two vector CDFs. More...
 
template<class P_V , class P_M , class Q_V , class Q_M >
void ComputeCovCorrMatricesBetweenVectorRvs (const BaseVectorRV< P_V, P_M > &paramRv, const BaseVectorRV< Q_V, Q_M > &qoiRv, unsigned int localNumSamples, P_M &pqCovMatrix, P_M &pqCorrMatrix)
 
template<class P_V , class P_M >
std::ostream & operator<< (std::ostream &os, const MLSampling< P_V, P_M > &obj)
 

Variables

const int UQ_UNAVAILABLE_RANK = -1
 
const int UQ_OK_RC = 0
 
const int UQ_INCOMPLETE_IMPLEMENTATION_RC = -1
 
const int UQ_INVALID_PARAMETER_SPEC_RC = -2
 
const int UQ_INVALID_OBSERVABLE_SPEC_RC = -3
 
const int UQ_INVALID_QOI_SPEC_RC = -4
 
const int UQ_INVALID_INTERNAL_RESULT_RC = -5
 
const int UQ_INVALID_INTERNAL_STATE_RC = -6
 
const int UQ_FAILED_TO_OPEN_FILE_RC = -7
 
const int UQ_MATRIX_IS_NOT_POS_DEFINITE_RC = -8
 
const int UQ_FAILED_READING_FILE_RC = -9
 
const int UQ_INVALID_SPACE_COMPONENT_ID_RC = -10
 
const int UQ_MATRIX_SVD_FAILED_RC = -11
 
std::terminate_handler old_terminate_handler
 

Typedef Documentation

typedef MPI_Comm QUESO::RawType_MPI_Comm

Definition at line 38 of file MpiComm.h.

typedef MPI_Datatype QUESO::RawType_MPI_Datatype

Definition at line 40 of file MpiComm.h.

typedef MPI_Group QUESO::RawType_MPI_Group

Definition at line 39 of file MpiComm.h.

typedef MPI_Op QUESO::RawType_MPI_Op

Definition at line 41 of file MpiComm.h.

typedef MPI_Status QUESO::RawType_MPI_Status

Definition at line 42 of file MpiComm.h.

Function Documentation

int QUESO::CheckFilePath ( const char *  pathname)

int CheckFilePath(const char *path) {

// verify parent directories in path exist (and create if not).

ifdef HAVE_GRVY return(grvy_check_file_path(path)); else

return 0; endif }

Definition at line 367 of file Miscellaneous.C.

References GRVY_CheckDir().

Referenced by QUESO::FullEnvironment::FullEnvironment(), QUESO::BaseEnvironment::openInputFile(), QUESO::BaseEnvironment::openOutputFile(), QUESO::BaseEnvironment::openUnifiedInputFile(), and QUESO::BaseEnvironment::openUnifiedOutputFile().

368  {
369 
370  // verify parent directories in path exist (and create if not).
371 
372 #ifdef HAVE_GRVY
373  return(grvy_check_file_path(pathname));
374 #else
375 
376  const int MAX_DEPTH = 50;
377 
378  char *pathlocal;
379  char *parents;
380  char *dirstring;
381  char *token;
382  int depth = 0;
383 
384  // Save a copy of pathname and look for the parent directories.
385 
386  pathlocal = strdup(pathname);
387  dirstring = strdup(pathname);
388  parents = dirname(pathlocal);
389 
390  if(strcmp(parents,".") == 0)
391  {
392  free(pathlocal);
393  free(dirstring);
394  return 0;
395  }
396 
397  // Deal with the possibility of an absolute path being provided
398 
399  bool abs_path = false;
400 
401  std::string leading_char("");
402  std::string path_to_check;
403 
404  if(strncmp(parents,"/",1) == 0)
405  {
406  leading_char = "/";
407  abs_path = true;
408  }
409 
410  // Verify existence of top-level directory
411 
412  if( (token = strtok(parents,"/")) != NULL )
413  {
414  path_to_check += leading_char + token;
415 
416  if ( GRVY_CheckDir(path_to_check.c_str()) )
417  {
418  free(pathlocal);
419  free(dirstring);
420  return -1;
421  }
422 
423  // Now, search for any remaining parent directories.
424 
425  if(abs_path)
426  sprintf(dirstring,"/%s",token);
427  else
428  sprintf(dirstring,"%s",token);
429 
430  while ( (token = strtok(0,"/")) && (depth < MAX_DEPTH) )
431  {
432  dirstring = strcat(dirstring,"/");
433 
434  if(GRVY_CheckDir(strcat(dirstring,token)))
435  {
436  free(pathlocal);
437  free(dirstring);
438  return -1;
439  }
440  depth++;
441  };
442 
443  if(depth >= MAX_DEPTH )
444  {
445  std::cerr << __func__ << ": error - Max directory depth exceeded, limit = " << MAX_DEPTH << std::endl;
446  free(pathlocal);
447  free(dirstring);
448  return -1;
449  }
450  }
451 
452  // Clean Up
453  free(pathlocal);
454  free(dirstring);
455 
456  return 0;
457 #endif
458  }
int GRVY_CheckDir(const char *dirname)
template<class V , class M >
void QUESO::ComputeConditionalGaussianVectorRV ( const V &  muVec1,
const V &  muVec2,
const M &  sigmaMat11,
const M &  sigmaMat12,
const M &  sigmaMat21,
const M &  sigmaMat22,
const V &  sampleVec2,
V &  muVec1_cond_on_2,
M &  sigmaMat11_cond_on_2 
)

Definition at line 214 of file GaussianVectorRV.C.

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

224 {
225  const BaseEnvironment& env = muVec1.env();
226  unsigned int dim1 = muVec1.sizeLocal();
227  unsigned int dim2 = muVec2.sizeLocal();
228 
229  UQ_FATAL_TEST_MACRO((sigmaMat11.numRowsLocal() != dim1) || (sigmaMat11.numCols() != dim1),
230  env.worldRank(),
231  "ComputeConditionalGaussianVectorRV()",
232  "invalid sigmaMat11");
233 
234  UQ_FATAL_TEST_MACRO((sigmaMat12.numRowsLocal() != dim1) || (sigmaMat12.numCols() != dim2),
235  env.worldRank(),
236  "ComputeConditionalGaussianVectorRV()",
237  "invalid sigmaMat12");
238 
239  UQ_FATAL_TEST_MACRO((sigmaMat21.numRowsLocal() != dim2) || (sigmaMat21.numCols() != dim1),
240  env.worldRank(),
241  "ComputeConditionalGaussianVectorRV()",
242  "invalid sigmaMat21");
243 
244  UQ_FATAL_TEST_MACRO((sigmaMat22.numRowsLocal() != dim2) || (sigmaMat22.numCols() != dim2),
245  env.worldRank(),
246  "ComputeConditionalGaussianVectorRV()",
247  "invalid sigmaMat22");
248 
249  // Check transpose operation
250  M mat_tt(sigmaMat12);
251  mat_tt.cwSet(0.);
252  mat_tt.fillWithTranspose(0,0,sigmaMat21,true,true);
253  double auxNorm = (mat_tt - sigmaMat12).normFrob();
254  if (auxNorm >= 1.e-12) {
255  if (env.subDisplayFile()) {
256  *env.subDisplayFile() << "In ComputeConditionalGaussianVectorRV()"
257  << ": WARNING, ||sigmaMat21^T - sigmaMat12||_2 = " << auxNorm
258  << std::endl;
259  }
260  }
261  UQ_FATAL_TEST_MACRO(auxNorm >= 1.e-12,
262  env.worldRank(),
263  "ComputeConditionalGaussianVectorRV()",
264  "sigmaMat12 and sigmaMat21 are not transpose of each other");
265 
266  UQ_FATAL_TEST_MACRO((sampleVec2.sizeLocal() != dim2),
267  env.worldRank(),
268  "ComputeConditionalGaussianVectorRV()",
269  "invalid sampleVec2");
270 
271  UQ_FATAL_TEST_MACRO((muVec1_cond_on_2.sizeLocal() != dim1),
272  env.worldRank(),
273  "ComputeConditionalGaussianVectorRV()",
274  "invalid muVec1_cond_on_2");
275 
276  UQ_FATAL_TEST_MACRO((sigmaMat11_cond_on_2.numRowsLocal() != dim1) || (sigmaMat11_cond_on_2.numCols() != dim1),
277  env.worldRank(),
278  "ComputeConditionalGaussianVectorRV()",
279  "invalid sigmaMat11_cond_on_2");
280 
281  muVec1_cond_on_2 = muVec1 + sigmaMat12 * sigmaMat22.invertMultiply(sampleVec2 - muVec2);
282  sigmaMat11_cond_on_2 = sigmaMat11 - sigmaMat12 * sigmaMat22.invertMultiply(sigmaMat21);
283 
284  return;
285 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
template<class T >
void QUESO::ComputeCovCorrBetweenScalarSequences ( const ScalarSequence< T > &  subPSeq,
const ScalarSequence< T > &  subQSeq,
unsigned int  subNumSamples,
T &  covValue,
T &  corrValue 
)

Definition at line 4287 of file ScalarSequence.C.

References QUESO::MpiComm::Allreduce(), QUESO::ScalarSequence< T >::env(), QUESO::BaseEnvironment::inter0Comm(), QUESO::BaseEnvironment::inter0Rank(), RawValue_MPI_DOUBLE, RawValue_MPI_SUM, RawValue_MPI_UNSIGNED, QUESO::ScalarSequence< T >::subSequenceSize(), QUESO::ScalarSequence< T >::unifiedMeanExtra(), QUESO::ScalarSequence< T >::unifiedSampleVarianceExtra(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

Referenced by ComputeSubGaussian2dKde().

4293 {
4294  // Check input data consistency
4295  const BaseEnvironment& env = subPSeq.env();
4296 
4297  UQ_FATAL_TEST_MACRO((subNumSamples > subPSeq.subSequenceSize()) || (subNumSamples > subQSeq.subSequenceSize()),
4298  env.worldRank(),
4299  "ComputeCovCorrBetweenScalarSequences()",
4300  "subNumSamples is too large");
4301 
4302  // For both P and Q vector sequences: fill them
4303  T tmpP = 0.;
4304  T tmpQ = 0.;
4305 
4306  // For both P and Q vector sequences: compute the unified mean
4307  T unifiedMeanP = subPSeq.unifiedMeanExtra(true,0,subNumSamples);
4308  T unifiedMeanQ = subQSeq.unifiedMeanExtra(true,0,subNumSamples);
4309 
4310  // Compute "sub" covariance matrix
4311  covValue = 0.;
4312  for (unsigned k = 0; k < subNumSamples; ++k) {
4313  // For both P and Q vector sequences: get the difference (wrt the unified mean) in them
4314  tmpP = subPSeq[k] - unifiedMeanP;
4315  tmpQ = subQSeq[k] - unifiedMeanQ;
4316  covValue += tmpP*tmpQ;
4317  }
4318 
4319  // For both P and Q vector sequences: compute the unified variance
4320  T unifiedSampleVarianceP = subPSeq.unifiedSampleVarianceExtra(true,
4321  0,
4322  subNumSamples,
4323  unifiedMeanP);
4324 
4325  T unifiedSampleVarianceQ = subQSeq.unifiedSampleVarianceExtra(true,
4326  0,
4327  subNumSamples,
4328  unifiedMeanQ);
4329 
4330  // Compute unified covariance
4331  if (env.inter0Rank() >= 0) {
4332  unsigned int unifiedNumSamples = 0;
4333  env.inter0Comm().Allreduce((void *) &subNumSamples, (void *) &unifiedNumSamples, (int) 1, RawValue_MPI_UNSIGNED, RawValue_MPI_SUM,
4334  "ComputeCovCorrBetweenScalarSequences()",
4335  "failed MPI.Allreduce() for subNumSamples");
4336 
4337  double aux = 0.;
4338  env.inter0Comm().Allreduce((void *) &covValue, (void *) &aux, (int) 1, RawValue_MPI_DOUBLE, RawValue_MPI_SUM,
4339  "ComputeCovCorrBetweenScalarSequences()",
4340  "failed MPI.Allreduce() for a matrix position");
4341  covValue = aux/((double) (unifiedNumSamples-1)); // Yes, '-1' in order to compensate for the 'N-1' denominator factor in the calculations of sample variances above (whose square roots will be used below)
4342 
4343  corrValue = covValue/std::sqrt(unifiedSampleVarianceP)/std::sqrt(unifiedSampleVarianceQ);
4344 
4345  if ((corrValue < -1.) || (corrValue > 1.)) { // prudencio 2010-07-23
4346  std::cerr << "In ComputeCovCorrBetweenScalarSequences()"
4347  << ": computed correlation is out of range, corrValue = " << corrValue
4348  << std::endl;
4349  }
4350  //UQ_FATAL_TEST_MACRO((corrValue < -1.) || (corrValue > 1.),
4351  // env.worldRank(),
4352  // "ComputeCovCorrBetweenScalarSequences()",
4353  // "computed correlation is out of range");
4354  }
4355  else {
4356  // Node not in the 'inter0' communicator: do nothing extra
4357  }
4358 
4359  return;
4360 }
#define RawValue_MPI_DOUBLE
Definition: MpiComm.h:48
#define RawValue_MPI_UNSIGNED
Definition: MpiComm.h:49
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
#define RawValue_MPI_SUM
Definition: MpiComm.h:52
template<class P_V , class P_M , class Q_V , class Q_M >
void QUESO::ComputeCovCorrMatricesBetweenVectorRvs ( const BaseVectorRV< P_V, P_M > &  paramRv,
const BaseVectorRV< Q_V, Q_M > &  qoiRv,
unsigned int  localNumSamples,
P_M &  pqCovMatrix,
P_M &  pqCorrMatrix 
)

Definition at line 213 of file VectorRV.C.

References ComputeCovCorrMatricesBetweenVectorSequences(), QUESO::BaseVectorRV< V, M >::env(), QUESO::BaseVectorRV< V, M >::imageSet(), QUESO::VectorSpace< V, M >::numOfProcsForStorage(), QUESO::BaseVectorRealizer< V, M >::realization(), QUESO::BaseVectorRV< V, M >::realizer(), UQ_FATAL_TEST_MACRO, QUESO::VectorSet< V, M >::vectorSpace(), QUESO::BaseEnvironment::worldRank(), and QUESO::VectorSpace< V, M >::zeroVector().

219 {
220  // Check input data consistency
221  const BaseEnvironment& env = paramRv.env();
222 
223  bool useOnlyInter0Comm = (paramRv.imageSet().vectorSpace().numOfProcsForStorage() == 1) &&
224  (qoiRv.imageSet().vectorSpace().numOfProcsForStorage() == 1);
225 
226  UQ_FATAL_TEST_MACRO((useOnlyInter0Comm == false),
227  env.worldRank(),
228  "ComputeCovCorrMatricesBetweenVectorRvs()",
229  "parallel vectors not supported yet");
230 
231  unsigned int numRows = paramRv.imageSet().vectorSpace().dim();
232  unsigned int numCols = qoiRv.imageSet().vectorSpace().dim();
233 
234  UQ_FATAL_TEST_MACRO((numRows != pqCovMatrix.numRows()) || (numCols != pqCovMatrix.numCols()),
235  env.worldRank(),
236  "ComputeCovCorrMatricesBetweenVectorRvs()",
237  "inconsistent dimensions for covariance matrix");
238 
239  UQ_FATAL_TEST_MACRO((numRows != pqCorrMatrix.numRows()) || (numCols != pqCorrMatrix.numCols()),
240  env.worldRank(),
241  "ComputeCorrelationBetweenVectorRvs()",
242  "inconsistent dimensions for correlation matrix");
243 
244  UQ_FATAL_TEST_MACRO((localNumSamples > paramRv.realizer().period()) || (localNumSamples > qoiRv.realizer().period()),
245  env.worldRank(),
246  "ComputeCovCorrMatricesBetweenVectorRvs()",
247  "localNumSamples is too large");
248 
249  // For both P and Q vector sequences: fill them
250  P_V tmpP(paramRv.imageSet().vectorSpace().zeroVector());
251  Q_V tmpQ(qoiRv.imageSet().vectorSpace().zeroVector());
252 
253  SequenceOfVectors<P_V,P_M> localWorkingPSeq(paramRv.imageSet().vectorSpace(),
254  localNumSamples,
255  "covTmpP");
256  SequenceOfVectors<Q_V,Q_M> localWorkingQSeq(qoiRv.imageSet().vectorSpace(),
257  localNumSamples,
258  "covTmpQ");
259  for (unsigned int k = 0; k < localNumSamples; ++k) {
260  paramRv.realizer().realization(tmpP);
261  localWorkingPSeq.setPositionValues(k,tmpP);
262 
263  qoiRv.realizer().realization(tmpQ);
264  localWorkingQSeq.setPositionValues(k,tmpQ);
265  }
266 
268  localWorkingQSeq,
269  localNumSamples,
270  pqCovMatrix,
271  pqCorrMatrix);
272 
273  return;
274 }
const V & zeroVector() const
Returns a vector filled with zeros.
Definition: VectorSpace.C:218
virtual const VectorSpace< V, M > & vectorSpace() const =0
Vector space to which this set belongs to. See template specialization.
const BaseEnvironment & env() const
QUESO environment; access to private attribute m_env.
Definition: VectorRV.C:72
unsigned int numOfProcsForStorage() const
Returns total number of processes.
Definition: VectorSpace.C:193
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
virtual void realization(V &nextValues) const =0
Performs a realization (sample) from a probability density function. See template specialization...
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
Definition: VectorRV.C:79
void ComputeCovCorrMatricesBetweenVectorSequences(const BaseVectorSequence< P_V, P_M > &subPSeq, const BaseVectorSequence< Q_V, Q_M > &subQSeq, unsigned int subNumSamples, P_M &pqCovMatrix, P_M &pqCorrMatrix)
const BaseVectorRealizer< V, M > & realizer() const
Finds a realization (sample) of the PDF of this vector RV; access to private attribute m_realizer...
Definition: VectorRV.C:98
template<class P_V , class P_M , class Q_V , class Q_M >
void QUESO::ComputeCovCorrMatricesBetweenVectorSequences ( const BaseVectorSequence< P_V, P_M > &  subPSeq,
const BaseVectorSequence< Q_V, Q_M > &  subQSeq,
unsigned int  subNumSamples,
P_M &  pqCovMatrix,
P_M &  pqCorrMatrix 
)

Definition at line 2651 of file VectorSequence.C.

References QUESO::MpiComm::Allreduce(), QUESO::MpiComm::Barrier(), QUESO::VectorSpace< V, M >::dimGlobal(), QUESO::VectorSpace< V, M >::dimLocal(), QUESO::BaseVectorSequence< V, M >::getPositionValues(), QUESO::BaseEnvironment::inter0Comm(), QUESO::BaseEnvironment::inter0Rank(), QUESO::VectorSpace< V, M >::numOfProcsForStorage(), RawValue_MPI_DOUBLE, RawValue_MPI_SUM, RawValue_MPI_UNSIGNED, QUESO::BaseVectorSequence< V, M >::subSequenceSize(), QUESO::BaseVectorSequence< V, M >::unifiedMeanExtra(), QUESO::BaseVectorSequence< V, M >::unifiedSampleVarianceExtra(), UQ_FATAL_TEST_MACRO, QUESO::BaseVectorSequence< V, M >::vectorSpace(), QUESO::BaseEnvironment::worldRank(), and QUESO::VectorSpace< V, M >::zeroVector().

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

2657 {
2658  // Check input data consistency
2659  const BaseEnvironment& env = subPSeq.vectorSpace().zeroVector().env();
2660 
2661  bool useOnlyInter0Comm = (subPSeq.vectorSpace().numOfProcsForStorage() == 1) &&
2662  (subQSeq.vectorSpace().numOfProcsForStorage() == 1);
2663 
2664  UQ_FATAL_TEST_MACRO((useOnlyInter0Comm == false),
2665  env.worldRank(),
2666  "ComputeCovCorrMatricesBetweenVectorSequences()",
2667  "parallel vectors not supported yet");
2668 
2669  unsigned int numRowsLocal = subPSeq.vectorSpace().dimLocal();
2670  unsigned int numCols = subQSeq.vectorSpace().dimGlobal();
2671 
2672  UQ_FATAL_TEST_MACRO((numRowsLocal != pqCovMatrix.numRowsLocal()) || (numCols != pqCovMatrix.numCols()),
2673  env.worldRank(),
2674  "ComputeCovCorrMatricesBetweenVectorSequences()",
2675  "inconsistent dimensions for covariance matrix");
2676 
2677  UQ_FATAL_TEST_MACRO((numRowsLocal != pqCorrMatrix.numRowsLocal()) || (numCols != pqCorrMatrix.numCols()),
2678  env.worldRank(),
2679  "ComputeCorrelationBetweenVectorSequences()",
2680  "inconsistent dimensions for correlation matrix");
2681 
2682  UQ_FATAL_TEST_MACRO((subNumSamples > subPSeq.subSequenceSize()) || (subNumSamples > subQSeq.subSequenceSize()),
2683  env.worldRank(),
2684  "ComputeCovCorrMatricesBetweenVectorSequences()",
2685  "subNumSamples is too large");
2686 
2687  // For both P and Q vector sequences: fill them
2688  P_V tmpP(subPSeq.vectorSpace().zeroVector());
2689  Q_V tmpQ(subQSeq.vectorSpace().zeroVector());
2690 
2691  // For both P and Q vector sequences: compute the unified mean
2692  P_V unifiedMeanP(subPSeq.vectorSpace().zeroVector());
2693  subPSeq.unifiedMeanExtra(0,subNumSamples,unifiedMeanP);
2694 
2695  Q_V unifiedMeanQ(subQSeq.vectorSpace().zeroVector());
2696  subQSeq.unifiedMeanExtra(0,subNumSamples,unifiedMeanQ);
2697 
2698  // Compute "sub" covariance matrix
2699  for (unsigned i = 0; i < numRowsLocal; ++i) {
2700  for (unsigned j = 0; j < numCols; ++j) {
2701  pqCovMatrix(i,j) = 0.;
2702  }
2703  }
2704  for (unsigned k = 0; k < subNumSamples; ++k) {
2705  // For both P and Q vector sequences: get the difference (wrt the unified mean) in them
2706  subPSeq.getPositionValues(k,tmpP);
2707  tmpP -= unifiedMeanP;
2708 
2709  subQSeq.getPositionValues(k,tmpQ);
2710  tmpQ -= unifiedMeanQ;
2711 
2712  for (unsigned i = 0; i < numRowsLocal; ++i) {
2713  for (unsigned j = 0; j < numCols; ++j) {
2714  pqCovMatrix(i,j) += tmpP[i]*tmpQ[j];
2715  }
2716  }
2717  }
2718 
2719  // For both P and Q vector sequences: compute the unified variance
2720  P_V unifiedSampleVarianceP(subPSeq.vectorSpace().zeroVector());
2721  subPSeq.unifiedSampleVarianceExtra(0,
2722  subNumSamples,
2723  unifiedMeanP,
2724  unifiedSampleVarianceP);
2725 
2726  Q_V unifiedSampleVarianceQ(subQSeq.vectorSpace().zeroVector());
2727  subQSeq.unifiedSampleVarianceExtra(0,
2728  subNumSamples,
2729  unifiedMeanQ,
2730  unifiedSampleVarianceQ);
2731 
2732  // Compute unified covariance matrix
2733  if (useOnlyInter0Comm) {
2734  if (env.inter0Rank() >= 0) {
2735  unsigned int unifiedNumSamples = 0;
2736  env.inter0Comm().Allreduce((void *) &subNumSamples, (void *) &unifiedNumSamples, (int) 1, RawValue_MPI_UNSIGNED, RawValue_MPI_SUM,
2737  "ComputeCovCorrMatricesBetweenVectorSequences()",
2738  "failed MPI.Allreduce() for subNumSamples");
2739 
2740  for (unsigned i = 0; i < numRowsLocal; ++i) {
2741  for (unsigned j = 0; j < numCols; ++j) {
2742  double aux = 0.;
2743  env.inter0Comm().Allreduce((void *) &pqCovMatrix(i,j), (void *) &aux, (int) 1, RawValue_MPI_DOUBLE, RawValue_MPI_SUM,
2744  "ComputeCovCorrMatricesBetweenVectorSequences()",
2745  "failed MPI.Allreduce() for a matrix position");
2746  pqCovMatrix(i,j) = aux/((double) (unifiedNumSamples-1)); // Yes, '-1' in order to compensate for the 'N-1' denominator factor in the calculations of sample variances above (whose square roots will be used below)
2747  }
2748  }
2749 
2750  for (unsigned i = 0; i < numRowsLocal; ++i) {
2751  for (unsigned j = 0; j < numCols; ++j) {
2752  pqCorrMatrix(i,j) = pqCovMatrix(i,j)/std::sqrt(unifiedSampleVarianceP[i])/std::sqrt(unifiedSampleVarianceQ[j]);
2753  if (((pqCorrMatrix(i,j) + 1.) < -1.e-8) ||
2754  ((pqCorrMatrix(i,j) - 1.) > 1.e-8)) {
2755  if (env.inter0Rank() == 0) {
2756  std::cerr << "In ComputeCovCorrMatricesBetweenVectorSequences()"
2757  << ": worldRank = " << env.worldRank()
2758  << ", i = " << i
2759  << ", j = " << j
2760  << ", pqCorrMatrix(i,j)+1 = " << pqCorrMatrix(i,j)+1.
2761  << ", pqCorrMatrix(i,j)-1 = " << pqCorrMatrix(i,j)-1.
2762  << std::endl;
2763  }
2764  env.inter0Comm().Barrier();
2765  }
2766  UQ_FATAL_TEST_MACRO(((pqCorrMatrix(i,j) + 1.) < -1.e-8) ||
2767  ((pqCorrMatrix(i,j) - 1.) > 1.e-8),
2768  env.worldRank(),
2769  "ComputeCovCorrMatricesBetweenVectorSequences()",
2770  "computed correlation is out of range");
2771  }
2772  }
2773  }
2774  else {
2775  // Node not in the 'inter0' communicator: do nothing extra
2776  }
2777  }
2778  else {
2779  UQ_FATAL_TEST_MACRO((useOnlyInter0Comm == false),
2780  env.worldRank(),
2781  "ComputeCovCorrMatricesBetweenVectorSequences()",
2782  "parallel vectors not supported yet (2)");
2783  }
2784 
2785  return;
2786 }
unsigned int dimGlobal() const
Definition: VectorSpace.C:205
#define RawValue_MPI_DOUBLE
Definition: MpiComm.h:48
#define RawValue_MPI_UNSIGNED
Definition: MpiComm.h:49
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 ...
const V & zeroVector() const
Returns a vector filled with zeros.
Definition: VectorSpace.C:218
unsigned int dimLocal() const
Definition: VectorSpace.C:199
unsigned int numOfProcsForStorage() const
Returns total number of processes.
Definition: VectorSpace.C:193
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
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...
virtual void getPositionValues(unsigned int posId, V &vec) const =0
Gets the values of the sequence at position posId and stores them at vec. See template specialization...
#define RawValue_MPI_SUM
Definition: MpiComm.h:52
const VectorSpace< V, M > & vectorSpace() const
Vector space; access to protected attribute VectorSpace&lt;V,M&gt;&amp; m_vectorSpace.
virtual unsigned int subSequenceSize() const =0
Size of the sub-sequence of vectors. See template specialization.
template<class T >
void QUESO::ComputeSubGaussian2dKde ( const ScalarSequence< T > &  scalarSeq1,
const ScalarSequence< T > &  scalarSeq2,
unsigned int  initialPos,
double  scaleValue1,
double  scaleValue2,
const std::vector< T > &  evaluationPositions1,
const std::vector< T > &  evaluationPositions2,
std::vector< double > &  densityValues 
)

Definition at line 4166 of file ScalarSequence.C.

References ComputeCovCorrBetweenScalarSequences(), QUESO::ScalarSequence< T >::env(), QUESO::ScalarSequence< T >::subSequenceSize(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

Referenced by ComputeUnifiedGaussian2dKde().

4174 {
4175  UQ_FATAL_TEST_MACRO(initialPos != 0,
4176  scalarSeq1.env().worldRank(),
4177  "ComputeSubGaussian2dKde()",
4178  "not implemented yet for initialPos != 0");
4179 
4180  double covValue = 0.;
4181  double corrValue = 0.;
4183  scalarSeq2,
4184  scalarSeq1.subSequenceSize(),
4185  covValue,
4186  corrValue);
4187 
4188  bool bRC = ((initialPos < scalarSeq1.subSequenceSize()) &&
4189  (scalarSeq1.subSequenceSize() == scalarSeq2.subSequenceSize()) &&
4190  (0 < evaluationPositions1.size() ) &&
4191  (evaluationPositions1.size() == evaluationPositions2.size() ) &&
4192  (evaluationPositions1.size() == densityValues.size() ));
4193  UQ_FATAL_TEST_MACRO(bRC == false,
4194  scalarSeq1.env().worldRank(),
4195  "ComputeSubGaussian2dKde()",
4196  "invalid input data");
4197 
4198  unsigned int dataSize = scalarSeq1.subSequenceSize() - initialPos;
4199  unsigned int numEvals = evaluationPositions1.size();
4200 
4201  double scale1Inv = 1./scaleValue1;
4202  double scale2Inv = 1./scaleValue2;
4203  //corrValue = 0.;
4204  double r = 1. - corrValue*corrValue;
4205  if (r <= 0.) { // prudencio 2010-07-23
4206  std::cerr << "In ComputeSubGaussian2dKde()"
4207  << ": WARNING, r = " << r
4208  << std::endl;
4209  }
4210  //UQ_FATAL_TEST_MACRO(r < 0.,
4211  // scalarSeq1.env().worldRank(),
4212  // "ComputeSubGaussian2dKde()",
4213  // "negative r");
4214  for (unsigned int j = 0; j < numEvals; ++j) {
4215  double x1 = evaluationPositions1[j];
4216  double x2 = evaluationPositions2[j];
4217  double value = 0.;
4218  for (unsigned int k = 0; k < dataSize; ++k) {
4219  double d1k = scale1Inv*(x1 - scalarSeq1[initialPos+k]);
4220  double d2k = scale2Inv*(x2 - scalarSeq2[initialPos+k]);
4221  value += exp(-.5*( d1k*d1k + 2*corrValue*d1k*d2k + d2k*d2k )/r);
4222  }
4223  densityValues[j] = scale1Inv * scale2Inv * (value/(double) dataSize) / 2. / M_PI / sqrt(r);
4224  }
4225 
4226  return;
4227 }
void ComputeCovCorrBetweenScalarSequences(const ScalarSequence< T > &subPSeq, const ScalarSequence< T > &subQSeq, unsigned int subNumSamples, T &covValue, T &corrValue)
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
template<class T >
void QUESO::ComputeUnifiedGaussian2dKde ( bool  useOnlyInter0Comm,
const ScalarSequence< T > &  scalarSeq1,
const ScalarSequence< T > &  scalarSeq2,
unsigned int  initialPos,
double  unifiedScaleValue1,
double  unifiedScaleValue2,
const std::vector< T > &  unifiedEvaluationPositions1,
const std::vector< T > &  unifiedEvaluationPositions2,
std::vector< double > &  unifiedDensityValues 
)

Definition at line 4231 of file ScalarSequence.C.

References ComputeSubGaussian2dKde(), QUESO::ScalarSequence< T >::env(), QUESO::BaseEnvironment::inter0Rank(), QUESO::BaseEnvironment::numSubEnvironments(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

4240 {
4241  if (scalarSeq1.env().numSubEnvironments() == 1) {
4242  return ComputeSubGaussian2dKde(scalarSeq1,
4243  scalarSeq2,
4244  initialPos,
4245  unifiedScaleValue1,
4246  unifiedScaleValue2,
4247  unifiedEvaluationPositions1,
4248  unifiedEvaluationPositions2,
4249  unifiedDensityValues);
4250  }
4251 
4252  // As of 14/Nov/2009, this routine needs to be checked if it requires sub sequences to have equal size. Good.
4253 
4254  if (useOnlyInter0Comm) {
4255  if (scalarSeq1.env().inter0Rank() >= 0) {
4256  UQ_FATAL_TEST_MACRO(true,
4257  scalarSeq1.env().worldRank(),
4258  "ComputeUnifiedGaussian2dKde()",
4259  "inter0 case not supported yet");
4260  }
4261  else {
4262  // Node not in the 'inter0' communicator
4263  ComputeSubGaussian2dKde(scalarSeq1,
4264  scalarSeq2,
4265  initialPos,
4266  unifiedScaleValue1,
4267  unifiedScaleValue2,
4268  unifiedEvaluationPositions1,
4269  unifiedEvaluationPositions2,
4270  unifiedDensityValues);
4271  }
4272  }
4273  else {
4274  UQ_FATAL_TEST_MACRO(true,
4275  scalarSeq1.env().worldRank(),
4276  "ComputeUnifiedGaussian2dKde()",
4277  "parallel vectors not supported yet");
4278  }
4279 
4280  //scalarSeq1.env().fullComm().Barrier();
4281 
4282  return;
4283 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
void ComputeSubGaussian2dKde(const ScalarSequence< T > &scalarSeq1, const ScalarSequence< T > &scalarSeq2, unsigned int initialPos, double scaleValue1, double scaleValue2, const std::vector< T > &evaluationPositions1, const std::vector< T > &evaluationPositions2, std::vector< double > &densityValues)
template<class V , class M >
void QUESO::CovCond ( double  condNumber,
const V &  direction,
M &  covMatrix,
M &  precMatrix 
)

Definition at line 30 of file CovCond.C.

References leftDiagScaling(), and matrixProduct().

32 {
33  //std::cout << "Entering CovCond()"
34  // << std::endl;
35 
36  V v1(direction);
37  //std::cout << "In CovCond(), v1 contents are:"
38  // << std::endl
39  // << v1
40  // << std::endl;
41 
42  V v2(direction,condNumber,1.0); // MATLAB linspace
43  v2.cwInvert();
44  v2.sort();
45  //std::cout << "In CovCond(), v2 contents are:"
46  // << std::endl
47  // << v2
48  // << std::endl;
49 
50  double v1Norm2 = v1.norm2();
51  if (v1[0] >=0) v1[0] += v1Norm2;
52  else v1[0] -= v1Norm2;
53  double v1Norm2Sq = v1.norm2Sq();
54 
55  M Z(direction,1.0);
56  Z -= (2./v1Norm2Sq) * matrixProduct(v1,v1);
57  //std::cout << "In CovCond(), Z contents are:"
58  // << std::endl
59  // << Z
60  // << std::endl;
61 
62  M Zt(Z.transpose());
63  covMatrix = Z * leftDiagScaling(v2, Zt);
64  precMatrix = Z * leftDiagScaling(1./v2,Zt);
65 
66  //std::cout << "Leaving CovCond()"
67  // << std::endl;
68 }
GslMatrix matrixProduct(const GslVector &v1, const GslVector &v2)
Definition: GslMatrix.C:2409
GslMatrix leftDiagScaling(const GslVector &vec, const GslMatrix &mat)
Definition: GslMatrix.C:2425
int QUESO::GRVY_CheckDir ( const char *  dirname)

Definition at line 461 of file Miscellaneous.C.

Referenced by CheckFilePath().

462 {
463  struct stat st;
464 
465  if(stat(dirname,&st) != 0)
466  {
467  if( mkdir(dirname,0700) != 0 )
468  {
469  std::cerr << __func__ << ": error - unable to create directory " << dirname << std::endl;
470  return -1;
471  }
472  }
473  else if (!S_ISDIR(st.st_mode))
474  {
475  std::cerr << __func__ << ": error - entry exists, but is not a directory " << dirname << std::endl;
476  return -1;
477  }
478 
479  return 0;
480 }
template<class T >
double QUESO::horizontalDistance ( const BaseScalarCdf< T > &  cdf1,
const BaseScalarCdf< T > &  cdf2,
double  epsilon 
)

It calculated the maximum horizontal distance between two CDFs.

Definition at line 96 of file ScalarCdf.C.

References QUESO::BaseEnvironment::displayVerbosity(), QUESO::BaseScalarCdf< T >::env(), QUESO::BaseScalarCdf< T >::inverse(), QUESO::BaseScalarCdf< T >::prefix(), QUESO::BaseEnvironment::subDisplayFile(), and QUESO::BaseScalarCdf< T >::value().

Referenced by horizontalDistances().

99 {
100  double maxDistance = 0.;
101  double xForMaxDistance = 0.;
102 
103  double x1 = cdf1.inverse(epsilon*.5);
104  double x2 = cdf1.inverse(1.-epsilon*.5);
105  if (cdf1.env().subDisplayFile()) {
106  *cdf1.env().subDisplayFile() << "In horizontalDistance()"
107  << ", cdf1.prefix() = " << cdf1.prefix()
108  << ", cdf2.prefix() = " << cdf2.prefix()
109  << ", epsilon = " << epsilon
110  << ": x1 = " << x1
111  << ", x2 = " << x2
112  << std::endl;
113  }
114 
115  //if (cdf1.env().subDisplayFile()) {
116  // *cdf1.env().subDisplayFile() << "In horizontalDistance: x1 = " << x1
117  // << ", x2 = " << x2
118  // << std::endl;
119  //}
120 
121  double numEvaluationPoints = 1001.;
122  for (double i = 0.; i < numEvaluationPoints; ++i) {
123  double ratio = i/(numEvaluationPoints-1.); // IMPORTANT: Yes, '-1.'
124  double x = (1.-ratio)*x1 + ratio*x2;
125  double y = cdf2.inverse(cdf1.value(x));
126  double d = fabs(x-y);
127  if ((cdf1.env().subDisplayFile()) && (cdf1.env().displayVerbosity() >= 3)) {
128  *cdf1.env().subDisplayFile() << "In horizontalDistance"
129  << ": i = " << i
130  << ", x = " << x
131  << ", cdf1.value(x) = " << cdf1.value(x)
132  << ", y = " << y
133  << ", d = " << d
134  << ", currentMaxDistance = " << maxDistance
135  << std::endl;
136  }
137  if (maxDistance < d) {
138  maxDistance = d;
139  xForMaxDistance = x;
140  if ((cdf1.env().subDisplayFile()) && (cdf1.env().displayVerbosity() >= 3)) {
141  *cdf1.env().subDisplayFile() << "In horizontalDistance"
142  << ": i = " << i
143  << ", NOW maxDistance = " << maxDistance
144  << ", xForMaxDistance = " << xForMaxDistance
145  << std::endl;
146  }
147  }
148  }
149 
150  if (cdf1.env().subDisplayFile()) {
151  *cdf1.env().subDisplayFile() << "In horizontalDistance()"
152  << ", cdf1.prefix() = " << cdf1.prefix()
153  << ", cdf2.prefix() = " << cdf2.prefix()
154  << ", epsilon = " << epsilon
155  << ": maxDistance = " << maxDistance
156  << ", xForMaxDistance = " << xForMaxDistance
157  << std::endl;
158  }
159 
160  return maxDistance;
161 }
template<class V , class M >
void QUESO::horizontalDistances ( const BaseVectorCdf< V, M > &  cdf1,
const BaseVectorCdf< V, M > &  cdf2,
const V &  epsilonVec,
V &  distances 
)

It calculated the maximum horizontal distances between two vector CDFs.

Definition at line 89 of file VectorCdf.C.

References QUESO::BaseVectorCdf< V, M >::cdf(), horizontalDistance(), and QUESO::BaseVectorCdf< V, M >::pdfSupport().

93 {
94  for (unsigned int i = 0; i < cdf1.pdfSupport().vectorSpace().dimLocal(); ++i) {
95  distances[i] = horizontalDistance(cdf1.cdf(i),
96  cdf2.cdf(i),
97  epsilonVec[i]);
98  }
99 
100  return;
101 }
double horizontalDistance(const BaseScalarCdf< T > &cdf1, const BaseScalarCdf< T > &cdf2, double epsilon)
It calculated the maximum horizontal distance between two CDFs.
Definition: ScalarCdf.C:96
template<class V , class M >
VectorSet< V, M > * QUESO::InstantiateIntersection ( const VectorSet< V, M > &  domain1,
const VectorSet< V, M > &  domain2 
)

This method calculates the intersection of domain1 and domain2.

It is used, for instance, to calculate the domain of the Posterior PDF, which is the intersection of the domain of the Prior PDF and of the likelihood function.

Definition at line 37 of file InstantiateIntersection.C.

References QUESO::VectorSpace< V, M >::dimGlobal(), QUESO::VectorSet< V, M >::env(), QUESO::VectorSpace< V, M >::env(), QUESO::BoxSubset< V, M >::maxValues(), QUESO::BoxSubset< V, M >::minValues(), QUESO::VectorSet< V, M >::prefix(), UQ_FATAL_TEST_MACRO, QUESO::VectorSubset< V, M >::vectorSpace(), QUESO::VectorSet< V, M >::vectorSpace(), and QUESO::BaseEnvironment::worldRank().

Referenced by QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMetropolisHastings(), and QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMLSampling().

38 {
39  VectorSet<V,M>* result = NULL;
40 
41  unsigned int dim1 = domain1.vectorSpace().dimGlobal();
42  unsigned int dim2 = domain2.vectorSpace().dimGlobal();
43 
44  if (result == NULL) {
45  const VectorSpace<V,M>* tmp1 = dynamic_cast<const VectorSpace<V,M>* >(&domain1);
46  const VectorSpace<V,M>* tmp2 = dynamic_cast<const VectorSpace<V,M>* >(&domain2);
47 
48  if ((tmp1 != NULL) && (tmp2 != NULL)) {
49  if (dim1 < dim2) {
50  result = new VectorSpace<V,M>(tmp1->env(),
51  tmp1->prefix().c_str(),
52  tmp1->dimGlobal(),
53  NULL);//tmp1->componentsNames());
54  }
55  else if (dim1 == dim2) {
56  result = new VectorSpace<V,M>(tmp1->env(),
57  tmp1->prefix().c_str(),
58  tmp1->dimGlobal(),
59  NULL);//tmp1->componentsNames());
60  }
61  else {
62  result = new VectorSpace<V,M>(tmp2->env(),
63  tmp2->prefix().c_str(),
64  tmp2->dimGlobal(),
65  NULL);//tmp2->componentsNames());
66  }
67  }
68  }
69 
70  if (result == NULL) {
71  const VectorSubset<V,M>* tmp1 = dynamic_cast<const VectorSubset<V,M>* >(&domain1);
72  const VectorSubset<V,M>* tmp2 = dynamic_cast<const VectorSubset<V,M>* >(&domain2);
73 
74  if ((tmp1 != NULL) && (tmp2 != NULL)) {
75  if (dim1 == dim2) {
76  const BoxSubset<V,M>* box1 = dynamic_cast<const BoxSubset<V,M>* >(&domain1);
77  const BoxSubset<V,M>* box2 = dynamic_cast<const BoxSubset<V,M>* >(&domain2);
78 
79  if ((box1 != NULL) && (box2 != NULL)) {
80  V minV(box1->minValues());
81  V maxV(box1->maxValues());
82  for (unsigned int i = 0; i < dim1; ++i) {
83  minV[i] = std::max(box1->minValues()[i],
84  box2->minValues()[i]);
85  }
86  for (unsigned int i = 0; i < dim1; ++i) {
87  maxV[i] = std::min(box1->maxValues()[i],
88  box2->maxValues()[i]);
89  }
90  result = new BoxSubset<V,M>(box1->prefix().c_str(),
91  box1->vectorSpace(),
92  minV,
93  maxV);
94  }
95  else {
96  result = new IntersectionSubset<V,M>(tmp1->prefix().c_str(),
97  tmp1->vectorSpace(),
98  0., // FIX ME
99  domain1,
100  domain2);
101  }
102  }
103  else {
104  UQ_FATAL_TEST_MACRO(true,
105  domain1.env().worldRank(),
106  "InstantiateIntersection<V,M>()",
107  "situation 001");
108  }
109  }
110  }
111 
112  if (result == NULL) {
113  const VectorSubset<V,M>* tmp1 = dynamic_cast<const VectorSubset<V,M>* >(&domain1);
114  const VectorSpace <V,M>* tmp2 = dynamic_cast<const VectorSpace <V,M>* >(&domain2);
115 
116  if ((tmp1 != NULL) && (tmp2 != NULL)) {
117  if (dim1 == dim2) {
118  const BoxSubset<V,M>* box1 = dynamic_cast<const BoxSubset<V,M>* >(&domain1);
119  if (box1 != NULL) {
120  result = new BoxSubset<V,M>(box1->prefix().c_str(),
121  box1->vectorSpace(),
122  box1->minValues(),
123  box1->maxValues());
124  }
125  else {
126  UQ_FATAL_TEST_MACRO(true,
127  domain1.env().worldRank(),
128  "InstantiateIntersection<V,M>()",
129  "situation 002");
130  }
131  }
132  else {
133  UQ_FATAL_TEST_MACRO(true,
134  domain1.env().worldRank(),
135  "InstantiateIntersection<V,M>()",
136  "situation 003");
137  }
138  }
139  }
140 
141  if (result == NULL) {
142  const VectorSpace <V,M>* tmp1 = dynamic_cast<const VectorSpace <V,M>* >(&domain1);
143  const VectorSubset<V,M>* tmp2 = dynamic_cast<const VectorSubset<V,M>* >(&domain2);
144 
145  if ((tmp1 != NULL) && (tmp2 != NULL)) {
146  if (dim1 == dim2) {
147  const BoxSubset<V,M>* box2 = dynamic_cast<const BoxSubset<V,M>* >(&domain2);
148  if (box2 != NULL) {
149  result = new BoxSubset<V,M>(box2->prefix().c_str(),
150  box2->vectorSpace(),
151  box2->minValues(),
152  box2->maxValues());
153  }
154  else {
155  UQ_FATAL_TEST_MACRO(true,
156  domain1.env().worldRank(),
157  "InstantiateIntersection<V,M>()",
158  "situation 004");
159  }
160  }
161  else {
162  UQ_FATAL_TEST_MACRO(true,
163  domain1.env().worldRank(),
164  "InstantiateIntersection<V,M>()",
165  "situation 005");
166  }
167  }
168  }
169 
170  if (result == NULL) {
171  UQ_FATAL_TEST_MACRO(true,
172  domain1.env().worldRank(),
173  "InstantiateIntersection<V,M>()",
174  "situation 006");
175  }
176 
177  return result;
178 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
GslMatrix QUESO::leftDiagScaling ( const GslVector &  vec,
const GslMatrix &  mat 
)

Definition at line 2425 of file GslMatrix.C.

References QUESO::Matrix::env(), QUESO::GslMatrix::numCols(), QUESO::GslMatrix::numRowsLocal(), QUESO::GslVector::sizeLocal(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

Referenced by CovCond().

2426 {
2427  unsigned int vSize = vec.sizeLocal();
2428  unsigned int mRows = mat.numRowsLocal();
2429  unsigned int mCols = mat.numCols();
2430 
2431  UQ_FATAL_TEST_MACRO((vSize != mRows),
2432  mat.env().worldRank(),
2433  "GslMatrix leftDiagScaling(vector,matrix)",
2434  "size of vector is different from the number of rows in matrix");
2435 
2436  UQ_FATAL_TEST_MACRO((mCols != mRows),
2437  mat.env().worldRank(),
2438  "GslMatrix leftDiagScaling(vector,matrix)",
2439  "routine currently works for square matrices only");
2440 
2441  GslMatrix answer(mat);
2442  for (unsigned int i = 0; i < mRows; ++i) {
2443  double vecValue = vec[i];
2444  for (unsigned int j = 0; j < mCols; ++j) {
2445  answer(i,j) *= vecValue;
2446  }
2447  }
2448 
2449  return answer;
2450 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
GslMatrix QUESO::matrixProduct ( const GslVector &  v1,
const GslVector &  v2 
)

Definition at line 2409 of file GslMatrix.C.

References QUESO::Vector::env(), QUESO::Vector::map(), and QUESO::GslVector::sizeLocal().

Referenced by CovCond(), QUESO::SequenceOfVectors< V, M >::estimateConvBrooksGelman(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step04_inter0(), and QUESO::MetropolisHastingsSG< P_V, P_M >::updateAdaptedCovMatrix().

2410 {
2411  unsigned int nRows = v1.sizeLocal();
2412  unsigned int nCols = v2.sizeLocal();
2413  GslMatrix answer(v1.env(),v1.map(),nCols);
2414 
2415  for (unsigned int i = 0; i < nRows; ++i) {
2416  double value1 = v1[i];
2417  for (unsigned int j = 0; j < nCols; ++j) {
2418  answer(i,j) = value1*v2[j];
2419  }
2420  }
2421 
2422  return answer;
2423 }
template<class T >
bool QUESO::MiscCheckForSameValueInAllNodes ( T &  inputValue,
double  acceptableTreshold,
const MpiComm &  comm,
const char *  whereString 
)

Definition at line 484 of file Miscellaneous.C.

References QUESO::MpiComm::Allreduce(), QUESO::MpiComm::Barrier(), QUESO::MpiComm::Bcast(), QUESO::MpiComm::MyPID(), QUESO::MpiComm::NumProc(), RawValue_MPI_DOUBLE, RawValue_MPI_SUM, RawValue_MPI_UNSIGNED, UQ_FATAL_TEST_MACRO, and UQ_UNAVAILABLE_RANK.

Referenced by QUESO::MLSampling< P_V, P_M >::generateSequence_Step03_inter0(), and QUESO::MLSampling< P_V, P_M >::generateSequence_Step09_all().

488 {
489  // Filter out those nodes that should not participate
490  if (comm.MyPID() < 0) return true;
491 
492  double localValue = (double) inputValue;
493  double sumValue = 0.;
494  comm.Allreduce((void *) &localValue, (void *) &sumValue, (int) 1, RawValue_MPI_DOUBLE, RawValue_MPI_SUM,
495  whereString,
496  "failed MPI on 'sumValue' inside MiscCheckForSameValueInAllNodes()");
497 
498  double totalNumNodes = (double) comm.NumProc();
499  double testValue = fabs(1. - localValue/(sumValue/totalNumNodes));
500  unsigned int boolSum = 0;
501 #if 1
502  unsigned int boolResult = 0;
503  if (testValue > acceptableTreshold) boolResult = 1;
504  comm.Allreduce((void *) &boolResult, (void *) &boolSum, (int) 1, RawValue_MPI_UNSIGNED, RawValue_MPI_SUM,
505  whereString,
506  "failed MPI on 'boolSum' inside MiscCheckForSameValueInAllNodes()");
507 
508  if (boolSum > 0) {
509  comm.Barrier();
510  for (int i = 0; i < comm.NumProc(); ++i) {
511  if (i == comm.MyPID()) {
512  std::cerr << "WARNING, "
513  << whereString
514  << ", inside MiscCheckForSameValueInAllNodes()"
515  << ", rank (in this communicator) = " << i
516  << ": boolSum = " << boolSum
517  << ", localValue = " << localValue
518  << ", sumValue = " << sumValue
519  << ", totalNumNodes = " << totalNumNodes
520  << ", avgValue = " << (sumValue/totalNumNodes)
521  << ", relativeTest = " << testValue
522  << std::endl;
523  }
524  comm.Barrier();
525  }
526  comm.Barrier();
527 
528  comm.Bcast((void *) &localValue, (int) 1, RawValue_MPI_DOUBLE, 0,
529  whereString,
530  "failed MPI on 'boolSum' inside MiscCheckForSameValueInAllNodes()");
531  inputValue = localValue; // IMPORTANT
532  }
533 #else
534  UQ_FATAL_TEST_MACRO(testValue > acceptableTreshold,
536  whereString,
537  "not all nodes have the same value inside MiscCheckForSameValueInAllNodes()");
538 #endif
539 
540  return (boolSum == 0);
541 }
#define RawValue_MPI_DOUBLE
Definition: MpiComm.h:48
#define RawValue_MPI_UNSIGNED
Definition: MpiComm.h:49
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:73
#define RawValue_MPI_SUM
Definition: MpiComm.h:52
template<class V1 , class V2 >
void QUESO::MiscCheckTheParallelEnvironment ( const V1 &  vec1,
const V2 &  vec2 
)

Definition at line 572 of file Miscellaneous.C.

References QUESO::BaseEnvironment::fullComm(), QUESO::MpiComm::NumProc(), QUESO::BaseEnvironment::numSubEnvironments(), QUESO::BaseEnvironment::subComm(), QUESO::BaseEnvironment::subRank(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

573 {
574  const BaseEnvironment& env = vec1.env();
575 
576  if (env.numSubEnvironments() == (unsigned int) env.fullComm().NumProc()) {
577  UQ_FATAL_TEST_MACRO(env.subRank() != 0,
578  env.worldRank(),
579  "MiscCheckTheParallelEnvironment<V1,V2>()",
580  "there should exist only one processor per sub environment");
581  UQ_FATAL_TEST_MACRO((vec1.numOfProcsForStorage() != 1) ||
582  (vec2.numOfProcsForStorage() != 1),
583  env.worldRank(),
584  "MiscCheckTheParallelEnvironment<V1,V2>()",
585  "only 1 processor (per sub environment) should be necessary for the storage of a parameter vector");
586  }
587  else if (env.numSubEnvironments() < (unsigned int) env.fullComm().NumProc()) {
588  UQ_FATAL_TEST_MACRO(env.fullComm().NumProc()%env.numSubEnvironments() != 0,
589  env.worldRank(),
590  "MiscCheckTheParallelEnvironment<V1,V2>()",
591  "total number of processors should be a multiple of the number of sub environments");
592  unsigned int numProcsPerSubEnvironment = env.fullComm().NumProc()/env.numSubEnvironments();
593  UQ_FATAL_TEST_MACRO(env.subComm().NumProc() != (int) numProcsPerSubEnvironment,
594  env.worldRank(),
595  "MiscCheckTheParallelEnvironment<V1,V2>()",
596  "inconsistent number of processors per sub environment");
597  if ((vec1.numOfProcsForStorage() == 1) &&
598  (vec2.numOfProcsForStorage() == 1)) {
599  // Ok
600  }
601  else if ((vec1.numOfProcsForStorage() == numProcsPerSubEnvironment) &&
602  (vec2.numOfProcsForStorage() == numProcsPerSubEnvironment)) {
603  UQ_FATAL_TEST_MACRO(true,
604  env.worldRank(),
605  "MiscCheckTheParallelEnvironment<V1,V2>()",
606  "parallel vectors are not supported yet");
607  }
608  else {
609  UQ_FATAL_TEST_MACRO(true,
610  env.worldRank(),
611  "MiscCheckTheParallelEnvironment<V1,V2>()",
612  "number of processors required for a vector storage should be equal to either 1 or to the number of processors in the sub environment");
613  }
614  }
615  else {
616  UQ_FATAL_TEST_MACRO(true,
617  env.worldRank(),
618  "MiscCheckTheParallelEnvironment<V1,V2>()",
619  "number of processors per sub environment is less than 1!");
620  }
621 
622  return;
623 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
template<class V >
void QUESO::MiscComputePositionsBetweenMinMax ( minValues,
maxValues,
std::vector< V * > &  positions 
)

Definition at line 545 of file Miscellaneous.C.

548 {
549  double factor = 0.5;
550  switch (positions.size()) {
551  case 0:
552  // Do nothing
553  break;
554 
555  case 1:
556  positions[0] = new V((1. - factor) * minValues + factor * maxValues);
557  break;
558 
559  default:
560  for (unsigned int i = 0; i < positions.size(); ++i) {
561  factor = ((double) i)/(((double) positions.size()) - 1.);
562  positions[i] = new V((1. - factor) * minValues + factor * maxValues);
563  }
564  break;
565  }
566 
567  return;
568 }
double QUESO::MiscDoubleDebugMessage ( double  value,
const char *  message 
)

Definition at line 339 of file Miscellaneous.C.

342 {
343  if (message) {
344  std::cout << "Passing in MiscDoubleDebugMessage(), value = " << value << ", message = " << message << std::endl;
345  }
346  return value;
347 }
double QUESO::MiscGammar ( double  a,
double  b,
const RngBase *  rngObject 
)

Definition at line 253 of file Miscellaneous.C.

References QUESO::RngBase::gaussianSample(), and QUESO::RngBase::uniformSample().

257 {
258  double result = 0.;
259  if (a < 1.) {
260  result = MiscGammar(1.+a,b,rngObject)*std::pow( rngObject->uniformSample(),1./a );
261  }
262  else {
263  double d = a-1./3.;
264  double c = 1./std::sqrt(9.*d);
265  double x = 0.;
266  double w = 0.;
267  while (1) {
268  while (1) {
269  x = rngObject->gaussianSample(1.);
270  w = 1.+c*x;
271  if (w > 0.) break;
272  }
273  w = std::pow(w,3.);
274  double u = rngObject->uniformSample();
275  double compValue = 1.-0.0331*std::pow(x,4.);
276  if (u < compValue) break;
277  compValue = 0.5*std::pow(x,2.)+d*(1.-w+log(w));
278  if (log(u) < compValue) break;
279  }
280  result = b*d*w;
281  }
282 
283  return result;
284 }
double MiscGammar(double a, double b, const RngBase *rngObject)
double QUESO::MiscGaussianDensity ( double  x,
double  mu,
double  sigma 
)

Definition at line 311 of file Miscellaneous.C.

Referenced by QUESO::ArrayOfSequences< V, M >::gaussianKDE(), QUESO::ScalarSequence< T >::subGaussian1dKde(), and QUESO::ScalarSequence< T >::unifiedGaussian1dKde().

312 {
313  double sigma2 = sigma*sigma;
314  double diff = x-mu;
315 
316  return (1./std::sqrt(2*M_PI*sigma2))*std::exp(-.5*diff*diff/sigma2);
317 }
double QUESO::MiscGetEllapsedSeconds ( struct timeval *  timeval0)

Definition at line 287 of file Miscellaneous.C.

Referenced by QUESO::MonteCarloSG< P_V, P_M, Q_V, Q_M >::actualGenerateSequence(), QUESO::MLSampling< P_V, P_M >::generateBalLinkedChains_all(), QUESO::MetropolisHastingsSG< P_V, P_M >::generateFullChain(), QUESO::MLSampling< P_V, P_M >::generateSequence(), QUESO::MLSampling< P_V, P_M >::generateSequence_Level0_all(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step01_inter0(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step02_inter0(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step03_inter0(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step04_inter0(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step05_inter0(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step06_all(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step07_inter0(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step08_all(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step09_all(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step10_all(), QUESO::MLSampling< P_V, P_M >::generateSequence_Step11_inter0(), QUESO::MLSampling< P_V, P_M >::generateUnbLinkedChains_all(), QUESO::MLSampling< P_V, P_M >::justBalance_proc0(), QUESO::SequenceOfVectors< V, M >::unifiedReadContents(), QUESO::ScalarSequence< T >::unifiedReadContents(), QUESO::SequenceOfVectors< V, M >::unifiedWriteContents(), and QUESO::ScalarSequence< T >::unifiedWriteContents().

288 {
289  double result = 0.;
290 
291  struct timeval timevalNow;
292  /*int iRC;*/
293  /*iRC = */gettimeofday(&timevalNow, NULL);
294 
295  result = (double) (timevalNow.tv_sec - timeval0->tv_sec );
296  result *= 1.e+6;
297  result += (double) (timevalNow.tv_usec - timeval0->tv_usec);
298  result *= 1.e-6;
299 
300  return result;
301 }
double QUESO::MiscHammingWindow ( unsigned int  N,
unsigned int  j 
)

Definition at line 303 of file Miscellaneous.C.

304 {
305  double angle = 2.*M_PI*((double) j)/((double) N);
306  double result = 0.53836 - 0.46164*cos(angle);
307 
308  return result;
309 }
int QUESO::MiscIntDebugMessage ( int  value,
const char *  message 
)

Definition at line 329 of file Miscellaneous.C.

332 {
333  if (message) {
334  std::cout << "Passing in MiscIntDebugMessage(), value = " << value << ", message = " << message << std::endl;
335  }
336  return value;
337 }
int QUESO::MiscReadCharsAndDoubleFromFile ( std::ifstream &  ifs,
std::string &  termString,
double *  termValue,
bool &  endOfLineAchieved 
)

Definition at line 196 of file Miscellaneous.C.

References UQ_FAILED_READING_FILE_RC, and UQ_OK_RC.

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

201 {
202  int iRC = UQ_OK_RC;
203  endOfLineAchieved = false;
204 
205  char c = ' ';
206  while (c == ' ') {
207  ifs.get(c);
208  if ((ifs.rdstate() & std::ifstream::failbit)) {
210  break;
211  }
212  };
213 
214  char term[512];
215  unsigned int pos = 0;
216 
217  if (!iRC) {
218  while ((pos < 512) && (c != '\n') && (c != '\0') && (c != ' ')) {
219  term[pos++] = c;
220  if ((ifs.rdstate() & std::ifstream::failbit)) {
222  break;
223  }
224  ifs.get(c);
225  };
226  }
227 
228  if (!iRC) {
229  if (c == '\n') endOfLineAchieved = true;
230  term[pos] = '\0';
231  termString = term;
232  //std::cout << "Read chars = " << termString << std::endl;
233  if (termValue) {
234  if (termString == std::string("inf")) {
235  *termValue = INFINITY;
236  }
237  else if (termString == std::string("-inf")) {
238  *termValue = -INFINITY;
239  }
240  else if (termString == std::string("nan")) {
241  *termValue = nan("");
242  }
243  else {
244  *termValue = strtod(termString.c_str(),NULL);
245  }
246  }
247  }
248 
249  return iRC;
250 }
const int UQ_FAILED_READING_FILE_RC
Definition: Defines.h:84
const int UQ_OK_RC
Definition: Defines.h:75
void QUESO::MiscReadDoublesFromString ( const std::string &  inputString,
std::vector< double > &  outputDoubles 
)

Definition at line 39 of file Miscellaneous.C.

References UQ_FATAL_TEST_MACRO, and UQ_UNAVAILABLE_RANK.

Referenced by QUESO::EnvironmentOptions::getMyOptionValues(), QUESO::MLSamplingOptions::getMyOptionValues(), QUESO::StatisticalInverseProblemOptions::getMyOptionValues(), QUESO::StatisticalForwardProblemOptions::getMyOptionValues(), QUESO::MonteCarloSGOptions::getMyOptionValues(), QUESO::MetropolisHastingsSGOptions::getMyOptionValues(), and QUESO::MLSamplingLevelOptions::getMyOptionValues().

42 {
43  //std::cout << "In MiscReadDoublesFromString()"
44  // << ": inputString = " << inputString
45  // << std::endl;
46  outputDoubles.clear();
47  bool aDoubleIsBeingRead = false;
48  std::string::size_type positionOfFirstChar = 0;
49  std::string::size_type numberOfChars = 0;
50  for (std::string::size_type i = 0; i < inputString.size(); ++i) {
51  UQ_FATAL_TEST_MACRO((inputString[i] == '\0'),
53  "MiscReadDoublesFromString()",
54  "character '\0' should not be found!");
55  if (inputString[i] == ' ') {
56  if (aDoubleIsBeingRead == true) {
57  // We just finished reading the current string/double. Convert string to double now.
58  char tmpVar[numberOfChars+1];
59  for (std::string::size_type j = 0; j < numberOfChars; ++j) {
60  tmpVar[j] = inputString[positionOfFirstChar+j];
61  }
62  tmpVar[numberOfChars] = '\0';
63  outputDoubles.push_back(strtod(tmpVar,NULL));
64 
65  // Continue loop
66  aDoubleIsBeingRead = false;
67  positionOfFirstChar = 0;
68  numberOfChars = 0;
69  }
70  }
71  else {
72  if (aDoubleIsBeingRead == false) {
73  aDoubleIsBeingRead = true;
74  positionOfFirstChar = i;
75  }
76  numberOfChars++;
77  }
78  } // for
79  if (aDoubleIsBeingRead == true) {
80  // We just finished reading the current string/double. Convert string to double now.
81  char tmpVar[numberOfChars+1];
82  for (std::string::size_type j = 0; j < numberOfChars; ++j) {
83  tmpVar[j] = inputString[positionOfFirstChar+j];
84  }
85  tmpVar[numberOfChars] = '\0';
86  outputDoubles.push_back(strtod(tmpVar,NULL));
87  }
88  std::vector<double>(outputDoubles).swap(outputDoubles);
89 
90  return;
91 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:73
int QUESO::MiscReadStringAndDoubleFromFile ( std::ifstream &  ifs,
std::string &  termString,
double *  termValue 
)

Definition at line 165 of file Miscellaneous.C.

References UQ_FAILED_READING_FILE_RC, and UQ_OK_RC.

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

169 {
170  int iRC = UQ_OK_RC;
171 
172  ifs >> termString;
173  if ((ifs.rdstate() & std::ifstream::failbit)) {
175  }
176  else if (termValue) {
177  if (termString == std::string("inf")) {
178  *termValue = INFINITY;
179  }
180  else if (termString == std::string("-inf")) {
181  *termValue = -INFINITY;
182  }
183  else if (termString == std::string("nan")) {
184  *termValue = nan("");
185  }
186  else {
187  *termValue = strtod(termString.c_str(),NULL);
188  }
189  }
190  //if (!iRC) std::cout << "Read termString = " << termString << std::endl;
191 
192  return iRC;
193 }
const int UQ_FAILED_READING_FILE_RC
Definition: Defines.h:84
const int UQ_OK_RC
Definition: Defines.h:75
void QUESO::MiscReadWordsFromString ( const std::string &  inputString,
std::vector< std::string > &  outputWords 
)

Definition at line 94 of file Miscellaneous.C.

References UQ_FATAL_TEST_MACRO, and UQ_UNAVAILABLE_RANK.

97 {
98  //std::cout << "In MiscReadWordsFromString()"
99  // << ": inputString = " << inputString
100  // << std::endl;
101  outputWords.clear();
102  bool aWordIsBeingRead = false;
103  std::string::size_type positionOfFirstChar = 0;
104  std::string::size_type numberOfChars = 0;
105  for (std::string::size_type i = 0; i < inputString.size(); ++i) {
106  UQ_FATAL_TEST_MACRO((inputString[i] == '\0'),
108  "MiscReadWordsFromString()",
109  "character '\0' should not be found!");
110  if (inputString[i] == ' ') {
111  if (aWordIsBeingRead == true) {
112  // We just finished reading the current string/word.
113  char tmpVar[numberOfChars+1];
114  for (std::string::size_type j = 0; j < numberOfChars; ++j) {
115  tmpVar[j] = inputString[positionOfFirstChar+j];
116  }
117  tmpVar[numberOfChars] = '\0';
118  outputWords.push_back(tmpVar);
119 
120  // Continue loop
121  aWordIsBeingRead = false;
122  positionOfFirstChar = 0;
123  numberOfChars = 0;
124  }
125  }
126  else {
127  if (aWordIsBeingRead == false) {
128  aWordIsBeingRead = true;
129  positionOfFirstChar = i;
130  }
131  numberOfChars++;
132  }
133  } // for
134  if (aWordIsBeingRead == true) {
135  // We just finished reading the current string/word.
136  char tmpVar[numberOfChars+1];
137  for (std::string::size_type j = 0; j < numberOfChars; ++j) {
138  tmpVar[j] = inputString[positionOfFirstChar+j];
139  }
140  tmpVar[numberOfChars] = '\0';
141  outputWords.push_back(tmpVar);
142  }
143  std::vector<std::string>(outputWords).swap(outputWords);
144 
145  return;
146 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:73
unsigned int QUESO::MiscUintDebugMessage ( unsigned int  value,
const char *  message 
)

Definition at line 319 of file Miscellaneous.C.

322 {
323  if (message) {
324  std::cout << "Passing in MiscUintDebugMessage(), value = " << value << ", message = " << message << std::endl;
325  }
326  return value;
327 }
int QUESO::MyWorldfullRank ( )

Returns the rank of the calling process in the communicator.

Definition at line 30 of file Defines.C.

30  {
31  int result = 0;
32  int iRC;
33  iRC = MPI_Comm_rank(MPI_COMM_WORLD,&result);
34  if (iRC) {}; // just to remove compiler warning
35  return result;
36 }
GslVector QUESO::operator* ( double  a,
const GslVector &  x 
)

Definition at line 1344 of file GslVector.C.

1345 {
1346  GslVector answer(x);
1347  answer *= a;
1348 
1349  return answer;
1350 }
GslVector QUESO::operator* ( const GslVector &  x,
const GslVector &  y 
)

Definition at line 1352 of file GslVector.C.

1353 {
1354  GslVector answer(x);
1355  answer *= y;
1356 
1357  return answer;
1358 }
GslMatrix QUESO::operator* ( double  a,
const GslMatrix &  mat 
)

Definition at line 2352 of file GslMatrix.C.

2353 {
2354  GslMatrix answer(mat);
2355  answer *= a;
2356  return answer;
2357 }
GslVector QUESO::operator* ( const GslMatrix &  mat,
const GslVector &  vec 
)

Definition at line 2359 of file GslMatrix.C.

References QUESO::GslMatrix::multiply().

2360 {
2361  return mat.multiply(vec);
2362 }
GslMatrix QUESO::operator* ( const GslMatrix &  m1,
const GslMatrix &  m2 
)

Definition at line 2364 of file GslMatrix.C.

References QUESO::Matrix::env(), QUESO::Matrix::map(), QUESO::GslMatrix::numCols(), QUESO::GslMatrix::numRowsLocal(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

2365 {
2366  unsigned int m1Rows = m1.numRowsLocal();
2367  unsigned int m1Cols = m1.numCols();
2368  unsigned int m2Rows = m2.numRowsLocal();
2369  unsigned int m2Cols = m2.numCols();
2370 
2371  UQ_FATAL_TEST_MACRO((m1Cols != m2Rows),
2372  m1.env().worldRank(),
2373  "GslMatrix operator*(matrix,matrix)",
2374  "different sizes m1Cols and m2Rows");
2375 
2376  GslMatrix mat(m1.env(),m1.map(),m2Cols);
2377 
2378  //std::cout << "In GslMatrix(mat * mat): m1Cols = " << m1Cols << std::endl;
2379 
2380  unsigned int commonSize = m1Cols;
2381  for (unsigned int row1 = 0; row1 < m1Rows; ++row1) {
2382  for (unsigned int col2 = 0; col2 < m2Cols; ++col2) {
2383  double result = 0.;
2384  for (unsigned int k = 0; k < commonSize; ++k) {
2385  result += m1(row1,k)*m2(k,col2);
2386  }
2387  mat(row1,col2) = result;
2388  }
2389  //std::cout << "In GslMatrix(mat * mat): ended row " << row1 << std::endl;
2390  }
2391 
2392  return mat;
2393 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
GslVector QUESO::operator+ ( const GslVector &  x,
const GslVector &  y 
)

Definition at line 1377 of file GslVector.C.

1378 {
1379  GslVector answer(x);
1380  answer += y;
1381 
1382  return answer;
1383 }
GslMatrix QUESO::operator+ ( const GslMatrix &  m1,
const GslMatrix &  m2 
)

Definition at line 2395 of file GslMatrix.C.

2396 {
2397  GslMatrix answer(m1);
2398  answer += m2;
2399  return answer;
2400 }
GslVector QUESO::operator- ( const GslVector &  x,
const GslVector &  y 
)

Definition at line 1385 of file GslVector.C.

1386 {
1387  GslVector answer(x);
1388  answer -= y;
1389 
1390  return answer;
1391 }
GslMatrix QUESO::operator- ( const GslMatrix &  m1,
const GslMatrix &  m2 
)

Definition at line 2402 of file GslMatrix.C.

2403 {
2404  GslMatrix answer(m1);
2405  answer -= m2;
2406  return answer;
2407 }
GslVector QUESO::operator/ ( double  a,
const GslVector &  x 
)

Definition at line 1327 of file GslVector.C.

References QUESO::GslVector::cwInvert().

1328 {
1329  GslVector answer(x);
1330  answer.cwInvert();
1331  answer *= a;
1332 
1333  return answer;
1334 }
GslVector QUESO::operator/ ( const GslVector &  x,
const GslVector &  y 
)

Definition at line 1336 of file GslVector.C.

1337 {
1338  GslVector answer(x);
1339  answer /= y;
1340 
1341  return answer;
1342 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const InfiniteDimensionalMCMCSamplerOptions &  opts 
)

Definition at line 139 of file InfiniteDimensionalMCMCSamplerOptions.C.

References QUESO::InfiniteDimensionalMCMCSamplerOptions::print().

141 {
142  obj.print(os);
143  return os;
144 }
template<class V , class M >
std::ostream& QUESO::operator<< ( std::ostream &  os,
const ArrayOfOneDTables< V, M > &  obj 
)

Definition at line 121 of file ArrayOfOneDTables.C.

References QUESO::ArrayOfOneDTables< V, M >::print().

122 {
123  obj.print(os);
124  return os;
125 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const MLSamplingOptions &  obj 
)

Definition at line 203 of file MLSamplingOptions.C.

References QUESO::MLSamplingOptions::print().

204 {
205  obj.print(os);
206 
207  return os;
208 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const EnvironmentOptions &  obj 
)

Print values of the options chosen.

Definition at line 356 of file EnvironmentOptions.C.

References QUESO::EnvironmentOptions::print().

357 {
358  obj.print(os);
359 
360  return os;
361 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const StatisticalInverseProblemOptions &  obj 
)

Prints the object obj, overloading an operator.

Definition at line 246 of file StatisticalInverseProblemOptions.C.

References QUESO::StatisticalInverseProblemOptions::print().

247 {
248  obj.print(os);
249 
250  return os;
251 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const StatisticalForwardProblemOptions &  obj 
)

Prints the object obj, overloading an operator.

Definition at line 263 of file StatisticalForwardProblemOptions.C.

References QUESO::StatisticalForwardProblemOptions::print().

264 {
265  obj.print(os);
266 
267  return os;
268 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const MonteCarloSGOptions &  obj 
)

Prints the object obj, overloading an operator.

Definition at line 448 of file MonteCarloSGOptions.C.

References QUESO::MonteCarloSGOptions::print().

449 {
450  obj.print(os);
451 
452  return os;
453 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const GslVector &  obj 
)

Definition at line 1320 of file GslVector.C.

References QUESO::GslVector::print().

1321 {
1322  obj.print(os);
1323 
1324  return os;
1325 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const MetropolisHastingsSGOptions &  obj 
)

Definition at line 1000 of file MetropolisHastingsSGOptions.C.

References QUESO::MetropolisHastingsSGOptions::print().

1001 {
1002  obj.print(os);
1003 
1004  return os;
1005 }
template<class V , class M >
std::ostream& QUESO::operator<< ( std::ostream &  os,
const AsciiTable< V, M > &  obj 
)

Definition at line 351 of file AsciiTable.C.

352 {
353  obj.print(os);
354 
355  return os;
356 }
std::ostream & QUESO::operator<< ( std::ostream &  os,
const MLSamplingLevelOptions &  obj 
)

Definition at line 956 of file MLSamplingLevelOptions.C.

References QUESO::MLSamplingLevelOptions::print().

957 {
958  obj.print(os);
959 
960  return os;
961 }
std::ostream& QUESO::operator<< ( std::ostream &  os,
const BaseEnvironment &  obj 
)
std::ostream & QUESO::operator<< ( std::ostream &  os,
const GslMatrix &  obj 
)

Definition at line 2345 of file GslMatrix.C.

References QUESO::GslMatrix::print().

2346 {
2347  obj.print(os);
2348 
2349  return os;
2350 }
template<class P_V , class P_M >
std::ostream& QUESO::operator<< ( std::ostream &  os,
const MLSampling< P_V, P_M > &  obj 
)

Definition at line 4864 of file MLSampling.C.

4865 {
4866  obj.print(os);
4867 
4868  return os;
4869 }
bool QUESO::operator== ( const GslVector &  lhs,
const GslVector &  rhs 
)

Definition at line 1394 of file GslVector.C.

References QUESO::Vector::env(), QUESO::GslVector::sizeLocal(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

1395 {
1396  bool answer = true;
1397 
1398  unsigned int size1 = lhs.sizeLocal();
1399  unsigned int size2 = rhs.sizeLocal();
1400  UQ_FATAL_TEST_MACRO((size1 != size2),
1401  lhs.env().worldRank(),
1402  "operator==()",
1403  "different sizes of lhs and rhs");
1404 
1405  for (unsigned int i = 0; i < size1; ++i) {
1406  if (lhs[i] != rhs[i]) {
1407  answer = false;
1408  break;
1409  }
1410  }
1411 
1412  return answer;
1413 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
int QUESO::QUESO_get_numeric_version ( )

Definition at line 77 of file Environment.C.

References QUESO_MAJOR_VERSION, QUESO_MICRO_VERSION, and QUESO_MINOR_VERSION.

Referenced by QUESO_version_print().

78  {
79  // Note: return format follows the versioning convention xx.yy.z where
80  //
81  // xx = major version number
82  // yy = minor version number
83  // zz = micro version number
84  //
85  // For example:
86  // v. 0.23 -> 002300 = 2300
87  // v. 0.23.1 -> 002301 = 2301
88  // v. 10.23.2 -> 102302
89 
90  int major_version = 0;
91  int minor_version = 0;
92  int micro_version = 0;
93 
94 #ifdef QUESO_MAJOR_VERSION
95  major_version = QUESO_MAJOR_VERSION;
96 #endif
97 
98 #ifdef QUESO_MINOR_VERSION
99  minor_version = QUESO_MINOR_VERSION;
100 #endif
101 
102 #ifdef QUESO_MICRO_VERSION
103  micro_version = QUESO_MICRO_VERSION;
104 #endif
105 
106  return(major_version*10000 + minor_version*100 + micro_version);
107  }
#define QUESO_MAJOR_VERSION
Definition: queso.h:34
#define QUESO_MICRO_VERSION
Definition: queso.h:36
#define QUESO_MINOR_VERSION
Definition: queso.h:35
void QUESO::queso_terminate_handler ( )

Function for unhandled exceptions in Queso.

queso_terminate_handler This function deals with unhandled exceptions encountered in Queso. It provides a call to MPI_abort using the global communicator.

Definition at line 1490 of file Environment.C.

References old_terminate_handler.

Referenced by QUESO::FullEnvironment::FullEnvironment().

1491 {
1492  int mpi_initialized;
1493  MPI_Initialized (&mpi_initialized);
1494 
1495  if (mpi_initialized)
1496  {
1497  //MPI_Abort(m_fullComm->Comm(), 1);
1498  MPI_Abort(MPI_COMM_WORLD, 1);
1499  }
1500  else
1501  {
1502  // The system terminate_handler may do useful things like printing
1503  // uncaught exception information, or the user may have created
1504  // their own terminate handler that we want to call.
1506  }
1507  exit(1);
1508 }
std::terminate_handler old_terminate_handler
Definition: Environment.C:124
void QUESO::QUESO_version_print ( std::ostream &  os)

Definition at line 47 of file Environment.C.

References QUESO_BUILD_ARCH, QUESO_BUILD_DATE, QUESO_BUILD_HOST, QUESO_BUILD_USER, QUESO_BUILD_VERSION, QUESO_CXX, QUESO_CXXFLAGS, QUESO_get_numeric_version(), QUESO_GLPK_DIR, QUESO_GRVY_DIR, QUESO_GSL_DIR, QUESO_HDF5_DIR, QUESO_LIB_RELEASE, QUESO_LIB_VERSION, and QUESO_TRILINOS_DIR.

Referenced by QUESO::FullEnvironment::FullEnvironment(), and main().

48  {
49  {
50  os << "------------------------------------------------------------------------------------------" ;
51  os << "--------------------" << std::endl;
52  os << "QUESO Library: Version = " << QUESO_LIB_VERSION;
53  os << " (" << QUESO_get_numeric_version() << ")" << std::endl << std::endl;
54 
55  os << QUESO_LIB_RELEASE << std::endl << std::endl;
56 
57  os << "Build Date = " << QUESO_BUILD_DATE << std::endl;
58  os << "Build Host = " << QUESO_BUILD_HOST << std::endl;
59  os << "Build User = " << QUESO_BUILD_USER << std::endl;
60  os << "Build Arch = " << QUESO_BUILD_ARCH << std::endl;
61  os << "Build Rev = " << QUESO_BUILD_VERSION << std::endl << std::endl;
62 
63  os << "C++ Config = " << QUESO_CXX << " " << QUESO_CXXFLAGS << std::endl;
64  os << std::endl;
65  os << "Trilinos DIR = " << QUESO_TRILINOS_DIR << std::endl;
66  os << "GSL Libs = " << QUESO_GSL_DIR << std::endl;
67  os << "GRVY DIR = " << QUESO_GRVY_DIR << std::endl;
68  os << "GLPK DIR = " << QUESO_GLPK_DIR << std::endl;
69  os << "HDF5 DIR = " << QUESO_HDF5_DIR << std::endl;
70  os << "------------------------------------------------------------------------------------------" ;
71  os << "--------------------" << std::endl;
72  }
73 
74  return;
75  }
#define QUESO_BUILD_HOST
Definition: queso.h:40
int QUESO_get_numeric_version()
Definition: Environment.C:77
#define QUESO_BUILD_DATE
Definition: queso.h:41
#define QUESO_GSL_DIR
Definition: queso.h:53
#define QUESO_BUILD_VERSION
Definition: queso.h:42
#define QUESO_CXXFLAGS
Definition: queso.h:48
#define QUESO_LIB_RELEASE
Definition: queso.h:45
#define QUESO_GRVY_DIR
Definition: queso.h:54
#define QUESO_LIB_VERSION
Definition: queso.h:44
#define QUESO_CXX
Definition: queso.h:47
#define QUESO_BUILD_USER
Definition: queso.h:38
#define QUESO_BUILD_ARCH
Definition: queso.h:39
#define QUESO_TRILINOS_DIR
Definition: queso.h:52
#define QUESO_HDF5_DIR
Definition: queso.h:56
#define QUESO_GLPK_DIR
Definition: queso.h:55
GslMatrix QUESO::rightDiagScaling ( const GslMatrix &  mat,
const GslVector &  vec 
)

Definition at line 2452 of file GslMatrix.C.

References QUESO::Matrix::env(), QUESO::GslMatrix::numCols(), QUESO::GslMatrix::numRowsLocal(), QUESO::GslVector::sizeLocal(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

2453 {
2454  unsigned int vSize = vec.sizeLocal();
2455  unsigned int mRows = mat.numRowsLocal();
2456  unsigned int mCols = mat.numCols();
2457 
2458  UQ_FATAL_TEST_MACRO((vSize != mCols),
2459  mat.env().worldRank(),
2460  "GslMatrix rightDiagScaling(matrix,vector)",
2461  "size of vector is different from the number of cols in matrix");
2462 
2463  UQ_FATAL_TEST_MACRO((mCols != mRows),
2464  mat.env().worldRank(),
2465  "GslMatrix rightDiagScaling(matrix,vector)",
2466  "routine currently works for square matrices only");
2467 
2468  GslMatrix answer(mat);
2469  for (unsigned int j = 0; j < mCols; ++j) {
2470  double vecValue = vec[j];
2471  for (unsigned int i = 0; i < mRows; ++i) {
2472  answer(i,j) *= vecValue;
2473  }
2474  }
2475 
2476  return answer;
2477 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
double QUESO::scalarProduct ( const GslVector &  x,
const GslVector &  y 
)

Definition at line 1360 of file GslVector.C.

References QUESO::Vector::env(), QUESO::GslVector::sizeLocal(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

Referenced by QUESO::GslVector::norm2Sq().

1361 {
1362  unsigned int size1 = x.sizeLocal();
1363  unsigned int size2 = y.sizeLocal();
1364  UQ_FATAL_TEST_MACRO((size1 != size2),
1365  x.env().worldRank(),
1366  "scalarProduct()",
1367  "different sizes of x and y");
1368 
1369  double result = 0.;
1370  for (unsigned int i = 0; i < size1; ++i) {
1371  result += x[i]*y[i];
1372  }
1373 
1374  return result;
1375 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
template<class T >
double QUESO::SubF1F2Gaussian2dKdeIntegral ( const ScalarSequence< T > &  scalarSeq1,
const ScalarSequence< T > &  scalarSeq2,
unsigned int  initialPos,
double  scaleValue1,
double  scaleValue2,
const Base1D1DFunction &  func1,
const Base1D1DFunction &  func2,
unsigned int  quadratureOrder 
)

Calculates the integral of a 2D Gaussian KDE.

This function performs numerical integration (via Hermite-Gauss quadrature, see GaussianHermite1DQuadrature), of a bi-variate Gaussian KDE (refer to ScalarSequence::subGaussian1dKde(), ArrayOfSequences::gaussianKDE(), or SequenceOfVectors::subGaussian1dKde().

Definition at line 977 of file 1D1DFunction.C.

References QUESO::ScalarSequence< T >::env(), QUESO::ScalarSequence< T >::subSequenceSize(), UQ_FATAL_TEST_MACRO, UQ_UNAVAILABLE_RANK, QUESO::Base1D1DFunction::value(), and QUESO::BaseEnvironment::worldRank().

985 {
986  double resultValue = 0.;
987 
988  UQ_FATAL_TEST_MACRO(initialPos != 0,
989  scalarSeq1.env().worldRank(),
990  "SubF1F2Gaussian2dKdeIntegral()",
991  "not implemented yet for initialPos != 0");
992  UQ_FATAL_TEST_MACRO(scalarSeq1.subSequenceSize() != scalarSeq2.subSequenceSize(),
993  scalarSeq1.env().worldRank(),
994  "SubF1F2Gaussian2dKdeIntegral()",
995  "different sizes");
996 
997  GaussianHermite1DQuadrature quadObj(0.,1.,quadratureOrder);
998  const std::vector<double>& quadPositions = quadObj.positions();
999  const std::vector<double>& quadWeights = quadObj.weights ();
1000  UQ_FATAL_TEST_MACRO(quadPositions.size() != quadWeights.size(),
1002  "SubF1F2Gaussian2dKdeIntegral()",
1003  "quadObj has invalid state");
1004 
1005  unsigned int numQuadraturePositions = quadPositions.size();
1006  unsigned int dataSize = scalarSeq1.subSequenceSize();
1007  for (unsigned int k = 0; k < dataSize; ++k) {
1008  double value1 = 0.;
1009  double value2 = 0.;
1010  double x1k = scalarSeq1[k];
1011  double x2k = scalarSeq2[k];
1012  for (unsigned int j = 0; j < numQuadraturePositions; ++j) {
1013  value1 += func1.value(scaleValue1*quadPositions[j]+x1k)*quadWeights[j];
1014  value2 += func2.value(scaleValue2*quadPositions[j]+x2k)*quadWeights[j];
1015  }
1016  resultValue += value1*value2;
1017  }
1018  resultValue *= 1./(2.*M_PI)/((double) dataSize);
1019 
1020  return resultValue;
1021 }
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:222
const int UQ_UNAVAILABLE_RANK
Definition: Defines.h:73

Variable Documentation

std::terminate_handler QUESO::old_terminate_handler
const int QUESO::UQ_FAILED_READING_FILE_RC = -9

Definition at line 84 of file Defines.h.

Referenced by MiscReadCharsAndDoubleFromFile(), and MiscReadStringAndDoubleFromFile().

const int QUESO::UQ_FAILED_TO_OPEN_FILE_RC = -7

Definition at line 82 of file Defines.h.

const int QUESO::UQ_INCOMPLETE_IMPLEMENTATION_RC = -1
const int QUESO::UQ_INVALID_INTERNAL_RESULT_RC = -5

Definition at line 80 of file Defines.h.

const int QUESO::UQ_INVALID_INTERNAL_STATE_RC = -6
const int QUESO::UQ_INVALID_OBSERVABLE_SPEC_RC = -3

Definition at line 78 of file Defines.h.

const int QUESO::UQ_INVALID_PARAMETER_SPEC_RC = -2

Definition at line 77 of file Defines.h.

const int QUESO::UQ_INVALID_QOI_SPEC_RC = -4

Definition at line 79 of file Defines.h.

const int QUESO::UQ_INVALID_SPACE_COMPONENT_ID_RC = -10

Definition at line 85 of file Defines.h.

const int QUESO::UQ_MATRIX_IS_NOT_POS_DEFINITE_RC = -8
const int QUESO::UQ_MATRIX_SVD_FAILED_RC = -11

Definition at line 86 of file Defines.h.

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

const int QUESO::UQ_OK_RC = 0
const int QUESO::UQ_UNAVAILABLE_RANK = -1

Definition at line 73 of file Defines.h.

Referenced by QUESO::Base1D1DFunction::Base1D1DFunction(), QUESO::Base1DQuadrature::Base1DQuadrature(), QUESO::Generic1D1DFunction::deriv(), QUESO::Constant1D1DFunction::deriv(), QUESO::Linear1D1DFunction::deriv(), QUESO::PiecewiseLinear1D1DFunction::deriv(), QUESO::Sampled1D1DFunction::deriv(), QUESO::ScalarTimesFunc1D1DFunction::deriv(), QUESO::FuncTimesFunc1D1DFunction::deriv(), QUESO::FuncPlusFunc1D1DFunction::deriv(), QUESO::LagrangePolynomial1D1DFunction::deriv(), QUESO::LagrangeBasis1D1DFunction::deriv(), QUESO::DistArray< T >::DistArray(), QUESO::Fft< T >::forward(), QUESO::FullEnvironment::FullEnvironment(), QUESO::GaussianHermite1DQuadrature::GaussianHermite1DQuadrature(), QUESO::Generic1DQuadrature::Generic1DQuadrature(), QUESO::LagrangeBasis1D1DFunction::LagrangeBasis1D1DFunction(), QUESO::LagrangePolynomial1D1DFunction::LagrangePolynomial1D1DFunction(), QUESO::Map::Map(), MiscCheckForSameValueInAllNodes(), MiscReadDoublesFromString(), MiscReadWordsFromString(), QUESO::MpiComm::MpiComm(), QUESO::Base1D1DFunction::multiplyAndIntegrate(), QUESO::TwoDArray< T >::operator()(), QUESO::PiecewiseLinear1D1DFunction::PiecewiseLinear1D1DFunction(), QUESO::Base1DQuadrature::positions(), QUESO::TwoDArray< T >::setLocation(), SubF1F2Gaussian2dKdeIntegral(), QUESO::UniformLegendre1DQuadrature::UniformLegendre1DQuadrature(), QUESO::Generic1D1DFunction::value(), QUESO::Constant1D1DFunction::value(), QUESO::Linear1D1DFunction::value(), QUESO::PiecewiseLinear1D1DFunction::value(), QUESO::Sampled1D1DFunction::value(), QUESO::Base1DQuadrature::weights(), and QUESO::WignerInverseChebyshev1st1DQuadrature::WignerInverseChebyshev1st1DQuadrature().


Generated on Thu Apr 23 2015 19:18:35 for queso-0.50.1 by  doxygen 1.8.5