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


C++ xx函数代码示例

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


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

示例1: xx

StandardPVFieldPtr StandardPVField::getStandardPVField()
{
    static StandardPVFieldPtr standardPVField;
    static Mutex mutex;
    Lock xx(mutex);

    if(standardPVField.get()==NULL) {
        standardPVField= StandardPVFieldPtr(new StandardPVField());
    }
    return standardPVField;
}
开发者ID:epicsdeb,项目名称:epics-pvd,代码行数:11,代码来源:StandardPVField.cpp

示例2: updateCloth

// 布の形状の更新
void updateCloth(void) {
    // ★ 次の手順で質点の位置を決定する
    //clothのみがグローバル変数
    // 1. 質点に働く力を求める
    // 質点のfの定義
    for(int y = 0; y < POINT_NUM; y++) {
        for(int x = 0; x < POINT_NUM; x++) {
            cloth->points[x][y].f.set(0,0,0);
        }
    }
    //バネによる力を考える
    for(int i = 0; i < cloth->springs.size(); i++) {
        Vector3d nowlength(cloth->springs[i]->p0->p - cloth->springs[i]->p1->p);
        double gap = nowlength.length() - cloth->springs[i]->restLength;
        double strpower = Ks * gap; 
        //p1-p0
        Vector3d attraction(cloth->springs[i]->p1->p.x - cloth->springs[i]->p0->p.x,
                            cloth->springs[i]->p1->p.y - cloth->springs[i]->p0->p.y,
                            cloth->springs[i]->p1->p.z - cloth->springs[i]->p0->p.z);  
        attraction.normalize();
        attraction.scale(strpower);
        cloth->springs[i]->p0->f += attraction; 
        //向きを反転
        attraction.scale(-1);
        cloth->springs[i]->p1->f += attraction;
    }
    //重力M*gを加える
    //ついでに空気抵抗を考える
    for(int y = 0; y < POINT_NUM; y++) { 
        for(int x = 0; x < POINT_NUM; x++) {
           Vector3d grav(Mass*gravity.x,Mass*gravity.y,Mass*gravity.z);
           cloth->points[x][y].f +=  grav;
           Vector3d airresister(Dk*cloth->points[x][y].v.x,Dk*cloth->points[x][y].v.y,Dk*cloth->points[x][y].v.z);
           cloth->points[x][y].f -= airresister;
        }
    }

            // 2. 質点の加速度を求める
            // 3. 質点の速度を更新する
            // 4. 質点の位置を更新する
    for(int y = 0; y < POINT_NUM; y++){
        for(int x = 0; x < POINT_NUM; x++) {
            //加速度accelを求めてdTを掛けた
            if(!(cloth->points[x][y].bFixed)){
                Vector3d accel(cloth->points[x][y].f.x/Mass*dT,cloth->points[x][y].f.y/Mass*dT,cloth->points[x][y].f.z/Mass*dT);
                //質点の速度
                cloth->points[x][y].v += accel;
                //質点の位置
                Vector3d xx(cloth->points[x][y].v.x*dT,cloth->points[x][y].v.y*dT,cloth->points[x][y].v.z*dT);
                cloth->points[x][y].p += xx;
            }
        }
    }
}
开发者ID:kiddikn,项目名称:computer-graphics,代码行数:55,代码来源:kadai10.cpp

示例3: xx

void PvaClientMonitor::destroy()
{
    {
        Lock xx(mutex);
        if(isDestroyed) return;
        isDestroyed = true;
    }
    if(monitor) monitor->destroy();
    monitor.reset();
    monitorElement.reset();
}
开发者ID:pheest,项目名称:pvaClientCPP,代码行数:11,代码来源:pvaClientMonitor.cpp

示例4: main

/* >>> start tutorial code >>> */
int main( ){


    USING_NAMESPACE_ACADO

    // DEFINE VALRIABLES:
    // ---------------------------
    DVector                 b(3)  ;
    DifferentialState      x("", 2, 2);
    Function               f     ;


    // DEFINE THE VECTOR AND MATRIX ENTRIES:
    // -------------------------------------
    b(0)   = 1.0;  b(1)   = 1.0;  b(2)   = 1.0;


    // DEFINE A TEST FUNCTION:
    // -----------------------
    f << x.getInverse();


    // TEST THE FUNCTION f:
    // --------------------
    EvaluationPoint zz(f);

    DVector xx(4);

    xx(0) = 2.0;
    xx(1) = 0.1;
    xx(2) = 0.0;
    xx(3) = 2.0;

    zz.setX( xx );

    // EVALUATE f AT THE POINT  (tt,xx):
    // ---------------------------------
    std::cout << "f: " << std::endl << f.evaluate( zz ) << std::endl;

    return 0;
}
开发者ID:OspreyX,项目名称:acado,代码行数:42,代码来源:symbolic_matrix_inversion.cpp

示例5: xx

Tmatrix<Interval> EllipsoidalIntegrator::integrate( double t0, double tf, int M,
													const Tmatrix<Interval> &x,
													const Tmatrix<Interval> &p,
													const Tmatrix<Interval> &w ){

  
	typedef TaylorVariable<Interval> T;
	
	Tmatrix< TaylorVariable<Interval> > xx(x.getDim());
	
	Tmatrix<T> *pp = 0;
	Tmatrix<T> *ww = 0;
	
	if( p.getDim() > 0 ) pp = new Tmatrix<T>(p.getDim());
	if( w.getDim() > 0 ) ww = new Tmatrix<T>(w.getDim());
	
	int nn = 0;
	for( int i=0; i<(int) x.getDim(); i++ ) if( diam(x(i)) > EQUALITY_EPS ) nn++;
	for( int i=0; i<(int) p.getDim(); i++ ) if( diam(p(i)) > EQUALITY_EPS ) nn++;
	for( int i=0; i<(int) w.getDim(); i++ ) if( diam(w(i)) > EQUALITY_EPS ) nn++;
	
	TaylorModel<Interval> Mod( nn, M );
	
	nn = 0;
	for( int i=0; i<(int) x.getDim(); i++ ){
		if( diam(x(i)) > EQUALITY_EPS ){ xx(i) = T( &Mod, nn, x(i) ); nn++; }
		else xx(i) = x(i);
	}
	for( int i=0; i<(int) p.getDim(); i++ ){
		if( diam(p(i)) > EQUALITY_EPS ){ pp->operator()(i) = T( &Mod, nn, p(i) ); nn++; }
		else pp->operator()(i) = p(i);
	}
	for( int i=0; i<(int) w.getDim(); i++ ){
		if( diam(w(i)) > EQUALITY_EPS ){ ww->operator()(i) = T( &Mod, nn, w(i) ); nn++; }
		else ww->operator()(i) = w(i);
	}
	
	integrate( t0, tf, &xx, pp, ww );
	
	return getStateBound( xx );
}
开发者ID:drewm1980,项目名称:acado,代码行数:41,代码来源:ellipsoidal_integrator.cpp

示例6: gradient

 //! method to overload to compute grad_f, the first derivative of
 //  the cost function with respect to x
 virtual void gradient(Array& grad, const Array& x) const {
     Real eps = finiteDifferenceEpsilon(), fp, fm;
     Array xx(x);
     for (Size i=0; i<x.size(); i++) {
         xx[i] += eps;
         fp = value(xx);
         xx[i] -= 2.0*eps;
         fm = value(xx);
         grad[i] = 0.5*(fp - fm)/eps;
         xx[i] = x[i];
     }
 }
开发者ID:androidYibo,项目名称:documents,代码行数:14,代码来源:costfunction.hpp

示例7: throw

void SVD::solve(MatDoub_I &b, MatDoub_O &x, Doub thresh = -1.)
{
	int i,j,m=b.ncols();
	if (b.nrows() != n || x.nrows() != n || b.ncols() != x.ncols())
		throw("SVD::solve bad sizes");
	VecDoub xx(n);
	for (j=0;j<m;j++) {
		for (i=0;i<n;i++) xx[i] = b[i][j];
		solve(xx,xx,thresh);
		for (i=0;i<n;i++) x[i][j] = xx[i];
	}
}
开发者ID:skydave,项目名称:thesis,代码行数:12,代码来源:svd.cpp

示例8: PvaClientBeingDestroyed

 static void PvaClientBeingDestroyed() {
     size_t numLeft = 0;
     {
          Lock xx(mutex);
          --numberPvaClient;
           numLeft = numberPvaClient;
     }
     if(numLeft<=0) {
         ClientFactory::stop();
         CAClientFactory::stop();
     }
 }
开发者ID:MichaelRitzert,项目名称:pvaClientCPP,代码行数:12,代码来源:pvaClient.cpp

示例9: apply

  static void apply( const matrix_type & A ,
                     const multi_vector_type & x ,
                     const multi_vector_type & y ,
                     const std::vector<Ordinal> & col_indices )
  {
    CudaSparseSingleton & s = CudaSparseSingleton::singleton();
    const double alpha = 1 , beta = 0 ;
    const int n = A.graph.row_map.dimension_0() - 1 ;
    const int nz = A.graph.entries.dimension_0();
    const size_t ncol = col_indices.size();

    // Copy columns of x into a contiguous vector
    vector_type xx( Kokkos::allocate_without_initializing, "xx" , n * ncol );
    vector_type yy( Kokkos::allocate_without_initializing, "yy" , n * ncol );

    for (size_t col=0; col<ncol; col++) {
      const std::pair< size_t , size_t > span( n * col , n * ( col + 1 ) );
      vector_type xx_view = Kokkos::subview<vector_type>( xx , span );
      vector_type x_col =
        Kokkos::subview<vector_type>( x, Kokkos::ALL(), col_indices[col] );
      Kokkos::deep_copy(xx_view, x_col);
    }

    // Sparse matrix-times-multivector
    cusparseStatus_t status =
      cusparseDcsrmm( s.handle ,
                      CUSPARSE_OPERATION_NON_TRANSPOSE ,
                      n , ncol , n , nz ,
                      &alpha ,
                      s.descra ,
                      A.values.ptr_on_device() ,
                      A.graph.row_map.ptr_on_device() ,
                      A.graph.entries.ptr_on_device() ,
                      xx.ptr_on_device() ,
                      n ,
                      &beta ,
                      yy.ptr_on_device() ,
                      n );

    if ( CUSPARSE_STATUS_SUCCESS != status ) {
      throw std::runtime_error( std::string("ERROR - cusparseDcsrmv " ) );
    }

    // Copy columns out of continguous multivector
    for (size_t col=0; col<ncol; col++) {
      const std::pair< size_t , size_t > span( n * col , n * ( col + 1 ) );
      vector_type yy_view = Kokkos::subview<vector_type>( yy , span );
      vector_type y_col =
        Kokkos::subview<vector_type>( y, Kokkos::ALL(), col_indices[col] );
      Kokkos::deep_copy(y_col, yy_view );
    }
  }
开发者ID:gitter-badger,项目名称:quinoa,代码行数:52,代码来源:Stokhos_Cuda_CrsMatrix.hpp

示例10: xx

void Executor::execute(CommandPtr const & command)
{
    Lock xx(mutex);
    command->next.reset();
    if(!head.get()) {
        head = command;
        moreWork.signal();
        return;
    }
    CommandPtr tail = head;
    while(tail->next) tail = tail->next;
    tail->next = command;   
}
开发者ID:anjohnson,项目名称:pvDataCPP,代码行数:13,代码来源:executor.cpp

示例11: _io_service

 connection::connection(boost::asio::io_service& ios, const std::string& request_id_header) :
     _io_service(ios),
     _request_id_header_tag(request_id_header),
     _waiting_for_async_reply(false),
     _request_complete(false),
     _keep_alive(false)
 {
     {
         csi::spinlock::scoped_lock xx(s_spinlock);
         s_context_count++;
     }
     _parser.data = this; // this is the wrong "this" since this is a baseclass... dont call any virtuals from this
     http_parser_init(&_parser, HTTP_REQUEST);
 }
开发者ID:bitbouncer,项目名称:csi-http,代码行数:14,代码来源:connection.cpp

示例12: PvaClientBeingConstructed

 static void PvaClientBeingConstructed()
 {
     bool saveFirst = false;
     { 
          Lock xx(mutex);
          ++numberPvaClient;
          saveFirst = firstTime;
          firstTime = false;
     }
     if(saveFirst) {
         ClientFactory::start();
         CAClientFactory::start();
     }
 }
开发者ID:MichaelRitzert,项目名称:pvaClientCPP,代码行数:14,代码来源:pvaClient.cpp

示例13: jacobian

 //! method to overload to compute J_f, the jacobian of
 // the cost function with respect to x
 virtual void jacobian(Matrix &jac, const Array &x) const {
     Real eps = finiteDifferenceEpsilon();
     Array xx(x), fp, fm;
     for(Size i=0; i<x.size(); ++i) {
         xx[i] += eps;
         fp = values(xx);
         xx[i] -= 2.0*eps;
         fm = values(xx);
         for(Size j=0; j<fp.size(); ++j) {
             jac[j][i] = 0.5*(fp[j]-fm[j])/eps;
         }
         xx[i] = x[i];
     }
 }
开发者ID:BGC-nglass,项目名称:quantlib,代码行数:16,代码来源:costfunction.hpp

示例14: main

/* >>> start tutorial code >>> */
int main( ){

    USING_NAMESPACE_ACADO

    // DEFINE VALRIABLES:
    // ---------------------------
       DifferentialState x, y;
       Function f;

       f << x*x + pow(y,2);

    // TEST THE FUNCTION f:
    // --------------------
       EvaluationPoint  z(f);
       EvaluationPoint dz(f);

       Vector xx(2);  Vector dx(2);

       xx(0) =  1.0;  dx(0) =  0.5;
       xx(1) =  1.0;  dx(1) =  0.1;

       z.setX( xx );  dz.setX( dx );


    // FORWARD DIFFERENTIATION:
    // ------------------------
       Vector ff = f.evaluate  ( z  );
       Vector df = f.AD_forward( dz );


    // PRINT THE RESULTS:
    // ------------------
       ff.print("result of evaluation      \n");
       df.print("result for the derivative \n");

    return 0;
}
开发者ID:drewm1980,项目名称:acado,代码行数:38,代码来源:automatic_forward_differentiation.cpp

示例15: main

int main( ){

    USING_NAMESPACE_ACADO

    // DEFINE VARIABLES:
    // -----------------------
       DifferentialState x, y;
       IntermediateState z   ;
       Function f;

       z = 1.0;

       int run1;

       for( run1 = 0; run1 < 5; run1++ )
            z += sin( z + x*y );

       f << z;


    // TEST THE FUNCTION f:
    // --------------------
       EvaluationPoint zz(f);

       Vector xx(2);
       xx.setZero();
       xx(0) = 2.0;
       xx(1) = 0.0;

       zz.setX(xx);

       Vector result = f.evaluate( zz );
       result.print("result");

    return 0;
}
开发者ID:ThomasBesselmann,项目名称:acado,代码行数:36,代码来源:loops.cpp


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