What is a fast way to evaluate function. Now, I am evaluating a function
using for-loop and vectors. For example,
1 2 3 4 5
void evaluate(std::vector <double>& f,std::vector <double>& x){
for ( int i = 0; i < x.size(); i++ ){
f.push_back(2*x[i]);
}
}
where I am evaluating function f(x) = 2*x;
But, I am a quite new with C++ so I don't know is this method slow or fast.
Length of the vector x is something between 3 and 15, but I need to evaluate
this many times.