1 /*! 2 * \file include/TFEL/Math/AccelerationAlgorithms/AitkenAccelerationAlgorithm.hxx 3 * \brief 4 * \author Thomas Helfer 5 * \date 28/05/2020 6 * \copyright Copyright (C) 2006-2018 CEA/DEN, EDF R&D. All rights 7 * reserved. 8 * This project is publicly released under either the GNU GPL Licence 9 * or the CECILL-A licence. A copy of thoses licences are delivered 10 * with the sources of TFEL. CEA or EDF may also distribute this 11 * project under specific licensing conditions. 12 */ 13 14 #ifndef LIB_TFEL_MATH_ACCELERATIONALGORITHMS_AITKENACCELERATIONALGORITHM_HXX 15 #define LIB_TFEL_MATH_ACCELERATIONALGORITHMS_AITKENACCELERATIONALGORITHM_HXX 16 17 #include <ostream> 18 19 namespace tfel { 20 21 namespace math { 22 23 /*! 24 * \brief an implementation of the Aitken \f$\Delta^{2}\f$ algorithm 25 * \tparam NumericType: numeric type used 26 * \tparam IndexType: integer used to store the iteration number 27 */ 28 template <typename NumericType, typename IndexType = unsigned int> 29 struct AitkenAccelerationAlgorithm { 30 /*! 31 * \brief this method shall be called before starting a new resolution 32 * \param[in] x0: initial guess 33 */ 34 void initialize(const NumericType); 35 /*! 36 * \brief perform the acceleration 37 * \param[in,out] x: on input, the result of the Picard iteration. On 38 * output, an accelerated estimate. 39 */ 40 void accelerate(NumericType&); 41 42 private: 43 //! \brief previous iterate 44 NumericType x0; 45 //! \brief previous iterate 46 NumericType x1; 47 //! \brief iteration number 48 IndexType i = 0; 49 }; // end of struct AitkenAccelerationAlgorithm 50 51 /*! 52 * \brief output stream operator 53 * \param[in] os: output operator 54 * \param[in] a: algorithm 55 */ 56 template <typename NumericType, typename IndexType> 57 std::ostream& operator<<( 58 std::ostream&, 59 const AitkenAccelerationAlgorithm<NumericType, IndexType>&); 60 61 } // end of namespace math 62 63 } // end of namespace tfel 64 65 #include "TFEL/Math/AccelerationAlgorithms/AitkenAccelerationAlgorithm.ixx" 66 67 #endif /* LIB_TFEL_MATH_ACCELERATIONALGORITHMS_AITKENACCELERATIONALGORITHM_HXX */ 68