text:
module GLX

import GetC.@getCFun

typealias GLenum Cuint
typealias GLboolean Cuchar
typealias GLbitfield Cuint
typealias GLvoid Void
typealias GLbyte Cuchar
typealias GLshort Cshort
typealias GLint Cint
typealias GLubyte Cuchar
typealias GLushort Cushort
typealias GLuint Cuint
typealias GLsizei Csize_t
typealias GLfloat Cfloat
typealias GLclampf Cfloat
typealias GLdouble Cdouble
typealias GLclampd Cdouble
typealias GLchar Cchar
typealias GLint64 Clonglong
typealias GLuint64 Culonglong
typealias GLhalf Cushort
typealias GLhalfARB Cushort
typealias GLhalfNV Cushort
typealias GLsync Ptr{Void}
typealias Pointer Ptr{Void}
typealias GLsizeiptr Cint
typealias GLintptr Cptrdiff_t
const SAMPLES_3DFX = 0x8051
export SAMPLES_3DFX
const SAMPLE_BUFFERS_3DFX = 0x8050
export SAMPLE_BUFFERS_3DFX
const GPU_CLOCK_AMD = 0x21A4
export GPU_CLOCK_AMD
const GPU_FASTEST_TARGET_GPUS_AMD = 0x21A2
export GPU_FASTEST_TARGET_GPUS_AMD
const GPU_NUM_PIPES_AMD = 0x21A5
export GPU_NUM_PIPES_AMD
const GPU_NUM_RB_AMD = 0x21A7
export GPU_NUM_RB_AMD
const GPU_NUM_SIMD_AMD = 0x21A6
export GPU_NUM_SIMD_AMD
const GPU_NUM_SPI_AMD = 0x21A8
export GPU_NUM_SPI_AMD
const GPU_OPENGL_VERSION_STRING_AMD = 0x1F02
export GPU_OPENGL_VERSION_STRING_AMD
const GPU_RAM_AMD = 0x21A3
export GPU_RAM_AMD
const GPU_RENDERER_STRING_AMD = 0x1F01
export GPU_RENDERER_STRING_AMD
const GPU_VENDOR_AMD = 0x1F00
export GPU_VENDOR_AMD
const CONTEXT_DEBUG_BIT_ARB = 0x00000001
export CONTEXT_DEBUG_BIT_ARB
const CONTEXT_FLAGS_ARB = 0x2094
export CONTEXT_FLAGS_ARB
const CONTEXT_FORWARD_COMPATIBLE_BIT_ARB = 0x00000002
export CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
const CONTEXT_MAJOR_VERSION_ARB = 0x2091
export CONTEXT_MAJOR_VERSION_ARB
const CONTEXT_MINOR_VERSION_ARB = 0x2092
export CONTEXT_MINOR_VERSION_ARB
const CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB = 0x00000002
export CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
const CONTEXT_CORE_PROFILE_BIT_ARB = 0x00000001
export CONTEXT_CORE_PROFILE_BIT_ARB
const CONTEXT_PROFILE_MASK_ARB = 0x9126
export CONTEXT_PROFILE_MASK_ARB
const CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB = 0x8256
export CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB
const CONTEXT_ROBUST_ACCESS_BIT_ARB = 0x00000004
export CONTEXT_ROBUST_ACCESS_BIT_ARB
const LOSE_CONTEXT_ON_RESET_ARB = 0x8252
export LOSE_CONTEXT_ON_RESET_ARB
const NO_RESET_NOTIFICATION_ARB = 0x8261
export NO_RESET_NOTIFICATION_ARB
const RGBA_FLOAT_BIT_ARB = 0x00000004
export RGBA_FLOAT_BIT_ARB
const RGBA_FLOAT_TYPE_ARB = 0x20B9
export RGBA_FLOAT_TYPE_ARB
const FRAMEBUFFER_SRGB_CAPABLE_ARB = 0x20B2
export FRAMEBUFFER_SRGB_CAPABLE_ARB
const SAMPLES_ARB = 100001
export SAMPLES_ARB
const SAMPLE_BUFFERS_ARB = 100000
export SAMPLE_BUFFERS_ARB
const CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB = 0x2095
export CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB
const BACK_BUFFER_AGE_EXT = 0x20F4
export BACK_BUFFER_AGE_EXT
const CONTEXT_ES2_PROFILE_BIT_EXT = 0x00000004
export CONTEXT_ES2_PROFILE_BIT_EXT
const CONTEXT_ES_PROFILE_BIT_EXT = 0x00000004
export CONTEXT_ES_PROFILE_BIT_EXT
const RGBA_UNSIGNED_FLOAT_BIT_EXT = 0x00000008
export RGBA_UNSIGNED_FLOAT_BIT_EXT
const RGBA_UNSIGNED_FLOAT_TYPE_EXT = 0x20B1
export RGBA_UNSIGNED_FLOAT_TYPE_EXT
const FRAMEBUFFER_SRGB_CAPABLE_EXT = 0x20B2
export FRAMEBUFFER_SRGB_CAPABLE_EXT
const SHARE_CONTEXT_EXT = 0x800A
export SHARE_CONTEXT_EXT
const VISUAL_ID_EXT = 0x800B
export VISUAL_ID_EXT
const MAX_SWAP_INTERVAL_EXT = 0x20F2
export MAX_SWAP_INTERVAL_EXT
const SWAP_INTERVAL_EXT = 0x20F1
export SWAP_INTERVAL_EXT
const LATE_SWAPS_TEAR_EXT = 0x20F3
export LATE_SWAPS_TEAR_EXT
const AUX0_EXT = 0x20E2
export AUX0_EXT
const AUX1_EXT = 0x20E3
export AUX1_EXT
const AUX2_EXT = 0x20E4
export AUX2_EXT
const AUX3_EXT = 0x20E5
export AUX3_EXT
const AUX4_EXT = 0x20E6
export AUX4_EXT
const AUX5_EXT = 0x20E7
export AUX5_EXT
const AUX6_EXT = 0x20E8
export AUX6_EXT
const AUX7_EXT = 0x20E9
export AUX7_EXT
const AUX8_EXT = 0x20EA
export AUX8_EXT
const AUX9_EXT = 0x20EB
export AUX9_EXT
const BACK_EXT = 0x20E0
export BACK_EXT
const BACK_LEFT_EXT = 0x20E0
export BACK_LEFT_EXT
const BACK_RIGHT_EXT = 0x20E1
export BACK_RIGHT_EXT
const BIND_TO_MIPMAP_TEXTURE_EXT = 0x20D2
export BIND_TO_MIPMAP_TEXTURE_EXT
const BIND_TO_TEXTURE_RGBA_EXT = 0x20D1
export BIND_TO_TEXTURE_RGBA_EXT
const BIND_TO_TEXTURE_RGB_EXT = 0x20D0
export BIND_TO_TEXTURE_RGB_EXT
const BIND_TO_TEXTURE_TARGETS_EXT = 0x20D3
export BIND_TO_TEXTURE_TARGETS_EXT
const FRONT_EXT = 0x20DE
export FRONT_EXT
const FRONT_LEFT_EXT = 0x20DE
export FRONT_LEFT_EXT
const FRONT_RIGHT_EXT = 0x20DF
export FRONT_RIGHT_EXT
const MIPMAP_TEXTURE_EXT = 0x20D7
export MIPMAP_TEXTURE_EXT
const TEXTURE_1D_BIT_EXT = 0x00000001
export TEXTURE_1D_BIT_EXT
const TEXTURE_1D_EXT = 0x20DB
export TEXTURE_1D_EXT
const TEXTURE_2D_BIT_EXT = 0x00000002
export TEXTURE_2D_BIT_EXT
const TEXTURE_2D_EXT = 0x20DC
export TEXTURE_2D_EXT
const TEXTURE_FORMAT_EXT = 0x20D5
export TEXTURE_FORMAT_EXT
const TEXTURE_FORMAT_NONE_EXT = 0x20D8
export TEXTURE_FORMAT_NONE_EXT
const TEXTURE_FORMAT_RGBA_EXT = 0x20DA
export TEXTURE_FORMAT_RGBA_EXT
const TEXTURE_FORMAT_RGB_EXT = 0x20D9
export TEXTURE_FORMAT_RGB_EXT
const TEXTURE_RECTANGLE_BIT_EXT = 0x00000004
export TEXTURE_RECTANGLE_BIT_EXT
const TEXTURE_RECTANGLE_EXT = 0x20DD
export TEXTURE_RECTANGLE_EXT
const TEXTURE_TARGET_EXT = 0x20D6
export TEXTURE_TARGET_EXT
const Y_INVERTED_EXT = 0x20D4
export Y_INVERTED_EXT
const DIRECT_COLOR_EXT = 0x8003
export DIRECT_COLOR_EXT
const GRAY_SCALE_EXT = 0x8006
export GRAY_SCALE_EXT
const PSEUDO_COLOR_EXT = 0x8004
export PSEUDO_COLOR_EXT
const STATIC_COLOR_EXT = 0x8005
export STATIC_COLOR_EXT
const STATIC_GRAY_EXT = 0x8007
export STATIC_GRAY_EXT
const TRANSPARENT_ALPHA_VALUE_EXT = 0x28
export TRANSPARENT_ALPHA_VALUE_EXT
const TRANSPARENT_BLUE_VALUE_EXT = 0x27
export TRANSPARENT_BLUE_VALUE_EXT
const TRANSPARENT_GREEN_VALUE_EXT = 0x26
export TRANSPARENT_GREEN_VALUE_EXT
const TRANSPARENT_INDEX_EXT = 0x8009
export TRANSPARENT_INDEX_EXT
const TRANSPARENT_INDEX_VALUE_EXT = 0x24
export TRANSPARENT_INDEX_VALUE_EXT
const TRANSPARENT_RED_VALUE_EXT = 0x25
export TRANSPARENT_RED_VALUE_EXT
const TRANSPARENT_RGB_EXT = 0x8008
export TRANSPARENT_RGB_EXT
const TRANSPARENT_TYPE_EXT = 0x23
export TRANSPARENT_TYPE_EXT
const TRUE_COLOR_EXT = 0x8002
export TRUE_COLOR_EXT
const X_VISUAL_TYPE_EXT = 0x22
export X_VISUAL_TYPE_EXT
const NON_CONFORMANT_VISUAL_EXT = 0x800D
export NON_CONFORMANT_VISUAL_EXT
const SLOW_VISUAL_EXT = 0x8001
export SLOW_VISUAL_EXT
const VISUAL_CAVEAT_EXT = 0x20
export VISUAL_CAVEAT_EXT
const BUFFER_SWAP_COMPLETE_INTEL_MASK = 0x04000000
export BUFFER_SWAP_COMPLETE_INTEL_MASK
const COPY_COMPLETE_INTEL = 0x8181
export COPY_COMPLETE_INTEL
const EXCHANGE_COMPLETE_INTEL = 0x8180
export EXCHANGE_COMPLETE_INTEL
const FLIP_COMPLETE_INTEL = 0x8182
export FLIP_COMPLETE_INTEL
const X3DFX_FULLSCREEN_MODE_MESA = 0x2
export X3DFX_FULLSCREEN_MODE_MESA
const X3DFX_WINDOW_MODE_MESA = 0x1
export X3DFX_WINDOW_MODE_MESA
const FLOAT_COMPONENTS_NV = 0x20B0
export FLOAT_COMPONENTS_NV
const COLOR_SAMPLES_NV = 0x20B3
export COLOR_SAMPLES_NV
const COVERAGE_SAMPLES_NV = 100001
export COVERAGE_SAMPLES_NV
const NUM_VIDEO_SLOTS_NV = 0x20F0
export NUM_VIDEO_SLOTS_NV
const DEVICE_ID_NV = 0x20CD
export DEVICE_ID_NV
const NUM_VIDEO_CAPTURE_SLOTS_NV = 0x20CF
export NUM_VIDEO_CAPTURE_SLOTS_NV
const UNIQUE_ID_NV = 0x20CE
export UNIQUE_ID_NV
const VIDEO_OUT_ALPHA_NV = 0x20C4
export VIDEO_OUT_ALPHA_NV
const VIDEO_OUT_COLOR_AND_ALPHA_NV = 0x20C6
export VIDEO_OUT_COLOR_AND_ALPHA_NV
const VIDEO_OUT_COLOR_AND_DEPTH_NV = 0x20C7
export VIDEO_OUT_COLOR_AND_DEPTH_NV
const VIDEO_OUT_COLOR_NV = 0x20C3
export VIDEO_OUT_COLOR_NV
const VIDEO_OUT_DEPTH_NV = 0x20C5
export VIDEO_OUT_DEPTH_NV
const VIDEO_OUT_FIELD_1_NV = 0x20C9
export VIDEO_OUT_FIELD_1_NV
const VIDEO_OUT_FIELD_2_NV = 0x20CA
export VIDEO_OUT_FIELD_2_NV
const VIDEO_OUT_FRAME_NV = 0x20C8
export VIDEO_OUT_FRAME_NV
const VIDEO_OUT_STACKED_FIELDS_1_2_NV = 0x20CB
export VIDEO_OUT_STACKED_FIELDS_1_2_NV
const VIDEO_OUT_STACKED_FIELDS_2_1_NV = 0x20CC
export VIDEO_OUT_STACKED_FIELDS_2_1_NV
const SWAP_COPY_OML = 0x8062
export SWAP_COPY_OML
const SWAP_EXCHANGE_OML = 0x8061
export SWAP_EXCHANGE_OML
const SWAP_METHOD_OML = 0x8060
export SWAP_METHOD_OML
const SWAP_UNDEFINED_OML = 0x8063
export SWAP_UNDEFINED_OML
const BLENDED_RGBA_SGIS = 0x8025
export BLENDED_RGBA_SGIS
const SAMPLES_SGIS = 100001
export SAMPLES_SGIS
const SAMPLE_BUFFERS_SGIS = 100000
export SAMPLE_BUFFERS_SGIS
const MULTISAMPLE_SUB_RECT_HEIGHT_SGIS = 0x8027
export MULTISAMPLE_SUB_RECT_HEIGHT_SGIS
const MULTISAMPLE_SUB_RECT_WIDTH_SGIS = 0x8026
export MULTISAMPLE_SUB_RECT_WIDTH_SGIS
const DIGITAL_MEDIA_PBUFFER_SGIX = 0x8024
export DIGITAL_MEDIA_PBUFFER_SGIX
const COLOR_INDEX_BIT_SGIX = 0x00000002
export COLOR_INDEX_BIT_SGIX
const COLOR_INDEX_TYPE_SGIX = 0x8015
export COLOR_INDEX_TYPE_SGIX
const DRAWABLE_TYPE_SGIX = 0x8010
export DRAWABLE_TYPE_SGIX
const FBCONFIG_ID_SGIX = 0x8013
export FBCONFIG_ID_SGIX
const PIXMAP_BIT_SGIX = 0x00000002
export PIXMAP_BIT_SGIX
const RENDER_TYPE_SGIX = 0x8011
export RENDER_TYPE_SGIX
const RGBA_BIT_SGIX = 0x00000001
export RGBA_BIT_SGIX
const RGBA_TYPE_SGIX = 0x8014
export RGBA_TYPE_SGIX
const WINDOW_BIT_SGIX = 0x00000001
export WINDOW_BIT_SGIX
const X_RENDERABLE_SGIX = 0x8012
export X_RENDERABLE_SGIX
const BAD_HYPERPIPE_CONFIG_SGIX = 91
export BAD_HYPERPIPE_CONFIG_SGIX
const BAD_HYPERPIPE_SGIX = 92
export BAD_HYPERPIPE_SGIX
const HYPERPIPE_DISPLAY_PIPE_SGIX = 0x00000001
export HYPERPIPE_DISPLAY_PIPE_SGIX
const HYPERPIPE_ID_SGIX = 0x8030
export HYPERPIPE_ID_SGIX
const HYPERPIPE_PIPE_NAME_LENGTH_SGIX = 80
export HYPERPIPE_PIPE_NAME_LENGTH_SGIX
const HYPERPIPE_PIXEL_AVERAGE_SGIX = 0x00000004
export HYPERPIPE_PIXEL_AVERAGE_SGIX
const HYPERPIPE_RENDER_PIPE_SGIX = 0x00000002
export HYPERPIPE_RENDER_PIPE_SGIX
const HYPERPIPE_STEREO_SGIX = 0x00000003
export HYPERPIPE_STEREO_SGIX
const PIPE_RECT_LIMITS_SGIX = 0x00000002
export PIPE_RECT_LIMITS_SGIX
const PIPE_RECT_SGIX = 0x00000001
export PIPE_RECT_SGIX
const ACCUM_BUFFER_BIT_SGIX = 0x00000080
export ACCUM_BUFFER_BIT_SGIX
const AUX_BUFFERS_BIT_SGIX = 0x00000010
export AUX_BUFFERS_BIT_SGIX
const BACK_LEFT_BUFFER_BIT_SGIX = 0x00000004
export BACK_LEFT_BUFFER_BIT_SGIX
const BACK_RIGHT_BUFFER_BIT_SGIX = 0x00000008
export BACK_RIGHT_BUFFER_BIT_SGIX
const BUFFER_CLOBBER_MASK_SGIX = 0x08000000
export BUFFER_CLOBBER_MASK_SGIX
const DAMAGED_SGIX = 0x8020
export DAMAGED_SGIX
const DEPTH_BUFFER_BIT_SGIX = 0x00000020
export DEPTH_BUFFER_BIT_SGIX
const EVENT_MASK_SGIX = 0x801F
export EVENT_MASK_SGIX
const FRONT_LEFT_BUFFER_BIT_SGIX = 0x00000001
export FRONT_LEFT_BUFFER_BIT_SGIX
const FRONT_RIGHT_BUFFER_BIT_SGIX = 0x00000002
export FRONT_RIGHT_BUFFER_BIT_SGIX
const HEIGHT_SGIX = 0x801E
export HEIGHT_SGIX
const LARGEST_PBUFFER_SGIX = 0x801C
export LARGEST_PBUFFER_SGIX
const MAX_PBUFFER_HEIGHT_SGIX = 0x8017
export MAX_PBUFFER_HEIGHT_SGIX
const MAX_PBUFFER_PIXELS_SGIX = 0x8018
export MAX_PBUFFER_PIXELS_SGIX
const MAX_PBUFFER_WIDTH_SGIX = 0x8016
export MAX_PBUFFER_WIDTH_SGIX
const OPTIMAL_PBUFFER_HEIGHT_SGIX = 0x801A
export OPTIMAL_PBUFFER_HEIGHT_SGIX
const OPTIMAL_PBUFFER_WIDTH_SGIX = 0x8019
export OPTIMAL_PBUFFER_WIDTH_SGIX
const PBUFFER_BIT_SGIX = 0x00000004
export PBUFFER_BIT_SGIX
const PBUFFER_SGIX = 0x8023
export PBUFFER_SGIX
const PRESERVED_CONTENTS_SGIX = 0x801B
export PRESERVED_CONTENTS_SGIX
const SAMPLE_BUFFERS_BIT_SGIX = 0x00000100
export SAMPLE_BUFFERS_BIT_SGIX
const SAVED_SGIX = 0x8021
export SAVED_SGIX
const STENCIL_BUFFER_BIT_SGIX = 0x00000040
export STENCIL_BUFFER_BIT_SGIX
const WIDTH_SGIX = 0x801D
export WIDTH_SGIX
const WINDOW_SGIX = 0x8022
export WINDOW_SGIX
const SYNC_FRAME_SGIX = 0x00000000
export SYNC_FRAME_SGIX
const SYNC_SWAP_SGIX = 0x00000001
export SYNC_SWAP_SGIX
const VISUAL_SELECT_GROUP_SGIX = 0x8028
export VISUAL_SELECT_GROUP_SGIX
const ACCUM_BUFFER_BIT = 0x00000080
export ACCUM_BUFFER_BIT
const AUX_BUFFERS_BIT = 0x00000010
export AUX_BUFFERS_BIT
const BACK_LEFT_BUFFER_BIT = 0x00000004
export BACK_LEFT_BUFFER_BIT
const BACK_RIGHT_BUFFER_BIT = 0x00000008
export BACK_RIGHT_BUFFER_BIT
const COLOR_INDEX_BIT = 0x00000002
export COLOR_INDEX_BIT
const COLOR_INDEX_TYPE = 0x8015
export COLOR_INDEX_TYPE
const CONFIG_CAVEAT = 0x20
export CONFIG_CAVEAT
const DAMAGED = 0x8020
export DAMAGED
const DEPTH_BUFFER_BIT = 0x00000020
export DEPTH_BUFFER_BIT
const DIRECT_COLOR = 0x8003
export DIRECT_COLOR
const DONT_CARE = 0xFFFFFFFF
export DONT_CARE
const DRAWABLE_TYPE = 0x8010
export DRAWABLE_TYPE
const EVENT_MASK = 0x801F
export EVENT_MASK
const FBCONFIG_ID = 0x8013
export FBCONFIG_ID
const FRONT_LEFT_BUFFER_BIT = 0x00000001
export FRONT_LEFT_BUFFER_BIT
const FRONT_RIGHT_BUFFER_BIT = 0x00000002
export FRONT_RIGHT_BUFFER_BIT
const GRAY_SCALE = 0x8006
export GRAY_SCALE
const HEIGHT = 0x801E
export HEIGHT
const LARGEST_PBUFFER = 0x801C
export LARGEST_PBUFFER
const MAX_PBUFFER_HEIGHT = 0x8017
export MAX_PBUFFER_HEIGHT
const MAX_PBUFFER_PIXELS = 0x8018
export MAX_PBUFFER_PIXELS
const MAX_PBUFFER_WIDTH = 0x8016
export MAX_PBUFFER_WIDTH
const NONE = 0x8000
export NONE
const NON_CONFORMANT_CONFIG = 0x800D
export NON_CONFORMANT_CONFIG
const PBUFFER = 0x8023
export PBUFFER
const PBUFFER_BIT = 0x00000004
export PBUFFER_BIT
const PBUFFER_CLOBBER_MASK = 0x08000000
export PBUFFER_CLOBBER_MASK
const PBUFFER_HEIGHT = 0x8040
export PBUFFER_HEIGHT
const PBUFFER_WIDTH = 0x8041
export PBUFFER_WIDTH
const PIXMAP_BIT = 0x00000002
export PIXMAP_BIT
const PRESERVED_CONTENTS = 0x801B
export PRESERVED_CONTENTS
const PSEUDO_COLOR = 0x8004
export PSEUDO_COLOR
const RENDER_TYPE = 0x8011
export RENDER_TYPE
const RGBA_BIT = 0x00000001
export RGBA_BIT
const RGBA_TYPE = 0x8014
export RGBA_TYPE
const SAVED = 0x8021
export SAVED
const SCREEN = 0x800C
export SCREEN
const SLOW_CONFIG = 0x8001
export SLOW_CONFIG
const STATIC_COLOR = 0x8005
export STATIC_COLOR
const STATIC_GRAY = 0x8007
export STATIC_GRAY
const STENCIL_BUFFER_BIT = 0x00000040
export STENCIL_BUFFER_BIT
const TRANSPARENT_ALPHA_VALUE = 0x28
export TRANSPARENT_ALPHA_VALUE
const TRANSPARENT_BLUE_VALUE = 0x27
export TRANSPARENT_BLUE_VALUE
const TRANSPARENT_GREEN_VALUE = 0x26
export TRANSPARENT_GREEN_VALUE
const TRANSPARENT_INDEX = 0x8009
export TRANSPARENT_INDEX
const TRANSPARENT_INDEX_VALUE = 0x24
export TRANSPARENT_INDEX_VALUE
const TRANSPARENT_RED_VALUE = 0x25
export TRANSPARENT_RED_VALUE
const TRANSPARENT_RGB = 0x8008
export TRANSPARENT_RGB
const TRANSPARENT_TYPE = 0x23
export TRANSPARENT_TYPE
const TRUE_COLOR = 0x8002
export TRUE_COLOR
const VISUAL_ID = 0x800B
export VISUAL_ID
const WIDTH = 0x801D
export WIDTH
const WINDOW = 0x8022
export WINDOW
const WINDOW_BIT = 0x00000001
export WINDOW_BIT
const X_RENDERABLE = 0x8012
export X_RENDERABLE
const X_VISUAL_TYPE = 0x22
export X_VISUAL_TYPE
const SAMPLES = 100001
export SAMPLES
const SAMPLE_BUFFERS = 100000
export SAMPLE_BUFFERS
@getCFun "libGL" glxCreateContextAttribsARB glxCreateContextAttribsARB(dpy::Ptr{Display}, config::GLXFBConfig, share_context::GLXContext, direct::Cint, attrib_list::Ptr{Cint})::Ptr{Void}
export glxCreateContextAttribsARB
@getCFun "libGL" glxGetProcAddressARB glxGetProcAddressARB(procName::Ptr{GLubyte})::Ptr{Void}
export glxGetProcAddressARB
@getCFun "libGL" glxGetCurrentDisplayEXT glxGetCurrentDisplayEXT()::Ptr{Void}
export glxGetCurrentDisplayEXT
@getCFun "libGL" glxQueryContextInfoEXT glxQueryContextInfoEXT(dpy::Ptr{Display}, context::GLXContext, attribute::Cint, value::Ptr{Cint})::Cint
export glxQueryContextInfoEXT
@getCFun "libGL" glxGetContextIDEXT glxGetContextIDEXT(context::GLXContext)::Cuint
export glxGetContextIDEXT
@getCFun "libGL" glxImportContextEXT glxImportContextEXT(dpy::Ptr{Display}, contextID::GLXContextID)::Ptr{Void}
export glxImportContextEXT
@getCFun "libGL" glxFreeContextEXT glxFreeContextEXT(dpy::Ptr{Display}, context::GLXContext)::Void
export glxFreeContextEXT
@getCFun "libGL" glxSwapIntervalEXT glxSwapIntervalEXT(dpy::Ptr{Display}, drawable::GLXDrawable, interval::int)::Void
export glxSwapIntervalEXT
@getCFun "libGL" glxBindTexImageEXT glxBindTexImageEXT(dpy::Ptr{Display}, drawable::GLXDrawable, buffer::int, attrib_list::Ptr{int})::Void
export glxBindTexImageEXT
@getCFun "libGL" glxReleaseTexImageEXT glxReleaseTexImageEXT(dpy::Ptr{Display}, drawable::GLXDrawable, buffer::int)::Void
export glxReleaseTexImageEXT
@getCFun "libGL" glxGetAGPOffsetMESA glxGetAGPOffsetMESA(pointer::Ptr{Void})::Cuint
export glxGetAGPOffsetMESA
@getCFun "libGL" glxCopySubBufferMESA glxCopySubBufferMESA(dpy::Ptr{Display}, drawable::GLXDrawable, x::int, y::int, width::int, height::int)::Void
export glxCopySubBufferMESA
@getCFun "libGL" glxCreateGLXPixmapMESA glxCreateGLXPixmapMESA(dpy::Ptr{Display}, visual::XVisualInfo, pixmap::Pixmap, cmap::Colormap)::Ptr{Void}
export glxCreateGLXPixmapMESA
@getCFun "libGL" glxReleaseBuffersMESA glxReleaseBuffersMESA(dpy::Ptr{Display}, drawable::GLXDrawable)::Cint
export glxReleaseBuffersMESA
@getCFun "libGL" glxSet3DfxModeMESA glxSet3DfxModeMESA(mode::Cint)::Cint
export glxSet3DfxModeMESA
@getCFun "libGL" glxCopyImageSubDataNV glxCopyImageSubDataNV(dpy::Ptr{Display}, srcCtx::GLXContext, srcName::GLuint, srcTarget::GLenum, srcLevel::GLint, srcX::GLint, srcY::GLint, srcZ::GLint, dstCtx::GLXContext, dstName::GLuint, dstTarget::GLenum, dstLevel::GLint, dstX::GLint, dstY::GLint, dstZ::GLint, width::GLsizei, height::GLsizei, depth::GLsizei)::Void
export glxCopyImageSubDataNV
@getCFun "libGL" glxEnumerateVideoDevicesNV glxEnumerateVideoDevicesNV(dpy::Ptr{Display}, screen::Cint, nelements::Ptr{Cint})::Ptr{Cuint}
export glxEnumerateVideoDevicesNV
@getCFun "libGL" glxBindVideoDeviceNV glxBindVideoDeviceNV(dpy::Ptr{Display}, video_slot::Cuint, video_device::Cuint, attrib_list::Ptr{Cint})::Cint
export glxBindVideoDeviceNV
@getCFun "libGL" glxJoinSwapGroupNV glxJoinSwapGroupNV(dpy::Ptr{Display}, drawable::GLXDrawable, group::GLuint)::Cint
export glxJoinSwapGroupNV
@getCFun "libGL" glxBindSwapBarrierNV glxBindSwapBarrierNV(dpy::Ptr{Display}, group::GLuint, barrier::GLuint)::Cint
export glxBindSwapBarrierNV
@getCFun "libGL" glxQuerySwapGroupNV glxQuerySwapGroupNV(dpy::Ptr{Display}, drawable::GLXDrawable, group::Ptr{GLuint}, barrier::Ptr{GLuint})::Cint
export glxQuerySwapGroupNV
@getCFun "libGL" glxQueryMaxSwapGroupsNV glxQueryMaxSwapGroupsNV(dpy::Ptr{Display}, screen::Cint, maxGroups::Ptr{GLuint}, maxBarriers::Ptr{GLuint})::Cint
export glxQueryMaxSwapGroupsNV
@getCFun "libGL" glxQueryFrameCountNV glxQueryFrameCountNV(dpy::Ptr{Display}, screen::Cint, count::Ptr{GLuint})::Cint
export glxQueryFrameCountNV
@getCFun "libGL" glxResetFrameCountNV glxResetFrameCountNV(dpy::Ptr{Display}, screen::Cint)::Cint
export glxResetFrameCountNV
@getCFun "libGL" glxBindVideoCaptureDeviceNV glxBindVideoCaptureDeviceNV(dpy::Ptr{Display}, video_capture_slot::Cuint, device::GLXVideoCaptureDeviceNV)::Cint
export glxBindVideoCaptureDeviceNV
@getCFun "libGL" glxEnumerateVideoCaptureDevicesNV glxEnumerateVideoCaptureDevicesNV(dpy::Ptr{Display}, screen::Cint, nelements::Ptr{Cint})::Ptr{Void}
export glxEnumerateVideoCaptureDevicesNV
@getCFun "libGL" glxLockVideoCaptureDeviceNV glxLockVideoCaptureDeviceNV(dpy::Ptr{Display}, device::GLXVideoCaptureDeviceNV)::Void
export glxLockVideoCaptureDeviceNV
@getCFun "libGL" glxQueryVideoCaptureDeviceNV glxQueryVideoCaptureDeviceNV(dpy::Ptr{Display}, device::GLXVideoCaptureDeviceNV, attribute::Cint, value::Ptr{Cint})::Cint
export glxQueryVideoCaptureDeviceNV
@getCFun "libGL" glxReleaseVideoCaptureDeviceNV glxReleaseVideoCaptureDeviceNV(dpy::Ptr{Display}, device::GLXVideoCaptureDeviceNV)::Void
export glxReleaseVideoCaptureDeviceNV
@getCFun "libGL" glxGetVideoDeviceNV glxGetVideoDeviceNV(dpy::Ptr{Display}, screen::Cint, numVideoDevices::Cint, pVideoDevice::GLXVideoDeviceNV)::Cint
export glxGetVideoDeviceNV
@getCFun "libGL" glxReleaseVideoDeviceNV glxReleaseVideoDeviceNV(dpy::Ptr{Display}, screen::Cint, VideoDevice::GLXVideoDeviceNV)::Cint
export glxReleaseVideoDeviceNV
@getCFun "libGL" glxBindVideoImageNV glxBindVideoImageNV(dpy::Ptr{Display}, VideoDevice::GLXVideoDeviceNV, pbuf::GLXPbuffer, iVideoBuffer::Cint)::Cint
export glxBindVideoImageNV
@getCFun "libGL" glxReleaseVideoImageNV glxReleaseVideoImageNV(dpy::Ptr{Display}, pbuf::GLXPbuffer)::Cint
export glxReleaseVideoImageNV
@getCFun "libGL" glxSendPbufferToVideoNV glxSendPbufferToVideoNV(dpy::Ptr{Display}, pbuf::GLXPbuffer, iBufferType::Cint, pulCounterPbuffer::Ptr{Culong}, bBlock::GLboolean)::Cint
export glxSendPbufferToVideoNV
@getCFun "libGL" glxGetVideoInfoNV glxGetVideoInfoNV(dpy::Ptr{Display}, screen::Cint, VideoDevice::GLXVideoDeviceNV, pulCounterOutputPbuffer::Ptr{Culong}, pulCounterOutputVideo::Ptr{Culong})::Cint
export glxGetVideoInfoNV
@getCFun "libGL" glxGetSyncValuesOML glxGetSyncValuesOML(dpy::Ptr{Display}, drawable::GLXDrawable, ust::Ptr{Clonglong}, msc::Ptr{Clonglong}, sbc::Ptr{Clonglong})::Cint
export glxGetSyncValuesOML
@getCFun "libGL" glxGetMscRateOML glxGetMscRateOML(dpy::Ptr{Display}, drawable::GLXDrawable, numerator::Ptr{Cint}, denominator::Ptr{Cint})::Cint
export glxGetMscRateOML
@getCFun "libGL" glxSwapBuffersMscOML glxSwapBuffersMscOML(dpy::Ptr{Display}, drawable::GLXDrawable, target_msc::CClonglong, divisor::CClonglong, remainder::CClonglong)::CClonglong
export glxSwapBuffersMscOML
@getCFun "libGL" glxWaitForMscOML glxWaitForMscOML(dpy::Ptr{Display}, drawable::GLXDrawable, target_msc::CClonglong, divisor::CClonglong, remainder::CClonglong, ust::Ptr{Clonglong}, msc::Ptr{Clonglong}, sbc::Ptr{Clonglong})::Cint
export glxWaitForMscOML
@getCFun "libGL" glxWaitForSbcOML glxWaitForSbcOML(dpy::Ptr{Display}, drawable::GLXDrawable, target_sbc::CClonglong, ust::Ptr{Clonglong}, msc::Ptr{Clonglong}, sbc::Ptr{Clonglong})::Cint
export glxWaitForSbcOML
@getCFun "libGL" glxAssociateDMPbufferSGIX glxAssociateDMPbufferSGIX(dpy::Ptr{Display}, pbuffer::GLXPbufferSGIX, params::DMparams, dmbuffer::DMbuffer)::Cint
export glxAssociateDMPbufferSGIX
@getCFun "libGL" glxGetFBConfigAttribSGIX glxGetFBConfigAttribSGIX(dpy::Ptr{Display}, config::GLXFBConfigSGIX, attribute::Cint, value::Ptr{Cint})::Cint
export glxGetFBConfigAttribSGIX
@getCFun "libGL" glxChooseFBConfigSGIX glxChooseFBConfigSGIX(dpy::Ptr{Display}, screen::Cint, attrib_list::Ptr{Cint}, nelements::Ptr{Cint})::Ptr{Void}
export glxChooseFBConfigSGIX
@getCFun "libGL" glxCreateGLXPixmapWithConfigSGIX glxCreateGLXPixmapWithConfigSGIX(dpy::Ptr{Display}, config::GLXFBConfigSGIX, pixmap::Pixmap)::Ptr{Void}
export glxCreateGLXPixmapWithConfigSGIX
@getCFun "libGL" glxCreateContextWithConfigSGIX glxCreateContextWithConfigSGIX(dpy::Ptr{Display}, config::GLXFBConfigSGIX, render_type::Cint, share_list::GLXContext, direct::Cint)::Ptr{Void}
export glxCreateContextWithConfigSGIX
@getCFun "libGL" glxGetVisualFromFBConfigSGIX glxGetVisualFromFBConfigSGIX(dpy::Ptr{Display}, config::GLXFBConfigSGIX)::Ptr{Void}
export glxGetVisualFromFBConfigSGIX
@getCFun "libGL" glxGetFBConfigFromVisualSGIX glxGetFBConfigFromVisualSGIX(dpy::Ptr{Display}, vis::XVisualInfo)::Ptr{Void}
export glxGetFBConfigFromVisualSGIX
@getCFun "libGL" glxQueryHyperpipeNetworkSGIX glxQueryHyperpipeNetworkSGIX(dpy::Ptr{Display}, npipes::Ptr{Cint})::Ptr{Void}
export glxQueryHyperpipeNetworkSGIX
@getCFun "libGL" glxHyperpipeConfigSGIX glxHyperpipeConfigSGIX(dpy::Ptr{Display}, networkId::Cint, npipes::Cint, cfg::Ptr{GLXHyperpipeConfigSGIX}, hpId::Ptr{Cint})::Cint
export glxHyperpipeConfigSGIX
@getCFun "libGL" glxQueryHyperpipeConfigSGIX glxQueryHyperpipeConfigSGIX(dpy::Ptr{Display}, hpId::Cint, npipes::Ptr{Cint})::Ptr{Void}
export glxQueryHyperpipeConfigSGIX
@getCFun "libGL" glxDestroyHyperpipeConfigSGIX glxDestroyHyperpipeConfigSGIX(dpy::Ptr{Display}, hpId::Cint)::Cint
export glxDestroyHyperpipeConfigSGIX
@getCFun "libGL" glxBindHyperpipeSGIX glxBindHyperpipeSGIX(dpy::Ptr{Display}, hpId::Cint)::Cint
export glxBindHyperpipeSGIX
@getCFun "libGL" glxQueryHyperpipeBestAttribSGIX glxQueryHyperpipeBestAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, attribList::Ptr{Void}, returnAttribList::Ptr{Void})::Cint
export glxQueryHyperpipeBestAttribSGIX
@getCFun "libGL" glxHyperpipeAttribSGIX glxHyperpipeAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, attribList::Ptr{Void})::Cint
export glxHyperpipeAttribSGIX
@getCFun "libGL" glxQueryHyperpipeAttribSGIX glxQueryHyperpipeAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, returnAttribList::Ptr{Void})::Cint
export glxQueryHyperpipeAttribSGIX
@getCFun "libGL" glxCreateGLXPbufferSGIX glxCreateGLXPbufferSGIX(dpy::Ptr{Display}, config::GLXFBConfigSGIX, width::Cuint, height::Cuint, attrib_list::Ptr{Cint})::Ptr{Void}
export glxCreateGLXPbufferSGIX
@getCFun "libGL" glxDestroyGLXPbufferSGIX glxDestroyGLXPbufferSGIX(dpy::Ptr{Display}, pbuf::GLXPbufferSGIX)::Void
export glxDestroyGLXPbufferSGIX
@getCFun "libGL" glxQueryGLXPbufferSGIX glxQueryGLXPbufferSGIX(dpy::Ptr{Display}, pbuf::GLXPbufferSGIX, attribute::Cint, value::Ptr{uint32})::Cint
export glxQueryGLXPbufferSGIX
@getCFun "libGL" glxSelectEventSGIX glxSelectEventSGIX(dpy::Ptr{Display}, drawable::GLXDrawable, mask::unsigned_long)::Void
export glxSelectEventSGIX
@getCFun "libGL" glxGetSelectedEventSGIX glxGetSelectedEventSGIX(dpy::Ptr{Display}, drawable::GLXDrawable, mask::Ptr{unsigned_long})::Void
export glxGetSelectedEventSGIX
@getCFun "libGL" glxBindSwapBarrierSGIX glxBindSwapBarrierSGIX(dpy::Ptr{Display}, drawable::GLXDrawable, barrier::int)::Void
export glxBindSwapBarrierSGIX
@getCFun "libGL" glxQueryMaxSwapBarriersSGIX glxQueryMaxSwapBarriersSGIX(dpy::Ptr{Display}, screen::Cint, max::Ptr{Cint})::Cint
export glxQueryMaxSwapBarriersSGIX
@getCFun "libGL" glxJoinSwapGroupSGIX glxJoinSwapGroupSGIX(dpy::Ptr{Display}, drawable::GLXDrawable, member::GLXDrawable)::Void
export glxJoinSwapGroupSGIX
@getCFun "libGL" glxBindChannelToWindowSGIX glxBindChannelToWindowSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, window::Window)::Cint
export glxBindChannelToWindowSGIX
@getCFun "libGL" glxChannelRectSGIX glxChannelRectSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, x::Cint, y::Cint, w::Cint, h::Cint)::Cint
export glxChannelRectSGIX
@getCFun "libGL" glxQueryChannelRectSGIX glxQueryChannelRectSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, dx::Ptr{Cint}, dy::Ptr{Cint}, dw::Ptr{Cint}, dh::Ptr{Cint})::Cint
export glxQueryChannelRectSGIX
@getCFun "libGL" glxQueryChannelDeltasSGIX glxQueryChannelDeltasSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, x::Ptr{Cint}, y::Ptr{Cint}, w::Ptr{Cint}, h::Ptr{Cint})::Cint
export glxQueryChannelDeltasSGIX
@getCFun "libGL" glxChannelRectSyncSGIX glxChannelRectSyncSGIX(display::Ptr{Display}, screen::Cint, channel::Cint, synctype::GLenum)::Cint
export glxChannelRectSyncSGIX
@getCFun "libGL" glxCreateGLXVideoSourceSGIX glxCreateGLXVideoSourceSGIX(display::Ptr{Display}, screen::Cint, server::VLServer, path::VLPath, nodeClass::Cint, drainNode::VLNode)::Ptr{Void}
export glxCreateGLXVideoSourceSGIX
@getCFun "libGL" glxDestroyGLXVideoSourceSGIX glxDestroyGLXVideoSourceSGIX(dpy::Ptr{Display}, glxvideosource::Ptr{GGLXVideoSourceSGIX})::Void
export glxDestroyGLXVideoSourceSGIX
@getCFun "libGL" glxCushionSGI glxCushionSGI(dpy::Ptr{Display}, window::Window, cushion::float32)::Void
export glxCushionSGI
@getCFun "libGL" glxMakeCurrentReadSGI glxMakeCurrentReadSGI(dpy::Ptr{Display}, draw::GLXDrawable, read::GLXDrawable, ctx::GLXContext)::Cint
export glxMakeCurrentReadSGI
@getCFun "libGL" glxGetCurrentReadDrawableSGI glxGetCurrentReadDrawableSGI()::Ptr{Void}
export glxGetCurrentReadDrawableSGI
@getCFun "libGL" glxSwapIntervalSGI glxSwapIntervalSGI(interval::Cint)::Cint
export glxSwapIntervalSGI
@getCFun "libGL" glxGetVideoSyncSGI glxGetVideoSyncSGI(count::Ptr{uint32})::Cint
export glxGetVideoSyncSGI
@getCFun "libGL" glxWaitVideoSyncSGI glxWaitVideoSyncSGI(divisor::Cint, remainder::Cint, count::Ptr{uint32})::Cint
export glxWaitVideoSyncSGI
@getCFun "libGL" glxGetTransparentIndexSUN glxGetTransparentIndexSUN(dpy::Ptr{Display}, overlay::Window, underlay::Window, pTransparentIndex::Ptr{long})::Cint
export glxGetTransparentIndexSUN
@getCFun "libGL" glxGetFBConfigs glxGetFBConfigs(dpy::Ptr{Display}, screen::Cint, nelements::Ptr{Cint})::Ptr{Void}
export glxGetFBConfigs
@getCFun "libGL" glxChooseFBConfig glxChooseFBConfig(dpy::Ptr{Display}, screen::Cint, attrib_list::Ptr{Cint}, nelements::Ptr{Cint})::Ptr{Void}
export glxChooseFBConfig
@getCFun "libGL" glxGetFBConfigAttrib glxGetFBConfigAttrib(dpy::Ptr{Display}, config::GLXFBConfig, attribute::Cint, value::Ptr{Cint})::Cint
export glxGetFBConfigAttrib
@getCFun "libGL" glxGetVisualFromFBConfig glxGetVisualFromFBConfig(dpy::Ptr{Display}, config::GLXFBConfig)::Ptr{Void}
export glxGetVisualFromFBConfig
@getCFun "libGL" glxCreateWindow glxCreateWindow(dpy::Ptr{Display}, config::GLXFBConfig, win::Window, attrib_list::Ptr{Cint})::Ptr{Void}
export glxCreateWindow
@getCFun "libGL" glxDestroyWindow glxDestroyWindow(dpy::Ptr{Display}, win::GLXWindow)::Void
export glxDestroyWindow
@getCFun "libGL" glxCreatePixmap glxCreatePixmap(dpy::Ptr{Display}, config::GLXFBConfig, pixmap::Pixmap, attrib_list::Ptr{Cint})::Ptr{Void}
export glxCreatePixmap
@getCFun "libGL" glxDestroyPixmap glxDestroyPixmap(dpy::Ptr{Display}, pixmap::GLXPixmap)::Void
export glxDestroyPixmap
@getCFun "libGL" glxCreatePbuffer glxCreatePbuffer(dpy::Ptr{Display}, config::GLXFBConfig, attrib_list::Ptr{Cint})::Ptr{Void}
export glxCreatePbuffer
@getCFun "libGL" glxDestroyPbuffer glxDestroyPbuffer(dpy::Ptr{Display}, pbuf::GLXPbuffer)::Void
export glxDestroyPbuffer
@getCFun "libGL" glxQueryDrawable glxQueryDrawable(dpy::Ptr{Display}, draw::GLXDrawable, attribute::int, value::Ptr{uint32})::Void
export glxQueryDrawable
@getCFun "libGL" glxCreateNewContext glxCreateNewContext(dpy::Ptr{Display}, config::GLXFBConfig, render_type::Cint, share_list::GLXContext, direct::Cint)::Ptr{Void}
export glxCreateNewContext
@getCFun "libGL" glxMakeContextCurrent glxMakeContextCurrent(dpy::Ptr{Display}, draw::GLXDrawable, read::GLXDrawable, ctx::GLXContext)::Cint
export glxMakeContextCurrent
@getCFun "libGL" glxGetCurrentReadDrawable glxGetCurrentReadDrawable()::Ptr{Void}
export glxGetCurrentReadDrawable
@getCFun "libGL" glxGetCurrentDisplay glxGetCurrentDisplay()::Ptr{Void}
export glxGetCurrentDisplay
@getCFun "libGL" glxQueryContext glxQueryContext(dpy::Ptr{Display}, ctx::GLXContext, attribute::Cint, value::Ptr{Cint})::Cint
export glxQueryContext
@getCFun "libGL" glxSelectEvent glxSelectEvent(dpy::Ptr{Display}, draw::GLXDrawable, event_mask::unsigned_long)::Void
export glxSelectEvent
@getCFun "libGL" glxGetSelectedEvent glxGetSelectedEvent(dpy::Ptr{Display}, draw::GLXDrawable, event_mask::Ptr{unsigned_long})::Void
export glxGetSelectedEvent
@getCFun "libGL" glxGetProcAddress glxGetProcAddress(procName::Ptr{GLubyte})::Ptr{Void}
export glxGetProcAddress
@getCFun "libGL" glxRender glxRender()::Void
export glxRender
@getCFun "libGL" glxRenderLarge glxRenderLarge()::Void
export glxRenderLarge
@getCFun "libGL" glxCreateContext glxCreateContext(gc_id::GLint, screen::GLint, visual::GLint, share_list::GLint)::Void
export glxCreateContext
@getCFun "libGL" glxDestroyContext glxDestroyContext(context::GLint)::Void
export glxDestroyContext
@getCFun "libGL" glxMakeCurrent glxMakeCurrent(drawable::GLint, context::GLint)::Void
export glxMakeCurrent
@getCFun "libGL" glxIsDirect glxIsDirect(dpy::GLint, context::GLint)::Void
export glxIsDirect
@getCFun "libGL" glxQueryVersion glxQueryVersion(major::Ptr{GLint}, minor::Ptr{GLint})::Void
export glxQueryVersion
@getCFun "libGL" glxWaitGL glxWaitGL(context::GLint)::Void
export glxWaitGL
@getCFun "libGL" glxWaitX glxWaitX()::Void
export glxWaitX
@getCFun "libGL" glxCopyContext glxCopyContext(source::GLint, dest::GLint, mask::GLint)::Void
export glxCopyContext
@getCFun "libGL" glxSwapBuffers glxSwapBuffers(drawable::GLint)::Void
export glxSwapBuffers
@getCFun "libGL" glxUseXFont glxUseXFont(font::GLint, first::GLint, count::GLint, list_base::GLint)::Void
export glxUseXFont
@getCFun "libGL" glxCreateGLXPixmap glxCreateGLXPixmap(visual::GLint, pixmap::GLint, glxpixmap::GLint)::Void
export glxCreateGLXPixmap
@getCFun "libGL" glxGetVisualConfigs glxGetVisualConfigs()::Void
export glxGetVisualConfigs
@getCFun "libGL" glxDestroyGLXPixmap glxDestroyGLXPixmap(pixmap::GLint)::Void
export glxDestroyGLXPixmap
@getCFun "libGL" glxVendorPrivate glxVendorPrivate()::Void
export glxVendorPrivate
@getCFun "libGL" glxVendorPrivateWithReply glxVendorPrivateWithReply()::Void
export glxVendorPrivateWithReply
@getCFun "libGL" glxQueryExtensionsString glxQueryExtensionsString(screen::GLint)::Void
export glxQueryExtensionsString
@getCFun "libGL" glxQueryServerString glxQueryServerString(screen::GLint, name::GLint)::Void
export glxQueryServerString
@getCFun "libGL" glxClientInfo glxClientInfo()::Void
export glxClientInfo
@getCFun "libGL" glxGetFBConfigs glxGetFBConfigs()::Void
export glxGetFBConfigs
@getCFun "libGL" glxCreatePixmap glxCreatePixmap(config::GLint, pixmap::GLint, glxpixmap::GLint)::Void
export glxCreatePixmap
@getCFun "libGL" glxDestroyPixmap glxDestroyPixmap(glxpixmap::GLint)::Void
export glxDestroyPixmap
@getCFun "libGL" glxCreateNewContext glxCreateNewContext(config::GLint, render_type::GLint, share_list::GLint, direct::GLint)::Void
export glxCreateNewContext
@getCFun "libGL" glxQueryContext glxQueryContext()::Void
export glxQueryContext
@getCFun "libGL" glxMakeContextCurrent glxMakeContextCurrent(drawable::GLint, readdrawable::GLint, context::GLint)::Void
export glxMakeContextCurrent
@getCFun "libGL" glxCreatePbuffer glxCreatePbuffer(config::GLint, pbuffer::GLint)::Void
export glxCreatePbuffer
@getCFun "libGL" glxDestroyPbuffer glxDestroyPbuffer(pbuffer::GLint)::Void
export glxDestroyPbuffer
@getCFun "libGL" glxGetDrawableAttributes glxGetDrawableAttributes(drawable::GLint)::Void
export glxGetDrawableAttributes
@getCFun "libGL" glxChangeDrawableAttributes glxChangeDrawableAttributes(drawable::GLint)::Void
export glxChangeDrawableAttributes
@getCFun "libGL" glxCreateWindow glxCreateWindow(config::GLint, window::GLint, glxwindow::GLint)::Void
export glxCreateWindow
@getCFun "libGL" glxDestroyWindow glxDestroyWindow(glxwindow::GLint)::Void
export glxDestroyWindow
@getCFun "libGL" glxSwapIntervalSGI glxSwapIntervalSGI()::Void
export glxSwapIntervalSGI
@getCFun "libGL" glxMakeCurrentReadSGI glxMakeCurrentReadSGI(drawable::GLint, readdrawable::GLint, context::GLint)::Void
export glxMakeCurrentReadSGI
@getCFun "libGL" glxCreateGLXVideoSourceSGIX glxCreateGLXVideoSourceSGIX(dpy::GLint, screen::GLint, server::GLint, path::GLint, class::GLint, node::GLint)::Void
export glxCreateGLXVideoSourceSGIX
@getCFun "libGL" glxDestroyGLXVideoSourceSGIX glxDestroyGLXVideoSourceSGIX(dpy::GLint, glxvideosource::GLint)::Void
export glxDestroyGLXVideoSourceSGIX
@getCFun "libGL" glxQueryContextInfoEXT glxQueryContextInfoEXT()::Void
export glxQueryContextInfoEXT
@getCFun "libGL" glxGetFBConfigsSGIX glxGetFBConfigsSGIX()::Void
export glxGetFBConfigsSGIX
@getCFun "libGL" glxCreateContextWithConfigSGIX glxCreateContextWithConfigSGIX(gc_id::GLint, screen::GLint, config::GLint, share_list::GLint)::Void
export glxCreateContextWithConfigSGIX
@getCFun "libGL" glxCreateGLXPixmapWithConfigSGIX glxCreateGLXPixmapWithConfigSGIX(config::GLint, pixmap::GLint, glxpixmap::GLint)::Void
export glxCreateGLXPixmapWithConfigSGIX
@getCFun "libGL" glxCreateGLXPbufferSGIX glxCreateGLXPbufferSGIX(config::GLint, pbuffer::GLint)::Void
export glxCreateGLXPbufferSGIX
@getCFun "libGL" glxDestroyGLXPbufferSGIX glxDestroyGLXPbufferSGIX(pbuffer::GLint)::Void
export glxDestroyGLXPbufferSGIX
@getCFun "libGL" glxChangeDrawableAttributesSGIX glxChangeDrawableAttributesSGIX(drawable::GLint)::Void
export glxChangeDrawableAttributesSGIX
@getCFun "libGL" glxGetDrawableAttributesSGIX glxGetDrawableAttributesSGIX(drawable::GLint)::Void
export glxGetDrawableAttributesSGIX
@getCFun "libGL" glxJoinSwapGroupSGIX glxJoinSwapGroupSGIX(window::GLint, group::GLint)::Void
export glxJoinSwapGroupSGIX
@getCFun "libGL" glxBindSwapBarrierSGIX glxBindSwapBarrierSGIX(window::GLint, barrier::GLint)::Void
export glxBindSwapBarrierSGIX
@getCFun "libGL" glxQueryMaxSwapBarriersSGIX glxQueryMaxSwapBarriersSGIX()::Void
export glxQueryMaxSwapBarriersSGIX
@getCFun "libGL" glxQueryHyperpipeNetworkSGIX glxQueryHyperpipeNetworkSGIX(dpy::Ptr{Display}, npipes::Ptr{Cint})::Ptr{Void}
export glxQueryHyperpipeNetworkSGIX
@getCFun "libGL" glxHyperpipeConfigSGIX glxHyperpipeConfigSGIX(dpy::Ptr{Display}, networkId::Cint, npipes::Cint, cfg::Ptr{GLXHyperpipeConfigSGIX}, hpId::Ptr{Cint})::Cint
export glxHyperpipeConfigSGIX
@getCFun "libGL" glxQueryHyperpipeConfigSGIX glxQueryHyperpipeConfigSGIX(dpy::Ptr{Display}, hpId::Cint, npipes::Ptr{Cint})::Ptr{Void}
export glxQueryHyperpipeConfigSGIX
@getCFun "libGL" glxDestroyHyperpipeConfigSGIX glxDestroyHyperpipeConfigSGIX(dpy::Ptr{Display}, hpId::Cint)::Cint
export glxDestroyHyperpipeConfigSGIX
@getCFun "libGL" glxBindHyperpipeSGIX glxBindHyperpipeSGIX(dpy::Ptr{Display}, hpId::Cint)::Cint
export glxBindHyperpipeSGIX
@getCFun "libGL" glxQueryHyperpipeBestAttribSGIX glxQueryHyperpipeBestAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, attribList::Ptr{Void}, returnAttribList::Ptr{Void})::Cint
export glxQueryHyperpipeBestAttribSGIX
@getCFun "libGL" glxHyperpipeAttribSGIX glxHyperpipeAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, attribList::Ptr{Void})::Cint
export glxHyperpipeAttribSGIX
@getCFun "libGL" glxQueryHyperpipeAttribSGIX glxQueryHyperpipeAttribSGIX(dpy::Ptr{Display}, timeSlice::Cint, attrib::Cint, size::Cint, returnAttribList::Ptr{Void})::Cint
export glxQueryHyperpipeAttribSGIX

end


text:
"
    Polynomial{T<:Number} <: Function

A Polynomial struct implements the mathematical object P(x) = ∑ cᵢ xⁱ by
storing the coefficients cᵢ (i ∈ {0,..., deg(P)}) into a 1-dimensional array of
numbers. The **degree** of a polynomial is the highest power of the xᵢ terms.
"
struct Polynomial{T<:Number} <: Function
    coeffs::Array{T,1}
    degree::Int

    function Polynomial{T}(c::Array{T,1}) where {T<:Number}
        n = length(c) - 1
        new(c, n)
    end

end

Polynomial(c::Array{T,1}) where {T<:Number} = Polynomial{T}(c)

deg(poly::Polynomial{T}) where {T<:Number} = poly.degree

function (poly::Polynomial{T})(x::Number, bases=zeros(T, deg(poly), 1)) where {T<:Number}
    #= Method 1: The first and most straightforward approach:
    result = 0
    for (power, c) in enumerate(poly.coeffs)
        result += c * x^(power - 1)
    end
    =#

    #= Method 2: Find the powers and store them for future uses:
    result = 0
    power = 1
    for c in poly.coeffs
        result += c * power
        power *= x
    end
    =#

    #= Method 3 (Horner): Nest multiplication =#
    result = poly.coeffs[end]
    for i = deg(poly):-1:1
        result *= x - bases[i]
        result += poly.coeffs[i]
    end

    result
end

ext: jl


text:
using QCMaterial
using PyCall
using LinearAlgebra

import Random
import PyCall: pyimport

nsite = 2
n_qubit　= 2*nsite
U = 1.0
V = 1.0
μ = 1.0
ε = 1.0
d_theta = 1e-5

#Hamiltonian
ham_op = generate_impurity_ham_with_1imp_multibath(U, V, μ, ε, nsite)

n_electron_gs = 2
@assert mod(n_electron_gs, 2) == 0
sparse_mat = get_number_preserving_sparse_operator(ham_op, n_qubit, n_electron_gs);
enes_ed = eigvals(sparse_mat.toarray());
println("ground energy_exact=", minimum(enes_ed))

#Ansatz
vc = uccgsd(n_qubit, orbital_rot=true)
state0 = create_hf_state(n_qubit, n_electron_gs)
theta_init = rand(num_theta(vc))
#Perform VQE
cost_history, thetas_opt =
    QCMaterial.solve_gs(jordan_wigner(ham_op), vc, state0, theta_init=theta_init, verbose=true,
        comm=QCMaterial.MPI_COMM_WORLD
    )

println("ground energy_vqe =", cost_history[end])

#c^{dag},c
#c^{dag},c
up1 = up_index(1)
down1 = down_index(1)
up2 = up_index(2)
down2 = down_index(2)
#right_op = FermionOperator("$(up1) ", 1.0)
#right_op = jordan_wigner(right_op)
#left_op = FermionOperator("$(up1)^ ", 1.0)
#left_op = jordan_wigner(left_op)

right_op = FermionOperator("$(down1) ", 1.0)
right_op = jordan_wigner(right_op)
left_op = FermionOperator("$(down1)^ ", 1.0)
left_op = jordan_wigner(left_op)

vc_ex = uccgsd(n_qubit, orbital_rot=true, conserv_Sz_singles=false)

#state_gs = QulacsQuantumState(n_qubit,0b0000)
state_gs = create_hf_state(n_qubit, n_electron_gs)
update_circuit_param!(vc, thetas_opt)
update_quantum_state!(vc, state_gs)

n_electron_ex = 1
state0_ex = create_hf_state(n_qubit, n_electron_ex)

#@assert mod(n_electron_ex, 1) == 0
taus = collect(range(0.0, 4, length=1000))
beta = taus[end]

Gfunc_ij_list = -compute_gtau(jordan_wigner(ham_op), left_op, right_op, vc_ex,  state_gs, state0_ex, taus, d_theta)
println("Gfunc_ij_list=", Gfunc_ij_list)

function write_to_txt(file_name, x, y)
    open(file_name,"w") do fp
        for i in 1:length(x)
            println(fp, x[i], " ", real(y[i]))
        end
    end
end

write_to_txt("g_of_tau_dimer_buntenn_1000.txt", taus, Gfunc_ij_list)

max_stars_repo_name: Sakurairihito/QCMaterialNew

max_issues_repo_name: sakurairihito/QCMaterialNew

max_forks_repo_name: sakurairihito/QCMaterialNew


text:
simpk = d" (1+3im)| 1 > "
proj = simpk*simpk'
projop = convert(QuDirac.OpSum, proj)

k = sum([d" (i+(i*im)) * | i >" for i=0:3])
b = sum([d" (i+(i*3*im)) * | i >" for i=0:3])'
op = (k*b) + d"| 3 >< 0 |"

qubits = normalize(sum(ket, 0:1))^3
bitdens = qubits*qubits'

bell = d" 1/√2 * (| 1,1 > + | 0,0 >) "
bell_unbal = d" normalize!( | 0,1 > + 2.0| 1,0 > ) "
belldens = bell * bell'


text:
"""
RandomWalker(x::AbstractModelConfig)

Random Walk in 2D over `NS` steps (100 by default). Returns the results to as an array and
saves them to a `.csv` file (_RandomWalker.csv_ by default) inside the run directory
(`pathof(x)` by default), if `setup` method has been invoked to create it.
"""
function RandomWalker(x::AbstractModelConfig)
 #model run
 haskey(x.inputs,"NS") ? NS=x.inputs["NS"] : NS=100
 m=zeros(NS,2)
 [m[i,j]=m[i-1,j]+rand((-1,1)) for j in 1:2, i in 2:NS]

 #output to file
 haskey(x.inputs,"filename") ? fil=x.inputs["filename"] : fil="RandomWalker.csv"
 if isdir(pathof(x))
     df = DataFrame(x = m[:,1], y = m[:,2])
     fil=joinpath(pathof(x),"RandomWalker.csv")
     CSV.write(fil, df)
 end

 return m
end


text:
function char_to_magmaInt(option::AbstractChar)
    if option == 'A'
        return MagmaAllVec
    elseif option == 'S'
        return MagmaSomeVec
    elseif option == 'O'
        return MagmaOverwriteVec
    elseif option == 'V'
        return MagmaVec
    elseif option == 'N'
        return MagmaNoVec
    end
end
function char_to_magmaIntUplo(option::AbstractChar)
    if option == 'U'
        return MagmaUpper
    elseif option == 'L'
        return MagmaLower
    end
end

subsetrows(X::AbstractVector, Y::AbstractArray, k) = Y[1:k]
subsetrows(X::AbstractMatrix, Y::AbstractArray, k) = Y[1:k, :]

include("svd.jl")
include("linearsystemsolver.jl")
include("eigen.jl")


text:
###############################################################################
#
# Flint
#
###############################################################################

"""
Flint's own root-finding algorithm, as called via *_poly_factor_equal_deg
"""
function flint_root_find(x::fq_nmod_poly)
   R = parent(x)
   F = base_ring(R)
   fac = Nemo.fq_nmod_poly_factor(F)
   ccall((:fq_nmod_poly_factor_equal_deg, :libflint), Void,
         (Ptr{Nemo.fq_nmod_poly_factor}, Ptr{fq_nmod_poly}, Int,
         Ptr{FqNmodFiniteField}), &fac, &x, 1, &F)
   res = Dict{fq_nmod, Int}()
   for i in 1:fac.num
      f = R()
      ccall((:fq_nmod_poly_factor_get_poly, :libflint), Void,
            (Ptr{fq_nmod_poly}, Ptr{Nemo.fq_nmod_poly_factor}, Int,
            Ptr{FqNmodFiniteField}), &f, &fac, i-1, &F)
      d = unsafe_load(fac.exp,i)
      res[-coeff(f,0)] = d
   end
   return res
end


text:
import XLSX

function gen_excel_charstring(L)
    charstring = ""
    total_length = Int('A') + L - 1
    if total_length < 91
        return string(Char(total_length))
    end
    div_count = 0
    tmp = total_length - 91
    first_int = tmp
    while first_int > 90
        div_count += 1
        first_int -= 90
    end
    first_char = Char(Int('A') + div_count)
    second_int = total_length - 91 -(div_count*90) - 1
    second_char = Char(Int('A') + second_int)
    return string(first_char, second_char)
end

function write_xlsx(path, providers, clients, D_MN, D_NN)
    XLSX.openxlsx(path, mode="w") do xf
        sheet = xf[1]
        XLSX.rename!(sheet, "Providers")
        XLSX.addsheet!(xf, "Clients")
        XLSX.addsheet!(xf, "D_MN")
        XLSX.addsheet!(xf, "D_NN")

        sheet = xf["Providers"]
        m = length(providers)
        sheet["A1", dim=2] = ["id", "cx", "cy", "type"]
        sheet["A2", dim=1] = [provider.id for provider in providers]
        sheet["B2", dim=1] = [provider.cx for provider in providers]
        sheet["C2", dim=1] = [provider.cy for provider in providers]
        sheet["D2", dim=1] = [provider.type for provider in providers]

        sheet = xf["Clients"]
        n = length(clients)
        sheet["A1", dim=2] = ["id", "cx", "cy", "type"]
        sheet["A2", dim=1] = [client.id for client in clients]
        sheet["B2", dim=1] = [client.cx for client in clients]
        sheet["C2", dim=1] = [client.cy for client in clients]
        sheet["D2", dim=1] = [client.type for client in clients]

        sheet = xf["D_MN"]
        col_index = gen_excel_charstring(n)
        row_index = m
        sheet[string("A1:", col_index, row_index)] = D_MN

        sheet = xf["D_NN"]
        col_index = gen_excel_charstring(n)
        row_index = n
        sheet[string("A1:", col_index, row_index)] = D_NN
    end
end

max_stars_repo_name: dwirya/nodegen

max_issues_repo_name: dwirya/nodegen

max_forks_repo_name: dwirya/nodegen


text:
using Turing

#Returns a categorical distribution.
@sf fdirichlet(alpha) = begin
    ps = dirichlet(alpha)
    () -> categorical(ps)
end

#Makes 10 draws from the categorical distribution returned by fdirichlet.
@sf fdp() = begin
    dist = fdirichlet(ones(10)/5)
    Int[dist() for i = 1:30]
end

#Because we haven't conditioned on anything, we only need to draw one sample.
println(sample(fdp, 1)[end])


text:
"""Approximate normal distribution"""
logtransform(x) = log.(x .+ 1 .- minimum(x))

"""Approximate normal distribution of selected entries
for all selected features of an Experiment `e`.
Warning: columns are converted to float when necessary.
"""
function logtransform!(e::Experiment)
    _data_to_float!(e)
    e.data[e.selected_entries, e.selected_features] .= e |>
                                                     getdata |>
                                                     eachcol |>
                                                     x -> map(logtransform, x) |>
                                                     x -> hcat(x...)
end

"""Center and scale on control values"""
normtransform(x,y) = (x .- median(y)) ./ mad(y, normalize = true)

"""Center and scale all selected entries for each selectead features
of an Experiment `e` on control values matching a Filter `f`,
based on the median and median absolute deviation of the control.
Warning: columns are converted to float when necessary.
"""
function normtransform!(e::Experiment, f::AbstractFilter)
    f_col = filter_entries(e,f)
    _data_to_float!(e)
    e.data[e.selected_entries, e.selected_features] .= e.data[:, e.selected_features] |>
                                                     eachcol |>
                                                     x -> map(y -> normtransform(y[e.selected_entries],
                                                                                y[f_col]), x) |>
                                                     x -> hcat(x...)
end

"""Returns column  of 'data' that are never pairwise-correlated more than 'threshold',
   prioritizing columns by a given order 'ordercol' (defaults to left to right).
"""
function decorrelate(data::DataFrame; ordercol = nothing, threshold = 0.8)
    if ordercol === nothing
        ordercol = collect(1:size(data, 2))
    end
    # Columns to sort
    L1 = copy(ordercol) # Copy to avoid modifying the input list
    # Sorted columns to keep
    L2 = Array{Int64,1}()
    while length(L1) > 0
        # Use the first non-correlated term as "pivot"
        refFt = first(L1)
        append!(L2, refFt)
        popfirst!(L1)
        stillToKeep = []
        # Which remaining terms are non correlated?
        for (ift, ft) in enumerate(L1)
            if abs(cor(data[:,refFt], data[:,ft])) < threshold
                append!(stillToKeep, ift)
            end
        end
        # Remove remaining correlated terms
        L1 = L1[stillToKeep]
    end
    return(L2)
end

# Allows the computation to be mapped on columns of a DataFrame
decorrelate(data::AbstractMatrix; ordercol = nothing, threshold = 0.8) =
	decorrelate(DataFrame(data), ordercol = ordercol, threshold = threshold)

"""Returns column  of selected data in Experiment `e` that are never
    pairwise-correlated more than 'threshold', prioritizing columns by
    a given order 'ordercol' (defaults to left to right).
"""
function decorrelate!(e::Experiment; ordercol = nothing, threshold = 0.8)
    _assert_clean_data(e)
    e.selected_features = e.selected_features[decorrelate(getdata(e),
                                                        ordercol=ordercol,
                                                        threshold=threshold)]
end

"""Returns column  of selected data in Experiment `e` that are never
    pairwise-correlated more than 'threshold', prioritizing columns
    with largest median absolute deviation.
"""
function decorrelate_by_mad!(e::Experiment; threshold = 0.8)
    _assert_clean_data(e)
    # Order features from biggest mad to smallest mad
    # When features have mad(reference) = 1, it means that we rank features
    # by how more variable they are overall compared to the reference
    order_features = sortperm(convert(Array, map(x -> mad(x, normalize = true),
                     eachcol(getdata(e)))), rev=true);
    decorrelate!(e, ordercol = order_features, threshold = threshold)
end


text:
# Conjugate update rules

function update(d::Beta, x::Vector)
	a, n = sum(x), length(x)
	b = n - a
	Beta(d.alpha + a, d.beta + b)
end

function update(d::Normal, x::Vector)
	error("Not yet defined")
end

# Beta/Bernoulli pair
#  * x is a vector of 0's and 1's
function update(prior::Beta, ::Type{Bernoulli}, x::Vector)
	a, n = sum(x), length(x)
	b = n - a
	Beta(prior.alpha + a, prior.beta + b)
end

# Beta/Binomial pair
#  * D is a matrix with a column of successes and a column of trials
function update(prior::Beta, ::Type{Bernoulli}, D::Matrix)
	a, n = sum(D, 1)
	b = n - a
	Beta(prior.alpha + a, prior.beta + b)
end

# Beta/NegativeBinomial pair
# TODO

# Gamma/Poisson pair
# TODO

# Dirichlet/Categorical pair
function update(prior::Dirichlet, ::Type{Categorical}, x::Vector)
	alpha = copy(prior.alpha)
	for i in 1:length(x)
		alpha[x[i]] += 1.0
	end
	return Dirichlet(alpha)
end

# Dirichlet/Multinomial pair
function update(prior::Dirichlet, ::Type{Multinomial}, x::Vector)
	return Dirichlet(prior.alpha + x)
end

# Dirichlet/Multinomial pair
function update(prior::Dirichlet, ::Type{Multinomial}, x::Matrix)
	return Dirichlet(prior.alpha + vec(sum(x, 2)))
end

# Hypergeometric/BetaBinomial pair

# Geometric/Beta pair

# Gamma/Exponential pair
function update(prior::Gamma, ::Type{Exponential}, x::Vector)
	n = length(x)
	a, b = prior.shape, 1.0 / prior.scale
	return Gamma(a + n, 1.0 / (b + sum(x)))
end

# function credibleinterval()
# end

# Known variance of data, s_data^2
function update(prior_m::Normal,
	            s_data::Real,
	            ::Type{Normal},
	            x::Vector)
	n = length(x)
	m_prior, s_prior = mean(prior_m), std(prior_m)
	c = (n * s_prior^2 + s_data^2)
	s_posterior = sqrt((s_data^2 * s_prior^2) / c)
	m_posterior = s_data^2 / c * m_prior + (n * s_prior^2) / c * mean(x)
	return Normal(m_posterior, s_posterior)
end

# Unknown mean, unknown variance
function update(prior_m::Normal,
	            prior_s::Gamma,
	            ::Type{Normal},
	            x::Vector)
	# mu: True mean of data
	# lambda: True precision of data
	#...
end


text:
"""
    Fronts.ϕ(r, t)

Evaluate the Boltzmann variable ϕ at position `r` and time `t`.

Type `\\phi<tab>` to obtain the `ϕ` symbol.

The Boltzmann variable is defined as `ϕ=r/√t` and makes the Boltzmann transformation possible.

To prevent possible name clashes, this function is not exported.

See also: [`transform`](@ref)
"""
ϕ(r, t) = r/√t

"""
    ∂ϕ_∂r(r, t)

Partial derivative of the Boltzmann variable.

Type `\\partial<tab>` to obtain the `∂` symbol; `\\phi<tab>` to obtain the `ϕ` symbol.

See also: [`ϕ`](@ref)
"""
∂ϕ_∂r(r, t) = 1/√t

"""
    ∂ϕ_∂t(r, t)

Partial derivative of the Boltzmann variable.

Type `\\partial<tab>` to obtain the `∂` symbol; `\\phi<tab>` to obtain the `ϕ` symbol.

See also: [`ϕ`](@ref)
"""
∂ϕ_∂t(r, t) = -ϕ(r,t)/2t

"""
    Fronts.r(ϕ, t)

Convert back from the Boltzmann variable to `r`.

To prevent possible name clashes, this function is not exported.

See also: [`ϕ`](@ref)
"""
r(ϕ, t) = ϕ*√t

"""
    Fronts.t(ϕ, r)

Convert back from the Boltzmann variable to `t`.

To prevent possible name clashes, this function is not exported.

See also: [`ϕ`](@ref)
"""
t(ϕ, r) = (r/ϕ)^2

"""
    transform(r, t)

Same as `ϕ(r,t)`.

See also: [`ϕ`](@ref)
"""
transform(r, t) = ϕ(r,t)

"""
    TransformedFunction

Abstract type for functions of the Boltzmann variable ϕ.

Every subtype of `TransformedFunction` gets access to the following methods:

    (::TransformedFunction)(r, t)
    d_dϕ(::TransformedFunction, r, t)
    ∂_∂r(::TransformedFunction, r, t)
    ∂_∂t(::TransformedFunction, r, t)

# Implementation

In order to access the previous methods, a type `T <: TransformedFunction` must define these methods:

    (::T)(ϕ)
    d_dϕ(::T, ϕ)
"""
abstract type TransformedFunction end

(f::TransformedFunction)(r, t) = f(ϕ(r,t))

d_dϕ(f::TransformedFunction, r, t) = d_dϕ(f, ϕ(r,t))

∂_∂r(f::TransformedFunction, r, t) = d_dϕ(f, r, t)*∂ϕ_∂r(r, t)

∂_∂t(f::TransformedFunction, r, t) = d_dϕ(f, r, t)*∂ϕ_∂t(r, t)


text:
export SimpleModel

"""
    struct SimpleModel{I,O} <: TimelessInstantModel{I,O}

A model that always produces the same SFunc.
This is an TimelessInstantModel, so must always be called when the parents are the same time point.
The constructor takes the sfunc as argument, which is stored.
There is a convencience method to create a SimpleModel for any sfunc by applying the sfunc to zero arguments.
"""
struct SimpleModel{I,O} <: TimelessInstantModel{I,O}
    sf::SFunc{I,O}
end

make_initial(m::SimpleModel) = m.sf

# Convenience for making constant models, a very common case
(sf::SFunc{I,O})() where {I,O} = SimpleModel{I,O}(sf)


text:
# Simple Send and Accept with Return Value

using SimLynx
SimLynx.greet()

using Distributions: Exponential, Uniform
using Random

@process my_lock() begin
    while true
        @accept caller lock(i::Integer) begin
            return "locked for $caller which should be p1($i)"
        end
        @accept caller unlock()
    end
end

the_lock = Nothing

@process p1(i::Integer) begin
    println("$(current_time()): Process p1($i) started")
    let msg = @send the_lock lock(i)
        println("msg = $msg")
    end
    println("$(current_time()): Process p1($i) acquired lock")
    work(rand(Uniform(1.0, 10.0)))
    println("$(current_time()): Process p1($i) released lock")
    @send the_lock unlock()
    println("$(current_time()): Process p1($i) ended")
end

function run_simulation(n::Integer)
    @simulation begin
        # current_trace!(true)
        global the_lock = @schedule now my_lock()
        for i = 1:n
            @schedule at rand(Uniform(0.0, 10.0)) p1(i)
        end
        start_simulation()
    end
end

run_simulation(10)


text:
using LinearAlgebra
using BesselFunctions
using LegendrePolynomials
using QuadGK
using Dierckx
using MsgWrap

####################################
# * Potential funcs
#----------------------------------

Δk_func(k1,k2,cosθ) = sqrt(k2^2 + k1^2 - 2*k1*k2*cosθ)

function VkkFromVΔk(k1, k2, l, VΔk_func)
    val,err = quadgk(cosθ -> VΔk_func(Δk_func(k1,k2,cosθ)) * Pl(cosθ,l),
                     -1, 1,
                     rtol=1e-4, atol=0.)

    return 2π*val
end

# Assumes isotropic V(r)
function VΔkFromVr(Δk, Vr_func ; rmin=0, rmax=Inf)
    # Special case for Δk == 0 needed to prevent nans.
    if Δk == 0
        sphj_func = r -> 1.
    else
        sphj_func = r -> sphj(0,Δk*r)
    end
    val,err = quadgk(r -> r^2 * Vr_func(r) * sphj_func(r), rmin, rmax, rtol=1e-6, atol=1e-10)

    return 1/(2*pi^2) * val
end

"""
    PrepareInterpedVkk(Vr_func, Δk_list)

Returns a function which will evaluate V_l(k,k′) from an isotropic V(r) given by
`Vr_func`, by first building up a set of values of V(Δk) on a grid given in
`Δk_list` and interpolating between these.
"""
function PrepareInterpedVkk(Vr_func, Δk_list ; kwds...)
    VΔk_list = @msgwrap Debug "Calculating VΔk_spl" VΔkFromVr.(Δk_list, Ref(Vr_func) ; kwds...)
    let VΔk_spl = Spline1D(Δk_list, VΔk_list, k=1)
        (k1,k2,l) -> VkkFromVΔk(k1,k2,l, VΔk_spl)
    end
end

################################
# * The Equations
#------------------------------

"""
SetupMatrix(k_list, pot_r, l, u ; rmin,rmax, pot_k=:auto)

Sets up the matrix `M` which represents the integration in the
Lippmann-Schwinger equation for the T-matrix of partial wave `l`. Returns both `M` and the potential
matrix `Vmat`, which is the potential evaluated at all (k,k′) pairs of the grid
`k_list`.

The majority of the work of the integral is actually done before this function is called, as `u`
is the integrating vector. Obtain this through `Quadrature`.

Either pass the potential in as V(r) with `pot_r` or V(k,k′) with `pot_k`. If
`pot_r` is used, then `PrepareInterpedVkk` will be called, using the values
`rmin` and `rmax`. This may be inefficient if this function is used multiple
times, and providing a `pot_k` will be faster.
"""
function SetupMatrix(k_list,
                     pot_r,
                     l,
                     u ;
                     rmin=nothing,rmax=nothing,
                     pot_k=:auto
                     )

    # I need all Vs connecting all ks to other ks
    k1 = k_list
    k2 = k_list'

    if pot_k == :auto
        Δk_list = LinRange(0., 2*maximum(k_list), 10001)
        pot_k = PrepareInterpedVkk(pot_r, Δk_list, rmin=rmin, rmax=rmax)
    end

    Vmat = @msgwrap Debug "Calc Vmat" pot_k.(k1,k2, l)

    f = k_list'.^2 .* Vmat
    M = u' .* f

    return M,Vmat
end

"""
OffShellScattering(en, l, potfunc ; rmin=1e-4, rmax=10., pot_k=:auto, kwds...)

Do a calculation of all T_l(k,k′) values for `l` and the V(r) of `potfunc`, from the k grid created by `Quadrature`
with the corresponding `kwds`.

This should work for any energy, even on-shell, but in the future it may be
optimised to not assume that the divergence at k=κ is missed.
"""
function OffShellScattering(en, l, potfunc ; rmin=1e-4, rmax=10., pot_k=:auto, kwds...)
    k_list,u = Quadrature(en ; kwds...)

    κ = sqrt(2*en)

    M,Vmat = SetupMatrix(k_list, potfunc, l, u ; rmin=rmin, rmax=rmax, pot_k=pot_k )

    T = (I - M)\Vmat

    return k_list,T
end

"""
OnShellScattering(en, l, potfunc ; rmin=1e-4, rmax=10.)

Like `OffShellScattering` but only solves for Tₗ(k,k) where ℏ²k²/2m = `en`.
Returns a single value, in contrast to `OffShellScattering`.
"""
function OnShellScattering(en, l, potfunc ; rmin=1e-4, rmax=10., kwds...)
    target_k = sqrt(2*en)

    @assert isreal(target_k)
    k_list,u = Quadrature(en ; kwds...)

    M,Vmat = SetupMatrix(k_list, potfunc, l, u ; rmin=rmin, rmax=rmax )

    ind = findfirst(==(target_k), k_list)
    RHS = Vmat[:,ind]

    T = (I - M)\RHS

    T[ind]
end

# For testing
function OnShellFromOffShell(en, l, potfunc, k_target=Float64(sqrt(2*en))  ; kwds...)
    # k_target = Float64(sqrt(2*en))

    k_list,T_mat = OffShellScattering(en, l, potfunc ; kwds...)
    Tr = Spline1D(k_list, real.(diag(T_mat)))(k_target)
    Ti = Spline1D(k_list, imag.(diag(T_mat)))(k_target)
    T = Tr + im*Ti
end

    ##############################################################
# * Applied to the Lax formalism
#------------------------------------------------------------

"""
SearchLax(k_target, potfunc, c; N=10, max_iters=101, zero_limit=false, tol=1e-5, guess=:auto, α=1.)

Finds a self-consistent solution for the equation from Lax (1952), ε = (ℏk)²/2m + cT.

This iterates on the equation until the energy converges to within `tol`. If
set, `guess` provides the starting energy, otherwise it is set to the kinetic
energy. An error is raised if `max_iters` is reached. The parameter `N` is
passed through to `Quadrature`. A dampening term can be achieved with `α` < 1.

`zero_limit` provides a way to force the imaginary-part to zero. For some
reason, the self-consistent loop seems to diverge if this isn't included.

Currently assumes s-wave scattering is sufficient to determine T.

Note: it seems to be that a unique solution is not gaurnateed. And this may find
solutions with positive imaginary parts which are unphysical.
"""
function SearchLax(k_target, potfunc, c; max_iters=101, zero_limit=false, tol=1e-5, guess=:auto, α=1., rmin, rmax, k_max=:auto, kwds...)
    K = k_target^2/2
    # This comes from a factor of 4pi from my choice of Legendre expansion (T_0 -> T(a<-a))
    # and a factor of 1/(2pi)^3 from the choice of plane wave in the # solution of T.
    TEnergy(T) = 2*pi^2 * T
    ESelfCon(T) = K + c*TEnergy(T)

    if k_max == :auto
        k_list,u = Quadrature(K ; kwds...)
        # Note: got to go extra, because the energy will change.
        k_max = maximum(k_list) * 4
        @debug "Automatically chose k_max" k_max
    end
    Δk_list = LinRange(0., k_max, 10001)
    pot_k = PrepareInterpedVkk(potfunc, Δk_list, rmin=rmin, rmax=rmax)

    if guess == :auto
        en = ESelfCon(0.)
    else
        en = guess
    end

    l = 0

    for i = 1:max_iters
        i == max_iters && error("Max iterations ($max_iters) reached!")

        k_list,T_mat = OffShellScattering(en, l, potfunc, pot_k=pot_k ; kwds...)
        maximum(k_list) > k_max && @warn "Energy creates a k_list with max > k_max" en k_max maximum(k_list)

        Tr = Spline1D(k_list, real.(diag(T_mat)))(k_target)
        Ti = Spline1D(k_list, imag.(diag(T_mat)))(k_target)
        T = Tr + im*Ti

        new_en = ESelfCon(T)
        @debug "Iteration" en new_en T K TEnergy(T)
        if zero_limit
            # Still need the imaginary part here in case en goes negative (for sqrt).
            new_en = real(new_en) + 0im
        end

        if abs(new_en - en) < tol
            break
        end
        en = (1-α)*en + α*new_en
    end

    return en
end

using ProgressMeter
function LaxScan(k_list, potfunc, c ; adjust_guess=true, kwds...)
    E_list = []
    guess = :auto
    @showprogress for k in k_list
        E = try
            SearchLax(k, potfunc, c ; guess=guess, kwds...)
        catch exc
            @error "Got exception for k=$k" k exc
            NaN
        end
        push!(E_list, E)
        if adjust_guess && !isnan(E)
            guess = E
        end
    end
    return E_list
end


text:
"""
`TableND(response_name, spl_response, m_vars, b_vars,
            var_input, var_names)`

Defines an arbitrary input arbitrary output ND spline with
the following properties:

# Arguments
* response_values::ND Array              : Values of response being splined
* response_name::String               : Name of the response being splined
* var_input::Tuple(Arrays)    : Input variable values for reference
* var_names::String     : Names of input variables
"""
mutable struct TableND
  # Initialization variables (USER INPUT)

  response_values
  response_names

  # Keep track of what it was run at
  var_input
  var_names

  TableND(response_values, response_names, var_input, var_names) = new(response_values,
      response_names, var_input, var_names)

end

"""
`SplineND(response_name, spl_response, m_vars, b_vars,
var_input, var_names)`

Defines an arbitrary input arbitrary output ND spline with
the following properties:

# Arguments
* response_name::String               : Name of the response being splined
* spl_response::ND Spline via interpolation     : ND Spline of response
* m_vars::Tuple    : Spline access linear function slopes for input variables
* b_vars::Tuple    : Spline access linear function offset for input variables
* var_input::Tuple(Arrays)    : Input variable values for reference
* var_names::String     : Names of input variables

NOTE:
"""
mutable struct SplineND
  # Initialization variables (USER INPUT)
  response_name
  spl_response

  m_vars
  b_vars

  var_input
  var_names

  SplineND(response_name, spl_response, m_vars, b_vars,
      var_input, var_names) = new(response_name, spl_response, m_vars,
                                    b_vars, var_input, var_names)

end

"""
`genMapInput(var_input)`

Defines the arrays needed for the julia map function to run all of the combinations of input variables

  Parameters
  ----------
  var_input::Tuple(Arrays)    : Input variable values for reference

  Returns
  ----------
  map_in: Array(Arrays)     :Arrays used by the julia map function to run the airfoil/whatever generation function

  NOTE:
  """
function genMapInput(var_input)
    # Set up map input based on variable inputs
    map_in = Array{Array{Float64,length(var_input)},1}(undef,length(var_input))
    # Iterate through each variable to get N matrices for the map function combinations
    for i = 1:length(var_input)
      # Check if var_inputs are linear

      if (length(var_input[i])>2) #Catch single variable inputs before accessing them
        if (!isapprox((var_input[i][1]-var_input[i][2]), (var_input[i][2]-var_input[i][3])))
          error("Variable inputs MUST be linear for gridded interpolation
          $(var_input[i][1]-var_input[i][2]) != $(var_input[i][2]-var_input[i][3])")
        end
      end

      # Create array that specifies dimensions to reshape function
      tmp = ones(Int64,length(var_input))
      tmp[i] = length(var_input[i])
      # println(tmp)

      # Put values into an array of the correct N
      tmp2 = reshape(var_input[i],tmp...)

      # Create array that specifies dimensions to repeat function
      tmp3 = ones(Int64,length(var_input))
      for j = 1:length(var_input)
        if i != j
          tmp3[j] = length(var_input[j])
        end
      end

      # Repeat the values into the full array and add to the map input tuple
      map_in[i] = repeat(tmp2,outer = tmp3)
    end
    return map_in
end

"""
`genNDarray(f,response_names,var_input,var_names)`
generates ND array of responses for M outputs and N inputs with
a call to an external function (like xfoil).  See example for how
to correctly wrap a function

Parameters
----------
response_names: array string
names of the output values
var_input: tuple array(floats)
input values that airfoil will be run at
var_names: array string
names of the input variables

Returns
-------
response_values : Array(Arrays(Tuples))
values from the data function

Notes
-----
input variables MUST be linearly spaced and accessing the spline outside of
the defined variable inputs could return undefined behavior

"""
function genNDarray(f, response_names, var_input, var_names)

    # Iterate through each variable to get N matrices for the map function combinations
    map_in = genMapInput(var_input)
    response_values = map(f, map_in...) #TODO: Replace with pmap for parallelization

    return response_values #tableND
end

"""
`SplineND_from_tableND(tableND)`

defines the

Parameters
----------
var_input::Tuple(Arrays)    : Input variable values for reference

Returns
----------
map_in: Array(Arrays)     :Arrays used by the julia map function to run the airfoil/whatever generation function

NOTE:
"""
function SplineND_from_tableND(tableND)

    #create the 3D splines
    splND = []
    for i = 1:length(tableND.response_names)
        response = tableND.response_values[i]

        spl_response = interpolate(response, BSpline(Cubic(Line(OnCell()))))

        #create splines for the reverse mapping of variables
        #y = mx+b or # = m*value+b (put in value, get out it's number)
        m_vars = Vector{Float64}(undef, length(tableND.var_names))
        b_vars = similar(m_vars)
        for j = 1:length(tableND.var_names)
            m_vars[j] = (length(tableND.var_input[j]) - 1) / (maximum(tableND.var_input[j]) - minimum(tableND.var_input[j]))
            b_vars[j] = Float64(1-m_vars[j] * minimum(tableND.var_input[j]))
        end

        splND = push!(splND, SplineND(tableND.response_names[i], spl_response,
                                    m_vars, b_vars, tableND.var_input, tableND.var_names))
    end

    return splND
end

"""helper function for accessing ND spline"""
function interpND(splND, vars)

    var_nums = Vector{eltype(vars)}(undef, length(splND.var_names))
    for i = 1:length(vars)

        if vars[i] > maximum(splND.var_input[i])
            # warn("Accessing spline in extrapolated area, capping at max. Variable $i value: $(vars[i])")
            vars[i] = maximum(splND.var_input[i])
        elseif vars[i]<minimum(splND.var_input[i])
            # warn("Accessing spline in extrapolated area, capping at min. Variable $i value: $(vars[i])")
            vars[i] = minimum(splND.var_input[i])
        end
        #Map to the spline index
        var_nums[i] = splND.m_vars[i] * vars[i] + splND.b_vars[i]
    end
    response = splND.spl_response[var_nums...]
    # g = gradient(splND, var_nums...)

    return response#, g
end

"""Not ready yet"""
function plotNDtable(tableND)

    for i = 1:length(tableND.response_names)
        PyPlot.figure("$(tableND.response_names[i])_vs_$(tableND.var_names[1]),$(tableND.var_names[j])")

        for j = 1:length(tableND.var_names)
            # plot aoa and response against each other variable
        end
    end

end

"""Internal: Break up functions calling airfoilpreppy for clarity,
handles aoa extraction out of the ND array to feed into airfoilpreppy
then puts it back into the correct ND array format for b-splining"""
function afpreppy_wrap3(NDtable, coord, grid_alphas, r_over_R, c_over_r, TSR, CDmax, var_indices)
    # var_indices for airfoil data should be Re, Mach, then whatever
    var_indices = round.(Int, var_indices)
    idx_Re = var_indices[1]
    idx_M = var_indices[2]
    #TODO: match input variable names to correct index instead of assuming
    Re = NDtable.var_input[2][idx_Re] #Re assumed to be second variable
    M = NDtable.var_input[3][idx_M]
    alpha = NDtable.var_input[1] #AOA assumed to be in first variable

    cl = NDtable.response_values[1][:, var_indices...] #Assumed to be first response
    cd = NDtable.response_values[2][:, var_indices...] #Assumed to be second response
    cm = NDtable.response_values[3][:, var_indices...] #Assumed to be 3rd response
    conv = NDtable.response_values[4][:, var_indices...] #Assumed to be 3rd response

    cl2 = []
    cd2 = []
    cm2 = []
    alpha2 = []

    # build good data
    i2 = 1
    for i = 1:length(cl)
        if conv[i]==true
            push!(cl2, cl[i])
            push!(cd2, cd[i])
            push!(cm2, cm[i])
            push!(alpha2, alpha[i])
            i2 += 1
        end
    end

    # Warn if the number of converged points is less than half
    if i2 < (length(cl) / 2)
        @warn("Percent of converged solutions is $(i2 / length(cl) * 100)%")
    end
    # PyPlot.figure("$Re $M")
    # PyPlot.plot(alpha2, cl2)
    polar = Polar(Re, alpha2, cl2, cd2, cm2, x=coord[:,1], y=coord[:,2])
    # 3D corrected Polar
    #especially too high or low aoa for the conditions, possibly pop out data, then spline and resample?
    liftslope, zeroliftangle, aoafit, clfit = fitliftslope(alpha2, cl2)
    aoaclmaxlinear, _ = findclmaxlinear(alpha2, cl2, liftslope, zeroliftangle; tol=0.1, interpolate=true)
    aoaclminlinear, _ = findclmaxlinear(alpha2, -cl2, liftslope, zeroliftangle; tol=0.1, interpolate=true)

    if aoaclmaxlinear<aoaclminlinear
        @warn("$aoaclmaxlinear max <$aoaclminlinear min degrees for linear region, correcting with min and max converged aoas (deg)")
        aoaclmaxlinear = maximum(alpha2)
        aoaclminlinear = minimum(alpha2)
    end

    # println("min: $aoaclminlinear")
    # println("max: $aoaclmaxlinear")

    newpolar = correction3D(polar, r_over_R, c_over_r, TSR,
                                alpha_linear_min=aoaclminlinear,
                                alpha_linear_max=aoaclmaxlinear,
                                alpha_max_corr=maximum(alpha2))

    # Extrapolated polar
    extrap_polar = extrapolate(newpolar, CDmax; nalpha = 40)

    cl = extrap_polar.init_cl
    cd = extrap_polar.init_cd
    cm = extrap_polar.init_cm
    alpha_extrap = extrap_polar.init_alpha
    alpha_extrap2 = copy(extrap_polar.init_alpha)

    #Remove elements if duplicated aoa
    j = 1
    for i = 2:length(alpha_extrap2)
        if alpha_extrap2[i] == alpha_extrap2[i-j]
            deleteat!(alpha_extrap, i - j)
            deleteat!(cl, i - j)
            deleteat!(cd, i - j)
            deleteat!(cm, i - j)
            j += 1 #update index for deleting in array
        end
    end

    clspl = Dierckx.Spline1D(alpha_extrap, cl, bc="nearest") # Evaluate at alphas that were specified to keep the 3D gridded spline consistent
    clgrid_alphas = clspl(grid_alphas)

    cdspl = Dierckx.Spline1D(alpha_extrap, cd, bc="nearest") # Evaluate at alphas that were specified to keep the 3D gridded spline consistent
    cdgrid_alphas = cdspl(grid_alphas)

    cmspl = Dierckx.Spline1D(alpha_extrap, cm, bc="nearest") # Evaluate at alphas that were specified to keep the 3D gridded spline consistent
    cmgrid_alphas = cmspl(grid_alphas)

    return clgrid_alphas, cdgrid_alphas, cmgrid_alphas
end

"""
    `NDTable_correction3D_extrap(NDtable, r_over_R, c_over_r, TSR;grid_alphas=[i for i in -180:1.0:180])`

runs airfoilprepy for each aoa vs cl, cd, cm, etc contained in a TableND object

Parameters
----------
NDtable: TableND
    a TableND object
r_over_R: Float
    blade radial position
c_over_r: Float
    chord to radius ratio at radial position
TSR: Float
    tip speed ratio: wind turbine analysis definition
grid_alphas: Array
    linearly space alphas for response value splines

Returns
-------
tableND : TableND
    a new TableND object

Notes
-----
does include some robust measures to get rid of duplicate points, non-converged airfoil data

"""
function NDTable_correction3D_extrap(NDtable, r_over_R, c_over_r, TSR;grid_alphas=[i for i in -180:1.0:180], CDmax = 1.3)
    #Create array of indices to correctly access each cl curve
    var_indices = [] # Array{Array{Int64, length(var_input)}, 1}(length(var_input))
    for i = 2:length(NDtable.var_input) #skip first dimension,  assumed to be AOA
        push!(var_indices, range(1, stop=length(NDtable.var_input[i]), length=length(NDtable.var_input[i])))
    end
    map_in = genMapInput(var_indices) #everything except AOA

    coord = zeros(10, 2) #TODO? airfoil not included here

    function afpreppy_wrap2(var_indices...)
        cl, cd, cm = afpreppy_wrap3(NDtable, coord, grid_alphas, r_over_R, c_over_r, TSR, CDmax, var_indices)
        return (cl, cd, cm)
    end

    response_values = map(afpreppy_wrap2, map_in...) #TODO: Replace with pmap for parallelization

    cl = [tup[1] for tup in response_values]
    cd = [tup[2] for tup in response_values]
    cm = [tup[3] for tup in response_values]

    cl2 = zeros(length(grid_alphas), prod(size(NDtable.response_values[1])[2:end]))
    cd2 = similar(cl2) * 0.0
    cm2 = similar(cl2) * 0.0
    response_values_extrap = []

    for i = 1:length(grid_alphas)
        cl2[i, :] = [aoa[i] for aoa in cl]
        cd2[i, :] = [aoa[i] for aoa in cd]
        cm2[i, :] = [aoa[i] for aoa in cm]
    end
    cl2 = reshape(cl2, length(grid_alphas), size(NDtable.response_values[1])[2:end]...)
    cd2 = reshape(cd2, length(grid_alphas), size(NDtable.response_values[1])[2:end]...)
    cm2 = reshape(cm2, length(grid_alphas), size(NDtable.response_values[1])[2:end]...)

    # Reshape to be a float of floats(size(variable_inputs))
    response_values2 = Array{Array{Float64, length(NDtable.var_input)}, 1}(undef, length(NDtable.response_values))
    response_values2[1] = cl2
    response_values2[2] = cd2
    response_values2[3] = cm2
    response_values2[4] = ones(size(cm2))

    #update the variable input for the extrapolated aoa
    var_input = (grid_alphas, NDtable.var_input[2:end]...)

    return TableND(response_values2, NDtable.response_names, var_input, NDtable.var_names)
end #NDTable_correction3D_extrap


text:
struct BlockRange{N,R<:NTuple{N,AbstractUnitRange{Int}}} <: AbstractArray{Block{N,Int},N}
    indices::R
    BlockRange{N,R}(inds::R) where {N,R} = new{N,R}(inds)
end

# The following is adapted from Julia v0.7 base/multidimensional.jl
# definition of CartesianRange

# deleted code that isn't used, such as 0-dimensional case
"""
    BlockRange(startblock, stopblock)

represents a cartesian range of blocks.

The relationship between `Block` and `BlockRange` mimicks the relationship between
`CartesianIndex` and `CartesianRange`.
"""
BlockRange

BlockRange(inds::NTuple{N,AbstractUnitRange{Int}}) where {N} =
    BlockRange{N,typeof(inds)}(inds)
BlockRange(inds::Vararg{AbstractUnitRange{Int},N}) where {N} =
    BlockRange(inds)

(:)(start::Block{1}, stop::Block{1}) = BlockRange((first(start.n):first(stop.n),))
(:)(start::Block, stop::Block) = throw(ArgumentError("Use `BlockRange` to construct a cartesian range of blocks"))
Base.BroadcastStyle(::Type{<:BlockRange{1}}) = DefaultArrayStyle{1}()
broadcasted(::DefaultArrayStyle{1}, ::typeof(Block), r::UnitRange) = Block(first(r)):Block(last(r))
broadcasted(::DefaultArrayStyle{1}, ::typeof(Int), block_range::BlockRange{1}) = first(block_range.indices)

# AbstractArray implementation
axes(iter::BlockRange{N,R}) where {N,R} = map(axes1, iter.indices)
Base.IndexStyle(::Type{BlockRange{N,R}}) where {N,R} = IndexCartesian()
@inline function Base.getindex(iter::BlockRange{N,<:NTuple{N,Base.OneTo}}, I::Vararg{Int, N}) where {N}
    @boundscheck checkbounds(iter, I...)
    Block(I)
end
@inline function Base.getindex(iter::BlockRange{N,R}, I::Vararg{Int, N}) where {N,R}
    @boundscheck checkbounds(iter, I...)
    Block(I .- first.(axes1.(iter.indices)) .+ first.(iter.indices))
end

@inline function iterate(iter::BlockRange)
    iterfirst, iterlast = first(iter), last(iter)
    if any(map(>, iterfirst.n, iterlast.n))
        return nothing
    end
    iterfirst, iterfirst
end
@inline function iterate(iter::BlockRange, state)
    nextstate = Block(inc(state.n, first(iter).n, last(iter).n))
    nextstate.n[end] > last(iter.indices[end]) && return nothing
    nextstate, nextstate
end

# increment & carry
@inline inc(::Tuple{}, ::Tuple{}, ::Tuple{}) = ()
@inline inc(state::Tuple{Int}, start::Tuple{Int}, stop::Tuple{Int}) = (state[1]+1,)
@inline function inc(state, start, stop)
    if state[1] < stop[1]
        return (state[1]+1,tail(state)...)
    end
    newtail = inc(tail(state), tail(start), tail(stop))
    (start[1], newtail...)
end

# 0-d cartesian ranges are special-cased to iterate once and only once
iterate(iter::BlockRange{0}, done=false) = done ? nothing : (Block(), true)

size(iter::BlockRange) = map(dimlength, first(iter).n, last(iter).n)
dimlength(start, stop) = stop-start+1

length(iter::BlockRange) = prod(size(iter))

first(iter::BlockRange) = Block(map(first, iter.indices))
last(iter::BlockRange)  = Block(map(last, iter.indices))

@inline function in(i::Block{N}, r::BlockRange{N}) where {N}
    _in(true, i.n, first(r).n, last(r).n)
end
_in(b, ::Tuple{}, ::Tuple{}, ::Tuple{}) = b
@inline _in(b, i, start, stop) = _in(b & (start[1] <= i[1] <= stop[1]), tail(i), tail(start), tail(stop))


text:
import Pkg

function _to_packagespec_string(pkg::Dict{Symbol, String})
    kwargs_string = ""
    for (key, value) in pkg
        kwargs_string *= "$(key) = \"$(value)\", "
    end
    return "Pkg.PackageSpec(; $(kwargs_string))"
end

function _to_packagespec_string(pkgs::AbstractVector{<:AbstractDict})
    num_pkgs = length(pkgs)
    pkg_strings = Vector{String}(undef, num_pkgs)
    for i = 1:num_pkgs
        pkg_strings[i] = _to_packagespec_string(pkgs[i])
    end
    return "Pkg.Types.PackageSpec[$(join(pkg_strings, ", "))]"
end

function _generate_install_packages_content(config::Config)
    pkgs = config.pkgs
    no_test = config.no_test
    exclude_packages_from_sysimage = config.exclude_packages_from_sysimage
    pkg_names_to_import = Vector{String}(undef, 0)
    pkg_names_to_test = Vector{String}(undef, 0)
    for pkg in pkgs
        pkg_name = pkg[:name]
        if ( !(pkg_name in no_test) ) && ( !(pkg_name in exclude_packages_from_sysimage) )
            push!(pkg_names_to_test, pkg_name)
        end
    end
    pkgs_string = _to_packagespec_string(pkgs)
    lines = String[
        "import Pkg",
        "Pkg.add($(pkgs_string))",
        "for name in $(pkg_names_to_test) # pkg_names_to_test",
        "Pkg.add(name)",
        "Pkg.test(name)",
        "end",
        "Pkg.add(collect(values(Pkg.Types.stdlibs())))",
        "for (uuid, info) in Pkg.dependencies()",
        "Pkg.add(info.name)",
        "end",
        "for (uuid, info) in Pkg.dependencies()",
        "if info.name in $(pkg_names_to_test)",
        "project_file = joinpath(info.source, \"Project.toml\")",
        "test_project_file = joinpath(info.source, \"test\", \"Project.toml\")",
        "if ispath(project_file)",
        "project = Pkg.TOML.parsefile(project_file)",
        "if haskey(project, \"deps\")",
        "project_deps = project[\"deps\"]",
        "for entry in keys(project_deps)",
        "Pkg.add(entry)",
        "end",
        "end",
        "if haskey(project, \"extras\")",
        "project_extras = project[\"extras\"]",
        "for entry in keys(project_extras)",
        "Pkg.add(entry)",
        "end",
        "end",
        "end",
        "if ispath(test_project_file)",
        "test_project = Pkg.TOML.parsefile(test_project_file)",
        "if haskey(test_project, \"deps\")",
        "test_project_deps = project[\"deps\"]",
        "for entry in keys(test_project_deps)",
        "Pkg.add(entry)",
        "end",
        "end",
        "end",
        "end",
        "end",
        "for (uuid, info) in Pkg.dependencies()",
        "Pkg.add(info.name)",
        "end"
    ]
    content = join(lines, "\n") * "\n"
    return content
end


text:
struct BOCcos{T <: AbstractGNSS, M, N} <: AbstractGNSSBOCcos{T, M, N}
    system::T
end

function BOCcos(system::T, m, n) where T <: AbstractGNSS
    BOCcos{T, m, n}(system)
end

function get_system_string(s::BOCcos{T,M,N}) where {T,M,N}
    "BOCcos($(get_system_string(s.system)), $M, $N)"
end

"""
$(SIGNATURES)

Get codes of base GNSS system for BOCcos as a Matrix, where each
column represents a PRN.
"""
function get_codes(boc::AbstractGNSSBOCcos)
    get_codes(boc.system)
end

"""
$(SIGNATURES)

Get code length of base GNSS system for BOCcos.
"""
@inline function get_code_length(boc::AbstractGNSSBOCcos)
    get_code_length(boc.system)
end

"""
$(SIGNATURES)

Get secondary code length of base GNSS system for BOCcos.
"""
@inline function get_secondary_code_length(boc::AbstractGNSSBOCcos)
    get_secondary_code_length(boc.system)
end

"""
$(SIGNATURES)

Get center frequency of base GNSS system for BOCcos.
"""
@inline function get_center_frequency(boc::AbstractGNSSBOCcos)
    get_center_frequency(boc.system)
end

"""
$(SIGNATURES)

Get code frequency of base GNSS system for BOCcos.
"""
function get_code_frequency(boc::AbstractGNSSBOCcos{C, M, N}) where {C, M, N}
    N * get_code_frequency(boc.system)
end

"""
$(SIGNATURES)

Get subcarrier frequency of generic BOC GNSS system
"""
function get_subcarrier_frequency(boc::AbstractGNSSBOCcos{C, M, N}) where {C, M, N}
    M * get_code_frequency(boc.system)
end

"""
$(SIGNATURES)

Get data frequency of base GNSS system for BOCcos.
"""
function get_data_frequency(boc::AbstractGNSSBOCcos)
    get_data_frequency(boc.system)
end

"""
$(SIGNATURES)

Get code of BOC at
phase `phase` of PRN `prn`.
"""
Base.@propagate_inbounds function get_code(
    boc::AbstractGNSSBOCcos{C, M, N},
    phase,
    prn::Integer
) where {C, M, N}
    floored_phase = floor(Int, phase)
    floored_BOC_phase = floor(Int, phase * 2 * M / N)
    modded_floored_phase = mod(
        floored_phase,
        get_code_length(boc.system) * get_secondary_code_length(boc.system)
    )
    get_code_unsafe(boc.system, modded_floored_phase, prn) *
        (iseven(floored_BOC_phase) << 1 - 1)
end

"""
$(SIGNATURES)

Get code of type BOC at
phase `phase` of PRN `prn`. The phase will not be wrapped by the code
length. The phase has to be smaller than the code length.
"""
Base.@propagate_inbounds function get_code_unsafe(
    boc::AbstractGNSSBOCcos{C, M, N},
    phase,
    prn::Integer
) where {C, M, N}
    floored_phase = floor(Int, phase)
    floored_BOC_phase = floor(Int, phase * 2 * M / N)
    get_code_unsafe(boc.system, floored_phase, prn) *
        (iseven(floored_BOC_phase) << 1 - 1)
end

"""
$(SIGNATURES)
Get spectral power of generic BOC GNSS system
"""
function get_code_spectrum(s::AbstractGNSSBOCcos{<:AbstractGNSS, 0}, f)
    return get_code_spectrum_BPSK(get_code_frequency(s), f)
end
function get_code_spectrum(s::AbstractGNSSBOCcos, f)
    return get_code_spectrum_BOCcos(get_code_frequency(s), get_subcarrier_frequency(s), f)
end


text:
using LinearAlgebra, Distributions

param = :regular
θ_init = [0.1, -0.8, 1.5, 0.0, 0.3]
P_trgt = FitzhughDiffusion(param, θ_init...)

P_aux = [FitzhughDiffusionAux(param, θ_init..., t₀, u, T, v) for (t₀,T,u,v)
        in zip(obs.time[1:end-1], obs.time[2:end], obs.values[1:end-1], obs.values[2:end])]

L = @SMatrix [1. 0.]
Σ = @SMatrix [10^(-3)]

model_setup = DiffusionSetup(P_trgt, P_aux, PartObs())
set_observations!(model_setup, [L for _ in P_aux], [Σ for _ in P_aux],
                  obs.values, obs.time)
set_imputation_grid!(model_setup, 1/400)
set_x0_prior!(model_setup, KnownStartingPt(x0))
initialise!(eltype(x0), model_setup, Vern7(), false, NoChangePt(100))
set_auxiliary!(model_setup; skip_for_save=10^0, adaptive_prop=NoAdaptation())

mcmc_setup = MCMCSetup(
      Imputation(NoBlocking(), 0.975, Vern7()),
      ParamUpdate(MetropolisHastingsUpdt(), 1, θ_init,
                  UniformRandomWalk(0.5, true), ImproperPosPrior(),
                  UpdtAuxiliary(Vern7(), check_if_recompute_ODEs(P_aux, 1))
                  ),
      ParamUpdate(MetropolisHastingsUpdt(), 2, θ_init,
                  UniformRandomWalk(0.5, false), ImproperPrior(),
                  UpdtAuxiliary(Vern7(), check_if_recompute_ODEs(P_aux, 2))
                  ),
      ParamUpdate(MetropolisHastingsUpdt(), 3, θ_init,
                  UniformRandomWalk(0.5, true), ImproperPosPrior(),
                  UpdtAuxiliary(Vern7(), check_if_recompute_ODEs(P_aux, 3))
                  ),
      ParamUpdate(MetropolisHastingsUpdt(), 5, θ_init,
                  UniformRandomWalk(0.5, true), ImproperPosPrior(),
                  UpdtAuxiliary(Vern7(), check_if_recompute_ODEs(P_aux, 5))
                  ))

schedule = MCMCSchedule(1*10^4, [[1,2,3,4,5]],
                        (save=3*10^2, verbose=10^2, warm_up=100,
                         readjust=(x->x%100==0), fuse=(x->false)))

Random.seed!(4)
out = mcmc(mcmc_setup, schedule, model_setup)

using PyPlot
plot(out[1].time, out[1].paths[10])
scatter(obs...)

out[1].time
out[1].paths[3]

for j in [1,2,3,5]
    plot([out[2].θ_chain[i][j] for i in 1:length(out[2].θ_chain)])
end
cred_interval(x, p = 0.95) = quantile(x, [(1-p)/2, 1-(1-p)/2])
[cred_interval(getindex.(out[2].θ_chain, j)) for j in [1,2,3,5]]


text:
@testset "mcse.jl" begin
    samples = randn(100)

    @testset "results" begin
        result = @inferred(mcse(samples))
        @test result isa Float64
        @test result > 0

        for method in (:imse, :ipse, :bm)
            result = @inferred(mcse(samples; method=method))
            @test result isa Float64
            @test result > 0
        end
    end

    @testset "warning" begin
        for size in (51, 75, 100, 153)
            @test_logs (:warn,) mcse(samples; method=:bm, size=size)
        end
    end

    @testset "exception" begin
        @test_throws ArgumentError mcse(samples; method=:somemethod)
    end
end


text:
module TestStockTimeSeries
using AlphaVantage
using Test
using JSON3

TEST_SLEEP_TIME =  parse(Float64, get(ENV, "TEST_SLEEP_TIME", "15"))
MAX_TESTS = parse(Int64, get(ENV, "MAX_TESTS", "1"))

stock_time_series_functions = [:time_series_daily, :time_series_daily_adjusted, :time_series_weekly, :time_series_weekly_adjusted, :time_series_monthly, :time_series_monthly_adjusted]

stock_time_series_functions_test = vcat(:time_series_intraday, stock_time_series_functions[1:MAX_TESTS])

@testset "Stock Time Series" begin
    for f in stock_time_series_functions_test
        @eval begin
            testname = string($f)
            @testset "$testname" begin
                @testset "AlphaVantageResponse" begin
                    data = $f("MSFT")
                    @test isa(data, AlphaVantageResponse)
                end
                sleep(TEST_SLEEP_TIME + 2*rand())
                @testset "JSON" begin
                    data = $f("MSFT", datatype="json")
                    @test typeof(data) === Dict{String,Any}
                    @test length(data) === 2
                end
                sleep(TEST_SLEEP_TIME + 2*rand())
                @testset "CSV" begin
                    data = $f("MSFT", datatype="csv")
                    @test typeof(data) === Tuple{Array{Any, 2}, Array{AbstractString, 2}}
                    @test length(data) === 2
                end
                sleep(TEST_SLEEP_TIME + 2*rand())
                @testset "JSON3" begin
                    data = $f("MSFT", datatype="json", parser = x -> JSON3.read(x.body))
                    @test typeof(data) === JSON3.Object{Vector{UInt8}, Vector{UInt64}}
                    @test length(data) === 2
                end
            end
        end
        sleep(TEST_SLEEP_TIME + 2*rand()) #as to not overload the API
    end

    f = :time_series_intraday_extended
    @eval begin
        testname = string($f)
        @testset "$testname" begin
            data = $f("MSFT")
            @test typeof(data) === Tuple{Array{Any, 2}, Array{AbstractString, 2}}
            @test length(data) === 2
        end
    end
end

end # module


text:
# Autogenerated wrapper script for cddlib_jll for x86_64-apple-darwin
export libcdd, libcddgmp

using GMP_jll
JLLWrappers.@generate_wrapper_header("cddlib")
JLLWrappers.@declare_library_product(libcdd, "@rpath/libcdd.0.dylib")
JLLWrappers.@declare_library_product(libcddgmp, "@rpath/libcddgmp.0.dylib")
function __init__()
    JLLWrappers.@generate_init_header(GMP_jll)
    JLLWrappers.@init_library_product(
        libcdd,
        "lib/libcdd.0.dylib",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@init_library_product(
        libcddgmp,
        "lib/libcddgmp.0.dylib",
        RTLD_LAZY | RTLD_DEEPBIND,
    )

    JLLWrappers.@generate_init_footer()
end  # __init__()