/********************************************************************/ /* Copyright (c) 2017 System fugen G.K. and Yuzi Mizuno */ /* All rights reserved. */ /********************************************************************/ #ifndef _MGGausp_HH_ #define _MGGausp_HH_ /** @addtogroup ALGORITHM * @{ */ /** * @brief Legendre-Gauss quadratuer formula over (a,b) . * The DE formula (double exponential formula) is applied. * *Note* Original Fortran program codes are from DDGAUSP of the book * "Fortran77による数値計算ソフトウェア" by M.Sugihara, M.Mori, published by Maruzen K.K. * * @retval result of integration. */ template double mgGausp( func& f, /// 16) return 0.; double c1 = (b + a) / 2, c2 = (b - a) / 2; int nh; double v; if(n % 2 == 0){ nh = n / 2; v = 0.; }else{ nh = (n - 1) / 2; v = w[n * 17 - 17] * f(c1); } for (int i = 1; i <= nh; ++i) { double t1 = c1 + c2 * c[i + n * 17 - 17]; double t2 = c1 - c2 * c[i + n * 17 - 17]; v += w[i + n * 17 - 17] * (f(t1) + f(t2)); } v = c2 * v; return v; } #undef w #undef c /** @} */ // end of ALGORITHM group #endif