I am trying to implement a physics engine based around hamiltonian mechanics. Facing several problems, such as to
- Differentiate the H function
- Partially evaluate a partial derivative of the H function for an efficient use of the Runge-Kutta method
I decided to represent functions as struct (Partial evaluation of a function represented as a struct).
However, combining the code of C++ templates with standart C++ code proves difficult. Moreover, evaluating a struct-function appears to take at least 2× more time than a corresponding standart function.
So I ask the Stackoverflow community, whether should I keep my approach or change it.
EDIT
I use g++ and compile from command line:
g++ -std=c++14 -IC:\Hudba\include Stin.cpp Tma.cpp -LC:\Hudba\lib -lglfw3 -lglew32 -lglu32 -lopengl32 -lkernel32 -luser32 -lgdi32 -lws2_32.
In order to partially evaluate a struct-function, I need to pass it an array of values that is not known at compile time, which is impossible using templates.