本文整理汇总了C++中DVector::getDim方法的典型用法代码示例。如果您正苦于以下问题:C++ DVector::getDim方法的具体用法?C++ DVector::getDim怎么用?C++ DVector::getDim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DVector
的用法示例。
在下文中一共展示了DVector::getDim方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setForwardSeed
returnValue Integrator::setForwardSeed( const int &order,
const DVector &xSeed,
const DVector &pSeed,
const DVector &uSeed,
const DVector &wSeed ){
int run1;
if( rhs == 0 ) return ACADOERROR( RET_TRIVIAL_RHS );
DVector tmpX;
DVector components = rhs->getDifferentialStateComponents();
dP = pSeed;
dU = uSeed;
dW = wSeed;
if( xSeed.getDim() != 0 ){
tmpX.init( components.getDim() );
for( run1 = 0; run1 < (int) components.getDim(); run1++ )
tmpX(run1) = xSeed((int) components(run1));
}
return setProtectedForwardSeed( tmpX, pSeed, uSeed, wSeed, order );
}
示例2: subjectTo
returnValue OCP::subjectTo( const DVector& _lb, const Expression& _expr, const DVector& _ub )
{
ASSERT(_lb.getDim() == _expr.getDim() && _lb.getDim() == _ub.getDim());
constraint->add(_lb, _expr, _ub);
return SUCCESSFUL_RETURN;
}
示例3: checkSymmetry
BooleanType RungeKuttaExport::checkSymmetry( const DVector& _cc ) {
if( _cc.getDim() <= 1 ) return BT_FALSE;
BooleanType symmetry = BT_TRUE;
uint i;
for( i = 0; i < _cc.getDim(); i++ ) {
int tmp = acadoRoundAway(1.0 - _cc(i) - _cc(_cc.getDim()-1-i));
if( symmetry ) symmetry = (tmp == 0);
}
return symmetry;
}
示例4: initializeButcherTableau
returnValue RungeKuttaExport::initializeButcherTableau( const DMatrix& _AA, const DVector& _bb, const DVector& _cc ) {
if( _cc.isEmpty() || !_AA.isSquare() || _AA.getNumRows() != _bb.getDim() || _bb.getDim() != _cc.getDim() ) return RET_INVALID_OPTION;
numStages = _cc.getDim();
is_symmetric = checkSymmetry( _cc );
// std::cout << "Symmetry of the chosen method: " << is_symmetric << "\n";
AA = _AA;
bb = _bb;
cc = _cc;
return SUCCESSFUL_RETURN;
}
示例5: evaluateTransition
returnValue Integrator::evaluateTransition( const double time, DVector &xd, const DVector &xa,
const DVector &p, const DVector &u, const DVector &w ){
ASSERT( transition != 0 );
EvaluationPoint z( *transition, xd.getDim(), xa.getDim(), p.getDim(), u.getDim(), w.getDim() );
z.setT ( time );
z.setX ( xd );
z.setXA( xa );
z.setP ( p );
z.setU ( u );
z.setW ( w );
xd = transition->evaluate( z );
return SUCCESSFUL_RETURN;
}
示例6: integrate
returnValue Integrator::integrate( const Grid &t_ ,
const DVector &x0 ,
const DVector &xa ,
const DVector &p ,
const DVector &u ,
const DVector &w ){
int run1;
returnValue returnvalue;
if( rhs == 0 ) return ACADOERROR( RET_TRIVIAL_RHS );
DVector tmpX;
DVector components = rhs->getDifferentialStateComponents();
const int N = components.getDim();
if( x0.getDim() != 0 ){
tmpX.init( components.getDim() );
for( run1 = 0; run1 < (int) components.getDim(); run1++ )
tmpX(run1) = x0((int) components(run1));
}
// tmpX.print( "integrator x0" );
// u.print( "integrator u0" );
// p.print( "integrator p0" );
returnvalue = evaluate( tmpX, xa, p, u, w, t_ );
if( returnvalue != SUCCESSFUL_RETURN )
return returnvalue;
xE.init(rhs->getDim());
xE.setZero();
DVector tmp(rhs->getDim());
getProtectedX(&tmp);
for( run1 = 0; run1 < N; run1++ )
xE((int) components(run1)) = tmp(run1);
for( run1 = N; run1 < N + ma; run1++ )
xE(run1) = tmp(run1);
if( transition != 0 )
returnvalue = evaluateTransition( t_.getLastTime(), xE, xa, p, u, w );
return returnvalue;
}
示例7: getBackwardSensitivities
returnValue Integrator::getBackwardSensitivities( DVector &DX,
DVector &DP ,
DVector &DU ,
DVector &DW ,
int order ) const{
int run2;
returnValue returnvalue;
DVector tmpX ( rhs->getDim() );
DX.setZero();
DP.setZero();
DU.setZero();
DW.setZero();
returnvalue = getProtectedBackwardSensitivities( tmpX, DP, DU, DW, order );
DVector components = rhs->getDifferentialStateComponents();
for( run2 = 0; run2 < (int) components.getDim(); run2++ )
DX((int) components(run2)) = tmpX(run2);
for( run2 = 0; run2 < (int) dPb.getDim(); run2++ )
DP(run2) += dPb(run2);
for( run2 = 0; run2 < (int) dUb.getDim(); run2++ )
DU(run2) += dUb(run2);
for( run2 = 0; run2 < (int) dWb.getDim(); run2++ )
DW(run2) += dWb(run2);
return returnvalue;
}
示例8: setBackwardSeed
returnValue Integrator::setBackwardSeed( const int &order,
const DVector &seed ){
dXb = seed;
uint run1;
DVector tmp( seed.getDim() );
DVector components = rhs->getDifferentialStateComponents();
if( seed.getDim() != 0 ){
tmp.init( components.getDim() );
for( run1 = 0; run1 < components.getDim(); run1++ )
tmp(run1) = seed((int) components(run1));
}
return setProtectedBackwardSeed( tmp, order );
}
示例9: diffTransitionForward
returnValue Integrator::diffTransitionForward( DVector &DX,
const DVector &DP,
const DVector &DU,
const DVector &DW,
const int &order ){
ASSERT( transition != 0 );
EvaluationPoint z( *transition, DX.getDim(), 0, DP.getDim(), DU.getDim(), DW.getDim() );
z.setX ( DX );
z.setP ( DP );
z.setU ( DU );
z.setW ( DW );
if( order == 1 ) DX = transition->AD_forward( z );
if( order != 1 ) return ACADOERROR( RET_NOT_IMPLEMENTED_YET );
return SUCCESSFUL_RETURN;
}
示例10: diffTransitionBackward
returnValue Integrator::diffTransitionBackward( DVector &DX,
DVector &DP,
DVector &DU,
DVector &DW,
int &order ){
ASSERT( transition != 0 );
if( order != 1 ) return ACADOERROR( RET_NOT_IMPLEMENTED_YET );
EvaluationPoint z( *transition, DX.getDim(), 0, DP.getDim(), DU.getDim(), DW.getDim() );
transition->AD_backward( DX, z );
DX = z.getX();
DP = z.getP();
DU = z.getU();
DW = z.getW();
return SUCCESSFUL_RETURN;
}
示例11: times
OCP::OCP( const double &tStart_, const double &tEnd_, const DVector& _numSteps )
: MultiObjectiveFunctionality(),
grid(new Grid()), objective(new Objective()), constraint(new Constraint())
{
if( _numSteps.getDim() <= 0 ) ACADOERROR( RET_INVALID_ARGUMENTS );
DVector times( _numSteps.getDim()+1 );
times(0) = tStart_;
double totalSteps = 0;
uint i;
for( i = 0; i < _numSteps.getDim(); i++ ) {
totalSteps += _numSteps(i);
}
double h = (tEnd_ - tStart_)/totalSteps;
for( i = 0; i < _numSteps.getDim(); i++ ) {
times(i+1) = times(i) + h*_numSteps(i);
}
setupGrid( times );
modelData.setIntegrationGrid(*grid, totalSteps);
}
示例12: getMouseEvent
BooleanType GnuplotWindow::getMouseEvent( double &mouseX, double &mouseY )
{
DVector tmp;
if (tmp.read( "mouse.dat" ) != SUCCESSFUL_RETURN)
return BT_FALSE;
mouseX = tmp( tmp.getDim()-2 );
mouseY = tmp( tmp.getDim()-1 );
if ( system("rm mouse.dat") )
return BT_FALSE;
return BT_TRUE;
}
示例13: setVector
returnValue VariablesGrid::setVector( uint pointIdx,
const DVector& _values
)
{
if ( pointIdx >= getNumPoints( ) )
return ACADOERROR( RET_INDEX_OUT_OF_BOUNDS );
if ( _values.getDim( ) != getNumRows( pointIdx ) )
return ACADOERROR( RET_VECTOR_DIMENSION_MISMATCH );
for( uint j=0; j<getNumRows( ); ++j )
operator()( pointIdx,j ) = _values( j );
return SUCCESSFUL_RETURN;
}
示例14: integrateSensitivities
returnValue Integrator::integrateSensitivities( ){
uint run1;
returnValue returnvalue;
if( ( nBDirs > 0 || nBDirs2 > 0 ) && transition != 0 ){
int order;
if( nBDirs2 > 0 ) order = 2;
else order = 1;
returnvalue = diffTransitionBackward( dXb, dPb, dUb, dWb, order );
setBackwardSeed( order, dXb );
if( returnvalue != SUCCESSFUL_RETURN ) return ACADOERROR(returnvalue);
}
returnvalue = evaluateSensitivities();
if( returnvalue != SUCCESSFUL_RETURN ) return ACADOERROR(returnvalue);
if( nBDirs > 0 || nBDirs2 > 0 ) return SUCCESSFUL_RETURN;
int order = 1;
if( nFDirs2 > 0 ) order = 2;
DMatrix tmp( rhs->getDim(), 1 );
returnvalue = getProtectedForwardSensitivities(&tmp,order);
DVector components = rhs->getDifferentialStateComponents();
dX.init(rhs->getDim()-ma);
dX.setZero();
for( run1 = 0; run1 < components.getDim(); run1++ )
dX((int) components(run1)) = tmp(run1,0);
if( returnvalue != SUCCESSFUL_RETURN ) return ACADOERROR(returnvalue);
if( transition != 0 )
returnvalue = diffTransitionForward( dX, dP, dU, dW, order );
return returnvalue;
}
示例15: setParameterDeadTimes
returnValue Actuator::setParameterDeadTimes( const DVector& _deadTimes
)
{
if ( _deadTimes.getDim( ) != getNP( ) )
return ACADOERROR( RET_INVALID_ARGUMENTS );
if ( _deadTimes.getMin( ) < 0.0 )
return ACADOERROR( RET_INVALID_ARGUMENTS );
if ( deadTimes.getDim( ) == 0 )
return ACADOERROR( RET_MEMBER_NOT_INITIALISED );
for( uint i=0; i<getNP(); ++i )
deadTimes( getNU()+i ) = _deadTimes( i );
return SUCCESSFUL_RETURN;
}