Changeset 1901


Ignore:
Timestamp:
Dec 18, 2012 3:12:42 PM (7 years ago)
Author:
stefan
Message:

patch by Miles Lubin to get malloc'ed arrays in C interface ray methods

Location:
trunk/Clp/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Clp/src/ClpModel.hpp

    r1878 r1901  
    765765         ray_=NULL;
    766766     }
     767         /// Access internal ray storage. Users should call infeasibilityRay() or unboundedRay() instead.
     768         inline const double * internalRay() const {
     769                 return ray_;
     770         }
    767771     /// See if status (i.e. basis) array exists (partly for OsiClp)
    768772     inline bool statusExists() const {
  • trunk/Clp/src/Clp_C_Interface.cpp

    r1689 r1901  
    638638}
    639639/* Infeasibility/unbounded ray (NULL returned if none/wrong)
    640    Up to user to use delete [] on these arrays.  */
     640   Up to user to use free() on these arrays.  */
    641641COINLIBAPI double * COINLINKAGE
    642642Clp_infeasibilityRay(Clp_Simplex * model)
    643643{
    644      return model->model_->infeasibilityRay();
     644     const double * ray = model->model_->internalRay();
     645     double * array = NULL;
     646     int numberRows = model->model_->numberRows();
     647     int status = model->model_->status();
     648     if (status == 1 && ray) {
     649          array = static_cast<double*>(malloc(numberRows*sizeof(double)));
     650          memcpy(array,ray,numberRows*sizeof(double));
     651#ifndef CLP_NO_SWAP_SIGN
     652          // swap signs to be consistent with norm
     653          for (int i = 0; i < numberRows; i++)
     654               array[i] = -array[i];
     655#endif
     656     }
     657     return array;
    645658}
    646659COINLIBAPI double * COINLINKAGE
    647660Clp_unboundedRay(Clp_Simplex * model)
    648661{
    649      return model->model_->unboundedRay();
     662     const double * ray = model->model_->internalRay();
     663     double * array = NULL;
     664     int numberColumns = model->model_->numberColumns();
     665     int status = model->model_->status();
     666     if (status == 2 && ray) {
     667          array = static_cast<double*>(malloc(numberColumns*sizeof(double)));
     668          memcpy(array,ray,numberColumns*sizeof(double));
     669     }
     670     return array;
    650671}
    651672/* See if status array exists (partly for OsiClp) */
  • trunk/Clp/src/Clp_C_Interface.h

    r1665 r1901  
    198198     COINLIBAPI char * COINLINKAGE Clp_integerInformation(Clp_Simplex * model);
    199199     /** Infeasibility/unbounded ray (NULL returned if none/wrong)
    200          Up to user to use delete [] on these arrays.  */
     200         Up to user to use free() on these arrays.  */
    201201     COINLIBAPI double * COINLINKAGE Clp_infeasibilityRay(Clp_Simplex * model);
    202202     COINLIBAPI double * COINLINKAGE Clp_unboundedRay(Clp_Simplex * model);
Note: See TracChangeset for help on using the changeset viewer.