当前位置: 首页>>代码示例>>C++>>正文


C++ Matrix::squaredNorm方法代码示例

本文整理汇总了C++中eigen::Matrix::squaredNorm方法的典型用法代码示例。如果您正苦于以下问题:C++ Matrix::squaredNorm方法的具体用法?C++ Matrix::squaredNorm怎么用?C++ Matrix::squaredNorm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eigen::Matrix的用法示例。


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

示例1: check_unit_vector

 bool check_unit_vector(const char* function,
                    const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta,
                    const char* name,
                    T_result* result) {
   typedef typename Eigen::Matrix<T_prob,Eigen::Dynamic,1>::size_type size_t;
   if (theta.size() == 0) {
     std::string message(name);
     message += " is not a valid unit vector. %1% elements in the vector.";
     return dom_err(function,0,name,
                    message.c_str(),"",
                    result);
   }
   T_prob ssq = theta.squaredNorm();
   if (fabs(1.0 - ssq) > CONSTRAINT_TOLERANCE) {
     std::stringstream msg;
     msg << "in function check_unit_vector(%1%), ";
     msg << name << " is not a valid unit vector.";
     msg << " The sum of the squares of the elements should be 1, but is " << ssq;
     std::string tmp(msg.str());
     return dom_err(function,ssq,name,
                    tmp.c_str(),"",
                    result);
   }
   return true;
 }
开发者ID:HerraHuu,项目名称:stan,代码行数:25,代码来源:check_unit_vector.hpp

示例2: cholesky_downdate

void cholesky_downdate (Eigen::Matrix<double, N, N>& L, Eigen::Matrix<double, N, 1> p) {

	L.template triangularView<Eigen::Lower>().solveInPlace(p);

	assert(p.squaredNorm() < 1); // otherwise the downdate would destroy positive definiteness.
	double rho = std::sqrt (1 - p.squaredNorm());

	Eigen::JacobiRotation<double> rot;
	Eigen::Matrix<double, N, 1> temp;
	temp.setZero();

	for (int i = N-1; i >= 0; --i) {
		rot.makeGivens(rho, p(i), &rho), p(i) = 0;
		apply_jacobi_rotation(temp, L.col(i), rot);
	}
}
开发者ID:caomw,项目名称:slam-4,代码行数:16,代码来源:cholesky.hpp

示例3: calc_deviation

double calc_deviation(
  const Eigen::Matrix<_Scalar, _Rows, _Cols>& approx,
  const Eigen::Matrix<_Scalar, _Rows, _Cols>& exact )
{
  assert( approx.size() == exact.size() );
  double exact_square_sum = exact.squaredNorm();
  double  diff_square_sum = ( approx - exact ).squaredNorm();
  return
    exact_square_sum == 0.0 ?
    sqrt( diff_square_sum ) :
    sqrt( diff_square_sum / exact_square_sum );
}
开发者ID:robertrueger,项目名称:hVMC,代码行数:12,代码来源:fpctrl.hpp

示例4:

Quaternion<FloatT> exp_r(const Eigen::Matrix<FloatT, 3, 1>& v)
{
	// a2 = tan^2(theta/4)
	FloatT a2 = v.squaredNorm();
	Quaternion<FloatT> ret;
	// sin(theta/2) = 2*tan(theta/4) / (1 + tan^2(theta/4))
	// v == v.normalized() * tan^2(theta/4)
	ret.vec() = v*(2/(1+a2));
	// cos(theta/2) = (1 - tan^2(theta/4)) / (1 + tan^2(theta/4))
	ret.w() = (1-a2)/(1+a2);
	return ret;
}
开发者ID:msrLi,项目名称:lxyppc-tetrix,代码行数:12,代码来源:quaternions.hpp

示例5: check_unit_vector

 bool check_unit_vector(const char* function,
                        const char* name,
                        const Eigen::Matrix<T_prob, Dynamic, 1>& theta) {
   check_nonzero_size(function, name, theta);
   T_prob ssq = theta.squaredNorm();
   if (!(fabs(1.0 - ssq) <= CONSTRAINT_TOLERANCE)) {
     std::stringstream msg;
     msg << "is not a valid unit vector."
         << " The sum of the squares of the elements should be 1, but is ";
     std::string msg_str(msg.str());
     domain_error(function, name, ssq, msg_str.c_str());
   }
   return true;
 }
开发者ID:piero-ranalli,项目名称:math,代码行数:14,代码来源:check_unit_vector.hpp

示例6: A

double GreenStrain_LIMSolver2D::computeFunction(const Eigen::Matrix<double,Eigen::Dynamic,1>& x)
{
  // green strain energy
  double shape = 0;
  Eigen::Matrix<double,2,2> I = Eigen::Matrix<double,2,2>::Identity();
  for(int t=0;t<mesh->Triangles->rows();t++)
  {
    Eigen::Vector2d A(x[TriangleVertexIdx.coeff(0,t)],x[TriangleVertexIdx.coeff(1,t)]);
    Eigen::Vector2d B(x[TriangleVertexIdx.coeff(2,t)],x[TriangleVertexIdx.coeff(3,t)]);
    Eigen::Vector2d C(x[TriangleVertexIdx.coeff(4,t)],x[TriangleVertexIdx.coeff(5,t)]);

    Eigen::Matrix<double,2,3> V;
    V.col(0) = A;
    V.col(1) = B;
    V.col(2) = C;

    Eigen::Matrix<double,2,2> F = V*Ms.block<3,2>(0,2*t);
    Eigen::Matrix<double,2,2> E = (F.transpose()*F - I);
    shape += E.squaredNorm()*Divider;
  }

    return shape;
}
开发者ID:JianpingCAI,项目名称:libigl,代码行数:23,代码来源:GreenStrain_LIMSolver2D.cpp

示例7: dot_self

 inline double dot_self(const Eigen::Matrix<double, R, C>& v) {
   stan::math::check_vector("dot_self", "v", v);
   return v.squaredNorm();
 }
开发者ID:alyst,项目名称:math,代码行数:4,代码来源:dot_self.hpp

示例8: squared_norm

 Float squared_norm(const Eigen::Matrix<Float,I,J>& mat) { return mat.squaredNorm() ; }
开发者ID:bezout,项目名称:sablabac,代码行数:1,代码来源:block.hpp


注:本文中的eigen::Matrix::squaredNorm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。