• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Gt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Gt函数的典型用法代码示例。如果您正苦于以下问题:C++ Gt函数的具体用法?C++ Gt怎么用?C++ Gt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Gt函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: OpenFile

/*!
  Computes the first unpolarized moment
  
  \f[
  {\cal O}_{14} = \overline{q} \left[ \gamma_1 
  \stackrel{\displaystyle \leftrightarrow}{D}_4
  +\gamma_4 
  \stackrel{\displaystyle \leftrightarrow}{D}_1
  \right] q
  \f]
  
  with polarized projector
*/
void AlgNuc3pt::calc_EnergyMomentum(const ThreeMom& mom)
{
  OpenFile(); 
  Fprintf(fp,"The next is: Energy momentum k4 + 4k\n");
  CloseFile();
  for ( int n = 0; n < num_qprop; n++ ) {
    for (int i(X);i<4;i++){
      DIR d = DIR(i) ;
      Gamma Gx(d);
      Gamma Gt(T);
      Derivative Der_t(T);
      Derivative Der_x(d);
      
      Nuc3ptStru Xq_xt(mom,Gx, Der_t);
      Xq_xt.Calc3pt(*u_s_prop, *q_prop[n]);
      Xq_xt.Calc3pt(*d_s_prop, *q_prop[n]);
      
      Nuc3ptStru Xq_tx(mom,Gt,Der_x);
      Xq_tx.Calc3pt(*u_s_prop, *q_prop[n]);
      Xq_tx.Calc3pt(*d_s_prop, *q_prop[n]);
      
      Xq_xt += Xq_tx ;
      OpenFile(); 
      Xq_xt.Print(fp) ; 
      CloseFile();
    }
  }
}
开发者ID:DeanHowarth,项目名称:QUDA-CPS,代码行数:41,代码来源:alg_nuc3pt.C


示例2: TestTimeReversibility

void TestTimeReversibility(Integrator const& integrator) {
  Length const q_initial = 1 * Metre;
  Speed const v_initial = 0 * Metre / Second;
  Speed const v_amplitude = 1 * Metre / Second;
  Instant const t_initial;
  Instant const t_final = t_initial + 100 * Second;
  Time const step = 1 * Second;

  std::vector<ODE::SystemState> solution;
  ODE harmonic_oscillator;
  harmonic_oscillator.compute_acceleration =
      std::bind(ComputeHarmonicOscillatorAcceleration,
                _1, _2, _3, /*evaluations=*/nullptr);
  IntegrationProblem<ODE> problem;
  problem.equation = harmonic_oscillator;
  ODE::SystemState const initial_state = {{q_initial}, {v_initial}, t_initial};
  ODE::SystemState final_state;
  problem.initial_state = &initial_state;
  problem.t_final = t_final;
  problem.append_state = [&final_state](ODE::SystemState const& state) {
    final_state = state;
  };

  integrator.Solve(problem, step);

  problem.initial_state = &final_state;
  problem.t_final = t_initial;

  integrator.Solve(problem, -step);

  EXPECT_EQ(t_initial, final_state.time.value);
  if (integrator.time_reversible) {
    EXPECT_THAT(final_state.positions[0].value,
                AlmostEquals(q_initial, 0, 8));
    EXPECT_THAT(final_state.velocities[0].value,
                VanishesBefore(v_amplitude, 0, 16));
  } else {
    EXPECT_THAT(AbsoluteError(q_initial,
                              final_state.positions[0].value),
                Gt(1e-4 * Metre));
    EXPECT_THAT(AbsoluteError(v_initial,
                              final_state.velocities[0].value),
                Gt(1e-4 * Metre / Second));
  }
}
开发者ID:eggrobin,项目名称:Principia,代码行数:45,代码来源:symplectic_runge_kutta_nyström_integrator_test.cpp


示例3: TEST

TEST(MatchingContainers, Foo)
{
    MockFoo foo;
    EXPECT_CALL(foo, Bar(ElementsAre(1, Gt(0), _, 5)));
    EXPECT_CALL(foo, Bar(UnorderedElementsAre(2, 3)));
    
    const vector<int> a{1, 2, 3, 5};
    foo.Bar(a);
    
    const vector<int> b{3, 2};
    foo.Bar(b);
}
开发者ID:Junch,项目名称:StudyCppUTest,代码行数:12,代码来源:MatchingContainers.cpp


示例4: Gt

/*!
  Computes the conserved vector current using the
  \f[
  {\cal O}_\mu = \overline{q} \gamma_\mu q
  \f]
  
  all possible mometa are inserted
*/
void AlgNuc3pt::calc_Cons_Vector(int Nmom, ThreeMom* mom)
{     
  Gamma Gt(T);
  Nuc3ptCons VectCurr(Gt);
  const int MaxNmom=50;
  if(Nmom>MaxNmom)
    ERR.General(cname,"calc_Cons_Vector","Nmom(%d)>MaxNmom(%d)",Nmom,MaxNmom);
  Nuc3ptCons *VectCurrp[MaxNmom][4];
  for(int ip(0);ip<Nmom;ip++) for (int i(X);i<4;i++){
      DIR d = DIR(i) ;
      Gamma G(d);
      VectCurrp[ip][i] = new Nuc3ptCons(mom[ip],G) ;
    }
  
  for ( int n = 0; n < num_qprop; n++ ) {
    QPropW* quark = new QPropWGaussSrc(*q_prop[n]);
    
    VectCurr.Calc3pt(*u_s_prop,*quark);
    for(int ip(0);ip<Nmom;ip++) 
      for (int i(X);i<4;i++)
	VectCurrp[ip][i]->Calc3pt(*u_s_prop,*quark);
    
    u_s_prop->DeleteQPropLs();
    
    if(Nuc3pt_arg->DoConserved == 1) {
      char dummy[30];
      d_s_prop->RestoreQPropLs_ftom(dummy);
    }
    
    VectCurr.Calc3pt(*d_s_prop,*quark);
    for(int ip(0);ip<Nmom;ip++) for (int i(X);i<4;i++)
				  VectCurrp[ip][i]->Calc3pt(*d_s_prop,*quark);
    
    d_s_prop->DeleteQPropLs();
    
    OpenFile(); 
    VectCurr.Print(fp) ;
    for(int ip(0);ip<Nmom;ip++) for (int i(X);i<4;i++)
				  VectCurrp[ip][i]->Print(fp) ;
    CloseFile();
    
    delete quark;
  }

  for(int ip(0);ip<Nmom;ip++) 
    for (int i(X);i<4;i++)
      delete VectCurrp[ip][i];

}
开发者ID:DeanHowarth,项目名称:QUDA-CPS,代码行数:57,代码来源:alg_nuc3pt.C


示例5: TestTermination

void TestTermination(
    Integrator const& integrator) {
  Length const q_initial = 1 * Metre;
  Speed const v_initial = 0 * Metre / Second;
  Instant const t_initial;
  Instant const t_final = t_initial + 163 * Second;
  Time const step = 42 * Second;
  int const steps = static_cast<int>(std::floor((t_final - t_initial) / step));

  int evaluations = 0;

  std::vector<ODE::SystemState> solution;
  ODE harmonic_oscillator;
  harmonic_oscillator.compute_acceleration =
      std::bind(ComputeHarmonicOscillatorAcceleration,
                _1, _2, _3, &evaluations);
  IntegrationProblem<ODE> problem;
  problem.equation = harmonic_oscillator;
  ODE::SystemState const initial_state = {{q_initial}, {v_initial}, t_initial};
  problem.initial_state = &initial_state;
  problem.t_final = t_final;
  problem.append_state = [&solution](ODE::SystemState const& state) {
    solution.push_back(state);
  };

  integrator.Solve(problem, step);

  EXPECT_EQ(steps, solution.size());
  EXPECT_THAT(solution.back().time.value,
              AllOf(Gt(t_final - step), Le(t_final)));
  switch (integrator.composition) {
    case BA:
    case ABA:
      EXPECT_EQ(steps * integrator.evaluations, evaluations);
      break;
    case BAB:
      EXPECT_EQ(steps * integrator.evaluations + 1, evaluations);
      break;
    default:
      LOG(FATAL) << "Invalid composition";
  }
  Length q_error;
  Speed v_error;
  for (int i = 0; i < steps; ++i) {
    Time const t = solution[i].time.value - t_initial;
    EXPECT_THAT(t, AlmostEquals((i + 1) * step, 0));
  }
}
开发者ID:eggrobin,项目名称:Principia,代码行数:48,代码来源:symplectic_runge_kutta_nyström_integrator_test.cpp


示例6: TestTermination

void TestTermination(Integrator const& integrator) {
  Length const q_initial = 1 * Metre;
  Speed const v_initial = 0 * Metre / Second;
  Instant const t_initial;
  Instant const t_final = t_initial + 1630 * Second;
  Time const step = 42 * Second;
  int const steps = static_cast<int>(std::floor((t_final - t_initial) / step));

  int evaluations = 0;

  std::vector<ODE::SystemState> solution;
  ODE harmonic_oscillator;
  harmonic_oscillator.compute_acceleration =
      std::bind(ComputeHarmonicOscillatorAcceleration,
                _1, _2, _3, &evaluations);
  IntegrationProblem<ODE> problem;
  problem.equation = harmonic_oscillator;
  ODE::SystemState const initial_state = {{q_initial}, {v_initial}, t_initial};
  problem.initial_state = &initial_state;
  auto append_state = [&solution](ODE::SystemState const& state) {
    solution.push_back(state);
  };

  auto const instance =
      integrator.NewInstance(problem, std::move(append_state), step);
  integrator.Solve(t_final, *instance);

  EXPECT_EQ(steps, solution.size());
  EXPECT_THAT(solution.back().time.value,
              AllOf(Gt(t_final - step), Le(t_final)));
  Length q_error;
  Speed v_error;
  for (int i = 0; i < steps; ++i) {
    Time const t = solution[i].time.value - t_initial;
    EXPECT_THAT(t, AlmostEquals((i + 1) * step, 0));
  }
}
开发者ID:mkalte666,项目名称:Principia,代码行数:37,代码来源:symmetric_linear_multistep_integrator_test.cpp


示例7: cellGreater

bool cellGreater(Cell cell, double val) {
    return cellRelOp(Gt(), cell, val);
}
开发者ID:alphaxxl,项目名称:hhvm,代码行数:3,代码来源:tv-comparisons.cpp


示例8: Nuc_c5


//.........这里部分代码省略.........
	    Nuc3pt_arg->mt[nt]+=Nuc3pt_arg->t_sink; // locations of the proton sinks
            Nuc3pt_arg->mt[nt]=Nuc3pt_arg->mt[nt]%(GJP.Tnodes()*GJP.TnodeSites());
	    q_prop[n]->GaussSmearSinkProp(Nuc3pt_arg->mt[nt],q_prop[n]->GaussArg());
          }
	  
	} //end smeared sink
      }


      //Now do the 3pt functions

      // If doing coherent sinks, don't calculate the 3pt functions until all the 
      // forward propagators have been calculated. --MFL
      int do_seq = 0;
//      int t_sink;

      if(Nuc3pt_arg->calc_seqQ != MULT_SEQ 
	&& Nuc3pt_arg->calc_seqQ != WRITE_MULT_SEQ 
	&& Nuc3pt_arg->calc_seqQ != READ_MULT_SEQ) {
	do_seq = 1;
        t_sink = ts + Nuc3pt_arg->t_sink;
      }
      // once all the forward propagators have been calculated,
      // do the sequential propagaotrs. --MFL
      else if (i_source == num_qprop-1) {
	do_seq = 1;
	t_sink = Nuc3pt_arg->t_source + Nuc3pt_arg->t_sink;
      }


      if(Nuc3pt_arg->DoUnPolarized && do_seq)
	{
	  // for conserved vector currents
	  Gamma Gt(T);
	  Nuc3ptCons VectCurr(Gt);
	  Nuc3ptCons *VectCurrp[4];
	  if(Nuc3pt_arg->DoConserved) {
	  for (int i(X);i<4;i++){
	    DIR d = DIR(i) ;
	    Gamma G(d);
	    VectCurrp[i] = new Nuc3ptCons(Nmom,G) ;
	  }
	  }

	  OpenFile();
	  Fprintf(fp,"UnPolarized Zero mom.\n");
	  CloseFile();

  	  //first do the zero momentum un-polarized stuff

	  //up-quark
	  GetTheSeqPropagator(t_sink,qmass,
			      PROT_U_SEQ,ZeroMom,PPAR);

	  //down-quark
	  GetTheSeqPropagator(t_sink,qmass,
			      PROT_D_SEQ,ZeroMom,PPAR);

	  calc_Scalar();         //needed for the sigma term
	  calc_Vector();	 //Vector current
	  calc_X_q_b();          //<x>_q (b) does not need non-zero momentum
	  for(int i(0) ; i<Nmom ; i++) calc_Vector(sink_mom[i]);

	  //conserved current
	  if(Nuc3pt_arg->DoConserved) {
	    if(GJP.Snodes()==2) u_s_prop->SwapQPropLs();
开发者ID:DeanHowarth,项目名称:QUDA-CPS,代码行数:67,代码来源:alg_nuc3pt.C


示例9: init

    virtual void init(Voxel& voxel)
    {

        half_odf_size = voxel.ti.half_vertices_count;
        unsigned int b_count = voxel.bvalues.size();
        icosa_data.resize(half_odf_size*3);
        for (unsigned int index = 0; index < half_odf_size; ++index)
            std::copy(voxel.ti.vertices[index].begin(),voxel.ti.vertices[index].end(),icosa_data.begin()+index*3);

        float interop_angle = voxel.param[0]/180.0*M_PI;
        float smoothing_angle = voxel.param[1]/180.0*M_PI;

        Ht.resize(half_odf_size*b_count); // n * m
        // H=phi(acos(QtV))
        for (unsigned int n = 0,index = 0; n < half_odf_size; ++n)
            for (unsigned int m = 0; m < b_count; ++m,++index)
            {
                float value = std::abs(
                                  voxel.bvectors[m]*image::vector<3,float>(voxel.ti.vertices[n]));
                Ht[index] = spherical_guassian(value,interop_angle);
            }
        iHtH.resize(half_odf_size*half_odf_size);
        iHtH_pivot.resize(half_odf_size);
        image::matrix::square(Ht.begin(),iHtH.begin(),image::dyndim(half_odf_size,b_count));

        image::matrix::lu_decomposition(iHtH.begin(),iHtH_pivot.begin(),image::dyndim(half_odf_size,half_odf_size));

        // vector of angles
        std::vector<float> C(3*k); // 3 by k matrix
        for (unsigned int index = 0; index < k; ++index)
        {
            C[index] = std::cos(2.0*M_PI*((float)index+1)/((float)k));
            C[k+index] = std::sin(2.0*M_PI*((float)index+1)/((float)k));
            C[k+k+index] = 0.0;
        }
        // RC

        std::vector<float> G(half_odf_size*half_odf_size);
        std::vector<float> icosa_data_r(half_odf_size*3);
        for (unsigned int gi = 0; gi < half_odf_size; ++gi)
        {
            image::vector<3,float> u(voxel.ti.vertices[gi]);
            float r[9];// a 3-by-3 matrix
            rotation_matrix(r,u.begin());
            std::vector<float> Gt(half_odf_size*k); // a half_odf_size-by-k matrix

            // 	Gt = icosa_data*r*C;
            image::matrix::product(icosa_data.begin(),r,icosa_data_r.begin(),image::dyndim(half_odf_size,3),image::dim<3,3>());
            image::matrix::product(icosa_data_r.begin(),C.begin(),Gt.begin(),image::dyndim(half_odf_size,3),image::dyndim(3,k));

            for (unsigned int i = 0; i < Gt.size(); ++i)
                Gt[i] = spherical_guassian(std::abs(Gt[i]),interop_angle);

            unsigned int posgi = gi*half_odf_size;
            for (unsigned int i = 0,posi = 0; i < half_odf_size; ++i,posi+=k)
                G[posgi+i] = std::accumulate(Gt.begin()+posi,Gt.begin()+posi+k,0.0);
        }

        // add smoothing to G
        std::vector<float> S(half_odf_size*half_odf_size);
        for (unsigned int i = 0; i < half_odf_size; ++i)
        {
            float sum = 0.0;
            for (unsigned int j = 0,index = i*half_odf_size; j < half_odf_size; ++j,++index)
                sum +=
                    S[index] = spherical_guassian(std::abs(voxel.ti.vertices_cos(i,j)),smoothing_angle);

            for (unsigned int j = 0,index = i*half_odf_size; j < half_odf_size; ++j,++index)
                S[index] /= sum;
        }
        sG.resize(half_odf_size*half_odf_size);
        //sG = S*G;
        image::matrix::product(S.begin(),G.begin(),sG.begin(),image::dyndim(half_odf_size,half_odf_size),image::dyndim(half_odf_size,half_odf_size));

    }
开发者ID:YounesN,项目名称:DSI-Studio,代码行数:75,代码来源:qbi_process.hpp


示例10: TestConvergence

void TestConvergence(Integrator const& integrator,
                     Time const& beginning_of_convergence) {
  Length const q_initial = 1 * Metre;
  Speed const v_initial = 0 * Metre / Second;
  Speed const v_amplitude = 1 * Metre / Second;
  AngularFrequency const ω = 1 * Radian / Second;
  Instant const t_initial;
  Instant const t_final = t_initial + 100 * Second;

  Time step = beginning_of_convergence;
  int const step_sizes = 50;
  double const step_reduction = 1.1;
  std::vector<double> log_step_sizes;
  log_step_sizes.reserve(step_sizes);
  std::vector<double> log_q_errors;
  log_step_sizes.reserve(step_sizes);
  std::vector<double> log_p_errors;
  log_step_sizes.reserve(step_sizes);

  std::vector<ODE::SystemState> solution;
  ODE harmonic_oscillator;
  harmonic_oscillator.compute_acceleration =
      std::bind(ComputeHarmonicOscillatorAcceleration,
                _1, _2, _3, /*evaluations=*/nullptr);
  IntegrationProblem<ODE> problem;
  problem.equation = harmonic_oscillator;
  ODE::SystemState const initial_state = {{q_initial}, {v_initial}, t_initial};
  problem.initial_state = &initial_state;
  ODE::SystemState final_state;
  auto const append_state = [&final_state](ODE::SystemState const& state) {
    final_state = state;
  };

  for (int i = 0; i < step_sizes; ++i, step /= step_reduction) {
    auto const instance = integrator.NewInstance(problem, append_state, step);
    integrator.Solve(t_final, *instance);
    Time const t = final_state.time.value - t_initial;
    Length const& q = final_state.positions[0].value;
    Speed const& v = final_state.velocities[0].value;
    double const log_q_error = std::log10(
        AbsoluteError(q / q_initial, Cos(ω * t)));
    double const log_p_error = std::log10(
        AbsoluteError(v / v_amplitude, -Sin(ω * t)));
    if (log_q_error <= -13 || log_p_error <= -13) {
      // If we keep going the effects of finite precision will drown out
      // convergence.
      break;
    }
    log_step_sizes.push_back(std::log10(step / Second));
    log_q_errors.push_back(log_q_error);
    log_p_errors.push_back(log_p_error);
  }
  double const q_convergence_order = Slope(log_step_sizes, log_q_errors);
  double const q_correlation =
      PearsonProductMomentCorrelationCoefficient(log_step_sizes, log_q_errors);
  LOG(INFO) << "Convergence order in q : " << q_convergence_order;
  LOG(INFO) << "Correlation            : " << q_correlation;

#if !defined(_DEBUG)
  EXPECT_THAT(RelativeError(integrator.order, q_convergence_order),
              Lt(0.05));
  EXPECT_THAT(q_correlation, AllOf(Gt(0.99), Lt(1.01)));
#endif
  double const v_convergence_order = Slope(log_step_sizes, log_p_errors);
  double const v_correlation =
      PearsonProductMomentCorrelationCoefficient(log_step_sizes, log_p_errors);
  LOG(INFO) << "Convergence order in p : " << v_convergence_order;
  LOG(INFO) << "Correlation            : " << v_correlation;
#if !defined(_DEBUG)
  // SPRKs with odd convergence order have a higher convergence order in p.
  EXPECT_THAT(
      RelativeError(integrator.order + (integrator.order % 2),
                    v_convergence_order),
      Lt(0.03));
  EXPECT_THAT(v_correlation, AllOf(Gt(0.99), Lt(1.01)));
#endif
}
开发者ID:mkalte666,项目名称:Principia,代码行数:77,代码来源:symmetric_linear_multistep_integrator_test.cpp


示例11: Gt

Gt operator>(const FieldType& fld, const FieldType& o2) {
    return Gt(fld, o2);
}
开发者ID:aclysma,项目名称:Helium,代码行数:3,代码来源:expr.cpp


示例12: Eq

 static bool Eq(Value lhs, Value rhs) { return !Lt(lhs, rhs) && !Gt(lhs, rhs); }
开发者ID:Mapotempo,项目名称:omim,代码行数:1,代码来源:hotels_filter.hpp


示例13: pushToken__

void Parser::executeAction(int production) try {
    if (d_token__ != _UNDETERMINED_)
        pushToken__(d_token__); // save an already available token

    // $insert defaultactionreturn
    // save default non-nested block $$
    if (int size = s_productionInfo[production].d_size)
        d_val__ = d_vsp__[1 - size];

    switch (production) {
        // $insert actioncases

        case 1:
#line 43 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = d_vsp__[0].data<Tag__::basic>();
            res = d_val__.get<Tag__::basic>();
        } break;

        case 2:
#line 51 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = add(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 3:
#line 54 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = sub(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 4:
#line 57 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = mul(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 5:
#line 60 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = div(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 6:
#line 63 "parser.yy"
        {
            auto tup = parse_implicit_mul(d_vsp__[-2].data<Tag__::string>());
            if (neq(*std::get<1>(tup), *one)) {
                d_val__.get<Tag__::basic>() = mul(
                    std::get<0>(tup),
                    pow(std::get<1>(tup), d_vsp__[0].data<Tag__::basic>()));
            } else {
                d_val__.get<Tag__::basic>()
                    = pow(std::get<0>(tup), d_vsp__[0].data<Tag__::basic>());
            }
        } break;

        case 7:
#line 73 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = pow(d_vsp__[-2].data<Tag__::basic>(),
                                              d_vsp__[0].data<Tag__::basic>());
        } break;

        case 8:
#line 76 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Lt(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

        case 9:
#line 79 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Gt(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

        case 10:
#line 82 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Le(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

        case 11:
#line 85 "parser.yy"
        {
            d_val__.get<Tag__::basic>() = rcp_static_cast<const Basic>(
                Ge(d_vsp__[-2].data<Tag__::basic>(),
                   d_vsp__[0].data<Tag__::basic>()));
        } break;

//.........这里部分代码省略.........
开发者ID:symengine,项目名称:symengine,代码行数:101,代码来源:parser.cpp


示例14: TEST_P

TEST_P(SimpleHarmonicMotionTest, Convergence) {
  parameters_.initial.positions.emplace_back(SIUnit<Length>());
  parameters_.initial.momenta.emplace_back(Speed());
  parameters_.initial.time = Time();
#if defined(_DEBUG)
  parameters_.tmax = 1 * SIUnit<Time>();
#else
  parameters_.tmax = 100 * SIUnit<Time>();
#endif
  parameters_.sampling_period = 0;
  parameters_.Δt = GetParam().beginning_of_convergence;
  int const step_sizes = 50;
  double const step_reduction = 1.1;
  std::vector<double> log_step_sizes;
  log_step_sizes.reserve(step_sizes);
  std::vector<double> log_q_errors;
  log_step_sizes.reserve(step_sizes);
  std::vector<double> log_p_errors;
  log_step_sizes.reserve(step_sizes);
  for (int i = 0; i < step_sizes; ++i, parameters_.Δt /= step_reduction) {
    integrator_->SolveTrivialKineticEnergyIncrement<Length>(
        &ComputeHarmonicOscillatorAcceleration,
        parameters_,
        &solution_);
    double const log_q_error = std::log10(
        std::abs(solution_[0].positions[0].value / SIUnit<Length>() -
                 Cos(solution_[0].time.value *
                     SIUnit<AngularFrequency>())));
    double const log_p_error = std::log10(
        std::abs(solution_[0].momenta[0].value / SIUnit<Speed>() +
                 Sin(solution_[0].time.value *
                     SIUnit<AngularFrequency>())));
    if (log_q_error <= -13 || log_p_error <= -13) {
      // If we keep going the effects of finite precision will drown out
      // convergence.
      break;
    }
    log_step_sizes.push_back(std::log10(parameters_.Δt / SIUnit<Time>()));
    log_q_errors.push_back(log_q_error);
    log_p_errors.push_back(log_p_error);
  }
  double const q_convergence_order = Slope(log_step_sizes, log_q_errors);
  double const q_correlation =
      PearsonProductMomentCorrelationCoefficient(log_step_sizes, log_q_errors);
  LOG(INFO) << GetParam();
  LOG(INFO) << "Convergence order in q : " << q_convergence_order;
  LOG(INFO) << "Correlation            : " << q_correlation;
#if 0
  LOG(INFO) << "Convergence data for q :\n" <<
      BidimensionalDatasetMathematicaInput(log_step_sizes, log_q_errors);
#endif
#if !defined(_DEBUG)
  EXPECT_THAT(RelativeError(GetParam().convergence_order, q_convergence_order),
              Lt(0.02));
  EXPECT_THAT(q_correlation, AllOf(Gt(0.99), Lt(1.01)));
#endif
  double const v_convergence_order = Slope(log_step_sizes, log_p_errors);
  double const v_correlation =
      PearsonProductMomentCorrelationCoefficient(log_step_sizes, log_p_errors);
  LOG(INFO) << "Convergence order in p : " << v_convergence_order;
  LOG(INFO) << "Correlation            : " << v_correlation;
#if 0
  LOG(INFO) << "Convergence data for p :\n" <<
      BidimensionalDatasetMathematicaInput(log_step_sizes, log_q_errors);
#endif
#if !defined(_DEBUG)
  // SPRKs with odd convergence order have a higher convergence order in p.
  EXPECT_THAT(
     RelativeError(((GetParam().convergence_order + 1) / 2) * 2,
                   v_convergence_order),
     Lt(0.02));
  EXPECT_THAT(v_correlation, AllOf(Gt(0.99), Lt(1.01)));
#endif
}
开发者ID:Artoria2e5,项目名称:Principia,代码行数:74,代码来源:simple_harmonic_motion.cpp


示例15: TEST_F

TEST_F(ManœuvreTest, Apollo8SIVB) {
    // Data from NASA's Saturn V Launch Vehicle, Flight Evaluation Report AS-503,
    // Apollo 8 Mission (1969),
    // http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/19690015314.pdf.
    // We use the reconstructed or actual values.

    // Table 2-2. Significant Event Times Summary.
    Instant const range_zero;
    Instant const s_ivb_1st_90_percent_thrust = range_zero +    530.53 * Second;
    Instant const s_ivb_1st_eco               = range_zero +    684.98 * Second;
    // Initiate S-IVB Restart Sequence and Start of Time Base 6 (T6).
    Instant const t6                          = range_zero +   9659.54 * Second;
    Instant const s_ivb_2nd_90_percent_thrust = range_zero + 10'240.02 * Second;
            Instant const s_ivb_2nd_eco               = range_zero + 10'555.51 * Second;

    // From Table 7-2. S-IVB Steady State Performance - First Burn.
    Force thrust_1st                  = 901'557 * Newton;
                                        Speed specific_impulse_1st        = 4'204.1 * Newton * Second / Kilogram;
    Variation<Mass> lox_flowrate_1st  = 178.16 * Kilogram / Second;
    Variation<Mass> fuel_flowrate_1st = 36.30 * Kilogram / Second;

    // From Table 7-7. S-IVB Steady State Performance - Second Burn.
    Force thrust_2nd                  = 897'548 * Newton;
                                        Speed specific_impulse_2nd        = 4199.2 * Newton * Second / Kilogram;
                                        Variation<Mass> lox_flowrate_2nd  = 177.70 * Kilogram / Second;
                                        Variation<Mass> fuel_flowrate_2nd = 36.01 * Kilogram / Second;

                                        // Table 21-5. Total Vehicle Mass, S-IVB First Burn Phase, Kilograms.
                                        Mass total_vehicle_at_s_ivb_1st_90_percent_thrust = 161143 * Kilogram;
                                        Mass total_vehicle_at_s_ivb_1st_eco               = 128095 * Kilogram;

                                        // Table 21-7. Total Vehicle Mass, S-IVB Second Burn Phase, Kilograms.
                                        Mass total_vehicle_at_s_ivb_2nd_90_percent_thrust = 126780 * Kilogram;
                                        Mass total_vehicle_at_s_ivb_2nd_eco               =  59285 * Kilogram;

                                        // An arbitrary direction, we're not testing this.
                                        Vector<double, World> e_y({0, 1, 0});

    Manœuvre<World> first_burn(thrust_1st,
                                total_vehicle_at_s_ivb_1st_90_percent_thrust,
                                specific_impulse_1st, e_y);
    EXPECT_THAT(RelativeError(lox_flowrate_1st + fuel_flowrate_1st,
                              first_burn.mass_flow()),
                Lt(1E-4));

    first_burn.set_duration(s_ivb_1st_eco - s_ivb_1st_90_percent_thrust);
    EXPECT_THAT(
        RelativeError(total_vehicle_at_s_ivb_1st_eco, first_burn.final_mass()),
        Lt(1E-3));

    first_burn.set_initial_time(s_ivb_1st_90_percent_thrust);
    EXPECT_EQ(s_ivb_1st_eco, first_burn.final_time());

    // Accelerations from Figure 4-4. Ascent Trajectory Acceleration Comparison.
    // Final acceleration from Table 4-2. Comparison of Significant Trajectory
    // Events.
    EXPECT_THAT(
        first_burn.acceleration()(first_burn.initial_time()).Norm(),
        AllOf(Gt(5 * Metre / Pow<2>(Second)), Lt(6.25 * Metre / Pow<2>(Second))));
    EXPECT_THAT(first_burn.acceleration()(range_zero + 600 * Second).Norm(),
                AllOf(Gt(6.15 * Metre / Pow<2>(Second)),
                      Lt(6.35 * Metre / Pow<2>(Second))));
    EXPECT_THAT(first_burn.acceleration()(first_burn.final_time()).Norm(),
                AllOf(Gt(7.03 * Metre / Pow<2>(Second)),
                      Lt(7.05 * Metre / Pow<2>(Second))));

    Manœuvre<World> second_burn(thrust_2nd,
                                 total_vehicle_at_s_ivb_2nd_90_percent_thrust,
                                 specific_impulse_2nd, e_y);
    EXPECT_THAT(RelativeError(lox_flowrate_2nd + fuel_flowrate_2nd,
                              second_burn.mass_flow()),
                Lt(2E-4));

    second_burn.set_duration(s_ivb_2nd_eco - s_ivb_2nd_90_percent_thrust);
    EXPECT_THAT(
        RelativeError(total_vehicle_at_s_ivb_2nd_eco, second_burn.final_mass()),
        Lt(2E-3));

    second_burn.set_initial_time(s_ivb_2nd_90_percent_thrust);
    EXPECT_EQ(s_ivb_2nd_eco, second_burn.final_time());

    // Accelerations from Figure 4-9. Injection Phase Acceleration Comparison.
    // Final acceleration from Table 4-2. Comparison of Significant Trajectory
    // Events.
    EXPECT_THAT(second_burn.acceleration()(second_burn.initial_time()).Norm(),
                AllOf(Gt(7 * Metre / Pow<2>(Second)),
                      Lt(7.5 * Metre / Pow<2>(Second))));
    EXPECT_THAT(second_burn.acceleration()(t6 + 650 * Second).Norm(),
                AllOf(Gt(8 * Metre / Pow<2>(Second)),
                      Lt(8.02 * Metre / Pow<2>(Second))));
    EXPECT_THAT(second_burn.acceleration()(t6 + 700 * Second).Norm(),
                AllOf(Gt(8.8 * Metre / Pow<2>(Second)),
                      Lt(9 * Metre / Pow<2>(Second))));
    EXPECT_THAT(second_burn.acceleration()(t6 + 750 * Second).Norm(),
                AllOf(Gt(9.9 * Metre / Pow<2>(Second)),
                      Lt(10 * Metre / Pow<2>(Second))));
    EXPECT_THAT(second_burn.acceleration()(t6 + 850 * Second).Norm(),
                AllOf(Gt(12.97 * Metre / Pow<2>(Second)),
                      Lt(13 * Metre / Pow<2>(Second))));
    EXPECT_THAT(second_burn.acceleration()(second_burn.final_time()).Norm(),
//.........这里部分代码省略.........
开发者ID:Wavechaser,项目名称:Principia,代码行数:101,代码来源:manœuvre_test.cpp


示例16: EvaluatePhong

void EvaluatePhong(const bool adjoint,
                   const ADFloat *buffer,
                   const ADVector3 &wi,
                   const ADVector3 &normal,
                   const ADVector3 &wo,
                   const ADVector2 st,
                   ADVector3 &contrib,
                   ADFloat &cosWo,
                   ADFloat &pdf,
                   ADFloat &revPdf) {
    ADVector3 Kd;
    ADVector3 Ks;
    ADFloat exponent;
    ADFloat KsWeight;
    buffer = Deserialize(buffer, Kd);
    buffer = Deserialize(buffer, Ks);
    buffer = Deserialize(buffer, exponent);
    buffer = Deserialize(buffer, KsWeight);

    ADFloat cosWi = Dot(normal, wi);
    std::vector<CondExprCPtr> ret = CreateCondExprVec(4);
    BeginIf(Gt(cosWi, Float(0.0)), ret);
    { SetCondOutput({normal[0], normal[1], normal[2], cosWi}); }
    BeginElse();
    { SetCondOutput({-normal[0], -normal[1], -normal[2], -cosWi}); }
    EndIf();
    ADVector3 normal_(ret[0], ret[1], ret[2]);
    cosWi = ret[3];
    cosWo = Dot(normal_, wo);
    ret = CreateCondExprVec(4);
    BeginIf(Gt(KsWeight, Float(0.0)), ret);
    {
        ADFloat alpha = Dot(Reflect(wi, normal_), wo);
        ADFloat weight = pow(alpha, exponent) * c_INVTWOPI;
        std::vector<CondExprCPtr> ret = CreateCondExprVec(4);
        BeginIf(Gt(weight, Float(1e-10)), ret);
        {
            ADFloat expoConst1 = (exponent + Float(1.0));
            ADFloat expoConst2 = (exponent + Float(2.0));
            ADVector3 specContrib = Ks * (expoConst2 * weight);
            ADFloat specPdf = KsWeight * expoConst1 * weight;
            SetCondOutput({specContrib[0], specContrib[1], specContrib[2], specPdf});
        }
        BeginElse();
        {
            SetCondOutput({Const<ADFloat>(0.0),
                           Const<ADFloat>(0.0),
                           Const<ADFloat>(0.0),
                           Const<ADFloat>(0.0)});
        }
        EndIf();
        ADVector3 specContrib = ADVector3(ret[0], ret[1], ret[2]);
        ADFloat specPdf = ret[3];
        SetCondOutput({specContrib[0], specContrib[1], specContrib[2], specPdf});
    }
    BeginElse();
    {
        SetCondOutput(
            {Const<ADFloat>(0.0), Const<ADFloat>(0.0), Const<ADFloat>(0.0), Const<ADFloat>(0.0)});
    }
    EndIf();
    contrib[0] = ret[0];
    contrib[1] = ret[1];
    contrib[2] = ret[2];
    pdf = ret[3];
    revPdf = ret[3];

    ret = CreateCondExprVec(5);
    BeginIf(Lt(KsWeight, Float(1.0)), ret);
    {
        ADVector3 diffContrib = Kd * Const<ADFloat>(c_INVPI);
        ADFloat tmp = (Float(1.0) - KsWeight) * c_INVPI;
        ADFloat diffPdf = tmp * cosWo;
        ADFloat revDiffPdf = tmp * cosWi;
        SetCondOutput({diffContrib[0], diffContrib[1], diffContrib[2], diffPdf, revDiffPdf});
    }
    BeginElse();
    {
        SetCondOutput({Const<ADFloat>(0.0),
                       Const<ADFloat>(0.0),
                       Const<ADFloat>(0.0),
                       Const<ADFloat>(0.0),
                       Const<ADFloat>(0.0)});
    }
    EndIf();
    contrib[0] += ret[0];
    contrib[1] += ret[1];
    contrib[2] += ret[2];
    pdf += ret[3];
    revPdf += ret[4];
    contrib *= cosWo;
}
开发者ID:bssrdf,项目名称:dpt,代码行数:92,代码来源:phong.cpp


示例17: cellGreater

bool cellGreater(const Cell* cell, bool val) {
  return cellRelOp(Gt(), cell, val);
}
开发者ID:floreal,项目名称:hiphop-php,代码行数:3,代码来源:tv_comparisons.cpp


示例18: tvGreater

bool tvGreater(const TypedValue* tv1, const TypedValue* tv2) {
  return tvRelOp(Gt(), tv1, tv2);
}
开发者ID:floreal,项目名称:hiphop-php,代码行数:3,代码来源:tv_comparisons.cpp


示例19: tvGreater

bool tvGreater(TypedValue tv1, TypedValue tv2) {
    return tvRelOp(Gt(), tv1, tv2);
}
开发者ID:alphaxxl,项目名称:hhvm,代码行数:3,代码来源:tv-comparisons.cpp


示例20: SamplePhong

void SamplePhong(const bool adjoint,
                 const ADFloat *buffer,
                 const ADVector3 &wi,
                 const ADVector3 &normal,
                 const ADVector2 st,
                 const ADVector2 rndParam,
                 const ADFloat uDiscrete,
                 const bool fixDiscrete,
                 ADVector3 &wo,
                 ADVector3 &contrib,
                 ADFloat &cosWo,
                 ADFloat &pdf,
                 ADFloat &revPdf) {
    ADVector3 Kd;
    ADVector3 Ks;
    ADFloat exponent;
    ADFloat KsWeight;
    buffer = Deserialize(buffer, Kd);
    buffer = Deserialize(buffer, Ks);
    buffer = Deserialize(buffer, exponent);
    buffer = Deserialize(buffer, KsWeight);

    ADFloat cosWi = Dot(normal, wi);
    std::vector<CondExprCPtr> ret = CreateCondExprVec(4);
    BeginIf(Gt(cosWi, Float(0.0)), ret);
    { SetCondOutput({normal[0], normal[1], normal[2], cosWi}); }
    BeginElse();
    { SetCondOutput({-normal[0], -normal[1], -normal[2], -cosWi}); }
    EndIf();
    ADVector3 normal_(ret[0], ret[1], ret[2]);
    cosWi = ret[3];
    ADVector3 R = Reflect(wi, normal_);
    ret = CreateCondExprVec(4);
    BeginIf(Gt(uDiscrete, KsWeight), ret);
    {
        ADVector3 localDir = SampleCosHemisphere(rndParam);
        ADVector3 b0;
        ADVector3 b1;
        CoordinateSystem(normal_, b0, b1);
        ADVector3 wo = localDir[0] * b0 + localDir[1] * b1 + localDir[2] * normal_;
        ADFloat factor = (Float(1.0) - KsWeight);
        SetCondOutput({wo[0], wo[1], wo[2], factor});
    }
    BeginElse();
    {
        ADFloat power = Float(1.0) / (exponent + Float(1.0));
        ADFloat cosAlpha = pow(rndParam[1], power);
        // Ugly hack to avoid sqrt(0) which has undefined derivatives...
        ADFloat sinAlpha = sqrt(fmax(Float(1.0) - square(cosAlpha), Float(1e-6)));
        ADFloat phi = c_TWOPI * rndParam[0];
        ADVector3 localDir = ADVector3(sinAlpha * cos(phi), sinAlpha * sin(phi), cosAlpha);
        ADVector3 b0;
        ADVector3 b1;
        CoordinateSystem(R, b0, b1);
        ADVector3 wo = localDir[0] * b0 + localDir[1] * b1 + localDir[2] * R;
        ADFloat factor = KsWeight;
        SetCondOutput({wo[0], wo[1], wo[2], factor});
    }
    EndIf();
    wo = ADVector3(ret[0], ret[1], ret[2]);
    ADFloat factor = ret[3];
    cosWo = Dot(normal_, wo);

    BeginIf(Gt(KsWeight, Float(0.0)), ret);
    {
        ADFloat alpha = fmax(Dot(Reflect(wi, normal_), wo), Float(0.0));
        ADFloat weight = pow(alpha, exponent) * c_INVTWOPI;
        ADFloat expoConst1 = (exponent + Float(1.0));
        ADFloat expoConst2 = (exponent + Float(2.0));
        std::vector<CondExprCPtr> ret = CreateCondExprVec(4);
        BeginIf(Gt(weight, Float(1e-10)), ret);
        {
            ADVector3 specContrib = Ks * (expoConst2 * weight);
            ADFloat specPdf = KsWeight * expoConst1 * weight;
            SetCondOutput({specContrib[0], specContrib[1], specContrib[2], specPdf});
        }
        BeginElse();
        {
            SetCondOutput({Const<ADFloat>(0.0),
                           Const<ADFloat>(0.0),
                           Const<ADFloat>(0.0),
                           Const<ADFloat>(0.0)});
        }
        EndIf();
        ADVector3 specContrib = ADVector3(ret[0], ret[1], ret[2]);
        ADFloat specPdf = ret[3];
        SetCondOutput({specContrib[0], specContrib[1], specContrib[2], specPdf});
    }
    BeginElse();
    {
        SetCondOutput(
            {Const<ADFloat>(0.0), Const<ADFloat>(0.0), Const<ADFloat>(0.0), Const<ADFloat>(0.0)});
    }
    EndIf();
    contrib[0] = ret[0];
    contrib[1] = ret[1];
    contrib[2] = ret[2];
    pdf = ret[3];
    revPdf = ret[3];

//.........这里部分代码省略.........
开发者ID:bssrdf

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Guard函数代码示例发布时间:2022-05-30
下一篇:
C++ Grid函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap