text:
#addon.h
#=@getf mgl_difr_axial(a::Ptr{dual}, n::Cint, step::Cint, q::dual, Border::Cint, tmp::Ptr{dual}, kk::Cint, di::Cdouble)::Void=#
#=@getf mgl_difr_axial_old(a::Ptr{dual}, n::Cint, step::Cint, q::dual, Border::Cint, tmp1::Ptr{dual}, tmp2::Ptr{dual}, kk::Cint, di::Cdouble)::Void=#
#=@getf mgl_difr_grid(a::Ptr{dual}, n::Cint, step::Cint, q::dual, Border::Cint, tmp::Ptr{dual}, kk::Cint)::Void=#
#=@getf mgl_difr_grid_old(a::Ptr{dual}, n::Cint, step::Cint, q::dual, Border::Cint, tmp1::Ptr{dual}, tmp2::Ptr{dual}, kk::Cint)::Void=#

@getf lib mgl_gauss_rnd()::Cdouble
@getf lib mgl_fft_freq(freq::Ptr{Cdouble}, nn::Clong)::Void
@getf lib mgl_strcls(str::Ptr{Cchar})::Void
@getf lib mgl_strpos(str::Ptr{Cchar}, fnd::Ptr{Cchar})::Cint
@getf lib mgl_chrpos(str::Ptr{Cchar}, fnd::Cchar)::Cint
@getf lib mgl_fgetpar(fp::Ptr{FILE}, str::Ptr{Cchar})::Void
@getf lib mgl_istrue(ch::Cchar)::Cint
@getf lib mgl_test(str::Ptr{Cchar})::Void
@getf lib mgl_info(str::Ptr{Cchar})::Void

#base_cf.h
@getf lib mgl_get_warn(gr::HMGL)::Cint
@getf lib mgl_set_warn(gr::HMGL, code::Cint, text::Ptr{Cchar})::Void
@getf lib mgl_get_plotid(gr::HMGL)::Ptr{Cchar}
@getf lib mgl_set_plotid(gr::HMGL, id::Ptr{Cchar})::Void
@getf lib mgl_get_quality(gr::HMGL)::Cint
@getf lib mgl_set_quality(gr::HMGL, qual::Cint)::Void
@getf lib mgl_set_draw_reg(gr::HMGL, nx::Clong, ny::Clong, m::Clong)::Void
@getf lib mgl_is_frames(gr::HMGL)::Cint
@getf lib mgl_get_flag(gr::HMGL, flag::uint32_t)::Cint
@getf lib mgl_set_flag(gr::HMGL, val::Cint, flag::uint32_t)::Void
@getf lib mgl_use_graph(gr::HMGL, inc::Cint)::Clong
@getf lib mgl_set_rdc_acc(gr::HMGL, reduce::Cint)::Void
@getf lib mgl_start_group(gr::HMGL, name::Ptr{Cchar})::Void
@getf lib mgl_end_group(gr::HMGL)::Void
@getf lib mgl_highlight(gr::HMGL, id::Cint)::Void
@getf lib mgl_set_palette(gr::HMGL, colors::Ptr{Cchar})::Void
@getf lib mgl_set_color(id::Cchar, r::Cdouble, g::Cdouble, b::Cdouble)::Void
@getf lib mgl_set_def_sch(gr::HMGL, sch::Ptr{Cchar})::Void
@getf lib mgl_set_mask(id::Cchar, mask::Ptr{Cchar})::Void
@getf lib mgl_set_mask_val(id::Cchar, mask::Culonglong)::Void
@getf lib mgl_set_mask_angle(gr::HMGL, angle::Cint)::Void
@getf lib mgl_set_alpha_default(gr::HMGL, alpha::Cdouble)::Void
@getf lib mgl_set_bar_width(gr::HMGL, width::Cdouble)::Void
@getf lib mgl_set_meshnum(gr::HMGL, num::Cint)::Void
@getf lib mgl_set_facenum(gr::HMGL, num::Cint)::Void
@getf lib mgl_clear_unused(gr::HMGL)::Void
@getf lib mgl_set_ambbr(gr::HMGL, i::Cdouble)::Void
@getf lib mgl_set_difbr(gr::HMGL, i::Cdouble)::Void
@getf lib mgl_set_light_dif(gr::HMGL, enable::Cint)::Void
@getf lib mgl_set_cut(gr::HMGL, cut::Cint)::Void
@getf lib mgl_set_cut_box(gr::HMGL, x1::Cdouble, y1::Cdouble, z1::Cdouble, x2::Cdouble, y2::Cdouble, z2::Cdouble)::Void
@getf lib mgl_set_cutoff(gr::HMGL, EqC::Ptr{Cchar})::Void
@getf lib mgl_set_ranges(gr::HMGL, x1::Cdouble, x2::Cdouble, y1::Cdouble, y2::Cdouble, z1::Cdouble, z2::Cdouble)::Void
@getf lib mgl_set_range_val(gr::HMGL, dir::Cchar, v1::Cdouble, v2::Cdouble)::Void
@getf lib mgl_add_range_val(gr::HMGL, dir::Cchar, v1::Cdouble, v2::Cdouble)::Void
@getf lib mgl_set_range_dat(gr::HMGL, dir::Cchar, a::HCDT, add::Cint)::Void
@getf lib mgl_set_auto_ranges(gr::HMGL, x1::Cdouble, x2::Cdouble, y1::Cdouble, y2::Cdouble, z1::Cdouble, z2::Cdouble, c1::Cdouble, c2::Cdouble)::Void
@getf lib mgl_zoom_axis(gr::HMGL, x1::Cdouble, y1::Cdouble, z1::Cdouble, c1::Cdouble, x2::Cdouble, y2::Cdouble, z2::Cdouble, c2::Cdouble)::Void
@getf lib mgl_set_origin(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble)::Void
@getf lib mgl_set_func(gr::HMGL, EqX::Ptr{Cchar}, EqY::Ptr{Cchar}, EqZ::Ptr{Cchar}, EqA::Ptr{Cchar})::Void
@getf lib mgl_set_coor(gr::HMGL, how::Cint)::Void
@getf lib mgl_set_ternary(gr::HMGL, enable::Cint)::Void
@getf lib mgl_set_tick_rotate(gr::HMGL, enable::Cint)::Void
@getf lib mgl_set_tick_skip(gr::HMGL, enable::Cint)::Void
@getf lib mgl_def_font(name::Ptr{Cchar}, path::Ptr{Cchar})::Void
@getf lib mgl_set_mark_size(gr::HMGL, size::Cdouble)::Void
@getf lib mgl_set_arrow_size(gr::HMGL, size::Cdouble)::Void
@getf lib mgl_set_font_size(gr::HMGL, size::Cdouble)::Void
@getf lib mgl_set_font_def(gr::HMGL, fnt::Ptr{Cchar})::Void
@getf lib mgl_set_rotated_text(gr::HMGL, enable::Cint)::Void
@getf lib mgl_load_font(gr::HMGL, name::Ptr{Cchar}, path::Ptr{Cchar})::Void
@getf lib mgl_copy_font(gr::HMGL, gr_from::HMGL)::Void
@getf lib mgl_restore_font(gr::HMGL)::Void

#canvas_cf.h
@getf lib mgl_create_graph(width::Cint, height::Cint)::HMGL
@getf lib mgl_delete_graph(gr::HMGL)::Void
@getf lib mgl_set_size(gr::HMGL, width::Cint, height::Cint)::Void
@getf lib mgl_set_def_param(gr::HMGL)::Void
@getf lib mgl_combine_gr(gr::HMGL, gr2::HMGL)::Void
@getf lib mgl_finish(gr::HMGL)::Void
@getf lib mgl_set_tick_len(gr::HMGL, len::Cdouble, stt::Cdouble)::Void
@getf lib mgl_set_axis_stl(gr::HMGL, stl::Ptr{Cchar}, tck::Ptr{Cchar}, sub::Ptr{Cchar})::Void
@getf lib mgl_adjust_ticks(gr::HMGL, dir::Ptr{Cchar})::Void
@getf lib mgl_set_ticks(gr::HMGL, dir::Cchar, d::Cdouble, ns::Cint, org::Cdouble)::Void
@getf lib mgl_set_ticks_fact(gr::HMGL, dir::Cchar, d::Cdouble, ns::Cint, org::Cdouble, fact::Ptr{Cchar})::Void
@getf lib mgl_set_ticks_factw(gr::HMGL, dir::Cchar, d::Cdouble, ns::Cint, org::Cdouble, fact::Ptr{Cwchar_t})::Void
@getf lib mgl_set_ticks_str(gr::HMGL, dir::Cchar, lbl::Ptr{Cchar}, add::Cint)::Void
@getf lib mgl_set_ticks_wcs(gr::HMGL, dir::Cchar, lbl::Ptr{Cwchar_t}, add::Cint)::Void
@getf lib mgl_set_ticks_val(gr::HMGL, dir::Cchar, val::HCDT, lbl::Ptr{Cchar}, add::Cint)::Void
@getf lib mgl_set_ticks_valw(gr::HMGL, dir::Cchar, val::HCDT, lbl::Ptr{Cwchar_t}, add::Cint)::Void
@getf lib mgl_tune_ticks(gr::HMGL, tune::Cint, fact_pos::Cdouble)::Void
@getf lib mgl_set_tick_templ(gr::HMGL, dir::Cchar, templ::Ptr{Cchar})::Void
@getf lib mgl_set_tick_templw(gr::HMGL, dir::Cchar, templ::Ptr{Cwchar_t})::Void
@getf lib mgl_set_ticks_time(gr::HMGL, dir::Cchar, d::Cdouble, t::Ptr{Cchar})::Void
@getf lib mgl_set_tick_shift(gr::HMGL, sx::Cdouble, sy::Cdouble, sz::Cdouble, sc::Cdouble)::Void
@getf lib mgl_box(gr::HMGL)::Void
@getf lib mgl_box_str(gr::HMGL, col::Ptr{Cchar}, ticks::Cint)::Void
@getf lib mgl_axis(gr::HMGL, dir::Ptr{Cchar}, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_axis_grid(gr::HMGL, dir::Ptr{Cchar}, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_label(gr::HMGL, dir::Cchar, text::Ptr{Cchar}, pos::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_labelw(gr::HMGL, dir::Cchar, text::Ptr{Cwchar_t}, pos::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_colorbar(gr::HMGL, sch::Ptr{Cchar})::Void
@getf lib mgl_colorbar_ext(gr::HMGL, sch::Ptr{Cchar}, x::Cdouble, y::Cdouble, w::Cdouble, h::Cdouble)::Void
@getf lib mgl_colorbar_val(gr::HMGL, dat::HCDT, sch::Ptr{Cchar})::Void
@getf lib mgl_colorbar_val_ext(gr::HMGL, dat::HCDT, sch::Ptr{Cchar}, x::Cdouble, y::Cdouble, w::Cdouble, h::Cdouble)::Void
@getf lib mgl_add_legend(gr::HMGL, text::Ptr{Cchar}, style::Ptr{Cchar})::Void
@getf lib mgl_add_legendw(gr::HMGL, text::Ptr{Cwchar_t}, style::Ptr{Cchar})::Void
@getf lib mgl_clear_legend(gr::HMGL)::Void
@getf lib mgl_legend_pos(gr::HMGL, x::Cdouble, y::Cdouble, font::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_legend(gr::HMGL, where::Cint, font::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_set_legend_marks(gr::HMGL, num::Cint)::Void
@getf lib mgl_show_image(gr::HMGL, viewer::Ptr{Cchar}, keep::Cint)::Void
@getf lib mgl_write_frame(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_tga(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_bmp(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_jpg(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_png(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_png_solid(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_bps(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_eps(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_svg(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_tex(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_obj(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar}, use_png::Cint)::Void
@getf lib mgl_write_obj_old(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar}, use_png::Cint)::Void
@getf lib mgl_write_stl(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_off(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar}, colored::Cint)::Void
@getf lib mgl_write_xyz(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_wgl(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_prc(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar}, make_pdf::Cint)::Void
@getf lib mgl_write_gif(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_start_gif(gr::HMGL, fname::Ptr{Cchar}, ms::Cint)::Void
@getf lib mgl_close_gif(gr::HMGL)::Void
@getf lib mgl_export_mgld(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_import_mgld(gr::HMGL, fname::Ptr{Cchar}, add::Cint)::Void
@getf lib mgl_write_json(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_write_json_z(gr::HMGL, fname::Ptr{Cchar}, descr::Ptr{Cchar})::Void
@getf lib mgl_get_json(gr::HMGL)::Ptr{Char}
@getf lib mgl_get_rgb(gr::HMGL)::Ptr{UInt8}
@getf lib mgl_get_rgba(gr::HMGL)::Ptr{UInt8}
@getf lib mgl_set_obj_id(gr::HMGL, id::Cint)::Void
@getf lib mgl_get_obj_id(gr::HMGL, x::Cint, y::Cint)::Cint
@getf lib mgl_get_spl_id(gr::HMGL, x::Cint, y::Cint)::Cint
@getf lib mgl_get_width(gr::HMGL)::Cint
@getf lib mgl_get_height(gr::HMGL)::Cint
@getf lib mgl_calc_xyz(gr::HMGL, xs::Cint, ys::Cint, x::Ptr{Float}, y::Ptr{Float}, z::Ptr{Float})::Void
@getf lib mgl_calc_scr(gr::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, xs::Ptr{Cint}, ys::Ptr{Cint})::Void
@getf lib mgl_is_active(gr::HMGL, xs::Cint, ys::Cint, d::Cint)::Clong
@getf lib mgl_new_frame(gr::HMGL)::Cint
@getf lib mgl_end_frame(gr::HMGL)::Void
@getf lib mgl_get_num_frame(gr::HMGL)::Cint
@getf lib mgl_reset_frames(gr::HMGL)::Void
@getf lib mgl_get_frame(gr::HMGL, i::Cint)::Void
@getf lib mgl_set_frame(gr::HMGL, i::Cint)::Void
@getf lib mgl_show_frame(gr::HMGL, i::Cint)::Void
@getf lib mgl_del_frame(gr::HMGL, i::Cint)::Void
@getf lib mgl_set_transp_type(gr::HMGL, kind::Cint)::Void
@getf lib mgl_set_alpha(gr::HMGL, enable::Cint)::Void
@getf lib mgl_set_fog(gr::HMGL, d::Cdouble, dz::Cdouble)::Void
@getf lib mgl_set_light(gr::HMGL, enable::Cint)::Void
@getf lib mgl_set_light_n(gr::HMGL, n::Cint, enable::Cint)::Void
@getf lib mgl_add_light(gr::HMGL, n::Cint, x::Cdouble, y::Cdouble, z::Cdouble)::Void
@getf lib mgl_add_light_ext(gr::HMGL, n::Cint, x::Cdouble, y::Cdouble, z::Cdouble, c::Cchar, br::Cdouble, ap::Cdouble)::Void
@getf lib mgl_add_light_loc(gr::HMGL, n::Cint, x::Cdouble, y::Cdouble, z::Cdouble, dx::Cdouble, dy::Cdouble, dz::Cdouble, c::Cchar, br::Cdouble, ap::Cdouble)::Void
@getf lib mgl_mat_pop(gr::HMGL)::Void
@getf lib mgl_mat_push(gr::HMGL)::Void
@getf lib mgl_clf(gr::HMGL)::Void
@getf lib mgl_clf_str(gr::HMGL, col::Ptr{Cchar})::Void
@getf lib mgl_clf_rgb(gr::HMGL, r::Cdouble, g::Cdouble, b::Cdouble)::Void
@getf lib mgl_clf_chr(gr::HMGL, col::Cchar)::Void
@getf lib mgl_subplot(gr::HMGL, nx::Cint, ny::Cint, m::Cint, style::Ptr{Cchar})::Void
@getf lib mgl_subplot_d(gr::HMGL, nx::Cint, ny::Cint, m::Cint, style::Ptr{Cchar}, dx::Cdouble, dy::Cdouble)::Void
@getf lib mgl_multiplot(gr::HMGL, nx::Cint, ny::Cint, m::Cint, dx::Cint, dy::Cint, style::Ptr{Cchar})::Void
@getf lib mgl_inplot(gr::HMGL, x1::Cdouble, x2::Cdouble, y1::Cdouble, y2::Cdouble)::Void
@getf lib mgl_relplot(gr::HMGL, x1::Cdouble, x2::Cdouble, y1::Cdouble, y2::Cdouble)::Void
@getf lib mgl_columnplot(gr::HMGL, num::Cint, ind::Cint, d::Cdouble)::Void
@getf lib mgl_gridplot(gr::HMGL, nx::Cint, ny::Cint, m::Cint, d::Cdouble)::Void
@getf lib mgl_stickplot(gr::HMGL, num::Cint, ind::Cint, tet::Cdouble, phi::Cdouble)::Void
@getf lib mgl_title(gr::HMGL, title::Ptr{Cchar}, stl::Ptr{Cchar}, size::Cdouble)::Void
@getf lib mgl_titlew(gr::HMGL, title::Ptr{Cwchar_t}, stl::Ptr{Cchar}, size::Cdouble)::Void
@getf lib mgl_set_plotfactor(gr::HMGL, val::Cdouble)::Void
@getf lib mgl_aspect(gr::HMGL, Ax::Cdouble, Ay::Cdouble, Az::Cdouble)::Void
@getf lib mgl_rotate(gr::HMGL, TetX::Cdouble, TetZ::Cdouble, TetY::Cdouble)::Void
@getf lib mgl_rotate_vector(gr::HMGL, Tet::Cdouble, x::Cdouble, y::Cdouble, z::Cdouble)::Void
@getf lib mgl_perspective(gr::HMGL, val::Cdouble)::Void
@getf lib mgl_view(gr::HMGL, TetX::Cdouble, TetZ::Cdouble, TetY::Cdouble)::Void
@getf lib mgl_zoom(gr::HMGL, x1::Cdouble, y1::Cdouble, x2::Cdouble, y2::Cdouble)::Void
@getf lib mgl_draw_thr()::Void
@getf lib mgl_set_click_func(gr::HMGL, p::Ptr{Void})::Void
@getf lib mgl_wnd_set_delay(gr::HMGL, dt::Cdouble)::Void
@getf lib mgl_wnd_get_delay(gr::HMGL)::Cdouble
@getf lib mgl_setup_window(gr::HMGL, clf_upd::Cint, showpos::Cint)::Void
@getf lib mgl_wnd_toggle_alpha(gr::HMGL)::Void
@getf lib mgl_wnd_toggle_light(gr::HMGL)::Void
@getf lib mgl_wnd_toggle_zoom(gr::HMGL)::Void
@getf lib mgl_wnd_toggle_rotate(gr::HMGL)::Void
@getf lib mgl_wnd_toggle_no(gr::HMGL)::Void
@getf lib mgl_wnd_update(gr::HMGL)::Void
@getf lib mgl_wnd_reload(gr::HMGL)::Void
@getf lib mgl_wnd_adjust(gr::HMGL)::Void
@getf lib mgl_wnd_next_frame(gr::HMGL)::Void
@getf lib mgl_wnd_prev_frame(gr::HMGL)::Void
@getf lib mgl_wnd_animation(gr::HMGL)::Void
@getf lib mgl_get_last_mouse_pos(gr::HMGL, x::Ptr{Float}, y::Ptr{Float}, z::Ptr{Float})::Void
@getf lib mgl_create_parser()::HMPR
@getf lib mgl_use_parser(p::HMPR, inc::Cint)::Clong
@getf lib mgl_delete_parser(p::HMPR)::Void
@getf lib mgl_parser_add_param(p::HMPR, id::Cint, str::Ptr{Cchar})::Void
@getf lib mgl_parser_add_paramw(p::HMPR, id::Cint, str::Ptr{Cwchar_t})::Void
@getf lib mgl_parser_add_var(p::HMPR, name::Ptr{Cchar})::HMDT
@getf lib mgl_parser_add_varw(p::HMPR, name::Ptr{Cwchar_t})::HMDT
@getf lib mgl_parser_find_var(p::HMPR, name::Ptr{Cchar})::HMDT
@getf lib mgl_parser_find_varw(p::HMPR, name::Ptr{Cwchar_t})::HMDT
@getf lib mgl_parser_del_var(p::HMPR, name::Ptr{Cchar})::Void
@getf lib mgl_parser_del_varw(p::HMPR, name::Ptr{Cwchar_t})::Void
@getf lib mgl_parser_del_all(p::HMPR)::Void
@getf lib mgl_parse_line(gr::HMGL, p::HMPR, str::Ptr{Cchar}, pos::Cint)::Cint
@getf lib mgl_parse_linew(gr::HMGL, p::HMPR, str::Ptr{Cwchar_t}, pos::Cint)::Cint
@getf lib mgl_parse_file(gr::HMGL, p::HMPR, fp::Ptr{FILE}, print::Cint)::Void
@getf lib mgl_parse_text(gr::HMGL, p::HMPR, str::Ptr{Cchar})::Void
@getf lib mgl_parse_textw(gr::HMGL, p::HMPR, str::Ptr{Cwchar_t})::Void
@getf lib mgl_parser_restore_once(p::HMPR)::Void
@getf lib mgl_parser_allow_setsize(p::HMPR, a::Cint)::Void
@getf lib mgl_parser_allow_file_io(p::HMPR, a::Cint)::Void
@getf lib mgl_parser_stop(p::HMPR)::Void
@getf lib mgl_parser_cmd_type(pr::HMPR, name::Ptr{Cchar})::Cint
@getf lib mgl_parser_cmd_num(pr::HMPR)::Clong
@getf lib mgl_parser_calc(pr::HMPR, formula::Ptr{Cchar})::HMDT
@getf lib mgl_parser_calcw(pr::HMPR, formula::Ptr{Cwchar_t})::HMDT

#cont.h
@getf lib mgl_text_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, text::Ptr{Cchar}, font::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textw_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, text::Ptr{Cwchar_t}, font::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_text_xy(gr::HMGL, x::HCDT, y::HCDT, text::Ptr{Cchar}, font::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textw_xy(gr::HMGL, x::HCDT, y::HCDT, text::Ptr{Cwchar_t}, font::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_text_y(gr::HMGL, y::HCDT, text::Ptr{Cchar}, font::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textw_y(gr::HMGL, y::HCDT, text::Ptr{Cwchar_t}, font::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_gen(gr::HMGL, val::Cdouble, a::HCDT, x::HCDT, y::HCDT, z::HCDT, stl::Ptr{Cchar})::Void
@getf lib mgl_contf_gen(gr::HMGL, v1::Cdouble, v2::Cdouble, a::HCDT, x::HCDT, y::HCDT, z::HCDT, stl::Ptr{Cchar})::Void
@getf lib mgl_cont_xy_val(gr::HMGL, v::HCDT, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_val(gr::HMGL, v::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_xy(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_cont(gr::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_xy_val(gr::HMGL, v::HCDT, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_val(gr::HMGL, v::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_xy(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contf(gr::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contd_xy_val(gr::HMGL, v::HCDT, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contd_val(gr::HMGL, v::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contd_xy(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contd(gr::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contv_xy_val(gr::HMGL, v::HCDT, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contv_val(gr::HMGL, v::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contv_xy(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_contv(gr::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_axial_xy_val(gr::HMGL, v::HCDT, x::HCDT, y::HCDT, a::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_axial_val(gr::HMGL, v::HCDT, a::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_axial_xy(gr::HMGL, x::HCDT, y::HCDT, a::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_axial(gr::HMGL, a::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_torus(gr::HMGL, r::HCDT, z::HCDT, col::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_grid3_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_grid3(gr::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_dens3_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_dens3(gr::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont3_xyz_val(gr::HMGL, v::HCDT, x::HCDT, y::HCDT, z::HCDT, a::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont3_val(gr::HMGL, v::HCDT, a::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont3_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont3(gr::HMGL, a::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf3_xyz_val(gr::HMGL, v::HCDT, x::HCDT, y::HCDT, z::HCDT, a::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf3_val(gr::HMGL, v::HCDT, a::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf3_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf3(gr::HMGL, a::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void

#datac_cf.h
@getf lib mgl_srnd(seed::Clong)::Void
@getf lib mgl_rnd()::Cdouble
@getf lib mgl_ipowc(x::Dual, n::Cint)::Dual
@getf lib mgl_expi(a::Dual)::Dual
@getf lib mgl_create_datac()::HADT
@getf lib mgl_create_datac_size(nx::Clong, ny::Clong, nz::Clong)::HADT
@getf lib mgl_create_datac_file(fname::Ptr{Cchar})::HADT
@getf lib mgl_delete_datac(dat::HADT)::Void
@getf lib mgl_datac_rearrange(dat::HADT, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_datac_link(dat::HADT, A::Ptr{Dual}, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_datac_set_float(dat::HADT, A::Ptr{Cfloat}, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_datac_set_double(dat::HADT, A::Ptr{Cdouble}, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_datac_set_complex(dat::HADT, A::Ptr{Dual}, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_datac_set(dat::HADT, a::HCDT)::Void
@getf lib mgl_datac_set_vector(dat::HADT, v::Ptr{gsl_vector})::Void
@getf lib mgl_datac_set_matrix(dat::HADT, m::Ptr{gsl_matrix})::Void
@getf lib mgl_datac_set_value(dat::HADT, v::Dual, i::Clong, j::Clong, k::Clong)::Void
@getf lib mgl_datac_get_value(dat::HCDT, i::Clong, j::Clong, k::Clong)::Dual
@getf lib mgl_datac_set_values(dat::HADT, val::Ptr{Cchar}, nx::Clong, ny::Clong, nz::Clong)::Void
@getf lib mgl_datac_set_ri(dat::HADT, re::HCDT, im::HCDT)::Void
@getf lib mgl_datac_set_ap(dat::HADT, abs::HCDT, phi::HCDT)::Void
@getf lib mgl_datac_read(dat::HADT, fname::Ptr{Cchar})::Cint
@getf lib mgl_datac_read_mat(dat::HADT, fname::Ptr{Cchar}, dim::Clong)::Cint
@getf lib mgl_datac_read_dim(dat::HADT, fname::Ptr{Cchar}, mx::Clong, my::Clong, mz::Clong)::Cint
@getf lib mgl_datac_read_range(d::HADT, templ::Ptr{Cchar}, from::Cdouble, to::Cdouble, step::Cdouble, as_slice::Cint)::Cint
@getf lib mgl_datac_read_all(dat::HADT, templ::Ptr{Cchar}, as_slice::Cint)::Cint
@getf lib mgl_datac_save(dat::HCDT, fname::Ptr{Cchar}, ns::Clong)::Void
@getf lib mgl_datac_read_hdf(d::HADT, fname::Ptr{Cchar}, data::Ptr{Cchar})::Cint
@getf lib mgl_datac_save_hdf(d::HCDT, fname::Ptr{Cchar}, data::Ptr{Cchar}, rewrite::Cint)::Void
@getf lib mgl_datac_create(dat::HADT, nx::Clong, ny::Clong, nz::Clong)::Void
@getf lib mgl_datac_transpose(dat::HADT, dim::Ptr{Cchar})::Void
@getf lib mgl_datac_set_id(d::HADT, id::Ptr{Cchar})::Void
@getf lib mgl_datac_fill(dat::HADT, x1::Dual, x2::Dual, dir::Cchar)::Void
@getf lib mgl_datac_fill_eq(gr::HMGL, dat::HADT, eq::Ptr{Cchar}, vdat::HCDT, wdat::HCDT, opt::Ptr{Cchar})::Void
@getf lib mgl_datac_modify(dat::HADT, eq::Ptr{Cchar}, dim::Clong)::Void
@getf lib mgl_datac_modify_vw(dat::HADT, eq::Ptr{Cchar}, vdat::HCDT, wdat::HCDT)::Void
@getf lib mgl_datac_put_val(dat::HADT, val::Dual, i::Clong, j::Clong, k::Clong)::Void
@getf lib mgl_datac_put_dat(dat::HADT, val::HCDT, i::Clong, j::Clong, k::Clong)::Void
@getf lib mgl_datac_squeeze(dat::HADT, rx::Clong, ry::Clong, rz::Clong, smooth::Clong)::Void
@getf lib mgl_datac_extend(dat::HADT, n1::Clong, n2::Clong)::Void
@getf lib mgl_datac_insert(dat::HADT, dir::Cchar, at::Clong, num::Clong)::Void
@getf lib mgl_datac_delete(dat::HADT, dir::Cchar, at::Clong, num::Clong)::Void
@getf lib mgl_datac_join(dat::HADT, d::HCDT)::Void
@getf lib mgl_datac_smooth(d::HADT, dirs::Ptr{Cchar}, delta::Float)::Void
@getf lib mgl_datac_cumsum(dat::HADT, dir::Ptr{Cchar})::Void
@getf lib mgl_datac_integral(dat::HADT, dir::Ptr{Cchar})::Void
@getf lib mgl_datac_diff(dat::HADT, dir::Ptr{Cchar})::Void
@getf lib mgl_datac_diff2(dat::HADT, dir::Ptr{Cchar})::Void
@getf lib mgl_datac_swap(dat::HADT, dir::Ptr{Cchar})::Void
@getf lib mgl_datac_roll(dat::HADT, dir::Cchar, num::Clong)::Void
@getf lib mgl_datac_mirror(dat::HADT, dir::Ptr{Cchar})::Void
@getf lib mgl_datac_crop(dat::HADT, n1::Clong, n2::Clong, dir::Cchar)::Void
@getf lib mgl_datac_hankel(dat::HADT, dir::Ptr{Cchar})::Void
@getf lib mgl_datac_fft(dat::HADT, dir::Ptr{Cchar})::Void
@getf lib mgl_datac_correl(dat1::HCDT, dat2::HCDT, dir::Ptr{Cchar})::HADT
@getf lib mgl_datac_diffr(dat::HADT, how::Ptr{Cchar}, q::Float)::Void
@getf lib mgl_datac_real(dat::HCDT)::HMDT
@getf lib mgl_datac_imag(dat::HCDT)::HMDT
@getf lib mgl_datac_abs(dat::HCDT)::HMDT
@getf lib mgl_datac_arg(dat::HCDT)::HMDT
@getf lib mgl_datac_linear(d::HCDT, x::Float, y::Float, z::Float)::Dual
@getf lib mgl_datac_linear_ext(d::HCDT, x::Float, y::Float, z::Float, dx::Ptr{Dual}, dy::Ptr{Dual}, dz::Ptr{Dual})::Dual
@getf lib mgl_datac_spline(dat::HCDT, x::Float, y::Float, z::Float)::Dual
@getf lib mgl_datac_spline_ext(dat::HCDT, x::Float, y::Float, z::Float, dx::Ptr{Dual}, dy::Ptr{Dual}, dz::Ptr{Dual})::Dual
@getf lib mgl_create_cexpr(expr::Ptr{Cchar})::HAEX
@getf lib mgl_delete_cexpr(ex::HAEX)::Void
@getf lib mgl_cexpr_eval(ex::HAEX, x::Dual, y::Dual, z::Dual)::Dual
@getf lib mgl_cexpr_eval_v(ex::HAEX, vars::Ptr{Dual})::Dual

#data_cf.h
#=@getf lib mgl_srnd(seed::Clong)::Void=#
#=@getf lib mgl_rnd()::Cdouble=#
@getf lib mgl_ipow(x::Cdouble, n::Cint)::Cdouble
@getf lib mgl_get_time(time::Ptr{Cchar}, fmt::Ptr{Cchar})::Cdouble
@getf lib mgl_create_data()::HMDT
@getf lib mgl_create_data_size(nx::Clong, ny::Clong, nz::Clong)::HMDT
@getf lib mgl_create_data_file(fname::Ptr{Cchar})::HMDT
@getf lib mgl_delete_data(dat::HMDT)::Void
@getf lib mgl_data_rearrange(dat::HMDT, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_data_link(dat::HMDT, A::Ptr{Float}, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_data_set_float(dat::HMDT, A::Ptr{Cfloat}, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_data_set_double(dat::HMDT, A::Ptr{Cdouble}, mx::Clong, my::Clong, mz::Clong)::Void
@getf lib mgl_data_set_float2(d::HMDT)::Void
@getf lib mgl_data_set_double2(d::HMDT)::Void
@getf lib mgl_data_set_float3(d::HMDT)::Void
@getf lib mgl_data_set_double3(d::HMDT)::Void
@getf lib mgl_data_set(dat::HMDT, a::HCDT)::Void
@getf lib mgl_data_set_vector(dat::HMDT, v::Ptr{gsl_vector})::Void
@getf lib mgl_data_set_matrix(dat::HMDT, m::Ptr{gsl_matrix})::Void
@getf lib mgl_data_set_value(dat::HMDT, v::Float, i::Clong, j::Clong, k::Clong)::Void
@getf lib mgl_data_get_value(dat::HCDT, i::Clong, j::Clong, k::Clong)::Float
@getf lib mgl_data_set_values(dat::HMDT, val::Ptr{Cchar}, nx::Clong, ny::Clong, nz::Clong)::Void
@getf lib mgl_data_read_hdf(d::HMDT, fname::Ptr{Cchar}, data::Ptr{Cchar})::Cint
@getf lib mgl_data_save_hdf(d::HCDT, fname::Ptr{Cchar}, data::Ptr{Cchar}, rewrite::Cint)::Void
@getf lib mgl_datas_hdf(fname::Ptr{Cchar}, buf::Ptr{Cchar}, size::Clong)::Cint
@getf lib mgl_data_read(dat::HMDT, fname::Ptr{Cchar})::Cint
@getf lib mgl_data_read_mat(dat::HMDT, fname::Ptr{Cchar}, dim::Clong)::Cint
@getf lib mgl_data_read_dim(dat::HMDT, fname::Ptr{Cchar}, mx::Clong, my::Clong, mz::Clong)::Cint
@getf lib mgl_data_read_range(d::HMDT, templ::Ptr{Cchar}, n1::Cdouble, n2::Cdouble, step::Cdouble, as_slice::Cint)::Cint
@getf lib mgl_data_read_all(dat::HMDT, templ::Ptr{Cchar}, as_slice::Cint)::Cint
@getf lib mgl_data_save(dat::HCDT, fname::Ptr{Cchar}, ns::Clong)::Void
@getf lib mgl_data_export(dat::HCDT, fname::Ptr{Cchar}, scheme::Ptr{Cchar}, v1::Float, v2::Float, ns::Clong)::Void
@getf lib mgl_data_import(dat::HMDT, fname::Ptr{Cchar}, scheme::Ptr{Cchar}, v1::Float, v2::Float)::Void
@getf lib mgl_data_create(dat::HMDT, nx::Clong, ny::Clong, nz::Clong)::Void
@getf lib mgl_data_transpose(dat::HMDT, dim::Ptr{Cchar})::Void
@getf lib mgl_data_norm(dat::HMDT, v1::Float, v2::Float, sym::Clong, dim::Clong)::Void
@getf lib mgl_data_norm_slice(dat::HMDT, v1::Float, v2::Float, dir::Cchar, keep_en::Clong, sym::Clong)::Void
@getf lib mgl_data_subdata(dat::HCDT, xx::Clong, yy::Clong, zz::Clong)::HMDT
@getf lib mgl_data_subdata_ext(dat::HCDT, xx::HCDT, yy::HCDT, zz::HCDT)::HMDT
@getf lib mgl_data_column(dat::HCDT, eq::Ptr{Cchar})::HMDT
@getf lib mgl_data_set_id(d::HMDT, id::Ptr{Cchar})::Void
@getf lib mgl_data_fill(dat::HMDT, x1::Float, x2::Float, dir::Cchar)::Void
@getf lib mgl_data_fill_eq(gr::HMGL, dat::HMDT, eq::Ptr{Cchar}, vdat::HCDT, wdat::HCDT, opt::Ptr{Cchar})::Void
@getf lib mgl_data_refill_x(dat::HMDT, xdat::HCDT, vdat::HCDT, x1::Float, x2::Float, sl::Clong)::Void
@getf lib mgl_data_refill_xy(dat::HMDT, xdat::HCDT, ydat::HCDT, vdat::HCDT, x1::Float, x2::Float, y1::Float, y2::Float, sl::Clong)::Void
@getf lib mgl_data_refill_xyz(dat::HMDT, xdat::HCDT, ydat::HCDT, zdat::HCDT, vdat::HCDT, x1::Float, x2::Float, y1::Float, y2::Float, z1::Float, z2::Float)::Void
@getf lib mgl_data_refill_gr(gr::HMGL, dat::HMDT, xdat::HCDT, ydat::HCDT, zdat::HCDT, vdat::HCDT, sl::Clong, opt::Ptr{Cchar})::Void
@getf lib mgl_data_grid(gr::HMGL, d::HMDT, xdat::HCDT, ydat::HCDT, zdat::HCDT, opt::Ptr{Cchar})::Void
@getf lib mgl_data_grid_xy(d::HMDT, xdat::HCDT, ydat::HCDT, zdat::HCDT, x1::Float, x2::Float, y1::Float, y2::Float)::Void
@getf lib mgl_data_put_val(dat::HMDT, val::Float, i::Clong, j::Clong, k::Clong)::Void
@getf lib mgl_data_put_dat(dat::HMDT, val::HCDT, i::Clong, j::Clong, k::Clong)::Void
@getf lib mgl_data_modify(dat::HMDT, eq::Ptr{Cchar}, dim::Clong)::Void
@getf lib mgl_data_modify_vw(dat::HMDT, eq::Ptr{Cchar}, vdat::HCDT, wdat::HCDT)::Void
@getf lib mgl_data_squeeze(dat::HMDT, rx::Clong, ry::Clong, rz::Clong, smooth::Clong)::Void
@getf lib mgl_data_max(dat::HCDT)::Float
@getf lib mgl_data_neg_max(dat::HCDT)::Float
@getf lib mgl_data_min(dat::HCDT)::Float
@getf lib mgl_data_pos_min(dat::HCDT)::Float
@getf lib mgl_data_get_nx(d::HCDT)::Clong
@getf lib mgl_data_get_ny(d::HCDT)::Clong
@getf lib mgl_data_get_nz(d::HCDT)::Clong
@getf lib mgl_data_first(dat::HCDT, cond::Ptr{Cchar}, i::Ptr{Clong}, j::Ptr{Clong}, k::Ptr{Clong})::Float
@getf lib mgl_data_last(dat::HCDT, cond::Ptr{Cchar}, i::Ptr{Clong}, j::Ptr{Clong}, k::Ptr{Clong})::Float
@getf lib mgl_data_find(dat::HCDT, cond::Ptr{Cchar}, dir::Cchar, i::Clong, j::Clong, k::Clong)::Clong
@getf lib mgl_data_find_any(dat::HCDT, cond::Ptr{Cchar})::Cint
@getf lib mgl_data_max_int(dat::HCDT, i::Ptr{Clong}, j::Ptr{Clong}, k::Ptr{Clong})::Float
@getf lib mgl_data_max_real(dat::HCDT, x::Ptr{Float}, y::Ptr{Float}, z::Ptr{Float})::Float
@getf lib mgl_data_min_int(dat::HCDT, i::Ptr{Clong}, j::Ptr{Clong}, k::Ptr{Clong})::Float
@getf lib mgl_data_min_real(dat::HCDT, x::Ptr{Float}, y::Ptr{Float}, z::Ptr{Float})::Float
@getf lib mgl_data_momentum_val(d::HCDT, dir::Cchar, m::Ptr{Float}, w::Ptr{Float}, s::Ptr{Float}, k::Ptr{Float})::Float
@getf lib mgl_data_combine(dat1::HCDT, dat2::HCDT)::HMDT
@getf lib mgl_data_extend(dat::HMDT, n1::Clong, n2::Clong)::Void
@getf lib mgl_data_insert(dat::HMDT, dir::Cchar, at::Clong, num::Clong)::Void
@getf lib mgl_data_delete(dat::HMDT, dir::Cchar, at::Clong, num::Clong)::Void
@getf lib mgl_data_join(dat::HMDT, d::HCDT)::Void
@getf lib mgl_data_smooth(d::HMDT, dirs::Ptr{Cchar}, delta::Float)::Void
@getf lib mgl_data_sum(dat::HCDT, dir::Ptr{Cchar})::HMDT
@getf lib mgl_data_max_dir(dat::HCDT, dir::Ptr{Cchar})::HMDT
@getf lib mgl_data_min_dir(dat::HCDT, dir::Ptr{Cchar})::HMDT
@getf lib mgl_data_cumsum(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_integral(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_diff(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_diff_par(dat::HMDT, v1::HCDT, v2::HCDT, v3::HCDT)::Void
@getf lib mgl_data_diff2(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_swap(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_roll(dat::HMDT, dir::Cchar, num::Clong)::Void
@getf lib mgl_data_mirror(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_sort(dat::HMDT, idx::Clong, idy::Clong)::Void
@getf lib mgl_data_hankel(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_sinfft(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_cosfft(dat::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_fill_sample(dat::HMDT, how::Ptr{Cchar})::Void
@getf lib mgl_data_correl(dat1::HCDT, dat2::HCDT, dir::Ptr{Cchar})::HMDT
@getf lib mgl_fft_free(wt::Ptr{Void})::Void
@getf lib mgl_fft_free_thr(wt::Ptr{Void})::Void
@getf lib mgl_fft(x::Ptr{Cdouble}, s::Clong, n::Clong, wt::Ptr{Void}, ws::Ptr{Void}, inv::Cint)::Void
#=@getf lib mgl_clear_fft()::Void=#
@getf lib mgl_data_spline(dat::HCDT, x::Float, y::Float, z::Float)::Float
@getf lib mgl_data_linear(dat::HCDT, x::Float, y::Float, z::Float)::Float
@getf lib mgl_data_spline_ext(dat::HCDT, x::Float, y::Float, z::Float, dx::Ptr{Float}, dy::Ptr{Float}, dz::Ptr{Float})::Float
@getf lib mgl_data_linear_ext(dat::HCDT, x::Float, y::Float, z::Float, dx::Ptr{Float}, dy::Ptr{Float}, dz::Ptr{Float})::Float
@getf lib mgl_data_solve_1d(dat::HCDT, val::Float, spl::Cint, i0::Clong)::Float
@getf lib mgl_data_solve(dat::HCDT, val::Float, dir::Cchar, i0::HCDT, norm::Cint)::HMDT
@getf lib mgl_data_trace(d::HCDT)::HMDT
@getf lib mgl_data_resize(dat::HCDT, mx::Clong, my::Clong, mz::Clong)::HMDT
@getf lib mgl_data_resize_box(dat::HCDT, mx::Clong, my::Clong, mz::Clong, x1::Float, x2::Float, y1::Float, y2::Float, z1::Float, z2::Float)::HMDT
@getf lib mgl_data_hist(dat::HCDT, n::Clong, v1::Float, v2::Float, nsub::Clong)::HMDT
@getf lib mgl_data_hist_w(dat::HCDT, weight::HCDT, n::Clong, v1::Float, v2::Float, nsub::Clong)::HMDT
@getf lib mgl_data_momentum(dat::HCDT, dir::Cchar, how::Ptr{Cchar})::HMDT
@getf lib mgl_data_evaluate(dat::HCDT, idat::HCDT, jdat::HCDT, kdat::HCDT, norm::Cint)::HMDT
@getf lib mgl_data_envelop(dat::HMDT, dir::Cchar)::Void
@getf lib mgl_data_sew(dat::HMDT, dirs::Ptr{Cchar}, da::Float)::Void
@getf lib mgl_data_crop(dat::HMDT, n1::Clong, n2::Clong, dir::Cchar)::Void
@getf lib mgl_data_clean(dat::HMDT, id::Clong)::Void
@getf lib mgl_data_mul_dat(dat::HMDT, d::HCDT)::Void
@getf lib mgl_data_div_dat(dat::HMDT, d::HCDT)::Void
@getf lib mgl_data_add_dat(dat::HMDT, d::HCDT)::Void
@getf lib mgl_data_sub_dat(dat::HMDT, d::HCDT)::Void
@getf lib mgl_data_mul_num(dat::HMDT, d::Float)::Void
@getf lib mgl_data_div_num(dat::HMDT, d::Float)::Void
@getf lib mgl_data_add_num(dat::HMDT, d::Float)::Void
@getf lib mgl_data_sub_num(dat::HMDT, d::Float)::Void
@getf lib mgl_transform_a(am::HCDT, ph::HCDT, tr::Ptr{Cchar})::HMDT
@getf lib mgl_transform(re::HCDT, im::HCDT, tr::Ptr{Cchar})::HMDT
@getf lib mgl_data_fourier(re::HMDT, im::HMDT, dir::Ptr{Cchar})::Void
@getf lib mgl_data_stfa(re::HCDT, im::HCDT, dn::Clong, dir::Cchar)::HMDT
@getf lib mgl_triangulation_3d(x::HCDT, y::HCDT, z::HCDT)::HMDT
@getf lib mgl_triangulation_2d(x::HCDT, y::HCDT)::HMDT
@getf lib mgl_find_root()::Float
@getf lib mgl_find_root_txt(func::Ptr{Cchar}, ini::Float, var_id::Cchar)::Float
@getf lib mgl_data_roots(func::Ptr{Cchar}, ini::HCDT, var_id::Cchar)::HMDT
@getf lib mgl_create_expr(expr::Ptr{Cchar})::HMEX
@getf lib mgl_delete_expr(ex::HMEX)::Void
@getf lib mgl_expr_eval(ex::HMEX, x::Cdouble, y::Cdouble, z::Cdouble)::Cdouble
@getf lib mgl_expr_eval_v(ex::HMEX, vars::Ptr{Float})::Cdouble
@getf lib mgl_expr_diff(ex::HMEX, dir::Cchar, x::Cdouble, y::Cdouble, z::Cdouble)::Cdouble
@getf lib mgl_expr_diff_v(ex::HMEX, dir::Cchar, vars::Ptr{Float})::Cdouble

#define.h
@getf lib mgl_hypot(x::Cdouble, y::Cdouble)::Cdouble
@getf lib mgl_wcslen(str::Ptr{Cwchar_t})::Csize_t
@getf lib mgl_chrrgb(id::Cchar, rgb::Cfloat)::Void
@getf lib mgl_have_color(stl::Ptr{Cchar})::Clong
@getf lib mgl_set_num_thr(n::Cint)::Void
@getf lib mgl_test_txt(str::Ptr{Cchar})::Void
@getf lib mgl_set_test_mode(enable::Cint)::Void
@getf lib mgl_strtrim(str::Ptr{Cchar})::Void
@getf lib mgl_wcstrim(str::Ptr{Cwchar_t})::Void
@getf lib mgl_strlwr(str::Ptr{Cchar})::Void
@getf lib mgl_wcslwr(str::Ptr{Cwchar_t})::Void
@getf lib mgl_wcstombs(dst::Ptr{Cchar}, src::Ptr{Cwchar_t}, size::Cint)::Void
@getf lib mgl_clear_fft()::Void

#mgl_cf.h
@getf lib mgl_create_graph_gl()::HMGL

#mpi.h
@getf lib mgl_mpi_send(gr::HMGL, id::Cint)::Void
@getf lib mgl_mpi_recv(gr::HMGL, id::Cint)::Void

#other.h
@getf lib mgl_triplot_xyzc(gr::HMGL, nums::HCDT, x::HCDT, y::HCDT, z::HCDT, c::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_triplot_xyz(gr::HMGL, nums::HCDT, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_triplot_xy(gr::HMGL, nums::HCDT, x::HCDT, y::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_quadplot_xyzc(gr::HMGL, nums::HCDT, x::HCDT, y::HCDT, z::HCDT, c::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_quadplot_xyz(gr::HMGL, nums::HCDT, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_quadplot_xy(gr::HMGL, nums::HCDT, x::HCDT, y::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tricont_xyzcv(gr::HMGL, v::HCDT, nums::HCDT, x::HCDT, y::HCDT, z::HCDT, c::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tricont_xycv(gr::HMGL, v::HCDT, nums::HCDT, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tricont_xyzc(gr::HMGL, nums::HCDT, x::HCDT, y::HCDT, z::HCDT, c::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tricont_xyc(gr::HMGL, nums::HCDT, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_dots(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_dots_a(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_dots_ca(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, c::HCDT, a::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_crust(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_dens_x(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_dens_y(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_dens_z(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_x(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_y(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_z(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_x_val(graph::HMGL, v::HCDT, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_y_val(graph::HMGL, v::HCDT, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_cont_z_val(graph::HMGL, v::HCDT, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_x(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_y(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_z(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_x_val(graph::HMGL, v::HCDT, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_y_val(graph::HMGL, v::HCDT, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_contf_z_val(graph::HMGL, v::HCDT, a::HCDT, stl::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void

#pde.h
#=@getf lib mgl_pde_solve_c(gr::HMGL, ham::Ptr{Cchar}, ini_re::HCDT, ini_im::HCDT, dz::Float, k0::Float, opt::Ptr{Cchar})::HADT=#
#=@getf lib mgl_pde_solve(gr::HMGL, ham::Ptr{Cchar}, ini_re::HCDT, ini_im::HCDT, dz::Float, k0::Float, opt::Ptr{Cchar})::HMDT=#
#=@getf lib mgl_qo2d_solve_c(ham::Ptr{Cchar}, ini_re::HCDT, ini_im::HCDT, ray::HCDT, r::Float, k0::Float, xx::HMDT, yy::HMDT)::HADT=#
#=@getf lib mgl_qo2d_func_c()::HADT=#
#=@getf lib mgl_qo2d_solve(ham::Ptr{Cchar}, ini_re::HCDT, ini_im::HCDT, ray::HCDT, r::Float, k0::Float, xx::HMDT, yy::HMDT)::HMDT=#
#=@getf lib mgl_qo2d_func()::HMDT=#
#=@getf lib mgl_qo3d_solve_c(ham::Ptr{Cchar}, ini_re::HCDT, ini_im::HCDT, ray::HCDT, r::Float, k0::Float, xx::HMDT, yy::HMDT, zz::HMDT)::HADT=#
#=@getf lib mgl_qo3d_func_c()::HADT=#
#=@getf lib mgl_qo3d_solve(ham::Ptr{Cchar}, ini_re::HCDT, ini_im::HCDT, ray::HCDT, r::Float, k0::Float, xx::HMDT, yy::HMDT, zz::HMDT)::HMDT=#
#=@getf lib mgl_qo3d_func()::HMDT=#
#=@getf lib mgl_ode_solve(x::Ptr{Float}, dx::Ptr{Float}, par::Ptr{Void}, n::Cint, x0::Ptr{Float}, dt::Float, tmax::Float, par::Ptr{Void})::HMDT=#
#=@getf lib mgl_ray_trace(ham::Ptr{Cchar}, x0::Float, y0::Float, z0::Float, px::Float, py::Float, pz::Float, dt::Float, tmax::Float)::HMDT=#
#=@getf lib mgl_jacobian_2d(x::HCDT, y::HCDT)::HMDT=#
#=@getf lib mgl_jacobian_3d(x::HCDT, y::HCDT, z::HCDT)::HMDT=#

#plot.h
@getf lib mgl_fplot(gr::HMGL, eqY::Ptr{Cchar}, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_fplot_xyz(gr::HMGL, eqX::Ptr{Cchar}, eqY::Ptr{Cchar}, eqZ::Ptr{Cchar}, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_radar(graph::HMGL, a::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_plot_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_plot_xy(graph::HMGL, x::HCDT, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_plot(graph::HMGL, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tens_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, c::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tens_xy(graph::HMGL, x::HCDT, y::HCDT, c::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tens(graph::HMGL, y::HCDT, c::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tape_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tape_xy(graph::HMGL, x::HCDT, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tape(graph::HMGL, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_boxplot_xy(graph::HMGL, x::HCDT, a::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_boxplot(graph::HMGL, a::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_area_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_area_xy(graph::HMGL, x::HCDT, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_area(graph::HMGL, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_region_3d(graph::HMGL, x1::HCDT, y1::HCDT, z1::HCDT, x2::HCDT, y2::HCDT, z2::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_region_xy(graph::HMGL, x::HCDT, y1::HCDT, y2::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_region(graph::HMGL, y1::HCDT, y2::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_stem_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_stem_xy(graph::HMGL, x::HCDT, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_stem(graph::HMGL, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_step_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_step_xy(graph::HMGL, x::HCDT, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_step(graph::HMGL, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_bars_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_bars_xy(graph::HMGL, x::HCDT, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_bars(graph::HMGL, y::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_barh_yx(graph::HMGL, y::HCDT, v::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_barh(graph::HMGL, v::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_ohlc_x(graph::HMGL, x::HCDT, open::HCDT, high::HCDT, low::HCDT, close::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_ohlc(graph::HMGL, open::HCDT, high::HCDT, low::HCDT, close::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_chart(graph::HMGL, a::HCDT, col::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_error_exy(graph::HMGL, x::HCDT, y::HCDT, ex::HCDT, ey::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_error_xy(graph::HMGL, x::HCDT, y::HCDT, ey::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_error(graph::HMGL, y::HCDT, ey::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_mark_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, r::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_mark_xy(graph::HMGL, x::HCDT, y::HCDT, r::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_mark_y(graph::HMGL, y::HCDT, r::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tube_xyzr(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, r::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tube_xyr(graph::HMGL, x::HCDT, y::HCDT, r::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tube_r(graph::HMGL, y::HCDT, r::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tube_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, r::Cdouble, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tube_xy(graph::HMGL, x::HCDT, y::HCDT, r::Cdouble, penl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tube(graph::HMGL, y::HCDT, r::Cdouble, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_candle_xyv(gr::HMGL, x::HCDT, v1::HCDT, v2::HCDT, y1::HCDT, y2::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_candle_yv(gr::HMGL, v1::HCDT, v2::HCDT, y1::HCDT, y2::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_candle(gr::HMGL, v::HCDT, y1::HCDT, y2::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void

#prim.h
@getf lib mgl_mark(gr::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, mark::Ptr{Cchar})::Void
@getf lib mgl_ball(gr::HMGL, x::Cdouble, y::Cdouble, z::Cdouble)::Void
@getf lib mgl_line(gr::HMGL, x1::Cdouble, y1::Cdouble, z1::Cdouble, x2::Cdouble, y2::Cdouble, z2::Cdouble, pen::Ptr{Cchar}, n::Cint)::Void
@getf lib mgl_curve(gr::HMGL, x1::Cdouble, y1::Cdouble, z1::Cdouble, dx1::Cdouble, dy1::Cdouble, dz1::Cdouble, x2::Cdouble, y2::Cdouble, z2::Cdouble, dx2::Cdouble, dy2::Cdouble, dz2::Cdouble, pen::Ptr{Cchar}, n::Cint)::Void
@getf lib mgl_error_box(gr::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, ex::Cdouble, ey::Cdouble, ez::Cdouble, pen::Ptr{Cchar})::Void
@getf lib mgl_face(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble, x1::Cdouble, y1::Cdouble, z1::Cdouble, x2::Cdouble, y2::Cdouble, z2::Cdouble, x3::Cdouble, y3::Cdouble, z3::Cdouble, stl::Ptr{Cchar})::Void
@getf lib mgl_facex(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble, wy::Cdouble, wz::Cdouble, stl::Ptr{Cchar}, dx::Cdouble, dy::Cdouble)::Void
@getf lib mgl_facey(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble, wx::Cdouble, wz::Cdouble, stl::Ptr{Cchar}, dx::Cdouble, dy::Cdouble)::Void
@getf lib mgl_facez(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble, wx::Cdouble, wy::Cdouble, stl::Ptr{Cchar}, dx::Cdouble, dy::Cdouble)::Void
@getf lib mgl_sphere(gr::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, r::Cdouble, stl::Ptr{Cchar})::Void
@getf lib mgl_drop(gr::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, dx::Cdouble, dy::Cdouble, dz::Cdouble, r::Cdouble, stl::Ptr{Cchar}, shift::Cdouble, ap::Cdouble)::Void
@getf lib mgl_cone(gr::HMGL, x1::Cdouble, y1::Cdouble, z1::Cdouble, x2::Cdouble, y2::Cdouble, z2::Cdouble, r1::Cdouble, r2::Cdouble, stl::Ptr{Cchar})::Void
@getf lib mgl_ellipse(gr::HMGL, x1::Cdouble, y1::Cdouble, z1::Cdouble, x2::Cdouble, y2::Cdouble, z2::Cdouble, r::Cdouble, stl::Ptr{Cchar})::Void
@getf lib mgl_rhomb(gr::HMGL, x1::Cdouble, y1::Cdouble, z1::Cdouble, x2::Cdouble, y2::Cdouble, z2::Cdouble, r::Cdouble, stl::Ptr{Cchar})::Void
@getf lib mgl_cones_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_cones_xz(graph::HMGL, x::HCDT, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_cones(graph::HMGL, z::HCDT, pen::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_dew_xy(gr::HMGL, x::HCDT, y::HCDT, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_dew_2d(gr::HMGL, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, optl::Ptr{Cchar})::Void
@getf lib mgl_puts(graph::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, text::Ptr{Cchar}, font::Ptr{Cchar}, size::Cdouble)::Void
@getf lib mgl_putsw(graph::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, text::Ptr{Cwchar_t}, font::Ptr{Cchar}, size::Cdouble)::Void
@getf lib mgl_puts_dir(graph::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, dx::Cdouble, dy::Cdouble, dz::Cdouble, text::Ptr{Cchar}, font::Ptr{Cchar}, size::Cdouble)::Void
@getf lib mgl_putsw_dir(graph::HMGL, x::Cdouble, y::Cdouble, z::Cdouble, dx::Cdouble, dy::Cdouble, dz::Cdouble, text::Ptr{Cwchar_t}, font::Ptr{Cchar}, size::Cdouble)::Void
@getf lib mgl_textmark_xyzr(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, r::HCDT, text::Ptr{Cchar}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textmarkw_xyzr(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, r::HCDT, text::Ptr{Cwchar_t}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textmark_xyr(graph::HMGL, x::HCDT, y::HCDT, r::HCDT, text::Ptr{Cchar}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textmarkw_xyr(graph::HMGL, x::HCDT, y::HCDT, r::HCDT, text::Ptr{Cwchar_t}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textmark_yr(graph::HMGL, y::HCDT, r::HCDT, text::Ptr{Cchar}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textmarkw_yr(graph::HMGL, y::HCDT, r::HCDT, text::Ptr{Cwchar_t}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textmark(graph::HMGL, y::HCDT, text::Ptr{Cchar}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_textmarkw(graph::HMGL, y::HCDT, text::Ptr{Cwchar_t}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_label_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, text::Ptr{Cchar}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_labelw_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, text::Ptr{Cwchar_t}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_label_xy(graph::HMGL, x::HCDT, y::HCDT, text::Ptr{Cchar}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_labelw_xy(graph::HMGL, x::HCDT, y::HCDT, text::Ptr{Cwchar_t}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_label_y(graph::HMGL, y::HCDT, text::Ptr{Cchar}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_labelw_y(graph::HMGL, y::HCDT, text::Ptr{Cwchar_t}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_table(gr::HMGL, x::Cdouble, y::Cdouble, val::HCDT, text::Ptr{Cchar}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tablew(gr::HMGL, x::Cdouble, y::Cdouble, val::HCDT, text::Ptr{Cwchar_t}, fnt::Ptr{Cchar}, opt::Ptr{Cchar})::Void

#surf.h
@getf lib mgl_fsurf(graph::HMGL, fz::Ptr{Cchar}, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_fsurf_xyz(graph::HMGL, fx::Ptr{Cchar}, fy::Ptr{Cchar}, fz::Ptr{Cchar}, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_grid_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_grid(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_mesh_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_mesh(graph::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_fall_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_fall(graph::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_belt_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_belt(graph::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf(graph::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_dens_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_dens(graph::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_boxs_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_boxs(graph::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tile_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tile(graph::HMGL, z::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tiles_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, r::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_tiles(graph::HMGL, z::HCDT, r::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surfc_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, c::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surfc(graph::HMGL, z::HCDT, c::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surfa_xy(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, c::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surfa(graph::HMGL, z::HCDT, c::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_stfa_xy(graph::HMGL, x::HCDT, y::HCDT, re::HCDT, im::HCDT, dn::Cint, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_stfa(graph::HMGL, re::HCDT, im::HCDT, dn::Cint, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_map_xy(graph::HMGL, x::HCDT, y::HCDT, a::HCDT, b::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_map(graph::HMGL, a::HCDT, b::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void

#vect.h
@getf lib mgl_traj_xy(gr::HMGL, x::HCDT, y::HCDT, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_traj_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_vect_xy(gr::HMGL, x::HCDT, y::HCDT, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_vect_2d(gr::HMGL, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_vect_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_vect_3d(gr::HMGL, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_flow_xy(gr::HMGL, x::HCDT, y::HCDT, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_flow_2d(gr::HMGL, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_flow_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_flow_3d(gr::HMGL, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_flowp_xy(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble, x::HCDT, y::HCDT, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_flowp_2d(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_flowp_xyz(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble, x::HCDT, y::HCDT, z::HCDT, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_flowp_3d(gr::HMGL, x0::Cdouble, y0::Cdouble, z0::Cdouble, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_pipe_xy(gr::HMGL, x::HCDT, y::HCDT, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, r0::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_pipe_2d(gr::HMGL, ax::HCDT, ay::HCDT, sch::Ptr{Cchar}, r0::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_pipe_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, r0::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_pipe_3d(gr::HMGL, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, r0::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_grad_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, ph::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_grad_xy(gr::HMGL, x::HCDT, y::HCDT, ph::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_grad(gr::HMGL, ph::HCDT, sch::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_vect3_xyz(gr::HMGL, x::HCDT, y::HCDT, z::HCDT, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void
@getf lib mgl_vect3(gr::HMGL, ax::HCDT, ay::HCDT, az::HCDT, sch::Ptr{Cchar}, sVal::Cdouble, opt::Ptr{Cchar})::Void

#volume.h
@getf lib mgl_surf3_xyz_val(graph::HMGL, Val::Cdouble, x::HCDT, y::HCDT, z::HCDT, a::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3_val(graph::HMGL, Val::Cdouble, a::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3a_xyz_val(graph::HMGL, Val::Cdouble, x::HCDT, y::HCDT, z::HCDT, a::HCDT, b::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3a_val(graph::HMGL, Val::Cdouble, a::HCDT, b::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3a_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, b::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3a(graph::HMGL, a::HCDT, b::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3c_xyz_val(graph::HMGL, Val::Cdouble, x::HCDT, y::HCDT, z::HCDT, a::HCDT, b::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3c_val(graph::HMGL, Val::Cdouble, a::HCDT, b::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3c_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, b::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_surf3c(graph::HMGL, a::HCDT, b::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_cloud_xyz(graph::HMGL, x::HCDT, y::HCDT, z::HCDT, a::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_cloud(graph::HMGL, a::HCDT, stl::Ptr{Cchar}, opt::Ptr{Cchar})::Void
@getf lib mgl_beam_val(graph::HMGL, Val::Cdouble, tr::HCDT, g1::HCDT, g2::HCDT, a::HCDT, r::Cdouble, stl::Ptr{Cchar}, norm::Cint)::Void
@getf lib mgl_beam(graph::HMGL, tr::HCDT, g1::HCDT, g2::HCDT, a::HCDT, r::Cdouble, stl::Ptr{Cchar}, norm::Cint, num::Cint)::Void

#wnd.h
@getf lib mgl_draw_graph(gr::HMGL, p::Ptr{Void})::Cint
@getf lib mgl_draw_class(gr::HMGL, p::Ptr{Void})::Cint
@getf lib mgl_click_class(p::Ptr{Void})::Void
@getf lib mgl_reload_class(p::Ptr{Void})::Void

#Functions that went missing somehow
@getf lib mgl_rasterize(gr::HMGL)::Void


text:
using NCDatasets

using Oceananigans.Fields
using Oceananigans.Utils: validate_interval
using Oceananigans.Grids: topology, interior_x_indices, interior_y_indices, interior_z_indices
using Oceananigans.Fields: cpudata

# Possibly should
collect_face_nodes(topo, ξF) = collect(ξF)[1:end-1]
collect_face_nodes(::Bounded, ξF) = collect(ξF)

const default_output_attributes = Dict(
    "u" => Dict("longname" => "Velocity in the x-direction", "units" => "m/s"),
    "v" => Dict("longname" => "Velocity in the y-direction", "units" => "m/s"),
    "w" => Dict("longname" => "Velocity in the z-direction", "units" => "m/s"),
    "b" => Dict("longname" => "Buoyancy",                    "units" => "m/s²"),
    "T" => Dict("longname" => "Conservative temperature",    "units" => "°C"),
    "S" => Dict("longname" => "Absolute salinity",           "units" => "g/kg")
)

"""
    NetCDFOutputWriter <: AbstractOutputWriter

An output writer for writing to NetCDF files.
"""
mutable struct NetCDFOutputWriter{D, O, I, F, S} <: AbstractOutputWriter
     filename :: String
      dataset :: D
      outputs :: O
     interval :: I
    frequency :: F
      clobber :: Bool
       slices :: S
     previous :: Float64
end

"""
    NetCDFOutputWriter(model, outputs; frequency=nothing, interval=nothing, filename=".",
                       global_attributes=Dict(), output_attributes=Dict(), dimensions=Dict(),
                       clobber=true, compression=0, slice_kw...)

Construct a `NetCDFOutputWriter` that writes `(label, output)` pairs in `outputs` (which should
be a `Dict`) to a NetCDF file, where `label` is a string that labels the output and `output` is
either field from the model (e.g. `model.velocities.u`) or a function `f(model)` that returns
something to be written to disk.

Keyword arguments
=================
- `frequency`: Save output every `n` model iterations.
- `interval`: Save output every `t` units of model clock time.
- `filename`: Filepath to save output to. Default: "." (current working directory).
- `global_attributes`: Dict of model properties to save with every file (deafult: Dict())
- `output_attributes`: Dict of attributes to be saved with each field variable (reasonable
  defaults are provided for velocities, temperature, and salinity).
- `dimensions`: A Dict of dimensions to apply to outputs (useful for function outputs as
  field dimensions can be inferred).
- `clobber`: Remove existing files if their filenames conflict. Default: `true`.
- `compression`: Determines the compression level of data (0-9, default 0)
- `slice_kw`: `dimname = Union{OrdinalRange, Integer}` will slice the dimension `dimname`.
  All other keywords are ignored. E.g. `xC = 3:10` will only produce output along the dimension
  `xC` between indices 3 and 10 for all fields with `xC` as one of their dimensions. `xC = 1`
  is treated like `xC = 1:1`. Multiple dimensions can be sliced in one call. Not providing slices
  writes output over the entire domain.
"""

function NetCDFOutputWriter(model, outputs; filename,
                                     interval = nothing,
                                    frequency = nothing,
                            global_attributes = Dict(),
                            output_attributes = Dict(),
                                   dimensions = Dict(),
                                      clobber = true,
                                  compression = 0,
                                           xC = interior_x_indices(Cell, model.grid),
                                           xF = interior_x_indices(Face, model.grid),
                                           yC = interior_y_indices(Cell, model.grid),
                                           yF = interior_y_indices(Face, model.grid),
                                           zC = interior_z_indices(Cell, model.grid),
                                           zF = interior_z_indices(Face, model.grid)
                           )

    mode = clobber ? "c" : "a"
    validate_interval(interval, frequency)

    # Generates a dictionary with keys "xC", "xF", etc, whose values give the slices to be saved.
    slice_keywords = Dict(name => a for (name, a) in zip(("xC", "yC", "zC", "xF", "yF", "zF"),
                                                         ( xC,   yC,   zC,   xF,   yF,   zF )))

    # Initiates the output file with dimensions
    write_grid_and_attributes(model; filename=filename, compression=compression,
                              attributes=global_attributes, mode=mode,
                              xC=xC, yC=yC, zC=zC, xF=xF, yF=yF, zF=zF)

    # Opens the same output file for writing fields from the user-supplied variable outputs
    dataset = Dataset(filename, "a")

    # Creates an unliimited dimension "time"
    defDim(dataset, "time", Inf)
    defVar(dataset, "time", Float64, ("time",))
    sync(dataset)

    # Ensure we have an attribute for every output. Use reasonable defaults if
    # none were specified by the user.
    for c in keys(outputs)
        if !haskey(output_attributes, c)
            output_attributes[c] = default_output_attributes[c]
        end
    end

    # Initiates empty variables for fields from the user-supplied variable outputs
    for (name, output) in outputs
        if output isa Field
            FT = eltype(output.grid)
            defVar(dataset, name, FT, (netcdf_spatial_dimensions(output)..., "time"),
                   compression=compression, attrib=output_attributes[name])
        else
            defVar(dataset, name, Float64, (dimensions[name]..., "time"),
                   compression=compression, attrib=output_attributes[name])
        end
    end
    sync(dataset)

    field_outputs = filter(o -> o.second isa Field, outputs) # extract outputs whose values are Fields

    # Store a slice specification for each field.
    slices = Dict(name => slice_indices(field; xC=xC, yC=yC, zC=zC, xF=xF, yF=yF, zF=zF)
                  for (name, field) in field_outputs)

    return NetCDFOutputWriter(filename, dataset, outputs, interval, frequency,
                              clobber, slices, 0.0)
end

Base.open(ow::NetCDFOutputWriter) = Dataset(ow.filename, "a")
Base.close(ow::NetCDFOutputWriter) = close(ow.dataset)

"""
    netcdf_spatial_dimensions(::field)

Returns the NetCDF dimensions associated with a field.

Examples
========
julia> netcdf_spatial_dimensions(model.velocities.u)
("xF", "yC", "zC")

julia> netcdf_spatial_dimensions(model.tracers.T)
("xC", "yC", "zC")
"""
netcdf_spatial_dimensions(::Field{LX, LY, LZ}) where {LX, LY, LZ} = xdim(LX), ydim(LY), zdim(LZ)

xdim(::Type{Face}) = "xF"
ydim(::Type{Face}) = "yF"
zdim(::Type{Face}) = "zF"

xdim(::Type{Cell}) = "xC"
ydim(::Type{Cell}) = "yC"
zdim(::Type{Cell}) = "zC"

# This function allows users to specify slices with integers; eg xC=3.
# Note: size(a[3:3, :, :]) = (1, Ny, Nz) versus size(a[3, :, :]) = (Ny, Nz)
get_slice(n::Integer) = n:n
get_slice(n::UnitRange) = n

"""
    slice_indices(field; slice_specs...)

Returns an array of indices that specify a view over a field's data.
"""
slice_indices(field; slice_specs...) =
    [get_slice(slice_specs[Symbol(dim)]) for dim in netcdf_spatial_dimensions(field)]

"""
    write_output(model, OutputWriter)

Writes output to the netcdf file at specified intervals. Increments the `time` dimension
every time an output is written to the file.
"""
function write_output(model, ow::NetCDFOutputWriter)
    ds = ow.dataset

    time_index = length(ds["time"]) + 1
    ds["time"][time_index] = model.clock.time

    for (name, output) in ow.outputs

        if output isa Field
            data = cpudata(output) # Transfer data to CPU if parent(output) is a CuArray
            ds[name][:, :, :, time_index] = view(data, ow.slices[name]...)
        else
            data = output(model)
            colons = Tuple(Colon() for _ in 1:ndims(data))
            ds[name][colons..., time_index] = data
        end

    end

    sync(ow.dataset)

    return nothing
end

"""
    write_grid_and_attributes(model; filename="grid.nc", mode="c",
                              compression=0, attributes=Dict(), slice_kw...)

Writes grid and global `attributes` to `filename`. By default writes information
to a standalone `grid.nc` file.

Keyword arguments
=================
- `filename`  : File name to be saved under.
- `mode`: NetCDF file is opened in either clobber ("c") or append ("a") mode. Default: "c".
- `compression`: Defines the compression level of data from 0-9. Default: 0.
- `attributes`: Global attributes. Default: Dict().
"""
function write_grid_and_attributes(model;
                                      filename = "grid.nc",
                                          mode = "c",
                                         units = "m",
                                   compression = 0,
                                    attributes = Dict(),
                                    slice_keywords...)

    dims = Dict(
                "xC" => collect(model.grid.xC[:, 1, 1]),
                "yC" => collect(model.grid.yC[1, :, 1]),
                "zC" => collect(model.grid.zC[1, 1, :]),

                "xF" => collect(model.grid.xF[:, 1, 1]),
                "yF" => collect(model.grid.yF[1, :, 1]),
                "zF" => collect(model.grid.zF[1, 1, :]),
               )

    dim_attribs = Dict(
                       "xC" => Dict("longname" => "Locations of the cell centers in the x-direction.", "units" => units),
                       "yC" => Dict("longname" => "Locations of the cell centers in the y-direction.", "units" => units),
                       "zC" => Dict("longname" => "Locations of the cell centers in the z-direction.", "units" => units),
                       "xF" => Dict("longname" => "Locations of the cell faces in the x-direction.",   "units" => units),
                       "yF" => Dict("longname" => "Locations of the cell faces in the y-direction.",   "units" => units),
                       "zF" => Dict("longname" => "Locations of the cell faces in the z-direction.",   "units" => units)
                      )

    # Slice coordinate arrays stored in the dims dict
    for (dim, indices) in slice_keywords
        dim = string(dim) # convert symbol to string
        dims[dim] = dims[dim][get_slice(indices)] # overwrite entries in dims Dict
    end

    Dataset(filename, mode, attrib=attributes) do ds
        for (dim_name, dim_array) in dims
            defVar(ds, dim_name, dim_array, (dim_name,),
                   compression=compression, attrib=dim_attribs[dim_name])
        end
    end

    return nothing
end

ext: jl


text:
module Day02
export day02

function parseLine(line)
    cmd, distance = split(line, " ")
    return (Symbol(cmd), parse(Int, distance))
end

function readInput(inputfile="inputs/input02.txt")
    return parseLine.(eachline(inputfile))
end

function day02(inputdata = readInput("inputs/input02.txt"))
    return (day02Part1(inputdata), day02Part2(inputdata))
end

function day02Part1(cmdlist)
    pos = 0+0im
    factors = (; forward=1, down=im, up=-im)
    for (cmd, dist) in cmdlist
        pos += factors[cmd]*dist
    end
    return real(pos)*imag(pos)
end

function day02Part2(cmdlist)
    pos = 0+0im
    aim = 0im
    ## simple "if" statements are probably cleaner...
    moves = (; forward = x -> (x*(1+aim), 0),
               down = x -> (0, im*x),
               up = x -> (0, -im*x))
    for (cmd, dist) in cmdlist
        Δpos, Δaim = moves[cmd](dist)
        pos += Δpos
        aim += Δaim
    end
    return real(pos)*imag(pos)
end

end #module


text:
#=
This file is auto-generated. Do not edit.
=#
"""
    mutable struct LoadZone <: AggregationTopology
        name::String
        maxactivepower::Float64
        maxreactivepower::Float64
        services::Vector{Service}
        forecasts::InfrastructureSystems.Forecasts
        internal::InfrastructureSystemsInternal
    end

# Arguments
- `name::String`
- `maxactivepower::Float64`
- `maxreactivepower::Float64`
- `services::Vector{Service}`: Services that this device contributes to
- `forecasts::InfrastructureSystems.Forecasts`: internal forecast storage
- `internal::InfrastructureSystemsInternal`: power system internal reference, do not modify
"""
mutable struct LoadZone <: AggregationTopology
    name::String
    maxactivepower::Float64
    maxreactivepower::Float64
    "Services that this device contributes to"
    services::Vector{Service}
    "internal forecast storage"
    forecasts::InfrastructureSystems.Forecasts
    "power system internal reference, do not modify"
    internal::InfrastructureSystemsInternal
end

function LoadZone(name, maxactivepower, maxreactivepower, services=Device[], forecasts=InfrastructureSystems.Forecasts(), )
    LoadZone(name, maxactivepower, maxreactivepower, services, forecasts, InfrastructureSystemsInternal(), )
end

function LoadZone(; name, maxactivepower, maxreactivepower, services=Device[], forecasts=InfrastructureSystems.Forecasts(), )
    LoadZone(name, maxactivepower, maxreactivepower, services, forecasts, )
end

# Constructor for demo purposes; non-functional.
function LoadZone(::Nothing)
    LoadZone(;
        name="init",
        maxactivepower=0.0,
        maxreactivepower=0.0,
        services=Device[],
        forecasts=InfrastructureSystems.Forecasts(),
    )
end

InfrastructureSystems.get_name(value::LoadZone) = value.name
"""Get LoadZone maxactivepower."""
get_maxactivepower(value::LoadZone) = value.maxactivepower
"""Get LoadZone maxreactivepower."""
get_maxreactivepower(value::LoadZone) = value.maxreactivepower
"""Get LoadZone services."""
get_services(value::LoadZone) = value.services

InfrastructureSystems.get_forecasts(value::LoadZone) = value.forecasts
"""Get LoadZone internal."""
get_internal(value::LoadZone) = value.internal


text:
module DensityEstimationDatasets

export sampled_mnist,
    twenty_datasets,
    twenty_dataset_names,
    twenty_datasets_file

using CSV
using DataFrames
using LazyArtifacts

####################
# Constants
#####################

const twenty_dataset_names = [
        "accidents", "ad", "baudio", "bbc", "bnetflix", "book", "c20ng", "cr52", "cwebkb",
        "dna", "jester", "kdd", "kosarek", "msnbc", "msweb", "nltcs", "plants", "pumsb_star", "tmovie", "tretail",
        "binarized_mnist"
];

#####################
# Data loaders
#####################

sampled_mnist() = twenty_datasets("binarized_mnist")

"""
    twenty_datasets_file(name, type)

Returns the file path the dataset. Automatically downloads all the datasets using `LazyArtifcats` the first time you call this function.

- `name`: Name of the dataset. See `twenty_dataset_names()` for valid options
- `type`: depending on the dataset, usual options are "train", "valid", and "test".
"""
function twenty_datasets_file(name, type)
    @assert in(name, twenty_dataset_names)
    data_dir = artifact"density_estimation_datasets"
    return data_dir*"/Density-Estimation-Datasets-1.0.1/datasets/$name/$name.$type.data"
end

"""
    train, valid, test = twenty_datasets(name)

Load a given dataset from the density estimation datasets. Automatically downloads the files as julia Artifacts.
See https://github.com/UCLA-StarAI/Density-Estimation-Datasets for a list of avaialble datasets.
"""
function twenty_datasets(name)
    @assert in(name, twenty_dataset_names)
    function load(type)
        dataframe = CSV.read(twenty_datasets_file(name, type), DataFrame;
            header=false, truestrings=["1"], falsestrings=["0"], types=Bool, strict=true)
    end
    train = load("train")
    valid = load("valid")
    test = load("test")
    return train, valid, test
end

end # module


text:
## Preloads
using Statistics
using FFTW
using Plots
using BenchmarkTools
using Profile
using LinearAlgebra
using Measures

##
function fink_filter_bank_fast(J, L;wd=1,pc=1)
    #plane coverage (default 1, full 2Pi 2)
    #width of the wavelets (default 1, wide 2)

    # -------- set parameters
    dθ   = pc*π/L
    wdθ  = wd*dθ
    nx   = 256
    dx   = nx/2-1

    # -------- allocate output array of zeros
    filt = zeros(256, 256, J, L)

    # -------- allocate theta and logr arrays
    logr = zeros(nx, nx)
    θ    = zeros(nx, nx)

    for l = 0:L-1
        θ_l = dθ*l

    # -------- allocate anggood BitArray
        anggood = falses(nx, nx)

    # -------- loop over pixels
        for x = 1:nx
            sx = mod(x+dx,nx)-dx -1    # define sx,sy so that no fftshift() needed
            for y = 1:nx
                sy = mod(y+dx,nx)-dx -1
                θ_pix  = mod(atan(sy, sx)+π -θ_l, 2*π)
                θ_good = abs(θ_pix-π) <= wdθ

            # If this is a pixel we might use, calculate log2(r)
                if θ_good
                    anggood[y, x] = θ_good
                    θ[y, x]       = θ_pix
                    r = sqrt(sx^2 + sy^2)
                    logr[y, x] = log2(max(1,r))
                end
            end
        end
        angmask = findall(anggood)
    # -------- compute the wavelet in the Fourier domain
    # -------- the angular factor is the same for all j
        F_angular = cos.((θ[angmask].-π).*L./(2 .*wd .*pc))

    # -------- loop over j for the radial part
        for j = 0:J-1
            jrad  = 7-j
            Δj    = abs.(logr[angmask].-jrad)
            rmask = (Δj .<= 1)

    # -------- radial part
            F_radial = cos.(Δj[rmask] .* (π/2))
            ind      = angmask[rmask]
            filt[ind,j+1,l+1] = F_radial .* F_angular[rmask]
        end
    end
    return filt
end

@time fink_filter_set = fink_filter_bank_fast(8,16,wd=1)

plot(Plots.heatmap(fftshift(fink_filter_set[:,:,2,1]),
    xlims=(1,256),
    ylims=(1,256),
    aspectratio=1,
    axis=nothing,
    border=:none,
    c=:cubehelix,
    legend = :none,
    margin=0mm))

Profile.clear()
@profile fink_filter_bank_fast(8,8)
Juno.profiler()

theme(:juno)

plot_array = Any[]
for i in 1:8
    for j in 1:8
    stride = min(128,2^(9-j))-1
    push!(plot_array,
    plot(Plots.heatmap(fftshift(fink_filter_set[:,:,j,i])[128-stride:129+stride,128-stride:129+stride],
        xlims=(1,256),
        ylims=(1,256),
        aspectratio=1,
        axis=nothing,
        border=:none,
        c=:cubehelix,
        legend = :none,
        margin=0mm)))
    end
end

plot(plot_array...,layout=(8,8))
plot!(size=(1000,1000))

p = plot(
    axis = nothing,
    layout = @layout(grid(8,8)),
    size = (1000,1000)
)

J=8
L=8

for i=1:J
    for j=1:L
        stride = min(128,2^(9-j))-1
        Plots.heatmap!(p[i], fftshift(fink_filter_set[:,:,j,i])[128-stride:129+stride,128-stride:129+stride],
            ratio=1)
    end
end
p

#Grrr ignore all plots and just do my rotational invariance tests...

# generate an image of a rod with some position, length, position angle,
# and FWHM
function rod(xcen, ycen, length, pa, fwhm)
    rodimage = zeros(256,256)
    nx = 256
    x=0
    y=0
    sig = fwhm/2.355
    dtor = π/180
    # -------- define a unit vector in direction of rod at position angle pa
    ux = sin(pa*dtor)   #  0 deg is up
    uy = cos(pa*dtor)   # 90 deg to the right

    for i=1:nx
        for j=1:nx
            x=i-nx/2+xcen
            y=j-nx/2+ycen

            # -------- distance parallel and perpendicular to
            dpara =  ux*x + uy*y
            dperp = -uy*x + ux*y

            if abs(dpara)-length <0
                dpara= 0
            end
            dpara = abs(dpara)
            dpara = min(abs(dpara-length),dpara)

            rodimage[i,j] = exp(-(dperp^2+dpara^2)/(2*sig^2))
        end
    end
    return rodimage
end

@time test_rod = rod(10,10,30,45,4)

fink_filter_set1 = fink_filter_list(fink_filter_bank(8,16))

plot(Plots.heatmap(test_rod,
    xlims=(1,256),
    ylims=(1,256),
    aspectratio=1,
    axis=nothing,
    border=:none,
    c=:cubehelix,
    legend = :none,
    margin=0mm),
    size=(2000,2000))

speedy_DHC(test_rod,fink_filter_set2)

##Check rotational invariance of DHC on S20 for
# J=8, L=8, wd=1, pc=1
# J=8, L=8, wd=1, pc=2
# J=8, L=8, wd=2, pc=1
# J=8, L=8, wd=2, pc=2

# J=8, L=16, wd=1, pc=1
# J=8, L=16, wd=1, pc=2
# J=8, L=16, wd=2, pc=1
# J=8, L=16, wd=2, pc=2

test_rod = rod(10,10,30,45,4)
fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,8))
@time speedy_DHC(test_rod,fink_filter_set2)

out0 = zeros(8258,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

using HDF5

h5write("./Data/j8l8w1p1.h5", "main/data", out0)

#Wow, awesome plot idea for smoothness is to plot coefficients as function of rotation

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,8,wd=1,pc=1))
out0 = zeros(8258,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l8w1p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,8,wd=2,pc=1))
out0 = zeros(8258,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l8w2p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,8,wd=1,pc=2))
out0 = zeros(8258,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l8w1p2.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,8,wd=2,pc=2))
out0 = zeros(8258,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l8w2p2.h5", "main/data", out0)

test_rod = rod(10,10,30,45,4)
fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,16))
@time speedy_DHC(test_rod,fink_filter_set2)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,16,wd=1,pc=1))
out0 = zeros(32898,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l16w1p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,16,wd=2,pc=1))
out0 = zeros(32898,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l16w2p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,16,wd=1,pc=2))
out0 = zeros(32898,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l16w1p2.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(8,16,wd=2,pc=2))
out0 = zeros(32898,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l16w2p2.h5", "main/data", out0)

J=8
L=8
2+J*L+J*L*J*L+J*L*J*L

J=8
L=16
2+J*L+J*L*J*L+J*L*J*L
J*L*J*L

temp = reshape(1:100,20,5)
temp1 = reshape(temp,4,5,5)

out0[2+J*L+1:2+J*L+J*L*J*L,:]
test = reshape(out0[2+J*L+1:2+J*L+J*L*J*L,:],J,L,J,L,360)

l=2
d=2
N=360
test[:,l,:,mod(l+d,L),:]

intermed = zeros(J,J,N,L)
for d=1:L
    intermed[:,:,:,d]=test[:,l,:,mod(l+d,L)+1,:]
end

intermed

dropdims(sum(intermed,dims=4),dims=4)

iso_mat = zeros(J,J,N,L)
for l=1:L
    intermed = zeros(J,J,N,L)
    for d=1:L
        intermed[:,:,:,d].=test[:,l,:,mod(l+d,L)+1,:]
    end
    iso_mat[:,:,:,l] .= dropdims(sum(intermed,dims=4),dims=4)
end
pow_mat = dropdims(sum(iso_mat,dims=4),dims=4)

function S20_iso(data,J,L,N)
    S20 = reshape(data[2+J*L+1:2+J*L+J*L*J*L,:],J,L,J,L,N)
    iso_mat = zeros(J,J,N,L)
    for l=1:L
        intermed = zeros(J,J,N,L)
        for d=1:L
            intermed[:,:,:,d].=S20[:,l,:,mod(l+d,L)+1,:]
        end
        iso_mat[:,:,:,l] .= dropdims(sum(intermed,dims=4),dims=4)
    end
    pow_mat = zeros(J,J,N)
    pow_mat = dropdims(sum(iso_mat,dims=4),dims=4)
    return pow_mat
end

angle_iso = S20_iso(out0,8,16,360)

plot(angle_iso[3,4,:])

pdf_err = zeros(J,J)
temp = zeros(N)
for j2=1:J
    for j1=1:J
        temp = (angle_iso[j1,j2,:].-mean(angle_iso[j1,j2,:]))./mean(angle_iso[j1,j2,:])
        pdf_err[j1,j2] = maximum(temp)-minimum(temp)
     end
 end

 maximum(pdf_err[2:8,2:8])

 function err_extract(iso_out)
     pdf_err = zeros(J,J)
     temp = zeros(N)
     for j2=1:J
         for j1=1:J
             temp = (iso_out[j1,j2,:].-mean(iso_out[j1,j2,:]))./mean(iso_out[j1,j2,:])
             pdf_err[j1,j2] = maximum(temp)-minimum(temp)
          end
      end
      return maximum(pdf_err[2:7,2:7])
 end

## Let me try to run through whole thing.
out0 = h5read("./Data/j8l16w1p1.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l16w2p1.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l16w1p2.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l16w2p2.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l8w1p1.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l8w2p1.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l8w1p2.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l8w2p2.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

## Start abs2 test. Probably want a wd 4 test...
#this might seem scarily wide. But if we want L=16/pi, maybe it is not so bad.

function speedy_DHC_abs2(image::Array{Float64,2}, filter_list)
    # Use 2 threads for FFT
    FFTW.set_num_threads(2)

    # array sizes
    (Nx, Ny)  = size(image)
    (J,L)     = size(filter_list[1])

    # allocate coeff arrays
    out_coeff = []
    S0  = zeros(Float64, 2)
    S1  = zeros(Float64, J, L)
    S20 = zeros(Float64, J, L, J, L)
    S12 = zeros(Float64, J, L, J, L)

    # allocate image arrays for internal use
    im_fdf_0_1 = zeros(Float64,           Nx, Ny, J, L)   # this must be zeroed!
    im_rd_0_1  = Array{Float64, 4}(undef, Nx, Ny, J, L)

    ## 0th Order
    S0[1]   = mean(image)
    norm_im = image.-S0[1]
    S0[2]   = sum(norm_im .* norm_im)/(Nx*Ny)
    norm_im ./= sqrt(Nx*Ny*S0[2])

    append!(out_coeff,S0[:])

    ## 1st Order
    im_fd_0 = fft(norm_im)

    # unpack filter_list
    f_ind   = filter_list[1]  # (J, L) array of filters represented as index value pairs
    f_val   = filter_list[2]

    zarr = zeros(ComplexF64, Nx, Ny)  # temporary array to fill with zvals

    # make a FFTW "plan" for an array of the given size and type
    P   = plan_ifft(im_fd_0)   # P is an operator, P*im is ifft(im)

    ## Main 1st Order and Precompute 2nd Order
    for l = 1:L
        for j = 1:J
            S1tot = 0.0
            f_i = f_ind[j,l]  # CartesianIndex list for filter
            f_v = f_val[j,l]  # Values for f_i
            # for (ind, val) in zip(f_i, f_v)   # this is slower!
            if length(f_i) > 0
                for i = 1:length(f_i)
                    ind       = f_i[i]
                    zval      = f_v[i] * im_fd_0[ind]
                    S1tot    += abs2(zval)
                    zarr[ind] = zval
                    im_fdf_0_1[ind,j,l] = abs2(zval)
                end
                S1[j,l] = S1tot
                im_rd_0_1[:,:,j,l] .= abs2.(P*zarr)
                zarr[f_i] .= 0
            end
        end
    end
    append!(out_coeff, S1[:])

    # we stored the abs()^2, so take sqrt (this is faster to do all at once)
    #im_rd_0_1 .= sqrt.(im_rd_0_1) #commented out for abs2

    ## 2nd Order
    Amat = reshape(im_fdf_0_1, Nx*Ny, J*L)
    S12  = reshape(Amat' * Amat, J, L, J, L)
    Amat = reshape(im_rd_0_1, Nx*Ny, J*L)
    S20  = reshape(Amat' * Amat, J, L, J, L)

    append!(out_coeff, S20)
    append!(out_coeff, S12)

    return out_coeff
end

J=8
L=8
fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=1,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l8w1p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=2,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l8w2p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=1,pc=2))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l8w1p2.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=2,pc=2))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l8w2p2.h5", "main/data", out0)

J=8
L=16
fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=1,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l16w1p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=2,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l16w2p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=1,pc=2))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l16w1p2.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=2,pc=2))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l16w2p2.h5", "main/data", out0)

## Let me try to run through whole thing with abs2
out0 = h5read("./Data/abs2j8l16w1p1.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l16w2p1.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l16w1p2.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l16w2p2.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l8w1p1.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l8w2p1.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l8w1p2.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l8w2p2.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

## try wd = 3

J=8
L=8
fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l8w3p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=2))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l8w3p2.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l8w3p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=2))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l8w3p2.h5", "main/data", out0)

J=8
L=16
fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l16w3p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=2))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l16w3p2.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l16w3p1.h5", "main/data", out0)

J=8
L=16
fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=2))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l16w3p2.h5", "main/data", out0)

## WU w3 case

out0 = h5read("./Data/abs2j8l8w3p1.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l8w3p2.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l8w3p1.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l8w3p2.h5", "main/data")
angle_iso = S20_iso(out0,8,8,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l16w3p1.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l16w3p2.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l16w3p1.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l16w3p2.h5", "main/data")
angle_iso = S20_iso(out0,8,16,360)
err_extract(angle_iso)

## Start L=32 Insanity

J=8
L=32
fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=1,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l32w1p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=2,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l32w2p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC(test_rod,fink_filter_set2)
end

h5write("./Data/j8l32w3p1.h5", "main/data", out0)

## abs2

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=1,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l32w1p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=2,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l32w2p1.h5", "main/data", out0)

fink_filter_set2 = fink_filter_list(fink_filter_bank_fast(J,L,wd=3,pc=1))
out0 = zeros(2+J*L+J*L*J*L+J*L*J*L,360)
@views for angle=1:360
    test_rod=rod(10,10,30,angle,4)
    out0[:,angle].=speedy_DHC_abs2(test_rod,fink_filter_set2)
end

h5write("./Data/abs2j8l32w3p1.h5", "main/data", out0)

## Work up

out0 = h5read("./Data/j8l32w1p1.h5", "main/data")
angle_iso = S20_iso(out0,8,32,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l32w2p1.h5", "main/data")
angle_iso = S20_iso(out0,8,32,360)
err_extract(angle_iso)

out0 = h5read("./Data/j8l32w3p1.h5", "main/data")
angle_iso = S20_iso(out0,8,32,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l32w1p1.h5", "main/data")
angle_iso = S20_iso(out0,8,32,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l32w2p1.h5", "main/data")
angle_iso = S20_iso(out0,8,32,360)
err_extract(angle_iso)

out0 = h5read("./Data/abs2j8l32w3p1.h5", "main/data")
angle_iso = S20_iso(out0,8,32,360)
err_extract(angle_iso)

## Try S12 analysis on the 2pi coverage cases. No rotation. Then do j1/2

function S12_iso(data,J,L,N)
    S20 = reshape(data[2+J*L+J*L*J*L+1:2+J*L+J*L*J*L+J*L*J*L,:],J,L,J,L,N)
    iso_mat = zeros(J,J,N,L)
    for l=1:L
        intermed = zeros(J,J,N,L)
        for d=1:L
            intermed[:,:,:,d].=S20[:,l,:,mod(l+d,L)+1,:]
        end
        iso_mat[:,:,:,l] .= dropdims(sum(intermed,dims=4),dims=4)
    end
    pow_mat = zeros(J,J,N)
    pow_mat = dropdims(sum(iso_mat,dims=4),dims=4)
    return pow_mat
end

angle_iso = S12_iso(out0,8,16,360)

plot(angle_iso[2,2,:])

function err_extract(iso_out,J,N)
     pdf_err = zeros(J,J)
     temp = zeros(N)
     for j2=1:J
         for j1=1:J
             temp = (iso_out[j1,j2,:].-mean(iso_out[j1,j2,:]))./mean(iso_out[j1,j2,:])
             pdf_err[j1,j2] = maximum(temp)-minimum(temp)
          end
      end
      pdf_err[isnan.(pdf_err)] .= 0
      return maximum(pdf_err[2:7,2:7])
 end

out0 = h5read("./Data/j8l8w1p2.h5", "main/data")
angle_iso = S12_iso(out0,8,8,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/j8l8w2p2.h5", "main/data")
angle_iso = S12_iso(out0,8,8,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/j8l8w3p2.h5", "main/data")
angle_iso = S12_iso(out0,8,8,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/j8l16w1p2.h5", "main/data")
angle_iso = S12_iso(out0,8,16,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/j8l16w2p2.h5", "main/data")
angle_iso = S12_iso(out0,8,16,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/j8l16w3p2.h5", "main/data")
angle_iso = S12_iso(out0,8,16,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/abs2j8l8w1p2.h5", "main/data")
angle_iso = S12_iso(out0,8,8,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/abs2j8l8w2p2.h5", "main/data")
angle_iso = S12_iso(out0,8,8,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/j8l8w3p2.h5", "main/data")
angle_iso = S12_iso(out0,8,8,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/abs2j8l16w1p2.h5", "main/data")
angle_iso = S12_iso(out0,8,16,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/abs2j8l16w2p2.h5", "main/data")
angle_iso = S12_iso(out0,8,16,360)
val = err_extract(angle_iso,8,360)

out0 = h5read("./Data/abs2j8l16w3p2.h5", "main/data")
angle_iso = S12_iso(out0,8,16,360)
val = err_extract(angle_iso,8,360)

max_stars_repo_name: andrew-saydjari/DHC

max_issues_repo_name: andrew-saydjari/DHC

max_forks_repo_name: andrew-saydjari/DHC


text:
using DiffEqBase: DEProblem, ODEProblem
using ProgressMeter

macro showprogress_if(pred, args...)
    quote
        if $(esc(pred))
            @showprogress $(map(esc, args)...)
        else
            $(map(esc, args)...)
        end
    end
end

objname(f) = rsplit(string(f), "."; limit=2)[end]

function is_semi_unitary(U, error=1e-7)
    n, m = size(U)
    I = n > m ? U' * U : U * U'
    diff = abs.(I .- eye(I))
    sum(diff) / length(diff) <= error
end

ceil_if(prop, x) = prop ? ceil(Int, x) : x

function default_Q0(T::DataType, dim_phase, dim_lyap)
    Q0 = zeros(T, dim_phase, dim_lyap)
    for i in 1:dim_lyap
        Q0[1:dim_phase - i + 1, i] = 1
    end
    return qr(Q0)[1]
end

default_Q0(array::AbstractArray, dim_phase, dim_lyap) =
    default_Q0(eltype(array), dim_phase, dim_lyap)

default_Q0(prob::DEProblem, dim_phase, dim_lyap) =
    default_Q0(prob.u0, dim_phase, dim_lyap)

default_Q0(x, dim) = default_Q0(x, dim, dim)


text:
using Documenter
using Random
using Tilde
using StableRNGs

DocMeta.setdocmeta!(Tilde, :DocTestSetup,
    quote
        using Random
        using Tilde
        using StableRNGs
        using MeasureTheory
        Random.seed!(3)
    end; recursive=true)

@testset "Doctests" begin
    doctest(Tilde)
end


text:
cd("INSERT_PATH")

using Distributions
using Polynomials
using DataFrames

include("toolBox.jl")
include("ghmBGSBR.jl")

#########################################################
# Parameter Declaration
#########################################################

# map parameters
theta, x0, y0 = [0., 2. ,-0.1, 0.3], 0.5, 1.

# sample size
ss = 1000
# past prediction horizon
T = 2

# noise f_{2,l} precisions
w1, lam1 = 0.9, 1e07
lam2 = 1e02

# corresponding deterministic orbit
xdet = zeros(ss+T)
xdet[1] = ghm(theta, x0, y0)
xdet[2] = ghm(theta, xdet[1], x0)
for i in 3:(ss+T)
  xdet[i] = ghm(theta, xdet[i-1], xdet[i-2])
end

dataSeed = 29
# fulldata = copy(xdet) # no noise
# fulldata = genDataf1(ss + T, theta, x0, y0, lam2, dataSeed) #f_{1} noise
fulldata = genData(ss + T, theta, x0, y0, w1, lam1, lam2, dataSeed) #f_{2,l} noise
predValues = fulldata[1:T]
data = fulldata[(T+1):end]

# GSBR reconstruction - bPrediction
gibbsIter, burnIn, gEps1, gEps2, thLow, thUp, zLow, zUp, papr, pbpr, thin, samplerSeed =
 150000, 50000, 3., 0.3, -10.0, 10.0, -5.0, 5.0, 1., 10., 10, 2105;

filename = "/Results"
savelocation = string(pwd(), filename, "/seed$samplerSeed")
mkpath(savelocation)
writedlm(string(savelocation,"/xdet.txt"), xdet, '\n')
writedlm(string(savelocation,"/predValues.txt"), predValues)
writedlm(string(savelocation,"/data.txt"), data, '\n')

@time f = open("PATH/smGHM.txt", "a") do f
	for i in 1:150
		println("#######################################")
	    println("Simulation: $i/150")
		println("#######################################")
		x0s = ghmBGSBR(data[280+i:end], T, gibbsIter, burnIn, gEps1, gEps2, thLow, thUp, zLow, zUp, papr, pbpr, thin, samplerSeed);
		writedlm(f, x0s)
		end
	x0s = 0
	gc()
end

max_stars_repo_path: Generalized Henon/runCodeMult.jl

max_stars_repo_name: KosKal/SM-GSBR

max_issues_repo_path: Generalized Henon/runCodeMult.jl

max_issues_repo_name: KosKal/SM-GSBR

max_forks_repo_path: Generalized Henon/runCodeMult.jl

max_forks_repo_name: KosKal/SM-GSBR