I'm trying to build a polynomial function generator, so that it takes a vector (arbitrary size) as argument, and generates a polynomial function I can use later.
for instance,
poly_gen(vector<int> power_index)
returns a function (or by other method) in forms of (that i can call with another function)
y(k)=a0+ a1*n+ a2*n^2 + a3*n^3 + ... + ak*n^k
where a0,a1....ak are stored in the vector- power_index
and later I can call it with
int calc_poly(int n)
and this calc_poly
can return me a number, calculated by using the polynomial expression generated by poly_gen()
PS: I don't know how to search this question by key words. function,construction, generator, pointer, functor... didn't give me the desired results.
thank you all!