Skip to content

Commit

Permalink
Merge pull request #43 from sp-nitech/bug_fix
Browse files Browse the repository at this point in the history
Fix bug of magic_intpl
  • Loading branch information
takenori-y committed Jul 21, 2023
2 parents 5ce6a83 + 565782f commit ecf5821
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/input/input_source_filling_magic_number.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ int InputSourceFillingMagicNumber::Proceed() {
} else if (magic_number_region_[i]) {
// Interpolate magic numbers.
double left;
if (magic_number_ == final_output_[i]) {
left = right;
} else if (static_cast<int>(queue_.size()) == magic_number_region_[i]) {
if (static_cast<int>(queue_.size()) != magic_number_region_[i]) {
left = (*(queue_.rbegin() + magic_number_region_[i]))[i];
} else if (magic_number_ != final_output_[i]) {
left = final_output_[i];
} else {
left = (*(queue_.rbegin() + magic_number_region_[i]))[i];
left = right;
}
const double slope((left - right) / (magic_number_region_[i] + 1));
double value(right);
Expand Down
6 changes: 6 additions & 0 deletions test/test_magic_intpl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ teardown() {
$sptk4/magic_intpl $tmp/1 -magic 0 > $tmp/3
run $sptk4/aeq $tmp/2 $tmp/3
[ "$status" -eq 0 ]

echo 0 9 0 0 2 1 0 0 4 5 0 0 | $sptk3/x2x +ad > $tmp/4
echo 2 9 2 5 2 1 3 3 4 5 4 5 | $sptk3/x2x +ad > $tmp/5
$sptk4/magic_intpl -l 2 $tmp/4 -magic 0 > $tmp/6
run $sptk4/aeq $tmp/5 $tmp/6
[ "$status" -eq 0 ]
}

@test "magic_intpl: valgrind" {
Expand Down

0 comments on commit ecf5821

Please sign in to comment.