inline void normalize std vector double double sum for int size sum su

1
2
3
4
5
6
7
8
9
inline void normalize(std::vector<double>& x)
{
double sum = 0;
for (int i = 0; i < x.size(); ++i)
sum += x[i] * x[i];
sum = sqrt(sum);
for (int i = 0; i < x.size(); ++i)
x[i] /= sum;
}