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

i.gensigset: fix possible pole and divide by zero errors in regroup #4500

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

Conversation

ymdatta
Copy link
Contributor

@ymdatta ymdatta commented Oct 11, 2024

Using logarithm function call with zero argument will lead to a pole error, which occurs if the mathematical function has an exact infinite result.

Check if the argument value is zero before passing that to the log function to avoid such errors. I also added check for negative numbers just to make sure the argument is in the right domain for the log function as well.

There was also a possible divide by zero scenario when we were dividing the class data by subsum, which can be zero. Added a conditional check which avoids going to that stage.

@github-actions github-actions bot added C Related code is in C module imagery labels Oct 11, 2024
if (subsum > 0)
likelihood += log(subsum) + maxlike;

if (subsum) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't combine both of these in the same conditional as subsum being negative is not valid for log, but valid while calculating Data.

@nilason nilason added this to the 8.5.0 milestone Oct 12, 2024
Using logarithm function call with zero argument will lead to
a pole error, which occurs if the mathematical function has
an exact infinite result.

Check if the argument value is zero before passing that to
the log function to avoid such errors. I also added check
for negative numbers just to make sure the argument is in
the right domain for the log function as well.

There was also a possible divide by zero scenario when we
were dividing the class data by subsum, which can be zero.
Added a conditional check which avoids going to that stage.

Signed-off-by: Mohan Yelugoti <ymdatta.work@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C imagery module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants