20 for (
int i=0;i<n;i++) x[i]= 1.0/(
double)(1+n-i);
26 for (
int i=0;i<x.size();i++)sum+=x[i];
37 auto x=std::make_shared<std::vector<double>>(n);
void initialize(std::vector< double > &x)
We pass (as in example 03) a reference to the vector to the functions using it.
double sum_elements(std::vector< double > &x)
A::value_type sum(const A &a)
Sum of array or expression.