Fix a bug reported by Thomas Hoffmann in ngspice-users discussion,

2023-02-18.  Incorrect tests were used to detect a crossing in the
first two data samples.
This commit is contained in:
Giles Atkinson 2023-02-21 16:04:39 +00:00 committed by Holger Vogt
parent 06aa693852
commit d9b52eb3e1
1 changed files with 4 additions and 6 deletions

View File

@ -491,14 +491,13 @@ com_measure_when(
crossCnt = 0;
if (value < value2) {
section = S_BELOW_VAL;
if ((prevValue <= value2) && (value >= value2)) {
if (prevValue >= prevValue2) {
fallCnt = 1;
crossCnt = 1;
}
} else {
section = S_ABOVE_VAL;
if ((prevValue <= value2) && (value >= value2)) {
if (prevValue < prevValue2) {
riseCnt = 1;
crossCnt = 1;
}
@ -509,14 +508,13 @@ com_measure_when(
crossCnt = 0;
if (value < meas->m_val) {
section = S_BELOW_VAL;
if ((prevValue <= meas->m_val) && (value >= meas->m_val)) {
if (prevValue >= meas->m_val) {
fallCnt = 1;
crossCnt = 1;
}
} else {
section = S_ABOVE_VAL;
if ((prevValue <= meas->m_val) && (value >= meas->m_val)) {
if (prevValue < meas->m_val) {
riseCnt = 1;
crossCnt = 1;
}