Skip to content

Commit 9f7beea

Browse files
committed
Partial rw copy of A for NE structure built explicitly
1 parent 0d6c16e commit 9f7beea

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

highs/ipm/hipo/ipm/FactorHiGHSSolver.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,26 @@ Int FactorHiGHSSolver::buildNEstructure(const HighsSparseMatrix& A,
129129

130130
// NB: A must have sorted columns for this to work
131131

132-
// create partial row-wise representation
133-
// for now, using the full row-wise matrix
132+
// create partial row-wise representation without values, and array or
133+
// corresponding indices between cw and rw representation
134134
{
135-
HighsSparseMatrix At = A;
136-
At.ensureRowwise();
137-
ptrNE_rw_ = std::move(At.start_);
138-
idxNE_rw_ = std::move(At.index_);
139-
}
135+
ptrNE_rw_.assign(A.num_row_ + 1, 0);
136+
idxNE_rw_.assign(A.numNz(), 0);
137+
138+
// pointers of row-start
139+
for (Int el = 0; el < A.numNz(); ++el) ptrNE_rw_[A.index_[el] + 1]++;
140+
for (Int i = 0; i < A.num_row_; ++i) ptrNE_rw_[i + 1] += ptrNE_rw_[i];
140141

141-
{
142142
std::vector<Int> temp = ptrNE_rw_;
143143
corr_NE_.assign(A.numNz(), 0);
144144

145-
// build array or corresponding indices
145+
// rw-indices and corresponding indices created together
146146
for (Int col = 0; col < A.num_col_; ++col) {
147147
for (Int el = A.start_[col]; el < A.start_[col + 1]; ++el) {
148148
Int row = A.index_[el];
149149

150150
corr_NE_[temp[row]] = el;
151+
idxNE_rw_[temp[row]] = col;
151152
temp[row]++;
152153
}
153154
}
@@ -203,6 +204,7 @@ Int FactorHiGHSSolver::buildNEstructure(const HighsSparseMatrix& A,
203204
// now assign indices
204205
for (Int i = 0; i < nz_in_col; ++i) {
205206
Int index = temp_index[i];
207+
// push_back is better then reserve, because the final length is not known
206208
rowsNE_.push_back(index);
207209
is_nz[index] = false;
208210
}

0 commit comments

Comments
 (0)