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

C++ VectorSpace类代码示例

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

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



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

示例1: extractSubSpaceImpl

    std::shared_ptr< VectorSpace > extractSubSpaceImpl( const VectorSpace& space,
                                                        unsigned global_id )
    {
        if ( is< ProductSpace::VectorCreator >( space.creator() ) )
        {
            const auto& product_space_creator =
                cast_ref< ProductSpace::VectorCreator >( space.creator() );
            const auto& subSpaces = product_space_creator.subSpaces();
            std::shared_ptr< VectorSpace > result;
            for ( auto i = 0u; i < subSpaces.size(); ++i )
            {
                if ( product_space_creator.inverseIdMap( i ) == global_id &&
                     !is< ProductSpace::VectorCreator >( subSpaces[ i ]->creator() ) )
                    return subSpaces[ i ];

                if ( is< ProductSpace::VectorCreator >( subSpaces[ i ]->creator() ) )
                {
                    auto result = extractSubSpaceImpl( *subSpaces[ i ], global_id );
                    if ( result )
                        return result;
                }
            }
        }

        return nullptr;
    }
开发者ID:spacy-dev,项目名称:Spacy,代码行数:26,代码来源:VectorSpace.cpp


示例2:

template <class Scalar> inline
DefaultBlockVector<Scalar>
::DefaultBlockVector(const VectorSpace<Scalar>& space)
  : BlockVectorBase<Scalar>(), space_(space), blocks_(space.numBlocks())
{
  for (int i=0; i<space.numBlocks(); i++)
  {
    blocks_[i] = space.getBlock(i).createMember();
  }
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:10,代码来源:PlayaDefaultBlockVectorImpl.hpp


示例3: is_compatible

bool VectorSpaceThyra::is_compatible(const VectorSpace& vec_spc ) const
{
  if( this->dim()==vec_spc.dim() && this->is_in_core() && vec_spc.is_in_core() )
    return true;
  const VectorSpaceThyra
    *thyra_vec_spc = dynamic_cast<const VectorSpaceThyra*>(&vec_spc);
  if( thyra_vec_spc->thyra_vec_spc()->isCompatible(*thyra_vec_spc_) )
    return true;
  return false;
}
开发者ID:00liujj,项目名称:trilinos,代码行数:10,代码来源:AbstractLinAlgPack_VectorSpaceThyra.cpp


示例4: LinearOperator

 LinearOperatorCreator::LinearOperatorCreator( const VectorSpace& X, const VectorSpace& Y )
     : Generic::LinearOperatorCreator< LinearOperator >(
           [&X, &Y]( const VectorSpace* space ) {
               return LinearOperator(
                   ::Eigen::MatrixXd::Zero( cast_ref< VectorCreator >( X.creator() ).dim(),
                                            cast_ref< VectorCreator >( Y.creator() ).dim() ),
                   *space, X, Y );
           },
           X, Y )
 {
 }
开发者ID:spacy-dev,项目名称:Spacy,代码行数:11,代码来源:LinearOperatorCreator.cpp


示例5: goToStart

template <class Scalar> inline
void BlockIterator<Scalar>
::goToStart(const VectorSpace<Scalar>& space,
  std::deque<int>& pos) const
{
  pos.push_back(0);
  if (space.isBlockSpace())
  {
    goToStart(space.getBlock(0), pos);
  }
}
开发者ID:00liujj,项目名称:trilinos,代码行数:11,代码来源:PlayaBlockIteratorImpl.hpp


示例6: vecSpace_

SerialVector::SerialVector(const VectorSpace<double>& vs)
  : SingleChunkVector<double>(),
    vecSpace_(vs),
    data_(vs.dim()),
    dim_(vs.dim())
{
  const SerialVectorSpace* rvs 
    = dynamic_cast<const SerialVectorSpace*>(vs.ptr().get());
  TEUCHOS_TEST_FOR_EXCEPTION(rvs==0, std::runtime_error,
    "could not cast vector space to SerialVectorSpace in "
    "SerialVector ctor");
}
开发者ID:00liujj,项目名称:trilinos,代码行数:12,代码来源:PlayaSerialVector.cpp


示例7: GetInversection_v_Point

/**********************************************************************
 * Function_Name: Intersection
 * Return 		: double
 * Comments 	: returns the dist_from_sphere, if the intersection
 * 				 	else it returns a -1
 **********************************************************************/
double Ellipse::Intersection(const Vertex& RayOrigin, const VectorSpace& Ray) const
{
	Vertex V_Point = GetInversection_v_Point(RayOrigin, Ray);

	VectorSpace RayOrig2EllipCenter(  RayOrigin.arr, Center.arr );
	VectorSpace RayOrig2Ellip_Norm;
	RayOrig2Ellip_Norm = RayOrig2EllipCenter;
	RayOrig2Ellip_Norm.DoNormalization();

	VectorSpace RayNorm;
	RayNorm = Ray;
	RayNorm.DoNormalization();

	double c_dot_v  = RayOrig2Ellip_Norm.Dot( RayNorm );

	if( c_dot_v > 0 || Ray.RayNVal != 1 ) // Sphere is not behind the ray origin
	{
		double r = mean_radius;
		double c = RayOrigin.Distance( Center );

		double v = V_Point.Distance( RayOrigin );

		double v2 = pow(v,2);
		double c2 = pow(c,2);
		double r2 = pow(r,2);
		double dSquare = r2 - c2 + v2;

		if( dSquare < 0 )
		{
			return -1;
		}
		else
		{
			double d = sqrt( dSquare );
			double t;

			if( Ray.RayNVal == 1)
			{
				t = v - d;
				return t;
			}
			else
			{
				t = v + d;
				return t;
			}
		}

	}

	return -1;
}
开发者ID:hnkulkarni,项目名称:Raytracer,代码行数:58,代码来源:Ellipse.cpp


示例8: is_compatible

bool VectorSpaceSubSpace::is_compatible(const VectorSpace& another_space) const
{
  if( this->dim() == another_space.dim() && this->is_in_core() && another_space.is_in_core() )
    return true;
  const VectorSpaceSubSpace
    *a_space = dynamic_cast<const VectorSpaceSubSpace*>(&another_space);
  if(!a_space)
    return false;
  return
    ( this->full_space_.get() == NULL && a_space->full_space_.get() == NULL )
    ||
    ( this->rng_ == a_space->rng_ && this->full_space_->is_compatible(*a_space->full_space_) );
}
开发者ID:haripandey,项目名称:trilinos,代码行数:13,代码来源:AbstractLinAlgPack_VectorSpaceSubSpace.cpp


示例9: CompoundVectorSpace

  IteratesVectorSpace::IteratesVectorSpace(const VectorSpace& x_space, const VectorSpace& s_space,
      const VectorSpace& y_c_space, const VectorSpace& y_d_space,
      const VectorSpace& z_L_space, const VectorSpace& z_U_space,
      const VectorSpace& v_L_space, const VectorSpace& v_U_space
                                          )
      :
      CompoundVectorSpace(8, x_space.Dim() + s_space.Dim()
                          + y_c_space.Dim() + y_d_space.Dim()
                          + z_L_space.Dim() + z_U_space.Dim()
                          + v_L_space.Dim() + v_U_space.Dim()
                         )
  {
    x_space_ = &x_space;
    s_space_ = &s_space;
    y_c_space_ = &y_c_space;
    y_d_space_ = &y_d_space;
    z_L_space_ = &z_L_space;
    z_U_space_ = &z_U_space;
    v_L_space_ = &v_L_space;
    v_U_space_ = &v_U_space;

    this->CompoundVectorSpace::SetCompSpace(0, *x_space_);
    this->CompoundVectorSpace::SetCompSpace(1, *s_space_);
    this->CompoundVectorSpace::SetCompSpace(2, *y_c_space_);
    this->CompoundVectorSpace::SetCompSpace(3, *y_d_space_);
    this->CompoundVectorSpace::SetCompSpace(4, *z_L_space_);
    this->CompoundVectorSpace::SetCompSpace(5, *z_U_space_);
    this->CompoundVectorSpace::SetCompSpace(6, *v_L_space_);
    this->CompoundVectorSpace::SetCompSpace(7, *v_U_space_);
  }
开发者ID:AyMaN-GhOsT,项目名称:simbody,代码行数:30,代码来源:IpIteratesVector.cpp


示例10: double

/**********************************************************************
 * Function_Name: RotAxis
 * Return 		:
 * Comments 	:
 **********************************************************************/
int Transformation::RotAxis( double(&Rw)[4][4],  VectorSpace w )
{

	w.DoNormalization();

	VectorSpace m;

	for( int i = 0; i < 3; i++ )
	{
		m.vs[i] = (double)(rand() % 1000)/1000;
	}

	m.DoNormalization();


	VectorSpace u;

	u = w;
	u.CrossProduct(m);
	u.DoNormalization();

	VectorSpace v;
	v = w;
	v.CrossProduct(u);


	// Filling Up Rw
	FillUpRw( Rw, u.vs, v.vs, w.vs);

	CheckRotationMat(Rw);

	return EXIT_SUCCESS;
}
开发者ID:hnkulkarni,项目名称:Raytracer,代码行数:38,代码来源:Transformation.cpp


示例11:

VectorSpace<Type, N> VectorSpace<Type, N>::operator -(const VectorSpace<Type, N>& v2) const
{

	// Vectors should have same size
	VectorSpace<Type, N> result;

	for (int i= v2.MinIndex(); i <= v2.MaxIndex(); ++i)
	{
		result[i] = (*this)[i] - v2[i];
	}

	return result;

}
开发者ID:JinhuiAchilles,项目名称:C_Github,代码行数:14,代码来源:VectorSpace.cpp


示例12: rcp

RCP<GhostImporter<double> > 
EpetraVectorType::createGhostImporter(const VectorSpace<double>& space,
                                      int nGhost,
                                      const int* ghostIndices) const
{
  const EpetraVectorSpace* p 
    = dynamic_cast<const EpetraVectorSpace*>(space.ptr().get());

  TEUCHOS_TEST_FOR_EXCEPTION(p==0, std::runtime_error,
                     "non-epetra vector space [" << space.description() << "] given as "
                     "argument to EpetraVectorType::createGhostImporter()");

  return rcp(new EpetraGhostImporter(p->epetraMap(), nGhost, ghostIndices));
  
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:15,代码来源:PlayaEpetraVectorType.cpp


示例13: zeroOperator

template <class Scalar> inline
SimpleBlockOp<Scalar>::SimpleBlockOp(
  const VectorSpace<Scalar>& domain,
  const VectorSpace<Scalar>& range)
  : LinearOpWithSpaces<Scalar>(domain, range), blocks_(range.numBlocks())
{
  for (int i=0; i<blocks_.size(); i++) 
  {
    blocks_[i] = Array<LinearOperator<Scalar> >(domain.numBlocks());
    for (int j=0; j<blocks_[i].size(); j++)
    {
      blocks_[i][j] = zeroOperator(domain.getBlock(j), range.getBlock(i));
    }
  }
}
开发者ID:00liujj,项目名称:trilinos,代码行数:15,代码来源:PlayaSimpleBlockOpImpl.hpp


示例14: init_identity

void MatrixSymPosDefLBFGS::init_identity( const VectorSpace& space_diag, value_type alpha )
{
  // Validate input
  TEUCHOS_TEST_FOR_EXCEPTION(
    alpha <= 0.0, std::invalid_argument
    ,"MatrixSymPosDefLBFGS::init_identity(n,alpha) : Error, "
    "alpha = " << alpha << " <= 0 is not allowed!" );
  
  // Set the vector space
  vec_spc_ = space_diag.clone();
  vec_spc_.get();

  // Set storage
  S_ = vec_spc_->create_members(m_);
  Y_ = vec_spc_->create_members(m_);
  TEUCHOS_TEST_FOR_EXCEPT( !( S_.get() ) );
  TEUCHOS_TEST_FOR_EXCEPT( !( Y_.get() ) );
  STY_.resize( m_, m_ );
  STSYTY_.resize( m_+1, m_+1 );
  STSYTY_.diag(0) = 0.0;

  gamma_k_ = 1.0/alpha;

  // Initialize counters
  m_bar_	= 0;

  n_ = vec_spc_->dim();        // initialized;
  original_is_updated_ = true; // This will never change for now
  inverse_is_updated_  = true; // This will never change for now
  num_secant_updates_  = 0;    // reset this to zero
}
开发者ID:00liujj,项目名称:trilinos,代码行数:31,代码来源:ConstrainedOptPack_MatrixSymPosDefLBFGS.cpp


示例15:

ExperimentStorage<S_V,S_M,D_V,D_M>::ExperimentStorage(
  const VectorSpace<S_V,S_M>& scenarioSpace,
  unsigned int                numExperiments)
  :
  m_env                    (scenarioSpace.env()),
  m_scenarioSpace          (scenarioSpace),
  m_paper_n                (numExperiments),
  m_paper_n_ys_transformed (m_paper_n,0),
  m_paper_n_y              (0),
  m_addId                  (0),
  m_scenarioVecs_standard  (m_paper_n, (S_V*) NULL),
  m_dataVecs_transformed   (m_paper_n, (D_V*) NULL),
  m_covMats_transformed_inv(m_paper_n, (D_M*) NULL),
  m_y_space                (NULL),
  m_yVec_transformed       (NULL),
  m_Wy                     (NULL)
{
  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
    *m_env.subDisplayFile() << "Entering ExperimentStorage<S_V,S_M,D_V,D_M>::constructor()"
                            << "\n  m_paper_n = " << m_paper_n
                            << std::endl;
  }

  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
    *m_env.subDisplayFile() << "Leaving ExperimentStorage<S_V,S_M,D_V,D_M>::constructor()"
                            << std::endl;
  }
}
开发者ID:EricDoug,项目名称:queso,代码行数:28,代码来源:ExperimentStorage.C


示例16:

SmartPtr<Vector> NLPScalingObject::apply_vector_scaling_d_LU_NonConst(
   const Matrix&                 Pd_LU,
   const SmartPtr<const Vector>& lu,
   const VectorSpace&            d_space
   )
{
   DBG_START_METH("NLPScalingObject::apply_vector_scaling_d_LU_NonConst", dbg_verbosity);
   SmartPtr<Vector> scaled_d_LU = lu->MakeNew();
   if( have_d_scaling() )
   {
      SmartPtr<Vector> tmp_d = d_space.MakeNew();

      // move to full d space
      Pd_LU.MultVector(1.0, *lu, 0.0, *tmp_d);

      // scale in full x space
      tmp_d = apply_vector_scaling_d_NonConst(ConstPtr(tmp_d));

      // move back to x_L space
      Pd_LU.TransMultVector(1.0, *tmp_d, 0.0, *scaled_d_LU);
   }
   else
   {
      scaled_d_LU->Copy(*lu);
   }

   return scaled_d_LU;
}
开发者ID:,项目名称:,代码行数:28,代码来源:


示例17: m_dimGlobal

VectorSpace<V,M>::VectorSpace(const VectorSpace<V,M>& aux)
  : VectorSet<V,M>(aux.env(),((std::string)(aux.m_prefix)).c_str(),INFINITY),
    m_dimGlobal(aux.m_dimGlobal),
    m_map(newMap()),
    m_dimLocal(m_map->NumMyElements()),
    m_componentsNamesArray(NULL),
    m_componentsNamesVec(NULL),
    m_emptyComponentName(""),
    m_zeroVector(new V(m_env,*m_map))
{
  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
    *m_env.subDisplayFile() << "Entering VectorSpace<V,M>::constructor(2)"
                            << ": aux.m_componentsNamesArray = " << aux.m_componentsNamesArray
                            << ", aux.m_componentsNamesVec = "   << aux.m_componentsNamesVec
                            << std::endl;
  }

  if (aux.m_componentsNamesArray != NULL) {
    m_componentsNamesArray = new DistArray<std::string>(*(aux.m_componentsNamesArray));
  }

  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 5)) {
    *m_env.subDisplayFile() << "Leaving VectorSpace<V,M>::constructor(2)"
                            << std::endl;
  }
}
开发者ID:brianw525,项目名称:queso,代码行数:26,代码来源:VectorSpace.C


示例18: TEUCHOS_TEST_FOR_EXCEPTION

RCP<GhostImporter<double> > 
SerialVectorType::createGhostImporter(const VectorSpace<double>& space,
                                      int nGhost,
                                      const int* ghostIndices) const
{
  TEUCHOS_TEST_FOR_EXCEPTION(dynamic_cast<const SerialVectorSpace*>(space.ptr().get())==0, std::runtime_error, "expected " 
    << space << " to be a SerialVectorSpace");
  return rcp(new SerialGhostImporter());
}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:9,代码来源:PlayaSerialVectorType.cpp


示例19: vecMaker

Array<Vector<double> > vecMaker(int nVecs, int n,
  int nProc, int rank, const VectorType<double>& vecType)
{
  /* This VS will go out of scope when the function is exited, but
   * its vectors will remember it */
  VectorSpace<double> space 
    = vecType.createEvenlyPartitionedSpace(MPIComm::world(), n);

  Rand::setLocalSeed(space.comm(), 314159);

  Array<Vector<double> > rtn(nVecs);
  for (int i=0; i<rtn.size(); i++)
  {
    rtn[i] = space.createMember();
    rtn[i].randomize();
  }
  return rtn;

}
开发者ID:cakeisalie,项目名称:oomphlib_003,代码行数:19,代码来源:Timings.cpp


示例20: vecMaker

Array<Vector<double> > vecMaker(int nVecs,
  int nProc, int rank, const VectorType<double>& vecType)
{
  int n1 = 3;
  int n2 = 4;
  int n3 = 2;
  int n4 = 5;
  int n5 = 6;
  int n6 = 4;

  /* This VS will go out of scope when the function is exited, but
   * its vectors will remember it */
  VectorSpace<double> vs1 
    = vecType.createEvenlyPartitionedSpace(MPIComm::world(), n1);
  VectorSpace<double> vs2 
    = vecType.createEvenlyPartitionedSpace(MPIComm::world(), n2);
  VectorSpace<double> vs3 
    = vecType.createEvenlyPartitionedSpace(MPIComm::world(), n3);
  VectorSpace<double> vs4 
    = vecType.createEvenlyPartitionedSpace(MPIComm::world(), n4);
  VectorSpace<double> vs5 
    = vecType.createEvenlyPartitionedSpace(MPIComm::world(), n5);
  VectorSpace<double> vs6
    = vecType.createEvenlyPartitionedSpace(MPIComm::world(), n6);

  VectorSpace<double> vs 
    = blockSpace(vs1, blockSpace(vs2, blockSpace(vs3, vs4)), 
      blockSpace(vs5, vs6));

  Out::root() << "space = " << vs << endl;

  Rand::setLocalSeed(vs.comm(), 314159);

  Array<Vector<double> > rtn(nVecs);
  for (int i=0; i<rtn.size(); i++)
  {
    rtn[i] = vs.createMember();
    rtn[i].randomize();
  }
  return rtn;
}
开发者ID:colinpotter,项目名称:trilinos,代码行数:41,代码来源:BlockVectorTest.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ VectorString类代码示例发布时间:2022-05-31
下一篇:
C++ VectorSet类代码示例发布时间: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