really struggling with this problem.
I'm writing a piece of code to solve a general system of linear ODE's using the forward Euler method.
I believe my code is working fine inside the classes but I'm having a problem initializing it.
Here is the constructor for my ForwardEulerSolver class:
ForwardEulerSolver(ODEInterface& anODESystem, const Vector& initialState,
const double initialTime, const double finalTime, const double stepSize,
Vector (*pFunction)(double time, Vector u), const std::string outputFileName
= "output.dat", const int saveGap = 1, const int printGap = 1);
I believe the problem is with Vector (*pFunction)(double time, Vector u). The function in question is supposed to be a function that takes a time "t", and a vector u, and returns the vector u^{dot} (ie: du/dx).
Then in my driver I define:
Vector FunctionToSolve(double time, Vector U)
{
Vector Output(1);
Output[0] = 1/(1 + pow(time,2));
return Output;
}
as a separate function (I know the vector U is unused here, and the problem is 1D but I want the option to perform this with more than 1 dimension and with a more complex f). I then have:
Vector (*pfunction)(double, Vector);
pfunction = &FunctionToSolve;
in int main().
I then try to initialize ForwardEulerClass in the following way:
ForwardEulerSolver* EulerSystem(*pODESystem, *initialVector, 0, 10, 0.01, *pfunction);
and get the following error on that line:
error: cannot convert 'Vector (*)(double, Vector)' to 'ForwardEulerSolver*' in initialization
im also getting a ton of warnings saying (all on the same line):
warning: right operand of comma operator has no effect [-Wunused-value]
warning: value computed is not used [-Wunused-value]
and
error: expression list treated as compound expression in initializer [-fpermissive]
Any help would be greatly appreciated! Thanks!