copasi/trajectory/CTrajectoryProblem.cpp
/**
 * This function synchronizes step size and number
 */
This function synchronizes step size and number
This function synchronizes step size and number
bool CTrajectoryProblem::sync()
{
  bool success = true;
  if (fabs(*mpDuration) < std::numeric_limits< C_FLOAT64 >::min())
    return success;
  C_FLOAT64 Tmp = *mpDuration;
  C_FLOAT64 StepSize = *mpStepSize;
  C_FLOAT64 StepNumber = (C_FLOAT64) * mpStepNumber;
  if (mStepNumberSetLast)
    {
      StepSize = Tmp / (C_FLOAT64) * mpStepNumber;
      if (fabs(StepSize) < 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon() * fabs(*mpDuration))
        {
          CCopasiMessage(CCopasiMessage::WARNING,
                         MCTrajectoryProblem + 3, StepSize);
          StepSize = 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon() * fabs(*mpDuration);
          StepSize = (Tmp < 0.0) ? - fabs(StepSize) : fabs(StepSize);
          StepNumber = fabs(ceil(Tmp / StepSize));
        }
    }
  else
    {
      if (fabs(StepSize) < 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon() * fabs(*mpDuration))
        {
          CCopasiMessage(CCopasiMessage::WARNING,
                         MCTrajectoryProblem + 3, StepSize);
          StepSize = 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon() * fabs(*mpDuration);
          StepSize = (Tmp < 0.0) ? - fabs(StepSize) : fabs(StepSize);
        }
      StepNumber = fabs(ceil(Tmp / StepSize));
      if ((C_FLOAT64) ULONG_MAX < StepNumber)
        {
          CCopasiMessage(CCopasiMessage::WARNING,
                         MCTrajectoryProblem + 2, StepNumber);
          StepNumber = (C_FLOAT64) ULONG_MAX;
          StepSize = Tmp / StepNumber;
        }
      StepSize = (Tmp < 0.0) ? - fabs(StepSize) : fabs(StepSize);
    }
  *mpStepSize = StepSize;
  *mpStepNumber = (unsigned C_INT32) StepNumber;
  return success;
}
bool CTrajectoryProblem :: sync ( ) { bool success = true ; if ( fabs ( * mpDuration ) < std :: numeric_limits < C_FLOAT64 > :: min ( ) ) return success ; C_FLOAT64 Tmp = * mpDuration ; C_FLOAT64 StepSize = * mpStepSize ; C_FLOAT64 StepNumber = ( C_FLOAT64 ) * mpStepNumber ; if ( mStepNumberSetLast ) { StepSize = Tmp / ( C_FLOAT64 ) * mpStepNumber ; if ( fabs ( StepSize ) < 100.0 * std :: numeric_limits < C_FLOAT64 > :: epsilon ( ) * fabs ( * mpDuration ) ) { CCopasiMessage ( CCopasiMessage :: WARNING , MCTrajectoryProblem + 3 , StepSize ) ; StepSize = 100.0 * std :: numeric_limits < C_FLOAT64 > :: epsilon ( ) * fabs ( * mpDuration ) ; StepSize = ( Tmp < 0.0 ) ? - fabs ( StepSize ) : fabs ( StepSize ) ; StepNumber = fabs ( ceil ( Tmp / StepSize ) ) ; } } else { if ( fabs ( StepSize ) < 100.0 * std :: numeric_limits < C_FLOAT64 > :: epsilon ( ) * fabs ( * mpDuration ) ) { CCopasiMessage ( CCopasiMessage :: WARNING , MCTrajectoryProblem + 3 , StepSize ) ; StepSize = 100.0 * std :: numeric_limits < C_FLOAT64 > :: epsilon ( ) * fabs ( * mpDuration ) ; StepSize = ( Tmp < 0.0 ) ? - fabs ( StepSize ) : fabs ( StepSize ) ; } StepNumber = fabs ( ceil ( Tmp / StepSize ) ) ; if ( ( C_FLOAT64 ) ULONG_MAX < StepNumber ) { CCopasiMessage ( CCopasiMessage :: WARNING , MCTrajectoryProblem + 2 , StepNumber ) ; StepNumber = ( C_FLOAT64 ) ULONG_MAX ; StepSize = Tmp / StepNumber ; } StepSize = ( Tmp < 0.0 ) ? - fabs ( StepSize ) : fabs ( StepSize ) ; } * mpStepSize = StepSize ; * mpStepNumber = ( unsigned C_INT32 ) StepNumber ; return success ; }
This function synchronizes step size and number
This function synchronizes step size and number
/* Assure that the step size is not to small for machine accuracy */ /* Assure that the step size has the appropriate sign. */ /* Assure that the step size has the appropriate sign. */ /* Protect against overflow */ /* Assure that the step size has the appropriate sign. */