@Martin_fr
I'm not an expert either but regarding the presented code I've noticed:
1)If I change "For n:= 1 to Number do" to "For n:=0 to Number-1 do" and change "[n-1]" with "[n]" inside the loop
and
If I change "For k:= 1 to Number do" to "For k:=0 to Number-1 do" and change "[k-1]" with "[k]" inside the loop
then the code will be executed slower, although to me, it should run faster due to the removal of "-1"s. Probably it's due to the initial assignment at the beginning of the "for" loops, I didn't looked at the code produced.
2)Situations like the following one are known. If I completely remove variable Trapezoid and replace
ZHelp:= ZHelp + Trapezoid;
with
ZHelp:= ZHelp + ((abs(ZArray[k-1]-ZArray[k])/2 + Min(ZArray[k-1], ZArray[k])) * (XValues[k]-XValues[k-1]));
again, the code is executed slower.
3)As far as I remember I've been surprised to notice that declaring a new variable "XValuesdouble:double;"
and changing
For k:=0 to Number-1 do
ZArray[k]:= ZValues[k] * A * exp(-Pi*power(A/1000*(XValues[k]-XValues[n]), 2));
with
XValuesdouble:=XValues[n];
For k:=0 to Number-1 do
ZArray[k]:= ZValues[k] * A * exp(-Pi*power(A/1000*(XValues[k]-XValuesdouble), 2));
again lead to a decrease of code execution speed.
Using level 3 optimization level.
However, It's a very strange CPU I have here, many things don't work as expected.