COIN-OR::LEMON - Graph Library

Changeset 2364:3a5e67bd42d2 in lemon-0.x for lemon/lp_glpk.cc


Ignore:
Timestamp:
02/15/07 20:15:14 (13 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3175
Message:

Lp row and col getter function
lp section reader and writer for lemon IO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/lp_glpk.cc

    r2363 r2364  
    127127  }
    128128 
    129   void LpGlpk::_setRowCoeffs(int i, LpRowIterator b, LpRowIterator e)
     129  void LpGlpk::_setRowCoeffs(int i, ConstRowIterator b, ConstRowIterator e)
    130130  {
    131131    std::vector<int> indices;
     
    135135    values.push_back(0);
    136136
    137     for(LpRowIterator it=b; it!=e; ++it) {
     137    for(ConstRowIterator it=b; it!=e; ++it) {
    138138      indices.push_back(it->first);
    139139      values.push_back(it->second);
     
    142142    lpx_set_mat_row(lp, i, values.size() - 1, &indices[0], &values[0]);
    143143  }
    144  
    145   void LpGlpk::_setColCoeffs(int i, LpColIterator b, LpColIterator e) {
     144
     145  void LpGlpk::_getRowCoeffs(int i, RowIterator b)
     146  {
     147    int length = lpx_get_mat_row(lp, i, 0, 0);
     148   
     149    std::vector<int> indices(length + 1);
     150    std::vector<Value> values(length + 1);
     151   
     152    lpx_get_mat_row(lp, i, &indices[0], &values[0]);
     153   
     154    for (int i = 1; i <= length; ++i) {
     155      *b = std::make_pair(indices[i], values[i]);
     156      ++b;
     157    }
     158  }
     159 
     160  void LpGlpk::_setColCoeffs(int i, ConstColIterator b, ConstColIterator e) {
    146161
    147162    std::vector<int> indices;
     
    151166    values.push_back(0);
    152167
    153     for(LpColIterator it=b; it!=e; ++it) {
     168    for(ConstColIterator it=b; it!=e; ++it) {
    154169      indices.push_back(it->first);
    155170      values.push_back(it->second);
     
    159174  }
    160175
     176  void LpGlpk::_getColCoeffs(int i, ColIterator b)
     177  {
     178    int length = lpx_get_mat_col(lp, i, 0, 0);
     179   
     180    std::vector<int> indices(length + 1);
     181    std::vector<Value> values(length + 1);
     182   
     183    lpx_get_mat_col(lp, i, &indices[0], &values[0]);
     184   
     185    for (int i = 1; i <= length; ++i) {
     186      *b = std::make_pair(indices[i], values[i]);
     187      ++b;
     188    }
     189  }
    161190
    162191  void LpGlpk::_setCoeff(int row, int col, Value value)
     
    224253    int length=lpx_get_mat_row(lp, row, 0, 0);
    225254   
    226     std::vector<int> indices(length + 2);
    227     std::vector<Value> values(length + 2);
     255    std::vector<int> indices(length + 1);
     256    std::vector<Value> values(length + 1);
    228257   
    229258    lpx_get_mat_row(lp, row, &indices[0], &values[0]);
Note: See TracChangeset for help on using the changeset viewer.