module GSL
Extended Modules
Defined in:
gsl.crgsl/base/error.cr
gsl/base/function.cr
gsl/base/functions.cr
gsl/base/histogram.cr
gsl/base/iterator.cr
gsl/base/libgsl.cr
gsl/base/matrix.cr
gsl/base/object.cr
gsl/base/permutation.cr
gsl/base/result.cr
gsl/base/rng.cr
gsl/base/sparse_matrix.cr
gsl/base/vector.cr
gsl/maths/analysis/diff.cr
gsl/maths/approximation/bspline.cr
gsl/maths/approximation/chebyshev.cr
gsl/maths/approximation/interpolation.cr
gsl/maths/basic/matrix.cr
gsl/maths/basic/poly.cr
gsl/maths/basic/sparse_matrix.cr
gsl/maths/basic/vector.cr
gsl/maths/optimization/fit.cr
gsl/maths/statistics/correlation.cr
gsl/maths/statistics/vector.cr
gsl/version.cr
Constant Summary
-
RNG =
LibGSL.gsl_rng_alloc(LibGSL.gsl_rng_env_setup)
-
VERSION =
"0.2.0"
Class Method Summary
-
.diff(function : GSL::Function, x : Float64, step : Float64 = 0.01, dir : Diff::Direction = Diff::Direction::Central)
This function implements Numerical Differentiation
-
.diff(x : Float64, step : Float64 = 0.01, dir : Diff::Direction = Diff::Direction::Central, &f : GSL::Function)
This function implements Numerical Differentiation
- .linreg(x, y, weight = nil, no_const : Bool = false)
-
.wrap_function(function : Function)
wraps user supplied function (can be closured) to the
LibGSL::Gsl_Function
structure. -
.wrap_function(&function : MultiRootFunctionFDF)
wraps user supplied function (can be closured) to the
LibGSL::Gsl_multiroot_function_fdf
structure. -
.wrap_function(function : FunctionFDF)
wraps user supplied function (can be closured) to the
LibGSL::Gsl_function_fdf
structure. -
.wrap_function(function : MultiRootFunction)
wraps user supplied function (can be closured) to the
LibGSL::Gsl_multiroot_function
structure. -
.wrap_function(function : MultiRootFunctionFDF)
wraps user supplied function (can be closured) to the
LibGSL::Gsl_multiroot_function_fdf
structure. -
.wrap_function_monte(function : FunctionVS, dim)
wraps user supplied function (can be closured) to the
LibGSL::Gsl_monte_function
structure. -
.wrap_function_monte(dim, &function : FunctionVS)
wraps user supplied function (can be closured) to the
LibGSL::Gsl_monte_function
structure. -
.wrap_rng(random : Random) : LibGSL::Gsl_rng
Wraps Crystal
Random
rng toGsl_rng
structure.
Class Method Detail
This function implements Numerical Differentiation
This is a variant of method where function is passed as pointer
Usage example:
f = ->(x : Float64) { Math.log(x) }
result, eps = GSL.diff(f, 4.0)
result.should be_close 0.25, 1e-9
Parameters:
function
- pointer to functionx
- point where differential is calculatedstep
- step of algorithm. Function values will be evaluated in a range(x-step .. x+step)
.dir
- algorithm. SeeDiff::Direction
and GSL docs for details
This function implements Numerical Differentiation
This is a variant of method where function is passed as a block
Usage example:
result, eps = GSL.diff(0.25) { |x| Math.log(x) }
result.should be_close 4.0, 1e-9
Parameters:
function
- pointer to functionx
- point where differential is calculatedstep
- step of algorithm. Function values will be evaluated in a range(x-step .. x+step)
.dir
- algorithm. SeeDiff::Direction
and GSL docs for details
wraps user supplied function (can be closured) to the LibGSL::Gsl_Function
structure. Used internally in high-level wrappers.
Note that if you use it directly and pass resulting function to some C code, you have to keep reference somewhere so it won't be garbage collected. Usually, it's not a problem because reference will remain on stack. So
...
function = GSL.wrap_function(f)
LibGSL.gsl_root_fsolver_set(raw, pointerof(function), x_lower, x_upper)
max_iter.times do
LibGSL.gsl_root_fsolver_iterate(raw)
...
end
won't be a problem (reference is saved in local variable function
).
But
def init_solver(f)
...
function = GSL.wrap_function(f)
LibGSL.gsl_root_fsolver_set(raw, pointerof(function), x_lower, x_upper)
return raw
end
will cause a problem - local variable function
will be GC'd.
wraps user supplied function (can be closured) to the LibGSL::Gsl_multiroot_function_fdf
structure. Used internally in high-level wrappers.
wraps user supplied function (can be closured) to the LibGSL::Gsl_function_fdf
structure. Used internally in high-level wrappers.
wraps user supplied function (can be closured) to the LibGSL::Gsl_multiroot_function
structure. Used internally in high-level wrappers.
wraps user supplied function (can be closured) to the LibGSL::Gsl_multiroot_function_fdf
structure. Used internally in high-level wrappers.
wraps user supplied function (can be closured) to the LibGSL::Gsl_monte_function
structure. Used internally in high-level wrappers.
wraps user supplied function (can be closured) to the LibGSL::Gsl_monte_function
structure. Used internally in high-level wrappers.
Wraps Crystal Random
rng to Gsl_rng
structure. Used internally in high-level wrappers.