text:
###################################################
# Quick guide for the Geodesy package
###################################################

#
# Step 1 - Grab some points
#

# Starting with points in a coordinate system defined by an SRID (https://en.wikipedia.org/wiki/SRID)
raw_data = [
        573105.43200000003    6086900.3839999996    277.42700000000002    "EPSG"    32755;
        572734.61300000001    6087631.6480000000    273.80000000000001    "EPSG"    32755;
        572688.82100000000    6086535.8650000002    267.334               "EPSG"    32755;
        573667.63899999997    6086370.3410000000    287.68799999999999    "EPSG"    32755
]

# build an srid type from the info in the raw data
auth = symbol(raw_data[1, end-1])
code = raw_data[1, end]
srid = SRID{auth, code}
typealias Utm55S CRS{srid}  # use a type alias if it suits

# create a vector of the points in this SRID
# Transformations for the CRS type are handled by Proj4 package so anything supported by Proj4 is fine, BUT
# its up to the user to correctly interpret the x,y,z fields of the CRS type as they could mean anything (lon lat ... / east north ... / x y ... etc)

Xin = convert(Vector{Utm55S}, raw_data[:, 1:3]; row=true) # = convert(Vector{CRS{srid}}, raw_data[:, 1:3]; row=true)

#
# Step 2 - Transform the points into an longitude / latitude / altitude format with the WGS84 ellipsoid (i.e. GPS coordinates)
#
# N.B.  The below step requires Geodesy to recognise the Proj4 projection for type LLA{WGS84}.  If you're using a point type
# that geodesy doesn't know the Proj4 projection for, overload Geodesy.get_projection() to return the appropriate Proj4 projection e.g.:
#    Geodesy.get_projection(::Type{LLA{WGS84}}) = Proj4.Projection("+proj=longlat +datum=WGS84 +no_defs")
#

Xwgs84 = geotransform(LLA{WGS84}, Xin)

#
# Step 3 - transform them into a local (East, North, Up) coordindate frame
#

# use the center of the points as the center of the local frame
bbox = Bounds(Xwgs84)
lla_ref = center(bbox)

# option a: embed the local frame's origin in the point type.  This saves passing around lla_ref
Xlocal_a = geotransform(ENU{lla_ref}, Xwgs84)
println(typeof(Xlocal_a))

# option b: don't embed the local frame's origin in the point type.  Use this approach if you use loads of reference points
Xlocal_b = geotransform(ENU, Xwgs84, lla_ref)
println(typeof(Xlocal_b))

#
# Step 4 - do something with the points.  For this guide we'll just add some new points in between the old ones
#

for pair in combinations(1:length(Xlocal_a), 2)
    push!(Xlocal_a, (Xlocal_a[pair[1]] + Xlocal_a[pair[2]]) / 2.0)
    push!(Xlocal_b, (Xlocal_b[pair[1]] + Xlocal_b[pair[2]]) / 2.0)
end

#
# Step 5 - convert back to a world coordinate frame (ECEF this time to be different)
#

Xecef_a = geotransform(ECEF, Xlocal_a)           # the reference point is in the type of Xlocal_a
Xecef_b = geotransform(ECEF, Xlocal_b, lla_ref)  # need to supply the reference point

#
# Step 6 - Lastly go back to the original format
#

Xout = geotransform(CRS{srid},  Xecef_a)

# N.B. the input srid was actually a utm projection (zone 55) for the WGS84 datum.  We can use this package to select the SRID that best matches another point
(zone, band) = Geodesy.utm_zone(lla_ref) # I think this is the same for all reference ellipses...
srid_out = Geodesy.utm_srid(lla_ref)     # Geodesy can only do this for the WGS84 datum at present

###############################################
# ECEF Type Warning
###############################################

# whether ECEF is truly an ECEF point depends on the datum
# e.g.:
lla_osgb36 = LLA{Geodesy.OSGB36}(0, 0, 0)          # OSGB36 is a good match to the Earth in the UK but not elsewhere
ecef_fake = geotransform(ECEF, lla_osgb36)         # = 6.377563396e6, 0.0, 0.0
# isn't a true ECEF point because the OSGB36 ellipsoid isn't geocentric.

# If in doubt, datum conversions can be using the CRS type to get Proj4 to do it, e.g.
ecef_srid = geotransform(SRID(ECEF{WGS84}), lla_osgb36)     # = 6.377879171552554e6,-99.12039106890559, 534.423089412207
ecef_wgs84 = convert(ECEF{WGS84}, ecef_srid)                # convert to a type native to this package (type conversion not a transformation)

# or equivilently
srid = SRID(lla_odgb36)
lla_srid = convert(CRS{srid}, lla_osgb36)                   # type conversion not a transformation
ecef_wgs84_2 = geotransform(ECEF{WGS84}, lla_srid)          # = 6.377879171552554e6,-99.12039106890559, 534.423089412207


text:
function Currency(str::AbstractString)
    @assert !isempty(str) "Can't create currency from an empty string."
    return Currency(Symbol(str))
end

function Currency(sym::Symbol)
    return Currency{sym}()
end

currency_symbol(::Currency{C}) where {C} = C

"""
    cashvalue(c::Cash{C,T}) :: T

Returns the numeric value of the amount of a cash.
"""
cashvalue(c::Cash{C,T}) where {C<:Currency,T<:Real} = c.value

"""
    cashcurrency(::Cash{C}) :: C

Returns the currency for a cash.
"""
cashcurrency(::Cash{C}) where {C<:Currency} = C()

# Allows syntax `Cash{BRL}(10.0)`
(::Type{Cash{C}})(x::T) where {C,T<:Real} = Cash{C,T}(x)

Base.show(io::IO, c::Currency{C}) where {C} = print(io, C)
Base.show(io::IO, c::Cash{C}) where {C<:Currency} = print(io, c.value, C())

ext: jl


text:
## TODO: pending https://github.com/JuliaLang/julia/issues/29420

const PNGCAPI = nothing
const PNG_BYTES_TO_CHECK = 8
const tm = Libc.TmStruct
const time_t = UInt
const jmp_buf = Nothing

const png_byte = Cuchar

const png_int_16 = Cshort

const png_uint_16 = Cushort

const png_int_32 = Cint

const png_uint_32 = Cuint

const png_size_t = Csize_t

const png_ptrdiff_t = Cptrdiff_t

const png_alloc_size_t = Csize_t

const png_fixed_point = png_int_32

const png_voidp = Ptr{Cvoid}

const png_const_voidp = Ptr{Cvoid}

const png_bytep = Ptr{png_byte}

const png_const_bytep = Ptr{png_byte}

const png_uint_32p = Ptr{png_uint_32}

const png_const_uint_32p = Ptr{png_uint_32}

const png_int_32p = Ptr{png_int_32}

const png_const_int_32p = Ptr{png_int_32}

const png_uint_16p = Ptr{png_uint_16}

const png_const_uint_16p = Ptr{png_uint_16}

const png_int_16p = Ptr{png_int_16}

const png_const_int_16p = Ptr{png_int_16}

const png_charp = Cstring

const png_const_charp = Cstring

const png_fixed_point_p = Ptr{png_fixed_point}

const png_const_fixed_point_p = Ptr{png_fixed_point}

const png_size_tp = Ptr{Csize_t}

const png_const_size_tp = Ptr{Csize_t}

const png_FILE_p = Ptr{Libc.FILE}

const png_doublep = Ptr{Cdouble}

const png_const_doublep = Ptr{Cdouble}

const png_bytepp = Ptr{Ptr{png_byte}}

const png_uint_32pp = Ptr{Ptr{png_uint_32}}

const png_int_32pp = Ptr{Ptr{png_int_32}}

const png_uint_16pp = Ptr{Ptr{png_uint_16}}

const png_int_16pp = Ptr{Ptr{png_int_16}}

const png_const_charpp = Ptr{Cstring}

const png_charpp = Ptr{Cstring}

const png_fixed_point_pp = Ptr{Ptr{png_fixed_point}}

const png_doublepp = Ptr{Ptr{Cdouble}}

const png_charppp = Ptr{Ptr{Cstring}}

const png_libpng_version_1_6_37 = Cstring

const png_struct_def = Cvoid

const png_struct = png_struct_def

const png_const_structp = Ptr{png_struct}

const png_structp = Ptr{png_struct}

const png_structpp = Ptr{Ptr{png_struct}}

const png_info_def = Cvoid

const png_info = png_info_def

const png_infop = Ptr{png_info}

const png_const_infop = Ptr{png_info}

const png_infopp = Ptr{Ptr{png_info}}

const png_structrp = Ptr{png_struct}

const png_const_structrp = Ptr{png_struct}

const png_inforp = Ptr{png_info}

const png_const_inforp = Ptr{png_info}

struct png_color_struct
    red::png_byte
    green::png_byte
    blue::png_byte
end

const png_color = png_color_struct

const png_colorp = Ptr{png_color}

const png_const_colorp = Ptr{png_color}

const png_colorpp = Ptr{Ptr{png_color}}

struct png_color_16_struct
    index::png_byte
    red::png_uint_16
    green::png_uint_16
    blue::png_uint_16
    gray::png_uint_16
end

const png_color_16 = png_color_16_struct

const png_color_16p = Ptr{png_color_16}

const png_const_color_16p = Ptr{png_color_16}

const png_color_16pp = Ptr{Ptr{png_color_16}}

struct png_color_8_struct
    red::png_byte
    green::png_byte
    blue::png_byte
    gray::png_byte
    alpha::png_byte
end

const png_color_8 = png_color_8_struct

const png_color_8p = Ptr{png_color_8}

const png_const_color_8p = Ptr{png_color_8}

const png_color_8pp = Ptr{Ptr{png_color_8}}

struct png_sPLT_entry_struct
    red::png_uint_16
    green::png_uint_16
    blue::png_uint_16
    alpha::png_uint_16
    frequency::png_uint_16
end

const png_sPLT_entry = png_sPLT_entry_struct

const png_sPLT_entryp = Ptr{png_sPLT_entry}

const png_const_sPLT_entryp = Ptr{png_sPLT_entry}

const png_sPLT_entrypp = Ptr{Ptr{png_sPLT_entry}}

struct png_sPLT_struct
    name::png_charp
    depth::png_byte
    entries::png_sPLT_entryp
    nentries::png_int_32
end

const png_sPLT_t = png_sPLT_struct

const png_sPLT_tp = Ptr{png_sPLT_t}

const png_const_sPLT_tp = Ptr{png_sPLT_t}

const png_sPLT_tpp = Ptr{Ptr{png_sPLT_t}}

struct png_text_struct
    compression::Cint
    key::png_charp
    text::png_charp
    text_length::Csize_t
    itxt_length::Csize_t
    lang::png_charp
    lang_key::png_charp
end

const png_text = png_text_struct

const png_textp = Ptr{png_text}

const png_const_textp = Ptr{png_text}

const png_textpp = Ptr{Ptr{png_text}}

struct png_time_struct
    year::png_uint_16
    month::png_byte
    day::png_byte
    hour::png_byte
    minute::png_byte
    second::png_byte
end

const png_time = png_time_struct

const png_timep = Ptr{png_time}

const png_const_timep = Ptr{png_time}

const png_timepp = Ptr{Ptr{png_time}}

struct png_unknown_chunk_t
    name::NTuple{5, png_byte}
    data::Ptr{png_byte}
    size::Csize_t
    location::png_byte
end

const png_unknown_chunk = png_unknown_chunk_t

const png_unknown_chunkp = Ptr{png_unknown_chunk}

const png_const_unknown_chunkp = Ptr{png_unknown_chunk}

const png_unknown_chunkpp = Ptr{Ptr{png_unknown_chunk}}

struct png_row_info_struct
    width::png_uint_32
    rowbytes::Csize_t
    color_type::png_byte
    bit_depth::png_byte
    channels::png_byte
    pixel_depth::png_byte
end

const png_row_info = png_row_info_struct

const png_row_infop = Ptr{png_row_info}

const png_row_infopp = Ptr{Ptr{png_row_info}}

# typedef PNG_CALLBACK
const png_error_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_rw_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_flush_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_read_status_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_write_status_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_progressive_info_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_progressive_end_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_progressive_row_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_user_transform_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_user_chunk_ptr = Ptr{Cvoid}

# PNG_FUNCTION
const png_longjmp_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_malloc_ptr = Ptr{Cvoid}

# typedef PNG_CALLBACK
const png_free_ptr = Ptr{Cvoid}

function png_access_version_number()
    ccall((:png_access_version_number, libpng), png_uint_32, ())
end

function png_set_sig_bytes(png_ptr, num_bytes)
    ccall((:png_set_sig_bytes, libpng), Cvoid, (png_structrp, Cint), png_ptr, num_bytes)
end

function png_sig_cmp(sig, start, num_to_check)
    ccall((:png_sig_cmp, libpng), Cint, (png_const_bytep, Csize_t, Csize_t), sig, start, num_to_check)
end

function png_create_read_struct(user_png_ver, error_ptr, error_fn, warn_fn)
    ccall((:png_create_read_struct, libpng), png_structp, (png_const_charp, png_voidp, png_error_ptr, png_error_ptr), user_png_ver, error_ptr, error_fn, warn_fn)
end

function png_create_write_struct(user_png_ver, error_ptr, error_fn, warn_fn)
    ccall((:png_create_write_struct, libpng), png_structp, (png_const_charp, png_voidp, png_error_ptr, png_error_ptr), user_png_ver, error_ptr, error_fn, warn_fn)
end

function png_get_compression_buffer_size(png_ptr)
    ccall((:png_get_compression_buffer_size, libpng), Csize_t, (png_const_structrp,), png_ptr)
end

function png_set_compression_buffer_size(png_ptr, size)
    ccall((:png_set_compression_buffer_size, libpng), Cvoid, (png_structrp, Csize_t), png_ptr, size)
end

function png_set_longjmp_fn(png_ptr, longjmp_fn, jmp_buf_size)
    ccall((:png_set_longjmp_fn, libpng), Ptr{jmp_buf}, (png_structrp, png_longjmp_ptr, Csize_t), png_ptr, longjmp_fn, jmp_buf_size)
end

function png_longjmp(png_ptr, val)
    ccall((:png_longjmp, libpng), Cvoid, (png_const_structrp, Cint), png_ptr, val)
end

function png_reset_zstream(png_ptr)
    ccall((:png_reset_zstream, libpng), Cint, (png_structrp,), png_ptr)
end

function png_create_read_struct_2(user_png_ver, error_ptr, error_fn, warn_fn, mem_ptr, malloc_fn, free_fn)
    ccall((:png_create_read_struct_2, libpng), png_structp, (png_const_charp, png_voidp, png_error_ptr, png_error_ptr, png_voidp, png_malloc_ptr, png_free_ptr), user_png_ver, error_ptr, error_fn, warn_fn, mem_ptr, malloc_fn, free_fn)
end

function png_create_write_struct_2(user_png_ver, error_ptr, error_fn, warn_fn, mem_ptr, malloc_fn, free_fn)
    ccall((:png_create_write_struct_2, libpng), png_structp, (png_const_charp, png_voidp, png_error_ptr, png_error_ptr, png_voidp, png_malloc_ptr, png_free_ptr), user_png_ver, error_ptr, error_fn, warn_fn, mem_ptr, malloc_fn, free_fn)
end

function png_write_sig(png_ptr)
    ccall((:png_write_sig, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_write_chunk(png_ptr, chunk_name, data, length)
    ccall((:png_write_chunk, libpng), Cvoid, (png_structrp, png_const_bytep, png_const_bytep, Csize_t), png_ptr, chunk_name, data, length)
end

function png_write_chunk_start(png_ptr, chunk_name, length)
    ccall((:png_write_chunk_start, libpng), Cvoid, (png_structrp, png_const_bytep, png_uint_32), png_ptr, chunk_name, length)
end

function png_write_chunk_data(png_ptr, data, length)
    ccall((:png_write_chunk_data, libpng), Cvoid, (png_structrp, png_const_bytep, Csize_t), png_ptr, data, length)
end

function png_write_chunk_end(png_ptr)
    ccall((:png_write_chunk_end, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_create_info_struct(png_ptr)
    ccall((:png_create_info_struct, libpng), png_infop, (png_const_structrp,), png_ptr)
end

function png_info_init_3(info_ptr, png_info_struct_size)
    ccall((:png_info_init_3, libpng), Cvoid, (png_infopp, Csize_t), info_ptr, png_info_struct_size)
end

function png_write_info_before_PLTE(png_ptr, info_ptr)
    ccall((:png_write_info_before_PLTE, libpng), Cvoid, (png_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_write_info(png_ptr, info_ptr)
    ccall((:png_write_info, libpng), Cvoid, (png_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_read_info(png_ptr, info_ptr)
    ccall((:png_read_info, libpng), Cvoid, (png_structrp, png_inforp), png_ptr, info_ptr)
end

function png_convert_to_rfc1123(png_ptr, ptime)
    ccall((:png_convert_to_rfc1123, libpng), png_const_charp, (png_structrp, png_const_timep), png_ptr, ptime)
end

function png_convert_to_rfc1123_buffer(out, ptime)
    ccall((:png_convert_to_rfc1123_buffer, libpng), Cint, (Ptr{Cchar}, png_const_timep), out, ptime)
end

function png_convert_from_struct_tm(ptime, ttime)
    ccall((:png_convert_from_struct_tm, libpng), Cvoid, (png_timep, Ptr{tm}), ptime, ttime)
end

function png_convert_from_time_t(ptime, ttime)
    ccall((:png_convert_from_time_t, libpng), Cvoid, (png_timep, time_t), ptime, ttime)
end

function png_set_expand(png_ptr)
    ccall((:png_set_expand, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_expand_gray_1_2_4_to_8(png_ptr)
    ccall((:png_set_expand_gray_1_2_4_to_8, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_palette_to_rgb(png_ptr)
    ccall((:png_set_palette_to_rgb, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_tRNS_to_alpha(png_ptr)
    ccall((:png_set_tRNS_to_alpha, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_expand_16(png_ptr)
    ccall((:png_set_expand_16, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_bgr(png_ptr)
    ccall((:png_set_bgr, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_gray_to_rgb(png_ptr)
    ccall((:png_set_gray_to_rgb, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_rgb_to_gray(png_ptr, error_action, red, green)
    ccall((:png_set_rgb_to_gray, libpng), Cvoid, (png_structrp, Cint, Cdouble, Cdouble), png_ptr, error_action, red, green)
end

function png_set_rgb_to_gray_fixed(png_ptr, error_action, red, green)
    ccall((:png_set_rgb_to_gray_fixed, libpng), Cvoid, (png_structrp, Cint, png_fixed_point, png_fixed_point), png_ptr, error_action, red, green)
end

function png_get_rgb_to_gray_status(png_ptr)
    ccall((:png_get_rgb_to_gray_status, libpng), png_byte, (png_const_structrp,), png_ptr)
end

function png_build_grayscale_palette(bit_depth, palette)
    ccall((:png_build_grayscale_palette, libpng), Cvoid, (Cint, png_colorp), bit_depth, palette)
end

function png_set_alpha_mode(png_ptr, mode, output_gamma)
    ccall((:png_set_alpha_mode, libpng), Cvoid, (png_structrp, Cint, Cdouble), png_ptr, mode, output_gamma)
end

function png_set_alpha_mode_fixed(png_ptr, mode, output_gamma)
    ccall((:png_set_alpha_mode_fixed, libpng), Cvoid, (png_structrp, Cint, png_fixed_point), png_ptr, mode, output_gamma)
end

function png_set_strip_alpha(png_ptr)
    ccall((:png_set_strip_alpha, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_swap_alpha(png_ptr)
    ccall((:png_set_swap_alpha, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_invert_alpha(png_ptr)
    ccall((:png_set_invert_alpha, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_filler(png_ptr, filler, flags)
    ccall((:png_set_filler, libpng), Cvoid, (png_structrp, png_uint_32, Cint), png_ptr, filler, flags)
end

function png_set_add_alpha(png_ptr, filler, flags)
    ccall((:png_set_add_alpha, libpng), Cvoid, (png_structrp, png_uint_32, Cint), png_ptr, filler, flags)
end

function png_set_swap(png_ptr)
    ccall((:png_set_swap, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_packing(png_ptr)
    ccall((:png_set_packing, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_packswap(png_ptr)
    ccall((:png_set_packswap, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_shift(png_ptr, true_bits)
    ccall((:png_set_shift, libpng), Cvoid, (png_structrp, png_const_color_8p), png_ptr, true_bits)
end

function png_set_interlace_handling(png_ptr)
    ccall((:png_set_interlace_handling, libpng), Cint, (png_structrp,), png_ptr)
end

function png_set_invert_mono(png_ptr)
    ccall((:png_set_invert_mono, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_background(png_ptr, background_color, background_gamma_code, need_expand, background_gamma)
    ccall((:png_set_background, libpng), Cvoid, (png_structrp, png_const_color_16p, Cint, Cint, Cdouble), png_ptr, background_color, background_gamma_code, need_expand, background_gamma)
end

function png_set_background_fixed(png_ptr, background_color, background_gamma_code, need_expand, background_gamma)
    ccall((:png_set_background_fixed, libpng), Cvoid, (png_structrp, png_const_color_16p, Cint, Cint, png_fixed_point), png_ptr, background_color, background_gamma_code, need_expand, background_gamma)
end

function png_set_scale_16(png_ptr)
    ccall((:png_set_scale_16, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_strip_16(png_ptr)
    ccall((:png_set_strip_16, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_set_quantize(png_ptr, palette, num_palette, maximum_colors, histogram, full_quantize)
    ccall((:png_set_quantize, libpng), Cvoid, (png_structrp, png_colorp, Cint, Cint, png_const_uint_16p, Cint), png_ptr, palette, num_palette, maximum_colors, histogram, full_quantize)
end

function png_set_gamma(png_ptr, screen_gamma, override_file_gamma)
    ccall((:png_set_gamma, libpng), Cvoid, (png_structrp, Cdouble, Cdouble), png_ptr, screen_gamma, override_file_gamma)
end

function png_set_gamma_fixed(png_ptr, screen_gamma, override_file_gamma)
    ccall((:png_set_gamma_fixed, libpng), Cvoid, (png_structrp, png_fixed_point, png_fixed_point), png_ptr, screen_gamma, override_file_gamma)
end

function png_set_flush(png_ptr, nrows)
    ccall((:png_set_flush, libpng), Cvoid, (png_structrp, Cint), png_ptr, nrows)
end

function png_write_flush(png_ptr)
    ccall((:png_write_flush, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_start_read_image(png_ptr)
    ccall((:png_start_read_image, libpng), Cvoid, (png_structrp,), png_ptr)
end

function png_read_update_info(png_ptr, info_ptr)
    ccall((:png_read_update_info, libpng), Cvoid, (png_structrp, png_inforp), png_ptr, info_ptr)
end

function png_read_rows(png_ptr, row, display_row, num_rows)
    ccall((:png_read_rows, libpng), Cvoid, (png_structrp, png_bytepp, png_bytepp, png_uint_32), png_ptr, row, display_row, num_rows)
end

function png_read_row(png_ptr, row, display_row)
    ccall((:png_read_row, libpng), Cvoid, (png_structrp, png_bytep, png_bytep), png_ptr, row, display_row)
end

function png_read_image(png_ptr, image)
    ccall((:png_read_image, libpng), Cvoid, (png_structrp, png_bytepp), png_ptr, image)
end

function png_write_row(png_ptr, row)
    ccall((:png_write_row, libpng), Cvoid, (png_structrp, png_const_bytep), png_ptr, row)
end

function png_write_rows(png_ptr, row, num_rows)
    ccall((:png_write_rows, libpng), Cvoid, (png_structrp, png_bytepp, png_uint_32), png_ptr, row, num_rows)
end

function png_write_image(png_ptr, image)
    ccall((:png_write_image, libpng), Cvoid, (png_structrp, png_bytepp), png_ptr, image)
end

function png_write_end(png_ptr, info_ptr)
    ccall((:png_write_end, libpng), Cvoid, (png_structrp, png_inforp), png_ptr, info_ptr)
end

function png_read_end(png_ptr, info_ptr)
    ccall((:png_read_end, libpng), Cvoid, (png_structrp, png_inforp), png_ptr, info_ptr)
end

function png_destroy_info_struct(png_ptr, info_ptr_ptr)
    ccall((:png_destroy_info_struct, libpng), Cvoid, (png_const_structrp, png_infopp), png_ptr, info_ptr_ptr)
end

function png_destroy_read_struct(png_ptr_ptr, info_ptr_ptr, end_info_ptr_ptr)
    ccall((:png_destroy_read_struct, libpng), Cvoid, (png_structpp, png_infopp, png_infopp), png_ptr_ptr, info_ptr_ptr, end_info_ptr_ptr)
end

function png_destroy_write_struct(png_ptr_ptr, info_ptr_ptr)
    ccall((:png_destroy_write_struct, libpng), Cvoid, (png_structpp, png_infopp), png_ptr_ptr, info_ptr_ptr)
end

function png_set_crc_action(png_ptr, crit_action, ancil_action)
    ccall((:png_set_crc_action, libpng), Cvoid, (png_structrp, Cint, Cint), png_ptr, crit_action, ancil_action)
end

function png_set_filter(png_ptr, method, filters)
    ccall((:png_set_filter, libpng), Cvoid, (png_structrp, Cint, Cint), png_ptr, method, filters)
end

function png_set_filter_heuristics(png_ptr, heuristic_method, num_weights, filter_weights, filter_costs)
    ccall((:png_set_filter_heuristics, libpng), Cvoid, (png_structrp, Cint, Cint, png_const_doublep, png_const_doublep), png_ptr, heuristic_method, num_weights, filter_weights, filter_costs)
end

function png_set_filter_heuristics_fixed(png_ptr, heuristic_method, num_weights, filter_weights, filter_costs)
    ccall((:png_set_filter_heuristics_fixed, libpng), Cvoid, (png_structrp, Cint, Cint, png_const_fixed_point_p, png_const_fixed_point_p), png_ptr, heuristic_method, num_weights, filter_weights, filter_costs)
end

function png_set_compression_level(png_ptr, level)
    ccall((:png_set_compression_level, libpng), Cvoid, (png_structrp, Cint), png_ptr, level)
end

function png_set_compression_mem_level(png_ptr, mem_level)
    ccall((:png_set_compression_mem_level, libpng), Cvoid, (png_structrp, Cint), png_ptr, mem_level)
end

function png_set_compression_strategy(png_ptr, strategy)
    ccall((:png_set_compression_strategy, libpng), Cvoid, (png_structrp, Cint), png_ptr, strategy)
end

function png_set_compression_window_bits(png_ptr, window_bits)
    ccall((:png_set_compression_window_bits, libpng), Cvoid, (png_structrp, Cint), png_ptr, window_bits)
end

function png_set_compression_method(png_ptr, method)
    ccall((:png_set_compression_method, libpng), Cvoid, (png_structrp, Cint), png_ptr, method)
end

function png_set_text_compression_level(png_ptr, level)
    ccall((:png_set_text_compression_level, libpng), Cvoid, (png_structrp, Cint), png_ptr, level)
end

function png_set_text_compression_mem_level(png_ptr, mem_level)
    ccall((:png_set_text_compression_mem_level, libpng), Cvoid, (png_structrp, Cint), png_ptr, mem_level)
end

function png_set_text_compression_strategy(png_ptr, strategy)
    ccall((:png_set_text_compression_strategy, libpng), Cvoid, (png_structrp, Cint), png_ptr, strategy)
end

function png_set_text_compression_window_bits(png_ptr, window_bits)
    ccall((:png_set_text_compression_window_bits, libpng), Cvoid, (png_structrp, Cint), png_ptr, window_bits)
end

function png_set_text_compression_method(png_ptr, method)
    ccall((:png_set_text_compression_method, libpng), Cvoid, (png_structrp, Cint), png_ptr, method)
end

function png_init_io(png_ptr, fp)
    ccall((:png_init_io, libpng), Cvoid, (png_structrp, png_FILE_p), png_ptr, fp)
end

function png_set_error_fn(png_ptr, error_ptr, error_fn, warning_fn)
    ccall((:png_set_error_fn, libpng), Cvoid, (png_structrp, png_voidp, png_error_ptr, png_error_ptr), png_ptr, error_ptr, error_fn, warning_fn)
end

function png_get_error_ptr(png_ptr)
    ccall((:png_get_error_ptr, libpng), png_voidp, (png_const_structrp,), png_ptr)
end

function png_set_write_fn(png_ptr, io_ptr, write_data_fn, output_flush_fn)
    ccall((:png_set_write_fn, libpng), Cvoid, (png_structrp, Any, png_rw_ptr, png_flush_ptr), png_ptr, io_ptr, write_data_fn, output_flush_fn)
end

function png_set_read_fn(png_ptr, io_ptr, read_data_fn)
    ccall((:png_set_read_fn, libpng), Cvoid, (png_structrp, png_voidp, png_rw_ptr), png_ptr, io_ptr, read_data_fn)
end

function png_get_io_ptr(png_ptr)
    ccall((:png_get_io_ptr, libpng), png_voidp, (png_const_structrp,), png_ptr)
end

function png_set_read_status_fn(png_ptr, read_row_fn)
    ccall((:png_set_read_status_fn, libpng), Cvoid, (png_structrp, png_read_status_ptr), png_ptr, read_row_fn)
end

function png_set_write_status_fn(png_ptr, write_row_fn)
    ccall((:png_set_write_status_fn, libpng), Cvoid, (png_structrp, png_write_status_ptr), png_ptr, write_row_fn)
end

function png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn)
    ccall((:png_set_mem_fn, libpng), Cvoid, (png_structrp, png_voidp, png_malloc_ptr, png_free_ptr), png_ptr, mem_ptr, malloc_fn, free_fn)
end

function png_get_mem_ptr(png_ptr)
    ccall((:png_get_mem_ptr, libpng), png_voidp, (png_const_structrp,), png_ptr)
end

function png_set_read_user_transform_fn(png_ptr, read_user_transform_fn)
    ccall((:png_set_read_user_transform_fn, libpng), Cvoid, (png_structrp, png_user_transform_ptr), png_ptr, read_user_transform_fn)
end

function png_set_write_user_transform_fn(png_ptr, write_user_transform_fn)
    ccall((:png_set_write_user_transform_fn, libpng), Cvoid, (png_structrp, png_user_transform_ptr), png_ptr, write_user_transform_fn)
end

function png_set_user_transform_info(png_ptr, user_transform_ptr, user_transform_depth, user_transform_channels)
    ccall((:png_set_user_transform_info, libpng), Cvoid, (png_structrp, png_voidp, Cint, Cint), png_ptr, user_transform_ptr, user_transform_depth, user_transform_channels)
end

function png_get_user_transform_ptr(png_ptr)
    ccall((:png_get_user_transform_ptr, libpng), png_voidp, (png_const_structrp,), png_ptr)
end

function png_get_current_row_number(arg1)
    ccall((:png_get_current_row_number, libpng), png_uint_32, (png_const_structrp,), arg1)
end

function png_get_current_pass_number(arg1)
    ccall((:png_get_current_pass_number, libpng), png_byte, (png_const_structrp,), arg1)
end

function png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, read_user_chunk_fn)
    ccall((:png_set_read_user_chunk_fn, libpng), Cvoid, (png_structrp, png_voidp, png_user_chunk_ptr), png_ptr, user_chunk_ptr, read_user_chunk_fn)
end

function png_get_user_chunk_ptr(png_ptr)
    ccall((:png_get_user_chunk_ptr, libpng), png_voidp, (png_const_structrp,), png_ptr)
end

function png_set_progressive_read_fn(png_ptr, progressive_ptr, info_fn, row_fn, end_fn)
    ccall((:png_set_progressive_read_fn, libpng), Cvoid, (png_structrp, png_voidp, png_progressive_info_ptr, png_progressive_row_ptr, png_progressive_end_ptr), png_ptr, progressive_ptr, info_fn, row_fn, end_fn)
end

function png_get_progressive_ptr(png_ptr)
    ccall((:png_get_progressive_ptr, libpng), png_voidp, (png_const_structrp,), png_ptr)
end

function png_process_data(png_ptr, info_ptr, buffer, buffer_size)
    ccall((:png_process_data, libpng), Cvoid, (png_structrp, png_inforp, png_bytep, Csize_t), png_ptr, info_ptr, buffer, buffer_size)
end

function png_process_data_pause(arg1, save)
    ccall((:png_process_data_pause, libpng), Csize_t, (png_structrp, Cint), arg1, save)
end

function png_process_data_skip(arg1)
    ccall((:png_process_data_skip, libpng), png_uint_32, (png_structrp,), arg1)
end

function png_progressive_combine_row(png_ptr, old_row, new_row)
    ccall((:png_progressive_combine_row, libpng), Cvoid, (png_const_structrp, png_bytep, png_const_bytep), png_ptr, old_row, new_row)
end

function png_malloc(png_ptr, size)
    ccall((:png_malloc, libpng), png_voidp, (png_const_structrp, png_alloc_size_t), png_ptr, size)
end

function png_calloc(png_ptr, size)
    ccall((:png_calloc, libpng), png_voidp, (png_const_structrp, png_alloc_size_t), png_ptr, size)
end

function png_malloc_warn(png_ptr, size)
    ccall((:png_malloc_warn, libpng), png_voidp, (png_const_structrp, png_alloc_size_t), png_ptr, size)
end

function png_free(png_ptr, ptr)
    ccall((:png_free, libpng), Cvoid, (png_const_structrp, png_voidp), png_ptr, ptr)
end

function png_free_data(png_ptr, info_ptr, free_me, num)
    ccall((:png_free_data, libpng), Cvoid, (png_const_structrp, png_inforp, png_uint_32, Cint), png_ptr, info_ptr, free_me, num)
end

function png_data_freer(png_ptr, info_ptr, freer, mask)
    ccall((:png_data_freer, libpng), Cvoid, (png_const_structrp, png_inforp, Cint, png_uint_32), png_ptr, info_ptr, freer, mask)
end

function png_malloc_default(png_ptr, size)
    ccall((:png_malloc_default, libpng), png_voidp, (png_const_structrp, png_alloc_size_t), png_ptr, size)
end

function png_free_default(png_ptr, ptr)
    ccall((:png_free_default, libpng), Cvoid, (png_const_structrp, png_voidp), png_ptr, ptr)
end

function png_error(png_ptr, error_message)
    ccall((:png_error, libpng), Cvoid, (png_const_structrp, png_const_charp), png_ptr, error_message)
end

function png_chunk_error(png_ptr, error_message)
    ccall((:png_chunk_error, libpng), Cvoid, (png_const_structrp, png_const_charp), png_ptr, error_message)
end

function png_warning(png_ptr, warning_message)
    ccall((:png_warning, libpng), Cvoid, (png_const_structrp, png_const_charp), png_ptr, warning_message)
end

function png_chunk_warning(png_ptr, warning_message)
    ccall((:png_chunk_warning, libpng), Cvoid, (png_const_structrp, png_const_charp), png_ptr, warning_message)
end

function png_benign_error(png_ptr, warning_message)
    ccall((:png_benign_error, libpng), Cvoid, (png_const_structrp, png_const_charp), png_ptr, warning_message)
end

function png_chunk_benign_error(png_ptr, warning_message)
    ccall((:png_chunk_benign_error, libpng), Cvoid, (png_const_structrp, png_const_charp), png_ptr, warning_message)
end

function png_set_benign_errors(png_ptr, allowed)
    ccall((:png_set_benign_errors, libpng), Cvoid, (png_structrp, Cint), png_ptr, allowed)
end

function png_get_valid(png_ptr, info_ptr, flag)
    ccall((:png_get_valid, libpng), png_uint_32, (png_const_structrp, png_const_inforp, png_uint_32), png_ptr, info_ptr, flag)
end

function png_get_rowbytes(png_ptr, info_ptr)
    ccall((:png_get_rowbytes, libpng), Csize_t, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_rows(png_ptr, info_ptr)
    ccall((:png_get_rows, libpng), png_bytepp, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_set_rows(png_ptr, info_ptr, row_pointers)
    ccall((:png_set_rows, libpng), Cvoid, (png_const_structrp, png_inforp, png_bytepp), png_ptr, info_ptr, row_pointers)
end

function png_get_channels(png_ptr, info_ptr)
    ccall((:png_get_channels, libpng), png_byte, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_image_width(png_ptr, info_ptr)
    ccall((:png_get_image_width, libpng), png_uint_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_image_height(png_ptr, info_ptr)
    ccall((:png_get_image_height, libpng), png_uint_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_bit_depth(png_ptr, info_ptr)
    ccall((:png_get_bit_depth, libpng), png_byte, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_color_type(png_ptr, info_ptr)
    ccall((:png_get_color_type, libpng), png_byte, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_filter_type(png_ptr, info_ptr)
    ccall((:png_get_filter_type, libpng), png_byte, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_interlace_type(png_ptr, info_ptr)
    ccall((:png_get_interlace_type, libpng), png_byte, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_compression_type(png_ptr, info_ptr)
    ccall((:png_get_compression_type, libpng), png_byte, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_pixels_per_meter(png_ptr, info_ptr)
    ccall((:png_get_pixels_per_meter, libpng), png_uint_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_x_pixels_per_meter(png_ptr, info_ptr)
    ccall((:png_get_x_pixels_per_meter, libpng), png_uint_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_y_pixels_per_meter(png_ptr, info_ptr)
    ccall((:png_get_y_pixels_per_meter, libpng), png_uint_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_pixel_aspect_ratio(png_ptr, info_ptr)
    ccall((:png_get_pixel_aspect_ratio, libpng), Cfloat, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_pixel_aspect_ratio_fixed(png_ptr, info_ptr)
    ccall((:png_get_pixel_aspect_ratio_fixed, libpng), png_fixed_point, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_x_offset_pixels(png_ptr, info_ptr)
    ccall((:png_get_x_offset_pixels, libpng), png_int_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_y_offset_pixels(png_ptr, info_ptr)
    ccall((:png_get_y_offset_pixels, libpng), png_int_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_x_offset_microns(png_ptr, info_ptr)
    ccall((:png_get_x_offset_microns, libpng), png_int_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_y_offset_microns(png_ptr, info_ptr)
    ccall((:png_get_y_offset_microns, libpng), png_int_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_signature(png_ptr, info_ptr)
    ccall((:png_get_signature, libpng), png_const_bytep, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_bKGD(png_ptr, info_ptr, background)
    ccall((:png_get_bKGD, libpng), png_uint_32, (png_const_structrp, png_inforp, Ptr{png_color_16p}), png_ptr, info_ptr, background)
end

function png_set_bKGD(png_ptr, info_ptr, background)
    ccall((:png_set_bKGD, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_color_16p), png_ptr, info_ptr, background)
end

function png_get_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)
    ccall((:png_get_cHRM, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}), png_ptr, info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)
end

function png_get_cHRM_XYZ(png_ptr, info_ptr, red_X, red_Y, red_Z, green_X, green_Y, green_Z, blue_X, blue_Y, blue_Z)
    ccall((:png_get_cHRM_XYZ, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}, Ptr{Cdouble}), png_ptr, info_ptr, red_X, red_Y, red_Z, green_X, green_Y, green_Z, blue_X, blue_Y, blue_Z)
end

function png_get_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y)
    ccall((:png_get_cHRM_fixed, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}), png_ptr, info_ptr, int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y)
end

function png_get_cHRM_XYZ_fixed(png_ptr, info_ptr, int_red_X, int_red_Y, int_red_Z, int_green_X, int_green_Y, int_green_Z, int_blue_X, int_blue_Y, int_blue_Z)
    ccall((:png_get_cHRM_XYZ_fixed, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}, Ptr{png_fixed_point}), png_ptr, info_ptr, int_red_X, int_red_Y, int_red_Z, int_green_X, int_green_Y, int_green_Z, int_blue_X, int_blue_Y, int_blue_Z)
end

function png_set_cHRM(png_ptr, info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)
    ccall((:png_set_cHRM, libpng), Cvoid, (png_const_structrp, png_inforp, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble), png_ptr, info_ptr, white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)
end

function png_set_cHRM_XYZ(png_ptr, info_ptr, red_X, red_Y, red_Z, green_X, green_Y, green_Z, blue_X, blue_Y, blue_Z)
    ccall((:png_set_cHRM_XYZ, libpng), Cvoid, (png_const_structrp, png_inforp, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble, Cdouble), png_ptr, info_ptr, red_X, red_Y, red_Z, green_X, green_Y, green_Z, blue_X, blue_Y, blue_Z)
end

function png_set_cHRM_fixed(png_ptr, info_ptr, int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y)
    ccall((:png_set_cHRM_fixed, libpng), Cvoid, (png_const_structrp, png_inforp, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point), png_ptr, info_ptr, int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y)
end

function png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, int_red_X, int_red_Y, int_red_Z, int_green_X, int_green_Y, int_green_Z, int_blue_X, int_blue_Y, int_blue_Z)
    ccall((:png_set_cHRM_XYZ_fixed, libpng), Cvoid, (png_const_structrp, png_inforp, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point, png_fixed_point), png_ptr, info_ptr, int_red_X, int_red_Y, int_red_Z, int_green_X, int_green_Y, int_green_Z, int_blue_X, int_blue_Y, int_blue_Z)
end

function png_get_eXIf(png_ptr, info_ptr, exif)
    ccall((:png_get_eXIf, libpng), png_uint_32, (png_const_structrp, png_inforp, Ptr{png_bytep}), png_ptr, info_ptr, exif)
end

function png_set_eXIf(png_ptr, info_ptr, exif)
    ccall((:png_set_eXIf, libpng), Cvoid, (png_const_structrp, png_inforp, png_bytep), png_ptr, info_ptr, exif)
end

function png_get_eXIf_1(png_ptr, info_ptr, num_exif, exif)
    ccall((:png_get_eXIf_1, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{png_uint_32}, Ptr{png_bytep}), png_ptr, info_ptr, num_exif, exif)
end

function png_set_eXIf_1(png_ptr, info_ptr, num_exif, exif)
    ccall((:png_set_eXIf_1, libpng), Cvoid, (png_const_structrp, png_inforp, png_uint_32, png_bytep), png_ptr, info_ptr, num_exif, exif)
end

function png_get_gAMA(png_ptr, info_ptr, file_gamma)
    ccall((:png_get_gAMA, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{Cdouble}), png_ptr, info_ptr, file_gamma)
end

function png_get_gAMA_fixed(png_ptr, info_ptr, int_file_gamma)
    ccall((:png_get_gAMA_fixed, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{png_fixed_point}), png_ptr, info_ptr, int_file_gamma)
end

function png_set_gAMA(png_ptr, info_ptr, file_gamma)
    ccall((:png_set_gAMA, libpng), Cvoid, (png_const_structrp, png_inforp, Cdouble), png_ptr, info_ptr, file_gamma)
end

function png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma)
    ccall((:png_set_gAMA_fixed, libpng), Cvoid, (png_const_structrp, png_inforp, png_fixed_point), png_ptr, info_ptr, int_file_gamma)
end

function png_get_hIST(png_ptr, info_ptr, hist)
    ccall((:png_get_hIST, libpng), png_uint_32, (png_const_structrp, png_inforp, Ptr{png_uint_16p}), png_ptr, info_ptr, hist)
end

function png_set_hIST(png_ptr, info_ptr, hist)
    ccall((:png_set_hIST, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_uint_16p), png_ptr, info_ptr, hist)
end

function png_get_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_method, compression_method, filter_method)
    ccall((:png_get_IHDR, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{png_uint_32}, Ptr{png_uint_32}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}, Ptr{Cint}), png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_method, compression_method, filter_method)
end

function png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_method, compression_method, filter_method)
    ccall((:png_set_IHDR, libpng), Cvoid, (png_const_structrp, png_inforp, png_uint_32, png_uint_32, Cint, Cint, Cint, Cint, Cint), png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_method, compression_method, filter_method)
end

function png_get_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type)
    ccall((:png_get_oFFs, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{png_int_32}, Ptr{png_int_32}, Ptr{Cint}), png_ptr, info_ptr, offset_x, offset_y, unit_type)
end

function png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type)
    ccall((:png_set_oFFs, libpng), Cvoid, (png_const_structrp, png_inforp, png_int_32, png_int_32, Cint), png_ptr, info_ptr, offset_x, offset_y, unit_type)
end

function png_get_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, units, params)
    ccall((:png_get_pCAL, libpng), png_uint_32, (png_const_structrp, png_inforp, Ptr{png_charp}, Ptr{png_int_32}, Ptr{png_int_32}, Ptr{Cint}, Ptr{Cint}, Ptr{png_charp}, Ptr{png_charpp}), png_ptr, info_ptr, purpose, X0, X1, type, nparams, units, params)
end

function png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, units, params)
    ccall((:png_set_pCAL, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_charp, png_int_32, png_int_32, Cint, Cint, png_const_charp, png_charpp), png_ptr, info_ptr, purpose, X0, X1, type, nparams, units, params)
end

function png_get_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type)
    ccall((:png_get_pHYs, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{png_uint_32}, Ptr{png_uint_32}, Ptr{Cint}), png_ptr, info_ptr, res_x, res_y, unit_type)
end

function png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type)
    ccall((:png_set_pHYs, libpng), Cvoid, (png_const_structrp, png_inforp, png_uint_32, png_uint_32, Cint), png_ptr, info_ptr, res_x, res_y, unit_type)
end

function png_get_PLTE(png_ptr, info_ptr, palette, num_palette)
    ccall((:png_get_PLTE, libpng), png_uint_32, (png_const_structrp, png_inforp, Ptr{png_colorp}, Ptr{Cint}), png_ptr, info_ptr, palette, num_palette)
end

function png_set_PLTE(png_ptr, info_ptr, palette, num_palette)
    ccall((:png_set_PLTE, libpng), Cvoid, (png_structrp, png_inforp, png_const_colorp, Cint), png_ptr, info_ptr, palette, num_palette)
end

function png_get_sBIT(png_ptr, info_ptr, sig_bit)
    ccall((:png_get_sBIT, libpng), png_uint_32, (png_const_structrp, png_inforp, Ptr{png_color_8p}), png_ptr, info_ptr, sig_bit)
end

function png_set_sBIT(png_ptr, info_ptr, sig_bit)
    ccall((:png_set_sBIT, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_color_8p), png_ptr, info_ptr, sig_bit)
end

function png_get_sRGB(png_ptr, info_ptr, file_srgb_intent)
    ccall((:png_get_sRGB, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{Cint}), png_ptr, info_ptr, file_srgb_intent)
end

function png_set_sRGB(png_ptr, info_ptr, srgb_intent)
    ccall((:png_set_sRGB, libpng), Cvoid, (png_const_structrp, png_inforp, Cint), png_ptr, info_ptr, srgb_intent)
end

function png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, srgb_intent)
    ccall((:png_set_sRGB_gAMA_and_cHRM, libpng), Cvoid, (png_const_structrp, png_inforp, Cint), png_ptr, info_ptr, srgb_intent)
end

function png_get_iCCP(png_ptr, info_ptr, name, compression_type, profile, proflen)
    ccall((:png_get_iCCP, libpng), png_uint_32, (png_const_structrp, png_inforp, png_charpp, Ptr{Cint}, png_bytepp, Ptr{png_uint_32}), png_ptr, info_ptr, name, compression_type, profile, proflen)
end

function png_set_iCCP(png_ptr, info_ptr, name, compression_type, profile, proflen)
    ccall((:png_set_iCCP, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_charp, Cint, png_const_bytep, png_uint_32), png_ptr, info_ptr, name, compression_type, profile, proflen)
end

function png_get_sPLT(png_ptr, info_ptr, entries)
    ccall((:png_get_sPLT, libpng), Cint, (png_const_structrp, png_inforp, png_sPLT_tpp), png_ptr, info_ptr, entries)
end

function png_set_sPLT(png_ptr, info_ptr, entries, nentries)
    ccall((:png_set_sPLT, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_sPLT_tp, Cint), png_ptr, info_ptr, entries, nentries)
end

function png_get_text(png_ptr, info_ptr, text_ptr, num_text)
    ccall((:png_get_text, libpng), Cint, (png_const_structrp, png_inforp, Ptr{png_textp}, Ptr{Cint}), png_ptr, info_ptr, text_ptr, num_text)
end

function png_set_text(png_ptr, info_ptr, text_ptr, num_text)
    ccall((:png_set_text, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_textp, Cint), png_ptr, info_ptr, text_ptr, num_text)
end

function png_get_tIME(png_ptr, info_ptr, mod_time)
    ccall((:png_get_tIME, libpng), png_uint_32, (png_const_structrp, png_inforp, Ptr{png_timep}), png_ptr, info_ptr, mod_time)
end

function png_set_tIME(png_ptr, info_ptr, mod_time)
    ccall((:png_set_tIME, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_timep), png_ptr, info_ptr, mod_time)
end

function png_get_tRNS(png_ptr, info_ptr, trans_alpha, num_trans, trans_color)
    ccall((:png_get_tRNS, libpng), png_uint_32, (png_const_structrp, png_inforp, Ptr{png_bytep}, Ptr{Cint}, Ptr{png_color_16p}), png_ptr, info_ptr, trans_alpha, num_trans, trans_color)
end

function png_set_tRNS(png_ptr, info_ptr, trans_alpha, num_trans, trans_color)
    ccall((:png_set_tRNS, libpng), Cvoid, (png_structrp, png_inforp, png_const_bytep, Cint, png_const_color_16p), png_ptr, info_ptr, trans_alpha, num_trans, trans_color)
end

function png_get_sCAL(png_ptr, info_ptr, unit, width, height)
    ccall((:png_get_sCAL, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{Cint}, Ptr{Cdouble}, Ptr{Cdouble}), png_ptr, info_ptr, unit, width, height)
end

function png_get_sCAL_fixed(png_ptr, info_ptr, unit, width, height)
    ccall((:png_get_sCAL_fixed, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{Cint}, Ptr{png_fixed_point}, Ptr{png_fixed_point}), png_ptr, info_ptr, unit, width, height)
end

function png_get_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight)
    ccall((:png_get_sCAL_s, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{Cint}, png_charpp, png_charpp), png_ptr, info_ptr, unit, swidth, sheight)
end

function png_set_sCAL(png_ptr, info_ptr, unit, width, height)
    ccall((:png_set_sCAL, libpng), Cvoid, (png_const_structrp, png_inforp, Cint, Cdouble, Cdouble), png_ptr, info_ptr, unit, width, height)
end

function png_set_sCAL_fixed(png_ptr, info_ptr, unit, width, height)
    ccall((:png_set_sCAL_fixed, libpng), Cvoid, (png_const_structrp, png_inforp, Cint, png_fixed_point, png_fixed_point), png_ptr, info_ptr, unit, width, height)
end

function png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight)
    ccall((:png_set_sCAL_s, libpng), Cvoid, (png_const_structrp, png_inforp, Cint, png_const_charp, png_const_charp), png_ptr, info_ptr, unit, swidth, sheight)
end

function png_set_keep_unknown_chunks(png_ptr, keep, chunk_list, num_chunks)
    ccall((:png_set_keep_unknown_chunks, libpng), Cvoid, (png_structrp, Cint, png_const_bytep, Cint), png_ptr, keep, chunk_list, num_chunks)
end

function png_handle_as_unknown(png_ptr, chunk_name)
    ccall((:png_handle_as_unknown, libpng), Cint, (png_const_structrp, png_const_bytep), png_ptr, chunk_name)
end

function png_set_unknown_chunks(png_ptr, info_ptr, unknowns, num_unknowns)
    ccall((:png_set_unknown_chunks, libpng), Cvoid, (png_const_structrp, png_inforp, png_const_unknown_chunkp, Cint), png_ptr, info_ptr, unknowns, num_unknowns)
end

function png_set_unknown_chunk_location(png_ptr, info_ptr, chunk, location)
    ccall((:png_set_unknown_chunk_location, libpng), Cvoid, (png_const_structrp, png_inforp, Cint, Cint), png_ptr, info_ptr, chunk, location)
end

function png_get_unknown_chunks(png_ptr, info_ptr, entries)
    ccall((:png_get_unknown_chunks, libpng), Cint, (png_const_structrp, png_inforp, png_unknown_chunkpp), png_ptr, info_ptr, entries)
end

function png_set_invalid(png_ptr, info_ptr, mask)
    ccall((:png_set_invalid, libpng), Cvoid, (png_const_structrp, png_inforp, Cint), png_ptr, info_ptr, mask)
end

function png_read_png(png_ptr, info_ptr, transforms, params)
    ccall((:png_read_png, libpng), Cvoid, (png_structrp, png_inforp, Cint, png_voidp), png_ptr, info_ptr, transforms, params)
end

function png_write_png(png_ptr, info_ptr, transforms, params)
    ccall((:png_write_png, libpng), Cvoid, (png_structrp, png_inforp, Cint, png_voidp), png_ptr, info_ptr, transforms, params)
end

function png_get_copyright(png_ptr)
    ccall((:png_get_copyright, libpng), png_const_charp, (png_const_structrp,), png_ptr)
end

function png_get_header_ver(png_ptr)
    ccall((:png_get_header_ver, libpng), png_const_charp, (png_const_structrp,), png_ptr)
end

function png_get_header_version(png_ptr)
    ccall((:png_get_header_version, libpng), png_const_charp, (png_const_structrp,), png_ptr)
end

function png_get_libpng_ver(png_ptr)
    ccall((:png_get_libpng_ver, libpng), png_const_charp, (png_const_structrp,), png_ptr)
end

function png_permit_mng_features(png_ptr, mng_features_permitted)
    ccall((:png_permit_mng_features, libpng), png_uint_32, (png_structrp, png_uint_32), png_ptr, mng_features_permitted)
end

function png_set_user_limits(png_ptr, user_width_max, user_height_max)
    ccall((:png_set_user_limits, libpng), Cvoid, (png_structrp, png_uint_32, png_uint_32), png_ptr, user_width_max, user_height_max)
end

function png_get_user_width_max(png_ptr)
    ccall((:png_get_user_width_max, libpng), png_uint_32, (png_const_structrp,), png_ptr)
end

function png_get_user_height_max(png_ptr)
    ccall((:png_get_user_height_max, libpng), png_uint_32, (png_const_structrp,), png_ptr)
end

function png_set_chunk_cache_max(png_ptr, user_chunk_cache_max)
    ccall((:png_set_chunk_cache_max, libpng), Cvoid, (png_structrp, png_uint_32), png_ptr, user_chunk_cache_max)
end

function png_get_chunk_cache_max(png_ptr)
    ccall((:png_get_chunk_cache_max, libpng), png_uint_32, (png_const_structrp,), png_ptr)
end

function png_set_chunk_malloc_max(png_ptr, user_chunk_cache_max)
    ccall((:png_set_chunk_malloc_max, libpng), Cvoid, (png_structrp, png_alloc_size_t), png_ptr, user_chunk_cache_max)
end

function png_get_chunk_malloc_max(png_ptr)
    ccall((:png_get_chunk_malloc_max, libpng), png_alloc_size_t, (png_const_structrp,), png_ptr)
end

function png_get_pixels_per_inch(png_ptr, info_ptr)
    ccall((:png_get_pixels_per_inch, libpng), png_uint_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_x_pixels_per_inch(png_ptr, info_ptr)
    ccall((:png_get_x_pixels_per_inch, libpng), png_uint_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_y_pixels_per_inch(png_ptr, info_ptr)
    ccall((:png_get_y_pixels_per_inch, libpng), png_uint_32, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_x_offset_inches(png_ptr, info_ptr)
    ccall((:png_get_x_offset_inches, libpng), Cfloat, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_x_offset_inches_fixed(png_ptr, info_ptr)
    ccall((:png_get_x_offset_inches_fixed, libpng), png_fixed_point, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_y_offset_inches(png_ptr, info_ptr)
    ccall((:png_get_y_offset_inches, libpng), Cfloat, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_y_offset_inches_fixed(png_ptr, info_ptr)
    ccall((:png_get_y_offset_inches_fixed, libpng), png_fixed_point, (png_const_structrp, png_const_inforp), png_ptr, info_ptr)
end

function png_get_pHYs_dpi(png_ptr, info_ptr, res_x, res_y, unit_type)
    ccall((:png_get_pHYs_dpi, libpng), png_uint_32, (png_const_structrp, png_const_inforp, Ptr{png_uint_32}, Ptr{png_uint_32}, Ptr{Cint}), png_ptr, info_ptr, res_x, res_y, unit_type)
end

function png_get_io_state(png_ptr)
    ccall((:png_get_io_state, libpng), png_uint_32, (png_const_structrp,), png_ptr)
end

function png_get_io_chunk_type(png_ptr)
    ccall((:png_get_io_chunk_type, libpng), png_uint_32, (png_const_structrp,), png_ptr)
end

function png_get_uint_31(png_ptr, buf)
    ccall((:png_get_uint_31, libpng), png_uint_32, (png_const_structrp, png_const_bytep), png_ptr, buf)
end

function png_save_uint_32(buf, i)
    ccall((:png_save_uint_32, libpng), Cvoid, (png_bytep, png_uint_32), buf, i)
end

function png_save_int_32(buf, i)
    ccall((:png_save_int_32, libpng), Cvoid, (png_bytep, png_int_32), buf, i)
end

function png_save_uint_16(buf, i)
    ccall((:png_save_uint_16, libpng), Cvoid, (png_bytep, Cuint), buf, i)
end

function png_set_check_for_invalid_index(png_ptr, allowed)
    ccall((:png_set_check_for_invalid_index, libpng), Cvoid, (png_structrp, Cint), png_ptr, allowed)
end

function png_get_palette_max(png_ptr, info_ptr)
    ccall((:png_get_palette_max, libpng), Cint, (png_const_structp, png_const_infop), png_ptr, info_ptr)
end

const png_control = Cvoid

const png_controlp = Ptr{png_control}

struct __JL_Ctag_7
    opaque::png_controlp
    version::png_uint_32
    width::png_uint_32
    height::png_uint_32
    format::png_uint_32
    flags::png_uint_32
    colormap_entries::png_uint_32
    warning_or_error::png_uint_32
    message::NTuple{64, Cchar}
end
function Base.getproperty(x::Ptr{__JL_Ctag_7}, f::Symbol)
    f === :opaque && return Ptr{png_controlp}(x + 0)
    f === :version && return Ptr{png_uint_32}(x + 8)
    f === :width && return Ptr{png_uint_32}(x + 12)
    f === :height && return Ptr{png_uint_32}(x + 16)
    f === :format && return Ptr{png_uint_32}(x + 20)
    f === :flags && return Ptr{png_uint_32}(x + 24)
    f === :colormap_entries && return Ptr{png_uint_32}(x + 28)
    f === :warning_or_error && return Ptr{png_uint_32}(x + 32)
    f === :message && return Ptr{NTuple{64, Cchar}}(x + 36)
    return getfield(x, f)
end

function Base.getproperty(x::__JL_Ctag_7, f::Symbol)
    r = Ref{__JL_Ctag_7}(x)
    ptr = Base.unsafe_convert(Ptr{__JL_Ctag_7}, r)
    fptr = getproperty(ptr, f)
    GC.@preserve r unsafe_load(fptr)
end

function Base.setproperty!(x::Ptr{__JL_Ctag_7}, f::Symbol, v)
    unsafe_store!(getproperty(x, f), v)
end

const png_image = __JL_Ctag_7

const png_imagep = Ptr{__JL_Ctag_7}

function png_image_begin_read_from_file(image, file_name)
    ccall((:png_image_begin_read_from_file, libpng), Cint, (png_imagep, Cstring), image, file_name)
end

function png_image_begin_read_from_stdio(image, file)
    ccall((:png_image_begin_read_from_stdio, libpng), Cint, (png_imagep, Ptr{Libc.FILE}), image, file)
end

function png_image_begin_read_from_memory(image, memory, size)
    ccall((:png_image_begin_read_from_memory, libpng), Cint, (png_imagep, png_const_voidp, Csize_t), image, memory, size)
end

function png_image_finish_read(image, background, buffer, row_stride, colormap)
    ccall((:png_image_finish_read, libpng), Cint, (png_imagep, png_const_colorp, Ptr{Cvoid}, png_int_32, Ptr{Cvoid}), image, background, buffer, row_stride, colormap)
end

function png_image_free(image)
    ccall((:png_image_free, libpng), Cvoid, (png_imagep,), image)
end

function png_image_write_to_file(image, file, convert_to_8bit, buffer, row_stride, colormap)
    ccall((:png_image_write_to_file, libpng), Cint, (png_imagep, Cstring, Cint, Ptr{Cvoid}, png_int_32, Ptr{Cvoid}), image, file, convert_to_8bit, buffer, row_stride, colormap)
end

function png_image_write_to_stdio(image, file, convert_to_8_bit, buffer, row_stride, colormap)
    ccall((:png_image_write_to_stdio, libpng), Cint, (png_imagep, Ptr{Libc.FILE}, Cint, Ptr{Cvoid}, png_int_32, Ptr{Cvoid}), image, file, convert_to_8_bit, buffer, row_stride, colormap)
end

function png_image_write_to_memory(image, memory, memory_bytes, convert_to_8_bit, buffer, row_stride, colormap)
    ccall((:png_image_write_to_memory, libpng), Cint, (png_imagep, Ptr{Cvoid}, Ptr{png_alloc_size_t}, Cint, Ptr{Cvoid}, png_int_32, Ptr{Cvoid}), image, memory, memory_bytes, convert_to_8_bit, buffer, row_stride, colormap)
end

function png_set_option(png_ptr, option, onoff)
    ccall((:png_set_option, libpng), Cint, (png_structrp, Cint, Cint), png_ptr, option, onoff)
end

const PNG_LIBPNG_VER_STRING = "1.6.37"

const PNG_HEADER_VERSION_STRING = " libpng version 1.6.37 - April 14, 2019\n"

const PNG_LIBPNG_VER_SONUM = 16

const PNG_LIBPNG_VER_DLLNUM = 16

const PNG_LIBPNG_VER_MAJOR = 1

const PNG_LIBPNG_VER_MINOR = 6

const PNG_LIBPNG_VER_RELEASE = 37

const PNG_LIBPNG_VER_BUILD = 0

const PNG_LIBPNG_BUILD_ALPHA = 1

const PNG_LIBPNG_BUILD_BETA = 2

const PNG_LIBPNG_BUILD_RC = 3

const PNG_LIBPNG_BUILD_STABLE = 4

const PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK = 7

const PNG_LIBPNG_BUILD_PATCH = 8

const PNG_LIBPNG_BUILD_PRIVATE = 16

const PNG_LIBPNG_BUILD_SPECIAL = 32

const PNG_LIBPNG_BUILD_BASE_TYPE = PNG_LIBPNG_BUILD_STABLE

const PNG_LIBPNG_VER = 10637

const PNG_API_RULE = 0

const PNG_DEFAULT_READ_MACROS = 1

const PNG_GAMMA_THRESHOLD_FIXED = 5000

const PNG_INFLATE_BUF_SIZE = 1024

# Skipping MacroDefinition: PNG_LINKAGE_API extern

# Skipping MacroDefinition: PNG_LINKAGE_CALLBACK extern

# Skipping MacroDefinition: PNG_LINKAGE_DATA extern

# Skipping MacroDefinition: PNG_LINKAGE_FUNCTION extern

const PNG_MAX_GAMMA_8 = 11

const PNG_QUANTIZE_BLUE_BITS = 5

const PNG_QUANTIZE_GREEN_BITS = 5

const PNG_QUANTIZE_RED_BITS = 5

const PNG_TEXT_Z_DEFAULT_COMPRESSION = -1

const PNG_TEXT_Z_DEFAULT_STRATEGY = 0

const PNG_USER_CHUNK_CACHE_MAX = 1000

const PNG_USER_CHUNK_MALLOC_MAX = 8000000

const PNG_USER_HEIGHT_MAX = 1000000

const PNG_USER_WIDTH_MAX = 1000000

const PNG_ZBUF_SIZE = 8192

const PNG_ZLIB_VERNUM = 0x12b0

const PNG_Z_DEFAULT_COMPRESSION = -1

const PNG_Z_DEFAULT_NOFILTER_STRATEGY = 0

const PNG_Z_DEFAULT_STRATEGY = 1

const PNG_sCAL_PRECISION = 5

const PNG_sRGB_PROFILE_CHECKS = 2

# Skipping MacroDefinition: PNG_CONST const

const PNGCBAPI = PNGCAPI

const PNGAPI = PNGCAPI

# Skipping MacroDefinition: PNG_USE_RESULT __attribute__ ( ( __warn_unused_result__ ) )

# Skipping MacroDefinition: PNG_NORETURN __attribute__ ( ( __noreturn__ ) )

# Skipping MacroDefinition: PNG_ALLOCATED __attribute__ ( ( __malloc__ ) )

# Skipping MacroDefinition: PNG_DEPRECATED __attribute__ ( ( __deprecated__ ) )

# Skipping MacroDefinition: PNG_PRIVATE __attribute__ ( ( __unavailable__ ( "This function is not exported by libpng." ) ) )

const PNG_LIBPNG_BUILD_TYPE = PNG_LIBPNG_BUILD_BASE_TYPE

const PNG_TEXT_COMPRESSION_NONE_WR = -3

const PNG_TEXT_COMPRESSION_zTXt_WR = -2

const PNG_TEXT_COMPRESSION_NONE = -1

const PNG_TEXT_COMPRESSION_zTXt = 0

const PNG_ITXT_COMPRESSION_NONE = 1

const PNG_ITXT_COMPRESSION_zTXt = 2

const PNG_TEXT_COMPRESSION_LAST = 3

const PNG_HAVE_IHDR = 0x01

const PNG_HAVE_PLTE = 0x02

const PNG_AFTER_IDAT = 0x08

const PNG_UINT_31_MAX = png_uint_32(Clong(0x7fffffff))

const PNG_FP_1 = 100000

const PNG_FP_HALF = 50000

const PNG_FP_MAX = png_fixed_point(Clong(0x7fffffff))

const PNG_FP_MIN = -PNG_FP_MAX

const PNG_COLOR_MASK_PALETTE = 1

const PNG_COLOR_MASK_COLOR = 2

const PNG_COLOR_MASK_ALPHA = 4

const PNG_COLOR_TYPE_GRAY = 0

const PNG_COLOR_TYPE_PALETTE = PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE

const PNG_COLOR_TYPE_RGB = PNG_COLOR_MASK_COLOR

const PNG_COLOR_TYPE_RGB_ALPHA = PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA

const PNG_COLOR_TYPE_GRAY_ALPHA = PNG_COLOR_MASK_ALPHA

const PNG_COLOR_TYPE_RGBA = PNG_COLOR_TYPE_RGB_ALPHA

const PNG_COLOR_TYPE_GA = PNG_COLOR_TYPE_GRAY_ALPHA

const PNG_COMPRESSION_TYPE_BASE = 0

const PNG_COMPRESSION_TYPE_DEFAULT = PNG_COMPRESSION_TYPE_BASE

const PNG_FILTER_TYPE_BASE = 0

const PNG_INTRAPIXEL_DIFFERENCING = 64

const PNG_FILTER_TYPE_DEFAULT = PNG_FILTER_TYPE_BASE

const PNG_INTERLACE_NONE = 0

const PNG_INTERLACE_ADAM7 = 1

const PNG_INTERLACE_LAST = 2

const PNG_OFFSET_PIXEL = 0

const PNG_OFFSET_MICROMETER = 1

const PNG_OFFSET_LAST = 2

const PNG_EQUATION_LINEAR = 0

const PNG_EQUATION_BASE_E = 1

const PNG_EQUATION_ARBITRARY = 2

const PNG_EQUATION_HYPERBOLIC = 3

const PNG_EQUATION_LAST = 4

const PNG_SCALE_UNKNOWN = 0

const PNG_SCALE_METER = 1

const PNG_SCALE_RADIAN = 2

const PNG_SCALE_LAST = 3

const PNG_RESOLUTION_UNKNOWN = 0

const PNG_RESOLUTION_METER = 1

const PNG_RESOLUTION_LAST = 2

const PNG_sRGB_INTENT_PERCEPTUAL = 0

const PNG_sRGB_INTENT_RELATIVE = 1

const PNG_sRGB_INTENT_SATURATION = 2

const PNG_sRGB_INTENT_ABSOLUTE = 3

const PNG_sRGB_INTENT_LAST = 4

const PNG_KEYWORD_MAX_LENGTH = 79

const PNG_MAX_PALETTE_LENGTH = 256

const PNG_INFO_gAMA = Cuint(0x0001)

const PNG_INFO_sBIT = Cuint(0x0002)

const PNG_INFO_cHRM = Cuint(0x0004)

const PNG_INFO_PLTE = Cuint(0x0008)

const PNG_INFO_tRNS = Cuint(0x0010)

const PNG_INFO_bKGD = Cuint(0x0020)

const PNG_INFO_hIST = Cuint(0x0040)

const PNG_INFO_pHYs = Cuint(0x0080)

const PNG_INFO_oFFs = Cuint(0x0100)

const PNG_INFO_tIME = Cuint(0x0200)

const PNG_INFO_pCAL = Cuint(0x0400)

const PNG_INFO_sRGB = Cuint(0x0800)

const PNG_INFO_iCCP = Cuint(0x1000)

const PNG_INFO_sPLT = Cuint(0x2000)

const PNG_INFO_sCAL = Cuint(0x4000)

const PNG_INFO_IDAT = Cuint(0x8000)

const PNG_INFO_eXIf = Cuint(0x00010000)

const PNG_TRANSFORM_IDENTITY = 0x0000

const PNG_TRANSFORM_STRIP_16 = 0x0001

const PNG_TRANSFORM_STRIP_ALPHA = 0x0002

const PNG_TRANSFORM_PACKING = 0x0004

const PNG_TRANSFORM_PACKSWAP = 0x0008

const PNG_TRANSFORM_EXPAND = 0x0010

const PNG_TRANSFORM_INVERT_MONO = 0x0020

const PNG_TRANSFORM_SHIFT = 0x0040

const PNG_TRANSFORM_BGR = 0x0080

const PNG_TRANSFORM_SWAP_ALPHA = 0x0100

const PNG_TRANSFORM_SWAP_ENDIAN = 0x0200

const PNG_TRANSFORM_INVERT_ALPHA = 0x0400

const PNG_TRANSFORM_STRIP_FILLER = 0x0800

const PNG_TRANSFORM_STRIP_FILLER_BEFORE = PNG_TRANSFORM_STRIP_FILLER

const PNG_TRANSFORM_STRIP_FILLER_AFTER = 0x1000

const PNG_TRANSFORM_GRAY_TO_RGB = 0x2000

const PNG_TRANSFORM_EXPAND_16 = 0x4000

const PNG_TRANSFORM_SCALE_16 = 0x8000

const PNG_FLAG_MNG_EMPTY_PLTE = 0x01

const PNG_FLAG_MNG_FILTER_64 = 0x04

const PNG_ALL_MNG_FEATURES = 0x05

const PNG_ERROR_ACTION_NONE = 1

const PNG_ERROR_ACTION_WARN = 2

const PNG_ERROR_ACTION_ERROR = 3

const PNG_RGB_TO_GRAY_DEFAULT = -1

const PNG_ALPHA_PNG = 0

const PNG_ALPHA_STANDARD = 1

const PNG_ALPHA_ASSOCIATED = 1

const PNG_ALPHA_PREMULTIPLIED = 1

const PNG_ALPHA_OPTIMIZED = 2

const PNG_ALPHA_BROKEN = 3

const PNG_DEFAULT_sRGB = -1

const PNG_GAMMA_MAC_18 = -2

const PNG_GAMMA_sRGB = 220000

const PNG_GAMMA_LINEAR = PNG_FP_1

const PNG_FILLER_BEFORE = 0

const PNG_FILLER_AFTER = 1

const PNG_BACKGROUND_GAMMA_UNKNOWN = 0

const PNG_BACKGROUND_GAMMA_SCREEN = 1

const PNG_BACKGROUND_GAMMA_FILE = 2

const PNG_BACKGROUND_GAMMA_UNIQUE = 3

const PNG_GAMMA_THRESHOLD = PNG_GAMMA_THRESHOLD_FIXED * 1.0e-5

const PNG_CRC_DEFAULT = 0

const PNG_CRC_ERROR_QUIT = 1

const PNG_CRC_WARN_DISCARD = 2

const PNG_CRC_WARN_USE = 3

const PNG_CRC_QUIET_USE = 4

const PNG_CRC_NO_CHANGE = 5

const PNG_NO_FILTERS = 0x00

const PNG_FILTER_NONE = 0x08

const PNG_FILTER_SUB = 0x10

const PNG_FILTER_UP = 0x20

const PNG_FILTER_AVG = 0x40

const PNG_FILTER_PAETH = 0x80

const PNG_FAST_FILTERS = (PNG_FILTER_NONE | PNG_FILTER_SUB) | PNG_FILTER_UP

const PNG_ALL_FILTERS = (PNG_FAST_FILTERS | PNG_FILTER_AVG) | PNG_FILTER_PAETH

const PNG_FILTER_VALUE_NONE = 0

const PNG_FILTER_VALUE_SUB = 1

const PNG_FILTER_VALUE_UP = 2

const PNG_FILTER_VALUE_AVG = 3

const PNG_FILTER_VALUE_PAETH = 4

const PNG_FILTER_VALUE_LAST = 5

const PNG_FILTER_HEURISTIC_DEFAULT = 0

const PNG_FILTER_HEURISTIC_UNWEIGHTED = 1

const PNG_FILTER_HEURISTIC_WEIGHTED = 2

const PNG_FILTER_HEURISTIC_LAST = 3

const PNG_DESTROY_WILL_FREE_DATA = 1

const PNG_SET_WILL_FREE_DATA = 1

const PNG_USER_WILL_FREE_DATA = 2

const PNG_FREE_HIST = Cuint(0x0008)

const PNG_FREE_ICCP = Cuint(0x0010)

const PNG_FREE_SPLT = Cuint(0x0020)

const PNG_FREE_ROWS = Cuint(0x0040)

const PNG_FREE_PCAL = Cuint(0x0080)

const PNG_FREE_SCAL = Cuint(0x0100)

const PNG_FREE_UNKN = Cuint(0x0200)

const PNG_FREE_PLTE = Cuint(0x1000)

const PNG_FREE_TRNS = Cuint(0x2000)

const PNG_FREE_TEXT = Cuint(0x4000)

const PNG_FREE_EXIF = Cuint(0x8000)

const PNG_FREE_ALL = Cuint(0xffff)

const PNG_FREE_MUL = Cuint(0x4220)

const PNG_HANDLE_CHUNK_AS_DEFAULT = 0

const PNG_HANDLE_CHUNK_NEVER = 1

const PNG_HANDLE_CHUNK_IF_SAFE = 2

const PNG_HANDLE_CHUNK_ALWAYS = 3

const PNG_HANDLE_CHUNK_LAST = 4

const PNG_IO_NONE = 0x0000

const PNG_IO_READING = 0x0001

const PNG_IO_WRITING = 0x0002

const PNG_IO_SIGNATURE = 0x0010

const PNG_IO_CHUNK_HDR = 0x0020

const PNG_IO_CHUNK_DATA = 0x0040

const PNG_IO_CHUNK_CRC = 0x0080

const PNG_IO_MASK_OP = 0x000f

const PNG_IO_MASK_LOC = 0x00f0

const PNG_INTERLACE_ADAM7_PASSES = 7

const PNG_IMAGE_VERSION = 1

const PNG_IMAGE_WARNING = 1

const PNG_IMAGE_ERROR = 2

const PNG_FORMAT_FLAG_ALPHA = Cuint(0x01)

const PNG_FORMAT_FLAG_COLOR = Cuint(0x02)

const PNG_FORMAT_FLAG_LINEAR = Cuint(0x04)

const PNG_FORMAT_FLAG_COLORMAP = Cuint(0x08)

const PNG_FORMAT_FLAG_BGR = Cuint(0x10)

const PNG_FORMAT_FLAG_AFIRST = Cuint(0x20)

const PNG_FORMAT_FLAG_ASSOCIATED_ALPHA = Cuint(0x40)

const PNG_FORMAT_GRAY = 0

const PNG_FORMAT_GA = PNG_FORMAT_FLAG_ALPHA

const PNG_FORMAT_AG = PNG_FORMAT_GA | PNG_FORMAT_FLAG_AFIRST

const PNG_FORMAT_RGB = PNG_FORMAT_FLAG_COLOR

const PNG_FORMAT_BGR = PNG_FORMAT_FLAG_COLOR | PNG_FORMAT_FLAG_BGR

const PNG_FORMAT_RGBA = PNG_FORMAT_RGB | PNG_FORMAT_FLAG_ALPHA

const PNG_FORMAT_ARGB = PNG_FORMAT_RGBA | PNG_FORMAT_FLAG_AFIRST

const PNG_FORMAT_BGRA = PNG_FORMAT_BGR | PNG_FORMAT_FLAG_ALPHA

const PNG_FORMAT_ABGR = PNG_FORMAT_BGRA | PNG_FORMAT_FLAG_AFIRST

const PNG_FORMAT_LINEAR_Y = PNG_FORMAT_FLAG_LINEAR

const PNG_FORMAT_LINEAR_Y_ALPHA = PNG_FORMAT_FLAG_LINEAR | PNG_FORMAT_FLAG_ALPHA

const PNG_FORMAT_LINEAR_RGB = PNG_FORMAT_FLAG_LINEAR | PNG_FORMAT_FLAG_COLOR

const PNG_FORMAT_LINEAR_RGB_ALPHA = (PNG_FORMAT_FLAG_LINEAR | PNG_FORMAT_FLAG_COLOR) | PNG_FORMAT_FLAG_ALPHA

const PNG_FORMAT_RGB_COLORMAP = PNG_FORMAT_RGB | PNG_FORMAT_FLAG_COLORMAP

const PNG_FORMAT_BGR_COLORMAP = PNG_FORMAT_BGR | PNG_FORMAT_FLAG_COLORMAP

const PNG_FORMAT_RGBA_COLORMAP = PNG_FORMAT_RGBA | PNG_FORMAT_FLAG_COLORMAP

const PNG_FORMAT_ARGB_COLORMAP = PNG_FORMAT_ARGB | PNG_FORMAT_FLAG_COLORMAP

const PNG_FORMAT_BGRA_COLORMAP = PNG_FORMAT_BGRA | PNG_FORMAT_FLAG_COLORMAP

const PNG_FORMAT_ABGR_COLORMAP = PNG_FORMAT_ABGR | PNG_FORMAT_FLAG_COLORMAP

const PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB = 0x01

const PNG_IMAGE_FLAG_FAST = 0x02

const PNG_IMAGE_FLAG_16BIT_sRGB = 0x04

const PNG_MAXIMUM_INFLATE_WINDOW = 2

const PNG_SKIP_sRGB_CHECK_PROFILE = 4

const PNG_IGNORE_ADLER32 = 8

const PNG_OPTION_NEXT = 12

const PNG_OPTION_UNSET = 0

const PNG_OPTION_INVALID = 1

const PNG_OPTION_OFF = 2

const PNG_OPTION_ON = 3


text:
module MLJOpenML

using OpenML
import OpenML: list_tags, list_datasets, describe_dataset, load

export OpenML

end # module


text:
import ITensors: product, position!, noiseterm

function product(P::ProjMPOSum, v::ITensor)::ITensor
  Pvs = fill(ITensor(), Threads.nthreads())
  Threads.@threads for M in P.pm
    Pvs[Threads.threadid()] += product(M, v)
  end
  return sum(Pvs)
end

function position!(P::ProjMPOSum, psi::MPS, pos::Int)
  Threads.@threads for M in P.pm
    position!(M, psi, pos)
  end
  return P
end

function noiseterm(P::ProjMPOSum, phi::ITensor, dir::String)
  nts = fill(ITensor(), Threads.nthreads())
  Threads.@threads for M in P.pm
    nts[Threads.threadid()] += noiseterm(M, phi, dir)
  end
  return sum(nts)
end


text:
using TuringCLIExample
TuringCLIExample.main(["--num_samples", "1000"])

max_stars_repo_name: HighDimensionalEconLab/TuringCLIExample

max_issues_repo_name: HighDimensionalEconLab/TuringCLIExample

max_forks_repo_name: HighDimensionalEconLab/TuringCLIExample


text:
"""
Constructor for data type ``Atom`` with
all keyword arguments.
Note that if the ``topology`` field is specified
than, the fields ``name``,
``alt_location``,
``insertion``,
``occupancy``,
``beta``,
``element``, and
``charge`` will be ignored,
because ``topology`` will overwrite these items.

Arguments
------------
index:Integer
    atom sequential index

atom_name:AbstractString
    raw atom name (with extra spaces if exist)

atom_type:AbstractString
    atom type

alt_location:Char
    alternative location indicator

insertion:Char
    insertion code according to PDB data format for ATOM

occupancy:AbstractFloat
    atom occupancy

beta:AbstractFloat
    temperature factor

element:AbstractString
    name of the chemical element for this atom

charge:Integer
    charge of the atom

residue_name:AbstractString
    residue name

residue_id:Integer
    residue ID

segment_name:AbstractString
    segment name

chain_name:AbstractString
    chain name

system_name:AbstractString
    molecular system name

coordinate:Array{AbstractFloat,1}
    atomic coordinate
"""
function Atom(;
    index::Integer=0,
    atom_name::AbstractString="",
    atom_type::AbstractString="",
    alt_location::Char=' ',
    insertion::Char=' ',
    occupancy::AbstractFloat=0.,
    beta::AbstractFloat=0.,
    element::AbstractString="",
    charge::Integer=0,
    coordinate::Array=Array{AbstractFloat,1}(),

    residue_name::AbstractString="",
    residue_id::Integer=0,
    segment_name::AbstractString="",
    chain_name::AbstractString="",
    system_name::AbstractString=""
    )
    return Atom(
        index,
        atom_name,
        atom_type,
        alt_location,
        insertion,
        occupancy,
        beta,
        element,
        charge,

        residue_name,
        residue_id,
        segment_name,
        chain_name,
        system_name,
        coordinate)
end


text:
"""Tendencies du,dv,dη of the non-diffusive right-hand side."""
function rhs!(du,dv,dη,u,v,η,Fx,f_q,H,η_ref,
            dvdx,dudy,dpdx,dpdy,
            p,u²,v²,KEu,KEv,dUdx,dVdy,
            h,h_u,h_v,h_q,U,V,U_v,V_u,
            qhv,qhu,q,q_u,q_v,
            qα,qβ,qγ,qδ)

    # layer thickness
    thickness!(h,η,H)
    Ix!(h_u,h)
    Iy!(h_v,h)

    # mass or volume flux U,V = uh,vh
    Uflux!(U,u,h_u)
    Vflux!(V,v,h_v)

    # divergence of mass flux
    ∂x!(dUdx,U)
    ∂y!(dVdy,V)

    # Bernoulli potential - recalculate for new η
    Bernoulli!(p,KEu,KEv,η)
    ∂x!(dpdx,p)
    ∂y!(dpdy,p)

    # Potential vorticity and advection thereof
    # PV is only updated outside
    PV_adv!(qhv,qhu,q,qα,qβ,qγ,qδ,q_u,q_v,U,V,V_u,U_v)

    # adding the terms
    momentum_u!(du,qhv,dpdx,Fx)
    momentum_v!(dv,qhu,dpdy)
    continuity!(dη,dUdx,dVdy,η,η_ref)
end

""" Update advective and Coriolis tendencies."""
function rhs_advcor!(u,v,η,H,h,h_u,h_v,h_q,U,V,dvdx,dudy,u²,v²,KEu,KEv,
                    q,f_q,qhv,qhu,qα,qβ,qγ,qδ,q_u,q_v,V_u,U_v)

    thickness!(h,η,H)
    Ixy!(h_q,h)

    # off-diagonals of stress tensor ∇(u,v), ∇(U,V)
    ∂x!(dvdx,v)
    ∂y!(dudy,u)

    # non-linear part of the Bernoulli potential
    speed!(u²,v²,u,v)
    Ix!(KEu,u²)
    Iy!(KEv,v²)

    # Potential vorticity update
    PV!(q,f_q,dvdx,dudy,h_q)

    # Linear combinations of the PV q
    if adv_scheme == "Sadourny"
        Iy!(q_u,q)
        Ix!(q_v,q)
    elseif adv_scheme == "ArakawaHsu"
        AHα!(qα,q)
        AHβ!(qβ,q)
        AHγ!(qγ,q)
        AHδ!(qδ,q)
    end
end

"""Layer thickness h obtained by adding sea surface height η to bottom height H."""
function thickness!(h,η,H)
    m,n = size(h)
    @boundscheck (m,n) == size(η) || throw(BoundsError())
    @boundscheck (m,n) == size(H) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            h[i,j] = η[i,j] + H[i,j]
        end
    end
end

"""Zonal mass flux U = uh."""
function Uflux!(U,u,h_u)
    m,n = size(U)
    @boundscheck (m,n) == size(h_u) || throw(BoundsError())
    @boundscheck (m+2+ep,n+2) == size(u) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            U[i,j] = u[1+ep+i,1+j]*h_u[i,j]
        end
    end
end

"""Meridional mass flux V = vh."""
function Vflux!(V,v,h_v)
    m,n = size(V)
    @boundscheck (m,n) == size(h_v) || throw(BoundsError())
    @boundscheck (m+2,n+2) == size(v) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            V[i,j] = v[i+1,j+1]*h_v[i,j]
        end
    end
end

"""Squared velocities u²,v²."""
function speed!(u²,v²,u,v)
    # u squared
    m,n = size(u²)
    @boundscheck (m,n) == size(u) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            u²[i,j] = u[i,j]^2
        end
    end

    # v squared
    m,n = size(v²)
    @boundscheck (m,n) == size(v) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            v²[i,j] = v[i,j]^2
        end
    end
end

"""Bernoulli potential p = 1/2*(u² + v²) + gη."""
function Bernoulli!(p,KEu,KEv,η)
    m,n = size(p)
    @boundscheck (m+ep,n+2) == size(KEu) || throw(BoundsError())
    @boundscheck (m+2,n) == size(KEv) || throw(BoundsError())
    @boundscheck (m,n) == size(η) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            p[i,j] = one_half*(KEu[i+ep,j+1] + KEv[i+1,j]) + g*η[i,j]
        end
    end
end

"""Sum up the tendencies of the non-diffusive right-hand side for the u-component."""
function momentum_u!(du,qhv,dpdx,Fx)
    m,n = size(du) .- (2*halo,2*halo) # cut off the halo
    @boundscheck (m,n) == size(qhv) || throw(BoundsError())
    @boundscheck (m+2-ep,n+2) == size(dpdx) || throw(BoundsError())
    @boundscheck (m,n) == size(Fx) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            du[i+2,j+2] = qhv[i,j] - dpdx[i+1-ep,j+1] + Fx[i,j]
        end
    end
end

"""Sum up the tendencies of the non-diffusive right-hand side for the v-component."""
function momentum_v!(dv,qhu,dpdy)
    m,n = size(dv) .- (2*halo,2*halo) # cut off the halo
    @boundscheck (m,n) == size(qhu) || throw(BoundsError())
    @boundscheck (m+2,n+2) == size(dpdy) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
             dv[i+2,j+2] = -qhu[i,j] - dpdy[i+1,j+1]
        end
    end
end

"""Continuity equation's right-hand side with surface relaxation
-∂x(uh) - ∂y(vh) + γ*(η_ref - η)."""
function continuity_surf_forc!(dη,dUdx,dVdy,η,η_ref)
    m,n = size(dη) .- (2*haloη,2*haloη)
    @boundscheck (m,n+2) == size(dUdx) || throw(BoundsError())
    @boundscheck (m+2,n) == size(dVdy) || throw(BoundsError())
    @boundscheck (m+2,n+2) == size(η) || throw(BoundsError())
    @boundscheck (m,n) == size(η_ref) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            dη[i+1,j+1] = -(dUdx[i,j+1] + dVdy[i+1,j]) + γ*(η_ref[i,j]-η[i+1,j+1])
        end
    end
end

"""Continuity equation's right-hand side -∂x(uh) - ∂y(vh) without forcing."""
function continuity_itself!(dη,dUdx,dVdy,η,η_ref)
    m,n = size(dη) .- (2*haloη,2*haloη)
    @boundscheck (m,n+2) == size(dUdx) || throw(BoundsError())
    @boundscheck (m+2,n) == size(dVdy) || throw(BoundsError())

    @inbounds for j ∈ 1:n
        for i ∈ 1:m
            dη[i+1,j+1] = -(dUdx[i,j+1] + dVdy[i+1,j])
        end
    end
end

if surface_forcing
    continuity! = continuity_surf_forc!
else
    continuity! = continuity_itself!
end

max_stars_repo_name: eschnett/juls

max_issues_repo_name: eschnett/juls

max_forks_repo_name: eschnett/juls


text:
module GEEBRA # general estimating equations with or without bias-reducting adjustments

@warn "As of version 0.1.1, GEEBRA will receive no further updates in the methods it provides. All methods in GEEBRA are available and will be maintained in the more extensive MEstimation (https://github.com/ikosmidis/MEstimation.jl) Julia package."

using NLsolve
using Optim
using FiniteDiff
using ForwardDiff
using LinearAlgebra
using Distributions

import Base: show, print
import StatsBase: fit, aic, vcov, coef, coeftable, stderror, CoefTable

export objective_function
export objective_function_template

export estimating_function
export get_estimating_function
export estimating_function_template

export aic
export tic
export vcov
export coef
export coeftable
export fit
export stderror

include("estimating_functions.jl")
include("objective_functions.jl")
include("fit.jl")
include("result_methods.jl")

end # module


text:
@testset "Geometric product" begin
    @test A * (B + C) ≈ A * B + A * C
    @test (B + C) * A ≈ B * A + C * A
    @test A * 1 == A
    @test A + (-A) ≈ zero(typeof(A))

    @test 1v1 * 1v3 == 1v13
    @test 1v3 * 1v1 == -1v13
    @test 1v3 * 1v2 * 1v1 == -1v123
    @test (1v1 + 2v2 + 1v12) * (1v1 + 1v3) == 1v + 1v13 - 2v12 + 2v23 - 1v2 + 1v123

    for r ∈ 0:4
        Aᵣ = As[r+1]
        for s ∈ 0:4
            Bₛ = Bs[s+1]
            res = Aᵣ * Bₛ
            contribs = map(k -> grade_projection(res, Val(abs(r - s) + 2k)), 0:(r + s - abs(r - s)) ÷ 2)
            @test res ≈ sum(contribs)
        end
    end
end


text:
"""
`FDHeatProblem` - Initalize the data structure
"""
function FDHeatProblem(a, b, nx, Δt, tmax, u0, bcl::PeriodicBC, bcr::PeriodicBC, ts::BEuler)
    Δx = (b-a)/(nx+1);
    x = LinRange(a, b, nx+2)[1:end-1];
    nΔt = Int(tmax/Δt)
    A = spzeros(nx+1, nx+1);
    rhs = zeros(nx+1);

    return FDHeatProblem(a, b, Δx, nx, x, Δt, nΔt, tmax, u0, A, rhs, bcl, bcr, ts)
end


text:
"""Loads an edge list file."""

function load_edge_list(path::String, dtype::Type=UInt32)
    edges = readdlm(path, dtype)
    return edges
end

function load_edge_list(path::String, n_edges::Int, dtype::Type=UInt32)
    edges = readdlm(path, dtype, dims=(n_edges, 2))
    return edges
end

max_stars_repo_name: quentin-burthier/GrandsGraphes

max_issues_repo_name: quentin-burthier/GrandsGraphes

max_forks_repo_name: quentin-burthier/GrandsGraphes


text:
using LinearAlgebra

struct ValueOne; end
ValueOne()

# Compute X <- a X + b I.
function matfun_axpby!(X,a,b,Y::UniformScaling)
    m,n=size(X)
    if ~(a isa ValueOne)
        rmul!(X,a)
    end
    @inbounds for i=1:n
        X[i,i]+=(b isa ValueOne) ? 1 : b
    end
end

# Compute X <- a X + b Y.
function matfun_axpby!(X,a,b,Y)
    m,n=size(X)
    if ~(a isa ValueOne)
        rmul!(X,a)
    end
    @inbounds for i=1:m
        @inbounds for j=1:n
            if (b isa ValueOne)
                X[i,j]+=Y[i,j]
            else
                X[i,j]+=b*Y[i,j]
            end
        end
    end
end

@inline function exp_sid_m7(A)
    T=promote_type(eltype(A),Float64)
    A_copy=similar(A,T); A_copy .= A;
    return exp_sid_m7!(A_copy)
end

@inline function exp_sid_m7!(A)
    T=promote_type(eltype(A),Float64) # Make it work for many 'bigger' types (matrices and scalars)
    # max_memslots=9
    n=size(A,1)
    # The first slots are precomputed nodes [:A]
    memslots2 = similar(A,T)
    memslots3 = similar(A,T)
    memslots4 = similar(A,T)
    memslots5 = similar(A,T)
    memslots6 = similar(A,T)
    memslots7 = similar(A,T)
    memslots8 = similar(A,T)
    memslots9 = similar(A,T)
    # Assign precomputed nodes memslots
    memslots1=A # overwrite A
    # Uniform scaling is exploited.
    # No matrix I explicitly allocated.
    value_one=ValueOne()
    # Computation order: B2 B3 B4 B5 Bb6 B6 Ba7 Bb7 B7 Ba8 Bb8_7 B8 T2k10
    # Computing B2 with operation: mult
    mul!(memslots2,memslots1,memslots1)
    # Computing B3 with operation: mult
    mul!(memslots3,memslots1,memslots2)
    # Computing B4 with operation: mult
    mul!(memslots4,memslots1,memslots3)
    # Computing B5 with operation: mult
    mul!(memslots5,memslots1,memslots4)
    # Computing Bb6 = x*A+x*B2+x*B3+x*B4+x*B5
    coeff1=1.313681421698863e-6
    coeff2=6.204734935438909e-8
    coeff3=2.957106114715868e-9
    coeff4=1.556371639324141e-10
    coeff5=1.556371639324141e-11
    memslots6 .= coeff1.*memslots1 .+ coeff2.*memslots2 .+ coeff3.*memslots3 .+ coeff4.*memslots4 .+ coeff5.*memslots5
    # Computing B6 with operation: mult
    mul!(memslots7,memslots5,memslots6)
    # Deallocating Bb6 in slot 6
    # Computing Ba7 = x*A+x*B2+x*B3+x*B4+x*B5+x*B6
    coeff1=5.951585263506065
    coeff2=0.4155284057336423
    coeff3=0.02479095151834799
    coeff4=0.001283057135586989
    coeff5=3.501669195497238e-5
    coeff6=1.0
    memslots6 .= coeff1.*memslots1 .+ coeff2.*memslots2 .+ coeff3.*memslots3 .+ coeff4.*memslots4 .+ coeff5.*memslots5 .+ coeff6.*memslots7
    # Computing Bb7 = x*B2+x*B3+x*B4+x*B5+x*B6
    coeff1=0.03306559506631931
    coeff2=0.002630043177655382
    coeff3=0.0002100333647757715
    coeff4=3.7537107416419e-5
    coeff5=1.0
    memslots8 .= coeff1.*memslots2 .+ coeff2.*memslots3 .+ coeff3.*memslots4 .+ coeff4.*memslots5 .+ coeff5.*memslots7
    # Computing B7 with operation: mult
    mul!(memslots9,memslots6,memslots8)
    # Deallocating Ba7 in slot 6
    # Deallocating Bb7 in slot 8
    # Computing Ba8 = x*A+x*B2+x*B3+x*B4+x*B5+x*B6+x*B7
    coeff1=11.10689398085882
    coeff2=2.991654767354374
    coeff3=0.2857950268422422
    coeff4=0.03005135891320298
    coeff5=0.002742336655922557
    coeff6=61.75954247606858
    coeff7=1.0
    # Smart lincomb recycle B7
    memslots9 .= coeff1.*memslots1 .+ coeff2.*memslots2 .+ coeff3.*memslots3 .+ coeff4.*memslots4 .+ coeff5.*memslots5 .+ coeff6.*memslots7 .+ coeff7.*memslots9
    # Computing Bb8_7 = x*A+x*B2+x*B3+x*B4+x*B5+x*B6
    coeff1=-0.000263823622233776
    coeff2=0.008139086096860678
    coeff3=0.001121744731945438
    coeff4=9.027588625491207e-5
    coeff5=8.572383602707347e-6
    coeff6=1.0
    # Smart lincomb recycle B6
    memslots7 .= coeff1.*memslots1 .+ coeff2.*memslots2 .+ coeff3.*memslots3 .+ coeff4.*memslots4 .+ coeff5.*memslots5 .+ coeff6.*memslots7
    # Computing B8 with operation: mult
    mul!(memslots6,memslots9,memslots7)
    # Deallocating Ba8 in slot 9
    # Deallocating Bb8_7 in slot 7
    # Computing T2k10 = x*I+x*A+x*B2+x*B3+x*B4+x*B5+x*B8
    coeff1=1.0
    coeff2=1.0
    coeff3=0.5029302610017967
    coeff4=0.07705596948494946
    coeff5=0.004985549176118462
    coeff6=6.263526066651383e-5
    coeff7=1.0
    # Smart lincomb recycle A
    memslots1 .= coeff2.*memslots1 .+ coeff3.*memslots2 .+ coeff4.*memslots3 .+ coeff5.*memslots4 .+ coeff6.*memslots5 .+ coeff7.*memslots6
    mul!(memslots1,true,I*coeff1,true,true)
    # Deallocating B2 in slot 2
    # Deallocating B3 in slot 3
    # Deallocating B4 in slot 4
    # Deallocating B5 in slot 5
    # Deallocating B8 in slot 6
    return memslots1 # Returning T2k10
end

max_stars_repo_name: matrixfunctions/GraphMatFunData

max_issues_repo_name: matrixfunctions/GraphMatFunData

max_forks_repo_name: matrixfunctions/GraphMatFunData


text:
"""
    GreedyIP(m::Int, s::Int)

 - `m` is the desired number of inducing points
 - `s` is the minibatch size on which to select a new inducing point

Greedy approach first proposed by Titsias[1].
Algorithm loops over minibatches of data and select the best ELBO improvement.

[1] Titsias, M. Variational Learning of Inducing Variables in Sparse Gaussian Processes. Aistats 5, 567–574 (2009).
"""
struct Greedy <: OffIPSA
    m::Int # Number of inducing points
    s::Int # Minibatch size for selection
    function Greedy(m, s)
        m > 0 || throw(ArgumentError("Number of inducing points should be positive"))
        s > 0 || throw(ArgumentError("Size of the minibatch should be positive"))
        return new(m, s)
    end
end

function inducingpoints(
    rng::AbstractRNG,
    alg::Greedy,
    X::AbstractVector;
    y,
    kernel::Kernel,
    noise::Real,
    kwargs...,
)
    noise > 0 || throw(ArgumentError("Noise should be positive"))
    length(X) == length(y) || throw(ArgumentError("y and X have different lengths"))
    if alg.m >= length(X)
        return edge_case(alg.m, length(X), X)
    end
    return greedy_ip(rng, X, y, kernel, alg.m, alg.s, noise)
end

Base.show(io::IO, ::Greedy) = print(io, "Greedy Selection of Inducing Points")

function greedy_ip(
    rng::AbstractRNG,
    X::AbstractVector,
    y::AbstractVector,
    kernel::Kernel,
    m::Int,
    s::Int,
    noise::Real,
)
    N = length(X) # Number of samples
    i = rand(rng, 1:N) # Take a random initial point
    Z = collect.(X[i:i]) # Initialize empty array of IPs
    IP_set = Set{Int}(i) # Keep track of selected points
    f = AbstractGPs.GP(kernel) # GP object to compute the elbo
    for _ in 2:m
        # Evaluate on a subset of the points of a maximum size of 1000
        X_test = Set(sample(rng, 1:N, min(1000, N); replace=false))
        best_i = 0
        best_L = -Inf
        # Parse over random points of this subset
        new_candidates = collect(setdiff(X_test, IP_set))
        # Sample a minibatch of candidates
        d = sample(
            rng,
            collect(setdiff(X_test, IP_set)),
            min(s, length(new_candidates));
            replace=false,
        )
        for j in d # Loop over every sample and evaluate the elbo addition with each new sample
            new_Z = vcat(Z, X[j:j])
            L = AbstractGPs.elbo(f(X[collect(X_test)], noise), y[collect(X_test)], f(new_Z))
            if L > best_L
                best_i = j
                best_L = L
            end
        end
        push!(Z, X[best_i])
        push!(IP_set, best_i)
    end
    return Z
end

# function elbo(Z::AbstractVector, X::AbstractVector, y::AbstractVector, kernel::Kernel, σ²::Real)
#     Knm = kernelmatrix(kernel, X, Z)
#     Kmm = kernelmatrix(kernel, Z) + T(jitt) * I
#     Qff = Knm * (Kmm \ Knm')
#     Kt = kerneldiagmatrix(kernel, X) .+ T(jitt) - diag(Qff)
#     Σ = inv(Kmm) + Knm' * Knm / σ²
#     invQnn = 1/σ² * I - 1/ (σ²)^2 * Knm * inv(Σ) * Knm'
#     logdetQnn = logdet(Σ) + logdet(Kmm)
#     return -0.5 * dot(y, invQnn * y) - 0.5 * logdetQnn -
#            1.0 / (2 * σ²) * sum(Kt)
# end


text:
type Token
    word::Int
    tag # ::Int
    head::Int
    label::Int
end

roottoken = Token(2, 1, 0, 1) # use PADDING

function normalize(word)
    w = lowercase(word)
    if w == "-lrb-"
        return "("
    elseif w == "-rrb-"
        return ")"
    else
        return w
    end
end

function readconll(parser::DepParser, path::AbstractString; train=true, cutoff=1)
    doc = Vector{Token}[]
    push!(doc, Token[])
    for line in open(readlines, path)
        line = chomp(line)
        if isempty(line)
            push!(doc, Token[])
        else
            items = split(line)
            word, tag, head, label = items[2], items[5], items[7], items[8]
            # word = replace(lowercase(word), r"\d", "0")
            word = normalize(word)
            wordid = get(parser.words, word, parser.words["UNKNOWN"])
            # cutoff
            # if !train && count(parser.words, wordid) <= cutoff
            #     wordid = parser.words["UNKNOWN"]
            # end
            tagid = train ? push!(parser.tags, tag) : parser.tags[tag]
            headid = parse(Int, head)
            labelid = train ? push!(parser.labels, label) : parser.labels[label]
            t = Token(wordid, tagid, headid, labelid)
            push!(doc[end], t)
        end
    end
    filter!(s -> length(s) > 0, doc)
    train && push!(parser.labels, "NONE")
    doc
end

function toconll(io::IO, parser::DepParser, sent::Vector{Token})
    for (id, t) in enumerate(sent)
        line = [id,
                getkey(parser.words, t.word),
                getkey(parser.tags, t.tag),
                getkey(parser.tags, t.tag),
                "-", "-",
                t.head,
                getkey(parser.labels, t.label),
                "-", "-"]
        println(io, join(line, "\t"))
    end
    println(io)
end
toconll(parser::DepParser, sent::Vector{Token}) = toconll(STDOUT, parser, sent)

function isprojective(sent::Vector{Token})
    counter = -1
    function visittree(w::Int)
        for i = 1:w-1
            if sent[i].head == w && !visittree(i)
                return false
            end
        end
        counter += 1
        w == counter || return false
        for i = w+1:length(sent)
            if sent[i].head == w && !visittree(i)
                return false
            end
        end
        return true
    end
    visittree(0)
end

function projectivize!(doc::Vector{Vector{Token}}, discard_nonprojective=false)
    discard = Int[]
    for i = 1:length(doc)
        if !projectivize!(doc[i], discard_nonprojective)
            push!(discard, i)
        end
    end
    for i in reverse(discard)
        splice!(doc, i)
    end
end

function projectivize!(sent::Vector{Token}, discard_nonprojective=false)
    ntokens = length(sent)
    left = Vector{Int}(ntokens)
    right = Vector{Int}(ntokens)

    while true
        fill!(left, 0)
        fill!(right, ntokens+1)

        for i = 1:ntokens
            headid = sent[i].head
            l = min(i, headid)
            r = max(i, headid)

            for j = l+1:r-1
                left[j] < l && ( left[j] = l )
                right[j] > r && ( right[j] = r )
            end
        end

        deepest_arc = 0
        max_depth = 0

        for i = 1:ntokens
            headid = sent[i].head
            headid == 0 && continue
            l = min(i, headid)
            r = max(i, headid)
            lbound = max(left[l], left[r])
            rbound = min(right[l], right[r])

            if l < lbound || r > rbound
                discard_nonprojective && return false
                depth = 0
                j = i
                while j != 0
                    depth += 1
                    j = sent[j].head
                end
                if depth > max_depth
                    deepest_arc = i
                    max_depth = depth
                end
            end
        end

        deepest_arc == 0 && return true
        lifted_head = sent[sent[deepest_arc].head].head
        sent[deepest_arc].head = lifted_head
    end
end

max_stars_repo_name: hshindo/JukaiNLP

max_issues_repo_name: hshindo/JukaiNLP

max_forks_repo_name: hshindo/JukaiNLP


text:
module TestConversions
    using Base.Test
    using DataArrays

    @assert isequal(@data([1, 2, NA]),
                    convert(DataArray, @pdata([1, 2, NA])))

    # Test vector() and matrix() conversion tools
    dv = @data ones(5)
    @assert isa(convert(Vector{Float64}, dv), Vector{Float64})
    dv[1] = NA
    # Should raise errors:
    # vector(dv)
    # convert(Vector{Float64}, dv)

    dm = @data ones(3, 3)
    @assert isa(convert(Matrix{Float64}, dm), Matrix{Float64})
    dm[1, 1] = NA
    # Should raise errors:
    # matrix(dm)
    # convert(Matrix{Float64}, dm)

    a = DataArray(Any,2)
    convert(DataArray{Integer}, a)
    a[1] = 2
    convert(DataArray{Integer}, a)
end


text:
abstract type RandomSampler <: Sampler end

struct RandomRatioSampler <: RandomSampler
    target_ratio::Real
    function RandomRatioSampler(target_ratio::Real)
        0 <= target_ratio <= 1 || throw(ArgumentError("Invalid sampling ratio $(target_ratio)."))
        return new(target_ratio)
    end
end

function sample(sampler::RandomRatioSampler, data::DataSet, labels::Vector{Symbol})::BitArray{1}
    return rand_sample(data, ceil(Int, sampler.target_ratio * length(labels)))
end

struct RandomNSampler <: RandomSampler
    n::Int
    function RandomNSampler(n::Int)
        n >= 0 || throw(ArgumentError("Invalid sampling amount $(n)."))
        return new(n)
    end
end

function sample(sampler::RandomNSampler, data::DataSet, labels::Vector{Symbol})::BitArray{1}
    return rand_sample(data, sampler.n)
end

function rand_sample(data::DataSet, n::Int)::BitArray{1}
    m = size(data, 2)
    sample_mask = falses(m)
    sample_mask[randperm(m)[1:n]] .= true
    return sample_mask
end


text:
@testset "formulate!" begin
    for method in (
        DisjunctiveConstraints.NaiveBigM(
            DisjunctiveConstraints.IntervalArithmetic(),
        ),
    )
        @testset "$method" begin
            form = _build_formulation_with_single_disjunction(method)
            @assert length(form.disjunction_formulaters) == 1
            formulater, _ = first(form.disjunction_formulaters)

            let node = Cerberus.Node()
                state = Cerberus.CurrentState()
                node_result = Cerberus.NodeResult(node)
                Cerberus.create_base_model!(state, form, node, CONFIG)
                Cerberus.apply_branchings!(state, node)
                @inferred Cerberus.formulate!(
                    state,
                    form,
                    formulater,
                    node,
                    node_result,
                    CONFIG,
                )
                x = [_SV(Cerberus.instantiate(_CVI(i), state)) for i in 1:5]
                @assert [v.variable.value for v in x] == collect(1:5)

                expected_bounds = [
                    (-1.5, 3.0),
                    (0.0, 0.5),
                    (0.0, 1.0),
                    (0.0, 1.0),
                    (0.0, 1.0),
                ]
                expected_et_acs =
                    [(1.0 * x[3] + 1.0 * x[4] + 1.0 * x[5], _ET(1.0))]
                expected_gt_acs = [
                    (1.0 * x[1] + 1.0 * x[2], _GT(-0.5)),
                    (1.0 * x[1] + 0.5 * x[3], _GT(-1.5)),
                    (1.0 * x[1] - 0.5 * x[4], _GT(-1.5)),
                    (1.0 * x[1] - 2.5 * x[5], _GT(-1.5)),
                    (1.0 * x[1] + 1.0 * x[2] - 0.5 * x[3], _GT(-1.5)),
                    (1.0 * x[2], _GT(0.0)),
                    (-1.0 * x[1] + 1.0 * x[2] - 2.0 * x[5], _GT(-3.0)),
                ]
                expected_lt_acs = [
                    (1.0 * x[1] + 4.0 * x[3], _LT(+3.0)),
                    (1.0 * x[1] + 2.0 * x[4], _LT(+3.0)),
                    (1.0 * x[1] + 1.0 * x[5], _LT(+3.0)),
                    (1.0 * x[1] + 1.0 * x[2] + 4.5 * x[3], _LT(+3.5)),
                    (1.0 * x[2] + 0.5 * x[4], _LT(0.5)),
                    (-1.0 * x[1] + 1.0 * x[2] + 3.0 * x[5], _LT(+2.0)),
                ]

                _test_roundtrip_model(
                    state.gurobi_model,
                    expected_bounds,
                    expected_lt_acs,
                    expected_gt_acs,
                    expected_et_acs,
                )

                disjunction_state = state.disjunction_state[formulater]
                @inferred Cerberus.delete_all_constraints!(
                    state.gurobi_model,
                    disjunction_state,
                )

                _test_roundtrip_model(
                    state.gurobi_model,
                    expected_bounds,
                    expected_lt_acs[1:0],
                    expected_gt_acs[1:1],
                    expected_et_acs,
                )
            end

            let node = Cerberus.Node(
                    [Cerberus.BoundUpdate(_CVI(3), _LT(0.0))],
                    Cerberus.BoundUpdate{_GT}[],
                    1,
                )
                state = Cerberus.CurrentState()
                node_result = Cerberus.NodeResult(node)
                # Instead of directly calling formulate!, do it through populate_lp_model!
                Cerberus.populate_lp_model!(
                    state,
                    form,
                    node,
                    node_result,
                    CONFIG,
                )
                x = [_SV(Cerberus.instantiate(_CVI(i), state)) for i in 1:5]
                @assert [v.variable.value for v in x] == collect(1:5)

                expected_bounds = [
                    (-1.5, 3.0),
                    (0.0, 0.5),
                    (0.0, 0.0),
                    (0.0, 1.0),
                    (0.0, 1.0),
                ]
                expected_et_acs =
                    [(1.0 * x[3] + 1.0 * x[4] + 1.0 * x[5], _ET(1.0))]
                expected_gt_acs = [
                    (1.0 * x[1] + 1.0 * x[2], _GT(-0.5)),
                    (1.0 * x[1] - 0.5 * x[4], _GT(-1.5)),
                    (1.0 * x[1] - 2.5 * x[5], _GT(-1.5)),
                    (1.0 * x[2], _GT(0.0)),
                    (-1.0 * x[1] + 1.0 * x[2] - 2.0 * x[5], _GT(-3.0)),
                ]
                expected_lt_acs = [
                    (1.0 * x[1] + 2.0 * x[4], _LT(+3.0)),
                    (1.0 * x[1] + 1.0 * x[5], _LT(+3.0)),
                    (1.0 * x[2] + 0.5 * x[4], _LT(0.5)),
                    (-1.0 * x[1] + 1.0 * x[2] + 3.0 * x[5], _LT(+2.0)),
                ]

                _test_roundtrip_model(
                    state.gurobi_model,
                    expected_bounds,
                    expected_lt_acs,
                    expected_gt_acs,
                    expected_et_acs,
                )

                disjunction_state = state.disjunction_state[formulater]
                @inferred Cerberus.delete_all_constraints!(
                    state.gurobi_model,
                    disjunction_state,
                )

                _test_roundtrip_model(
                    state.gurobi_model,
                    expected_bounds,
                    expected_lt_acs[1:0],
                    expected_gt_acs[1:1],
                    expected_et_acs,
                )
            end
        end
    end
    # TODO: Test cases where: 1) formulation is proven infeasible, and 2) disjunction is proven linear.
end


text:
mutable struct S a::Int64  end
function f(x) x.a end
f("foo")

max_stars_repo_name: gabriel-doriath-dohler/pjulia

max_issues_repo_name: gabriel-doriath-dohler/pjulia

max_forks_repo_name: gabriel-doriath-dohler/pjulia