One further comment: > >> rez += pow(x1[i] - x2[i],2); std::pow is rather slow as it can deal with any exponent, also negative and real. In your case it is better to use (x1[i] - x2[i]) * (x1[i] - x2[i]) Christian