Ejemplo n.º 1
0
/* Inputs:
   tstart, start of the period in julian date (Beijing Time)
   tend, end of the period in julian date (Beijing Time)
   phase, the desired phase, 0-3 for new moon to last quarter
   Output:
   vjdphases, the julian dates (Beijing Time) of all occurings of the
              desired phase
*/
void mphases(double tstart, double tend, int phase, vdouble& vjdphases)
{
    double offs;
    if (tstart < 2425245) /* Before 1928 */
        offs = (116.0 + 25.0 / 60.0) / 360.0;
    else
        offs = 120.0 / 360.0;
/* Find the lunation number of the first given phase after tstart */
    double period = 29.53058853;
    int lun = (int) ((tstart - offs - 2451550.09765 - phase * 7.375) / period);
    double jd1 = moonphasebylunation(lun, phase) + offs;
    while (jd1 - tstart > 29)
    {
        lun--;
        jd1 = moonphasebylunation(lun, phase) + offs;
    }
    while (tstart > jd1)
    {
        lun++;
        jd1 = moonphasebylunation(lun, phase) + offs;
    }
/* Compute subsequent phases until after tend */
    vjdphases.erase(vjdphases.begin(), vjdphases.end());
    jd1 = tt2ut(jd1);
    vjdphases.push_back(jd1);
    while (jd1 < tend - 29)
    {
        lun++;
        jd1 = moonphasebylunation(lun, phase) + offs;
        jd1 = tt2ut(jd1);
        if (jd1 < tend)
            vjdphases.push_back(jd1);
    }
}
Ejemplo n.º 2
0
double Bayespack::integrate(vdouble &mode,
			    int m, USRLGP *flogp, 
			    int n, USRMNS *fmean)
{
  int mn = m + n;

  // Make sure vectors are the right size
  //////////////////////////////////////////
  _mu.resize(mode.size());
  copy(mode.begin(), mode.end(), _mu.begin());

  _c.resize(m*(m+1)/2);
  _means.resize(mn);
  _errors.resize(mn);
  _covrnc.resize(m*(m+1)/2);

  banint_(m,                        // Dimension of space
          _relreq,                  // Relative error
          _maxvls,                  // Maximum number of function evaluations
          _rs,                      // rs = 0 first call, rs > 0 otherwise
          flogp,                    // log[Post(theta|d)]
          mn,                       // Number of means mn >= m
          fmean,                    // Additional means to compute
          _problem.c_str(),         // Problem title
          _mu[0],                   // Modes
          _c[0],                    // Cholesky matrix
          _pu,                      // Print level
          _numtrn,                  // Transform
          _method,                  // Method
          _nrmcon,                  // Normalization (integral)
          _means[0],                // Means
          _errors[0],               // Errors on means
          _covrnc[0],               // Covariance matrix
          _inform,                  // 0 = Ok, 1 = Not Ok
          _problem.size());
  return _nrmcon;
}