/************************************************************************* * Copyright (C) 2009-2010 Tavian Barnes * * * * This file is part of The vZ Library. * * * * The vZ Library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License as * * published by the Free Software Foundation; either version 3 of the * * License, or (at your option) any later version. * * * * The vZ Library is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with this program. If not, see * * . * *************************************************************************/ #ifndef VZ_HE12_HPP #define VZ_HE12_HPP namespace vZ { // Heun-Euler method // // Second-order with embedded first-order // Its tableau is: // // 0 | // 1 | 1 // ---+--------- // b | 1/2 1/2 // b* | 1 0 template class GenericHE12Integrator : public GenericAdaptiveIntegrator { public: typedef typename GenericAdaptiveIntegrator::Scalar Scalar; typedef typename GenericAdaptiveIntegrator::Function Function; GenericHE12Integrator(Function f) : GenericAdaptiveIntegrator(f, 2, s_a, s_b, s_bStar) { } ~GenericHE12Integrator() { } private: typedef typename GenericAdaptiveIntegrator::ACoefficients ACoefficients; typedef typename GenericAdaptiveIntegrator::BCoefficients BCoefficients; static ACoefficients s_a; static BCoefficients s_b; static BCoefficients s_bStar; static Scalar s_a2Arr[1]; static std::vector s_aArr[1]; static Scalar s_bArr[2]; static Scalar s_bStarArr[2]; }; // Type alias typedef GenericHE12Integrator HE12Integrator; // Implementation template typename GenericHE12Integrator::Scalar GenericHE12Integrator::s_a2Arr[1] = { Scalar(1) }; template std::vector::Scalar> GenericHE12Integrator::s_aArr[1] = { std::vector(s_a2Arr, s_a2Arr + 1) }; template typename GenericHE12Integrator::ACoefficients GenericHE12Integrator::s_a(s_aArr, s_aArr + 1); template typename GenericHE12Integrator::Scalar GenericHE12Integrator::s_bArr[2] = { Scalar(1)/Scalar(2), Scalar(1)/Scalar(2) }; template typename GenericHE12Integrator::BCoefficients GenericHE12Integrator::s_b(s_bArr, s_bArr + 2); template typename GenericHE12Integrator::Scalar GenericHE12Integrator::s_bStarArr[2] = { Scalar(1), Scalar(0) }; template typename GenericHE12Integrator::BCoefficients GenericHE12Integrator::s_bStar(s_bStarArr, s_bStarArr + 2); } #endif // VZ_HE12_HPP