Let's say I have a loop that will do some math on an array x. Is it better to assign a temporary double inside the loop at each iteration or should I use the array[i] every time? 
By better I mean performance-wise using C++. I wonder if C++ has some vectorization or cash optimization that I'm ruining?
Also what if I call a function using this array and I might need values of a function multiple times, so I usually do the same with functions. I assume this would be better than calling the function many times.
How about if the loop uses omp parallel, I assume this should be safe, correct?
for(int i=0; i<N; i++){
    double xi = X[i];
    double fi = f(xi);
    t[i] = xi*xi + fi + xi/fi;
}
 
     
     
     
    