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

C++ VectorType类代码示例

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

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



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

示例1: lpNorm

template<typename VectorType> void lpNorm(const VectorType& v)
{
  VectorType u = VectorType::Random(v.size());

  VERIFY_IS_APPROX(u.template lpNorm<Infinity>(), u.cwise().abs().maxCoeff());
  VERIFY_IS_APPROX(u.template lpNorm<1>(), u.cwise().abs().sum());
  VERIFY_IS_APPROX(u.template lpNorm<2>(), ei_sqrt(u.cwise().abs().cwise().square().sum()));
  VERIFY_IS_APPROX(ei_pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.cwise().abs().cwise().pow(5).sum());
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:9,代码来源:eigen2_array.cpp


示例2: mahadist

double mahadist(const vtkMeshModel* model, vtkPoint targetPt, vtkPoint meanPt) {
    MatrixType cov = model->GetCovarianceAtPoint(meanPt, meanPt);
    int pointDim =3;
    VectorType x = VectorType::Zero(pointDim);
    for (unsigned d = 0; d < pointDim; d++) {
      x(d) = targetPt[d] - meanPt[d];
    }
    return x.transpose() * cov.inverse() * x;
}
开发者ID:Celli119,项目名称:RvtkStatismo,代码行数:9,代码来源:ConstrainedModel.cpp


示例3: p_serialSolutionDist

 /// After serial solve, distribute solution
 void p_serialSolutionDist(VectorType& x) const
 {
   BOOST_ASSERT(!p_valueBuffer.empty());
   IdxType lo, hi;
   x.localIndexRange(lo, hi);
   p_serialSolution->getElementRange(lo, hi, &p_valueBuffer[0]);
   x.setElementRange(lo, hi, &p_valueBuffer[0]);
   x.ready();
 }
开发者ID:Anastien,项目名称:GridPACK,代码行数:10,代码来源:linear_solver_implementation.hpp


示例4: conjVector

VectorType conjVector(const VectorType & v){
  VectorType result(v.dimension());
  typename VectorType::const_iterator b = v.begin(), e = v.end();
  typename VectorType::iterator  r = result.begin();
  while(b!=e){
    *r = conj(*b);
    ++r; ++b;
  }
  return result;
}
开发者ID:dreal-deps,项目名称:capdDynSys-4.0,代码行数:10,代码来源:iobject.hpp


示例5: getCorners

 std::vector<typename SetType::VectorType> getCorners(const SetType & set) {
   typedef typename SetType::VectorType VectorType;
   std::vector<VectorType> cor;
   VectorType v = set.get_r();
   corners(v, set.get_r(), 0, v.dimension(), cor);
   for(typename std::vector<VectorType>::iterator it = cor.begin(); it != cor.end(); ++it){
     *it = set.get_x() + set.get_C() * set.get_r0() + set.get_B() * *it;
   }
   return cor;
 }
开发者ID:dreal-deps,项目名称:capdDynSys-3.0,代码行数:10,代码来源:InclRect2Set.hpp


示例6: lpNorm

template<typename VectorType> void lpNorm(const VectorType& v)
{
  using std::sqrt;
  VectorType u = VectorType::Random(v.size());

  VERIFY_IS_APPROX(u.template lpNorm<Infinity>(), u.cwiseAbs().maxCoeff());
  VERIFY_IS_APPROX(u.template lpNorm<1>(), u.cwiseAbs().sum());
  VERIFY_IS_APPROX(u.template lpNorm<2>(), sqrt(u.array().abs().square().sum()));
  VERIFY_IS_APPROX(numext::pow(u.template lpNorm<5>(), typename VectorType::RealScalar(5)), u.array().abs().pow(5).sum());
}
开发者ID:1k5,项目名称:eigen,代码行数:10,代码来源:array_for_matrix.cpp


示例7: split

Pped2Set<MatrixType>::Pped2Set(const VectorType& the_x)
  : m_x(the_x),
    m_r(the_x.dimension()),
    m_r0(the_x.dimension()),
    m_B(MatrixType::Identity(the_x.dimension())),
    m_C(MatrixType::Identity(the_x.dimension())) {

  m_r.clear();
  split(m_x,m_r0);
}
开发者ID:dreal-deps,项目名称:capdDynSys-3.0,代码行数:10,代码来源:Pped2Set.hpp


示例8: GetParamsMsg

CovarianceEstimatorInfo CovarianceEstimator::GetParamsMsg() const
{
	CovarianceEstimatorInfo info;
	info.source_name = _sourceName;
	VectorType params = _params->GetParamsVec();
	info.parameters.resize( params.size() );
	// GetVectorView( info.parameters ) = params;
	SerializeMatrix( params, info.parameters );
	return info;
}
开发者ID:Humhu,项目名称:percepto,代码行数:10,代码来源:CovarianceEstimator.cpp


示例9: printvector

 void printvector(VectorType const & vec)
 {
   #ifdef VIENNACL_AMG_DEBUGBENCH
   for (typename VectorType::const_iterator iter = vec.begin(); iter != vec.end(); ++iter)
   {
     std::cout << *iter << " ";
   }
   std::cout << std::endl;
   #endif
 }
开发者ID:bollig,项目名称:viennacl-dev,代码行数:10,代码来源:amg_debug.hpp


示例10: SetType

C1AffineSet<MatrixType,Policies>::C1AffineSet(const VectorType& x, const MatrixType& B, const VectorType& r, ScalarType t)
  : SetType(
      x+B*r,
      VectorType(x.dimension()),
      MatrixType::Identity(x.dimension()),
      MatrixType(x.dimension(),x.dimension()),
      t),
    C0BaseSet(x, B, r),
    C1BaseSet(x.dimension())
{}
开发者ID:dreal-deps,项目名称:capdDynSys-4.0,代码行数:10,代码来源:C1AffineSet.hpp


示例11: selectUnion

Selector selectUnion( const VectorType & union_vector )
{
  Selector selector;
  if (union_vector.size() > 0) {
    selector = dereference_if_pointer(union_vector[0]);
    for (unsigned i = 1 ; i < union_vector.size() ; ++i) {
      selector |= dereference_if_pointer(union_vector[i]);
    }
  }
  return selector;
}
开发者ID:cihanuq,项目名称:Trilinos,代码行数:11,代码来源:Selector.cpp


示例12: printTuple

 //FIXME: These need to be implemented
 virtual void printTuple(std::ostream &out, size_t i, char delimiter = ',')
 {
   SharedVectorType sharedVec = _data[i];
   VectorType* vec = sharedVec.get();
   size_t size = vec->size();
   out << size;
   for(size_t i=0;i<size;i++)
   {
     out << delimiter << vec->at(i);
   }
 }
开发者ID:mahendra-ramajayam,项目名称:DREAM3D,代码行数:12,代码来源:NeighborList.hpp


示例13: GetGeometry

void SolidFace3D::CalculateRightHandSide(VectorType& rRightHandSideVector,
                                         ProcessInfo& r_process_info)
{
    const unsigned int number_of_nodes = GetGeometry().size();
    unsigned int MatSize = number_of_nodes * 3;
    
    if (rRightHandSideVector.size() != MatSize)
    {
        rRightHandSideVector.resize(MatSize, false);
    }
    rRightHandSideVector = ZeroVector(MatSize);
    
    std::vector<SphericParticle*>& rNeighbours = this->mNeighbourSphericParticles;
    
    for (unsigned int i=0; i<rNeighbours.size(); i++)
    {
        if(rNeighbours[i]->Is(BLOCKED)) continue; //Inlet Generator Spheres are ignored when integrating forces.
        
        std::vector<DEMWall*>& rRFnei = rNeighbours[i]->mNeighbourRigidFaces;
                
        for (unsigned int i_nei = 0; i_nei < rRFnei.size(); i_nei++)
        {
            int Contact_Type = rNeighbours[i]->mContactConditionContactTypes[i_nei];
            
            if ( ( rRFnei[i_nei]->Id() == this->Id() ) && (Contact_Type > 0 ) )
            {
                
                array_1d<double, 4> weights_vector = rNeighbours[i]->mContactConditionWeights[i_nei];
                double weight = 0.0;
                
                double ContactForce[3] = {0.0};

                const array_1d<double, 3>& neighbour_rigid_faces_contact_force = rNeighbours[i]->mNeighbourRigidFacesTotalContactForce[i_nei];

                ContactForce[0] = neighbour_rigid_faces_contact_force[0];
                ContactForce[1] = neighbour_rigid_faces_contact_force[1];
                ContactForce[2] = neighbour_rigid_faces_contact_force[2];

                for (unsigned int k=0; k< number_of_nodes; k++)
                {
                    weight = weights_vector[k];
  
                    unsigned int w =  k * 3;

                    rRightHandSideVector[w + 0] += -ContactForce[0] * weight;
                    rRightHandSideVector[w + 1] += -ContactForce[1] * weight;
                    rRightHandSideVector[w + 2] += -ContactForce[2] * weight;
                }
                
            }//if the condition neighbour of my sphere neighbour is myself.
        }//Loop spheres neighbours (condition)
    }//Loop condition neighbours (spheres)
}//CalculateRightHandSide
开发者ID:KratosCSIC,项目名称:trunk,代码行数:53,代码来源:SolidFace.cpp


示例14: set_parameter

void deep_network::set_parameter(const VectorType &parameter_)
{
    int start_idx = 0;
    for (auto & layer : this->layers)
    {
        layer.W = Map<const MatrixType>(parameter_.data()+ start_idx,layer.get_input_dim(),layer.get_output_dim()) ;
        start_idx += layer.get_input_dim()  * layer.get_output_dim();
        layer.b = Map<const VectorType>(parameter_.data()+ start_idx, layer.get_output_dim());
        start_idx += layer.get_output_dim();
    }

}
开发者ID:rudaoshi,项目名称:artifact,代码行数:12,代码来源:deep_network.cpp


示例15: getMemoryOpCost

unsigned X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy,
                                           unsigned Alignment,
                                           unsigned AddressSpace) {
  VectorType *SrcVTy = dyn_cast<VectorType>(SrcTy);
  if (!SrcVTy)
    // To calculate scalar take the regular cost, without mask
    return getMemoryOpCost(Opcode, SrcTy, Alignment, AddressSpace);

  unsigned NumElem = SrcVTy->getVectorNumElements();
  VectorType *MaskTy =
    VectorType::get(Type::getInt8Ty(getGlobalContext()), NumElem);
  if ((Opcode == Instruction::Load && !isLegalMaskedLoad(SrcVTy, 1)) ||
      (Opcode == Instruction::Store && !isLegalMaskedStore(SrcVTy, 1)) ||
      !isPowerOf2_32(NumElem)) {
    // Scalarization
    unsigned MaskSplitCost = getScalarizationOverhead(MaskTy, false, true);
    unsigned ScalarCompareCost =
      getCmpSelInstrCost(Instruction::ICmp,
                         Type::getInt8Ty(getGlobalContext()), NULL);
    unsigned BranchCost = getCFInstrCost(Instruction::Br);
    unsigned MaskCmpCost = NumElem * (BranchCost + ScalarCompareCost);

    unsigned ValueSplitCost =
      getScalarizationOverhead(SrcVTy, Opcode == Instruction::Load,
                               Opcode == Instruction::Store);
    unsigned MemopCost =
        NumElem * BaseT::getMemoryOpCost(Opcode, SrcVTy->getScalarType(),
                                         Alignment, AddressSpace);
    return MemopCost + ValueSplitCost + MaskSplitCost + MaskCmpCost;
  }

  // Legalize the type.
  std::pair<unsigned, MVT> LT = TLI->getTypeLegalizationCost(SrcVTy);
  unsigned Cost = 0;
  if (LT.second != TLI->getValueType(SrcVTy).getSimpleVT() &&
      LT.second.getVectorNumElements() == NumElem)
    // Promotion requires expand/truncate for data and a shuffle for mask.
    Cost += getShuffleCost(TTI::SK_Alternate, SrcVTy, 0, 0) +
            getShuffleCost(TTI::SK_Alternate, MaskTy, 0, 0);

  else if (LT.second.getVectorNumElements() > NumElem) {
    VectorType *NewMaskTy = VectorType::get(MaskTy->getVectorElementType(),
                                            LT.second.getVectorNumElements());
    // Expanding requires fill mask with zeroes
    Cost += getShuffleCost(TTI::SK_InsertSubvector, NewMaskTy, 0, MaskTy);
  }
  if (!ST->hasAVX512())
    return Cost + LT.first*4; // Each maskmov costs 4

  // AVX-512 masked load/store is cheapper
  return Cost+LT.first;
}
开发者ID:Nanosim-LIG,项目名称:llvm,代码行数:52,代码来源:X86TargetTransformInfo.cpp


示例16: GetGeometry

/**
 * calculates this contact element's local contributions
 */
void MasterContactPoint2D::CalculateLocalSystem( MatrixType& rLeftHandSideMatrix,
        VectorType& rRightHandSideVector,
        ProcessInfo& rCurrentProcessInfo)
{
    unsigned int ndof = GetGeometry().size()*2;
    if( rRightHandSideVector.size() != ndof )
        rRightHandSideVector.resize(ndof,false);
    rRightHandSideVector = ZeroVector(ndof);
    if( rLeftHandSideMatrix.size1() != ndof )
        rLeftHandSideMatrix(ndof,ndof);
    rLeftHandSideMatrix = ZeroMatrix(ndof,ndof);

}
开发者ID:KratosCSIC,项目名称:trunk,代码行数:16,代码来源:master_contact_point_2d.cpp


示例17:

inline
void StackContextBase<TSuperClass>::setSlotVariable(const VariableSlotID slot,
                                                    const UnitType &newValue,
                                                    VectorType &container) const
{
    if(slot < container.size())
        container.replace(slot, newValue);
    else
    {
        container.resize(slot + 1);
        container.replace(slot, newValue);
    }
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:13,代码来源:qstackcontextbase.cpp


示例18: switch

/// getEVT - Return the value type corresponding to the specified type.  This
/// returns all pointers as MVT::iPTR.  If HandleUnknown is true, unknown types
/// are returned as Other, otherwise they are invalid.
EVT EVT::getEVT(Type *Ty, bool HandleUnknown){
  switch (Ty->getTypeID()) {
  default:
    return MVT::getVT(Ty, HandleUnknown);
  case Type::IntegerTyID:
    return getIntegerVT(Ty->getContext(), cast<IntegerType>(Ty)->getBitWidth());
  case Type::VectorTyID: {
    VectorType *VTy = cast<VectorType>(Ty);
    return getVectorVT(Ty->getContext(), getEVT(VTy->getElementType(), false),
                       VTy->getNumElements());
  }
  }
}
开发者ID:adiaaida,项目名称:llvm,代码行数:16,代码来源:ValueTypes.cpp


示例19:

VPFactory::VectorType
	VPFactory::getFlowKeys() const
{
	VectorType	retVector;

	for ( FlowDBConstIter it = flowDB.begin();
		  it != flowDB.end();
		  it ++ )
	{
		retVector.push_back( it->flowName );
	}

	return retVector;
}
开发者ID:andreaswatch,项目名称:dizuo,代码行数:14,代码来源:vpfactory.cpp


示例20: Scalar

void BallTree<_Scalar>::buildNode(Node& node, std::vector<int>& indices, AxisAlignedBoxType aabb, int level)
{
	Scalar avgradius = 0.;
	for (std::vector<int>::const_iterator it=indices.begin(), end=indices.end() ; it!=end ; ++it)
			avgradius += mRadii[*it];
	avgradius = mRadiusScale * avgradius / Scalar(indices.size());
	VectorType diag = aabb.max - aabb.min;
	if  (int(indices.size())<mTargetCellSize
		|| avgradius*0.9 > std::max(std::max(diag.X(), diag.Y()), diag.Z())
		|| int(level)>=mMaxTreeDepth)
	{
		node.leaf = true;
		node.size = indices.size();
		node.indices = new unsigned int[node.size];
		for (unsigned int i=0 ; i<node.size ; ++i)
			node.indices[i] = indices[i];
		return;
	}
	unsigned int dim = vcg::MaxCoeffId(diag);
	node.dim = dim;
	node.splitValue = Scalar(0.5*(aabb.max[dim] + aabb.min[dim]));
  node.leaf = 0;

	AxisAlignedBoxType aabbLeft=aabb, aabbRight=aabb;
	aabbLeft.max[dim] = node.splitValue;
	aabbRight.min[dim] = node.splitValue;

	std::vector<int> iLeft, iRight;
	split(indices, aabbLeft, aabbRight, iLeft,iRight);

	// we don't need the index list anymore
	indices.clear();

	{
		// left child
		//mNodes.resize(mNodes.size()+1);
		Node* pChild = new Node();
		node.children[0] = pChild;
		buildNode(*pChild, iLeft, aabbLeft, level+1);
	}

	{
		// right child
		//mNodes.resize(mNodes.size()+1);
		Node* pChild = new Node();
		node.children[1] = pChild;
		buildNode(*pChild, iRight, aabbRight, level+1);
	}
}
开发者ID:GuoXinxiao,项目名称:meshlab,代码行数:49,代码来源:balltree.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ VectorValues类代码示例发布时间:2022-05-31
下一篇:
C++ VectorT类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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