Skip to content

Commit

Permalink
Apply changes from issue #51 for precompilations and warnings
Browse files Browse the repository at this point in the history
This commit applies the updates from issue #51 provided by @yuyichao for enabling pre-compilation and removing warnings for method redefinition, but makes all code changes to non-underscored files.  The original order of loading files within __FILELIST.jl and GSL.jl is maintained by making edits to the include commands within __FILELIST.jl and removing entries from GSL.jl.  Tests of pre-compilation and execution of runtests.jl were performed for Julia 0.4.3 and the current Julia 0.5.0-dev nightly build.
  • Loading branch information
AndyGreenwell committed Feb 22, 2016
1 parent a0bcbe8 commit e4c7431
Show file tree
Hide file tree
Showing 19 changed files with 1,049 additions and 119 deletions.
7 changes: 3 additions & 4 deletions src/28_1_NumericalDifferentiationfunctions.jl
Expand Up @@ -14,16 +14,15 @@ function function_callback(x::Cdouble, f_)
f = unsafe_pointer_to_objref(f_)
Cdouble(f(x))
end
const function_callback_ptr = cfunction(function_callback, Cdouble, (Cdouble, Ptr{Void}))
const function_callback_ptr = Ref{Ptr{Void}}()

for gsl_deriv in (:deriv_central, :deriv_forward, :deriv_backward)
@eval begin
function ($gsl_deriv)(f::Function, x::Real, h::Real)
$gsl_deriv(
gsl_function(function_callback_ptr,
pointer_from_objref(f)),
gsl_function(function_callback_ptr[],
pointer_from_objref(f)),
x, h)
end
end
end

38 changes: 11 additions & 27 deletions src/34_5_Iteration.jl
Expand Up @@ -4,10 +4,10 @@
##################
# 34.5 Iteration #
##################
export min_fminimizer_iterate, min_fminimizer_iterate,
min_fminimizer_x_minimum, min_fminimizer_x_upper,
min_fminimizer_x_lower, min_fminimizer_f_minimum,
min_fminimizer_f_upper, min_fminimizer_f_lower
export min_fminimizer_iterate, min_fminimizer_x_minimum,
min_fminimizer_x_upper, min_fminimizer_x_lower,
min_fminimizer_f_minimum, min_fminimizer_f_upper,
min_fminimizer_f_lower


# This function performs a single iteration of the minimizer s. If the
Expand All @@ -16,7 +16,7 @@ export min_fminimizer_iterate, min_fminimizer_iterate,
# where the function evaluated to Inf or NaN. GSL_FAILUREthe
# algorithm could not improve the current best approximation or bounding
# interval.
#
#
# Returns: Cint
function min_fminimizer_iterate(s::Ptr{gsl_min_fminimizer})
errno = ccall( (:gsl_min_fminimizer_iterate, libgsl), Cint,
Expand All @@ -31,23 +31,7 @@ end

# This function returns the current estimate of the position of the minimum for
# the minimizer s.
#
# Returns: Cint
function min_fminimizer_iterate(s::Ptr{gsl_min_fminimizer})
s = Ref{gsl_min_fminimizer}()
errno = ccall( (:gsl_min_fminimizer_iterate, libgsl), Cint,
(Ref{gsl_min_fminimizer}, ), s )
gslerrno = gsl_errno(errno)
if gslerrno != SUCCESS && gslerrno != CONTINUE
throw(GSL_ERROR(errno))
end
return gslerrno
end


# This function returns the current estimate of the position of the minimum for
# the minimizer s.
#
#
# Returns: Cdouble
function min_fminimizer_x_minimum(s::Ptr{gsl_min_fminimizer})
ccall( (:gsl_min_fminimizer_x_minimum, libgsl), Cdouble,
Expand All @@ -57,7 +41,7 @@ end

# These functions return the current upper and lower bound of the interval for
# the minimizer s.
#
#
# Returns: Cdouble
function min_fminimizer_x_upper(s::Ptr{gsl_min_fminimizer})
ccall( (:gsl_min_fminimizer_x_upper, libgsl), Cdouble,
Expand All @@ -67,7 +51,7 @@ end

# These functions return the current upper and lower bound of the interval for
# the minimizer s.
#
#
# Returns: Cdouble
function min_fminimizer_x_lower(s::Ptr{gsl_min_fminimizer})
ccall( (:gsl_min_fminimizer_x_lower, libgsl), Cdouble,
Expand All @@ -78,7 +62,7 @@ end
# These functions return the value of the function at the current estimate of
# the minimum and at the upper and lower bounds of the interval for the
# minimizer s.
#
#
# Returns: Cdouble
function min_fminimizer_f_minimum(s::Ptr{gsl_min_fminimizer})
ccall( (:gsl_min_fminimizer_f_minimum, libgsl), Cdouble,
Expand All @@ -89,7 +73,7 @@ end
# These functions return the value of the function at the current estimate of
# the minimum and at the upper and lower bounds of the interval for the
# minimizer s.
#
#
# Returns: Cdouble
function min_fminimizer_f_upper(s::Ptr{gsl_min_fminimizer})
ccall( (:gsl_min_fminimizer_f_upper, libgsl), Cdouble,
Expand All @@ -100,7 +84,7 @@ end
# These functions return the value of the function at the current estimate of
# the minimum and at the upper and lower bounds of the interval for the
# minimizer s.
#
#
# Returns: Cdouble
function min_fminimizer_f_lower(s::Ptr{gsl_min_fminimizer})
ccall( (:gsl_min_fminimizer_f_lower, libgsl), Cdouble,
Expand Down
63 changes: 63 additions & 0 deletions src/41_1_Representation_of_floating_point_numbers.jl
@@ -0,0 +1,63 @@
#!/usr/bin/env julia
#GSL Julia wrapper
#(c) 2013 Jiahao Chen <jiahao@mit.edu>
#################################################
# 41.1 Representation of floating point numbers #
#################################################
export ieee_fprintf_float, ieee_fprintf_double,
ieee_printf_float, ieee_printf_double

# These functions output a formatted version of the IEEE floating-point number
# pointed to by x to the stream stream. A pointer is used to pass the number
# indirectly, to avoid any undesired promotion from float to double. The
# output takes one of the following forms, NaNthe Not-a-Number
# symbol Inf, -Infpositive or negative infinity
# 1.fffff...*2^E, -1.fffff...*2^Ea normalized floating point number
# 0.fffff...*2^E, -0.fffff...*2^Ea denormalized floating point number
# 0, -0positive or negative zero The output can be used directly
# in GNU Emacs Calc mode by preceding it with 2# to indicate binary.
#
# Returns: Void
function ieee_fprintf_float{tA<:Real}(stream::Ref{Void}, x_in::AbstractVector{tA})
x = convert(Vector{Cfloat}, x_in)
ccall( (:gsl_ieee_fprintf_float, libgsl), Void, (Ref{Void},
Ref{Cfloat}), stream, x )
end


# These functions output a formatted version of the IEEE floating-point number
# pointed to by x to the stream stream. A pointer is used to pass the number
# indirectly, to avoid any undesired promotion from float to double. The
# output takes one of the following forms, NaNthe Not-a-Number
# symbol Inf, -Infpositive or negative infinity
# 1.fffff...*2^E, -1.fffff...*2^Ea normalized floating point number
# 0.fffff...*2^E, -0.fffff...*2^Ea denormalized floating point number
# 0, -0positive or negative zero The output can be used directly
# in GNU Emacs Calc mode by preceding it with 2# to indicate binary.
#
# Returns: Void
function ieee_fprintf_double{tA<:Real}(stream::Ref{Void}, x_in::AbstractVector{tA})
x = convert(Vector{Cdouble}, x_in)
ccall( (:gsl_ieee_fprintf_double, libgsl), Void, (Ref{Void},
Ref{Cdouble}), stream, x )
end


# These functions output a formatted version of the IEEE floating-point number
# pointed to by x to the stream stdout.
#
# Returns: Void
function ieee_printf_float{tA<:Real}(x_in::AbstractVector{tA})
x = convert(Vector{Cfloat}, x_in)
ccall( (:gsl_ieee_printf_float, libgsl), Void, (Ref{Cfloat}, ), x )
end


# These functions output a formatted version of the IEEE floating-point number
# pointed to by x to the stream stdout.
#
# Returns: Void
function ieee_printf_double{tA<:Real}(x_in::AbstractVector{tA})
x = convert(Vector{Cdouble}, x_in)
ccall( (:gsl_ieee_printf_double, libgsl), Void, (Ref{Cdouble}, ), x )
end
18 changes: 9 additions & 9 deletions src/7_20_Gegenbauer_Functions.jl
Expand Up @@ -11,7 +11,7 @@ export sf_gegenpoly_1, sf_gegenpoly_2, sf_gegenpoly_3, sf_gegenpoly_1_e,

# These functions evaluate the Gegenbauer polynomials C^{(\lambda)}_n(x) using
# explicit representations for n =1, 2, 3.
#
#
# Returns: Cdouble
function sf_gegenpoly_1(lambda::Real, x::Real)
ccall( (:gsl_sf_gegenpoly_1, libgsl), Cdouble, (Cdouble, Cdouble),
Expand All @@ -22,7 +22,7 @@ end

# These functions evaluate the Gegenbauer polynomials C^{(\lambda)}_n(x) using
# explicit representations for n =1, 2, 3.
#
#
# Returns: Cdouble
function sf_gegenpoly_2(lambda::Real, x::Real)
ccall( (:gsl_sf_gegenpoly_2, libgsl), Cdouble, (Cdouble, Cdouble),
Expand All @@ -33,7 +33,7 @@ end

# These functions evaluate the Gegenbauer polynomials C^{(\lambda)}_n(x) using
# explicit representations for n =1, 2, 3.
#
#
# Returns: Cdouble
function sf_gegenpoly_3(lambda::Real, x::Real)
ccall( (:gsl_sf_gegenpoly_3, libgsl), Cdouble, (Cdouble, Cdouble),
Expand All @@ -44,7 +44,7 @@ end

# These functions evaluate the Gegenbauer polynomials C^{(\lambda)}_n(x) using
# explicit representations for n =1, 2, 3.
#
#
# Returns: Cint
function sf_gegenpoly_1_e(lambda::Real, x::Real)
result = Ref{gsl_sf_result}()
Expand All @@ -58,7 +58,7 @@ end

# These functions evaluate the Gegenbauer polynomials C^{(\lambda)}_n(x) using
# explicit representations for n =1, 2, 3.
#
#
# Returns: Cint
function sf_gegenpoly_2_e(lambda::Real, x::Real)
result = Ref{gsl_sf_result}()
Expand All @@ -72,7 +72,7 @@ end

# These functions evaluate the Gegenbauer polynomials C^{(\lambda)}_n(x) using
# explicit representations for n =1, 2, 3.
#
#
# Returns: Cint
function sf_gegenpoly_3_e(lambda::Real, x::Real)
result = Ref{gsl_sf_result}()
Expand All @@ -86,7 +86,7 @@ end

# These functions evaluate the Gegenbauer polynomial C^{(\lambda)}_n(x) for a
# specific value of n, lambda, x subject to \lambda > -1/2, n >= 0.
#
#
# Returns: Cdouble
function sf_gegenpoly_n(n::Integer, lambda::Real, x::Real)
ccall( (:gsl_sf_gegenpoly_n, libgsl), Cdouble, (Cint, Cdouble,
Expand All @@ -98,7 +98,7 @@ end

# These functions evaluate the Gegenbauer polynomial C^{(\lambda)}_n(x) for a
# specific value of n, lambda, x subject to \lambda > -1/2, n >= 0.
#
#
# Returns: Cint
function sf_gegenpoly_n_e(n::Integer, lambda::Real, x::Real)
result = Ref{gsl_sf_result}()
Expand All @@ -113,7 +113,7 @@ end

# This function computes an array of Gegenbauer polynomials C^{(\lambda)}_n(x)
# for n = 0, 1, 2, \dots, nmax, subject to \lambda > -1/2, nmax >= 0.
#
#
# Returns: Cint
function sf_gegenpoly_array(nmax::Integer, lambda::Real, x::Real)
result_array = Array(Cdouble, nmax+1)
Expand Down
80 changes: 80 additions & 0 deletions src/7_5_1_Regular_Cylindrical_Bessel_Functions.jl
@@ -0,0 +1,80 @@
#!/usr/bin/env julia
#GSL Julia wrapper
#(c) 2013 Jiahao Chen <jiahao@mit.edu>
##############################################
# 7.5.1 Regular Cylindrical Bessel Functions #
##############################################
export sf_bessel_J0, sf_bessel_J0_e, sf_bessel_J1, sf_bessel_J1_e,
sf_bessel_Jn, sf_bessel_Jn_e


# These routines compute the regular cylindrical Bessel function of zeroth
# order, J_0(x).
#
# Returns: Cdouble
function sf_bessel_J0(x::Real)
ccall( (:gsl_sf_bessel_J0, libgsl), Cdouble, (Cdouble, ), x )
end
@vectorize_1arg Number sf_bessel_J0


# These routines compute the regular cylindrical Bessel function of zeroth
# order, J_0(x).
#
# Returns: Cint
function sf_bessel_J0_e(x::Real)
result = Ref{gsl_sf_result}()
errno = ccall( (:gsl_sf_bessel_J0_e, libgsl), Cint, (Cdouble,
Ref{gsl_sf_result}), x, result )
if errno!= 0 throw(GSL_ERROR(errno)) end
return result[]
end
@vectorize_1arg Number sf_bessel_J0_e


# These routines compute the regular cylindrical Bessel function of first
# order, J_1(x).
#
# Returns: Cdouble
function sf_bessel_J1(x::Real)
ccall( (:gsl_sf_bessel_J1, libgsl), Cdouble, (Cdouble, ), x )
end
@vectorize_1arg Number sf_bessel_J1


# These routines compute the regular cylindrical Bessel function of first
# order, J_1(x).
#
# Returns: Cint
function sf_bessel_J1_e(x::Real)
result = Ref{gsl_sf_result}()
errno = ccall( (:gsl_sf_bessel_J1_e, libgsl), Cint, (Cdouble,
Ref{gsl_sf_result}), x, result )
if errno!= 0 throw(GSL_ERROR(errno)) end
return result[]
end
@vectorize_1arg Number sf_bessel_J1_e


# These routines compute the regular cylindrical Bessel function of order n,
# J_n(x).
#
# Returns: Cdouble
function sf_bessel_Jn(n::Integer, x::Real)
ccall( (:gsl_sf_bessel_Jn, libgsl), Cdouble, (Cint, Cdouble), n, x )
end
@vectorize_2arg Number sf_bessel_Jn


# These routines compute the regular cylindrical Bessel function of order n,
# J_n(x).
#
# Returns: Cint
function sf_bessel_Jn_e(n::Integer, x::Real)
result = Ref{gsl_sf_result}()
errno = ccall( (:gsl_sf_bessel_Jn_e, libgsl), Cint, (Cint, Cdouble,
Ref{gsl_sf_result}), n, x, result )
if errno!= 0 throw(GSL_ERROR(errno)) end
return result[]
end
@vectorize_2arg Number sf_bessel_Jn_e

0 comments on commit e4c7431

Please sign in to comment.