numerics/src/MLCP/mlcp_driver.c
/** Compute the size of internal work arrays (for SolverOptions struct) and allocate them.

    static function : it does not need to be in the interface.

    \param[in] problem the MixedLinearComplementarityProblem structure which handles the problem (M,q)
    \param[in] options structure used to define the solver(s) and their parameters
    \param[out] iwize integer work array size
    \param[out] dwsize double work array size
*/
Compute the size of internal work arrays (for SolverOptions struct) and allocate them.
static function : it does not need to be in the interface.

\param[in] problem the MixedLinearComplementarityProblem structure which handles the problem (M,q)
\param[in] options structure used to define the solver(s) and their parameters
\param[out] iwize integer work array size
\param[out] dwsize double work array size
Compute the size of internal work arrays ( for SolverOptions struct ) and allocate them . static function : it does not need to be in the interface . \ param [ in ] problem the MixedLinearComplementarityProblem structure which handles the problem ( M q ) \ param [ in ] options structure used to define the solver ( s ) and their parameters \ param [ out ] iwize integer work array size \ param [ out ] dwsize double work array size
static void mlcp_driver_allocate_work_arrays(MixedLinearComplementarityProblem* problem, SolverOptions* options)
{
  size_t iwsize, dwsize;
  switch(options->solverId)
  {
  case SICONOS_MLCP_DIRECT_ENUM:
    iwsize = mlcp_direct_getNbIWork(problem, options) + mlcp_enum_getNbIWork(problem, options);
    dwsize = mlcp_direct_getNbDWork(problem, options) + mlcp_enum_getNbDWork(problem, options);
    break;
  case SICONOS_MLCP_PATH_ENUM:
    iwsize = mlcp_enum_getNbIWork(problem, options);
    dwsize = mlcp_enum_getNbDWork(problem, options);
    break;
  case SICONOS_MLCP_DIRECT_PATH_ENUM:
    iwsize =mlcp_direct_getNbIWork(problem, options) + mlcp_enum_getNbIWork(problem, options);
    dwsize =mlcp_direct_getNbDWork(problem, options) + mlcp_enum_getNbDWork(problem, options);
    break;
  case SICONOS_MLCP_ENUM:
    iwsize = mlcp_enum_getNbIWork(problem, options);
    dwsize = mlcp_enum_getNbDWork(problem, options);
    break;
  case SICONOS_MLCP_DIRECT_SIMPLEX:
    iwsize = mlcp_direct_getNbIWork(problem, options);
    dwsize = mlcp_direct_getNbDWork(problem, options);
    break;
  case SICONOS_MLCP_DIRECT_PATH:
    iwsize = mlcp_direct_getNbIWork(problem, options);
    dwsize = mlcp_direct_getNbDWork(problem, options);
    break;
  case SICONOS_MLCP_FB:
    iwsize = mlcp_FB_getNbIWork(problem, options);
    dwsize = mlcp_FB_getNbDWork(problem, options);
    break;
  case SICONOS_MLCP_DIRECT_FB:
    iwsize = mlcp_direct_getNbIWork(problem, options) + mlcp_FB_getNbIWork(problem, options);
    dwsize = mlcp_direct_getNbDWork(problem, options) + mlcp_FB_getNbDWork(problem, options);
    break;
  default :
    iwsize = 0;
    dwsize = 0;
  }
  options->iWorkSize = iwsize;
  options->dWorkSize = dwsize;
  if(options->iWorkSize)
  {
    options->iWork = (int*)calloc(options->iWorkSize, sizeof(int));
  }
  if(options->dWorkSize)
    options->dWork = (double*)calloc(options->dWorkSize, sizeof(double));
}
static void mlcp_driver_allocate_work_arrays ( MixedLinearComplementarityProblem * problem , SolverOptions * options ) { size_t iwsize , dwsize ; switch ( options -> solverId ) { case SICONOS_MLCP_DIRECT_ENUM : iwsize = mlcp_direct_getNbIWork ( problem , options ) + mlcp_enum_getNbIWork ( problem , options ) ; dwsize = mlcp_direct_getNbDWork ( problem , options ) + mlcp_enum_getNbDWork ( problem , options ) ; break ; case SICONOS_MLCP_PATH_ENUM : iwsize = mlcp_enum_getNbIWork ( problem , options ) ; dwsize = mlcp_enum_getNbDWork ( problem , options ) ; break ; case SICONOS_MLCP_DIRECT_PATH_ENUM : iwsize = mlcp_direct_getNbIWork ( problem , options ) + mlcp_enum_getNbIWork ( problem , options ) ; dwsize = mlcp_direct_getNbDWork ( problem , options ) + mlcp_enum_getNbDWork ( problem , options ) ; break ; case SICONOS_MLCP_ENUM : iwsize = mlcp_enum_getNbIWork ( problem , options ) ; dwsize = mlcp_enum_getNbDWork ( problem , options ) ; break ; case SICONOS_MLCP_DIRECT_SIMPLEX : iwsize = mlcp_direct_getNbIWork ( problem , options ) ; dwsize = mlcp_direct_getNbDWork ( problem , options ) ; break ; case SICONOS_MLCP_DIRECT_PATH : iwsize = mlcp_direct_getNbIWork ( problem , options ) ; dwsize = mlcp_direct_getNbDWork ( problem , options ) ; break ; case SICONOS_MLCP_FB : iwsize = mlcp_FB_getNbIWork ( problem , options ) ; dwsize = mlcp_FB_getNbDWork ( problem , options ) ; break ; case SICONOS_MLCP_DIRECT_FB : iwsize = mlcp_direct_getNbIWork ( problem , options ) + mlcp_FB_getNbIWork ( problem , options ) ; dwsize = mlcp_direct_getNbDWork ( problem , options ) + mlcp_FB_getNbDWork ( problem , options ) ; break ; default : iwsize = 0 ; dwsize = 0 ; } options -> iWorkSize = iwsize ; options -> dWorkSize = dwsize ; if ( options -> iWorkSize ) { options -> iWork = ( int * ) calloc ( options -> iWorkSize , sizeof ( int ) ) ; } if ( options -> dWorkSize ) options -> dWork = ( double * ) calloc ( options -> dWorkSize , sizeof ( double ) ) ; }
Compute the size of internal work arrays (for SolverOptions struct) and allocate them.
Compute the size of internal work arrays ( for SolverOptions struct ) and allocate them .
// compute internal work arrays size, depending on the chosen solver. // allocate solver options working arrays.