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


C++ VectorType类代码示例

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


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


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