gsl_integration__qpsrt2.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* integration/qpsrt2.c
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Brian Gough
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. */
  19. /* The smallest interval has the largest error. Before bisecting
  20. decrease the sum of the errors over the larger intervals
  21. (error_over_large_intervals) and perform extrapolation. */
  22. static int
  23. increase_nrmax (gsl_integration_workspace * workspace);
  24. static int
  25. increase_nrmax (gsl_integration_workspace * workspace)
  26. {
  27. int k;
  28. int id = workspace->nrmax;
  29. int jupbnd;
  30. const size_t * level = workspace->level;
  31. const size_t * order = workspace->order;
  32. size_t limit = workspace->limit ;
  33. size_t last = workspace->size - 1 ;
  34. if (last > (1 + limit / 2))
  35. {
  36. jupbnd = limit + 1 - last;
  37. }
  38. else
  39. {
  40. jupbnd = last;
  41. }
  42. for (k = id; k <= jupbnd; k++)
  43. {
  44. size_t i_max = order[workspace->nrmax];
  45. workspace->i = i_max ;
  46. if (level[i_max] < workspace->maximum_level)
  47. {
  48. return 1;
  49. }
  50. workspace->nrmax++;
  51. }
  52. return 0;
  53. }
  54. static int
  55. large_interval (gsl_integration_workspace * workspace)
  56. {
  57. size_t i = workspace->i ;
  58. const size_t * level = workspace->level;
  59. if (level[i] < workspace->maximum_level)
  60. {
  61. return 1 ;
  62. }
  63. else
  64. {
  65. return 0 ;
  66. }
  67. }