Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConstAccel::evalParams() computes wrong k_grid when ts[i] is an element in m_ts #230

Open
TungYiLai opened this issue Apr 10, 2023 · 0 comments

Comments

@TungYiLai
Copy link

TungYiLai commented Apr 10, 2023

Describe the bug
Based on the description, the function should find k_grid s.t m_ts[k_grid] <= ts[i] < m_ts[k_grid + 1] but it doesn't.

To Reproduce
Try this code snippet

constexpr std::array<double, 7> m_ts = {0, 0.1, 0.2, 0.4, 0.8, 1.6, 3.2};
constexpr double ts = m_ts[2];
const auto ptr = std::lower_bound(m_ts.data() + 1, m_ts.data() + m_ts.size() - 1, ts);
std::cout << "ts: " << ts << ", k_grid: " << (ptr - m_ts.data() - 1) << std::endl;

The last line outputs ts: 0.2, k_grid: 1

Expected behavior
The correct k_grid should be 3 instead of 2.

Version
35f8c7d5e245517fb4e0031a3c890934792fdfc1

@TungYiLai TungYiLai changed the title ConstAccel::evalParams() computes wrong k_grid when ts[i] is an element inm_ts ConstAccel::evalParams() computes wrong k_grid when ts[i] is an element in m_ts Apr 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant