Index: trunk/tests/time_stamp.hh =================================================================== --- trunk/tests/time_stamp.hh (revision 563) +++ trunk/tests/time_stamp.hh (revision 564) @@ -1,29 +0,0 @@ -#ifndef TIME_STAMP_H_ -#define TIME_STAMP_H_ - -// -// Return the string representing current time in the format hh:mm:ss -// -// I. Volobouev -// March 2013 -// - -#include -#include -#include - -inline std::string time_stamp() -{ - struct tm *current; - time_t now; - - time(&now); - current = localtime(&now); - - char buf[10]; - sprintf(buf, "%02i:%02i:%02i", current->tm_hour, - current->tm_min, current->tm_sec); - return std::string(buf); -} - -#endif // TIME_STAMP_H_ Index: trunk/tests/jacobiEpsPseudoExp.cc =================================================================== --- trunk/tests/jacobiEpsPseudoExp.cc (revision 563) +++ trunk/tests/jacobiEpsPseudoExp.cc (revision 564) @@ -1,325 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "test_utils.hh" -#include "time_stamp.hh" - -#include "npstat/nm/ClassicalOrthoPolys1D.hh" -#include "npstat/nm/ContOrthoPoly1D.hh" -#include "npstat/nm/GaussLegendreQuadrature.hh" - -#include "npstat/stat/Distributions1D.hh" -#include "npstat/stat/SampleAccumulator.hh" -#include "npstat/stat/orthoPoly1DVProducts.hh" - -#include "npstat/rng/MersenneTwister.hh" - -using namespace npstat; -using namespace std; - - -inline static double kdelta(const unsigned i, - const unsigned j) -{ - return i == j ? 1.0 : 0.0; -} - - -static double calculateExpectation( - const JacobiOrthoPoly1D& jac, const unsigned nPoints, - const unsigned m, const unsigned n, - const unsigned maxdeg, const bool highOrder) -{ - const unsigned sumdeg = (unsigned)(jac.alpha()) + (unsigned)(jac.beta()) + 4U*maxdeg; - const unsigned nGood = GaussLegendreQuadrature::minimalExactRule(sumdeg); - assert(nGood); - GaussLegendreQuadrature glq(nGood); - return oracleEpsExpectation(jac, glq, nPoints, m, n, highOrder); -} - - -static double calculateCovariance( - const JacobiOrthoPoly1D& jac, const unsigned nPoints, - const unsigned m1, const unsigned n1, - const unsigned m2, const unsigned n2, - const unsigned maxdeg, const bool highOrder) -{ - const unsigned sumdeg = (unsigned)(jac.alpha()) + (unsigned)(jac.beta()) + 8U*maxdeg; - const unsigned nGood = GaussLegendreQuadrature::minimalExactRule(sumdeg); - assert(nGood); - GaussLegendreQuadrature glq(nGood); - return oracleEpsCovariance(jac, glq, nPoints, m1, n1, m2, n2, highOrder); -} - - -static string eps_name(const unsigned m, const unsigned n, - const char* prefix) -{ - ostringstream os; - os << prefix << "_eps_" << m << '_' << n; - return os.str(); -} - - -static string cov_columns(const unsigned maxdeg) -{ - ostringstream os; - unsigned colnum = 0; - - for (unsigned j=0; j<=maxdeg; ++j) - for (unsigned i=0; i<=j; ++i) - for (unsigned n=0; n<=maxdeg; ++n) - for (unsigned m=0; m<=n; ++m) - if (std::make_pair(m,n) <= std::make_pair(i,j)) - { - if (colnum++) - os << ' '; - os << "cov_" << m << '_' << n << '_' << i << '_' << j; - } - - return os.str(); -} - - -static string pseudo_exp_columns(const unsigned maxdeg) -{ - ostringstream os; - unsigned colnum = 0; - - for (unsigned j=0; j<=maxdeg; ++j) - for (unsigned i=0; i<=j; ++i, ++colnum) - { - if (colnum) - os << ' '; - os << eps_name(i, j, "real") << ' ' - << eps_name(i, j, "ora") << ' ' - << eps_name(i, j, "est"); - } - - os << ' ' << cov_columns(maxdeg); - return os.str(); -} - - -static string ora_columns(const unsigned maxdeg) -{ - ostringstream os; - unsigned colnum = 0; - - for (unsigned j=0; j<=maxdeg; ++j) - for (unsigned i=0; i<=j; ++i, ++colnum) - { - if (colnum) - os << ' '; - os << "eps_" << i << '_' << j; - } - - os << ' ' << cov_columns(maxdeg); - return os.str(); -} - - -template -static void print_accumulator(const string& which, - const Acc& acc, const double expMean) -{ - const double m = acc.mean(); - const double u = acc.meanUncertainty(); - const double nsig = (m - expMean)/u; - - cout << which << " average is " << m << " +- " << u - << ", expected " << expMean << " (" << nsig << " sigma)" << endl; -} - - -#define dump_parameter(str, value) do { \ - str << "set parameters(" << #value << ") " << value << '\n';\ -} while(0); - - -int main(int argc, char const* argv[]) -{ - const unsigned reportFrequency = 100; - - if (argc != 9) - { - cout << "Usage: " << parse_progname(argv[0]) - << " alpha beta pointsPerPseudo nPseudo maxdeg highOrder_eps highOrder_cov dirname" << endl; - exit(1); - } - - unsigned alpha, beta; - if (parse_unsigned(argv[1], &alpha)) exit(1); - if (parse_unsigned(argv[2], &beta)) exit(1); - - unsigned perpseudo; - if (parse_unsigned(argv[3], &perpseudo)) exit(1); - if (!perpseudo) - { - cerr << "pointsPerPseudo must be positive" << endl; - exit(1); - } - - unsigned npseudo; - if (parse_unsigned(argv[4], &npseudo)) exit(1); - if (npseudo < 2) - { - cerr << "nPseudo must be at least 2" << endl; - exit(1); - } - - unsigned maxdeg; - if (parse_unsigned(argv[5], &maxdeg)) exit(1); - if (!maxdeg) - { - cerr << "maxdeg must be positive" << endl; - exit(1); - } - - bool highOrder_eps, highOrder_cov; - if (parse_bool(argv[6], &highOrder_eps)) exit(1); - if (parse_bool(argv[7], &highOrder_cov)) exit(1); - - // Make a new directory and go there - const char* dirname = argv[8]; - if (mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)) - { - cerr << "Failed to make directory \"" << dirname << "\": " - << strerror(errno) << endl; - exit(1); - } - if (chdir(dirname)) - { - cerr << "Failed to change working directory to \"" << dirname << "\": " - << strerror(errno) << endl; - exit(1); - } - - // Print the command used and parsed argument values - { - ofstream cmdfile("parameters.tcl"); - assert(cmdfile.is_open()); - cmdfile << "# " << argv[0]; - for (int i=1; i rn; - rn.reserve(perpseudo); - - const unsigned integPoints = GaussLegendreQuadrature::minimalExactRule( - (unsigned)(jac.alpha()) + (unsigned)(jac.beta()) + 2U*maxdeg); - - for (unsigned ips=0; ips 0) - if (ips % reportFrequency == 0) - cout << time_stamp() << " running pseudo exp " << ips << endl; - - rn.clear(); - double tmp; - for (unsigned i=0; i