1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #pragma once
- #include <Mathematics/GMatrix.h>
- #include <Mathematics/OdeSolver.h>
- namespace WwiseGTE
- {
- template <typename Real, typename TVector, typename TMatrix>
- class OdeImplicitEuler : public OdeSolver<Real, TVector>
- {
- public:
-
- virtual ~OdeImplicitEuler() = default;
- OdeImplicitEuler(Real tDelta,
- std::function<TVector(Real, TVector const&)> const& F,
- std::function<TMatrix(Real, TVector const&)> const& DF)
- :
- OdeSolver<Real, TVector>(tDelta, F),
- mDerivativeFunction(DF)
- {
- }
-
-
- virtual void Update(Real tIn, TVector const& xIn, Real& tOut, TVector& xOut) override
- {
- TVector fVector = this->mFunction(tIn, xIn);
- TMatrix dfMatrix = mDerivativeFunction(tIn, xIn);
- TMatrix dgMatrix = TMatrix::Identity() - this->mTDelta * dfMatrix;
- TMatrix dgInverse = Inverse(dgMatrix);
- fVector = dgInverse * fVector;
- tOut = tIn + this->mTDelta;
- xOut = xIn + this->mTDelta * fVector;
- }
- private:
- std::function<TMatrix(Real, TVector const&)> mDerivativeFunction;
- };
- }
|