Example #1
0
		inline vector<double> rvs(const unsigned int _n)
			{
				vector<double> x_s(_n, 0.0);
				for (auto &itr : x_s)
					itr = stackoverflow::call(_rv.rf, _para);
				return x_s; 
			}
Example #2
0
double EW_CHMN::CV_q(QCD::quark q) const
{
    switch (q) {
        case QCD::UP:
            return ( 3.1166 + 0.0030 * x_s());
        case QCD::DOWN:
        case QCD::STRANGE:
        case QCD::CHARM:
            return ( 3.1167 + 0.0030 * x_s());
        case QCD::BOTTOM:
            return ( 3.1185 + 0.0030 * x_s());
        case QCD::TOP:
        default:
            throw std::runtime_error("Error in EW_CHMN::CV_q()");
    }
}
Example #3
0
double EW_CHMN::CA_q(QCD::quark q) const
{
    switch (q) {
        case QCD::UP:
            return ( 3.1377 + 0.00014 * x_t() + 0.0041 * x_s());
        case QCD::DOWN:
        case QCD::STRANGE:
            return ( 3.0956 - 0.00015 * x_t() + 0.0019 * x_s());
        case QCD::CHARM:
            return ( 3.1369 + 0.00014 * x_t() + 0.0043 * x_s());
        case QCD::BOTTOM:
            return ( 3.0758 - 0.00015 * x_t() + 0.0028 * x_s());
        case QCD::TOP:
        default:
            throw std::runtime_error("Error in EW_CHMN::CA_q()");
    }
}
Example #4
0
bool
Date::isValidDate(std::string s)
{
    std::string mn("january february march april may june july");
    mn += " august september october november december" ;
    Split x_mn(mn);

    s = hdhC::Lower()(s);
    s = hdhC::replaceChars(s, ',', ' ');
    Split x_s(s);

    if( x_s.size() != 3 )
        return false;

    int i_d, i_m, i_y;
    i_d = i_m = i_y = 0;

    for(size_t i=0 ; i < x_s.size() ; ++i )
    {
        if( hdhC::isAlpha(x_s[i]) )
        {
            for(size_t m=0 ; m < x_mn.size() ; ++m )
            {
                if( x_s[i] == x_mn[m].substr(0, x_s[i].size()) )
                {
                    i_m = hdhC::string2Double(x_s[i]) ;
                    break;
                }
            }
        }
        else
        {
            if( hdhC::isDigit(x_s[i]) )
            {
                if( x_s[i].size() > 2 )
                    i_y = hdhC::string2Double(x_s[i]) ;
                else
                    i_d = hdhC::string2Double(x_s[i]) ;
            }
            else
                i_d = hdhC::string2Double(x_s[i]) ;
        }
    }

    bool is=true;
    if( i_d == 0 )
        is=false ;
    if( i_m == 0 )
        is=false ;
    if( i_y == 0 )
        is=false ;

    if(is)
        return true;

    return false;
}
Example #5
0
  KOKKOS_INLINE_FUNCTION
  void operator() (device_type device) const {
    int element = device.league_rank();
    int num_threads = device.team_size();
    int thread = device.team_rank();

    int num_samples = dev_x.dimension_1();
    int num_samples_per_thread = num_samples / num_threads;

    // Initialize x
    storage_type x_s(&dev_x(element,thread),
                     num_samples_per_thread,
                     num_threads);
    storage_type y_s(&dev_y(element,thread),
                     num_samples_per_thread,
                     num_threads);
    array_vector_type x(x_s), y(y_s);

    simple_function<scalar_vector_type>(x,y);

    // Print x and y
    if (print) {
      for (int tidx = 0; tidx<num_threads; tidx++) {
        if (thread == tidx) {
          printf("x(%i) = [ ",tidx);
          for (int sample=0; sample<num_samples_per_thread; sample++)
            printf("%g ", x.coeff(sample));
          printf("]\n\n");
        }
        device.team_barrier();
      }

      for (int tidx = 0; tidx<num_threads; tidx++) {
        if (thread == tidx) {
          printf("y(%i) = [ ",tidx);
          for (int sample=0; sample<num_samples_per_thread; sample++)
            printf("%g ", y.coeff(sample));
          printf("]\n\n");
        }
        device.team_barrier();
      }
    }
  }
Example #6
0
double EW_CHMN::DeltaMw_SM() const
{
    return ( -0.137 * x_h() - 0.019 * x_h() * x_h() + 0.018 * x_t()
            - 0.005 * x_alpha() - 0.002 * x_s());
}
Example #7
0
double EW_CHMN::DeltaTz_SM() const
{
    return ( -0.0995 * x_h() - 0.2858 * x_h() * x_h() + 0.1175 * x_h() * x_h() * x_h()
            + 0.0367 * x_t() + 0.00026 * x_t() * x_t() - 0.0017 * x_h() * x_t()
            - 0.0033 * x_s() - 0.0001 * x_t() * x_s());
}
Example #8
0
double EW_CHMN::DeltaSz_SM() const
{
    return ( 0.2217 * x_h() - 0.1188 * x_h() * x_h() + 0.0320 * x_h() * x_h() * x_h()
            - 0.0014 * x_t() + 0.0005 * x_s());
}
Example #9
0
double EW_CHMN::GammaW() const
{
    double Rw = 2.1940 + DeltaRw();
    return ( 0.33904 * pow(Mw(), 3.0)
            * SM.getGF()*(1.0 + 0.008478 * Rw + 0.00065 * x_s()));
}
Example #10
0
int calib_gimbal_load(calib_gimbal_t &calib, const std::string &data_dir) {
  // Load calibration data
  calib.data_dir = data_dir;
  if (calib_gimbal_data_load(calib.data, data_dir) != 0) {
    LOG_ERROR("Failed to load calibration data [%s]!", data_dir.c_str());
    return -1;
  }

  // Load optimization params
  const std::string config_file = data_dir + "/camchain.yaml";
  const std::string joint_file = data_dir + "/joint.csv";
  if (calib_gimbal_params_load(calib.params, config_file, joint_file) != 0) {
    LOG_ERROR("Failed to load optimization params!");
    return -1;
  }

  // Setup optimization problem
  // const mat3_t K_s = calib.params.camchain.cam[0].K();
  // const mat3_t K_d = calib.params.camchain.cam[2].K();
  // const vec4_t D_s = calib.params.camchain.cam[0].D();
  // const vec4_t D_d = calib.params.camchain.cam[2].D();
  const mat3_t K_s;
  const mat3_t K_d;
  const vec4_t D_s;
  const vec4_t D_d;
  const double theta1_offset = *calib.params.theta1_offset;
  const double theta2_offset = *calib.params.theta2_offset;

  // const std::string dmodel_s = calib.params.camchain.cam[0].distortion_model;
  // const std::string dmodel_d = calib.params.camchain.cam[2].distortion_model;
  const std::string dmodel_s;
  const std::string dmodel_d;

  // Form residual blocks
  for (int i = 0; i < calib.data.nb_measurements; i++) {
    for (int j = 0; j < calib.data.P_s[i].rows(); j++) {
      const vec3_t P_s = calib.data.P_s[i].row(j);
      const vec3_t P_d = calib.data.P_d[i].row(j);

      // Undistort pixel measurements from static camera
      const vec2_t p_s = calib.data.Q_s[i].row(j);
      cv::Point2f pt_s(p_s(0), p_s(1));
      // pt_s = calib.params.camchain.cam[0].undistortPoint(pt_s);
      vec3_t x_s{pt_s.x, pt_s.y, 1.0};
      // x_s = calib.params.camchain.cam[0].K() * x_s;
      const vec2_t Q_s{x_s(0), x_s(1)};

      // Undistort pixel measurements from dynamic camera
      const vec2_t p_d = calib.data.Q_d[i].row(j);
      cv::Point2f pt_d(p_d(0), p_d(1));
      // pt_d = calib.params.camchain.cam[2].undistortPoint(pt_d);
      vec3_t x_d{pt_d.x, pt_d.y, 1.0};
      // x_d = calib.params.camchain.cam[2].K() * x_d;
      const vec2_t Q_d{x_d(0), x_d(1)};

      // auto residual =
      //     new GimbalCalibResidual(P_s, P_d,
      //                             Q_s, Q_d,
      //                             K_s, K_d,
      //                             D_s, D_d,
      //                             theta1_offset, theta2_offset);

      // Build cost function
      // auto cost_func =
      //     new ceres::AutoDiffCostFunction<GimbalCalibResidual, // Residual
      //     type
      //                                     4, // Size of residual
      //                                     6, // Size of: tau_s
      //                                     6, // Size of: tau_d
      //                                     3, // Size of: w1
      //                                     3, // Size of: w2
      //                                     1, // Size of: Lambda1
      //                                     1  // Size of: Lambda2
      //                                     >(residual);

      // Add residual block to problem
      // calib.problem.AddResidualBlock(cost_func, // Cost function
      //                                NULL,      // Loss function
      //                                calib.params.tau_s,
      //                                calib.params.tau_d,
      //                                calib.params.w1,
      //                                calib.params.w2,
      //                                &calib.params.Lambda1[i],
      //                                &calib.params.Lambda2[i]);
      // calib.problem.SetParameterBlockConstant(&calib.params.Lambda1[i]);
      // calib.problem.SetParameterBlockConstant(&calib.params.Lambda2[i]);
    }
  }
  calib.problem.SetParameterBlockConstant(calib.params.w2);

  return 0;
}