gsl_roots.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /* roots/gsl_roots.h
  2. *
  3. * Copyright (C) 1996, 1997, 1998, 1999, 2000, 2007 Reid Priedhorsky, 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. #ifndef __GSL_ROOTS_H__
  20. #define __GSL_ROOTS_H__
  21. #include <stdlib.h>
  22. #include "gsl_types.h"
  23. #include "gsl_math.h"
  24. #undef __BEGIN_DECLS
  25. #undef __END_DECLS
  26. #ifdef __cplusplus
  27. # define __BEGIN_DECLS extern "C" {
  28. # define __END_DECLS }
  29. #else
  30. # define __BEGIN_DECLS /* empty */
  31. # define __END_DECLS /* empty */
  32. #endif
  33. __BEGIN_DECLS
  34. typedef struct
  35. {
  36. const char *name;
  37. size_t size;
  38. int (*set) (void *state, gsl_function * f, double * root, double x_lower, double x_upper);
  39. int (*iterate) (void *state, gsl_function * f, double * root, double * x_lower, double * x_upper);
  40. }
  41. gsl_root_fsolver_type;
  42. typedef struct
  43. {
  44. const gsl_root_fsolver_type * type;
  45. gsl_function * function ;
  46. double root ;
  47. double x_lower;
  48. double x_upper;
  49. void *state;
  50. }
  51. gsl_root_fsolver;
  52. typedef struct
  53. {
  54. const char *name;
  55. size_t size;
  56. int (*set) (void *state, gsl_function_fdf * f, double * root);
  57. int (*iterate) (void *state, gsl_function_fdf * f, double * root);
  58. }
  59. gsl_root_fdfsolver_type;
  60. typedef struct
  61. {
  62. const gsl_root_fdfsolver_type * type;
  63. gsl_function_fdf * fdf ;
  64. double root ;
  65. void *state;
  66. }
  67. gsl_root_fdfsolver;
  68. gsl_root_fsolver *
  69. gsl_root_fsolver_alloc (const gsl_root_fsolver_type * T);
  70. void gsl_root_fsolver_free (gsl_root_fsolver * s);
  71. int gsl_root_fsolver_set (gsl_root_fsolver * s,
  72. gsl_function * f,
  73. double x_lower, double x_upper);
  74. int gsl_root_fsolver_iterate (gsl_root_fsolver * s);
  75. const char * gsl_root_fsolver_name (const gsl_root_fsolver * s);
  76. double gsl_root_fsolver_root (const gsl_root_fsolver * s);
  77. double gsl_root_fsolver_x_lower (const gsl_root_fsolver * s);
  78. double gsl_root_fsolver_x_upper (const gsl_root_fsolver * s);
  79. gsl_root_fdfsolver *
  80. gsl_root_fdfsolver_alloc (const gsl_root_fdfsolver_type * T);
  81. int
  82. gsl_root_fdfsolver_set (gsl_root_fdfsolver * s,
  83. gsl_function_fdf * fdf, double root);
  84. int
  85. gsl_root_fdfsolver_iterate (gsl_root_fdfsolver * s);
  86. void
  87. gsl_root_fdfsolver_free (gsl_root_fdfsolver * s);
  88. const char * gsl_root_fdfsolver_name (const gsl_root_fdfsolver * s);
  89. double gsl_root_fdfsolver_root (const gsl_root_fdfsolver * s);
  90. int
  91. gsl_root_test_interval (double x_lower, double x_upper, double epsabs, double epsrel);
  92. int
  93. gsl_root_test_residual (double f, double epsabs);
  94. int
  95. gsl_root_test_delta (double x1, double x0, double epsabs, double epsrel);
  96. GSL_VAR const gsl_root_fsolver_type * gsl_root_fsolver_bisection;
  97. GSL_VAR const gsl_root_fsolver_type * gsl_root_fsolver_brent;
  98. GSL_VAR const gsl_root_fsolver_type * gsl_root_fsolver_falsepos;
  99. GSL_VAR const gsl_root_fdfsolver_type * gsl_root_fdfsolver_newton;
  100. GSL_VAR const gsl_root_fdfsolver_type * gsl_root_fdfsolver_secant;
  101. GSL_VAR const gsl_root_fdfsolver_type * gsl_root_fdfsolver_steffenson;
  102. __END_DECLS
  103. #endif /* __GSL_ROOTS_H__ */