GMAN
GMAN

Reputation: 131

Parallel For to sum an array of ushorts (big array 18M)

I would like to use parallel processing for taking array statistics for large arrays of unsigned short (16 bit) values.

ushort[] array = new ushort[2560 * 3072]; // x = rows(2560) y = columns(3072)

double avg = Parallel.For (0, array.Length, WHAT GOES HERE);

The same for standard deviation & standard deviation of row means.

I have normal for loop versions of these functions and they take too long when combined with Median Filter methods.

The end product is to try and get a Median Filter for the array. But the first steps are important as well. So if you have the whole solution great but if you want to help with the first parts as well it is all appreciated.

Upvotes: 2

Views: 285

Answers (1)

Matthew Strawbridge
Matthew Strawbridge

Reputation: 20640

Have you tried PLINQ?

double average = array.AsParallel().Average(n => n);

I'm not sure how performant it will be with a large array of ushort values, but it's worth testing to see if it meets your needs.

Upvotes: 2

Related Questions