00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef QMCPROPERTY_H
00018 #define QMCPROPERTY_H
00019
00020 #define DCL 30
00021
00022 #include <iostream>
00023 #include <string>
00024 #include <math.h>
00025 #include <iomanip>
00026
00027 #ifdef PARALLEL
00028 #include <mpi.h>
00029 #endif
00030
00031 #include "QMCStatistic.h"
00032 #include "Array1D.h"
00033 #include "Array2D.h"
00034
00035 using namespace std;
00036
00042 class QMCProperty
00043 {
00044 private:
00045 QMCStatistic DeCorr[DCL];
00046 int DeCorr_flags[DCL];
00047 double DeCorr_sample[DCL];
00048 double DeCorr_weight[DCL];
00049
00050
00052
00053
00054
00055
00056
00061 int getDecorrDepth();
00062
00063 public:
00064
00069 QMCProperty();
00070
00074 void zeroOut();
00075
00081 void newSample(double s, double weight);
00082
00087 unsigned long getNumberSamples();
00088
00089 string getLongString();
00090 string getShortString();
00091
00096 double getAverage();
00097
00102 double getVariance();
00103
00104 double getSkewness();
00105 double getKurtosis();
00106
00111 double getSeriallyCorrelatedVariance();
00112
00117 double getStandardDeviation();
00118
00124 double getSeriallyCorrelatedStandardDeviation();
00125
00130 double getStandardDeviationStandardDeviation();
00131
00135 void operator = ( const QMCProperty &rhs);
00136
00140 void operator += ( QMCProperty &rhs);
00141
00147 QMCProperty operator + ( QMCProperty &rhs);
00148
00155 void reWeight(double w);
00156
00161 void toXML(ostream& strm);
00162
00168 bool readXML(istream& strm);
00169
00174 void printAll(ostream & strm);
00175
00180 friend ostream& operator <<(ostream& strm, QMCProperty &rhs);
00181
00194 double getBlockVariance(int i);
00195 double getBlockSkewness(int i);
00196 double getBlockKurtosis(int i);
00197
00210 double getBlockStandardDeviation(int i);
00211
00226 double getBlockStandardDeviationStandardDeviation(int i);
00227
00242 double getBlockVarianceStandardDeviation(int i);
00243
00247 double getCorrelationLength();
00248
00252 double getCorrelationLength(int i);
00253
00254 private:
00255
00281 static void calculateObjectiveFunction(Array1D<double> & params,
00282 Array1D<double> & standardDeviations,
00283 Array1D<double> & standardDeviationsErrors,
00284 double & functionValue,
00285 Array1D<double> & gradientValue);
00286
00311 static void calculateObjectiveFunction(Array1D<double> & params,
00312 Array1D<double> & standardDeviations,
00313 Array1D<double> & standardDeviationsErrors,
00314 double & functionValue);
00315
00337 static double calculateLineSearchObjectiveFunction(Array1D<double> & params,
00338 Array1D<double> & searchDirection,
00339 double stepLength,
00340 Array1D<double> & standardDeviations,
00341 Array1D<double> & standardDeviationsErrors);
00342
00364 static double calculateLineSearchObjectiveFunctionDerivative(
00365 Array1D<double> & params,
00366 Array1D<double> & searchDirection,
00367 double stepLength,
00368 Array1D<double> & standardDeviations,
00369 Array1D<double> & standardDeviationsErrors);
00370
00384 static double cubicInterpolateStep(double alphaLo, double alphaHi,
00385 double phi_0,
00386 double phi_alphaLo, double phi_alphaHi,
00387 double phiPrime_0);
00388
00410 static double zoom(double alphaLo, double alphaHi, double phi_0,
00411 double phi_alphaLo, double phi_alphaHi,
00412 double phiPrime_0, Array1D<double> & params,
00413 Array1D<double> & searchDirection,
00414 Array1D<double> & standardDeviations,
00415 Array1D<double> & standardDeviationsErrors);
00416
00434 static double wolfeStepLength(double alphaGuess, Array1D<double> & params,
00435 Array1D<double> & searchDirection,
00436 Array1D<double> & gradient,
00437 double functionValue,
00438 Array1D<double> & standardDeviations,
00439 Array1D<double> & standardDeviationsErrors);
00440
00445 void generateInitialGuessFittingParameters();
00446
00447 #ifdef PARALLEL
00448
00449 private:
00453 static bool mpiTypeCreated;
00454
00458 static void buildMpiType();
00459
00463 static void buildMpiReduce();
00464
00468 static void Reduce_Function(QMCProperty *in, QMCProperty *inout,
00469 int *len, MPI_Datatype *dptr);
00470
00471 public:
00472
00476 static MPI_Datatype MPI_TYPE;
00477
00481 static MPI_Op MPI_REDUCE;
00482
00483 #endif
00484
00485 };
00486
00487 #endif