/************************************************************************* * 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_SIMPLE_HPP #define VZ_SIMPLE_HPP #include namespace vZ { // Base class for non-adaptive RK-style algorithms template class GenericSimpleIntegrator : public GenericRKIntegrator { public: typedef typename GenericRKIntegrator::Scalar Scalar; typedef typename GenericRKIntegrator::Function Function; protected: typedef typename GenericRKIntegrator::ACoefficients ACoefficients; typedef typename GenericRKIntegrator::BCoefficients BCoefficients; typedef typename GenericRKIntegrator::KVector KVector; GenericSimpleIntegrator(Function f, ACoefficients a, BCoefficients b) : GenericRKIntegrator(f), m_a(a), m_b(b) { } virtual ~GenericSimpleIntegrator() { } void step(); private: ACoefficients m_a; BCoefficients m_b; }; // Type alias typedef GenericSimpleIntegrator SimpleIntegrator; // Implementations template void GenericSimpleIntegrator::step() { this->y(calculateY(calculateK(m_a), m_b)); this->x(this->x() + this->h()); } } #endif // VZ_SIMPLE_HPP