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

Function getSubVectors

highs/lp_data/HighsLpUtils.cpp:3471–3525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3469}
3470
3471void getSubVectors(const HighsIndexCollection& index_collection,
3472 const HighsInt data_dim, const double* data0,
3473 const double* data1, const double* data2,
3474 const HighsSparseMatrix& matrix, HighsInt& num_sub_vector,
3475 double* sub_vector_data0, double* sub_vector_data1,
3476 double* sub_vector_data2, HighsInt& sub_matrix_num_nz,
3477 HighsInt* sub_matrix_start, HighsInt* sub_matrix_index,
3478 double* sub_matrix_value) {
3479 // Ensure that if there's no data0 then it's not required in the
3480 // sub-vector
3481 if (data0 == nullptr) assert(sub_vector_data0 == nullptr);
3482 assert(ok(index_collection));
3483 HighsInt from_k;
3484 HighsInt to_k;
3485 limits(index_collection, from_k, to_k);
3486 // Surely this is checked elsewhere
3487 assert(0 <= from_k && to_k < data_dim);
3488 assert(from_k <= to_k);
3489 HighsInt out_from_vector;
3490 HighsInt out_to_vector;
3491 HighsInt in_from_vector;
3492 HighsInt in_to_vector = -1;
3493 HighsInt current_set_entry = 0;
3494 num_sub_vector = 0;
3495 sub_matrix_num_nz = 0;
3496 for (HighsInt k = from_k; k <= to_k; k++) {
3497 updateOutInIndex(index_collection, out_from_vector, out_to_vector,
3498 in_from_vector, in_to_vector, current_set_entry);
3499 assert(out_to_vector < data_dim);
3500 assert(in_to_vector < data_dim);
3501 for (HighsInt iVector = out_from_vector; iVector <= out_to_vector;
3502 iVector++) {
3503 if (sub_vector_data0 != nullptr)
3504 sub_vector_data0[num_sub_vector] = data0[iVector];
3505 if (sub_vector_data1 != nullptr)
3506 sub_vector_data1[num_sub_vector] = data1[iVector];
3507 if (sub_vector_data2 != nullptr)
3508 sub_vector_data2[num_sub_vector] = data2[iVector];
3509 if (sub_matrix_start != nullptr)
3510 sub_matrix_start[num_sub_vector] = sub_matrix_num_nz +
3511 matrix.start_[iVector] -
3512 matrix.start_[out_from_vector];
3513 num_sub_vector++;
3514 }
3515 for (HighsInt iEl = matrix.start_[out_from_vector];
3516 iEl < matrix.start_[out_to_vector + 1]; iEl++) {
3517 if (sub_matrix_index != nullptr)
3518 sub_matrix_index[sub_matrix_num_nz] = matrix.index_[iEl];
3519 if (sub_matrix_value != nullptr)
3520 sub_matrix_value[sub_matrix_num_nz] = matrix.value_[iEl];
3521 sub_matrix_num_nz++;
3522 }
3523 if (out_to_vector == data_dim - 1 || in_to_vector == data_dim - 1) break;
3524 }
3525}
3526
3527void getSubVectorsTranspose(const HighsIndexCollection& index_collection,
3528 const HighsInt data_dim, const double* data0,

Callers 2

getColsInterfaceMethod · 0.85
getRowsInterfaceMethod · 0.85

Calls 3

okFunction · 0.85
limitsFunction · 0.85
updateOutInIndexFunction · 0.85

Tested by

no test coverage detected