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


C++ CTime::getTime方法代码示例

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


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

示例1: get_time

double get_time() {
    CTime * timer;
    return (double) timer->getTime();
}
开发者ID:ricortiz,项目名称:SOFAFramework,代码行数:4,代码来源:Matrix_test.cpp

示例2: m

void SVDLinearSolver<TMatrix,TVector>::solve(Matrix& M, Vector& x, Vector& b)
{
#ifdef SOFA_DUMP_VISITOR_INFO
    simulation::Visitor::printComment("SVD");
#endif
#ifdef DISPLAY_TIME
    CTime timer;
    double time1 = (double) timer.getTime();
#endif
    const bool verbose  = f_verbose.getValue();

    /// Convert the matrix and the right-hand vector to Eigen objects
    Eigen::MatrixXd m(M.rowSize(),M.colSize());
    Eigen::VectorXd rhs(M.rowSize());
    for(unsigned i=0; i<(unsigned)M.rowSize(); i++ )
    {
        for( unsigned j=0; j<(unsigned)M.colSize(); j++ )
            m(i,j) = M[i][j];
        rhs(i) = b[i];
    }

    msg_info_when(verbose) << "solve, Here is the matrix m:  "
                           << m ;

    /// Compute the SVD decomposition and the condition number
    Eigen::JacobiSVD<Eigen::MatrixXd> svd(m, Eigen::ComputeThinU | Eigen::ComputeThinV);
    f_conditionNumber.setValue( (Real)(svd.singularValues()(0) / svd.singularValues()(M.rowSize()-1)) );



    if(verbose)
    {
        msg_info() << "solve, the singular values are:" << sendl << svd.singularValues()  << msgendl
                   << "Its left singular vectors are the columns of the thin U matrix: " << msgendl
                   << svd.matrixU() << msgendl
                   << "Its right singular vectors are the columns of the thin V matrix:" msgendl
                   << svd.matrixV() ;
    }else{
        msg_info() << "solve, the singular values are:" << sendl << svd.singularValues()  << msgendl;
    }

    /// Solve the equation system and copy the solution to the SOFA vector
//    Eigen::VectorXd solution = svd.solve(rhs);
//    for(unsigned i=0; i<M.rowSize(); i++ ){
//        x[i] = solution(i);
//    }
    Eigen::VectorXd Ut_b = svd.matrixU().transpose() *  rhs;
    Eigen::VectorXd S_Ut_b(M.colSize());
    for( unsigned i=0; i<(unsigned)M.colSize(); i++ )   /// product with the diagonal matrix, using the threshold for near-null values
    {
        if( svd.singularValues()[i] > f_minSingularValue.getValue() )
            S_Ut_b[i] = Ut_b[i]/svd.singularValues()[i];
        else
            S_Ut_b[i] = (Real)0.0 ;
    }
    Eigen::VectorXd solution = svd.matrixV() * S_Ut_b;
    for(unsigned i=0; i<(unsigned)M.rowSize(); i++ )
    {
        x[i] = (Real) solution(i);
    }

#ifdef DISPLAY_TIME
        time1 = (double)(((double) timer.getTime() - time1) * timeStamp / (nb_iter-1));
        dmsg_info() << " solve, SVD = "<<time1;
#endif
        dmsg_info() << "solve, rhs vector = " << msgendl << rhs.transpose() << msgendl
                    << " solution =   \n" << msgendl << x << msgendl
                    << " verification, mx - b = " << msgendl << (m * solution - rhs ).transpose() << msgendl;
}
开发者ID:fredroy,项目名称:sofa,代码行数:69,代码来源:SVDLinearSolver.cpp

示例3: updatePos

void CudaMasterContactSolver<real>::step(const core::ExecParams* params /* PARAMS FIRST */, double dt) {

	sofa::helper::AdvancedTimer::stepBegin("AnimationStep");

	context = dynamic_cast<simulation::Node *>(this->getContext()); // access to current node
#ifdef DISPLAY_TIME
	CTime *timer;
	double timeScale = 1.0 / (double)CTime::getRefTicksPerSec();
	timer = new CTime();
	double time_Free_Motion = (double) timer->getTime();
#endif

	// Update the BehaviorModels
	// Required to allow the RayPickInteractor interaction
	simulation::BehaviorUpdatePositionVisitor updatePos(params /* PARAMS FIRST */, dt);
	context->execute(&updatePos);

	simulation::MechanicalBeginIntegrationVisitor beginVisitor(params /* PARAMS FIRST */, dt);
	context->execute(&beginVisitor);

	// Free Motion
	simulation::SolveVisitor freeMotion(params /* PARAMS FIRST */, dt, true);
	context->execute(&freeMotion);
	//simulation::MechanicalPropagateFreePositionVisitor().execute(context);
	{
        sofa::core::MechanicalParams mparams(*params);
        sofa::core::MultiVecCoordId xfree = sofa::core::VecCoordId::freePosition();
        mparams.x() = xfree;
        simulation::MechanicalPropagatePositionVisitor(&mparams /* PARAMS FIRST */, 0, xfree, true).execute(context);
    }

	//core::VecId dx_id = (VecId)core::VecDerivId::dx();
	//simulation::MechanicalVOpVisitor(params /* PARAMS FIRST */, dx_id).execute( context);
    //simulation::MechanicalPropagateDxVisitor(params /* PARAMS FIRST */, dx_id, true).execute( context); //ignore the masks (is it necessary?)
	//simulation::MechanicalVOpVisitor(params /* PARAMS FIRST */, dx_id).execute( context);

#ifdef DISPLAY_TIME
	time_Free_Motion = ((double) timer->getTime() - time_Free_Motion)*timeScale;
	double time_computeCollision = (double) timer->getTime();
#endif
	
	computeCollision();

#ifdef DISPLAY_TIME
	time_computeCollision = ((double) timer->getTime() - time_computeCollision)*timeScale;
	double time_build_LCP = (double) timer->getTime();
#endif
	//MechanicalResetContactForceVisitor().execute(context);

	for (unsigned int i=0;i<constraintCorrections.size();i++) {
		core::behavior::BaseConstraintCorrection* cc = constraintCorrections[i];
		cc->resetContactForce();
	}
	
	build_LCP();
		
#ifdef DISPLAY_TIME
	time_build_LCP = ((double) timer->getTime() - time_build_LCP)*timeScale;
	double time_solve_LCP = (double) timer->getTime();
#endif

	double _tol = tol.getValue();
	int _maxIt = maxIt.getValue();

	if (! initial_guess.getValue()) _f.clear();

	double error = 0.0;

#ifdef CHECK
		real t1,t2;

		if (_mu > 0.0) {
			f_check.resize(_numConstraints,MBSIZE);
			for (unsigned i=0;i<_numConstraints;i++) f_check[i] = _f[i];
			
			real toln = ((int) (_realNumConstraints/3) + 1) * (real)_tol;
			t2 = sofa::gpu::cuda::CudaLCP<real>::CudaNlcp_gaussseidel(useGPU_d.getValue(),_numConstraints, _dFree.getCudaVector(), _W.getCudaMatrix(), f_check.getCudaVector(), _mu,_toln, _maxIt);

			t1 = sofa::gpu::cuda::CudaLCP<real>::CudaNlcp_gaussseidel(0,_numConstraints, _dFree.getCudaVector(), _W.getCudaMatrix(), _f.getCudaVector(), _mu,_toln, _maxIt);
		} else {
			f_check.resize(_numConstraints);
			for (unsigned i=0;i<_numConstraints;i++) f_check[i] = _f[i];
			t2 = sofa::gpu::cuda::CudaLCP<real>::CudaGaussSeidelLCP1(useGPU_d.getValue(),_numConstraints, _dFree.getCudaVector(), _W.getCudaMatrix(), f_check.getCudaVector(), _tol, _maxIt);

			t1 = sofa::gpu::cuda::CudaLCP<real>::CudaGaussSeidelLCP1(0,_numConstraints, _dFree.getCudaVector(), _W.getCudaMatrix(), _f.getCudaVector(), _tol, _maxIt);
		}

		for (unsigned i=0;i<f_check.size();i++) {
			if ((f_check.element(i)-_f.element(i)>CHECK) || (f_check.element(i)-_f.element(i)<-CHECK)) {
				std::cerr << "Error(" << useGPU_d.getValue() << ") dim(" << _numConstraints << ") realDim(" << _realNumConstraints << ") elmt(" << i << ") : (cpu," << f_check.element(i) << ") (gpu,(" << _f.element(i) << ")" << std::endl;
			}
		}

#else
		sout << "numcontacts = " << _realNumConstraints << " RealNumContacts =" <<  _numConstraints << sendl;

		if (_mu > 0.0) {

			real toln = ((int) (_realNumConstraints/3) + 1) * (real)_tol;
			error = sofa::gpu::cuda::CudaLCP<real>::CudaNlcp_gaussseidel(useGPU_d.getValue(),_realNumConstraints, _dFree.getCudaVector(), _W.getCudaMatrix(), _f.getCudaVector(), _mu,toln, _maxIt);
//.........这里部分代码省略.........
开发者ID:conanhung,项目名称:sofa_rc1,代码行数:101,代码来源:CudaMasterContactSolver.cpp


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