rb-gsl 1.16.0.2 → 1.16.0.3.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +5 -0
- data/README +2 -2
- data/Rakefile +2 -3
- data/lib/gsl/version.rb +1 -1
- data/rdoc/alf.rdoc +5 -5
- data/rdoc/blas.rdoc +8 -8
- data/rdoc/bspline.rdoc +16 -16
- data/rdoc/changes.rdoc +4 -9
- data/rdoc/cheb.rdoc +24 -24
- data/rdoc/cholesky_complex.rdoc +21 -21
- data/rdoc/combi.rdoc +36 -36
- data/rdoc/complex.rdoc +21 -21
- data/rdoc/const.rdoc +46 -46
- data/rdoc/dht.rdoc +48 -48
- data/rdoc/diff.rdoc +41 -41
- data/rdoc/ehandling.rdoc +5 -5
- data/rdoc/eigen.rdoc +152 -152
- data/rdoc/fft.rdoc +145 -145
- data/rdoc/fit.rdoc +108 -108
- data/rdoc/function.rdoc +10 -10
- data/rdoc/graph.rdoc +16 -16
- data/rdoc/hist.rdoc +102 -102
- data/rdoc/hist2d.rdoc +41 -41
- data/rdoc/hist3d.rdoc +8 -8
- data/rdoc/index.rdoc +18 -21
- data/rdoc/integration.rdoc +109 -109
- data/rdoc/interp.rdoc +70 -70
- data/rdoc/intro.rdoc +6 -6
- data/rdoc/linalg.rdoc +187 -187
- data/rdoc/linalg_complex.rdoc +1 -1
- data/rdoc/math.rdoc +57 -57
- data/rdoc/matrix.rdoc +272 -272
- data/rdoc/min.rdoc +56 -56
- data/rdoc/monte.rdoc +21 -21
- data/rdoc/multimin.rdoc +94 -94
- data/rdoc/multiroot.rdoc +79 -79
- data/rdoc/narray.rdoc +31 -31
- data/rdoc/ndlinear.rdoc +53 -53
- data/rdoc/nonlinearfit.rdoc +99 -99
- data/rdoc/ntuple.rdoc +30 -30
- data/rdoc/odeiv.rdoc +87 -87
- data/rdoc/perm.rdoc +89 -89
- data/rdoc/poly.rdoc +65 -65
- data/rdoc/qrng.rdoc +20 -20
- data/rdoc/randist.rdoc +81 -81
- data/rdoc/ref.rdoc +56 -56
- data/rdoc/rng.rdoc +84 -84
- data/rdoc/roots.rdoc +56 -56
- data/rdoc/sf.rdoc +427 -427
- data/rdoc/siman.rdoc +18 -18
- data/rdoc/sort.rdoc +29 -29
- data/rdoc/start.rdoc +8 -8
- data/rdoc/stats.rdoc +51 -51
- data/rdoc/sum.rdoc +11 -11
- data/rdoc/tensor.rdoc +30 -30
- data/rdoc/tut.rdoc +1 -1
- data/rdoc/use.rdoc +37 -37
- data/rdoc/vector.rdoc +187 -187
- data/rdoc/vector_complex.rdoc +23 -23
- data/rdoc/wavelet.rdoc +46 -46
- metadata +17 -20
- data/rdoc/rngextra.rdoc +0 -11
- data/rdoc/screenshot.rdoc +0 -40
data/rdoc/nonlinearfit.rdoc
CHANGED
@@ -1,60 +1,60 @@
|
|
1
1
|
#
|
2
2
|
# = Nonlinear Least-Squares Fitting
|
3
|
-
# This chapter describes functions for multidimensional nonlinear least-squares
|
4
|
-
# fitting. The library provides low level components for a variety of iterative
|
5
|
-
# solvers and convergence tests. These can be combined by the user to achieve
|
6
|
-
# the desired solution, with full access to the intermediate steps of the
|
7
|
-
# iteration. Each class of methods uses the same framework, so that you can
|
8
|
-
# switch between solvers at runtime without needing to recompile your program.
|
9
|
-
# Each instance of a solver keeps track of its own state, allowing the solvers
|
10
|
-
# to be used in multi-threaded programs.
|
3
|
+
# This chapter describes functions for multidimensional nonlinear least-squares
|
4
|
+
# fitting. The library provides low level components for a variety of iterative
|
5
|
+
# solvers and convergence tests. These can be combined by the user to achieve
|
6
|
+
# the desired solution, with full access to the intermediate steps of the
|
7
|
+
# iteration. Each class of methods uses the same framework, so that you can
|
8
|
+
# switch between solvers at runtime without needing to recompile your program.
|
9
|
+
# Each instance of a solver keeps track of its own state, allowing the solvers
|
10
|
+
# to be used in multi-threaded programs.
|
11
11
|
#
|
12
12
|
# Contents:
|
13
|
-
# 1. {Overview}[link:
|
14
|
-
# 1. {Initializing the Solver}[link:
|
15
|
-
# 1. {GSL::MultiFit::FdfSolver class}[link:
|
16
|
-
# 1. {Providing the function to be minimized}[link:
|
17
|
-
# 1. {GSL::MultiFit::Function_fdf class}[link:
|
18
|
-
# 1. {Iteration}[link:
|
19
|
-
# 1. {Search Stopping Parameters}[link:
|
20
|
-
# 1. {Computing the covariance matrix of best fit parameters}[link:
|
21
|
-
# 1. {Higher level interfaces}[link:
|
22
|
-
# 1. {Examples}[link:
|
23
|
-
# 1. {Fitting to user-defined functions}[link:
|
24
|
-
# 1. {Fitting to built-in functions}[link:
|
25
|
-
#
|
26
|
-
# ==
|
27
|
-
# The problem of multidimensional nonlinear least-squares fitting requires the
|
28
|
-
# minimization of the squared residuals of n functions, f_i, in p parameters,
|
29
|
-
# x_i, All algorithms proceed from an initial guess using the linearization,
|
30
|
-
# where x is the initial point, p is the proposed step and J is the Jacobian
|
31
|
-
# matrix J_{ij} = d f_i / d x_j. Additional strategies are used to enlarge the
|
32
|
-
# region of convergence. These include requiring a decrease in the norm ||F||
|
33
|
-
# on each step or using a trust region to avoid steps which fall outside the
|
34
|
-
# linear regime.
|
35
|
-
#
|
36
|
-
# To perform a weighted least-squares fit of a nonlinear model Y(x,t) to data
|
37
|
-
# (t_i, y_i) with independent gaussian errors \sigma_i, use function components
|
38
|
-
# of the following form, Note that the model parameters are denoted by x in this
|
39
|
-
# chapter since the non-linear least-squares algorithms are described
|
40
|
-
# geometrically (i.e. finding the minimum of a surface). The independent
|
41
|
-
# variable of any data to be fitted is denoted by t.
|
42
|
-
#
|
43
|
-
# With the definition above the Jacobian is
|
44
|
-
# J_{ij} =(1 / \sigma_i) d Y_i / d x_j, where Y_i = Y(x,t_i).
|
45
|
-
#
|
46
|
-
# ==
|
47
|
-
#
|
48
|
-
# ===
|
13
|
+
# 1. {Overview}[link:nonlinearfit_rdoc.html#label-Overview]
|
14
|
+
# 1. {Initializing the Solver}[link:nonlinearfit_rdoc.html#label-Initializing+the+Solver]
|
15
|
+
# 1. {GSL::MultiFit::FdfSolver class}[link:nonlinearfit_rdoc.html#label-FdfSolver+class]
|
16
|
+
# 1. {Providing the function to be minimized}[link:nonlinearfit_rdoc.html#label-Providing+the+function+to+be+minimized]
|
17
|
+
# 1. {GSL::MultiFit::Function_fdf class}[link:nonlinearfit_rdoc.html#label-Function_fdf+class]
|
18
|
+
# 1. {Iteration}[link:nonlinearfit_rdoc.html#label-Iteration]
|
19
|
+
# 1. {Search Stopping Parameters}[link:nonlinearfit_rdoc.html#label-Search+Stopping+Parameters]
|
20
|
+
# 1. {Computing the covariance matrix of best fit parameters}[link:nonlinearfit_rdoc.html#label-Computing+the+covariance+matrix+of+best+fit+parameters]
|
21
|
+
# 1. {Higher level interfaces}[link:nonlinearfit_rdoc.html#label-Higher+level+interfaces]
|
22
|
+
# 1. {Examples}[link:nonlinearfit_rdoc.html#label-Examples]
|
23
|
+
# 1. {Fitting to user-defined functions}[link:nonlinearfit_rdoc.html#label-Fitting+to+user-defined+functions]
|
24
|
+
# 1. {Fitting to built-in functions}[link:nonlinearfit_rdoc.html#label-Fitting+to+built-in+functions]
|
25
|
+
#
|
26
|
+
# == Overview
|
27
|
+
# The problem of multidimensional nonlinear least-squares fitting requires the
|
28
|
+
# minimization of the squared residuals of n functions, f_i, in p parameters,
|
29
|
+
# x_i, All algorithms proceed from an initial guess using the linearization,
|
30
|
+
# where x is the initial point, p is the proposed step and J is the Jacobian
|
31
|
+
# matrix J_{ij} = d f_i / d x_j. Additional strategies are used to enlarge the
|
32
|
+
# region of convergence. These include requiring a decrease in the norm ||F||
|
33
|
+
# on each step or using a trust region to avoid steps which fall outside the
|
34
|
+
# linear regime.
|
35
|
+
#
|
36
|
+
# To perform a weighted least-squares fit of a nonlinear model Y(x,t) to data
|
37
|
+
# (t_i, y_i) with independent gaussian errors \sigma_i, use function components
|
38
|
+
# of the following form, Note that the model parameters are denoted by x in this
|
39
|
+
# chapter since the non-linear least-squares algorithms are described
|
40
|
+
# geometrically (i.e. finding the minimum of a surface). The independent
|
41
|
+
# variable of any data to be fitted is denoted by t.
|
42
|
+
#
|
43
|
+
# With the definition above the Jacobian is
|
44
|
+
# J_{ij} =(1 / \sigma_i) d Y_i / d x_j, where Y_i = Y(x,t_i).
|
45
|
+
#
|
46
|
+
# == Initializing the Solver
|
47
|
+
#
|
48
|
+
# === FdfSolver class
|
49
49
|
# ---
|
50
50
|
# * GSL::MultiFit::FdfSolver.alloc(T, n, p)
|
51
51
|
#
|
52
|
-
# This creates an instance of the <tt>GSL::MultiFit::FdfSolver</tt> class of
|
52
|
+
# This creates an instance of the <tt>GSL::MultiFit::FdfSolver</tt> class of
|
53
53
|
# type <tt>T</tt> for <tt>n</tt> observations and <tt>p</tt> parameters. The type <tt>T</tt>
|
54
|
-
# is given by a <tt>Fixnum</tt> constant or a <tt>String</tt>,
|
54
|
+
# is given by a <tt>Fixnum</tt> constant or a <tt>String</tt>,
|
55
55
|
# * <tt>GSL::MultiFit::LMSDER</tt> or <tt>"lmsder"</tt>
|
56
56
|
# * <tt>GSL::MultiFit::LMDER</tt> or <tt>"lmder"</tt>
|
57
|
-
# For example, the following code creates an instance of a Levenberg-Marquardt
|
57
|
+
# For example, the following code creates an instance of a Levenberg-Marquardt
|
58
58
|
# solver for 100 data points and 3 parameters,
|
59
59
|
#
|
60
60
|
# solver = MultiFit::FdfSolver.alloc(MultiFit::LMDER, 100, 3)
|
@@ -62,10 +62,10 @@
|
|
62
62
|
# ---
|
63
63
|
# * GSL::MultiFit::FdfSolver#set(f, x)
|
64
64
|
#
|
65
|
-
# This method initializes, or reinitializes, an existing solver <tt>self</tt>
|
65
|
+
# This method initializes, or reinitializes, an existing solver <tt>self</tt>
|
66
66
|
# to use the function <tt>f</tt> and the initial guess <tt>x</tt>. The function <tt>f</tt>
|
67
67
|
# is an instance of the <tt>GSL::MultiFit::Function_fdf</tt> class (see below). The
|
68
|
-
# initial guess of the parameters <tt>x</tt> is given by a {GSL::Vector}[link:
|
68
|
+
# initial guess of the parameters <tt>x</tt> is given by a {GSL::Vector}[link:vector_rdoc.html] object.
|
69
69
|
#
|
70
70
|
# ---
|
71
71
|
# * GSL::MultiFit::FdfSolver#name
|
@@ -83,16 +83,16 @@
|
|
83
83
|
#
|
84
84
|
# Access to the members (see <tt>gsl_multifit_nlin.h</tt>)
|
85
85
|
#
|
86
|
-
# ==
|
87
|
-
# ===
|
86
|
+
# == Providing the function to be minimized
|
87
|
+
# === Function_fdf class
|
88
88
|
# ---
|
89
89
|
# * GSL::MultiFit::Function_fdf.alloc()
|
90
90
|
# * GSL::MultiFit::Function_fdf.alloc(f, df, p)
|
91
91
|
# * GSL::MultiFit::Function_fdf.alloc(f, df, fdf, p)
|
92
92
|
#
|
93
93
|
# Constructor for the <tt>Function_fdf</tt> class, to a
|
94
|
-
# function with <tt>p</tt> parameters, The first two or three arguments are Ruby Proc objects
|
95
|
-
# to evaluate the function to minimize and its derivative (Jacobian).
|
94
|
+
# function with <tt>p</tt> parameters, The first two or three arguments are Ruby Proc objects
|
95
|
+
# to evaluate the function to minimize and its derivative (Jacobian).
|
96
96
|
#
|
97
97
|
# ---
|
98
98
|
# * GSL::MultiFit::Function_fdf#set_procs(f, df, p)
|
@@ -106,24 +106,24 @@
|
|
106
106
|
# * GSL::MultiFit::Function_fdf#set_data(t, y, sigma)
|
107
107
|
#
|
108
108
|
# This sets the data <tt>t, y, sigma</tt> of length <tt>n</tt>, to the function <tt>self</tt>.
|
109
|
-
#
|
110
|
-
# ==
|
109
|
+
#
|
110
|
+
# == Iteration
|
111
111
|
# ---
|
112
112
|
# * GSL::MultiFit::FdfSolver#iterate
|
113
113
|
#
|
114
|
-
# THis performs a single iteration of the solver <tt>self</tt>. If the iteration
|
115
|
-
# encounters an unexpected problem then an error code will be returned.
|
116
|
-
# The solver maintains a current estimate of the best-fit parameters at all
|
114
|
+
# THis performs a single iteration of the solver <tt>self</tt>. If the iteration
|
115
|
+
# encounters an unexpected problem then an error code will be returned.
|
116
|
+
# The solver maintains a current estimate of the best-fit parameters at all
|
117
117
|
# times. This information can be accessed with the method <tt>position</tt>.
|
118
118
|
#
|
119
119
|
# ---
|
120
120
|
# * GSL::MultiFit::FdfSolver#position
|
121
121
|
#
|
122
|
-
# This returns the current position (i.e. best-fit parameters) of the solver
|
122
|
+
# This returns the current position (i.e. best-fit parameters) of the solver
|
123
123
|
# <tt>self</tt>, as a <tt>GSL::Vector</tt> object.
|
124
124
|
#
|
125
125
|
#
|
126
|
-
# ==
|
126
|
+
# == Search Stopping Parameters
|
127
127
|
# A minimization procedure should stop when one of the following conditions is true:
|
128
128
|
# * A minimum has been found to within the user-specified precision.
|
129
129
|
# * A user-specified maximum number of iterations has been reached.
|
@@ -134,9 +134,9 @@
|
|
134
134
|
# ---
|
135
135
|
# * GSL::MultiFit::FdfSolver#test_delta(epsabs, epsrel)
|
136
136
|
#
|
137
|
-
# This method tests for the convergence of the sequence by comparing the last
|
138
|
-
# step with the absolute error <tt>epsabs</tt> and relative error (<tt>epsrel</tt>
|
139
|
-
# to the current position. The test returns <tt>GSL::SUCCESS</tt> if the following
|
137
|
+
# This method tests for the convergence of the sequence by comparing the last
|
138
|
+
# step with the absolute error <tt>epsabs</tt> and relative error (<tt>epsrel</tt>
|
139
|
+
# to the current position. The test returns <tt>GSL::SUCCESS</tt> if the following
|
140
140
|
# condition is achieved,
|
141
141
|
# |dx_i| < epsabs + epsrel |x_i|
|
142
142
|
# for each component of <tt>x</tt> and returns <tt>GSL::CONTINUE</tt> otherwise.
|
@@ -145,19 +145,19 @@
|
|
145
145
|
# * GSL::MultiFit::FdfSolver#test_gradient(g, epsabs)
|
146
146
|
# * GSL::MultiFit::FdfSolver#test_gradient(epsabs)
|
147
147
|
#
|
148
|
-
# This function tests the residual gradient <tt>g</tt> against the absolute error
|
149
|
-
# bound <tt>epsabs</tt>. If <tt>g</tt> is not given, it is calculated internally.
|
150
|
-
# Mathematically, the gradient should be exactly zero at the minimum.
|
148
|
+
# This function tests the residual gradient <tt>g</tt> against the absolute error
|
149
|
+
# bound <tt>epsabs</tt>. If <tt>g</tt> is not given, it is calculated internally.
|
150
|
+
# Mathematically, the gradient should be exactly zero at the minimum.
|
151
151
|
# The test returns <tt>GSL::SUCCESS</tt> if the following condition is achieved,
|
152
152
|
# \sum_i |g_i| < epsabs
|
153
|
-
# and returns <tt>GSL::CONTINUE</tt> otherwise. This criterion is suitable for
|
154
|
-
# situations where the precise location of the minimum, x, is unimportant provided
|
153
|
+
# and returns <tt>GSL::CONTINUE</tt> otherwise. This criterion is suitable for
|
154
|
+
# situations where the precise location of the minimum, x, is unimportant provided
|
155
155
|
# a value can be found where the gradient is small enough.
|
156
156
|
#
|
157
157
|
# ---
|
158
158
|
# * GSL::MultiFit::FdfSolver#gradient
|
159
159
|
#
|
160
|
-
# This method returns the gradient g of \Phi(x) = (1/2) ||F(x)||^2 from the
|
160
|
+
# This method returns the gradient g of \Phi(x) = (1/2) ||F(x)||^2 from the
|
161
161
|
# Jacobian matrix and the function values, using the formula g = J^T f.
|
162
162
|
#
|
163
163
|
# ---
|
@@ -170,71 +170,71 @@
|
|
170
170
|
# Singleton methods of the <tt>GSL::MultiFit</tt> module.
|
171
171
|
#
|
172
172
|
#
|
173
|
-
# ==
|
173
|
+
# == Computing the covariance matrix of best fit parameters
|
174
174
|
# ---
|
175
175
|
# * GSL::MultiFit.covar(J, epsrel)
|
176
176
|
# * GSL::MultiFit.covar(J, epsrel, covar)
|
177
177
|
#
|
178
|
-
# This method uses the Jacobian matrix <tt>J</tt> to compute the covariance
|
178
|
+
# This method uses the Jacobian matrix <tt>J</tt> to compute the covariance
|
179
179
|
# matrix of the best-fit parameters. If an existing matrix <tt>covar</tt> is given,
|
180
|
-
# it is overwritten, and if not, this method returns a new matrix.
|
181
|
-
# The parameter <tt>epsrel</tt> is used to remove linear-dependent columns when
|
180
|
+
# it is overwritten, and if not, this method returns a new matrix.
|
181
|
+
# The parameter <tt>epsrel</tt> is used to remove linear-dependent columns when
|
182
182
|
# <tt>J</tt> is rank deficient.
|
183
183
|
#
|
184
184
|
# The covariance matrix is given by,
|
185
185
|
# covar = (J^T J)^{-1}
|
186
|
-
# and is computed by QR decomposition of <tt>J</tt> with column-pivoting.
|
186
|
+
# and is computed by QR decomposition of <tt>J</tt> with column-pivoting.
|
187
187
|
# Any columns of R which satisfy
|
188
188
|
# |R_{kk}| <= epsrel |R_{11}|
|
189
|
-
# are considered linearly-dependent and are excluded from the covariance matrix
|
189
|
+
# are considered linearly-dependent and are excluded from the covariance matrix
|
190
190
|
# (the corresponding rows and columns of the covariance matrix are set to zero).
|
191
191
|
#
|
192
|
-
# ==
|
192
|
+
# == Higher level interfaces
|
193
193
|
# ---
|
194
194
|
# * GSL::MultiFit::FdfSolver.fit(x, y, type[, guess])
|
195
195
|
# * GSL::MultiFit::FdfSolver.fit(x, w, y, type[, guess])
|
196
196
|
#
|
197
197
|
# This method uses <tt>FdfSolver</tt> with the LMSDER algorithm to fit the data
|
198
|
-
# <tt>[x, y]</tt> to a function of type <tt>type</tt>. The returned value is
|
198
|
+
# <tt>[x, y]</tt> to a function of type <tt>type</tt>. The returned value is
|
199
199
|
# an array of 4 elements, <tt>[coef, err, chisq, dof]</tt>,
|
200
200
|
# where <tt>coef</tt> is an array of the fitting coefficients, <tt>err</tt> contains
|
201
|
-
# errors in estimating <tt>coef</tt>, <tt>chisq</tt> is the
|
202
|
-
# chi-squared, and <tt>dof</tt> is the degree-of-freedom in the fitting
|
201
|
+
# errors in estimating <tt>coef</tt>, <tt>chisq</tt> is the
|
202
|
+
# chi-squared, and <tt>dof</tt> is the degree-of-freedom in the fitting
|
203
203
|
# which equals to (data length - number of fitting coefficients). The optional
|
204
204
|
# argument <tt>guess</tt> is an array of initial guess of the coefficients.
|
205
205
|
# The fitting type <tt>type</tt> is given by a <tt>String</tt> as follows.
|
206
|
-
# * <tt>"gaussian"</tt>: Gaussian fit,
|
206
|
+
# * <tt>"gaussian"</tt>: Gaussian fit,
|
207
207
|
# <tt>y = y0 + A exp(-(x-x0)^2/2/var)</tt>, <tt>coef = [y0, A, x0, var]</tt>
|
208
208
|
# * <tt>"gaussian_2peaks"</tt>: 2-peak Gaussian fit,
|
209
209
|
# <tt>y = y0 + A1 exp(-(x-x1)^2/2/var1) + A2 exp(-(x-x2)^2/2/var2)</tt>, <tt>coef = [y0, A1, x1, var1, A2, x2, var2]</tt>
|
210
|
-
# * <tt>"exp"</tt>: Exponential fit,
|
210
|
+
# * <tt>"exp"</tt>: Exponential fit,
|
211
211
|
# <tt>y = y0 + A exp(-b x)</tt>, <tt>coef = [y0, A, b]</tt>
|
212
|
-
# * <tt>"dblexp"</tt>: Double exponential fit,
|
212
|
+
# * <tt>"dblexp"</tt>: Double exponential fit,
|
213
213
|
# <tt>y = y0 + A1 exp(-b1 x) + A2 exp(-b2 x)</tt>, <tt>coef = [y0, A1, b1, A2, b2]</tt>
|
214
|
-
# * <tt>"sin"</tt>: Sinusoidal fit,
|
214
|
+
# * <tt>"sin"</tt>: Sinusoidal fit,
|
215
215
|
# <tt>y = y0 + A sin(f x + phi)</tt>, <tt>coef = [y0, A, f, phi]</tt>
|
216
|
-
# * <tt>"lor"</tt>: Lorentzian peak fit,
|
216
|
+
# * <tt>"lor"</tt>: Lorentzian peak fit,
|
217
217
|
# <tt>y = y0 + A/((x-x0)^2 + B)</tt>, <tt>coef = [y0, A, x0, B]</tt>
|
218
|
-
# * <tt>"hill"</tt>: Hill's equation fit,
|
218
|
+
# * <tt>"hill"</tt>: Hill's equation fit,
|
219
219
|
# <tt>y = y0 + (m - y0)/(1 + (xhalf/x)^r)</tt>, <tt>coef = [y0, n, xhalf, r]</tt>
|
220
|
-
# * <tt>"sigmoid"</tt>: Sigmoid (Fermi-Dirac) function fit,
|
220
|
+
# * <tt>"sigmoid"</tt>: Sigmoid (Fermi-Dirac) function fit,
|
221
221
|
# <tt>y = y0 + m/(1 + exp((x0-x)/r))</tt>, <tt>coef = [y0, m, x0, r]</tt>
|
222
|
-
# * <tt>"power"</tt>: Power-law fit,
|
222
|
+
# * <tt>"power"</tt>: Power-law fit,
|
223
223
|
# <tt>y = y0 + A x^r</tt>, <tt>coef = [y0, A, r]</tt>
|
224
|
-
# * <tt>"lognormal"</tt>: Lognormal peak fit,
|
224
|
+
# * <tt>"lognormal"</tt>: Lognormal peak fit,
|
225
225
|
# <tt>y = y0 + A exp[ -(log(x/x0)/width)^2 ]</tt>, <tt>coef = [y0, A, x0, width]</tt>
|
226
226
|
#
|
227
|
-
# See {Linear fitting}[link:
|
227
|
+
# See {Linear fitting}[link:fit_rdoc.html#label-Higer+level+interface] for linear and polynomical fittings.
|
228
228
|
#
|
229
|
-
# ==
|
230
|
-
# ===
|
229
|
+
# == Examples
|
230
|
+
# === Fitting to user-defined functions
|
231
231
|
#
|
232
|
-
# The following example program fits a weighted exponential model with background
|
233
|
-
# to experimental data, Y = A exp(-lambda t) + b. The first part of the program sets
|
234
|
-
# up the functions <tt>procf</tt> and <tt>procdf</tt> to calculate the model and its Jacobian.
|
232
|
+
# The following example program fits a weighted exponential model with background
|
233
|
+
# to experimental data, Y = A exp(-lambda t) + b. The first part of the program sets
|
234
|
+
# up the functions <tt>procf</tt> and <tt>procdf</tt> to calculate the model and its Jacobian.
|
235
235
|
# The appropriate fitting function is given by,
|
236
236
|
# f_i = ((A exp(-lambda t_i) + b) - y_i)/sigma_i
|
237
|
-
# where we have chosen t_i = i. The Jacobian matrix <tt>jac</tt> is the derivative of
|
237
|
+
# where we have chosen t_i = i. The Jacobian matrix <tt>jac</tt> is the derivative of
|
238
238
|
# these functions with respect to the three parameters (A, lambda, b). It is given by,
|
239
239
|
# J_{ij} = d f_i / d x_j
|
240
240
|
# where x_0 = A, x_1 = lambda and x_2 = b.
|
@@ -310,7 +310,7 @@
|
|
310
310
|
# printf("b = %.5f +/- %.5f\n", position[2], Math::sqrt(chi2/dof*covar[2][2]))
|
311
311
|
#
|
312
312
|
#
|
313
|
-
# ===
|
313
|
+
# === Fitting to built-in functions
|
314
314
|
# #!/usr/bin/env ruby
|
315
315
|
# require("gsl")
|
316
316
|
# include MultiFit
|
@@ -338,10 +338,10 @@
|
|
338
338
|
# graph(x, y, y0+amp*Sf::exp(-pow_2(Sf::log(x/x0)/w)))
|
339
339
|
#
|
340
340
|
#
|
341
|
-
# {prev}[link:
|
342
|
-
# {next}[link:
|
341
|
+
# {prev}[link:fit_rdoc.html]
|
342
|
+
# {next}[link:bspline_rdoc.html]
|
343
343
|
#
|
344
|
-
# {Reference index}[link:
|
344
|
+
# {Reference index}[link:ref_rdoc.html]
|
345
345
|
# {top}[link:index.html]
|
346
346
|
#
|
347
347
|
#
|
data/rdoc/ntuple.rdoc
CHANGED
@@ -1,28 +1,28 @@
|
|
1
1
|
#
|
2
2
|
# = N-tuples
|
3
|
-
# This chapter describes functions for creating and manipulating ntuples,
|
4
|
-
# sets of values associated with events. The ntuples are stored in files.
|
5
|
-
# Their values can be extracted in any combination and booked in a histogram using
|
3
|
+
# This chapter describes functions for creating and manipulating ntuples,
|
4
|
+
# sets of values associated with events. The ntuples are stored in files.
|
5
|
+
# Their values can be extracted in any combination and booked in a histogram using
|
6
6
|
# a selection function.
|
7
7
|
#
|
8
|
-
# The values to be stored are held in a {GSL::Vector}[link:
|
9
|
-
# a {GSL::Matrix}[link:
|
10
|
-
# and an ntuple is created associating this object with a file.
|
11
|
-
# The values are then written to the file (normally inside a loop) using
|
8
|
+
# The values to be stored are held in a {GSL::Vector}[link:vector_rdoc.html] or
|
9
|
+
# a {GSL::Matrix}[link:matrix_rdoc.html] object,
|
10
|
+
# and an ntuple is created associating this object with a file.
|
11
|
+
# The values are then written to the file (normally inside a loop) using
|
12
12
|
# the ntuple functions described below.
|
13
13
|
#
|
14
|
-
# A histogram can be created from ntuple data by providing a selection function
|
15
|
-
# and a value function. The selection function specifies whether an event should
|
16
|
-
# be included in the subset to be analyzed or not. The value function computes
|
14
|
+
# A histogram can be created from ntuple data by providing a selection function
|
15
|
+
# and a value function. The selection function specifies whether an event should
|
16
|
+
# be included in the subset to be analyzed or not. The value function computes
|
17
17
|
# the entry to be added to the histogram for each event.
|
18
18
|
#
|
19
|
-
# ==
|
19
|
+
# == The <tt>Ntuple</tt> class
|
20
20
|
# ---
|
21
21
|
# * GSL::Ntuple.create(filename, v)
|
22
22
|
# * GSL::Ntuple.alloc(filename, v)
|
23
23
|
#
|
24
|
-
# These create a new write-only ntuple file <tt>filename</tt> for ntuples.
|
25
|
-
# Any existing file with the same name is truncated to zero length and overwritten.
|
24
|
+
# These create a new write-only ntuple file <tt>filename</tt> for ntuples.
|
25
|
+
# Any existing file with the same name is truncated to zero length and overwritten.
|
26
26
|
# A preexisting <tt>Vector</tt> object <tt>v</tt> for the current ntuple data must be supplied:
|
27
27
|
# this is used to copy ntuples in and out of the file.
|
28
28
|
#
|
@@ -32,7 +32,7 @@
|
|
32
32
|
# This opens an existing ntuple file <tt>filename</tt> for reading. A preexisting
|
33
33
|
# <tt>Vector</tt> object <tt>v</tt> for the current ntuple data must be supplied.
|
34
34
|
#
|
35
|
-
# ==
|
35
|
+
# == Writing and reading ntuples
|
36
36
|
# ---
|
37
37
|
# * GSL::Ntuple#write
|
38
38
|
# * GSL::Ntuple#bookdata
|
@@ -44,11 +44,11 @@
|
|
44
44
|
#
|
45
45
|
# This method reads the current row of the ntuple file.
|
46
46
|
#
|
47
|
-
# ==
|
48
|
-
# Once an ntuple has been created its contents can be histogrammed in various ways using
|
49
|
-
# the function gsl_ntuple_project. Two user-defined functions must be provided, a function
|
50
|
-
# to select events and a function to compute scalar values. The selection function and the
|
51
|
-
# value function both accept the ntuple row as a first argument and other parameters as a
|
47
|
+
# == Histogramming ntuple values
|
48
|
+
# Once an ntuple has been created its contents can be histogrammed in various ways using
|
49
|
+
# the function gsl_ntuple_project. Two user-defined functions must be provided, a function
|
50
|
+
# to select events and a function to compute scalar values. The selection function and the
|
51
|
+
# value function both accept the ntuple row as a first argument and other parameters as a
|
52
52
|
# second argument.
|
53
53
|
#
|
54
54
|
# ---
|
@@ -58,10 +58,10 @@
|
|
58
58
|
# * GSL::Ntuple::ValueFn.alloc(proc)
|
59
59
|
#
|
60
60
|
# Constructors for selection functions and value functions.
|
61
|
-
# The selection function shoud return a non-zero value for each ntuple row that
|
61
|
+
# The selection function shoud return a non-zero value for each ntuple row that
|
62
62
|
# is to be included in the histogram. The value function should return the value to
|
63
63
|
# be added to the histogram for the ntuple row.
|
64
|
-
#
|
64
|
+
#
|
65
65
|
# ---
|
66
66
|
# * GSL::Ntuple::SelectFn#set_params(params)
|
67
67
|
# * GSL::Ntuple::ValueFn#set_params(params)
|
@@ -71,18 +71,18 @@
|
|
71
71
|
# ---
|
72
72
|
# * GSL::Ntuple.project(h, n, valfn, selfn)
|
73
73
|
#
|
74
|
-
# These methods updates the histogram <tt>h</tt> from the ntuple <tt>n</tt> using
|
75
|
-
# the functions <tt>valfn</tt> and <tt>selfn</tt>. For each ntuple row where the selection
|
76
|
-
# function <tt>selen</tt> is non-zero the corresponding value of that row is computed
|
77
|
-
# using the function value_func<tt>valfn</tt> and added to the histogram <tt>h</tt>.
|
78
|
-
# Those ntuple rows where <tt>selfn</tt> returns zero are ignored. New entries are added
|
79
|
-
# to the histogram, so subsequent calls can be used to accumulate further data in the
|
74
|
+
# These methods updates the histogram <tt>h</tt> from the ntuple <tt>n</tt> using
|
75
|
+
# the functions <tt>valfn</tt> and <tt>selfn</tt>. For each ntuple row where the selection
|
76
|
+
# function <tt>selen</tt> is non-zero the corresponding value of that row is computed
|
77
|
+
# using the function value_func<tt>valfn</tt> and added to the histogram <tt>h</tt>.
|
78
|
+
# Those ntuple rows where <tt>selfn</tt> returns zero are ignored. New entries are added
|
79
|
+
# to the histogram, so subsequent calls can be used to accumulate further data in the
|
80
80
|
# same histogram.
|
81
81
|
#
|
82
|
-
# {prev}[link:
|
83
|
-
# {next}[link:
|
82
|
+
# {prev}[link:hist2d_rdoc.html]
|
83
|
+
# {next}[link:monte_rdoc.html]
|
84
84
|
#
|
85
|
-
# {Reference index}[link:
|
85
|
+
# {Reference index}[link:ref_rdoc.html]
|
86
86
|
# {top}[link:index.html]
|
87
87
|
#
|
88
88
|
#
|
data/rdoc/odeiv.rdoc
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
#
|
2
2
|
# = Ordinary Differential Equations
|
3
|
-
# This chapter describes functions for solving ordinary differential equation
|
4
|
-
# (ODE) initial value problems. The library provides a variety of low-level
|
5
|
-
# methods, such as Runge-Kutta and Bulirsch-Stoer routines, and higher-level
|
6
|
-
# components for adaptive step-size control. The components can be combined
|
7
|
-
# by the user to achieve the desired solution, with full access to any
|
8
|
-
# intermediate steps.
|
3
|
+
# This chapter describes functions for solving ordinary differential equation
|
4
|
+
# (ODE) initial value problems. The library provides a variety of low-level
|
5
|
+
# methods, such as Runge-Kutta and Bulirsch-Stoer routines, and higher-level
|
6
|
+
# components for adaptive step-size control. The components can be combined
|
7
|
+
# by the user to achieve the desired solution, with full access to any
|
8
|
+
# intermediate steps.
|
9
9
|
#
|
10
10
|
#
|
11
11
|
# Contents:
|
12
|
-
# 1. {Classes for ODE solver}[link:
|
13
|
-
# 1. {Class Descriptions}[link:
|
14
|
-
# 1. {GSL::Odeiv::System : Defining the ODE System}[link:
|
15
|
-
# 1. {GSL::Odeiv::Step : Stepping Algorithms}[link:
|
16
|
-
# 1. {GSL::Odeiv::Control : Adaptive Step-size Control}[link:
|
17
|
-
# 1. {GSL::Odeiv::Evolve : Evolution}[link:
|
18
|
-
# 1. {GSL::Odeiv::Solver : Higher level interface}[link:
|
19
|
-
# 1. {Examples}[link:
|
12
|
+
# 1. {Classes for ODE solver}[link:odeiv_rdoc.html#label-Classes+for+ODE+solver]
|
13
|
+
# 1. {Class Descriptions}[link:odeiv_rdoc.html#label-Class+Descriptions]
|
14
|
+
# 1. {GSL::Odeiv::System : Defining the ODE System}[link:odeiv_rdoc.html#label-System]
|
15
|
+
# 1. {GSL::Odeiv::Step : Stepping Algorithms}[link:odeiv_rdoc.html#label-Step]
|
16
|
+
# 1. {GSL::Odeiv::Control : Adaptive Step-size Control}[link:odeiv_rdoc.html#label-Control]
|
17
|
+
# 1. {GSL::Odeiv::Evolve : Evolution}[link:odeiv_rdoc.html#label-Evolve]
|
18
|
+
# 1. {GSL::Odeiv::Solver : Higher level interface}[link:odeiv_rdoc.html#label-Solver]
|
19
|
+
# 1. {Examples}[link:odeiv_rdoc.html#label-Example]
|
20
20
|
#
|
21
|
-
# ==
|
21
|
+
# == Classes for ODE solver
|
22
22
|
#
|
23
23
|
# ---
|
24
24
|
# * GSL::Odeiv::System
|
@@ -33,20 +33,20 @@
|
|
33
33
|
#
|
34
34
|
# Another higher-level interface to ODE system classes.
|
35
35
|
#
|
36
|
-
# ==
|
36
|
+
# == Class Descriptions
|
37
37
|
#
|
38
|
-
# ===
|
38
|
+
# === System
|
39
39
|
# ---
|
40
40
|
# * GSL::Odeiv::System.alloc(func, jac, dim)
|
41
41
|
# * GSL::Odeiv::System.alloc(func, dim)
|
42
42
|
#
|
43
43
|
# Constructor. This defines a general ODE system with the dimension <tt>dim</tt>.
|
44
|
-
#
|
44
|
+
#
|
45
45
|
# # t: variable (scalar)
|
46
46
|
# # y: vector
|
47
47
|
# # dydt: vector
|
48
48
|
# # params: scalar or an array
|
49
|
-
#
|
49
|
+
#
|
50
50
|
# func = Proc.new { |t, y, dydt, params|
|
51
51
|
# mu = params
|
52
52
|
# dydt[0] = y[1]
|
@@ -66,12 +66,12 @@
|
|
66
66
|
# dfdy.set(1, 1, -mu*(y[0]*y[0] - 1.0))
|
67
67
|
# dfdt[0] = 0.0
|
68
68
|
# dfdt[1] = 0.0
|
69
|
-
# }
|
69
|
+
# }
|
70
70
|
#
|
71
71
|
# sys = GSL:Odeiv::System.alloc(func, jac, dim) # for "BSIMP" algorithm
|
72
72
|
#
|
73
|
-
# Note that some of the simpler solver algorithms do not make use of the
|
74
|
-
# Jacobian matrix, so it is not always strictly necessary to provide it.
|
73
|
+
# Note that some of the simpler solver algorithms do not make use of the
|
74
|
+
# Jacobian matrix, so it is not always strictly necessary to provide it.
|
75
75
|
# Thus the constructor is as
|
76
76
|
# sys = GSL:Odeiv::System.alloc(func, nil, dim) # for others, replaced by nil
|
77
77
|
# sys = GSL:Odeiv::System.alloc(func, dim) # or omit
|
@@ -99,14 +99,14 @@
|
|
99
99
|
# * GSL::Odeiv::System#dim
|
100
100
|
#
|
101
101
|
#
|
102
|
-
# ===
|
102
|
+
# === Step
|
103
103
|
# The lowest level components are the stepping functions which advance a solution from time <tt>t</tt> to <tt>t+h</tt> for a fixed step-size <tt>h</tt> and estimate the resulting local error.
|
104
104
|
#
|
105
105
|
# ---
|
106
106
|
# * GSL::Odeiv::Step.alloc(T, dim)
|
107
107
|
#
|
108
|
-
# Constructor for a stepping function of an algorithm type <tt>T</tt> for a system of
|
109
|
-
# dimension <tt>dim</tt>. The algorithms are specified by one of the constants under the
|
108
|
+
# Constructor for a stepping function of an algorithm type <tt>T</tt> for a system of
|
109
|
+
# dimension <tt>dim</tt>. The algorithms are specified by one of the constants under the
|
110
110
|
# <tt>GSL::Odeiv::Step</tt> class, as
|
111
111
|
#
|
112
112
|
# 1. <tt>GSL::Odeiv::Step::RK2</tt>, Embedded 2nd order Runge-Kutta with 3rd order error estimate.
|
@@ -121,7 +121,7 @@
|
|
121
121
|
# 1. <tt>GSL::Odeiv::Step::GEAR2</tt>, M=2 implicit Gear method
|
122
122
|
# 1. <tt>GSL::Odeiv::Step::RK2SIMP</tt> (GSL-1.6)
|
123
123
|
#
|
124
|
-
# * Ex:
|
124
|
+
# * Ex:
|
125
125
|
# step = Odeiv::Step.alloc(Odeiv::Step::RKF45, 2)
|
126
126
|
#
|
127
127
|
# The algorithm types can also be given by a String, same as the C struct name,
|
@@ -138,14 +138,14 @@
|
|
138
138
|
# 1. "<tt>gear2</tt>" or "<tt>gsl_odeiv_step_gear2</tt>"
|
139
139
|
# 1. "<tt>rk2simp</tt>" or "<tt>gsl_odeiv_step_rk2simp</tt>" (GSL-1.6)
|
140
140
|
#
|
141
|
-
# * Ex:
|
141
|
+
# * Ex:
|
142
142
|
# step = Odeiv::Step.alloc("bsimp", 4)
|
143
143
|
# step2 = Odeiv::Step.alloc("gsl_odeiv_step_rkck", 3)
|
144
144
|
#
|
145
145
|
# ---
|
146
146
|
# * GSL::Odeiv::Step#reset
|
147
147
|
#
|
148
|
-
# This method resets the stepper. It should be used whenever the next use
|
148
|
+
# This method resets the stepper. It should be used whenever the next use
|
149
149
|
# of s will not be a continuation of a previous step.
|
150
150
|
#
|
151
151
|
# ---
|
@@ -163,7 +163,7 @@
|
|
163
163
|
# ---
|
164
164
|
# * GSL::Odeiv::Step#order
|
165
165
|
#
|
166
|
-
# Returns the order of the stepper on the previous step.
|
166
|
+
# Returns the order of the stepper on the previous step.
|
167
167
|
# This order can vary if the stepper itself is adaptive.
|
168
168
|
#
|
169
169
|
# ---
|
@@ -171,86 +171,86 @@
|
|
171
171
|
# * GSL::Odeiv::Step#apply(t, h, y, yerr, dydt_in, sys)
|
172
172
|
# * GSL::Odeiv::Step#apply(t, h, y, yerr, sys)
|
173
173
|
#
|
174
|
-
# This method applies the stepper to the system of equations defined by
|
175
|
-
# <tt>dydt</tt>, using the step size <tt>h</tt> to advance the system from time
|
176
|
-
# <tt>t</tt> and state <tt>y</tt> to time <tt>t+h</tt>. The new state of the system
|
177
|
-
# is stored in <tt>y</tt> on output, with an estimate of the absolute error in
|
178
|
-
# each component stored in <tt>yerr</tt>. If the argument <tt>dydt_in</tt> is not
|
179
|
-
# <tt>nil</tt> it should be a {GSL::Vector}[link:
|
180
|
-
# containing the derivatives for the system at time <tt>t</tt> on input.
|
181
|
-
# This is optional as the derivatives will be computed internally if they
|
182
|
-
# are not provided, but allows the reuse of existing derivative information.
|
183
|
-
# On output the new derivatives of the system at time <tt>t+h</tt> will be
|
174
|
+
# This method applies the stepper to the system of equations defined by
|
175
|
+
# <tt>dydt</tt>, using the step size <tt>h</tt> to advance the system from time
|
176
|
+
# <tt>t</tt> and state <tt>y</tt> to time <tt>t+h</tt>. The new state of the system
|
177
|
+
# is stored in <tt>y</tt> on output, with an estimate of the absolute error in
|
178
|
+
# each component stored in <tt>yerr</tt>. If the argument <tt>dydt_in</tt> is not
|
179
|
+
# <tt>nil</tt> it should be a {GSL::Vector}[link:vector_rdoc.html] object
|
180
|
+
# containing the derivatives for the system at time <tt>t</tt> on input.
|
181
|
+
# This is optional as the derivatives will be computed internally if they
|
182
|
+
# are not provided, but allows the reuse of existing derivative information.
|
183
|
+
# On output the new derivatives of the system at time <tt>t+h</tt> will be
|
184
184
|
# stored in <tt>dydt_out</tt> if it is not nil.
|
185
185
|
#
|
186
|
-
# ===
|
186
|
+
# === Control
|
187
187
|
# ---
|
188
188
|
# * GSL::Odeiv::Control.standard_new(epsabs, epsrel, a_y, a_dydt)
|
189
189
|
# * GSL::Odeiv::Control.alloc(epsabs, epsrel, a_y, a_dydt)
|
190
190
|
#
|
191
|
-
# The standard control object is a four parameter heuristic based on
|
192
|
-
# absolute and relative errors <tt>epsabs</tt> and <tt>epsrel</tt>, and
|
193
|
-
# scaling factors <tt>a_y</tt> and <tt>a_dydt</tt> for the system state
|
191
|
+
# The standard control object is a four parameter heuristic based on
|
192
|
+
# absolute and relative errors <tt>epsabs</tt> and <tt>epsrel</tt>, and
|
193
|
+
# scaling factors <tt>a_y</tt> and <tt>a_dydt</tt> for the system state
|
194
194
|
# <tt>y(t)</tt> and derivatives <tt>y'(t)</tt> respectively.
|
195
195
|
#
|
196
196
|
# ---
|
197
197
|
# * GSL::Odeiv::Control.y_new(epsabs, epsrel)
|
198
198
|
#
|
199
|
-
# This method creates a new control object which will keep the local error
|
200
|
-
# on each step within an absolute error of <tt>epsabs</tt> and relative error
|
201
|
-
# of <tt>epsrel</tt> with respect to the solution <tt>y_i(t)</tt>.
|
202
|
-
# This is equivalent to the standard control object with <tt>a_y=1</tt>
|
199
|
+
# This method creates a new control object which will keep the local error
|
200
|
+
# on each step within an absolute error of <tt>epsabs</tt> and relative error
|
201
|
+
# of <tt>epsrel</tt> with respect to the solution <tt>y_i(t)</tt>.
|
202
|
+
# This is equivalent to the standard control object with <tt>a_y=1</tt>
|
203
203
|
# and <tt>a_dydt=0</tt>.
|
204
204
|
#
|
205
205
|
# ---
|
206
206
|
# * GSL::Odeiv::Control.yp_new(epsabs, epsrel)
|
207
207
|
#
|
208
|
-
# This method creates a new control object which will keep the local
|
209
|
-
# error on each step within an absolute error of <tt>epsabs</tt> and
|
210
|
-
# relative error of <tt>epsrel</tt> with respect to the derivatives of the
|
211
|
-
# solution <tt>y'_i(t)</tt>.
|
212
|
-
# This is equivalent to the standard control object with <tt>a_y=0</tt>
|
208
|
+
# This method creates a new control object which will keep the local
|
209
|
+
# error on each step within an absolute error of <tt>epsabs</tt> and
|
210
|
+
# relative error of <tt>epsrel</tt> with respect to the derivatives of the
|
211
|
+
# solution <tt>y'_i(t)</tt>.
|
212
|
+
# This is equivalent to the standard control object with <tt>a_y=0</tt>
|
213
213
|
# and <tt>a_dydt=1</tt>.
|
214
214
|
#
|
215
215
|
# ---
|
216
216
|
# * GSL::Odeiv::Control.alloc(epsabs, epsrel, a_y, a_dydt, vscale, dim)
|
217
217
|
#
|
218
|
-
# This creates a new control object which uses the same algorithm as
|
219
|
-
# <tt>GSL::Odeiv::Control.standard_new</tt> but with an absolute error which
|
218
|
+
# This creates a new control object which uses the same algorithm as
|
219
|
+
# <tt>GSL::Odeiv::Control.standard_new</tt> but with an absolute error which
|
220
220
|
# is scaled for each component by the <tt>GSL::Vector</tt> object <tt>vscale</tt>.
|
221
221
|
#
|
222
222
|
# ---
|
223
223
|
# * GSL::Odeiv::Control#init(epsabs, epsrel, a_y, a_dydt)
|
224
224
|
#
|
225
|
-
# This method initializes the controler with the parameters <tt>epsabs</tt>
|
226
|
-
# (absolute error), <tt>epsrel</tt> (relative error), <tt>a_y</tt>
|
225
|
+
# This method initializes the controler with the parameters <tt>epsabs</tt>
|
226
|
+
# (absolute error), <tt>epsrel</tt> (relative error), <tt>a_y</tt>
|
227
227
|
# (scaling factor for y) and <tt>a_dydt</tt> (scaling factor for derivatives).
|
228
228
|
#
|
229
229
|
# ---
|
230
230
|
# * GSL::Odeiv::Control#name
|
231
231
|
# * GSL::Odeiv::Control#hadjust(step, y0, yerr, dydt, h)
|
232
232
|
#
|
233
|
-
# This method adjusts the step-size <tt>h</tt> using the control function
|
234
|
-
# object, and the current values of <tt>y</tt>, <tt>yerr</tt> and <tt>dydt</tt>.
|
235
|
-
# The stepping function <tt>step</tt> is also needed to determine the order
|
233
|
+
# This method adjusts the step-size <tt>h</tt> using the control function
|
234
|
+
# object, and the current values of <tt>y</tt>, <tt>yerr</tt> and <tt>dydt</tt>.
|
235
|
+
# The stepping function <tt>step</tt> is also needed to determine the order
|
236
236
|
# of the method. On output, an array of two elements [<tt>hadj, status</tt>]
|
237
|
-
# is returned: If the error in the y-values <tt>yerr</tt> is found to be
|
238
|
-
# too large then the step-size <tt>h</tt> is reduced and the method returns
|
239
|
-
# [<tt>hadj, status</tt>=<tt>GSL::ODEIV::HADJ_DEC</tt>].
|
240
|
-
# If the error is sufficiently small then
|
241
|
-
# <tt>h</tt> may be increased and [<tt>hadj, status</tt>=<tt>GSL::ODEIV::HADJ_INC</tt>]
|
242
|
-
# is returned.
|
243
|
-
# The method returns [<tt>hadj, status</tt>=<tt>GSL::ODEIV::HADJ_NIL</tt>] if the step-size is
|
244
|
-
# unchanged. The goal of the method is to estimate the largest step-size
|
245
|
-
# which satisfies the user-specified accuracy requirements for the current
|
237
|
+
# is returned: If the error in the y-values <tt>yerr</tt> is found to be
|
238
|
+
# too large then the step-size <tt>h</tt> is reduced and the method returns
|
239
|
+
# [<tt>hadj, status</tt>=<tt>GSL::ODEIV::HADJ_DEC</tt>].
|
240
|
+
# If the error is sufficiently small then
|
241
|
+
# <tt>h</tt> may be increased and [<tt>hadj, status</tt>=<tt>GSL::ODEIV::HADJ_INC</tt>]
|
242
|
+
# is returned.
|
243
|
+
# The method returns [<tt>hadj, status</tt>=<tt>GSL::ODEIV::HADJ_NIL</tt>] if the step-size is
|
244
|
+
# unchanged. The goal of the method is to estimate the largest step-size
|
245
|
+
# which satisfies the user-specified accuracy requirements for the current
|
246
246
|
# point.
|
247
247
|
#
|
248
|
-
# ===
|
249
|
-
# The higher level of the system is the <tt>GSL::Evolve</tt> class which combines the
|
250
|
-
# results of a stepper and controler to reliably advance the solution forward
|
251
|
-
# over an interval <tt>(t_0, t_1)</tt>. If the controler signals that the step-size
|
252
|
-
# should be decreased the <tt>GSL::Evolve</tt> object backs out of the current step and
|
253
|
-
# tries the proposed smaller step-size. This process is continued until an
|
248
|
+
# === Evolve
|
249
|
+
# The higher level of the system is the <tt>GSL::Evolve</tt> class which combines the
|
250
|
+
# results of a stepper and controler to reliably advance the solution forward
|
251
|
+
# over an interval <tt>(t_0, t_1)</tt>. If the controler signals that the step-size
|
252
|
+
# should be decreased the <tt>GSL::Evolve</tt> object backs out of the current step and
|
253
|
+
# tries the proposed smaller step-size. This process is continued until an
|
254
254
|
# acceptable step-size is found.
|
255
255
|
#
|
256
256
|
# ---
|
@@ -261,28 +261,28 @@
|
|
261
261
|
# ---
|
262
262
|
# * GSL::Odeiv::Evolve#reset
|
263
263
|
#
|
264
|
-
# This method resets the GSL::Evolve object. It should be used whenever
|
264
|
+
# This method resets the GSL::Evolve object. It should be used whenever
|
265
265
|
# the next use of e will not be a continuation of a previous step.
|
266
266
|
#
|
267
267
|
# ---
|
268
268
|
# * GSL::Odeiv::Evolve#apply(evolve, control, step, sys, t, t1, h, y)
|
269
269
|
#
|
270
|
-
# This method advances the system <tt>sys</tt> from time <tt>t</tt> and position
|
271
|
-
# <tt>y</tt> using the stepping function <tt>step</tt>. The initial step-size is
|
272
|
-
# taken as <tt>h</tt>. The maximum time <tt>t1</tt> is guaranteed not to be exceeded by
|
270
|
+
# This method advances the system <tt>sys</tt> from time <tt>t</tt> and position
|
271
|
+
# <tt>y</tt> using the stepping function <tt>step</tt>. The initial step-size is
|
272
|
+
# taken as <tt>h</tt>. The maximum time <tt>t1</tt> is guaranteed not to be exceeded by
|
273
273
|
# the time-step. On output, an array of three elements is returned,
|
274
|
-
# [<tt>tnext, hnext, status</tt>], where <tt>tnext</tt> is the time advanced,
|
274
|
+
# [<tt>tnext, hnext, status</tt>], where <tt>tnext</tt> is the time advanced,
|
275
275
|
# <tt>hnext</tt> is the step-size
|
276
276
|
# for the next step, and <tt>status</tt> is an error code retunred by <tt>gsl_odeiv_evolve_apply()</tt> function.
|
277
|
-
# On the final time-step the value of <tt>tnext</tt> will be set to
|
277
|
+
# On the final time-step the value of <tt>tnext</tt> will be set to
|
278
278
|
# <tt>t1</tt> exactly.
|
279
279
|
#
|
280
280
|
# ---
|
281
281
|
# * GSL::Odeiv::Evolve#count
|
282
282
|
#
|
283
283
|
#
|
284
|
-
# ===
|
285
|
-
# This is the highest level interface to solve ODE system,
|
284
|
+
# === Solver
|
285
|
+
# This is the highest level interface to solve ODE system,
|
286
286
|
# which contains System, Step, Control, and Evolve classes.
|
287
287
|
#
|
288
288
|
# ---
|
@@ -329,10 +329,10 @@
|
|
329
329
|
#
|
330
330
|
# This method advances the system from time <tt>t</tt> and position <tt>y</tt> (<tt>GSL::Vector</tt> object) using the stepping function. On output, the new time and position are returned as an array [<tt>tnext, hnext, status</tt>], i.e. <tt>t, y</tt> themselves are not modified by this method. The maximum time <tt>t1</tt> is guaranteed not to be exceeded by the time-step. On the final time-step the value of <tt>tnext</tt> will be set to <tt>t1</tt> exactly.
|
331
331
|
#
|
332
|
-
# ==
|
332
|
+
# == Example
|
333
333
|
#
|
334
334
|
# The following program solves the second-order nonlinear Van der Pol oscillator equation,
|
335
|
-
# as found in the GSL manual, x"(t) + \mu x'(t) (x(t)^2 - 1) + x(t) = 0,
|
335
|
+
# as found in the GSL manual, x"(t) + \mu x'(t) (x(t)^2 - 1) + x(t) = 0,
|
336
336
|
#
|
337
337
|
# This can be converted into a first order system suitable for use with the routines described in this chapter by introducing a separate variable for the velocity, y = x'(t),
|
338
338
|
#
|
@@ -369,10 +369,10 @@
|
|
369
369
|
# end
|
370
370
|
#
|
371
371
|
#
|
372
|
-
# {prev}[link:
|
373
|
-
# {next}[link:
|
372
|
+
# {prev}[link:siman_rdoc.html]
|
373
|
+
# {next}[link:interp_rdoc.html]
|
374
374
|
#
|
375
|
-
# {Reference index}[link:
|
375
|
+
# {Reference index}[link:ref_rdoc.html]
|
376
376
|
# {top}[link:index.html]
|
377
377
|
#
|
378
378
|
#
|