说我有
double xSquared( const double )
{
return x*x;
}
...
std::function<double (double)> func = &xSquared;
...
Run Code Online (Sandbox Code Playgroud)
到目前为止,我使用这种结构的(更复杂的)目的很好.现在我有一个接受上述形式的std :: function的函数,我需要创建一个扩展原始的新的std :: function:
typedef std::function<double (double)> func1D;
double someFunction( const func1D &func, const double a )
{
func1D extendedFunc = func/(x-a); // I know this is incorrect, but how would I do that?
...
}
Run Code Online (Sandbox Code Playgroud)
所以数学等价物是:
f(x)=x²
g(x)= f(x)/(xa)
我怎么能做到这一点?谢谢您的帮助!