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

Remove noisy static_cast<int>(0). #1434

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

1uc
Copy link
Collaborator

@1uc 1uc commented Sep 18, 2024

No description provided.

bbpadministrator pushed a commit to BlueBrain/nmodl-references that referenced this pull request Sep 18, 2024
@1uc 1uc marked this pull request as ready for review September 18, 2024 08:31
@alkino
Copy link
Member

alkino commented Sep 18, 2024

It has been added because sometime this is a double and this is forbidden to use this for indexing

@1uc
Copy link
Collaborator Author

1uc commented Sep 18, 2024

It has been added because sometime this is a double

Okay, so it's not just for readability, but it's a bug fix, even better.

@alkino
Copy link
Member

alkino commented Sep 18, 2024

#776

@1uc
Copy link
Collaborator Author

1uc commented Sep 19, 2024

We have code that looks like this:

            nmodl_eigen_j[static_cast<int>(120)] =  -nmodl_eigen_x[static_cast<int>(0)] * _nt->_dt * kf11_ / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(0)]);
            nmodl_eigen_j[static_cast<int>(132)] = _nt->_dt * kb11_ / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(0)]);
            nmodl_eigen_f[static_cast<int>(1)] = (nmodl_eigen_x[static_cast<int>(0)] * _nt->_dt * kf0_ - nmodl_eigen_x[static_cast<int>(1)] * _nt->_dt * kb0_ - nmodl_eigen_x[static_cast<int>(1)] * _nt->_dt * kf1_ + nmodl_eigen_x[static_cast<int>(2)] * _nt->_dt * kb1_ + pow((*inst.diam[id]), 2.0) * ( -nmodl_eigen_x[static_cast<int>(1)] + old_ca_1) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(1)]) / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(1)]);
            nmodl_eigen_j[static_cast<int>(1)] = _nt->_dt * kf0_ / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(1)]);
            nmodl_eigen_j[static_cast<int>(13)] = ( -inst.global->beta * pow((*inst.diam[id]), 2.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(1)] - pow((*inst.diam[id]), 2.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(1)] - _nt->_dt * kb0_ - _nt->_dt * kf1_) / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(1)]);
            nmodl_eigen_j[static_cast<int>(25)] = _nt->_dt * kb1_ / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(1)]);

In order to be able to read this I need to apply a sequence of substitutions, first one it to remove all the static_cast<int>, they're just too much. Then we need to strip the nmodl_eigen_ which adds more clutter.

For example compare:

            nmodl_eigen_j[static_cast<int>(120)] =  -nmodl_eigen_x[static_cast<int>(0)] * _nt->_dt * kf11_ / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[static_cast<int>(0)]);

            nmodl_eigen_j[120] =  -nmodl_eigen_x[0] * _nt->_dt * kf11_ / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[0]);

            j[120] =  -x[0] * _nt->_dt * kf11_ / (pow((*inst.diam[id]), 2.0) * (inst.global->beta + 1.0) * (_thread_vars.vol_ptr(id))[0]);

There's still some problems with inst.diam, inst.global->beta and _thread_vars.vol_ptr that make it difficult to read; and arguably NOCMODL generated output is superior in that regard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants