Skip to content

Commit

Permalink
MIR-665 interpolation from matrix file
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaciel committed Nov 13, 2024
1 parent 5e4237a commit 4153d14
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/tools/mir-scrip-to-weight-matrix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,31 @@ struct MIRScripToWeightMatrix : public MIRTool {
return ia[i] != ia[j] ? ia[i] < ia[j] : ja[i] != ja[j] ? ja[i] < ja[j] : a[i] < a[j];
});

decltype(ia) ia_unsorted(nnz);
decltype(ia) ia_unsorted(Nr + 1, 0);
decltype(ja) ja_unsorted(nnz);
ia.swap(ia_unsorted);
ja.swap(ja_unsorted);

const auto base = static_cast<Index>(args.getUnsigned("base", DEFAULT_BASE));
for (size_t n = 0; n < nnz; ++n) {
ia[n] = ia_unsorted[sorted[n]] - base;
ja[n] = ja_unsorted[sorted[n]] - base;
ASSERT(0 <= ia[n] && ia[n] < Nr);
ASSERT(0 <= ja[n] && ja[n] < Nc);
auto r = ia_unsorted[sorted[n]] - base;
auto c = ja_unsorted[sorted[n]] - base;
ASSERT(0 <= r && r < Nr);
ASSERT(0 <= c && c < Nc);

ia[r + 1]++;
ja[n] = c;
}

ia_unsorted.clear();
ja_unsorted.clear();

for (size_t r = 0; r < Nr; ++r) {
ia[r + 1] += ia[r];
}

ASSERT(ia.front() == 0 && ia.back() == nnz);

decltype(a) a_unsorted(nnz);
a.swap(a_unsorted);

Expand Down

0 comments on commit 4153d14

Please sign in to comment.