當前位置: 首頁>>代碼示例>>C++>>正文


C++ VectorXd::squaredNorm方法代碼示例

本文整理匯總了C++中eigen::VectorXd::squaredNorm方法的典型用法代碼示例。如果您正苦於以下問題:C++ VectorXd::squaredNorm方法的具體用法?C++ VectorXd::squaredNorm怎麽用?C++ VectorXd::squaredNorm使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在eigen::VectorXd的用法示例。


在下文中一共展示了VectorXd::squaredNorm方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: if

double L2R_Huber_SVC::get_func(const Eigen::VectorXd &w) {
  z = y * (X * w).array();
  int indexD2 = 0;
  double zi, tmp;
  double f = 0;
  indexs_D1.clear();
  indexs_D2.clear();
  XD2w_yD2 = Eigen::VectorXd::Zero(l);

  for (int i = 0; i < l; ++i) {
    zi = z.coeffRef(i);
    tmp = 1 - zi;
    if (zi <= 0) {
      indexs_D1.push_back(i);
      f += (tmp - 0.5);
    } else if (zi < 1) {
      indexs_D2.push_back(i);
      f += tmp * tmp * 0.5;
      XD2w_yD2.coeffRef(indexD2) = -y.coeffRef(i) * tmp;
      ++indexD2;
    }
  }
  f *= C;
  f += w.squaredNorm() / 2.0;
  return f;
}
開發者ID:husk214,項目名稱:RPCVELB,代碼行數:26,代碼來源:L2R_Huber_SVC.cpp

示例2:

double l2r_l1hinge_spdc::get_primal_func(const Eigen::VectorXd &w) const {
  Eigen::ArrayXd wx = y_ * (x_ * w).array();
  double tmp = 0.0;
  for (int i = 0; i < num_ins_; ++i)
    tmp += std::max(0.0, 1.0 - wx[i]);
  return 0.5 * w.squaredNorm() + C * tmp;
}
開發者ID:husk214,項目名稱:rp-velb,代碼行數:7,代碼來源:l2r_l1hinge_spdc.cpp

示例3: gradientStep

double SmoothDualDecompositionFistaDescent::gradientStep(double rho,
            const Eigen::VectorXd& lambda,
            double& obj_lambda,
            Eigen::VectorXd& gradient,
            double& gradient_norm_squared,
            Eigen::VectorXd& y, double& omega)
{
    double obj_new;
    double obj_approx;
    
    // evaluate objective, gradient and gradient norm
    obj_lambda = computeObjectiveAndGradient(rho, gradient, lambda);
    gradient_norm_squared = gradient.squaredNorm();

    // backtracking
    do {
        y = lambda + gradient*(1.0/omega);
        obj_new = computeObjective(rho, y);
        obj_approx = obj_lambda+1/(2.0*omega)*gradient_norm_squared;
        if (obj_new < obj_approx) {
            omega *= _lipschitz_inc_u;
        }
    } while(obj_new < obj_approx);
    omega = std::max(_lipschitz_constant_optimistic, omega/_lipschitz_inc_d);

    return obj_new;
}
開發者ID:ppletscher,項目名稱:lpqp,代碼行數:27,代碼來源:SmoothDualDecompositionFistaDescent.cpp

示例4: determineNewTimeStep

bool AdaptiveTimeStepper::determineNewTimeStep(
    const Eigen::VectorXd & errorEstimate,
    const Eigen::VectorXd & solution,
    const double computedTimeStep,
    double & newTimeStep
    )
{
    assert( endTime > 0 );

    scalarList squaredNorm( Pstream::nProcs(), scalar( 0 ) );
    squaredNorm[Pstream::myProcNo()] = errorEstimate.squaredNorm();
    reduce( squaredNorm, sumOp<scalarList>() );
    double error = std::sqrt( sum( squaredNorm ) );

    squaredNorm = 0;
    squaredNorm[Pstream::myProcNo()] = solution.squaredNorm();
    reduce( squaredNorm, sumOp<scalarList>() );
    error /= std::sqrt( sum( squaredNorm ) );

    return determineNewTimeStep( error, computedTimeStep, newTimeStep );
}
開發者ID:KangX1,項目名稱:FOAM-FSI,代碼行數:21,代碼來源:AdaptiveTimeStepper.C

示例5: CalcObjVal

double cIKSolver::CalcObjVal(const Eigen::MatrixXd &joint_desc, const Eigen::VectorXd& pose, const Eigen::MatrixXd& cons_desc)
{
	// objective function is the 2-norm of the constraint violations
	double obj_val = 0;
	Eigen::VectorXd err;
	for (int c = 0; c < cons_desc.rows(); ++c)
	{
		const tConsDesc& curr_cons = cons_desc.row(c);
		double weight = curr_cons(eConsDesc::eConsDescWeight);
		err = BuildErr(joint_desc, pose, curr_cons);
		obj_val += weight * err.squaredNorm();
	}
	return obj_val;
}
開發者ID:bssrdf,項目名稱:DeepTerrainRL,代碼行數:14,代碼來源:IKSolver.cpp

示例6: option_value

 SimuEuro(const option & o, long path, const std::vector<double> & RN){
     opt=o;
     N= path;
     asset_price.resize(N);
     asset_price.setZero();
     option_value= asset_price;
     
     for (long i=0; i< N; i++) {
         asset_price(i)=opt.S* exp((opt.r- opt.q)*opt.T-.5*opt.sigma*opt.sigma*opt.T+ opt.sigma* sqrt(opt.T)* RN[i]);
         
         if(opt.Call) option_value(i)= fmax(asset_price(i)- opt.K,0.0);
         else option_value(i)= fmax(-asset_price(i)+opt.K, 0.0);
     }
     
     mean= option_value.sum()/ option_value.size() * exp(-opt.T*opt.r);
     stdiv= option_value.squaredNorm()/ option_value.size()* exp(-opt.r*opt.T *2);
     stdiv= stdiv- pow(mean,2.0);
     stdiv= sqrt(stdiv/ N);
 };
開發者ID:ericwbzhang,項目名稱:QuantLib_2.0,代碼行數:19,代碼來源:SimuEuro.hpp


注:本文中的eigen::VectorXd::squaredNorm方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。