| 282 | |
| 283 | |
| 284 | ZMatrix PolymakeFile::readMatrixProperty(const char *p, int height, int width) |
| 285 | { |
| 286 | ZMatrix ret(0,width); |
| 287 | |
| 288 | assert(hasProperty(p,true)); |
| 289 | list<PolymakeProperty>::iterator prop=findProperty(p); |
| 290 | stringstream s(prop->value); |
| 291 | // for(int i=0;i<height;i++) |
| 292 | for(int i=0;;i++) |
| 293 | { |
| 294 | if(i==height)break; |
| 295 | ZVector w(width); |
| 296 | for(int j=0;j<width;j++) |
| 297 | { |
| 298 | int v; |
| 299 | eatComment(s); |
| 300 | s>>v; |
| 301 | if(s.eof())goto done; |
| 302 | w[j]=v; |
| 303 | } |
| 304 | ret.appendRow(w); |
| 305 | } |
| 306 | done: |
| 307 | |
| 308 | if(height>=0)assert(ret.getHeight()==height); |
| 309 | // cerr<<p; |
| 310 | // eatComment(s); |
| 311 | // int v; |
| 312 | // s>>v; |
| 313 | // while(!s.eof())std::cerr<<char(s.get()); |
| 314 | // assert(s.eof()); |
| 315 | |
| 316 | return ret; |
| 317 | } |
| 318 | |
| 319 | |
| 320 | void PolymakeFile::writeMatrixProperty(const char *p, const ZMatrix &m, bool indexed, const vector<string> *comments) |