Changeset 2453


Ignore:
Timestamp:
Dec 21, 2018 3:19:20 PM (8 weeks ago)
Author:
unxusr
Message:

query matrix by column in C interface

Location:
trunk/Cbc/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cbc/src/Cbc_C_Interface.cpp

    r2433 r2453  
    715715    const CoinBigIndex *starts = cpmRow->getVectorStarts();
    716716    const double *rcoef = cpmRow->getElements() + starts[row];
     717    return rcoef;
     718}
     719
     720/** Number of non-zero entries in a column */
     721COINLIBAPI int COINLINKAGE
     722Cbc_getColNz(Cbc_Model * model, int col)
     723{
     724    const CoinPackedMatrix *cpmCol = model->model_->solver()->getMatrixByCol();
     725    return cpmCol->getVectorLengths()[col];
     726}
     727
     728/** Indices of rows that a column appears */
     729COINLIBAPI const int * COINLINKAGE
     730Cbc_getColIndices(Cbc_Model * model, int col)
     731{
     732    const CoinPackedMatrix *cpmCol = model->model_->solver()->getMatrixByCol();
     733    const CoinBigIndex *starts = cpmCol->getVectorStarts();
     734    const int *cidx = cpmCol->getIndices() + starts[col];
     735    return cidx;
     736}
     737
     738/** Coefficients that a column appear in rows */
     739COINLIBAPI const double * COINLINKAGE
     740Cbc_getColCoeffs(Cbc_Model * model, int col)
     741{
     742    const CoinPackedMatrix *cpmCol = model->model_->solver()->getMatrixByCol();
     743    const CoinBigIndex *starts = cpmCol->getVectorStarts();
     744    const double *rcoef = cpmCol->getElements() + starts[col];
    717745    return rcoef;
    718746}
  • trunk/Cbc/src/Cbc_C_Interface.h

    r2433 r2453  
    164164    COINLIBAPI const double * COINLINKAGE
    165165    Cbc_getRowCoeffs(Cbc_Model * model, int row)
     166    ;
     167    /** Number of non-zero entries in a column */
     168    COINLIBAPI int COINLINKAGE
     169    Cbc_getColNz(Cbc_Model * model, int col)
     170    ;
     171    /** Indices of rows that a column appears */
     172    COINLIBAPI const int * COINLINKAGE
     173    Cbc_getColIndices(Cbc_Model * model, int col)
     174    ;
     175    /** Coefficients that a column appear in rows */
     176    COINLIBAPI const double * COINLINKAGE
     177    Cbc_getColCoeffs(Cbc_Model * model, int col)
    166178    ;
    167179    /** Right hand side of a row */
Note: See TracChangeset for help on using the changeset viewer.