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; }
returnValue VariablesGrid::getSum( DVector& sum ) const { sum.setZero(); for( uint i=0; i<getNumPoints( ); ++i ) sum += getVector( i ); return SUCCESSFUL_RETURN; }
returnValue VariablesGrid::getIntegral( InterpolationMode mode, DVector& value ) const { value.setZero(); switch( mode ) { case IM_CONSTANT: for( uint i=0; i<getNumIntervals( ); ++i ) { for( uint j=0; j<getNumValues( ); ++j ) { //value(j) += ( getIntervalLength( i ) / getIntervalLength( ) ) * operator()( i,j ); value(j) += getIntervalLength( i ) * operator()( i,j ); } } break; case IM_LINEAR: for( uint i=0; i<getNumIntervals( ); ++i ) { for( uint j=0; j<getNumValues( ); ++j ) { //value(j) += ( getIntervalLength( i ) / getIntervalLength( ) ) * ( operator()( i,j ) + operator()( i+1,j ) ) / 2.0; value(j) += getIntervalLength( i ) * ( operator()( i,j ) + operator()( i+1,j ) ) / 2.0; } } break; default: return ACADOERROR( RET_NOT_YET_IMPLEMENTED ); } return SUCCESSFUL_RETURN; }