I have a structure (class) that keeps very large number of numbers (either float, double, int, byte) in an array.
Now I want to have very high performance approach to apply some primitive operations (Add/Subtract/Divide/Multiply with a constant) on this array.
This arrays is on a continuous piece of memory so for example for copying it I am using Buffer.BlockCopy.
But what about adding a constant or multiplying with a constant?
The first choice is to walk through the array using pointers. What other approaches do you suggest for this?
Using pointer (unsafe) is not certain to be more performant.
Why don’t you start with a normal
for(int index = 0; index < data.Lenght; index++)loop and see if it meets your requirements.And of course, the next step would be processing in parallel :