Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "itkComplexConjugateImageAdaptor.h"
#include "itkImageRegionIterator.h"
#include <random>


using PixelType = std::complex<float>;
Expand All @@ -34,13 +35,13 @@ itkComplexConjugateImageAdaptorTest(int, char *[])
image->Allocate();
const ImageType::RegionType region = image->GetLargestPossibleRegion();

srand(50L);
std::mt19937 randomNumberEngine;
std::uniform_real_distribution<float> randomNumberDistribution;

itk::ImageRegionIterator<ImageType> iter(image, region);
for (iter.GoToBegin(); !iter.IsAtEnd(); ++iter)
{
auto randMax = static_cast<float>(RAND_MAX);
const PixelType pixel(static_cast<float>(rand()) / randMax, static_cast<float>(rand()) / randMax);
const PixelType pixel(randomNumberDistribution(randomNumberEngine), randomNumberDistribution(randomNumberEngine));
Comment on lines -42 to +44
Copy link
Contributor Author

@N-Dekker N-Dekker May 14, 2025

Choose a reason for hiding this comment

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

For the record, this pull request was inspired by a discussion we had before about the use of static_cast<float>(RAND_MAX), at #5337 (comment) It appeared that RAND_MAX is platform dependent, so this static_cast<float> may or may not be lossless. Which made me want to get rid of static_cast<float>(RAND_MAX) 👹 !

iter.Set(pixel);
}

Expand Down
Loading