MCPcopy Create free account
hub / github.com/ERGO-Code/HiGHS / deleteRows

Method deleteRows

highs/util/HighsSparseMatrix.cpp:658–734  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

656}
657
658void HighsSparseMatrix::deleteRows(
659 const HighsIndexCollection& index_collection) {
660 assert(this->formatOk());
661 assert(ok(index_collection));
662 HighsInt from_k;
663 HighsInt to_k;
664 limits(index_collection, from_k, to_k);
665 if (from_k > to_k) return;
666
667 HighsInt delete_from_row;
668 HighsInt delete_to_row;
669 HighsInt keep_from_row;
670 HighsInt row_dim = this->num_row_;
671 HighsInt keep_to_row = -1;
672 HighsInt current_set_entry = 0;
673
674 // Set up a row mask to indicate the new row index of kept rows and
675 // -1 for deleted rows so that the kept entries in the column-wise
676 // matrix can be identified and have their correct row index.
677 vector<HighsInt> new_index;
678 new_index.resize(this->num_row_);
679 HighsInt new_num_row = 0;
680 bool mask = index_collection.is_mask_;
681 const vector<HighsInt>& row_mask = index_collection.mask_;
682 if (!mask) {
683 keep_to_row = -1;
684 current_set_entry = 0;
685 for (HighsInt k = from_k; k <= to_k; k++) {
686 updateOutInIndex(index_collection, delete_from_row, delete_to_row,
687 keep_from_row, keep_to_row, current_set_entry);
688 if (k == from_k) {
689 // Account for any initial rows being kept
690 for (HighsInt row = 0; row < delete_from_row; row++) {
691 new_index[row] = new_num_row;
692 new_num_row++;
693 }
694 }
695 for (HighsInt row = delete_from_row; row <= delete_to_row; row++) {
696 new_index[row] = -1;
697 }
698 for (HighsInt row = keep_from_row; row <= keep_to_row; row++) {
699 new_index[row] = new_num_row;
700 new_num_row++;
701 }
702 if (keep_to_row >= row_dim - 1) break;
703 }
704 } else {
705 for (HighsInt row = 0; row < this->num_row_; row++) {
706 if (row_mask[row]) {
707 new_index[row] = -1;
708 } else {
709 new_index[row] = new_num_row;
710 new_num_row++;
711 }
712 }
713 }
714 HighsInt new_num_nz = 0;
715 for (HighsInt col = 0; col < this->num_col_; col++) {

Callers

nothing calls this directly

Calls 5

formatOkMethod · 0.95
okFunction · 0.85
limitsFunction · 0.85
updateOutInIndexFunction · 0.85
resizeMethod · 0.45

Tested by

no test coverage detected