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

Method createRowwisePartitioned

highs/util/HighsSparseMatrix.cpp:1318–1387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1316}
1317
1318void HighsSparseMatrix::createRowwisePartitioned(
1319 const HighsSparseMatrix& matrix, const int8_t* in_partition) {
1320 assert(matrix.formatOk());
1321 assert(matrix.isColwise());
1322 assert(this->formatOk());
1323 const bool all_in_partition = in_partition == NULL;
1324
1325 HighsInt num_col = matrix.num_col_;
1326 HighsInt num_row = matrix.num_row_;
1327 HighsInt num_nz = matrix.numNz();
1328 const vector<HighsInt>& a_start = matrix.start_;
1329 const vector<HighsInt>& a_index = matrix.index_;
1330 const vector<double>& a_value = matrix.value_;
1331 vector<HighsInt>& ar_start = this->start_;
1332 vector<HighsInt>& ar_p_end = this->p_end_;
1333 vector<HighsInt>& ar_index = this->index_;
1334 vector<double>& ar_value = this->value_;
1335
1336 // Use ar_p_end and ar_end to compute lengths, which are then transformed into
1337 // the p_ends and ends of the inserted entries
1338 std::vector<HighsInt> ar_end;
1339 ar_start.resize(num_row + 1);
1340 ar_p_end.assign(num_row, 0);
1341 ar_end.assign(num_row, 0);
1342 // Count the nonzeros of nonbasic and basic columns in each row
1343 for (HighsInt iCol = 0; iCol < num_col; iCol++) {
1344 if (all_in_partition || in_partition[iCol]) {
1345 for (HighsInt iEl = a_start[iCol]; iEl < a_start[iCol + 1]; iEl++) {
1346 HighsInt iRow = a_index[iEl];
1347 ar_p_end[iRow]++;
1348 }
1349 } else {
1350 for (HighsInt iEl = a_start[iCol]; iEl < a_start[iCol + 1]; iEl++) {
1351 HighsInt iRow = a_index[iEl];
1352 ar_end[iRow]++;
1353 }
1354 }
1355 }
1356 // Compute the starts and turn the lengths into ends
1357 ar_start[0] = 0;
1358 for (HighsInt iRow = 0; iRow < num_row; iRow++)
1359 ar_start[iRow + 1] = ar_start[iRow] + ar_p_end[iRow] + ar_end[iRow];
1360 for (HighsInt iRow = 0; iRow < num_row; iRow++) {
1361 ar_end[iRow] = ar_start[iRow] + ar_p_end[iRow];
1362 ar_p_end[iRow] = ar_start[iRow];
1363 }
1364 // Insert the entries
1365 ar_index.resize(num_nz);
1366 ar_value.resize(num_nz);
1367 for (HighsInt iCol = 0; iCol < num_col; iCol++) {
1368 if (all_in_partition || in_partition[iCol]) {
1369 for (HighsInt iEl = a_start[iCol]; iEl < a_start[iCol + 1]; iEl++) {
1370 HighsInt iRow = a_index[iEl];
1371 HighsInt iToEl = ar_p_end[iRow]++;
1372 ar_index[iToEl] = iCol;
1373 ar_value[iToEl] = a_value[iEl];
1374 }
1375 } else {

Callers 1

Calls 4

formatOkMethod · 0.95
isColwiseMethod · 0.80
numNzMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected