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

Change randomValue function to provide reaching of maximum value. #565

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

fullset
Copy link
Collaborator

@fullset fullset commented Oct 15, 2019

Closes #251
Hey, @ihhub look, please.

You've said in the description that 1 on the way to solve this issue is

Change rand() % maximum to rand() % (maximum + 1). After this we have to change all calls of this function.

So, I've changed the most of calls of randomValue() but some other calls look fine without changing.

@fullset fullset self-assigned this Oct 15, 2019
@fullset fullset added the improvement Upgrade existing feature label Oct 15, 2019
@ihhub ihhub added this to the Whishlist milestone Oct 28, 2019
Copy link
Owner

@ihhub ihhub left a comment

Choose a reason for hiding this comment

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

Hi @fullset, thanks a lot for your huge efforts for issues!

Could we try to create a separate pull request just for randomBoolValue function? I think such change is transparent with no debates. What do you think?

@@ -207,8 +207,8 @@ namespace image_function_cuda
const std::vector < uint8_t > intensity = intensityArray( 2 );
PenguinV_Image::Image input = uniformImage( intensity[0], 0, 0, reference );

const bool horizontalFlip = (randomValue<uint32_t>( 0, 2 ) == 0);
const bool verticalFlip = (randomValue<uint32_t>( 0, 2 ) == 0);
const bool horizontalFlip = ( randomValue<uint32_t>( 0, 1 ) == 0 );
Copy link
Owner

Choose a reason for hiding this comment

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

Let's create randomBoolValue() function instead. No harm to do this but it makes code easier to read.

Copy link
Owner

Choose a reason for hiding this comment

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

For this function we could use rand() directly, no need to call randomValue<> function

@@ -1935,8 +1935,8 @@ namespace Function_Template
{
const std::vector < uint8_t > intensity = intensityArray( 2 );
PenguinV_Image::Image image = uniformImage( intensity[0] );
const uint32_t x = randomValue<uint32_t>( 0, image.width() );
const uint32_t y = randomValue<uint32_t>( 0, image.height() );
const uint32_t x = randomValue<uint32_t>( 0, image.width() - 1 );
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure that this format is good as another developer would definitely forget to add - 1. What's your opinion?

@ihhub ihhub marked this pull request as draft November 2, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Upgrade existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change randomValue function's maximum value
2 participants