| 384 | return normals; |
| 385 | } |
| 386 | void removeRedundantRows(ZMatrix &inequalities, ZMatrix &equations, bool removeInequalityRedundancies) |
| 387 | { |
| 388 | ensureCddInitialisation(); |
| 389 | |
| 390 | int numberOfEqualities=equations.getHeight(); |
| 391 | int numberOfInequalities=inequalities.getHeight(); |
| 392 | int numberOfRows=numberOfEqualities+numberOfInequalities; |
| 393 | |
| 394 | if(numberOfRows==0)return;//the full space, so description is already irredundant |
| 395 | |
| 396 | // dd_rowset r=NULL; |
| 397 | ZMatrix g=inequalities; |
| 398 | g.append(equations); |
| 399 | |
| 400 | // dd_LPSolverType solver=dd_DualSimplex; |
| 401 | dd_MatrixPtr A=NULL; |
| 402 | dd_ErrorType err=dd_NoError; |
| 403 | |
| 404 | A=ZMatrix2MatrixGmp(g,&err); |
| 405 | if (err!=dd_NoError) goto _L99; |
| 406 | |
| 407 | for(int i=numberOfInequalities;i<numberOfRows;i++) |
| 408 | set_addelem(A->linset,i+1); |
| 409 | |
| 410 | A->objective=dd_LPmax; |
| 411 | |
| 412 | dd_rowset impl_linset; |
| 413 | dd_rowset redset; |
| 414 | dd_rowindex newpos; |
| 415 | |
| 416 | if(removeInequalityRedundancies) |
| 417 | dd_MatrixCanonicalize(&A, &impl_linset, &redset, &newpos, &err); |
| 418 | else |
| 419 | dd_MatrixCanonicalizeLinearity(&A, &impl_linset, &newpos, &err); |
| 420 | |
| 421 | if (err!=dd_NoError) goto _L99; |
| 422 | |
| 423 | { |
| 424 | int n=A->colsize-1; |
| 425 | equations=ZMatrix(0,n); //TODO: the number of rows needed is actually known |
| 426 | inequalities=ZMatrix(0,n); //is known by set_card(). That might save some copying. |
| 427 | |
| 428 | { |
| 429 | int rowsize=A->rowsize; |
| 430 | QVector point(n); |
| 431 | for(int i=0;i<rowsize;i++) |
| 432 | { |
| 433 | for(int j=0;j<n;j++)point[j]=Rational(A->matrix[i][j+1]); |
| 434 | ((set_member(i+1,A->linset))?equations:inequalities).appendRow(QToZVectorPrimitive(point)); |
| 435 | } |
| 436 | } |
| 437 | assert(set_card(A->linset)==equations.getHeight()); |
| 438 | assert(A->rowsize==equations.getHeight()+inequalities.getHeight()); |
| 439 | |
| 440 | set_free(impl_linset); |
| 441 | if(removeInequalityRedundancies) |
| 442 | set_free(redset); |
| 443 | free(newpos); |
no test coverage detected